ZaiZai před 8 měsíci
rodič
revize
3f72360028
1 změnil soubory, kde provedl 76 přidání a 3 odebrání
  1. 76 3
      src/views/desk/wbs/element-lib.vue

+ 76 - 3
src/views/desk/wbs/element-lib.vue

@@ -81,15 +81,32 @@
             :edit-type="1"
             @close="editTableClose"
         />
+
+        <!-- 编辑元素公式 -->
+        <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>
 
 <script setup>
-import { ref, watch } from 'vue'
+import { nextTick, ref, watch } from 'vue'
 import { HcDelMsg } from 'hc-vue3-ui'
-import { arrToId, getArrValue, isNullES } from 'js-fast-way'
+import { arrToId, deepClone, getArrValue, isNullES } from 'js-fast-way'
 import mainApi from '~api/desk/wbs'
 import privateApi from '~api/wbs/private'
+import treeApi from '~api/wbs/tree'
+import HcEditFormula from '~src/views/project/list/edit-formula.vue'
 import HcWebTemplate from './element/web-temp.vue'
 import editElement from './element/edit-element.vue'
 import editEle from './edit-ele.vue'
@@ -241,7 +258,63 @@ const rowNodeClick = (row) => {
 }
 
 //公式配置
-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
+    editFormulaData.value = {
+        node: obj,
+        //wbsId: wbsId.value,
+        nodeId: nodeInfo.value.id,
+        eleId: row.id,
+        eleType: false,
+        globalType: 0,
+    }
+    await nextTick()
+    isEditFormulaShow.value = true
+}
+
+//公式操作完成
+const editFormulaFinish = () => {
 
 }