|
@@ -100,483 +100,496 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { nextTick, onMounted, ref, watch } from "vue";
|
|
|
|
-import { useAppStore } from "~src/store";
|
|
|
|
-import { deepClone, getArrValue, getObjValue, isNullES } from "js-fast-way";
|
|
|
|
-import mainApi from "~api/project/project";
|
|
|
|
-import treeApi from "~api/wbs/tree";
|
|
|
|
|
|
+import { nextTick, onMounted, ref, watch } from 'vue'
|
|
|
|
+import { useAppStore } from '~src/store'
|
|
|
|
+import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
|
+import mainApi from '~api/project/project'
|
|
|
|
+import treeApi from '~api/wbs/tree'
|
|
|
|
|
|
//缓存
|
|
//缓存
|
|
-const store = useAppStore();
|
|
|
|
|
|
+const store = useAppStore()
|
|
|
|
|
|
//双向绑定
|
|
//双向绑定
|
|
-const modelData = defineModel("modelValue", {
|
|
|
|
|
|
+const modelData = defineModel('modelValue', {
|
|
default: {},
|
|
default: {},
|
|
-});
|
|
|
|
|
|
+})
|
|
|
|
|
|
//监听数据
|
|
//监听数据
|
|
-const formModel = ref({});
|
|
|
|
|
|
+const formModel = ref({})
|
|
watch(
|
|
watch(
|
|
() => modelData.value,
|
|
() => modelData.value,
|
|
(data) => {
|
|
(data) => {
|
|
- formModel.value = data;
|
|
|
|
|
|
+ formModel.value = data
|
|
},
|
|
},
|
|
- { immediate: true, deep: true }
|
|
|
|
-);
|
|
|
|
|
|
+ { immediate: true, deep: true },
|
|
|
|
+)
|
|
|
|
|
|
//监听
|
|
//监听
|
|
-const userInfo = ref(store.getUserInfo);
|
|
|
|
|
|
+const userInfo = ref(store.getUserInfo)
|
|
watch(
|
|
watch(
|
|
() => store.getUserInfo,
|
|
() => store.getUserInfo,
|
|
(info) => {
|
|
(info) => {
|
|
- userInfo.value = info;
|
|
|
|
|
|
+ userInfo.value = info
|
|
},
|
|
},
|
|
- { immediate: true, deep: true }
|
|
|
|
-);
|
|
|
|
|
|
+ { immediate: true, deep: true },
|
|
|
|
+)
|
|
|
|
|
|
//渲染完成
|
|
//渲染完成
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- getWbsTreeList();
|
|
|
|
-});
|
|
|
|
|
|
+ getWbsTreeList()
|
|
|
|
+})
|
|
|
|
|
|
//顶部类型
|
|
//顶部类型
|
|
-const templateType = ref(1);
|
|
|
|
|
|
+const templateType = ref(1)
|
|
const templateTypeData = [
|
|
const templateTypeData = [
|
|
- { value: 1, label: "质检" },
|
|
|
|
- { value: 2, label: "试验" },
|
|
|
|
- { value: 3, label: "计量" },
|
|
|
|
- { value: 5, label: "征拆" },
|
|
|
|
-];
|
|
|
|
|
|
+ { value: 1, label: '质检' },
|
|
|
|
+ { value: 2, label: '试验' },
|
|
|
|
+ { value: 3, label: '计量' },
|
|
|
|
+ { value: 5, label: '征拆' },
|
|
|
|
+]
|
|
|
|
|
|
//树配置
|
|
//树配置
|
|
-const leftTreeRef = ref(null);
|
|
|
|
-const rightTreeRef = ref(null);
|
|
|
|
|
|
+const leftTreeRef = ref(null)
|
|
|
|
+const rightTreeRef = ref(null)
|
|
const treeProps = {
|
|
const treeProps = {
|
|
- children: "children",
|
|
|
|
- label: "title",
|
|
|
|
-};
|
|
|
|
|
|
+ children: 'children',
|
|
|
|
+ label: 'title',
|
|
|
|
+}
|
|
|
|
|
|
//获取WBS树列表
|
|
//获取WBS树列表
|
|
-const wbsId = ref("");
|
|
|
|
-const wbsTreeList = ref([]);
|
|
|
|
-const isLoading = ref(false);
|
|
|
|
|
|
+const wbsId = ref('')
|
|
|
|
+const wbsTreeList = ref([])
|
|
|
|
+const isLoading = ref(false)
|
|
|
|
+const selectData = ref({
|
|
|
|
+ referenceWbsTemplateId:'', //质检
|
|
|
|
+ referenceWbsTemplateIdLar:'', //征拆
|
|
|
|
+ referenceWbsTemplateIdMeter:'', //计量
|
|
|
|
+ referenceWbsTemplateIdTrial:'', //试验
|
|
|
|
+},
|
|
|
|
+
|
|
|
|
+)
|
|
const getWbsTreeList = async () => {
|
|
const getWbsTreeList = async () => {
|
|
- isLoading.value = true;
|
|
|
|
- const type = templateType.value;
|
|
|
|
- const { data } = await mainApi.findWbsTreeList(type);
|
|
|
|
|
|
+ isLoading.value = true
|
|
|
|
+ const type = templateType.value
|
|
|
|
+ const { data } = await mainApi.findWbsTreeList(type)
|
|
// 格式化数据
|
|
// 格式化数据
|
|
- const res = getObjValue(data);
|
|
|
|
|
|
+ const res = getObjValue(data)
|
|
let arr = [
|
|
let arr = [
|
|
- { label: "公有库", data: [] },
|
|
|
|
- { label: "私有库", data: [] },
|
|
|
|
- ];
|
|
|
|
|
|
+ { label: '公有库', data: [] },
|
|
|
|
+ { label: '私有库', data: [] },
|
|
|
|
+ ]
|
|
const wbsInfos = getArrValue(res.wbsInfos),
|
|
const wbsInfos = getArrValue(res.wbsInfos),
|
|
- wbsPrivates = getArrValue(res.wbsTreePrivates);
|
|
|
|
|
|
+ wbsPrivates = getArrValue(res.wbsTreePrivates)
|
|
// 公有库
|
|
// 公有库
|
|
wbsInfos.forEach((item) => {
|
|
wbsInfos.forEach((item) => {
|
|
- item.value = item.id;
|
|
|
|
- item.label = item.wbsName;
|
|
|
|
- });
|
|
|
|
- arr[0].data = wbsInfos;
|
|
|
|
|
|
+ item.value = item.id
|
|
|
|
+ item.label = item.wbsName
|
|
|
|
+ })
|
|
|
|
+ arr[0].data = wbsInfos
|
|
// 私有库
|
|
// 私有库
|
|
wbsPrivates.forEach((item) => {
|
|
wbsPrivates.forEach((item) => {
|
|
- item.label = item.projectName;
|
|
|
|
- item.value = item.wbsId + "," + item.projectId;
|
|
|
|
- });
|
|
|
|
- arr[1].data = wbsPrivates;
|
|
|
|
- wbsTreeList.value = arr;
|
|
|
|
- console.log(wbsTreeList.value, " wbsTreeList.value");
|
|
|
|
|
|
+ item.label = item.projectName
|
|
|
|
+ item.value = item.wbsId + ',' + item.projectId
|
|
|
|
+ })
|
|
|
|
+ arr[1].data = wbsPrivates
|
|
|
|
+ wbsTreeList.value = arr
|
|
|
|
+ console.log(wbsTreeList.value, ' wbsTreeList.value')
|
|
|
|
|
|
//处理选中
|
|
//处理选中
|
|
- const form = getObjValue(formModel.value);
|
|
|
|
- wbsId.value =
|
|
|
|
- type === 1
|
|
|
|
|
|
+ const form = getObjValue(formModel.value)
|
|
|
|
+ wbsId.value
|
|
|
|
+ = type === 1
|
|
? form.referenceWbsTemplateId
|
|
? form.referenceWbsTemplateId
|
|
- : form.referenceWbsTemplateIdTrial;
|
|
|
|
- if (type === 3) wbsId.value = form.referenceWbsTemplateIdMeter;
|
|
|
|
- if (type === 5) wbsId.value = form.referenceWbsTemplateIdLar;
|
|
|
|
- if (type === -1) wbsId.value = "";
|
|
|
|
|
|
+ : form.referenceWbsTemplateIdTrial
|
|
|
|
+ if (type === 3) wbsId.value = form.referenceWbsTemplateIdMeter
|
|
|
|
+ if (type === 5) wbsId.value = form.referenceWbsTemplateIdLar
|
|
|
|
+ if (type === -1) wbsId.value = ''
|
|
|
|
|
|
// referenceWbsType.value = form.referenceWbsTemplateType;
|
|
// referenceWbsType.value = form.referenceWbsTemplateType;
|
|
- referenceWbsType.value =
|
|
|
|
- type === 1
|
|
|
|
|
|
+ referenceWbsType.value
|
|
|
|
+ = type === 1
|
|
? form.referenceWbsTemplateType
|
|
? form.referenceWbsTemplateType
|
|
- : form.referenceWbsTemplateTypeTrial;
|
|
|
|
- if (type === 3) referenceWbsType.value = form.referenceWbsTemplateTypeMeter;
|
|
|
|
- if (type === 5) referenceWbsType.value = form.referenceWbsTemplateTypeLar;
|
|
|
|
- if (type === -1) referenceWbsType.value = "";
|
|
|
|
- isLoading.value = false;
|
|
|
|
- handleWbsID(wbsId.value);
|
|
|
|
- await wbsChange(wbsId.value);
|
|
|
|
-};
|
|
|
|
|
|
+ : form.referenceWbsTemplateTypeTrial
|
|
|
|
+ if (type === 3) referenceWbsType.value = form.referenceWbsTemplateTypeMeter
|
|
|
|
+ if (type === 5) referenceWbsType.value = form.referenceWbsTemplateTypeLar
|
|
|
|
+ if (type === -1) referenceWbsType.value = ''
|
|
|
|
+ isLoading.value = false
|
|
|
|
+ handleWbsID(wbsId.value)
|
|
|
|
+ await wbsChange(wbsId.value)
|
|
|
|
+}
|
|
|
|
|
|
const handleWbsID = (refId) => {
|
|
const handleWbsID = (refId) => {
|
|
if (refId && refId > 0) {
|
|
if (refId && refId > 0) {
|
|
- let priv = {};
|
|
|
|
- if (referenceWbsType.value == "private") {
|
|
|
|
|
|
+ let priv = {}
|
|
|
|
+ if (referenceWbsType.value == 'private') {
|
|
//私有
|
|
//私有
|
|
- let list = wbsTreeList.value[1].data;
|
|
|
|
|
|
+ let list = wbsTreeList.value[1].data
|
|
for (let i = 0; i < list.length; i++) {
|
|
for (let i = 0; i < list.length; i++) {
|
|
if (list[i].pkeyId == refId) {
|
|
if (list[i].pkeyId == refId) {
|
|
- wbsId.value = list[i].wbsId + "," + list[i].projectId;
|
|
|
|
- priv.wbsId = list[i].wbsId;
|
|
|
|
- priv.projectId = list[i].projectId;
|
|
|
|
- priv.value = list[i].value;
|
|
|
|
- priv.pkeyId = list[i].pkeyId;
|
|
|
|
- break;
|
|
|
|
|
|
+ wbsId.value = list[i].wbsId + ',' + list[i].projectId
|
|
|
|
+ priv.wbsId = list[i].wbsId
|
|
|
|
+ priv.projectId = list[i].projectId
|
|
|
|
+ priv.value = list[i].value
|
|
|
|
+ priv.pkeyId = list[i].pkeyId
|
|
|
|
+ break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//公有
|
|
//公有
|
|
- wbsId.value = refId;
|
|
|
|
|
|
+ wbsId.value = refId
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log(wbsId.value, " wbsId.value");
|
|
|
|
-};
|
|
|
|
|
|
+ console.log(wbsId.value, ' wbsId.value')
|
|
|
|
+}
|
|
//左边树
|
|
//左边树
|
|
-const leftLoading = ref(false);
|
|
|
|
-const leftTreeData = ref([]);
|
|
|
|
|
|
+const leftLoading = ref(false)
|
|
|
|
+const leftTreeData = ref([])
|
|
|
|
|
|
//切换wbs树
|
|
//切换wbs树
|
|
-const isDisabled = ref(false);
|
|
|
|
-const referenceWbsId = ref("");
|
|
|
|
-const referenceWbsType = ref("");
|
|
|
|
|
|
+const isDisabled = ref(false)
|
|
|
|
+const referenceWbsId = ref('')
|
|
|
|
+const referenceWbsType = ref('')
|
|
const wbsChange = async (val) => {
|
|
const wbsChange = async (val) => {
|
|
- isDisabled.value = false;
|
|
|
|
- leftLoading.value = true;
|
|
|
|
- referenceWbsId.value = val;
|
|
|
|
|
|
+ isDisabled.value = false
|
|
|
|
+ leftLoading.value = true
|
|
|
|
+ referenceWbsId.value = val
|
|
//无值
|
|
//无值
|
|
if (isNullES(val)) {
|
|
if (isNullES(val)) {
|
|
- await getRightTreeApi();
|
|
|
|
- leftLoading.value = false;
|
|
|
|
- return;
|
|
|
|
|
|
+ // await getRightTreeApi()
|
|
|
|
+ leftTreeData.value = []
|
|
|
|
+ rightTreeData.value = []
|
|
|
|
+ leftLoading.value = false
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
//私有库
|
|
//私有库
|
|
- if (val.toString().indexOf(",") >= 0) {
|
|
|
|
- referenceWbsType.value = "private";
|
|
|
|
- let ids = val.toString().split(",");
|
|
|
|
|
|
+ if (val.toString().indexOf(',') >= 0) {
|
|
|
|
+ referenceWbsType.value = 'private'
|
|
|
|
+ let ids = val.toString().split(',')
|
|
const { data } = await mainApi.findProjectTree({
|
|
const { data } = await mainApi.findProjectTree({
|
|
projectId: ids[1],
|
|
projectId: ids[1],
|
|
wbsId: ids[0],
|
|
wbsId: ids[0],
|
|
- });
|
|
|
|
- leftTreeData.value = getArrValue(data);
|
|
|
|
- leftLoading.value = false;
|
|
|
|
- await getRightTreeApi();
|
|
|
|
- return;
|
|
|
|
|
|
+ })
|
|
|
|
+ leftTreeData.value = getArrValue(data)
|
|
|
|
+ leftLoading.value = false
|
|
|
|
+ await getRightTreeApi()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
//公有库
|
|
//公有库
|
|
if (val.length > 0) {
|
|
if (val.length > 0) {
|
|
- referenceWbsType.value = "public";
|
|
|
|
- const { tenant_id } = getObjValue(userInfo.value);
|
|
|
|
|
|
+ referenceWbsType.value = 'public'
|
|
|
|
+ const { tenant_id } = getObjValue(userInfo.value)
|
|
const { data } = await treeApi.getAlltree({
|
|
const { data } = await treeApi.getAlltree({
|
|
tenantId: tenant_id,
|
|
tenantId: tenant_id,
|
|
- type: "1",
|
|
|
|
|
|
+ type: '1',
|
|
wbsId: val,
|
|
wbsId: val,
|
|
- });
|
|
|
|
- leftTreeData.value = getArrValue(data);
|
|
|
|
- leftLoading.value = false;
|
|
|
|
- await getRightTreeApi();
|
|
|
|
|
|
+ })
|
|
|
|
+ leftTreeData.value = getArrValue(data)
|
|
|
|
+ leftLoading.value = false
|
|
|
|
+ await getRightTreeApi()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
-};
|
|
|
|
|
|
+}
|
|
|
|
|
|
//获取右边数据
|
|
//获取右边数据
|
|
-const rightLoading = ref(false);
|
|
|
|
-const rightTreeData = ref([]);
|
|
|
|
|
|
+const rightLoading = ref(false)
|
|
|
|
+const rightTreeData = ref([])
|
|
const getRightTreeApi = async () => {
|
|
const getRightTreeApi = async () => {
|
|
- rightLoading.value = true;
|
|
|
|
- isDisabled.value = true;
|
|
|
|
- let refId = referenceWbsId.value;
|
|
|
|
|
|
+ rightLoading.value = true
|
|
|
|
+ isDisabled.value = true
|
|
|
|
+ let refId = referenceWbsId.value
|
|
if (isNullES(refId)) {
|
|
if (isNullES(refId)) {
|
|
- isDisabled.value = false;
|
|
|
|
- rightLoading.value = false;
|
|
|
|
- return;
|
|
|
|
|
|
+ isDisabled.value = false
|
|
|
|
+ rightLoading.value = false
|
|
|
|
+ return
|
|
}
|
|
}
|
|
//私有
|
|
//私有
|
|
- if (refId.toString().length > 0 && referenceWbsType.value === "private") {
|
|
|
|
- let ids = refId.toString().split(",");
|
|
|
|
|
|
+ if (refId.toString().length > 0 && referenceWbsType.value === 'private') {
|
|
|
|
+ let ids = refId.toString().split(',')
|
|
if (ids.length > 1) {
|
|
if (ids.length > 1) {
|
|
- refId = ids[0];
|
|
|
|
- let list = wbsTreeList.value[1].data;
|
|
|
|
|
|
+ refId = ids[0]
|
|
|
|
+ let list = wbsTreeList.value[1].data
|
|
refId = list.filter(({ projectId }) => projectId === ids[1])[0]
|
|
refId = list.filter(({ projectId }) => projectId === ids[1])[0]
|
|
- .pkeyId;
|
|
|
|
|
|
+ .pkeyId
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//引用被删会出现 wbsType -1
|
|
//引用被删会出现 wbsType -1
|
|
if (refId && refId > 0) {
|
|
if (refId && refId > 0) {
|
|
- let priv = {};
|
|
|
|
|
|
+ let priv = {}
|
|
//私有
|
|
//私有
|
|
- if (referenceWbsType.value === "private") {
|
|
|
|
- let list = wbsTreeList.value[1].data;
|
|
|
|
|
|
+ if (referenceWbsType.value === 'private') {
|
|
|
|
+ let list = wbsTreeList.value[1].data
|
|
for (let i = 0; i < list.length; i++) {
|
|
for (let i = 0; i < list.length; i++) {
|
|
if (list[i].pkeyId === refId) {
|
|
if (list[i].pkeyId === refId) {
|
|
- refId = list[i].wbsId + "," + list[i].projectId;
|
|
|
|
- priv.wbsId = list[i].wbsId;
|
|
|
|
- priv.projectId = list[i].projectId;
|
|
|
|
- priv.value = list[i].value;
|
|
|
|
- priv.pkeyId = list[i].pkeyId;
|
|
|
|
- break;
|
|
|
|
|
|
+ refId = list[i].wbsId + ',' + list[i].projectId
|
|
|
|
+ priv.wbsId = list[i].wbsId
|
|
|
|
+ priv.projectId = list[i].projectId
|
|
|
|
+ priv.value = list[i].value
|
|
|
|
+ priv.pkeyId = list[i].pkeyId
|
|
|
|
+ break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//公有
|
|
//公有
|
|
- refId = referenceWbsId.value;
|
|
|
|
|
|
+ refId = referenceWbsId.value
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log(refId, "refId");
|
|
|
|
|
|
+ console.log(refId, 'refId')
|
|
|
|
|
|
- const form = getObjValue(formModel.value);
|
|
|
|
- let recordId = formatWbsId(refId);
|
|
|
|
|
|
+ const form = getObjValue(formModel.value)
|
|
|
|
+ let recordId = formatWbsId(refId)
|
|
const { data } = await mainApi.findProjectTree({
|
|
const { data } = await mainApi.findProjectTree({
|
|
projectId: form.id,
|
|
projectId: form.id,
|
|
// wbsId: refId,
|
|
// wbsId: refId,
|
|
wbsId: recordId,
|
|
wbsId: recordId,
|
|
- });
|
|
|
|
- const projectTree = getArrValue(data);
|
|
|
|
- isDisabled.value = projectTree.length > 0;
|
|
|
|
- rightTreeData.value = projectTree;
|
|
|
|
- setRightTree();
|
|
|
|
- rightLoading.value = false;
|
|
|
|
-};
|
|
|
|
|
|
+ })
|
|
|
|
+ const projectTree = getArrValue(data)
|
|
|
|
+ isDisabled.value = projectTree.length > 0
|
|
|
|
+ rightTreeData.value = projectTree
|
|
|
|
+ setRightTree()
|
|
|
|
+ rightLoading.value = false
|
|
|
|
+}
|
|
|
|
|
|
//默认全部引用
|
|
//默认全部引用
|
|
-const allChecked = ref(false);
|
|
|
|
|
|
+const allChecked = ref(false)
|
|
const checkChang = () => {
|
|
const checkChang = () => {
|
|
- setCheckTreeChange();
|
|
|
|
-};
|
|
|
|
|
|
+ setCheckTreeChange()
|
|
|
|
+}
|
|
|
|
|
|
//左边树被展开
|
|
//左边树被展开
|
|
-const rightExpands = ref([]);
|
|
|
|
|
|
+const rightExpands = ref([])
|
|
const nodeLeftTreeExpand = (data) => {
|
|
const nodeLeftTreeExpand = (data) => {
|
|
- rightExpands.value = rightExpands.value.concat([data.id]);
|
|
|
|
-};
|
|
|
|
|
|
+ rightExpands.value = rightExpands.value.concat([data.id])
|
|
|
|
+}
|
|
|
|
|
|
//左边树复选框被点击
|
|
//左边树复选框被点击
|
|
-const leftNum = ref(0);
|
|
|
|
|
|
+const leftNum = ref(0)
|
|
const checkLeftTreeChange = () => {
|
|
const checkLeftTreeChange = () => {
|
|
- const e = leftTreeRef.value;
|
|
|
|
- let checkNum = e.getCheckedKeys().length;
|
|
|
|
- let halfNum = e.getHalfCheckedKeys().length;
|
|
|
|
- leftNum.value = checkNum + halfNum;
|
|
|
|
-};
|
|
|
|
|
|
+ const e = leftTreeRef.value
|
|
|
|
+ let checkNum = e.getCheckedKeys().length
|
|
|
|
+ let halfNum = e.getHalfCheckedKeys().length
|
|
|
|
+ leftNum.value = checkNum + halfNum
|
|
|
|
+}
|
|
|
|
|
|
//右边树复选框被点击
|
|
//右边树复选框被点击
|
|
-const rightNum = ref(0);
|
|
|
|
|
|
+const rightNum = ref(0)
|
|
const checkRightTreeChange = () => {
|
|
const checkRightTreeChange = () => {
|
|
- const e = rightTreeRef.value;
|
|
|
|
- let checkNum = e.getCheckedKeys().length;
|
|
|
|
- let halfNum = e.getHalfCheckedKeys().length;
|
|
|
|
- rightNum.value = checkNum + halfNum;
|
|
|
|
-};
|
|
|
|
|
|
+ const e = rightTreeRef.value
|
|
|
|
+ let checkNum = e.getCheckedKeys().length
|
|
|
|
+ let halfNum = e.getHalfCheckedKeys().length
|
|
|
|
+ rightNum.value = checkNum + halfNum
|
|
|
|
+}
|
|
|
|
|
|
//左边树新增到右边
|
|
//左边树新增到右边
|
|
const addTreeClick = () => {
|
|
const addTreeClick = () => {
|
|
const left = leftTreeRef.value,
|
|
const left = leftTreeRef.value,
|
|
- right = rightTreeRef.value;
|
|
|
|
|
|
+ right = rightTreeRef.value
|
|
if (rightTreeData.value.length < 1) {
|
|
if (rightTreeData.value.length < 1) {
|
|
//直接把左边勾选的树复制到右侧
|
|
//直接把左边勾选的树复制到右侧
|
|
- let allTree = JSON.parse(JSON.stringify(leftTreeData.value));
|
|
|
|
- const halfKeys = left.getHalfCheckedKeys();
|
|
|
|
- const keys = left.getCheckedKeys().concat(halfKeys);
|
|
|
|
- getRightTree(allTree, keys);
|
|
|
|
- rightTreeData.value = allTree;
|
|
|
|
- setCheckTreeChange(rightTreeData.value);
|
|
|
|
|
|
+ let allTree = JSON.parse(JSON.stringify(leftTreeData.value))
|
|
|
|
+ const halfKeys = left.getHalfCheckedKeys()
|
|
|
|
+ const keys = left.getCheckedKeys().concat(halfKeys)
|
|
|
|
+ getRightTree(allTree, keys)
|
|
|
|
+ rightTreeData.value = allTree
|
|
|
|
+ setCheckTreeChange(rightTreeData.value)
|
|
} else {
|
|
} else {
|
|
//只增加右侧树没有的节点,不会覆盖右侧树多余的节点
|
|
//只增加右侧树没有的节点,不会覆盖右侧树多余的节点
|
|
- let checkNodes = left.getCheckedNodes(false, true);
|
|
|
|
|
|
+ let checkNodes = left.getCheckedNodes(false, true)
|
|
|
|
|
|
- let rIdMap = new Map();
|
|
|
|
|
|
+ let rIdMap = new Map()
|
|
checkNodes.forEach((data) => {
|
|
checkNodes.forEach((data) => {
|
|
- rIdMap.set(data.id, data);
|
|
|
|
- });
|
|
|
|
|
|
+ rIdMap.set(data.id, data)
|
|
|
|
+ })
|
|
|
|
|
|
- let lIdSet = new Set();
|
|
|
|
- getRightTreeData(lIdSet, rightTreeData.value);
|
|
|
|
|
|
+ let lIdSet = new Set()
|
|
|
|
+ getRightTreeData(lIdSet, rightTreeData.value)
|
|
|
|
|
|
//在右侧id减去左侧有的id,剩下的就是新增的id
|
|
//在右侧id减去左侧有的id,剩下的就是新增的id
|
|
lIdSet.forEach((id) => {
|
|
lIdSet.forEach((id) => {
|
|
- rIdMap.delete(id);
|
|
|
|
- });
|
|
|
|
|
|
+ rIdMap.delete(id)
|
|
|
|
+ })
|
|
|
|
|
|
- let addMap = new Map();
|
|
|
|
|
|
+ let addMap = new Map()
|
|
rIdMap.forEach((data) => {
|
|
rIdMap.forEach((data) => {
|
|
- if (data.parentId !== "0" && data.parentId !== 0) {
|
|
|
|
|
|
+ if (data.parentId !== '0' && data.parentId !== 0) {
|
|
//在左侧树能找到父节点的,新增
|
|
//在左侧树能找到父节点的,新增
|
|
- let lNode = right.getNode(data.parentId);
|
|
|
|
- if (lNode) addMap.set(data, lNode.data.id);
|
|
|
|
|
|
+ let lNode = right.getNode(data.parentId)
|
|
|
|
+ if (lNode) addMap.set(data, lNode.data.id)
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ })
|
|
|
|
|
|
//把半选和选中的数组key合并
|
|
//把半选和选中的数组key合并
|
|
- const halfKeys = left.getHalfCheckedKeys();
|
|
|
|
- const keys = left.getCheckedKeys().concat(halfKeys);
|
|
|
|
- const myArray = Array.from(addMap.keys());
|
|
|
|
- let myright = deepClone(myArray);
|
|
|
|
- getRightTree(myright, keys);
|
|
|
|
|
|
+ const halfKeys = left.getHalfCheckedKeys()
|
|
|
|
+ const keys = left.getCheckedKeys().concat(halfKeys)
|
|
|
|
+ const myArray = Array.from(addMap.keys())
|
|
|
|
+ let myright = deepClone(myArray)
|
|
|
|
+ getRightTree(myright, keys)
|
|
myright.forEach((data) => {
|
|
myright.forEach((data) => {
|
|
- right.append(data, data.parentId);
|
|
|
|
- });
|
|
|
|
|
|
+ right.append(data, data.parentId)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
-};
|
|
|
|
|
|
+}
|
|
|
|
|
|
//获取右边树
|
|
//获取右边树
|
|
const getRightTree = (arr, keys) => {
|
|
const getRightTree = (arr, keys) => {
|
|
//对比所有的node和选中的key
|
|
//对比所有的node和选中的key
|
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
- let isIn = false;
|
|
|
|
|
|
+ let isIn = false
|
|
for (let j = keys.length - 1; j >= 0; j--) {
|
|
for (let j = keys.length - 1; j >= 0; j--) {
|
|
if (keys[j] === arr[i].id) {
|
|
if (keys[j] === arr[i].id) {
|
|
- isIn = true;
|
|
|
|
|
|
+ isIn = true
|
|
//已经匹配到的key移除,节省性能
|
|
//已经匹配到的key移除,节省性能
|
|
- keys.splice(j, 1);
|
|
|
|
- break;
|
|
|
|
|
|
+ keys.splice(j, 1)
|
|
|
|
+ break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (isIn) {
|
|
if (isIn) {
|
|
//包含在选中的节点,如果有childer继续递归判断
|
|
//包含在选中的节点,如果有childer继续递归判断
|
|
if (arr[i].children && arr[i].children.length) {
|
|
if (arr[i].children && arr[i].children.length) {
|
|
- getRightTree(arr[i].children, keys);
|
|
|
|
|
|
+ getRightTree(arr[i].children, keys)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//不包含在选中key的node删除
|
|
//不包含在选中key的node删除
|
|
- arr.splice(i, 1);
|
|
|
|
|
|
+ arr.splice(i, 1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-};
|
|
|
|
|
|
+}
|
|
|
|
|
|
const getRightTreeData = (set, arr) => {
|
|
const getRightTreeData = (set, arr) => {
|
|
arr.forEach((data) => {
|
|
arr.forEach((data) => {
|
|
- set.add(data.id);
|
|
|
|
|
|
+ set.add(data.id)
|
|
if (data.children && data.children.length) {
|
|
if (data.children && data.children.length) {
|
|
- getRightTreeData(set, data.children);
|
|
|
|
|
|
+ getRightTreeData(set, data.children)
|
|
}
|
|
}
|
|
- });
|
|
|
|
-};
|
|
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
|
|
//右边树移除
|
|
//右边树移除
|
|
const delTreeClick = () => {
|
|
const delTreeClick = () => {
|
|
const left = leftTreeRef.value,
|
|
const left = leftTreeRef.value,
|
|
- right = rightTreeRef.value;
|
|
|
|
- let delNodes = right.getCheckedNodes();
|
|
|
|
|
|
+ right = rightTreeRef.value
|
|
|
|
+ let delNodes = right.getCheckedNodes()
|
|
//只把选中的节点移除
|
|
//只把选中的节点移除
|
|
delNodes.forEach((node) => {
|
|
delNodes.forEach((node) => {
|
|
- right.remove(node);
|
|
|
|
- left.setChecked(node.id, false);
|
|
|
|
- });
|
|
|
|
- checkLeftTreeChange();
|
|
|
|
- checkRightTreeChange();
|
|
|
|
- setCheckTreeChange(delNodes);
|
|
|
|
-};
|
|
|
|
|
|
+ right.remove(node)
|
|
|
|
+ left.setChecked(node.id, false)
|
|
|
|
+ })
|
|
|
|
+ checkLeftTreeChange()
|
|
|
|
+ checkRightTreeChange()
|
|
|
|
+ setCheckTreeChange(delNodes)
|
|
|
|
+}
|
|
|
|
|
|
const setRightTree = () => {
|
|
const setRightTree = () => {
|
|
- let ids = [];
|
|
|
|
- const data = rightTreeData.value;
|
|
|
|
|
|
+ let ids = []
|
|
|
|
+ const data = rightTreeData.value
|
|
for (let i = 0; i < data.length; i++) {
|
|
for (let i = 0; i < data.length; i++) {
|
|
- getLeafIds(ids, data[i]);
|
|
|
|
|
|
+ getLeafIds(ids, data[i])
|
|
}
|
|
}
|
|
//在左边把右边的节点勾选上
|
|
//在左边把右边的节点勾选上
|
|
- const e = leftTreeRef.value;
|
|
|
|
|
|
+ const e = leftTreeRef.value
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
- e.setCheckedKeys(ids, true);
|
|
|
|
- });
|
|
|
|
-};
|
|
|
|
|
|
+ e.setCheckedKeys(ids, true)
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
|
|
const getLeafIds = (ids, data) => {
|
|
const getLeafIds = (ids, data) => {
|
|
if (data.children && data.children.length) {
|
|
if (data.children && data.children.length) {
|
|
for (let i = 0; i < data.children.length; i++) {
|
|
for (let i = 0; i < data.children.length; i++) {
|
|
- getLeafIds(ids, data.children[i]);
|
|
|
|
|
|
+ getLeafIds(ids, data.children[i])
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- ids.push(data.id);
|
|
|
|
|
|
+ ids.push(data.id)
|
|
}
|
|
}
|
|
-};
|
|
|
|
|
|
+}
|
|
|
|
|
|
const getTreeAllId = async (name) => {
|
|
const getTreeAllId = async (name) => {
|
|
- let tree;
|
|
|
|
- if (name === "left") {
|
|
|
|
- tree = leftTreeRef.value;
|
|
|
|
- } else if (name === "right") {
|
|
|
|
- tree = rightTreeRef.value;
|
|
|
|
|
|
+ let tree
|
|
|
|
+ if (name === 'left') {
|
|
|
|
+ tree = leftTreeRef.value
|
|
|
|
+ } else if (name === 'right') {
|
|
|
|
+ tree = rightTreeRef.value
|
|
}
|
|
}
|
|
if (allChecked.value) {
|
|
if (allChecked.value) {
|
|
- tree = leftTreeRef.value;
|
|
|
|
|
|
+ tree = leftTreeRef.value
|
|
}
|
|
}
|
|
- let ids = [];
|
|
|
|
|
|
+ let ids = []
|
|
for (let i = 0; i < tree.data.length; i++) {
|
|
for (let i = 0; i < tree.data.length; i++) {
|
|
- await getIds(ids, tree.data[i]);
|
|
|
|
|
|
+ await getIds(ids, tree.data[i])
|
|
}
|
|
}
|
|
- return ids.join(",");
|
|
|
|
-};
|
|
|
|
|
|
+ return ids.join(',')
|
|
|
|
+}
|
|
|
|
|
|
const getIds = async (ids, data) => {
|
|
const getIds = async (ids, data) => {
|
|
- ids.push(data.id);
|
|
|
|
|
|
+ ids.push(data.id)
|
|
if (data.children && data.children.length) {
|
|
if (data.children && data.children.length) {
|
|
for (let i = 0; i < data.children.length; i++) {
|
|
for (let i = 0; i < data.children.length; i++) {
|
|
- await getIds(ids, data.children[i]);
|
|
|
|
|
|
+ await getIds(ids, data.children[i])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-};
|
|
|
|
|
|
+}
|
|
|
|
|
|
//格式化wbsid
|
|
//格式化wbsid
|
|
const formatWbsId = (rid) => {
|
|
const formatWbsId = (rid) => {
|
|
- let refId = rid;
|
|
|
|
|
|
+ let refId = rid
|
|
if (isNullES(refId)) {
|
|
if (isNullES(refId)) {
|
|
- return refId;
|
|
|
|
|
|
+ return refId
|
|
}
|
|
}
|
|
- if (referenceWbsType.value === "private" && refId.toString().length > 0) {
|
|
|
|
|
|
+ if (referenceWbsType.value === 'private' && refId.toString().length > 0) {
|
|
// 私有库右边树形数据是通过 pkeyId 查询的
|
|
// 私有库右边树形数据是通过 pkeyId 查询的
|
|
- let ids = refId.toString().split(",");
|
|
|
|
|
|
+ let ids = refId.toString().split(',')
|
|
if (ids.length > 1) {
|
|
if (ids.length > 1) {
|
|
- refId = ids[0];
|
|
|
|
- let list = wbsTreeList.value[1].data;
|
|
|
|
|
|
+ refId = ids[0]
|
|
|
|
+ let list = wbsTreeList.value[1].data
|
|
refId = list.filter(({ projectId }) => projectId === ids[1])[0]
|
|
refId = list.filter(({ projectId }) => projectId === ids[1])[0]
|
|
- .pkeyId;
|
|
|
|
- return refId;
|
|
|
|
|
|
+ .pkeyId
|
|
|
|
+ return refId
|
|
} else {
|
|
} else {
|
|
- return "";
|
|
|
|
|
|
+ return ''
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- return refId;
|
|
|
|
|
|
+ return refId
|
|
}
|
|
}
|
|
-};
|
|
|
|
|
|
+}
|
|
|
|
|
|
-const rightObj = ref({});
|
|
|
|
|
|
+const rightObj = ref({})
|
|
const setCheckTreeChange = () => {
|
|
const setCheckTreeChange = () => {
|
|
- let recordId = formatWbsId(wbsId.value);
|
|
|
|
|
|
+ let recordId = formatWbsId(wbsId.value)
|
|
rightObj.value = {
|
|
rightObj.value = {
|
|
wbsId: recordId,
|
|
wbsId: recordId,
|
|
data: rightTreeData.value,
|
|
data: rightTreeData.value,
|
|
- };
|
|
|
|
-};
|
|
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
const getTreeObj = async () => {
|
|
const getTreeObj = async () => {
|
|
- const form = getObjValue(formModel.value);
|
|
|
|
- const ids = await getTreeAllId("right");
|
|
|
|
- const wbs_id = wbsId.value;
|
|
|
|
|
|
+ const form = getObjValue(formModel.value)
|
|
|
|
+ const ids = await getTreeAllId('right')
|
|
|
|
+ const wbs_id = wbsId.value
|
|
|
|
|
|
let obj = {
|
|
let obj = {
|
|
wbsId: wbs_id,
|
|
wbsId: wbs_id,
|
|
projectId: form.id,
|
|
projectId: form.id,
|
|
wbsType: templateType.value,
|
|
wbsType: templateType.value,
|
|
wbsTreeIds: ids,
|
|
wbsTreeIds: ids,
|
|
- };
|
|
|
|
- if (wbs_id.toString().indexOf(",") >= 0) {
|
|
|
|
|
|
+ }
|
|
|
|
+ if (wbs_id.toString().indexOf(',') >= 0) {
|
|
//私有库
|
|
//私有库
|
|
- obj.referenceType = "private";
|
|
|
|
- let ids = wbs_id.toString().split(",");
|
|
|
|
- obj.wbsId = ids[0];
|
|
|
|
- obj.referencePrivateWbsProjectId = ids[1];
|
|
|
|
- obj.primaryKeyId = leftTreeData.value[0].primaryKeyId;
|
|
|
|
|
|
+ obj.referenceType = 'private'
|
|
|
|
+ let ids = wbs_id.toString().split(',')
|
|
|
|
+ obj.wbsId = ids[0]
|
|
|
|
+ obj.referencePrivateWbsProjectId = ids[1]
|
|
|
|
+ obj.primaryKeyId = leftTreeData.value[0].primaryKeyId
|
|
} else {
|
|
} else {
|
|
//公有库
|
|
//公有库
|
|
- obj.referenceType = "public";
|
|
|
|
- obj.wbsId = wbs_id;
|
|
|
|
|
|
+ obj.referenceType = 'public'
|
|
|
|
+ obj.wbsId = wbs_id
|
|
}
|
|
}
|
|
- return obj;
|
|
|
|
-};
|
|
|
|
|
|
+ return obj
|
|
|
|
+}
|
|
|
|
|
|
defineExpose({
|
|
defineExpose({
|
|
getTreeObj,
|
|
getTreeObj,
|
|
-});
|
|
|
|
|
|
+})
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
<style lang="scss">
|