8
0
duy há 2 semanas atrás
pai
commit
040e7efac7

+ 19 - 4
src/views/desk/test-collect/partitioning.vue

@@ -11,7 +11,7 @@
                 <hc-search-input v-model="filterText" placeholder="输入关键字搜索" />
             </el-form-item>
             <el-form-item label="树数据:">
-                <hc-data-tree ref="treeRef" :h-props="treeProps" show-checkbox :datas="treeData" :search-val="filterText">
+                <hc-data-tree ref="treeRef" :h-props="treeProps" show-checkbox :datas="treeData" :search-val="filterText" :default-checked-keys="defaultCheckedKeys">
                     <template #name="{ data }">
                         <span class="text-16px font-400">{{ data.title }}</span>
                     </template>
@@ -46,18 +46,29 @@ const emit = defineEmits(['close', 'finish'])
 const isShow = defineModel('modelValue', {
     default: false,
 })
-
+const defaultCheckedKeys = ref([])
 //监听可否编辑
 const dataInfo = ref(props.data)
 watch(() => props.data, (data) => {
     dataInfo.value = data
+    console.log( dataInfo.value, '  dataInfo.value')
+    
+  
 }, { immediate: true, deep: true })
 
 //监听显示
-watch(isShow, () => getDataApi())
+watch(isShow, () =>{
+     getDataApi()
+     const { trialTreeIds } = dataInfo.value
+ if (isShow.value && trialTreeIds) {
+    defaultCheckedKeys.value = trialTreeIds.split(',')
+ }
+
+    })
 const getDataApi = () => {
     console.log(dataInfo.value)
     getProjectData()
+   
 }
 
 //项目列表
@@ -120,9 +131,10 @@ const dialogSubmit = async () => {
         return
     }
     submitLoading.value = true
+    let ids = checkIds.join(',')
     const { isRes } = await mainApi.matching({
         classId: dataInfo.value.id,
-        ids: checkIds,
+        ids: ids,
     })
     submitLoading.value = false
     if (!isRes) return
