Sfoglia il codice sorgente

增加公式引用菜单

duy 1 mese fa
parent
commit
e1fe93cbaf

+ 8 - 0
src/api/modules/data-fill/wbs.js

@@ -603,4 +603,12 @@ export default {
             params: form,
         })
     },
+    //公式引用
+     async setFormulaReference(form) {
+        return HcApi({
+            url: '/api/blade-manager/wbsTreeContract/setFormulaReference',
+            method: 'post',
+            data: form,
+        })
+    },
 }

+ 6 - 1
src/global/components/table-form/index.vue

@@ -140,6 +140,8 @@ const getExcelHtml = async () => {
                 emit('render', form)
             },
             onRight: (event, KeyName) => {
+               
+                
                 onRightClick(pkeyId, event, KeyName, pid)
             },
             onLeftClick: (key) => {
@@ -207,7 +209,10 @@ const onRightClick = async (pkeyId, event, KeyName, pid) => {
         const specialDom = await HTableForm.getQuerySelector(KeyName, pid)
         const startPos = specialDom?.selectionStart || 0
         const endPos = specialDom?.selectionEnd || 0
-        emit('rightTap', { event, KeyName, startPos, endPos, pkeyId, pid })
+        console.log(specialDom, 'specialDom')
+        const clearFormula = specialDom.getAttribute('clearFormula') || null
+      
+        emit('rightTap', { event, KeyName, startPos, endPos, pkeyId, pid, clearFormula })
     } catch (error) {
         console.error('Error in onRightClick:', error)
     }

+ 52 - 5
src/views/data-fill/collapse-form/index.vue

@@ -842,6 +842,7 @@ import nodeBaseApi from '~api/data-fill/nodebaseinfo'
 import thirdApi from '~api/tentative/detect/third'
 import { formValidate } from 'js-fast-way'
 import { getDictionaryData } from '~uti/tools'
+
 //参数
 const props = defineProps({
     datas: {
@@ -927,6 +928,7 @@ const isTemplateType = ref(useAppState.contractInfo?.templateType === 2)
 const formDataList = ref([])
 const formKeyIds = ref('')
 const formparentId = ref('')
+const primaryKeyId = ref(props.primaryKeyId)
 
 //处理ref
 const itemRefs = ref([])
@@ -1136,24 +1138,44 @@ const isOpen = infos['isOpenRandomNumber'] ?? 0
     newArr.push({ label: '关联试验文件', key: 'file' })
     newArr.push({ label: '公式参数', key: 'formula' })
     newArr.push({ label: '含水率', key: 'water' })
-
-
+   
     if (isStatus.value !== 3) {
         newArr.push({ label: '清除所有数据', key: 'clear' }),
             newArr.push({ label: '清除字段数据', key: 'clearcur' })
     }
 
-
+    // newArr.push({ label: '取消公式引用', key: 'cancelGs' })
+    // newArr.push({ label: '恢复公式引用', key: 'addGs' })
     tableFormMenu.value = newArr
+    
 }
 
 //鼠标右键事件
+
 const tableFormRightTap = (
-    { event, KeyName, startPos, endPos, pkeyId },
+   ele,
     index,
 ) => {
+    console.log(ele, 'ele')
+    
+    const { event, KeyName, startPos, endPos, pkeyId, clearFormula } = ele
+     const item = listDatas.value[index]
+     console.log(item, 'item')
     //存储临时信息
-    tableFormItemNode.value = { KeyName, index, startPos, endPos, pkeyId }
+    tableFormItemNode.value = { KeyName, index, startPos, endPos, pkeyId, initTableName:item.fullName }
+    console.log(clearFormula, 'clearFormula1111111')
+    if (clearFormula == 0) {
+         tableFormMenu.value.push({
+            label: '取消公式引用', key: 'cancelGs',
+         })
+    } else if (clearFormula == 1) {
+        tableFormMenu.value.push({
+           label: '恢复公式引用', key: 'addGs',
+         })
+    }
+         
+
+     
     contextMenuRef.value?.showMenu(event, false) //展开菜单
 }
 const checkKeys = ref([])
@@ -1237,6 +1259,16 @@ const handleMenuSelect = async ({ key }) => {
     } else if (key === 'deviation') {
          deviationShow.value = true
          getDeviationData()
+    } else if (key === 'cancelGs') {
+        console.log(tableFormItemNode.value, 'tableFormItemNode.value')
+        tableFormItemNode.value.status = 0
+        //取消公式引用
+        handleGsClick(tableFormItemNode.value)
+
+        
+    } else if (key === 'addGs') {
+         tableFormItemNode.value.status = 1
+         handleGsClick(tableFormItemNode.value)
     }
 }
 
@@ -2573,6 +2605,21 @@ const clearSaveClick = async (type)=>{
         })
 
 }
