Browse Source

Merge branch 'dev-烟台0301' into yantai_dev

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

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

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

Loading…
Cancel
Save