소스 검색

坟地专心协议修改

duy 1 년 전
부모
커밋
33239c5eca

+ 7 - 5
src/views/agree/special/collapse-form/form-item.vue

@@ -138,9 +138,9 @@ onMounted(async () => {
     //获取已填写的数据
     await getTableFormInfo(keyId.value)
     //按键key列表
-    await getHtmlBussColsApi(keyId.value)
+    await getHtmlBussColsApi(tableId.value)
     //渲染表单
-    await getExcelHtml(keyId.value)
+    await getExcelHtml(tableId.value)
     loading.value = false
 })
 
@@ -176,6 +176,7 @@ const getTableFormInfo = async (pkeyId) => {
     if (pkeyId) {
         const { error, code, data } = await landApi.getBussInfo({
             id: pkeyId,
+            tableId:tableId.value,
         }, false)
         const resData = getObjVal(data)
         if (!error && code === 200 && resData) {
@@ -192,7 +193,7 @@ const getTableFormInfo = async (pkeyId) => {
         }
     } else {
         tableFormInfo.value = {}
-        window?.$message?.warning('pkeyId为空')
+        // window?.$message?.warning('pkeyId为空')
     }
 }
 
@@ -201,7 +202,7 @@ const colsKeys = ref([])
 const getHtmlBussColsApi = async (pkeyId) => {
     if (pkeyId) {
         const { error, code, data } = await landApi.getBussCols({
-            id: pkeyId,
+            tableId: pkeyId,
        
         }, false)
         if (!error && code === 200) {
@@ -223,9 +224,10 @@ const getHtmlBussColsApi = async (pkeyId) => {
 //获取模板标签数据
 const excelHtml = ref('')
 const getExcelHtml = async (pkeyId) => {
+    console.log(pkeyId, 'pkeyId')
     if (pkeyId) {
         const { error, code, data } = await landApi.getExcelHtml({
-            id: pkeyId,
+            tableId: pkeyId,
         }, false)
         const resData = isString(data) ? data || '' : ''
         if (!error && code === 200 && resData) {

+ 41 - 16
src/views/agree/special/collapse-form/index.vue

@@ -15,7 +15,7 @@
                                 <el-button :disabled="!item?.pdfUrl" plain type="primary" @click.stop="previewClick(item)">
                                     预览
                                 </el-button>
-                                <el-button plain type="primary" :loading="tableFormSaveLoading" @click="tableFormSaveClick(item)">
+                                <el-button plain type="primary" :loading="tableFormSaveLoading" @click="tableFormSaveClick(item, null, index)">
                                     保存
                                 </el-button>
                             </div>
@@ -45,7 +45,7 @@
                                 :pid="`table-form-${item?.id}`"
                                 :area-id="areaId"
                                 :table-id="item.tableId"
-                                :agreement-id="agreementId"
+                                :agreement-id="item.agreementId"
                                 style="width: 100%;"
                                 @excelBodyTap="excelTableFormClick($event)"
                                 @render="tableFormRender($event, item, index)"
@@ -106,6 +106,7 @@ import { useAppStore } from '~src/store'
 import landApi from '~api/agree/land.js'
 import TableFormItem from './form-item.vue'
 import NoDataSvg from '~src/assets/view/no-data.svg'
+import { getStoreValue, setStoreValue } from '~uti/storage'
 import {
     arrIndex, deepClone, getArrValue,
     getObjVal, getObjValue, isNullES, setPosRange,
@@ -226,6 +227,7 @@ const closeIconArr = [
 watch(() => [
     props.datas,
 ], ([datas]) => {
+    console.log(datas, 'datas')
     setFormDataNum(datas)
 }, { deep: true })
 
@@ -285,7 +287,9 @@ const changeFormDatas = (pKeyId, type) => {
 const ActiveKey = ref('')
 const CollapseChange = (name) => {
     ActiveKey.value = name
+    setStoreValue('activeKey', ActiveKey.value)
     let index = getCollapseItemIndex(name)
+  
     if (index > -1) {
         getOffsetTop(name)
         const item = listDatas.value[index]
@@ -303,7 +307,9 @@ const CollapseChange = (name) => {
         formparentId.value = ''
     }
 }
-
+const setCollapseKey = (key) => {
+    CollapseChange(key)
+}
 //初始设置
 const setFormDataNum = (datas) => {
     itemRefs.value = []
@@ -367,6 +373,7 @@ const setChangeFormDatas = async (pkeyId, type) => {
 const DragModalTableForm = ref([])
 const DragModalHeight = ref(600)
 const windowClick = async (item, indexs) => {
+
     const list = deepClone(DragModalTableForm.value)
     let index = arrIndex(list, 'pkeyId', item.id)
     if (!item.isWindow) {
@@ -388,7 +395,7 @@ const windowClick = async (item, indexs) => {
             list.push(newTableForm)
         }
         DragModalTableForm.value = list
-        ActiveKey.value = ''
+    
     } else {
         await setChangeFormDatas(item?.id, 'collapse')
         //处理表单的ref
@@ -419,6 +426,7 @@ const setInitDragModalTableForm = (item, index) => {
         index: index,
         item: item,
         id:item.id,
+        tableId:item.tableId,
     }
 }
 
@@ -518,6 +526,7 @@ const dragNodeMoreMenuTap = ({ key }, items) => {
 
 const copyClickLoading = ref(false)
 const copyClick = async (items) => {
+    items.isTableRender = true
     const { id, isTableRender, isTableForm } = items
     if (id) {
         if (isStatus.value !== 3) {
@@ -529,7 +538,7 @@ const copyClick = async (items) => {
                 copyClickLoading.value = true
                 const isSave = await saveExcelBussData(items, null, false)
                 if (isSave) {
-                    await copeBussTab(id)
+                    await copeBussTab(id, isSave)
                 } else {
                     copyClickLoading.value = false
                     window?.$message?.warning('复制本表操作失败')
@@ -546,7 +555,7 @@ const copyClick = async (items) => {
  }
 
 //复制表的请求
-const copeBussTab = async (pkeyId) => {
+const copeBussTab = async (pkeyId, aid) => {
     copyClickLoading.value = true
     const { error, code } = await landApi.copeTab({
         id: pkeyId,
@@ -554,7 +563,7 @@ const copeBussTab = async (pkeyId) => {
     copyClickLoading.value = false
     if (!error && code === 200) {
         window?.$message?.success('操作成功')
-        renewData()
+        renewData(aid)
     }
 }
 
@@ -580,14 +589,18 @@ const fileListData = ref([])
 
 //单个保存
 const tableFormSaveLoading = ref(false)
-const tableFormSaveClick = async (item, dragItem = null) => {
+const tableFormSaveClick = async (item, dragItem = null, index) => {
+  
     if (isStatus.value !== 3) {
+        setStoreValue('activeKey', ActiveKey.value)
         tableFormSaveLoading.value = true
         const isSave = await saveExcelBussData(item, dragItem)
         if (isSave) {
-            await getBussPdfInfo(item, dragItem)
+           
             tableFormSaveLoading.value = false
-            renewData()
+            agreementId.value = agreementId
+            renewData(isSave)
+            // await getBussPdfInfo(item, dragItem)
         } else {
             tableFormSaveLoading.value = false
         }
@@ -603,13 +616,14 @@ const saveExcelBussData = async ({ id }, dragItem = null, showTip = true) => {
     const isRegExp = await refs?.isFormRegExp()
     if (isRegExp) {
         const formData = refs?.getFormData()
-        const { error, code } = await landApi.saveBussData(formData)
+        const { error, code, data } = await landApi.saveBussData(formData)
+     
         setDragModalLoading(dragItem)
         if (!error && code === 200) {
             if (showTip) {
                 window?.$message?.success('保存成功')
             }
-            return true
+            return data
         } else {
             return false
         }
@@ -622,6 +636,7 @@ const saveExcelBussData = async ({ id }, dragItem = null, showTip = true) => {
 //预览PDF
 const getBussPdfInfo = async ({ id }, dragItem = null, showTip = true) => {
     setDragModalLoading(dragItem, '获取pdf中...', true)
+    console.log(id, 'id')
     const { error, code, data } = await landApi.getSingleBussPdfInfo({
         id: id,
     }, false)
@@ -641,9 +656,13 @@ const getBussPdfInfo = async ({ id }, dragItem = null, showTip = true) => {
 
 
 //通知数据更新
-const renewData = () => {
-    emit('renew')
+const renewData = (id) => {
+
+    const activeKey = getStoreValue('activeKey')
+    console.log(activeKey, 'activeKey111111')
+    emit('renew', id, activeKey)
     ActiveKey.value = ''
+  
 }
 
 //设置表单的加载状态
@@ -661,7 +680,10 @@ const setDragModalLoading = (dragItem, text = '保存中...', show = false) => {
 const getFormRef = async (pkeyId) => {
     const itemRef = itemRefs.value
     const index = arrIndex(itemRef, 'pKeyId', pkeyId)
-    return itemRef[index].ref
+    if (index !== -1) {
+        return itemRef[index].ref
+    }
+   
 }
 
 //删除打开的窗口
@@ -677,8 +699,10 @@ const delWindowRefs = (pkeyId) => {
 
 //计算展开高度和滚动位置
 const getOffsetTop = (key = '') => {
+    console.log(key, 'key')
     if (key) {
         const dom = document.getElementById(key)
+        console.log(dom, 'dom')
         if (!draw_type.value) {
             if (dom?.offsetTop >= 583 && key) {
                 emit('offsetTop', dom?.offsetTop - 583)
@@ -686,7 +710,7 @@ const getOffsetTop = (key = '') => {
                 emit('offsetTop', dom?.offsetTop)
             }
         } else {
-            if (dom.offsetTop >= 424 && key) {
+            if (dom?.offsetTop >= 424 && key) {
                 emit('offsetTop', dom?.offsetTop - 424)
             } else {
                 emit('offsetTop', dom?.offsetTop)
@@ -853,6 +877,7 @@ defineExpose({
     getFormRegExpJson,
     getActiveKey,
     setActiveKey,
+    setCollapseKey,
 })
 </script>
 

+ 45 - 15
src/views/agree/special/form.vue

@@ -13,7 +13,7 @@
                 :area-id="areaId"
                 :agreement-id="agreementId"
                 :draw-type="isDrawType"
-                @renew="updateGetTablesData(agreementId)"
+                @renew="updateGetTablesData"
             />
             <HcStatus v-else text="暂无表单" />
         </el-scrollbar>
@@ -39,19 +39,20 @@
                 <span>取消并返回</span>
             </el-button>
         </template>
-        <HcDialog is-to-body :show="addModal" title="上传附件协议" @close="testModalClose">
-            <HcUpload :datas="uploadData" :file-list="fileListData" :is-canupload="false" action="/api/blade-manager/exceltab/add-bussfile-node" accept="application/pdf" accept-tip="允许格式:pdf" @change="uploadChange" />
+        <HcDialog is-to-body :show="addModal" title="上传附件协议" :footer="false" @close="testModalClose">
+            <HcUpload :datas="uploadData" :file-list="fileListData" :is-canupload="false" action="/api/blade-land/agreementFile/add-buss-file" accept="application/pdf" accept-tip="允许格式:pdf" @change="uploadChange" />
         </HcDialog>
     </HcCard>
 </template>
 
 <script setup>
-import { onActivated, ref } from 'vue'
+import { nextTick, onActivated, ref } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import CollapseForm from './collapse-form/index.vue'
 import landApi from '~api/agree/land.js'
 import { useAppStore } from '~src/store'
-import { getArrValue, getObjVal } from 'js-fast-way'
+import { getArrValue, isNullES } from 'js-fast-way'
+import { getStoreValue } from '~uti/storage'
 import HcUpload from './components/HcUpload.vue'
 
 const useAppState = useAppStore()
@@ -63,7 +64,6 @@ const useRoutes = useRoute()
 const dataType = ref(useRoutes?.query?.type ?? 'view')
 const agreementId = ref(useRoutes?.query?.id ?? '')
 const areaId = ref(useRoutes?.query?.areaId ?? '')
-const isDrawType = ref(true)
 
 //缓存页面被激活时
 onActivated(() => {
@@ -81,7 +81,6 @@ onActivated(() => {
 
 const listItemScrollRef = ref(null)
 
-//返回
 //返回
 const goBackClick = async () => {
     const { error, code, data } = await landApi.unSave({
@@ -110,14 +109,17 @@ const searchNodeAllTable = async () => {
     //处理数据
 
     if (!error && code === 200) {
-        agreementId.value = data
-        updateGetTablesData(data)
+        // agreementId.value = data
+        // updateGetTablesData(data)
+        ListItemDatas.value = getArrValue(data)
     } else {
-        agreementId.value = ''
+        // agreementId.value = ''
+        ListItemDatas.value = []
     }
 }
 //编辑获取表单列表
-const updateGetTablesData = async (id) => {
+const updateGetTablesData = async (id, key) => {
+    agreementId.value = id
     ListItemDatas.value = []
     ListItemLoading.value = true
     const { error, code, data } = await landApi.updateGetTables({
@@ -131,11 +133,19 @@ const updateGetTablesData = async (id) => {
     } else {
         ListItemDatas.value = []
     }
+    //保存后自动展开到当前表单
+    if (!isNullES(key)) {
+        await nextTick(() => {
+            ListItemRef.value?.setCollapseKey(key)
+        })
+    }
 }
 
 //保存
 const ListItemRef = ref(null)
 const tableFormSaveLoading = ref(false)
+//是否是抽屉
+const isDrawType = ref(true)
 const tableFormSaveClick = async () => {
     //获取数据
     let FormData = []
@@ -149,12 +159,15 @@ const tableFormSaveClick = async () => {
         const { error, code, data } = await landApi.saveBussData({
             dataInfo: { orderList: FormData },
         })
+        agreementId.value = data
         tableFormSaveLoading.value = false
         if (!error && code === 200) {
             window?.$message?.success('保存成功')
             dataType.value = 2
-             await bussPdfsClick()
-             updateGetTablesData(agreementId.value)
+            //  await bussPdfsClick()
+            const activeKey = getStoreValue('activeKey')
+            await updateGetTablesData(agreementId.value, activeKey)
+            
         }
     } else {
         console.log('预览')
@@ -183,15 +196,32 @@ const testModalClose = ()=>{
 }
 const addFile = ()=>{
     addModal.value = true
+    getBussFileList(agreementId.value)
+         //上传的配置
+         uploadData.value = {
+                agreementId:agreementId.value,
+                projectId: projectId.value,
+            }
 }
 const uploadData = ref({})
 const fileListData = ref([])
 //上传文件
 const uploadChange = async ({ type }) => {
     if (type === 'success') {
-        // getBussFileList(primaryKeyId.value)
+        getBussFileList(agreementId.value)
     } else if (type === 'del') {
-        // getBussFileList(primaryKeyId.value)
+        getBussFileList(agreementId.value)
+    }
+}
+//获取文件列表
+const getBussFileList = async (pkeyId) => {
+    const { error, code, data } = await landApi.getBussFileList({
+        agreementId: pkeyId,
+    })
+    if (!error && code === 200) {
+        fileListData.value = getArrValue(data)
+    } else {
+        fileListData.value = []
     }
 }
 </script>

+ 7 - 5
src/views/agree/tomb/collapse-form/form-item.vue

@@ -138,9 +138,9 @@ onMounted(async () => {
     //获取已填写的数据
     await getTableFormInfo(keyId.value)
     //按键key列表
-    await getHtmlBussColsApi(keyId.value)
+    await getHtmlBussColsApi(tableId.value)
     //渲染表单
-    await getExcelHtml(keyId.value)
+    await getExcelHtml(tableId.value)
     loading.value = false
 })
 
@@ -176,6 +176,7 @@ const getTableFormInfo = async (pkeyId) => {
     if (pkeyId) {
         const { error, code, data } = await landApi.getBussInfo({
             id: pkeyId,
+            tableId:tableId.value,
         }, false)
         const resData = getObjVal(data)
         if (!error && code === 200 && resData) {
@@ -192,7 +193,7 @@ const getTableFormInfo = async (pkeyId) => {
         }
     } else {
         tableFormInfo.value = {}
-        window?.$message?.warning('pkeyId为空')
+        // window?.$message?.warning('pkeyId为空')
     }
 }
 
@@ -201,7 +202,7 @@ const colsKeys = ref([])
 const getHtmlBussColsApi = async (pkeyId) => {
     if (pkeyId) {
         const { error, code, data } = await landApi.getBussCols({
-            id: pkeyId,
+            tableId: pkeyId,
        
         }, false)
         if (!error && code === 200) {
@@ -223,9 +224,10 @@ const getHtmlBussColsApi = async (pkeyId) => {
 //获取模板标签数据
 const excelHtml = ref('')
 const getExcelHtml = async (pkeyId) => {
+    console.log(pkeyId, 'pkeyId')
     if (pkeyId) {
         const { error, code, data } = await landApi.getExcelHtml({
-            id: pkeyId,
+            tableId: pkeyId,
         }, false)
         const resData = isString(data) ? data || '' : ''
         if (!error && code === 200 && resData) {

+ 41 - 16
src/views/agree/tomb/collapse-form/index.vue

@@ -15,7 +15,7 @@
                                 <el-button :disabled="!item?.pdfUrl" plain type="primary" @click.stop="previewClick(item)">
                                     预览
                                 </el-button>
-                                <el-button plain type="primary" :loading="tableFormSaveLoading" @click="tableFormSaveClick(item)">
+                                <el-button plain type="primary" :loading="tableFormSaveLoading" @click="tableFormSaveClick(item, null, index)">
                                     保存
                                 </el-button>
                             </div>
@@ -45,7 +45,7 @@
                                 :pid="`table-form-${item?.id}`"
                                 :area-id="areaId"
                                 :table-id="item.tableId"
-                                :agreement-id="agreementId"
+                                :agreement-id="item.agreementId"
                                 style="width: 100%;"
                                 @excelBodyTap="excelTableFormClick($event)"
                                 @render="tableFormRender($event, item, index)"
@@ -106,6 +106,7 @@ import { useAppStore } from '~src/store'
 import landApi from '~api/agree/land.js'
 import TableFormItem from './form-item.vue'
 import NoDataSvg from '~src/assets/view/no-data.svg'
+import { getStoreValue, setStoreValue } from '~uti/storage'
 import {
     arrIndex, deepClone, getArrValue,
     getObjVal, getObjValue, isNullES, setPosRange,
@@ -226,6 +227,7 @@ const closeIconArr = [
 watch(() => [
     props.datas,
 ], ([datas]) => {
+    console.log(datas, 'datas')
     setFormDataNum(datas)
 }, { deep: true })
 
@@ -285,7 +287,9 @@ const changeFormDatas = (pKeyId, type) => {
 const ActiveKey = ref('')
 const CollapseChange = (name) => {
     ActiveKey.value = name
+    setStoreValue('activeKey', ActiveKey.value)
     let index = getCollapseItemIndex(name)
+  
     if (index > -1) {
         getOffsetTop(name)
         const item = listDatas.value[index]
@@ -303,7 +307,9 @@ const CollapseChange = (name) => {
         formparentId.value = ''
     }
 }
-
+const setCollapseKey = (key) => {
+    CollapseChange(key)
+}
 //初始设置
 const setFormDataNum = (datas) => {
     itemRefs.value = []
@@ -367,6 +373,7 @@ const setChangeFormDatas = async (pkeyId, type) => {
 const DragModalTableForm = ref([])
 const DragModalHeight = ref(600)
 const windowClick = async (item, indexs) => {
+
     const list = deepClone(DragModalTableForm.value)
     let index = arrIndex(list, 'pkeyId', item.id)
     if (!item.isWindow) {
@@ -388,7 +395,7 @@ const windowClick = async (item, indexs) => {
             list.push(newTableForm)
         }
         DragModalTableForm.value = list
-        ActiveKey.value = ''
+    
     } else {
         await setChangeFormDatas(item?.id, 'collapse')
         //处理表单的ref
@@ -419,6 +426,7 @@ const setInitDragModalTableForm = (item, index) => {
         index: index,
         item: item,
         id:item.id,
+        tableId:item.tableId,
     }
 }
 
@@ -518,6 +526,7 @@ const dragNodeMoreMenuTap = ({ key }, items) => {
 
 const copyClickLoading = ref(false)
 const copyClick = async (items) => {
+    items.isTableRender = true
     const { id, isTableRender, isTableForm } = items
     if (id) {
         if (isStatus.value !== 3) {
@@ -529,7 +538,7 @@ const copyClick = async (items) => {
                 copyClickLoading.value = true
                 const isSave = await saveExcelBussData(items, null, false)
                 if (isSave) {
-                    await copeBussTab(id)
+                    await copeBussTab(id, isSave)
                 } else {
                     copyClickLoading.value = false
                     window?.$message?.warning('复制本表操作失败')
@@ -546,7 +555,7 @@ const copyClick = async (items) => {
  }
 
 //复制表的请求
-const copeBussTab = async (pkeyId) => {
+const copeBussTab = async (pkeyId, aid) => {
     copyClickLoading.value = true
     const { error, code } = await landApi.copeTab({
         id: pkeyId,
@@ -554,7 +563,7 @@ const copeBussTab = async (pkeyId) => {
     copyClickLoading.value = false
     if (!error && code === 200) {
         window?.$message?.success('操作成功')
-        renewData()
+        renewData(aid)
     }
 }
 
@@ -580,14 +589,18 @@ const fileListData = ref([])
 
 //单个保存
 const tableFormSaveLoading = ref(false)
-const tableFormSaveClick = async (item, dragItem = null) => {
+const tableFormSaveClick = async (item, dragItem = null, index) => {
+  
     if (isStatus.value !== 3) {
+        setStoreValue('activeKey', ActiveKey.value)
         tableFormSaveLoading.value = true
         const isSave = await saveExcelBussData(item, dragItem)
         if (isSave) {
-            await getBussPdfInfo(item, dragItem)
+           
             tableFormSaveLoading.value = false
-            renewData()
+            agreementId.value = agreementId
+            renewData(isSave)
+            // await getBussPdfInfo(item, dragItem)
         } else {
             tableFormSaveLoading.value = false
         }
@@ -603,13 +616,14 @@ const saveExcelBussData = async ({ id }, dragItem = null, showTip = true) => {
     const isRegExp = await refs?.isFormRegExp()
     if (isRegExp) {
         const formData = refs?.getFormData()
-        const { error, code } = await landApi.saveBussData(formData)
+        const { error, code, data } = await landApi.saveBussData(formData)
+     
         setDragModalLoading(dragItem)
         if (!error && code === 200) {
             if (showTip) {
                 window?.$message?.success('保存成功')
             }
-            return true
+            return data
         } else {
             return false
         }
@@ -622,6 +636,7 @@ const saveExcelBussData = async ({ id }, dragItem = null, showTip = true) => {
 //预览PDF
 const getBussPdfInfo = async ({ id }, dragItem = null, showTip = true) => {
     setDragModalLoading(dragItem, '获取pdf中...', true)
+    console.log(id, 'id')
     const { error, code, data } = await landApi.getSingleBussPdfInfo({
         id: id,
     }, false)
@@ -641,9 +656,13 @@ const getBussPdfInfo = async ({ id }, dragItem = null, showTip = true) => {
 
 
 //通知数据更新
-const renewData = () => {
-    emit('renew')
+const renewData = (id) => {
+
+    const activeKey = getStoreValue('activeKey')
+    console.log(activeKey, 'activeKey111111')
+    emit('renew', id, activeKey)
     ActiveKey.value = ''
+  
 }
 
 //设置表单的加载状态
@@ -661,7 +680,10 @@ const setDragModalLoading = (dragItem, text = '保存中...', show = false) => {
 const getFormRef = async (pkeyId) => {
     const itemRef = itemRefs.value
     const index = arrIndex(itemRef, 'pKeyId', pkeyId)
-    return itemRef[index].ref
+    if (index !== -1) {
+        return itemRef[index].ref
+    }
+   
 }
 
 //删除打开的窗口
@@ -677,8 +699,10 @@ const delWindowRefs = (pkeyId) => {
 
 //计算展开高度和滚动位置
 const getOffsetTop = (key = '') => {
+    console.log(key, 'key')
     if (key) {
         const dom = document.getElementById(key)
+        console.log(dom, 'dom')
         if (!draw_type.value) {
             if (dom?.offsetTop >= 583 && key) {
                 emit('offsetTop', dom?.offsetTop - 583)
@@ -686,7 +710,7 @@ const getOffsetTop = (key = '') => {
                 emit('offsetTop', dom?.offsetTop)
             }
         } else {
-            if (dom.offsetTop >= 424 && key) {
+            if (dom?.offsetTop >= 424 && key) {
                 emit('offsetTop', dom?.offsetTop - 424)
             } else {
                 emit('offsetTop', dom?.offsetTop)
@@ -853,6 +877,7 @@ defineExpose({
     getFormRegExpJson,
     getActiveKey,
     setActiveKey,
+    setCollapseKey,
 })
 </script>
 

+ 45 - 15
src/views/agree/tomb/form.vue

@@ -13,7 +13,7 @@
                 :area-id="areaId"
                 :agreement-id="agreementId"
                 :draw-type="isDrawType"
-                @renew="updateGetTablesData(agreementId)"
+                @renew="updateGetTablesData"
             />
             <HcStatus v-else text="暂无表单" />
         </el-scrollbar>
@@ -39,19 +39,20 @@
                 <span>取消并返回</span>
             </el-button>
         </template>
-        <HcDialog is-to-body :show="addModal" title="上传附件协议" @close="testModalClose">
-            <HcUpload :datas="uploadData" :file-list="fileListData" :is-canupload="false" action="/api/blade-manager/exceltab/add-bussfile-node" accept="application/pdf" accept-tip="允许格式:pdf" @change="uploadChange" />
+        <HcDialog is-to-body :show="addModal" title="上传附件协议" :footer="false" @close="testModalClose">
+            <HcUpload :datas="uploadData" :file-list="fileListData" :is-canupload="false" action="/api/blade-land/agreementFile/add-buss-file" accept="application/pdf" accept-tip="允许格式:pdf" @change="uploadChange" />
         </HcDialog>
     </HcCard>
 </template>
 
 <script setup>
-import { onActivated, ref } from 'vue'
+import { nextTick, onActivated, ref } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import CollapseForm from './collapse-form/index.vue'
 import landApi from '~api/agree/land.js'
 import { useAppStore } from '~src/store'
-import { getArrValue, getObjVal } from 'js-fast-way'
+import { getArrValue, isNullES } from 'js-fast-way'
+import { getStoreValue } from '~uti/storage'
 import HcUpload from './components/HcUpload.vue'
 
 const useAppState = useAppStore()
@@ -63,7 +64,6 @@ const useRoutes = useRoute()
 const dataType = ref(useRoutes?.query?.type ?? 'view')
 const agreementId = ref(useRoutes?.query?.id ?? '')
 const areaId = ref(useRoutes?.query?.areaId ?? '')
-const isDrawType = ref(true)
 
 //缓存页面被激活时
 onActivated(() => {
@@ -81,7 +81,6 @@ onActivated(() => {
 
 const listItemScrollRef = ref(null)
 
-//返回
 //返回
 const goBackClick = async () => {
     const { error, code, data } = await landApi.unSave({
@@ -110,14 +109,17 @@ const searchNodeAllTable = async () => {
     //处理数据
 
     if (!error && code === 200) {
-        agreementId.value = data
-        updateGetTablesData(data)
+        // agreementId.value = data
+        // updateGetTablesData(data)
+        ListItemDatas.value = getArrValue(data)
     } else {
-        agreementId.value = ''
+        // agreementId.value = ''
+        ListItemDatas.value = []
     }
 }
 //编辑获取表单列表
-const updateGetTablesData = async (id) => {
+const updateGetTablesData = async (id, key) => {
+    agreementId.value = id
     ListItemDatas.value = []
     ListItemLoading.value = true
     const { error, code, data } = await landApi.updateGetTables({
@@ -131,11 +133,19 @@ const updateGetTablesData = async (id) => {
     } else {
         ListItemDatas.value = []
     }
+    //保存后自动展开到当前表单
+    if (!isNullES(key)) {
+        await nextTick(() => {
+            ListItemRef.value?.setCollapseKey(key)
+        })
+    }
 }
 
 //保存
 const ListItemRef = ref(null)
 const tableFormSaveLoading = ref(false)
+//是否是抽屉
+const isDrawType = ref(true)
 const tableFormSaveClick = async () => {
     //获取数据
     let FormData = []
@@ -149,12 +159,15 @@ const tableFormSaveClick = async () => {
         const { error, code, data } = await landApi.saveBussData({
             dataInfo: { orderList: FormData },
         })
+        agreementId.value = data
         tableFormSaveLoading.value = false
         if (!error && code === 200) {
             window?.$message?.success('保存成功')
             dataType.value = 2
-             await bussPdfsClick()
-             updateGetTablesData(agreementId.value)
+            //  await bussPdfsClick()
+            const activeKey = getStoreValue('activeKey')
+            await updateGetTablesData(agreementId.value, activeKey)
+            
         }
     } else {
         console.log('预览')
@@ -183,15 +196,32 @@ const testModalClose = ()=>{
 }
 const addFile = ()=>{
     addModal.value = true
+    getBussFileList(agreementId.value)
+         //上传的配置
+         uploadData.value = {
+                agreementId:agreementId.value,
+                projectId: projectId.value,
+            }
 }
 const uploadData = ref({})
 const fileListData = ref([])
 //上传文件
 const uploadChange = async ({ type }) => {
     if (type === 'success') {
-        // getBussFileList(primaryKeyId.value)
+        getBussFileList(agreementId.value)
     } else if (type === 'del') {
-        // getBussFileList(primaryKeyId.value)
+        getBussFileList(agreementId.value)
+    }
+}
+//获取文件列表
+const getBussFileList = async (pkeyId) => {
+    const { error, code, data } = await landApi.getBussFileList({
+        agreementId: pkeyId,
+    })
+    if (!error && code === 200) {
+        fileListData.value = getArrValue(data)
+    } else {
+        fileListData.value = []
     }
 }
 </script>