Browse Source

删除多余代码,重新搞了标签感觉很乱

dongming
mk 8 months ago
parent
commit
adeae3aef8
  1. 228
      src/views/modules/volunteer/LifeCircleManagement/add.vue

228
src/views/modules/volunteer/LifeCircleManagement/add.vue

@ -5,19 +5,15 @@
<el-form ref="ref_form" :inline="true" :model="formData" :rules="dataRule" class="form"> <el-form ref="ref_form" :inline="true" :model="formData" :rules="dataRule" class="form">
<el-row> <el-row>
<!-- <el-col :span="12">
<el-form-item label="所属组织" prop="agencyName" label-width="100px">
<el-input v-model.trim="formData.agencyName" size="small" clearable placeholder="请输入活动名称" :disabled="true"
class="u-item-width-normal"></el-input>
</el-form-item>
</el-col> -->
<el-col :span="12"> <el-col :span="12">
<el-form-item label="类型" prop="type" label-width="100px"> <el-form-item label="类型" prop="type" label-width="100px">
<!-- <el-cascader @change="handleChangeAgency" :options="options" :disabled="showdisabled" :props="{ checkStrictly: true }"></el-cascader>
<el-form-item label="类型" prop="type" label-width="100px"> -->
<el-cascader v-model="this.formData.type" @change="handleChangeAgency" :options="options" <el-cascader v-model="this.formData.type" @change="handleChangeAgency" :options="options"
:disabled="showdisabled" :props="{emitPath: false, :disabled="showdisabled" :props="{
multiple: false, }"></el-cascader> emitPath: false,
multiple: false,
}"></el-cascader>
</el-form-item> </el-form-item>
@ -28,16 +24,7 @@
:disabled="showdisabled" class="u-item-width-normal"></el-input> :disabled="showdisabled" class="u-item-width-normal"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- <el-col :span="12">
<el-form-item label="组织类型" label-width="100px" prop="orgType">
<el-select class="u-item-width-normal" v-model.trim="formData.orgType" placeholder="请选择"
clearable>
<el-option v-for="item in OrganizationaltypeList" :key="item.value" :label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col> -->
<el-col :span="24"> <el-col :span="24">
<el-form-item label="位置" prop="searchValue" label-width="100px" style="display: block"> <el-form-item label="位置" prop="searchValue" label-width="100px" style="display: block">
<div style="width: 634px"> <div style="width: 634px">
@ -65,30 +52,17 @@
:disabled="showdisabled" class="u-item-width-normal"></el-input> :disabled="showdisabled" class="u-item-width-normal"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- <el-col :span="12">
<div style="display: flex; ">
<div >
<div v-for="(item, index) in formData.tags" :label="index" :key="item.name" :prop=index style="display: flex;">
<el-form-item label="标签" prop="tags" label-width="100px" >
<el-input :disabled="showdisabled" v-model="formData.tags" placeholder="请输入(最多添加四个)" lass="u-item-width-normal"></el-input>
</el-form-item>
<div v-if="index > 0" @click="removeDomain(item)" style="color: blue; font-size: 12px; margin-top: 15px">删除
</div>
</div>
</div>
<div @click="addDomain" style="color: blue; font-size: 12px; margin-top: 15px">添加
</div>
<i class="el-icon-circle-plus" @click="addDomain" style="font-size: 20px; margin-top:7px;"></i>
</div>
</el-col> -->
<el-col :span="12"> <el-col :span="12">
<div v-if="formData.tags1" style="display: flex;"> <div v-if="tags1" style="display: flex;">
<div> <div>
<div v-for="(item, index) in formData.tags1" :key="item.name + index" <div v-for="(item, index) in tags1" :key="index"
style="display: flex;"> style="display: flex;">
<el-form-item label="标签" prop="tags1" label-width="100px"> <el-form-item label="标签" label-width="100px" :rules="[
<el-input :disabled="showdisabled" v-model="item.tab" placeholder="请输入(最多添加四个)" { required: true, message: '请输入', trigger: 'blur' },
class="u-item-width-normal"></el-input> ]">
<el-input :disabled="showdisabled" v-model="tags1[index].tag"
placeholder="请输入(最多添加四个)" class="u-item-width-normal"></el-input>
</el-form-item> </el-form-item>
<div v-if="index > 0" @click="removeDomain(index)" <div v-if="index > 0" @click="removeDomain(index)"
style="color: blue; font-size: 12px; margin-top: 15px"> style="color: blue; font-size: 12px; margin-top: 15px">
@ -122,28 +96,6 @@
:disabled="showdisabled" class="u-item-width-normal"></el-input> :disabled="showdisabled" class="u-item-width-normal"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- <el-form-item label="组织介绍" prop="introduction" label-width="100px" style="display: block">
<div class="item_width_1">
<el-input type="textarea" autosize placeholder="请填写组织介绍"
v-model.trim="formData.introduction" :autosize="{ minRows:4., maxRows: 10}">
</el-input>
</div>
</el-form-item> -->
<!--
<el-form-item label="志愿品牌" prop="brand" label-width="100px" style="display: block">
<div class="item_width_1">
<el-input type="textarea" autosize placeholder="请输入内容" v-model.trim="formData.brand"
:autosize="{ minRows:4., maxRows: 10}">
</el-input>
</div>
</el-form-item>
-->
<el-form-item label="优惠券上传" label-width="100px" prop="brandImg">
<template>
<upload-image :defaultFileList="formData.couponUrl" :limit="1" @change="onChangeFileList1"
@file-removed="removedImg"></upload-image>
</template>
</el-form-item>
</el-row></el-form> </el-row></el-form>
</div> </div>
<div class="div_btn"> <div class="div_btn">
@ -362,7 +314,6 @@
} }
], ],
fileList: [], fileList: [],
fileList1:[],
searchValue: "", searchValue: "",
OrganizationaltypeList: [], OrganizationaltypeList: [],
ServicetypeListName: [], ServicetypeListName: [],
@ -372,17 +323,14 @@
{ label: "学校", value: 3 }, { label: "学校", value: 3 },
], ],
tableDate: {}, tableDate: {},
tags1: [],
formData: formData:
{ {
couponUrl:"",
agencyName: "", agencyName: "",
linkman: "", linkman: "",
linkPhone: "", linkPhone: "",
workTime: "", workTime: "",
type: "", type: "",
tags1: [
{}
],
tags: "",// tags: "",//
agencyId: this.$store.state.user.agencyId, agencyId: this.$store.state.user.agencyId,
address: "",// address: "",//
@ -401,14 +349,20 @@
mounted() { mounted() {
this.formData.agencyId = this.$store.state.user.agencyId this.formData.agencyId = this.$store.state.user.agencyId
this.formData.agencyName = this.$store.state.user.agencyName this.formData.agencyName = this.$store.state.user.agencyName
this.listServerOrg() let { latitude, longitude } = this.$store.state.user;
if (!latitude || latitude == "" || latitude == "0") {
latitude = 39.9088810666821;
longitude = 116.39743841556731;
}
this.formData.latitude = latitude;
this.formData.longitude = longitude;
this.activityType()
}, },
methods: { methods: {
// //
async initForm(type, unitId) { async initForm(type, unitId) {
console.log(type, unitId,"i就理解哦i");
if (type == "info") { if (type == "info") {
this.showdisabled = true this.showdisabled = true
} }
@ -427,8 +381,9 @@
if (type == "edit") { if (type == "edit") {
await this.getTableDetail(unitId) await this.getTableDetail(unitId)
} }
if (type == "add") {
this.tags1.push({tag:''})
}
}, },
// //
handleChangeAgency(val) { handleChangeAgency(val) {
@ -444,7 +399,7 @@
this.fileList=[{fileUrl:res.data.attrs[0].url}] this.fileList=[{fileUrl:res.data.attrs[0].url}]
this.searchValue=res.data.address this.searchValue=res.data.address
this.fileList1=[{fileUrl:res.data.couponUrl}] this.fileList1=[{fileUrl:res.data.couponUrl}]
this.formData.tags1=res.data.tags.split(',').map(item => ({ tab: item.trim() })); this.tags1=res.data.tags.split(',').map(item => ({ tag: item.trim() }));
map.setCenter(this.formData.latitude, this.formData.longitude); map.setCenter(this.formData.latitude, this.formData.longitude);
map.setMarker(this.formData.latitude, this.formData.longitude); map.setMarker(this.formData.latitude, this.formData.longitude);
} else { } else {
@ -454,11 +409,8 @@
}, },
// //
addDomain() { addDomain() {
if (this.tags1.length < 4) {
this.tags1.push({ tab: '' });
if (this.formData.tags1.length < 4) {
this.formData.tags1.push({tab: '' });
} else { } else {
this.$message.error("最多添加4个标签"); this.$message.error("最多添加4个标签");
} }
@ -467,41 +419,23 @@
// //
removeDomain(item) { removeDomain(item) {
console.log(item); console.log(item);
this.formData.tags1.splice(item, 1); this.tags1.splice(item, 1);
// var index = this.formData.sponsors.indexOf(item)
// if (index !== -1) {
// this.formData.sponsors.splice(index, 1)
// this.tableDate = {}
// }
},
validateContent() {
// 使HTML
const textContent = this.stripHtml(this.formData.sumUp);
if (textContent.trim() === '') {
this.formData.sumUp = null;
}
},
stripHtml(html) {
const div = document.createElement('div');
div.innerHTML = html;
return div.textContent || div.innerText || '';
}, },
async activityType() {
this.$nextTick(() => {
handleOnlineRegistration(value) { if (!map) {
// this.initMap(this.formData.latitude, this.formData.longitude);
if (value) { console.log("map", map, this.formData.latitude, this.formData.longitude)
this.online = true;
this.formData.online = 1;
} else { } else {
this.online = false; map.setCenter(this.formData.latitude, this.formData.longitude);
this.formData.cutOffTime = '' map.setMarker(this.formData.latitude, this.formData.longitude);
this.formData.online = 0; console.log("mapmapmap", map)
} }
})
}, },
onChangeFileList(e) { onChangeFileList(e) {
console.log(e, 'sssssb');
this.fileList = e.length > 0 ? e.map(item => ({ this.fileList = e.length > 0 ? e.map(item => ({
fileType: '0', fileType: '0',
type: 'image', type: 'image',
@ -520,68 +454,15 @@
this.formData.coverPic = ''; this.formData.coverPic = '';
} }
}, },
onChangeFileList1(e) {
console.log(e, 'sssssb');
this.fileList1 = e.length > 0 ? e.map(item => ({
fileType: '0',
type:'image',
fileType: '0',
name:item.response.data.fileName,
fileUrl: item.response.data.url,
format: item.response.data.fileName.split('.').pop(),
url: item.response.data.url
})) : []; // efileList
if (e.length > 0) {
console.log(this.fileList,"this.fileList");
this.formData.couponUrl=this.fileList1[0].url;
console.log(this.formData.attrs,"this.fileList");
} else {
this.formData.coverPic = '';
}
},
removedImg() { removedImg() {
this.formData.coverPic = '' this.formData.coverPic = ''
}, },
onChangeImgs(e, rowIndex = 0) {
console.log('onChangeFileList', e)
if (e.length > 0) {
this.activityImgs = []
e.forEach(item => {
let ob = {
fileType: '0',
fileUrl: item.response.data.url
}
this.activityImgs.push(ob)
})
}
},
handleTimeChange(time) {
if (time) {
const startTimeArray = util.dateFormatter(time[0], 'time').split('-')
console.log(startTimeArray);
const endTimeArray = util.dateFormatter(time[1], 'time').split('-')
console.log(endTimeArray);
this.formData.startTime = startTimeArray[0] + '-' + startTimeArray[1] + '-' + startTimeArray[2]
this.formData.endTime = endTimeArray[0] + '-' + endTimeArray[1] + '-' + endTimeArray[2]
// this.startTimeShow = startTimeArray[0] + '' + startTimeArray[1] + '' + startTimeArray[2] + ''
// this.endTimeShow = endTimeArray[0] + '' + endTimeArray[1] + '' + endTimeArray[2] + ''
} else {
this.formData.startTime = ''
this.formData.endTime = ''
}
},
async handleComfirm() { async handleComfirm() {
if (this.formData.tags1) { if (this.tags1) {
let one=this.formData.tags1.map(item => item.tab).join(', ') let one = this.tags1.map(item => item.tag).join(', ')
this.formData.tags = one; this.formData.tags = one;
console.log(this.formData, "this.formData"); console.log(this.formData, "this.formData");
} }
@ -611,16 +492,6 @@
this.$message.error('请输入联系人'); this.$message.error('请输入联系人');
return; return;
} }
// if (this.formData.tabs.length === 0) {
// this.$message.error('');
// return;
// }
// if (!this.formData.serviceTypeList) {
// this.$message.error('');
// return;
// }
console.log(this.formData, "this.formData"); console.log(this.formData, "this.formData");
this.addActivity() this.addActivity()
}, },
@ -641,16 +512,10 @@
this.btnDisable = false this.btnDisable = false
this.$message.error(msg) this.$message.error(msg)
} }
}, },
handleCancle() { handleCancle() {
console.log("sdlkfjklsdf ");
this.$emit('showAddClose') this.$emit('showAddClose')
}, },
// init // init
@ -743,11 +608,7 @@
this.formData.address = selPosition.address + selPosition.name this.formData.address = selPosition.address + selPosition.name
this.searchValue = selPosition.address + selPosition.name this.searchValue = selPosition.address + selPosition.name
console.log(this.formData.latitude, this.formData.longitude, "this.formData.latitude, this.formData.longitude"); console.log(this.formData.latitude, this.formData.longitude, "this.formData.latitude, this.formData.longitude");
}, },
}, },
computed: { computed: {
dataRule() { dataRule() {
@ -760,7 +621,6 @@
], ],
searchValue: [ searchValue: [
{ required: true, message: '请选择地址', trigger: 'blur' }, { required: true, message: '请选择地址', trigger: 'blur' },
], ],
linkPhone: [ linkPhone: [
{ required: true, message: '联系电话不能为空', trigger: 'blur' }, { required: true, message: '联系电话不能为空', trigger: 'blur' },
@ -780,9 +640,6 @@
}, },
props: { props: {
}, },
destroyed() { destroyed() {
map = null map = null
@ -802,6 +659,7 @@
z-index: 20000; z-index: 20000;
} }
} }
.u-item-width-normal { .u-item-width-normal {
width: 222px; width: 222px;
} }

Loading…
Cancel
Save