@@ -135,6 +147,9 @@ const dialogSubmit = async () => {
 const dialogClose = () => {
     isShow.value = false
     submitLoading.value = false
+    formModel.value.pid = ''
+    projectData.value = []
+    defaultCheckedKeys.value = []
     emit('close')
 }
 </script>

+ 195 - 191
src/views/project/list/independent/index.vue

@@ -10,13 +10,13 @@
                 <hc-card scrollbar>
                     <h3 class="mb-2">引用元素表</h3>
                     <ElTree
+                        v-if="isShowTree"
                         :load="treeLoadNode"
                         :props="treeProps"
                         accordion
                         highlight-current
                         lazy
                         @node-click="treeNodeTap"
-                        v-if="isShowTree"
                     />
                 </hc-card>
             </template>
@@ -30,16 +30,17 @@
                     </div>
                 </template>
                 <template #extra>
-                    <el-button hc-btn type="primary" @click="quteEleTableClick"
-                        >引用元素表单库</el-button
-                    >
+                    <el-button hc-btn type="primary" @click="quteEleTableClick">
+                        引用元素表单库
+                    </el-button>
                     <el-button
                         hc-btn
                         type="danger"
-                        @click="batchDel"
                         :loading="batchDelLoad"
-                        >删除元素表</el-button
+                        @click="batchDel"
                     >
+                        删除元素表
+                    </el-button>
                 </template>
                 <hc-table
                     :column="tableColumn"
@@ -51,29 +52,31 @@
                     @selection-change="tableCheckChange"
                 >
                     <template #action="{ row }">
-                        <el-link type="primary" @click="linkExcelClick(row)"
-                            >关联清表</el-link
-                        >
+                        <el-link type="primary" @click="linkExcelClick(row)">
+                            关联清表
+                        </el-link>
                         <el-link
                             v-loading="editElementLoading"
                             type="primary"
-                            @click="editElement(row)"
                             :disabled="row.excelIds == -1"
-                            >编辑元素</el-link
+                            @click="editElement(row)"
                         >
+                            编辑元素
+                        </el-link>
                         <el-link
                             v-loading="adjustExcelLoading"
                             type="primary"
-                            @click="adjustExcelClick(row)"
                             :disabled="row.excelIds == -1"
-                            >调整表单</el-link
-                        >
-                        <el-link type="primary" @click="rowFormulaClick(row)"
-                            >编辑公式</el-link
-                        >
-                        <el-link type="primary" @click="assignWbs(row)"
-                            >分配WBS</el-link
+                            @click="adjustExcelClick(row)"
                         >
+                            调整表单
+                        </el-link>
+                        <el-link type="primary" @click="rowFormulaClick(row)">
+                            编辑公式
+                        </el-link>
+                        <el-link type="primary" @click="assignWbs(row)">
+                            分配WBS
+                        </el-link>
                     </template>
                 </hc-table>
                 <template #action>
@@ -84,9 +87,9 @@
         <!-- 引用元素表 -->
         <quteElePage
             v-model="quteEleShow"
-            :projectId="projectId"
+            :project-id="projectId"
             @close="quteEleClose"
-        ></quteElePage>
+        />
         <!-- 关联清表 -->
         <HcAssociationList
             v-model="isAssociationShow"
@@ -110,300 +113,301 @@
         <!-- 分配WBS -->
         <allocateWbs
             v-model="isAllocateShow"
-            :wbsType="wbsType"
-            :projectId="projectId"
+            :wbs-type="wbsType"
+            :project-id="projectId"
             :data="allocateWbsInfo"
-        ></allocateWbs>
+        />
     </hc-drawer>
 </template>
 
 <script setup>
-import { ref, watch, nextTick } from "vue";
-import { HcDelMsg } from "hc-vue3-ui";
-import { getArrValue, arrToId, isNullES, deepClone } from "js-fast-way";
-import privateApi from "~api/wbs/private";
-import excelApi from "~api/exctab/exceltab";
-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"]);
-
-//双向绑定
-const isShow = defineModel("modelValue", {
-    default: false,
-});
-
-//监听显示
-watch(isShow, (val) => {
-    if (val) getDataApi();
-});
+import { nextTick, ref, watch } from 'vue'
+import { HcDelMsg } from 'hc-vue3-ui'
+import { arrToId, deepClone, getArrValue, isNullES } from 'js-fast-way'
+import privateApi from '~api/wbs/private'
+import excelApi from '~api/exctab/exceltab'
+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 props = defineProps({
     projectId: {
         type: String,
-        default: "",
+        default: '',
     },
     wbsType: {
         type: [String, Number],
-        default: "",
+        default: '',
     },
     wbsId: {
         type: [String, Number],
-        default: "",
+        default: '',
     },
-});
-const projectId = ref(props.projectId);
-const wbsId = ref(props.wbsId);
-const wbsType = ref(props.wbsType);
+})
+
+//事件
+const emit = defineEmits(['close'])
+
+//双向绑定
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听显示
+watch(isShow, (val) => {
+    if (val) getDataApi()
+})
+const projectId = ref(props.projectId)
+const wbsId = ref(props.wbsId)
+const wbsType = ref(props.wbsType)
 //监听数据
 watch(
     () => [props.projectId, props.wbsId, props.wbsType],
     ([pid, wid, wtype]) => {
-        projectId.value = pid;
-        wbsId.value = wid;
-        wbsType.value = wtype;
+        projectId.value = pid
+        wbsId.value = wid
+        wbsType.value = wtype
     },
-    { deep: true }
-);
+    { deep: true },
+)
 //处理相关数据
-const getDataApi = () => {};
+const getDataApi = () => {}
 
 //获取数据
-const tabTypeLazyTree = async (parentId = "12345678910") => {
+const tabTypeLazyTree = async (parentId = '12345678910') => {
     //发起请求
     const { data } = await privateApi.tabTypeLazyTree({
         parentId,
         current: 1,
         size: 1000,
         projectId: projectId.value,
-    });
-    const records = getArrValue(data?.records);
+    })
+    const records = getArrValue(data?.records)
     records.forEach((item) => {
-        item.isLeaf = !item.hasChildren;
-    });
-    return { data: records, total: data?.total };
-};
-const isShowTree = ref(true);
+        item.isLeaf = !item.hasChildren
+    })
+    return { data: records, total: data?.total }
+}
+const isShowTree = ref(true)
 const refreshTree = () => {
-    isShowTree.value = false;
+    isShowTree.value = false
 
     setTimeout(() => {
-        isShowTree.value = true;
-    }, 1000);
-};
+        isShowTree.value = true
+    }, 1000)
+}
 const treeLoadNode = async (node, resolve) => {
     if (node.level === 0) {
-        const resData = await tabTypeLazyTree();
-        resolve(resData?.data);
+        const resData = await tabTypeLazyTree()
+        resolve(resData?.data)
     } else {
         const resData = await tabTypeLazyTree(
             node?.data?.primaryKeyId,
-            "",
+            '',
             false,
             {
                 current: 1,
                 size: 2000,
                 projectId: projectId.value,
-            }
-        );
-        resolve(resData?.data);
+            },
+        )
+        resolve(resData?.data)
     }
-};
+}
 
 //树节点被点击
