Explorar el Código

取消公式引用

duy hace 1 mes
padre
commit
a9288c283b
Se han modificado 1 ficheros con 54 adiciones y 1 borrados
  1. 54 1
      src/views/tentative/detect/components/ListItem.vue

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

@@ -1088,8 +1088,34 @@ 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')
+
+
+
+// 先移除可能存在的旧菜单项
+    tableFormMenu.value = tableFormMenu.value.filter(
+        item => item.key !== 'cancelGs' && item.key !== 'addGs',
+    )
+
+    // 根据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.initTableName }
     contextMenuRef.value?.showMenu(event) //展开菜单
 }
 
@@ -1107,6 +1133,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 +1832,23 @@ 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,
+        type:2,
+
+
+    })
+    if (!error && code === 200) {
+      window.$message.success(msg)
+    } 
+}
 
 // 暴露出去
 defineExpose({