Browse Source

Merge branch 'dev-烟台0301' into yantai_dev

dev-烟台0301
mk 3 years ago
parent
commit
0495090d28
  1. 304
      src/views/modules/workSys/articleTag/edit.vue

304
src/views/modules/workSys/articleTag/edit.vue

@ -1,277 +1,301 @@
<template> <template>
<div class="epidemic-form"> <div class="epidemic-form">
<div class="dialog-h-content scroll-h"> <div class="dialog-h-content scroll-h">
<el-form
<el-form ref="ref_form" ref="ref_form"
:inline="true" :inline="true"
:model="formData" :model="formData"
:rules="rules" :rules="rules"
:disabled="formType === 'detail'" :disabled="formType === 'detail'"
class="form"> class="form"
>
<el-form-item label="分类名称" <el-form-item
label="分类名称"
prop="tagName" prop="tagName"
label-width="150px" label-width="150px"
style="display: block"> style="display: block"
<el-input class="item_width_2" >
<el-input
class="item_width_2"
placeholder="请输入角色名称" placeholder="请输入角色名称"
style="width: 260px"
clearable clearable
v-model="formData.tagName"> v-model="formData.tagName"
>
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- :prop="'formData.'+'agencyList.' +'agencyId'" --> <!-- :prop="'formData.'+'agencyList.' +'agencyId'" -->
<el-form-item label="应用范围" <el-form-item
label="应用范围"
label-width="150px" label-width="150px"
prop="agencyId" prop="agencyId"
style="display: block"
> >
<!-- { checkStrictly: true, emitPath: false,children:'subAgencyList',label:'agencyName',value:'agencyId'} --> <!-- -->
<el-cascader ref="cascaderUnit" <el-cascader
ref="cascaderUnit"
style="width: 260px"
v-model="formData.agencyId" v-model="formData.agencyId"
:options="orgOptions" :options="orgOptions"
:props="optionProps" :props="{
checkStrictly: true,
emitPath: false,
children: 'subAgencyList',
label: 'agencyName',
value: 'agencyId',
}"
clearable clearable
@change="cascaderClick" @change="cascaderClick"
/> />
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<div class="form_div_btn"> <div class="form_div_btn">
<el-button size="small" <el-button size="small" @click="handleCancle"> </el-button>
@click="handleCancle"> </el-button> <el-button
<el-button v-if="formType != 'detail'" v-if="formType != 'detail'"
size="small" size="small"
type="primary" type="primary"
:disabled="btnDisable" :disabled="btnDisable"
@click="handleComfirm"> </el-button> @click="handleComfirm"
> </el-button
>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { Loading } from "element-ui"; // Loading
import { requestPost, requestGet } from "@/js/dai/request";
import { Loading } from 'element-ui' // Loading let loading; //
import { requestPost, requestGet } from '@/js/dai/request'
let loading //
export default { export default {
data() { data() {
return { return {
formType: 'add', // addeditdetail formType: "add", // addeditdetail
btnDisable: false, btnDisable: false,
orgOptions: [], orgOptions: [],
optionProps: {
checkStrictly: true,
expandTrigger: 'hover',
value: 'agencyId',
label: 'agencyName',
children: 'subAgencyList',
},
agencyIdArray: [], agencyIdArray: [],
tagId:'', tagId: "",
formData: { formData: {
tagName: '', tagName: "",
agencyId:'', agencyId: "",
orgIdPath:'' orgIdPath: "",
}, },
formDatam: [], formDatam: [],
rules: { rules: {
tagName: [ tagName: [
{ required: true, message: '分类名称不能为空', trigger: 'blur' } { required: true, message: "分类名称不能为空", trigger: "blur" },
], ],
agencyId: [ agencyId: [
{ required: true, message: '应用范围不能为空', trigger: 'blur' } { required: true, message: "应用范围不能为空", trigger: "blur" },
] ],
}, },
} };
}, },
components: {}, components: {},
async mounted() { async mounted() {
await this.getOrgTreeList() await this.getOrgTreeList();
}, },
methods: { methods: {
async initForm(type, row) { async initForm(type, row) {
this.startLoading()
this.formType = type
console.log(row); console.log(row);
if(type!='add'){ this.startLoading();
this.formData.tagName = row.tagName this.formType = type;
this.tagId = row.id if (type != "add") {
this.formData.tagName = row.tagName;
this.tagId = row.id;
if (row.agencyList.length > 1) { if (row.agencyList.length > 1) {
this.formData.agencyId = row.agencyList[0].orgIdPath.split(':')[1] this.formData.agencyId = row.agencyList[0].pid;
this.formData.orgIdPath = row.agencyList[0].orgIdPath.split(':')[0] +':'+ row.agencyList[0].orgIdPath.split(':')[1] if (row.agencyList[0].orgIdPath.split(":").length == 2) {
this.formData.orgIdPath = row.agencyList[0].orgIdPath.split(":")[0];
} else { } else {
this.formData.agencyId = row.agencyList[0].agencyId this.formData.orgIdPath =
this.formData.orgIdPath = row.agencyList[0].orgIdPath row.agencyList[0].orgIdPath.split(":")[0] +
":" +
row.agencyList[0].orgIdPath.split(":")[1];
} }
} else if(row.agencyList.length == 0){
this.endLoading();
this.formData.agencyId = row.agencyList[0].agencyId;
this.formData.orgIdPath = row.agencyList[0].orgIdPath;
} }
this.endLoading() } else {
}
this.endLoading();
}, },
async getOrgTreeList() { async getOrgTreeList() {
this.dataListLoading = true this.dataListLoading = true;
// this.$http const url = "/gov/org/customeragency/agencylist";
// .post('gov/org/customeragency/agencylist', { customerId: this.customerId})
// .then(({ data: res }) => {
// if (res.code !== 0) {
// return this.$message.error(res.msg)
// } else {
// console.log('', res.data)
// let { agencyList, subAgencyList } = res.data
// const _arr = [{ ...agencyList, subAgencyList: [...subAgencyList] }]
// this.orgOptions = this.deepTree(_arr)
// }
// })
// .catch(() => {
// this.dataListLoading = false
// return this.$message.error('')
// })
const url = '/gov/org/customeragency/agencylist'
// const url = 'http://yapi.elinkservice.cn/mock/102/gov/org/agency/agencylist' // const url = 'http://yapi.elinkservice.cn/mock/102/gov/org/agency/agencylist'
let params = { let params = {
customerId: this.customerId customerId: this.customerId,
} };
const { data, code, msg } = await requestPost(url, params) const { data, code, msg } = await requestPost(url, params);
if (code === 0) { if (code === 0) {
this.options = [] this.options = [];
this.agencyIdArray.length = [] this.agencyIdArray.length = [];
this.orgOptions.push(data) this.orgOptions.push(data);
} else { } else {
this.$message.error(msg) this.$message.error(msg);
} }
this.dataListLoading = false this.dataListLoading = false;
}, },
deepTree(arr) { deepTree(arr) {
if (Array.isArray(arr)) { if (Array.isArray(arr)) {
return arr.map(item => { return arr.map((item) => {
return { return {
...item, ...item,
subAgencyList: item.subAgencyList.length > 0 && this.deepTree(item.subAgencyList) || null subAgencyList:
} (item.subAgencyList.length > 0 &&
}) this.deepTree(item.subAgencyList)) ||
null,
};
});
} }
}, },
cascaderClick() { cascaderClick() {
let obj = this.$refs["cascaderUnit"].getCheckedNodes()[0].data let obj = this.$refs["cascaderUnit"].getCheckedNodes()[0].data;
this.formDatam = [] this.formDatam = [];
if (obj) { if (obj) {
if (obj.level === "street") { if (obj.level === "street") {
for (let i in obj.subAgencyList) { for (let i in obj.subAgencyList) {
this.formDatam.push({'agencyId':obj.subAgencyList[i].agencyId,'orgIdPath':obj.subAgencyList[i].orgIdPath}) this.formDatam.push({
agencyId: obj.subAgencyList[i].agencyId,
orgIdPath: obj.subAgencyList[i].orgIdPath,
pid: obj.subAgencyList[i].pid,
agencyName: obj.subAgencyList[i].agencyName,
});
} }
} else { console.log(this.formDatam);
this.formDatam.push({'agencyId':obj.agencyId,'orgIdPath':obj.orgIdPath}) } else if (obj.level === "district") {
for (let i in obj.subAgencyList) {
if (obj.subAgencyList[i].subAgencyList != null) {
for (let j in obj.subAgencyList[i].subAgencyList) {
this.formDatam.push({
agencyId:obj.subAgencyList[i].subAgencyList[j].agencyId,
orgIdPath:obj.subAgencyList[i].subAgencyList[j].orgIdPath,
pid: obj.subAgencyList[i].pid,
agencyName: obj.subAgencyList[i].subAgencyList[j].agencyName,
});
}
}
}
console.log(this.formDatam);
} else if (obj.level === "community") {
this.formDatam.push({
agencyId: obj.agencyId,
orgIdPath: obj.orgIdPath,
agencyName: obj.agencyName,
pid: obj.pid
});
} }
} else { } else {
this.formDatam = [] this.formDatam = [];
} }
}, },
handleComfirm() { handleComfirm() {
this.$refs['ref_form'].validate((valid, messageObj) => { this.$refs["ref_form"].validate((valid, messageObj) => {
if (!valid) { if (!valid) {
app.util.validateRule(messageObj) app.util.validateRule(messageObj);
} else { } else {
this.addNat() this.addNat();
} }
});
})
}, },
async addNat() { async addNat() {
this.btnDisable = true this.btnDisable = true;
setTimeout(() => { setTimeout(() => {
this.btnDisable = false this.btnDisable = false;
}, 5000) }, 5000);
let url = '' let url = "";
if (this.formType === 'add') { if (this.formType === "add") {
url = '/gov/voice/tag/save' url = "/gov/voice/tag/save";
} else { } else {
url = '/gov/voice/tag/update' url = "/gov/voice/tag/update";
} }
const { tagName} = this.formData const { tagName } = this.formData;
let params = {} let params = {};
if (this.formType != "add") {
if(this.formType != 'add'){
if (this.formDatam.length == 0) { if (this.formDatam.length == 0) {
this.formDatam.push({'agencyId':this.formData.agencyId,'orgIdPath':this.formData.orgIdPath}) this.formDatam.push({
agencyId: this.formData.agencyId,
orgIdPath: this.formData.orgIdPath,
});
} }
params = { params = {
tagName, tagName,
agencyList: this.formDatam, agencyList: this.formDatam,
id:this.tagId id: this.tagId,
} };
} else { } else {
if (this.formDatam.length == 0) {
this.formDatam.push({
agencyId: this.formData.agencyId,
orgIdPath: this.formData.orgIdPath,
});
}
params = { params = {
tagName, tagName,
agencyList: this.formDatam, agencyList: this.formDatam,
};
} }
} console.log(params);
const { data, code, msg } = await requestPost(url,params) const { data, code, msg } = await requestPost(url, params);
if (code === 0) { if (code === 0) {
this.$message({ this.$message({
type: 'success', type: "success",
message: '操作成功' message: "操作成功",
}) });
this.resetData() this.resetData();
this.$emit('dialogOk') this.$emit("dialogOk");
this.btnDisable = false this.btnDisable = false;
} else { } else {
this.btnDisable = false this.btnDisable = false;
this.$message.error(msg) this.$message.error(msg);
} }
}, },
handleCancle() { handleCancle() {
this.resetData() this.resetData();
this.$emit('dialogCancle') this.$emit("dialogCancle");
}, },
resetData() { resetData() {
this.formData = { this.formData = {
tagName: '', tagName: "",
} };
this.$refs['ref_form'].resetFields() this.$refs["ref_form"].resetFields();
}, },
// //
startLoading() { startLoading() {
loading = Loading.service({ loading = Loading.service({
lock: true, // lock: true, //
text: '正在加载……', // text: "正在加载……", //
background: 'rgba(0,0,0,.7)' // background: "rgba(0,0,0,.7)", //
}) });
}, },
// //
endLoading() { endLoading() {
// clearTimeout(timer); // clearTimeout(timer);
if (loading) { if (loading) {
loading.close() loading.close();
}
} }
}, },
computed: {
}, },
computed: {},
props: { props: {
customerId: { customerId: {
type: String, type: String,
default:"" default: "",
} },
} },
} };
</script> </script>

Loading…
Cancel
Save