فهرست منبع

取消公式引用菜单

duy 1 ماه پیش
والد
کامیت
90876a8230
1فایلهای تغییر یافته به همراه142 افزوده شده و 9 حذف شده
  1. 142 9
      src/views/data-fill/collapse-form/index.vue

+ 142 - 9
src/views/data-fill/collapse-form/index.vue

@@ -780,7 +780,7 @@
             >
                 <el-form-item label="">
                     <el-radio-group v-model="uploadFileForm.selectedOption">
-                        <el-radio :label="true">
+                        <el-radio :value="true">
                             导入前 <el-input 
                                 v-model="uploadFileForm.pageSize" 
                                 style="width: 120px; display: inline-block" 
@@ -791,7 +791,7 @@
                             />
                             <span class="ml-4">页表格</span>
                         </el-radio>
-                        <el-radio :label="false" class="ml-8">全部</el-radio>
+                        <el-radio :value="false" class="ml-8">全部</el-radio>
                     </el-radio-group>
                 </el-form-item>
             </el-form>
@@ -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([])
@@ -978,6 +980,7 @@ watch(
     { deep: true },
 )
 
+
 //监听变量值
 watch(
     () => [
@@ -1020,6 +1023,17 @@ watch(
     },
 )
 
+//深度监听数据
+watch(
+    () => isStatus.value,
+
+    (status) => {
+          setTableFormMenu(useAppState.projectInfo)
+    },
+    { deep: true },
+)
+
+
 //渲染完成
 onMounted(() => {
      setFormDataNum(props.datas)
@@ -1136,24 +1150,79 @@ 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
+
+    if (isStatus.value === 3) {
+       tableFormMenu.value = [{
+        label: '关联试验文件', key: 'file',
+       }]
+    }
+    
 }
 
 //鼠标右键事件
+
 const tableFormRightTap = (
-    { event, KeyName, startPos, endPos, pkeyId },
+   ele,
     index,
 ) => {
+    console.log(ele, 'ele')
+    
+    const { event, KeyName, startPos, endPos, pkeyId, clearFormula, clearautomatic } = 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.initTableName }
+
+   // 先移除可能存在的旧菜单项
+    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',
+        })
+    }  
+    console.log(clearautomatic, 'clearautomatic')
+    
+   // 先过滤掉可能存在的"取消自动获取数据"(避免重复添加)
+        // tableFormMenu.value = tableFormMenu.value.filter(item => item.key !== 'clearautomatic')
+
+        // if (clearautomatic === '1') {
+        //     // 条件满足时:添加"取消自动获取数据",并移除"设置自动获取数据"
+        //     tableFormMenu.value.push({
+        //         label: '取消自动获取数据',
+        //         key: 'clearautomatic',
+        //     })
+        //     tableFormMenu.value = tableFormMenu.value.filter(item => item.key !== 'auto')
+        // } else {
+        //     // 条件不满足时:确保"设置自动获取数据"存在(如果原本没有可补充,若已有则保留)
+        //     const hasAutoItem = tableFormMenu.value.some(item => item.key === 'auto')
+        //     if (!hasAutoItem) {
+        //         tableFormMenu.value.push({
+        //             label: '设置自动获取数据',
+        //             key: 'auto',
+        //         })
+        //     }
+        // }
+
+     
     contextMenuRef.value?.showMenu(event, false) //展开菜单
 }
 const checkKeys = ref([])
@@ -1231,12 +1300,26 @@ const handleMenuSelect = async ({ key }) => {
 
         }
         getMajorDataTypeOptions()
+    } else if (key === 'clearautomatic') {
+        console.log('取消自动获取数据')
+
+        clearAutomatic(tableFormItemNode.value)
     } else if (key === 'pushCode') {
         pushCodeShow.value = true
 
     } 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)
     }
 }
 
@@ -1875,6 +1958,7 @@ const tableFormSaveClick = async (item, dragItem = null) => {
 
 //保存表单数据
 const inputTitle = ref('')
+const isRemoveForSubTab = ref(null)
 const saveExcelBussData = async (
     { pkeyId },
     dragItem = null,
@@ -1885,7 +1969,11 @@ const saveExcelBussData = async (
     const isRegExp = await refs?.isFormRegExp()
     if (isRegExp) {
         const formData = refs?.getFormData()
-        const { error, code, msg, data } = await wbsApi.saveExcelBussData(formData)
+        const { error, code, msg, data } = await wbsApi.saveExcelBussData({
+            ...formData,
+            isRemoveForSubTab:isRemoveForSubTab.value,
+
+        })
         setDragModalLoading(dragItem)
         if (!error && code === 200) {
             if (showTip) {
@@ -2531,8 +2619,9 @@ const clearSaveClick = async (type)=>{
                 const itemFormData = refs?.getFormData()
                 
                 // 主动调用保存接口 - 使用重新加载后的数据
+                isRemoveForSubTab.value = 1
                 await tableFormSaveClick(itemFormData)
-                
+                 isRemoveForSubTab.value = ''
                 if (DragModalTableForm.value.length > 0) {
                     let draindex = arrIndex(
                         DragModalTableForm.value,
@@ -2573,6 +2662,50 @@ 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,
+        type:1,
+
+
+    })
+    if (!error && code === 200) {
+      window.$message.success(msg)
+    } 
+}
+const clearAutomatic = async ()=>{
+    const { KeyName, pkeyId } = tableFormItemNode.value
+    const refs = await getFormRef(pkeyId)
+    const itemFormData = refs?.getFormData()
+   
+
+    const { error, code, msg, data } = await nodeBaseApi.clearAutomatic(
+
+        {
+            nodeId: treeId.value,
+            pkeyId: pkeyId,
+           
+          
+            paramName:KeyName,
+        },
+    )
+
+
+    if (!error && code === 200) {
+        console.log(data, 'data')
+        itemFormData[KeyName] = data
+        refs?.setFormData(itemFormData)
+       window.$message?.success(msg || '操作成功')
+       autoModalDialog.value = false
+
+
+    }
+}
 // 暴露出去
 defineExpose({
     getFormData,