From f389a01fee6f92a489671344e01ef448947f74fa Mon Sep 17 00:00:00 2001
From: mk <2403457699@qq.com>
Date: Thu, 9 Mar 2023 22:47:45 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E8=8C=83=E5=9B=B4=E5=A4=9A?=
=?UTF-8?q?=E9=80=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/modules/workSys/articleTag/edit.vue | 113 +++++++-----------
1 file changed, 41 insertions(+), 72 deletions(-)
diff --git a/src/views/modules/workSys/articleTag/edit.vue b/src/views/modules/workSys/articleTag/edit.vue
index 3dfd76d76..25f49d911 100644
--- a/src/views/modules/workSys/articleTag/edit.vue
+++ b/src/views/modules/workSys/articleTag/edit.vue
@@ -24,7 +24,6 @@
>
-
@@ -54,7 +53,6 @@
取 消
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", //表单操作类型 add新增,edit编辑,detail详情
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){
+ } else {
this.endLoading();
- this.formData.agencyId = row.agencyList[0].agencyId;
- this.formData.orgIdPath = row.agencyList[0].orgIdPath;
- }else{
- return
}
} 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;