-const nodeInfo = ref({});
+const nodeInfo = ref({})
 const treeProps = {
-    label: "title",
+    label: 'title',
     isLeaf: (item) => {
-        return !item.hasChildren;
+        return !item.hasChildren
     },
-};
+}
 const treeNodeTap = (data, node) => {
-    nodeInfo.value = data;
-    searchForm.value.parentId = data.id;
+    nodeInfo.value = data
+    searchForm.value.parentId = data.id
 
     if (node?.level === 1) {
-        searchClick();
+        searchClick()
     } else if (node?.level === 2) {
-        searchForm.value.total = 1;
-        tableData.value = [data];
+        searchForm.value.total = 1
+        tableData.value = [data]
     }
-};
+}
 
 //搜索表单
-const searchForm = ref({ current: 1, size: 30, total: 0 });
+const searchForm = ref({ current: 1, size: 30, total: 0 })
 
 //搜索
 const searchClick = () => {
-    const { parentId } = searchForm.value;
+    const { parentId } = searchForm.value
     if (isNullES(parentId)) {
-        window?.$message?.warning("请先在左侧点击一个节点");
-        return;
+        window?.$message?.warning('请先在左侧点击一个节点')
+        return
     }
-    searchForm.value.current = 1;
-    getTableData();
-};
+    searchForm.value.current = 1
+    getTableData()
+}
 
 //分页
 const pageChange = ({ current, size }) => {
-    const { parentId } = searchForm.value;
+    const { parentId } = searchForm.value
     if (isNullES(parentId)) {
-        window?.$message?.warning("请先在左侧点击一个节点");
-        return;
+        window?.$message?.warning('请先在左侧点击一个节点')
+        return
     }
-    searchForm.value.current = current;
-    searchForm.value.size = size;
-    getTableData();
-};
+    searchForm.value.current = current
+    searchForm.value.size = size
+    getTableData()
+}
 
 //表格数据
-const tableData = ref([]);
+const tableData = ref([])
 const tableColumn = ref([
-    { key: "title", name: "名称" },
-    { key: "elementTotal", name: "总量", width: 80, align: "center" },
-    { key: "tabOwner", name: "所属方", width: 140, align: "center" },
-    { key: "fillRate", name: "填报率", width: 80, align: "center" },
-    { key: "action", name: "操作", width: 220, align: "center" },
-]);
+    { key: 'title', name: '名称' },
+    { key: 'elementTotal', name: '总量', width: 80, align: 'center' },
+    { key: 'tabOwner', name: '所属方', width: 140, align: 'center' },
+    { key: 'fillRate', name: '填报率', width: 80, align: 'center' },
+    { key: 'action', name: '操作', width: 220, align: 'center' },
+])
 
 //获取表格数据
-const tableLoading = ref(false);
+const tableLoading = ref(false)
 const getTableData = async () => {
-    tableData.value = [];
-    tableLoading.value = true;
+    tableData.value = []
+    tableLoading.value = true
     const { data } = await privateApi.tabTypeLazyTree({
         ...searchForm.value,
         total: null,
         projectId: projectId.value,
-    });
-    tableLoading.value = false;
-    tableData.value = getArrValue(data?.records);
-    searchForm.value.total = data?.total || 0;
-};
+    })
+    tableLoading.value = false
+    tableData.value = getArrValue(data?.records)
+    searchForm.value.total = data?.total || 0
+}
 
 //表格被选择
-const tableCheckKeys = ref([]);
+const tableCheckKeys = ref([])
 const tableCheckChange = (rows) => {
-    tableCheckKeys.value = rows;
-};
+    tableCheckKeys.value = rows
+}
 
 //关联清表
 
-const isAssociationShow = ref(false);
-const associationInfo = ref({});
+const isAssociationShow = ref(false)
+const associationInfo = ref({})
 
 const linkExcelClick = async (item) => {
-    associationInfo.value = item;
-    await nextTick();
-    isAssociationShow.value = true;
-};
+    associationInfo.value = item
+    await nextTick()
+    isAssociationShow.value = true
+}
 
 //公式配置
-const rowFormulaClick = (row) => {};
+const rowFormulaClick = (row) => {}
 //分配WBS
-const isAllocateShow = ref(false);
-const allocateWbsInfo = ref({});
+const isAllocateShow = ref(false)
+const allocateWbsInfo = ref({})
 const assignWbs = (row) => {
-    allocateWbsInfo.value = row;
-    isAllocateShow.value = true;
-};
+    allocateWbsInfo.value = row
+    isAllocateShow.value = true
+}
 
 //编辑元素