+//公式引用
+const handleGsClick = async (item) => { 
+    const { error, code, msg } = await wbsApi.setFormulaReference({
+        key:item.KeyName,
+        initTableName:item.initTableName,
+        pkeyId:item.pkeyId,
+        status:item.status,
+        pid:treenodeDataInfo.value.primaryKeyId,
+
+
+    })
+    if (!error && code === 200) {
+      window.$message.success(msg)
+    } 
+}
 // 暴露出去
 defineExpose({
     getFormData,

+ 42 - 1
src/views/tentative/detect/components/ListItem.vue

@@ -1088,8 +1088,23 @@ const onRightClick = (event, KeyName, index) => {
     const specialDom = document.getElementById(KeyName + '')
     const startPos = specialDom?.selectionStart || 0
     const endPos = specialDom?.selectionEnd || 0
+    console.log(specialDom, 'specialDom')
+     const item = listDatas.value[index]
+     console.log(baseData.value.id, 'baseData')
+     const clearFormula = specialDom.getAttribute('clearFormula') || null
+      console.log(clearFormula, 'clearFormula')
+     if (clearFormula == 0) {
+         tableFormMenu.value.push({
+            label: '取消公式引用', key: 'cancelGs',
+         })
+    } else if (clearFormula == 1) {
+        tableFormMenu.value.push({
+           label: '恢复公式引用', key: 'addGs',
+         })
+    }
+   
     //存储临时信息
-    tableFormItemNode.value = { KeyName, index, startPos, endPos, pkeyId: formKeyIds.value }
+    tableFormItemNode.value = { KeyName, index, startPos, endPos, pkeyId: formKeyIds.value, clearFormula, initTableName:item.fullName }
     contextMenuRef.value?.showMenu(event) //展开菜单
 }
 
@@ -1107,6 +1122,16 @@ const handleMenuSelect = ({ key }) => {
 
         })
         getequipmentMenusData()
+    } else if (key === 'cancelGs') {
+        console.log(tableFormItemNode.value, 'tableFormItemNode.value')
+        tableFormItemNode.value.status = 0
+        //取消公式引用
+        handleGsClick(tableFormItemNode.value)
+
+        
+    } else if (key === 'addGs') {
+         tableFormItemNode.value.status = 1
+         handleGsClick(tableFormItemNode.value)
     }
 }
 
@@ -1796,6 +1821,22 @@ const getTheOrderDataClick = async (item, index) => {
     //渲染表单
     await getExcelHtml(item, index)
 }
+//公式引用
+//公式引用
+const handleGsClick = async (item) => { 
+    const { error, code, msg } = await wbsApi.setFormulaReference({
+        key:item.KeyName,
+        initTableName:item.initTableName,
+        pkeyId:item.pkeyId,
+        status:item.status,
+        pid: baseData.value.id,
+
+
+    })
+    if (!error && code === 200) {
+      window.$message.success(msg)
+    } 
+}
 
 // 暴露出去
 defineExpose({