Ver Fonte

关联试验数据弹窗修改

duy há 2 anos atrás
pai
commit
8092e22094

+ 8 - 0
src/api/modules/tentative/detect/test.js

@@ -137,4 +137,12 @@ export default {
             params: form
         }, msg);
     },
+    //获取试验表中的data数据接口:
+    async getBussddataInfotrial(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-manager/exceltab/get-buss-dataInfo-trial',
+            method: 'get',
+            params: form
+        }, msg);
+    },
 }

+ 2 - 1
src/api/modules/tentative/material/sampling.js

@@ -12,7 +12,8 @@ export default {
     // 获取试验树节点下的记录信息接口:
     async gettrialPage(form, msg = true) {
         return httpApi({
-            url: '/api/blade-business/trial/data/page',
+            // url: '/api/blade-business/trial/data/page',
+            url: '/api/blade-business/trial/data/relation/page',
             method: 'post',
             data: form
         }, msg);

+ 231 - 71
src/views/data-fill/components/ListItem.vue

@@ -136,12 +136,11 @@
     </HcDialog>
 
     <!--关联试验数据-->
-    <HcDialog :show="CTDModal" title="关联试验数据"  widths="84%"  saveText="确认关联" @close="CTDModal = false" @save="CTDModal = false">
+    <HcDialog :show="CTDModal" title="关联试验数据"  widths="84%"   :footer="false"  >
        <div class="adding-form-dialog-box">
             <div class="dialog-tree-box">
                  <el-scrollbar>
                       <ElTree class="hc-tree-node tree-line"
-                        :class="ui"
                         ref="ElTreeRef"
                         :props="ElTreeProps"
                         :load="ElTreeLoadNode"
@@ -150,8 +149,11 @@
                         accordion
                         node-key="primaryKeyId"
                         :default-expanded-keys="defaultExpandedCids"
+                        :autoExpandKeys="CTDTreeAutoExpandKeys"
                         @node-click="CTDElTreeClick"
-                        :indent="0">
+                        :indent="0"
+                       
+                      >
                       </ElTree>
                  </el-scrollbar>
             </div>
@@ -168,9 +170,9 @@
                     </div>
                 </div>
                 <div class="dialog-table">
-                        <HcTable ref="dialogTableRef" :loading="CTDdialogTableLoading" :column="CTDdialogTableColumn" :datas="CTDdialogTableData" isCheck @selection-change="CTDdialogTableSelection">
-                             <template #name="{row}">
-                                <span class="text-link" @click="CTDtableRowName(row)">{{row?.name}}</span>
+                        <HcTable  :loading="CTDdialogTableLoading" :column="CTDdialogTableColumn" :datas="CTDdialogTableData1" >
+                             <template #recordNo="{row}">
+                                <span class="text-link" @click="CTDtableRowName(row)">{{row?.recordNo}}</span>
                             </template>
                         </HcTable>
                 </div>
@@ -183,39 +185,40 @@
 
     </HcDialog>
     <!-- 选择要插入的数据 -->
-      <HcDialog :show="insertDataShow" title="选择需要插入的数据"  widths="84%"  saveText="保存" @close="insertDataShow = false" @save="insertDataShow = false">
+      <HcDialog :show="insertDataShow" title="选择需要插入的数据"  widths="84%"  saveText="保存" @close="cancelinsertData" @save="submitinsertData">
           <div>
                <div class="flex-1" style="padding-left:20px">
                     <HcNewSwitch :datas="tabTypeTab" :keys="tabTypeKey" @change="tabTypeChange" size="default" :round="false"/>
-                      <el-select v-model="testReportId" placeholder="试验记录表" clearable class="ml-2 w-80">
-                                <el-option v-for="item in testReportData" :key="item.value" :label="item['label']" :value="item['value']"/>
+                      <el-select v-model="testReportId" :placeholder="placeholderType" clearable class="ml-2 w-80" @change="testReportIdchange" :loading="insertDataSelectoading">
+                                <el-option v-for="item in testReportData" :key="item.id" :label="item['fullName']" :value="item['id']"/>
                       </el-select>
                 </div>
-                <!-- <div class="copy-node-many-table">
-                    <el-scrollbar v-loading="insertDataTableLoading" >
-                        <el-table :data="insertDataTable" border stripe>
-                            <el-table-column prop="fullName" label="数据名称"/>
-                            <el-table-column prop="action" label="操作" width="120" align="center">
-                                <template #default="{row}">
-                                      <el-checkbox v-model="row.isCheck"  size="large"  @change="insertDataTableCheck(row)"/>
-                                </template>
-                            </el-table-column>
-                        </el-table>
-                    </el-scrollbar>
-                </div> -->
                 <div class="dialog-table-box">
-                     <div class="dialog-table">
+                     <!-- <div class="dialog-table">
                         <HcTable :column="insertDataTableColumn" :datas="insertDataTable" :loading="insertDataTableLoading">
                             <template #tempLow="{row}">{{row['tempLow']}} ~ {{row['tempHigh']}}</template>
                             <template #action="{row}">
-                                     <el-checkbox v-model="row.isCheck"  size="large"  @change="insertDataTableCheck(row)"/>
+                                     <el-checkbox size="large"  @change="insertDataTableCheck(row)"/>
                                
                             </template>
                         </HcTable>
-                     </div>
-                     <div class="dialog-pages">
+                     </div> -->
+                     <!-- <div class="dialog-pages">
                         <HcPages :pages="insertDataPage" @change="insertDataPageChange"/>
-                    </div>
+                    </div> -->
+                 <div class="copy-node-many-table">
+                    <el-scrollbar v-loading="insertDataTableLoading" >
+                        <el-table :data="insertDataTable" border stripe    @selection-change="insertDataTableCheck">
+                            <el-table-column type="selection" width="55" />
+                            <el-table-column prop="key_12__3_1" label="数据名称"/>
+                            <!-- <el-table-column prop="action" label="操作" width="120" align="center">
+                                <template #default="{row}">
+                                      <el-checkbox  size="large"  @change="insertDataTableCheck(row)"/>
+                                </template> -->
+                            <!-- </el-table-column> -->
+                        </el-table>
+                    </el-scrollbar>
+                </div>
                 </div>
           </div>
       </HcDialog>
@@ -256,7 +259,7 @@
             </div>
     </HcDialog>
         <!--关联试验文件-->
-    <HcDialog :show="fileModal" title="关联试验文件"  widths="84%"  saveText="确认关联" @close="fileModal = false" @save="fileModal = false">
+    <HcDialog :show="fileModal" title="关联试验文件"  widths="84%"  saveText="保存" @close="fileModal = false" @save="fileModal = false">
         <div class="radio-box">
                 <el-radio-group v-model="radio">
                     <el-radio :label="3">Option A</el-radio>
@@ -307,6 +310,7 @@ import notableform from '~src/assets/view/notableform.svg';
 import HTableForm from "~src/plugins/HTableForm"
 import WbsTree from "../components/WbsTree.vue"
 import wbsApi from "~api/data-fill/wbs"
+import dataApi from "~api/tentative/detect/test";
 import HcUpload from "./HcUpload.vue"
 import {utilsText, isType, formValidate, deepClone, getObjValue} from "vue-utils-plus"
 import {useAppStore} from "~src/store";
@@ -345,7 +349,19 @@ const props = defineProps({
     drawType:{
         type:Boolean,
         default:false
-    }
+    },
+    wbsTempId: {
+        type: [String,Number],
+        default: ''
+    }, 
+    tenantId: {
+        type: [String,Number],
+        default: ''
+    },
+    wbsType: {
+        type: [String,Number],
+        default: ''
+    },
 })
 const {isString, getObjNullValue, getArrValue} = isType()
 const {setPosInsert, setPosRange} = utilsText()
@@ -358,6 +374,9 @@ const projectInfo = ref(props.projectInfo)
 const useAppState = useAppStore()
 const authBtnTabKey = ref(props.authBtnTabKey)
 const drawType = ref(props.drawType)
+const wbsTempId = ref(props.wbsTempId);
+const tenantId = ref(props.tenantId);
+const wbsType = ref(props.wbsType);
 //全局变量
 const projectId = ref(useAppState.getProjectId);
 
@@ -377,12 +396,31 @@ watch(() => [
     setFormDataNum(datas)
 })
 
+//监听
+// watch(() => [
+//     props.status
+// ], ([val]) => {
+//     //1 未填报,2待上报,3已上报
+//     isStatus.value = val
+// })
 //监听
 watch(() => [
-    props.status
-], ([val]) => {
-    //1 未填报,2待上报,3已上报
-    isStatus.value = val
+    props.autoExpandKeys,
+    props.projectId,
+    props.contractId,
+    props.wbsTempId,
+    props.tenantId,
+    props.wbsType,
+     props.status
+], ([expandKeys, UserProjectId, UserContractId, UserWbsTempId, UserTenantId, UserIdPrefix, wbs_type,val]) => {
+   
+    projectId.value = UserProjectId
+    contractId.value = UserContractId
+    wbsTempId.value = UserWbsTempId
+    tenantId.value = UserTenantId
+    
+    wbsType.value = wbs_type
+     isStatus.value = val
 })
 
 //渲染完成
@@ -648,23 +686,30 @@ const treeLoading = ref(false);
 const copyModalTable=ref([])
 const insertDataShow = ref(false);
 //类型tab数据和相关处理
-const tabTypeKey = ref('1')
+const tabTypeKey = ref('2')
 const tabTypeTab = ref([
     {key:'1',  name: '试验记录表'},
     {key:'2', name: '试验报告单'},
 ]);
+let placeholderType=ref('试验报告单')
 const tabTypeChange = ({key}) => {
     tabTypeKey.value = key
-    // listItemBaseData.value.tableType = key
-    // getSearchNodeTables()
+    if( tabTypeKey.value==='1'){
+        placeholderType='试验记录表'
+    }else{
+         placeholderType='试验报告单'
+    }
+    getSearchNodeTables()
+    
 }
 const insertDataTableLoading=ref(false)
 const insertDataTableColumn = ref(
-      [{key:'key1', name: '数据名称'}],
+      [{key:'key_12__3_1', name: '数据名称'}],
 )
 const insertDataTable=ref([])
-const insertDataTableCheck=()=>{
-    console.log('insertDataTableCheck');
+const multipleSelection = ref([])
+const insertDataTableCheck = (val) => {
+  multipleSelection.value = val
 }
 //分页
 const insertDataPage = ref({current: 1, size: 20, total: 0})
@@ -674,12 +719,18 @@ const insertDataPageChange = ({current, size}) => {
     // getDialogTableData()
 }
 
-const testReportId=ref('1');
-const testReportData=ref(
-    [
-        {id:'1',value:'1',label:'记录表1柔柔弱弱柔柔弱弱柔柔弱弱柔柔弱弱rrr'}
-    ]
-)
+const testReportId=ref('');
+const testReportData=ref([])
+let checPkd=ref([])
+const testReportIdchange = (key) => {
+testReportData.value.forEach((item)=>{
+        if(item.id=key){
+            checPkd.value.push(item)
+        }
+    })
+ console.log(checPkd,'checPkd');
+ getBussddataInfotrialData()
+}
 //树相关变量
 // const primaryKeyId = ref('')
 const nodeItemInfo = ref({})
@@ -968,6 +1019,14 @@ const specialNodeClick = async () => {
 const CTDModal = ref(false)
 //树形结构异步加载数据
 const defaultExpandedCids = ref([])
+//自动展开缓存
+const CTDTreeAutoExpandKeys = ref(getStoreData('CTDElTreeExpandKeys') || [])
+
+const ElTreeProps = ref({
+    label: 'title',
+    children: 'children',
+    isLeaf: 'hasChildren'
+})
 const ElTreeLoadNode = async (node, resolve) => {
     let parentId = '0';
     if (node.level !== 0) {
@@ -984,7 +1043,7 @@ const ElTreeLoadNode = async (node, resolve) => {
     //处理数据
     if (!error && code === 200) {
         let clickKey = '', defaultExpandedArr = [];
-        const keys = TreeExpandKey.value || []
+        const keys = CTDTreeAutoExpandKeys.value || []
         const resData = getArrValue(data)
         for (let i = 0; i < resData.length; i++) {
             resData[i].hasChildren = !resData[i].hasChildren
@@ -1013,7 +1072,7 @@ const ElTreeLoadNode = async (node, resolve) => {
         //最后一个,执行点击
         if (clickKey) {
             await nextTick(() => {
-                document.getElementById(`${idPrefix.value}${clickKey}`)?.click()
+                // document.getElementById(`${idPrefix.value}${clickKey}`)?.click()
             })
         }
     } else {
@@ -1024,12 +1083,101 @@ const ElTreeLoadNode = async (node, resolve) => {
     }
 }
 //节点被点击
-const CTDElTreeClick = async (data,node) => {
-    console.log('获取节点数据');
-    // let autoKeysArr = []
-    // await getNodeExpandKeys(node, autoKeysArr)
-    // const autoKeys = autoKeysArr.reverse()
-    // emit('nodeTap', {node, data, keys: autoKeys})
+const CTDnodeItemInfo = ref({})
+const CTDnodeDataInfo = ref({})
+const CTDdialogTableData1=ref([])
+const CTDdialogTableColumn = ref([
+    {key:'recordNo', name: '报告编号'},
+    {key:'reportDate', name: '报告日期'},
+    {key:'projectPositionName', name: '工程用途及部位'},
+    {key:'detectionResultName', name: '检测结果'},
+])
+const CTDElTreeClick = (data,node,keys) => {
+    CTDnodeItemInfo.value = node
+    CTDnodeDataInfo.value = data
+    getNodeData()
+    //缓存展开的节点
+     CTDTreeAutoExpandKeys.value = keys.value || []
+    setStoreData('CTDElTreeExpandKeys', keys.value)
+
+}
+//获取试验树节点下的记录信息
+const getNodeData = async ()=>{
+    //获取数据
+    CTDdialogTableLoading.value = true
+    const {error, code, data} = await samplingApi.gettrialPage({
+        contractId: contractId.value,
+        nodeId: CTDnodeDataInfo.primaryKeyId,
+        current: CTDsearchFormPage.value.current,
+        size: CTDsearchFormPage.value.size,
+        startTime:CTDsearchFormPage.value.startTime,
+        endTime:CTDsearchFormPage.value.lastTime,
+    })
+    //处理数据
+    if (!error && code === 200) {
+        CTDdialogTableData1.value = getArrValue(data['records'])
+        CTDsearchFormPage.value.total = data.total || 0
+        CTDdialogTableLoading.value = false
+    } else {
+        CTDdialogTableData1.value = []
+        CTDsearchFormPage.value.total = 0
+        CTDdialogTableLoading.value = false
+    }
+}
+//获取试验表中的data数据接口:
+const getBussddataInfotrialData = async ()=>{
+    insertDataTableLoading.value=true;
+    const {error, code, data} = await dataApi.getBussddataInfotrial({
+        id:testReportId.value,
+        pkeyId:checPkd.value[0]['pKeyId'],
+    })
+
+    insertDataTableLoading.value = false
+    if (!error && code === 200) {
+        insertDataTable.value = getArrValue(data)
+    } else {
+        insertDataTable.value = []
+         
+    }
+
+}
+
+//保存试验节点数据
+
+//取消关联数据
+const cancelinsertData = async () => {
+    insertDataShow.value=false
+    
+}
+//确定关联试验数据数据
+const submitinsertData = async () => {
+    if (multipleSelection.value.length>0) {
+        const item = tableFormItemNode.value
+        const form = formData.value[item.index]
+          const val =[]
+         multipleSelection.value.forEach((item)=>{
+             val.push(item['key_12__3_1'])
+         })
+         const newval=val.join('、')
+        formData.value[item.index][item.KeyName] = setPosInsert(item.startPos, item.endPos, form[item.KeyName], newval)
+        insertDataShow.value = false
+        CTDModal.value=false
+        let posVal = item.startPos + newval.length;
+        nextTick(() => {
+            setPosRange(item.KeyName, posVal)
+        })
+    }else{
+         window?.$message?.warning('请选择你要关联的数据')
+    }
+}
+
+    //节点被点击
+const ElTreeClick = async (data,node) => {
+    console.log(data,mode);
+    let autoKeysArr = []
+    await getNodeExpandKeys(node, autoKeysArr)
+    const autoKeys = autoKeysArr.reverse()
+    emit('nodeTap', {node, data, keys: autoKeys})
 }
 //处理自动展开的节点KEY
 const getNodeExpandKeys = async (node, newKeys) => {
@@ -1040,10 +1188,10 @@ const getNodeExpandKeys = async (node, newKeys) => {
         await getNodeExpandKeys(parent, newKeys)
     }
 }
-const CTDbetweenTime = ref(null)
+const CTDbetweenTime = ref([])
 //搜索表单
 const CTDsearchFormPage = ref({
-   betweenTime: null,queryTime: null,  wbsId: null, current: 1, size: 20, total: 0
+   startTime: null,lastTime: null,  wbsId: null, current: 1, size: 20, total: 0
 })
 const CTDsearchFormPageChange = ({current, size}) => {
     CTDsearchFormPage.value.current = current
@@ -1052,32 +1200,44 @@ const CTDsearchFormPageChange = ({current, size}) => {
 }
 const CTDbetweenTimeUpdate = ({arr, query}) => {
     CTDbetweenTime.value = arr
-    CTDsearchFormPage.value.queryTime = query
-}//搜索
+    CTDsearchFormPage.value.startTime = arr[0]
+     CTDsearchFormPage.value.lastTime = arr[1]
+}
+//搜索
 const CTDsearchClick = () => {
     CTDsearchFormPage.value.current = 1;
-    // getTableData()
+    getNodeData()
 }
 const CTDdialogTableLoading = ref (false)
+const insertDataSelectoading=ref(false)
 const CTDdialogTableKeys = ref ([])
-const CTDdialogTableColumn = ref([
-    {key:'title', name: '表单名称'},
-    {key:'tabType', name: '元素表类型'},
-    {key:'elementTotal', name: '元素总量'},
-    {key:'tabOwner', name: '所属方'},
-    {key:'fillRate', name: '填报率'}
-])
-const CTDdialogTableData=[]
 
-const CTDdialogTableSelection = (rows) => {
-    CTDdialogTableKeys.value = rows
-}
+let currowid=ref('')
 //名称被点击
 const CTDtableRowName = (row) => {
-    console.log('行',row);
-   
+     currowid=row.id
+    insertDataShow.value=true
+    getSearchNodeTables()
  }
-
+const getSearchNodeTables = async () => {
+    insertDataSelectoading.value = true
+    const { error, code, data } = await dataApi.searchNodeTables({
+        id: currowid,
+        projectId: projectId.value,
+        contractId: contractId.value,
+        primaryKeyId: CTDnodeDataInfo.value.primaryKeyId,
+        type: authBtnTabKey.value,
+        tableType: tabTypeKey.value
+    })
+    //处理数据
+    insertDataSelectoading.value = false
+    if (!error && code === 200) {
+        testReportData.value = getArrValue(data)
+    } else {
+        testReportData.value = []
+         
+    }
+}
 
 //关联试验文件
 const fileModal = ref(false)

+ 2 - 2
src/views/data-fill/wbs.vue

@@ -162,7 +162,7 @@
                         :contractId="contractId" 
                         @renew="getTableDataAll"
                          :drawType="!isDrawType"
-
+                        :wbsTempId="projectInfo?.referenceWbsTemplateIdTrial" :wbsType="2" :tenantId="userInfo?.tenant_id"
                         />
                     </el-scrollbar>
 
@@ -369,7 +369,7 @@ const contractId = ref(useAppState.getContractId);
 const projectInfo = ref(useAppState.getProjectInfo);
 const contractInfo = ref(useAppState.getContractInfo);
 const isCollapse = ref(useAppState.getCollapse)
-
+const userInfo = ref(useAppState.getUserInfo);
 //路由参数
 const routerQuery = useRoutes?.query;
 const typeName = routerQuery?.type || 'map'