ZaiZai пре 2 месеци
родитељ
комит
cd90b2b71c
2 измењених фајлова са 165 додато и 110 уклоњено
  1. 66 17
      src/views/project/list/edit-formula.vue
  2. 99 93
      src/views/project/list/independent/index.vue

+ 66 - 17
src/views/project/list/edit-formula.vue

@@ -851,7 +851,7 @@ const treeResetFunLazyLoad = async (node, resolve) => {
     const { level, data } = node
     treeResetFunItemData.value = data
     let parentId = level !== 0 ? data.id : 12345678910
-    const { eleType, node: dataNode, tableType } = getObjValue(dataInfo.value)
+    const { eleType, node: dataNode, tableType, pid } = getObjValue(dataInfo.value)
     const treeNode = getObjValue(dataNode)
     if (level === 0) treeResetFunLoading.value = true
     if (!eleType) {
@@ -885,7 +885,35 @@ const treeResetFunLazyLoad = async (node, resolve) => {
         //获取节点详情
         await getNodeDetailApi(treeNode)
     } else if (eleType) {
-        resolve([])
+        //获取接口数据
+        const { data } = await privateApi.tabTypeLazyTree({
+            parentId,
+            projectId: pid,
+            pcurrent: 1,
+            size: 99999,
+        })
+        const res = getArrValue(data.records)
+        treeResetFunLoading.value = false
+        resolve(res)
+        //处理返回的数据
+        await nextTick()
+        //处理展开
+        try {
+            let expandId = Number(treeNode.parentId) - 1
+            if (!isNullES(expandId) && expandId >= 0) node.childNodes[expandId].expand()
+        } catch { /* empty */
+        }
+        //处理选中
+        try {
+            const paramsId = treeNode.id
+            if (!isNullES(paramsId)) {
+                treeResetFunLazyRef.value?.setCurrentKey(paramsId)
+                treeRangeSelectLazyRef.value?.setCurrentKey(paramsId)
+            }
+        } catch { /* empty */
+        }
+        //获取节点详情
+        await getNodeDetailApi(treeNode)
     }
 }
 
@@ -907,23 +935,44 @@ const resetFunTreeSearch = async () => {
         isResetFunTreeLazy.value = true
         return
     }
-    isResetFunTreeLazy.value = false
-    treeResetFunLoading.value = true
-    const obj = treeResetFunItemData.value
-    const parentId = obj.hasChildren ? obj.id : ''
-    const { data, code } = await privateApi.tabTypeLazyTreeAll({
-        parentId: parentId,
-        current: 1,
-        size: 1000,
-        titleName: resetFunTree.value,
-    })
-    if (code !== 200) {
-        resetFunTreeAll.value = []
+    const { eleType, node: dataNode, tableType, pid } = getObjValue(dataInfo.value)
+    if (!eleType) {
+        isResetFunTreeLazy.value = false
+        treeResetFunLoading.value = true
+        const obj = treeResetFunItemData.value
+        const parentId = obj.hasChildren ? obj.id : ''
+        const { data, code } = await privateApi.tabTypeLazyTreeAll({
+            parentId: parentId,
+            current: 1,
+            size: 1000,
+            titleName: resetFunTree.value,
+        })
+        if (code !== 200) {
+            resetFunTreeAll.value = []
+            treeResetFunLoading.value = false
+            return
+        }
+        resetFunTreeAll.value = getArrValue(data?.records)
+        treeResetFunLoading.value = false
+    } else if (eleType) {
+        isResetFunTreeLazy.value = false
+        treeResetFunLoading.value = true
+        const obj = treeResetFunItemData.value
+        const parentId = obj.hasChildren ? obj.id : ''
+        const { data, code } = await privateApi.tabTypeLazyTree({
+            parentId: parentId,
+            current: 1,
+            size: 1000,
+            titleName: resetFunTree.value,
+        })
+        if (code !== 200) {
+            resetFunTreeAll.value = []
+            treeResetFunLoading.value = false
+            return
+        }
+        resetFunTreeAll.value = getArrValue(data?.records)
         treeResetFunLoading.value = false
-        return
     }
-    resetFunTreeAll.value = getArrValue(data?.records)
-    treeResetFunLoading.value = false
 }
 
 //重置函数元素搜索

+ 99 - 93
src/views/project/list/independent/index.vue

@@ -1,82 +1,32 @@
 <template>
-    <hc-drawer
-        v-model="isShow"
-        to-id="hc-main-box"
-        is-close
-        @close="drawerClose"
-    >
+    <hc-drawer v-model="isShow" to-id="hc-main-box" is-close @close="drawerClose">
         <hc-body split :options="{ sizes: [14, 96] }">
             <template #left>
                 <hc-card scrollbar>
                     <h3 class="mb-2">引用元素表</h3>
-                    <ElTree
-                        v-if="isShowTree"
-                        :load="treeLoadNode"
-                        :props="treeProps"
-                        accordion
-                        highlight-current
-                        lazy
-                        @node-click="treeNodeTap"
-                    />
+                    <ElTree v-if="isShowTree" :load="treeLoadNode" :props="treeProps" accordion highlight-current lazy @node-click="treeNodeTap" />
                 </hc-card>
             </template>
             <hc-card>
                 <template #header>
                     <div class="w-400px">
-                        <hc-search-input
-                            v-model="searchForm.titleName"
-                            @search="searchClick"
-                        />
+                        <hc-search-input v-model="searchForm.titleName" @search="searchClick" />
                     </div>
                 </template>
                 <template #extra>
-                    <el-button hc-btn type="primary" @click="quteEleTableClick">
-                        引用元素表单库
-                    </el-button>
-                    <el-button
-                        hc-btn
-                        type="danger"
-                        :loading="batchDelLoad"
-                        @click="batchDel"
-                    >
-                        删除元素表
-                    </el-button>
+                    <el-button hc-btn type="primary" @click="quteEleTableClick">引用元素表单库</el-button>
+                    <el-button hc-btn type="danger" :loading="batchDelLoad" @click="batchDel">删除元素表</el-button>
                 </template>
                 <hc-table
-                    :column="tableColumn"
-                    :datas="tableData"
-                    :loading="tableLoading"
-                    :index-style="{ width: 60 }"
-                    is-check
-                    :check-style="{ width: 29 }"
-                    @selection-change="tableCheckChange"
+                    :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }"
+                    is-check :check-style="{ width: 29 }" @selection-change="tableCheckChange"
                 >
                     <template #action="{ row }">