-const isEditElementShow = ref(false);
-const editElementInfo = ref({});
-const editElementData = ref({});
-const editElementLoading = ref(false);
+const isEditElementShow = ref(false)
+const editElementInfo = ref({})
+const editElementData = ref({})
+const editElementLoading = ref(false)
 const editElement = async (row) => {
-    editElementLoading.value = true;
-    const { code, data } = await excelApi.getExcelHtml({ pkeyId: row.id });
+    editElementLoading.value = true
+    const { code, data } = await excelApi.getExcelHtml({ pkeyId: row.id })
     if (code !== 200 || isNullES(data)) {
-        editElementLoading.value = false;
-        window?.$message.warning("表单异常,请联系管理员");
-        return;
+        editElementLoading.value = false
+        window?.$message.warning('表单异常,请联系管理员')
+        return
     }
-    editElementLoading.value = false;
-    editElementInfo.value = row;
+    editElementLoading.value = false
+    editElementInfo.value = row
     editElementData.value = {
         pid: projectId.value,
         wbsid: wbsId.value,
-    };
-    await nextTick();
-    isEditElementShow.value = true;
-};
+    }
+    await nextTick()
+    isEditElementShow.value = true
+}
 //编辑元素里的跳转页面
 const editElementToPage = async (name) => {
-    const row = deepClone(editElementInfo.value);
+    const row = deepClone(editElementInfo.value)
     //表单调整
-    if (name === "adjustment") {
-        adjustExcelInfo.value = deepClone(row);
-        await nextTick();
-        isAdjustExcelShow.value = true;
+    if (name === 'adjustment') {
+        adjustExcelInfo.value = deepClone(row)
+        await nextTick()
+        isAdjustExcelShow.value = true
     }
     //公式配置
-    if (name === "formula") {
-        console.log("还没做");
+    if (name === 'formula') {
+        console.log('还没做')
     }
-};
+}
 
 //调整表单
-const isAdjustExcelShow = ref(false);
-const adjustExcelLoading = ref(false);
-const adjustExcelInfo = ref({});
+const isAdjustExcelShow = ref(false)
+const adjustExcelLoading = ref(false)
+const adjustExcelInfo = ref({})
 const adjustExcelClick = async (row) => {
-    const { primaryKeyId, excelIds } = row;
+    const { primaryKeyId, excelIds } = row
     if (isNullES(primaryKeyId) || isNullES(excelIds)) {
-        window?.$message.warning("表单值异常,请联系管理员");
-        return;
+        window?.$message.warning('表单值异常,请联系管理员')
+        return
     }
-    adjustExcelLoading.value = true;
+    adjustExcelLoading.value = true
     const { code, data } = await excelApi.getExcelHtml({
         pkeyId: primaryKeyId,
-    });
+    })
     if (code !== 200 || isNullES(data)) {
-        adjustExcelLoading.value = false;
-        window?.$message.warning("表单异常,请联系管理员");
-        return;
+        adjustExcelLoading.value = false
+        window?.$message.warning('表单异常,请联系管理员')
+        return
     }
-    adjustExcelInfo.value = deepClone(row);
-    adjustExcelLoading.value = false;
-    isAdjustExcelShow.value = true;
-};
+    adjustExcelInfo.value = deepClone(row)
+    adjustExcelLoading.value = false
+    isAdjustExcelShow.value = true
+}
 //关闭抽屉
 const drawerClose = () => {
-    isShow.value = false;
-    emit("close");
-};
+    isShow.value = false
+    emit('close')
+}
 //删除元素表
-const batchDelLoad = ref(false);
+const batchDelLoad = ref(false)
 const batchDel = async () => {
     if (tableCheckKeys.value.length == 0) {
-        window?.$message?.warning("请先选择一个元素");
-        return;
+        window?.$message?.warning('请先选择一个元素')
+        return
     }
     HcDelMsg(async (resolve) => {
         //发起请求
-        const ids = arrToId(tableCheckKeys.value);
+        const ids = arrToId(tableCheckKeys.value)
         const { isRes } = await privateApi.delAprojectTab({
             projectId: projectId.value,
             primaryKeyIds: ids,
-        });
-        resolve(); //关闭弹窗
-        if (!isRes) return;
-        window.$message.success("删除成功");
-        getTableData().then();
-    });
-};
+        })
+        resolve() //关闭弹窗
+        if (!isRes) return
+        window.$message.success('删除成功')
+        getTableData().then()
+    })
+}
 
 //引用元素表单库
-const quteEleShow = ref(false);
+const quteEleShow = ref(false)
 const quteEleTableClick = () => {
-    quteEleShow.value = true;
-};
+    quteEleShow.value = true
+}
 const quteEleClose = () => {
-    quteEleShow.value = false;
-    getTableData().then();
-    refreshTree();
-};
+    quteEleShow.value = false
+    getTableData().then()
+    refreshTree()
+}
 </script>