Selaa lähdekoodia

复制本表不刷新其他数据

duy 1 vuosi sitten
vanhempi
commit
47c05c9731

+ 25 - 5
src/views/tentative/detect/components/ListItem.vue

@@ -250,6 +250,7 @@ import { setStoreValue } from '~uti/storage'
 import {
     arrIndex,
     base64ToFile,
+    clog,
     deepClone,
     downloadBlob,
     formValidate,
@@ -301,13 +302,17 @@ const props = defineProps({
         type: Array,
         default: () => ([]),
     },
+    newlistdata: {
+        type: Array,
+        default: () => ([]),
+    },
     nodeStatus: {
         type: String,
         default: () => (''),
     },
 })
 //事件
-const emit = defineEmits(['renew', 'offsetTop', 'updeviceUseIds', 'upcheckTableId', 'changesdate', 'chageorinData', 'changeIscanclick', 'changesingSaveId'])
+const emit = defineEmits(['renew', 'offsetTop', 'updeviceUseIds', 'upcheckTableId', 'changesdate', 'chageorinData', 'changeIscanclick', 'changesingSaveId', 'getList'])
 const useRoutes = useRoute()
 //路由参数
 const routerQuery = useRoutes?.query
@@ -323,6 +328,7 @@ const tabTypeKeyInfo = ref(props.tabTypeKey)
 const nodeIdvaluedata = ref(props.nodeIdvalue)
 const alllistDataval = ref(props.alllistData)
 const NodeStatusval = ref(props.NodeStatus)
+const newlistdata = ref(props.newlistdata)
 
 //监听
 watch(() => [
@@ -349,11 +355,13 @@ watch(() => [
     props.status,
     props.baseData,
     props.nodeIdvalue,
-], ([val, base, NodeIdvalue]) => {
+    props.newlistdata,
+], ([val, base, NodeIdvalue, Newlistdata]) => {
     //1 未填报,2待上报,3已上报
     isStatus.value = val
     baseData.value = base
     nodeIdvaluedata.value = NodeIdvalue
+    newlistdata.value = Newlistdata
 })
 
 //渲染完成
@@ -914,12 +922,24 @@ const copeBussTab = async (pkeyIds) => {
     })
     if (!error && code === 200) {
         window?.$message?.success('操作成功')
-        renewData(id)
-        chageOrinData()
+        // renewData(id)
+       chageOrinData()
+        getNewList( )
     }
     copyClickLoading.value = false
 }
-
+//获取表单列表
+const getNewList = (id)=>{
+    emit('getList', id)
+   setTimeout(() => {
+    let newObj = newlistdata.value
+    let oldObj = listDatas.value
+    const addedObject = newObj.find(obj => !oldObj.some(oldObj => oldObj.pKeyId === obj.pKeyId))
+    let index = arrIndex(newlistdata.value, 'pKeyId', addedObject.pKeyId) // 1
+    listDatas.value.splice(index, 0, addedObject)
+    formData.value.splice(index, 0, addedObject)
+   }, 1000)
+}
 //隐藏本表
 const hideClick = async ({ pKeyId, isBussShow }, index) => {
     if (isBussShow === 1) {

+ 31 - 3
src/views/tentative/detect/test-form.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="hc-page-box">
-        <HcTabCard :tabs="authBtnTabdata" :tab-key="authBtnTabKey" :disabled="router.currentRoute.value.query?.id && router.currentRoute.value.query?.id.length > 0 || newId.length > 0" @change="authBtnTabClick">
+        <HcTabCard :tabs="authBtnTabdata" :tab-key="authBtnTabKey" :disabled="router.currentRoute.value.query?.id && router.currentRoute.value.query?.id.length > 0 || newId?.length > 0" @change="authBtnTabClick">
             <template #extra>
                 <el-button hc-btn type="info" @click="toBackClick">返回</el-button>
                 <el-button
@@ -70,6 +70,7 @@
                     :node-idvalue="nodeIdvalue"
                     :status="1"
                     :tab-type-key="tabTypeKey"
+                    :newlistdata="newlistdata"
                     @chageorinData="chageorinData"
                     @changeIscanclick="changeIscanclick"
                     @changesdate="changeorinsdate"
@@ -78,6 +79,7 @@
                     @renew="getTableDataAll"
                     @upcheckTableId="upcheckTableId"
                     @updeviceUseIds="updeviceUseIds"
+                    @getList="searchNodeAllTable1"
                 />
             </el-scrollbar>
             <HcStatus v-else v-loading="isLoadList" text="暂无表单" />
@@ -217,7 +219,7 @@ import divisionApi from '~api/data-fill/division'
 import { getStoreValue, setStoreValue } from '~src/utils/storage'
 import TestTree from '../material/components/TestTree.vue'
 import TestTreeMaterial from '../material/components/TestTreeMaterial.vue'
-import { arrToId, getArrValue, getObjValue, isNullES, isString } from 'js-fast-way'
+import { arrIndex, arrToId, getArrValue, getObjValue, isNullES, isString } from 'js-fast-way'
 import { getDictionary } from '~api/other'
 import dayjs from 'dayjs'
 import { eVisaTaskCheckApi } from '~api/other'
@@ -510,7 +512,7 @@ const changeorinsdate = async (pKeyId, isBussShow, id) => {
     
 }
 //复制本表改变原始数据
-const chageorinData = () => {
+const chageorinData = async () => {
     getSearchNodeTablesall(1)
     getSearchNodeTablesall(2)
 }
@@ -996,6 +998,7 @@ const tableFormSaveClick = async () => {
             listItemBaseData.value.id = newId.value
         }
         if (isaddType) { //新增
+            console.log( alllistData.value, ' alllistData.value222222')
             if (setTypes.length > 1) {
                 FormData = alllistData.value
                 listItemBaseData.value.tableType = '1,2'
@@ -1456,6 +1459,31 @@ const treeLoadNode = async ({ node, item, level }, resolve) => {
     checkrelationId.value = getArrValue(data['isSelectedStatus'])
     resolve(getArrValue(data))
 }
+
+const newlistdata = ref([])
+const searchNodeAllTable1 = async (newaddId) => {
+    console.log(newaddId, 'newaddId')
+  console.log('重新获取表单列表')
+
+  const { error, code, data } = await dataApi.searchNodeTables({
+           
+            projectId: projectId.value,
+            contractId: contractId.value,
+            primaryKeyId: nodeId,
+            type: authBtnTabKey.value,
+            tableType: tabTypeKey.value,
+            isAdd: 1,
+        })
+        //处理数据
+
+        if (!error && code === 200) {
+            newlistdata.value = getArrValue(data)
+        } else {
+            newlistdata.value = []
+        }
+        
+      
+}
 </script>
 
 <style lang="scss" scoped>