-                        <el-link type="primary" @click="linkExcelClick(row)">
-                            关联清表
-                        </el-link>
-                        <el-link
-                            v-loading="editElementLoading"
-                            type="primary"
-                            :disabled="row.excelIds == -1"
-                            @click="editElement(row)"
-                        >
-                            编辑元素
-                        </el-link>
-                        <el-link
-                            v-loading="adjustExcelLoading"
-                            type="primary"
-                            :disabled="row.excelIds == -1"
-                            @click="adjustExcelClick(row)"
-                        >
-                            调整表单
-                        </el-link>
-                        <el-link type="primary" @click="rowFormulaClick(row)">
-                            编辑公式
-                        </el-link>
-                        <el-link type="primary" @click="assignWbs(row)">
-                            分配WBS
-                        </el-link>
+                        <el-link type="primary" @click="linkExcelClick(row)">关联清表</el-link>
+                        <el-link v-loading="editElementLoading" type="primary" :disabled="row.excelIds == -1" @click="editElement(row)">编辑元素</el-link>
+                        <el-link v-loading="adjustExcelLoading" type="primary" :disabled="row.excelIds == -1" @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>
@@ -85,38 +35,28 @@
             </hc-card>
         </hc-body>
         <!-- 引用元素表 -->
-        <quteElePage
-            v-model="quteEleShow"
-            :project-id="projectId"
-            @close="quteEleClose"
-        />
+        <quteElePage v-model="quteEleShow" :project-id="projectId" @close="quteEleClose" />
         <!-- 关联清表 -->
-        <HcAssociationList
-            v-model="isAssociationShow"
-            :info="associationInfo"
-            :type="2"
-        />
+        <HcAssociationList v-model="isAssociationShow" :info="associationInfo" :type="2" />
         <!-- 编辑元素 -->
