Browse Source

标签范围多选

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

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

@ -24,7 +24,6 @@
>
</el-input>
</el-form-item>
<!-- :prop="'formData.'+'agencyList.' +'agencyId'" -->
<el-form-item
label="应用范围"
label-width="150px"
@ -34,18 +33,18 @@
<!-- -->
<el-cascader
ref="cascaderUnit"
style="width: 260px"
style="width: 260px;"
v-model="formData.agencyId"
:options="orgOptions"
collapse-tags
:props="{
checkStrictly: true,
multiple: true,
emitPath: false,
children: 'subAgencyList',
label: 'agencyName',
value: 'agencyId',
}"
clearable
@change="cascaderClick"
/>
</el-form-item>
</el-form>
@ -54,7 +53,6 @@
<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"
@ -68,7 +66,7 @@
<script>
import { Loading } from "element-ui"; // Loading
import { requestPost, requestGet } from "@/js/dai/request";
import nextTick from "dai-js/tools/nextTick";
let loading; //
export default {
data() {
@ -76,11 +74,12 @@ export default {
formType: "add", // addeditdetail
btnDisable: false,
orgOptions: [],
agencyIdArray: [],
tagId: "",
sarr: [],
targetObj: {},
formData: {
tagName: "",
agencyId: "",
agencyId: [],
orgIdPath: "",
},
formDatam: [],
@ -105,24 +104,17 @@ export default {
this.startLoading();
this.formType = type;
if (type != "add") {
console.log(this.formData);
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];
this.formData.agencyId = [];
if (row.agencyList.length >= 1) {
for (let i in row.agencyList) {
this.formData.agencyId.push(row.agencyList[i].agencyId);
}
} else if(row.agencyList.length == 1){
this.endLoading();
this.formData.agencyId = row.agencyList[0].agencyId;
this.formData.orgIdPath = row.agencyList[0].orgIdPath;
} else {
return
this.endLoading();
}
} else {
}
@ -139,64 +131,26 @@ export default {
const { data, code, msg } = await requestPost(url, params);
if (code === 0) {
this.options = [];
this.agencyIdArray.length = [];
this.orgOptions.push(data);
} else {
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 = [];
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,
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,
});
}
getLastItem(list, vals, key) {
let LIST = list || [];
for (let item of LIST) {
// console.log(item[key]);
for (let i of vals) {
if (item[key] === i) {
this.sarr.push(item);
break;
} else {
this.getLastItem(item.subAgencyList, vals, key);
}
}
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 = [];
}
},
handleComfirm() {
@ -210,6 +164,21 @@ export default {
},
async addNat() {
this.newArr = [];
this.formDatam = [];
const map = new Map();
this.getLastItem(this.orgOptions, this.formData.agencyId, "agencyId");
this.newArr = this.sarr.filter(
(v) => !map.has(v.agencyId) && map.set(v.agencyId, 1)
);
for (let i in this.newArr) {
this.formDatam.push({
agencyId: this.newArr[i].agencyId,
orgIdPath: this.newArr[i].orgIdPath,
pid: this.newArr[i].pid,
agencyName: this.newArr[i].agencyName,
});
}
this.btnDisable = true;
setTimeout(() => {
this.btnDisable = false;

Loading…
Cancel
Save