duy 9 mesi fa
parent
commit
e9e745dce5

+ 169 - 0
src/views/project/list/independent/allocateWbs.vue

@@ -0,0 +1,169 @@
+<template>
+    <!-- 树节点调整排序 -->
+    <hc-dialog
+        v-model="isShow"
+        title="分配WBS"
+        widths="56rem"
+        isTable
+        @close="dialogClose"
+        @save="submitClick"
+        :loading="submitLoading"
+    >
+        <div v-loading="treeLoading">
+            <el-scrollbar>
+                <el-tree
+                    :props="treeProps"
+                    :load="treeLoad"
+                    lazy
+                    accordion
+                    highlight-current
+                    @node-click="treeClick"
+                >
+                    <template #default="{ node, data }">
+                        <span
+                            class="custom-tree-node"
+                            style="justify-content: flex-start"
+                        >
+                            <span>
+                                <el-checkbox
+                                    v-model="data.checked"
+                                    v-if="!data.hasChildren"
+                                    @change="handleCheckChange($event, data)"
+                                ></el-checkbox
+                            ></span>
+                            {{ node.label }}
+                        </span>
+                    </template>
+                </el-tree>
+            </el-scrollbar>
+        </div>
+    </hc-dialog>
+</template>
+<script setup>
+import { ref, watch, nextTick } from "vue";
+import mainApi from "~api/desk/wbs";
+import privateApi from "~api/wbs/private";
+import { arrToId, getArrValue, getObjValue } from "js-fast-way";
+import { useAppStore } from "~src/store";
+
+//事件
+const emit = defineEmits(["close"]);
+//双向绑定
+// eslint-disable-next-line no-undef
+const isShow = defineModel("modelValue", {
+    default: false,
+});
+const props = defineProps({
+    projectId: {
+        type: String,
+        default: "",
+    },
+    wbsType: {
+        type: [String, Number],
+        default: "",
+    },
+    wbsId: {
+        type: [String, Number],
+        default: "",
+    },
+    data: {
+        type: Object,
+        default: () => ({}),
+    },
+});
+const store = useAppStore();
+const userInfo = ref(store.getUserInfo);
+watch(
+    () => store.getUserInfo,
+    (info) => {
+        userInfo.value = info;
+    },
+    { immediate: true, deep: true }
+);
+const projectId = ref(props.projectId);
+const wbsId = ref(props.wbsId);
+const wbsType = ref(props.wbsType);
+const data = ref(props.data);
+//监听数据
+watch(
+    () => [props.projectId, props.wbsId, props.wbsType, props.data],
+    ([pid, wid, wtype, info]) => {
+        projectId.value = pid;
+        wbsId.value = wid;
+        wbsType.value = wtype;
+        data.value = info;
+    },
+    { deep: true }
+);
+//监听显示
+watch(isShow, (val) => {
+    selectData.value = [];
+    if (val) {
+    } else {
+        emit("close");
+    }
+});
+
+//关闭弹窗
+const dialogClose = () => {
+    selectData.value = [];
+    isShow.value = false;
+    emit("close");
+};
+//树
+const treeProps = {
+    label: "title",
+    isLeaf: (item) => {
+        return !item.hasChildren;
+    },
+};
+
+//懒加载树
+const treeLoading = ref(false);
+const treeLoad = async (node, resolve) => {
+    const { tenant_id } = getObjValue(userInfo.value);
+    treeLoading.value = true;
+    const parentId = node.level === 0 ? 0 : node.data.id;
+
+    const { data } = await privateApi.getLazytree({
+        parentId: parentId,
+        wbsId: wbsId.value,
+        tenantId: tenant_id,
+        projectId: projectId.value,
+        wbsType: wbsType.value,
+    });
+    treeLoading.value = false;
+    resolve(getArrValue(data));
+};
+
+//树节点被点击
+
+const treeClick = ({ id, type, nodeName }) => {};
+const selectData = ref([]);
+const handleCheckChange = (isCheck, data) => {
+    if (isCheck) {
+        selectData.value.push(data);
+    } else {
+        const index = selectData.value.indexOf(data);
+        if (index !== -1) {
+            selectData.value.splice(index, 1);
+        }
+    }
+};
+const submitLoading = ref(false);
+const submitClick = async () => {
+    const nodesIdArray = selectData.value.map((obj) => obj.primaryKeyId);
+    const commaSeparatedIds = nodesIdArray.join(","); // 使用逗号连接数组中的所有元素
+    submitLoading.value = true;
+    const { code, error, msg } = await privateApi.syncFormToContractNode({
+        nodeIds: commaSeparatedIds,
+        projectId: projectId.value,
+        primaryKeyId: data.value.id,
+    });
+    submitLoading.value = false;
+    if (!error && code === 200) {
+        window.$message.success(msg);
+        dialogClose();
+    }
+};
+</script>

+ 21 - 10
src/views/project/list/independent/index.vue

@@ -107,6 +107,13 @@
             :info="adjustExcelInfo"
             :type="2"
         />
+        <!-- 分配WBS -->
+        <allocateWbs
+            v-model="isAllocateShow"
+            :wbsType="wbsType"
+            :projectId="projectId"
+            :data="allocateWbsInfo"
+        ></allocateWbs>
     </hc-drawer>
 </template>
 
@@ -120,6 +127,7 @@ import quteElePage from "./quteElePage.vue";
 import HcAssociationList from "../association-list.vue";
 import HcEditElement from "../edit-element.vue";
 import HcAdjustExcel from "../adjust-excel.vue";
+import allocateWbs from "./allocateWbs.vue";
 //事件
 const emit = defineEmits(["close"]);
 
@@ -162,13 +170,6 @@ watch(
 //处理相关数据
 const getDataApi = () => {};
 
-//树配置
-const treeProps = {
-    label: "title",
-    children: "children",
-    isLeaf: "isLeaf",
-};
-
 //获取数据
 const tabTypeLazyTree = async (parentId = "12345678910") => {
     //发起请求
@@ -213,6 +214,12 @@ const treeLoadNode = async (node, resolve) => {
 
 //树节点被点击
 const nodeInfo = ref({});
+const treeProps = {
+    label: "title",
+    isLeaf: (item) => {
+        return !item.hasChildren;
+    },
+};
 const treeNodeTap = (data, node) => {
     nodeInfo.value = data;
     searchForm.value.parentId = data.id;
@@ -292,12 +299,16 @@ const linkExcelClick = async (item) => {
     await nextTick();
     isAssociationShow.value = true;
 };
-//调整表单
-const adjustTable = () => {};
+
 //公式配置
 const rowFormulaClick = (row) => {};
 //分配WBS
-const assignWbs = () => {};
+const isAllocateShow = ref(false);
+const allocateWbsInfo = ref({});
+const assignWbs = (row) => {
+    allocateWbsInfo.value = row;
+    isAllocateShow.value = true;
+};
 
 //编辑元素
 const isEditElementShow = ref(false);