-        <HcEditElement
-            v-model="isEditElementShow"
-            :info="editElementInfo"
-            :data="editElementData"
-            :type="2"
-            @to-page="editElementToPage"
-        />
+        <HcEditElement v-model="isEditElementShow" :info="editElementInfo" :data="editElementData" :type="2" @to-page="editElementToPage" />
         <!-- 调整表单 -->
-        <HcAdjustExcel
-            v-model="isAdjustExcelShow"
-            :info="adjustExcelInfo"
-            :type="2"
-        />
+        <HcAdjustExcel v-model="isAdjustExcelShow" :info="adjustExcelInfo" :type="2" />
         <!-- 分配WBS -->
-        <allocateWbs
-            v-model="isAllocateShow"
-            :wbs-type="wbsType"
-            :project-id="projectId"
-            :data="allocateWbsInfo"
-        />
+        <allocateWbs v-model="isAllocateShow" :wbs-type="wbsType" :project-id="projectId" :data="allocateWbsInfo" />
+        <!-- 编辑元素公式 -->
+        <hc-dialog v-model="elementFormulasShow" :footer="false" title="元素公式" is-table widths="660px" @close="elementFormulasClose">
+            <template #search>
+                <hc-search-input v-model="formulaInput" @search="searchFormulaClick" />
+            </template>
+            <hc-table :column="formulaTableColumn" :datas="formulaTableData" :is-current-row="false" :is-index="false">
+                <template #action="{ row }">
+                    <el-link :type="row.globalFormula === 1 ? 'warning' : 'primary'" @click="toFormulaGlobal(row)">全局公式</el-link>
+                </template>
+            </hc-table>
+        </hc-dialog>
+        <!-- 编辑公式 -->
+        <HcEditFormula v-model="isEditFormulaShow" :data="editFormulaData" @finish="editFormulaFinish" />
     </hc-drawer>
 </template>
 
@@ -124,13 +64,18 @@
 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 HcEditFormula from '~src/views/project/list/edit-formula.vue'
 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'
+
+import privateApi from '~api/wbs/private'
+import excelApi from '~api/exctab/exceltab'
+import treeApi from '~api/wbs/tree'
+
 const props = defineProps({
     projectId: {
         type: String,
@@ -305,9 +250,70 @@ const linkExcelClick = async (item) => {
 }
 
 //公式配置
-const rowFormulaClick = (row) => {
+const elementFormulasObj = ref({})
+const elementFormulasShow = ref(false)
+const rowFormulaClick = async (row) => {
+    elementFormulasObj.value = row
+    elementFormulasShow.value = true
+    const { data } = await treeApi.getTableElments({
+        id: row.initTableId,
+    })
+    const arr = getArrValue(data)
+    formulaTableData.value = arr
+    formulaTableList.value = deepClone(arr)
+}
+
+
+//元素公式列表
+const formulaTableColumn = [
+    { key: 'eName', name: '字段信息' },
+    { key: 'action', name: '操作', width: 80, align: 'center' },
+]
+const formulaTableData = ref([])
+const formulaTableList = ref([])
 
+// 搜索元素公式
+const formulaInput = ref('')
+const searchFormulaClick = () => {
+    const arr = formulaTableList.value
+    formulaTableData.value = arr.filter(({ eName }) => {
+        return eName.indexOf(formulaInput.value) > -1
+    })
+}
+
+//编辑元素公式关闭
+const elementFormulasClose = () => {
+    elementFormulasShow.value = false
+    formulaTableData.value = []
+    formulaTableList.value = []
 }
+
+//全局公式
+const editFormulaData = ref({})
+const isEditFormulaShow = ref(false)
+const toFormulaGlobal = async (row) => {
+    elementFormulasClose()
+    const obj = elementFormulasObj.value
+    const nodeId = nodeInfo.value.id
+    editFormulaData.value = {
+        node: obj,
+        pid: projectId.value,
+        //wbsId: wbsId.value,
+        nodeId: nodeId,
+        eleId: row.id,
+        eleType: true,
+        globalType: 1,
+    }
+    await nextTick()
+    isEditFormulaShow.value = true
+}
+
+//公式操作完成
+const editFormulaFinish = () => {
+
+}
+
+
 //分配WBS
 const isAllocateShow = ref(false)
 const allocateWbsInfo = ref({})