Jelajahi Sumber

征拆接口修改

duy 1 tahun lalu
induk
melakukan
2f9c187d9d

+ 10 - 3
src/api/modules/agree/land.js

@@ -1,9 +1,16 @@
 import { httpApi } from '../../request/httpApi'
 export default {
-        //获取补偿协议表单
-        async getPage(form, msg = true) {
+        //获取补偿协议表单(新增
+        async addGetTables(form, msg = true) {
             return httpApi({
-                url: '/api/blade-land/compensationInfo/getTables',
+                url: '/api/blade-land/compensationInfo/addGetTables',
+                method: 'get',
+                params: form,
+            }, msg)
+        },
+        async updateGetTables(form, msg = true) {
+            return httpApi({
+                url: '/api/blade-land/compensationInfo/updateGetTables',
                 method: 'get',
                 params: form,
             }, msg)

+ 79 - 54
src/views/agree/land/collapse-form/form-item.vue

@@ -1,72 +1,84 @@
 <template>
-    <HcTableForm ref="tableFormRef"
-                 :cols="colsKeys"
-                 :form="tableFormInfo"
-                 :height="heights"
-                 :html="excelHtml"
-                 :loading="loading"
-                 :pid="activeKey"
-                 :pkey="keyId"
-                 :scroll="scroll"
-                 :width="widths"
-                 @excelBodyTap="excelTableFormClick"
-                 @render="tableFormRender"
-                 @rightTap="tableFormRightTap"
+    <HcTableForm
+        ref="tableFormRef"
+        :cols="colsKeys"
+        :form="tableFormInfo"
+        :height="heights"
+        :html="excelHtml"
+        :loading="loading"
+        :pid="activeKey"
+        :pkey="keyId"
+        :scroll="scroll"
+        :width="widths"
+        @excelBodyTap="excelTableFormClick"
+        @render="tableFormRender"
+        @rightTap="tableFormRightTap"
     />
 </template>
 
 <script setup>
-import {ref, watch, onMounted} from "vue"
-import {useAppStore} from "~src/store";
-import wbsApi from "~api/data-fill/wbs";
-import {deepClone, getArrValue, getObjVal, isString} from "js-fast-way"
+import { onMounted, ref, watch } from 'vue'
+import { useAppStore } from '~src/store'
+import landApi from '~api/agree/land.js'
+import { deepClone, getArrValue, getObjVal, isString } from 'js-fast-way'
 
 //初始
 const props = defineProps({
-    tid: { // 树节点
+    areaId: { // 树节点
         type: [String, Number],
-        default: ''
+        default: '',
     },
     kid: { // pkeyId
         type: [String, Number],
-        default: ''
+        default: '',
     },
-    classify: { // 类型
+    classify: { // 类型1新增,2是编辑
         type: [String, Number],
-        default: ''
+        default: '',
     },
     scroll: {
         type: Boolean,
-        default: true
+        default: true,
     },
     height: {
         type: String,
-        default: '100%'
+        default: '100%',
     },
     width: {
         type: String,
-        default: 'auto'
+        default: 'auto',
     },
     datas: {
         type: Object,
-        default: () => ({})
+        default: () => ({}),
     },
     nodeName: { // 表单名称
         type: String,
-        default: ''
+        default: '',
     },
     pid: { // 折叠ID
         type: String,
-        default: ''
+        default: '',
     },
+    nodeType:{
+        type:[String, Number],
+        default: '', //表单节点类型
+    },
+    tableId:{
+        type: [String, Number],
+        default: '', //表单initTableId
+    },
+   
 })
 
+//事件
+const emit = defineEmits(['rightTap', 'render', 'excelBodyTap'])
 //初始变量
 const useAppState = useAppStore()
 const projectId = ref(useAppState.getProjectId)
 const contractId = ref(useAppState.getContractId)
 const keyId = ref(props.kid ? props.kid + '' : '')
-const treeId = ref(props.tid)
+const areaId = ref(props.areaId)
 const classify = ref(props.classify)
 const loading = ref(false)
 const changeData = ref(props.datas)
@@ -77,39 +89,45 @@ const widths = ref(props.width)
 const activeKey = ref(props.pid)
 
 const tableFormRef = ref(null)
+const nodeType = ref(props.nodeType)
+const tableId = ref(props.tableId)
 
 //监听
 watch(() => [
     useAppState.getProjectId,
     useAppState.getContractId,
-    props.tid,
+    props.areaId,
     props.kid,
     props.classify,
     props.nodeName,
     props.height,
     props.width,
     props.pid,
+    props.nodeType,
+    props.tableId,
 ], (
-    [project_id, contract_id, tree_id, key_id, cid, nodeName, height, width, pid]
+    [project_id, contract_id, area_id, key_id, cid, nodeName, height, width, pid, node_type, table_id],
 ) => {
     projectId.value = project_id
     contractId.value = contract_id
-    treeId.value = tree_id
+    areaId.value = area_id
     keyId.value = key_id ? key_id + '' : ''
     classify.value = cid
     nodeNames.value = nodeName
     heights.value = height
     widths.value = width
     activeKey.value = pid
+    nodeType.value = node_type
+    tableId.value = table_id
 })
 
 //深度监听变动的对象数据
 watch(() => [
-    props.datas
+    props.datas,
 ], ([data]) => {
     changeData.value = data
     setFormChangeData(data)
-}, {deep: true})
+}, { deep: true })
 
 
 //渲染完成
@@ -124,9 +142,6 @@ onMounted(async () => {
     loading.value = false
 })
 
-//事件
-const emit = defineEmits(['rightTap', 'render', 'excelBodyTap'])
-
 //表单被点击
 const excelTableFormClick = (item) => {
     emit('excelBodyTap', item)
@@ -135,12 +150,20 @@ const excelTableFormClick = (item) => {
 //获取表单初始数据
 const getFormDataInit = () => {
     return {
-        projectId: projectId.value,
-        contractId: contractId.value,
-        classify: classify.value,
+        // projectId: projectId.value,
+        // contractId: contractId.value,
+        // classify: classify.value,
+        // pkeyId: keyId.value,
+        // nodeId: treeId.value,
+        // isRenderForm: false,
         pkeyId: keyId.value,
-        nodeId: treeId.value,
+        agreementId:'', //	协议的id,新增协议为null
+        areaId:areaId.value, //当前树节点id
+        linkId:'', //当前表单的id,
+        projectId: projectId.value,
+        tableId:tableId.value, //表单的tableId
         isRenderForm: false,
+        nodeType:nodeType.value,
     }
 }
 
@@ -148,20 +171,20 @@ const getFormDataInit = () => {
 const tableFormInfo = ref({})
 const getTableFormInfo = async (pkeyId) => {
     if (pkeyId) {
-        const {error, code, data} = await wbsApi.getBussDataInfo({
-            pkeyId: pkeyId
+        const { error, code, data } = await landApi.getBussInfo({
+            linkId: pkeyId,
         }, false)
         const resData = getObjVal(data)
         if (!error && code === 200 && resData) {
             tableFormInfo.value = {
                 ...resData,
                 ...getFormDataInit(),
-                ...changeData.value
+                ...changeData.value,
             }
         } else {
             tableFormInfo.value = {
                 ...getFormDataInit(),
-                ...changeData.value
+                ...changeData.value,
             }
         }
     } else {
@@ -174,19 +197,20 @@ const getTableFormInfo = async (pkeyId) => {
 const colsKeys = ref([])
 const getHtmlBussColsApi = async (pkeyId) => {
     if (pkeyId) {
-        const {error, code, data} = await wbsApi.getHtmlBussCols({
-            pkeyId: pkeyId
+        const { error, code, data } = await landApi.getBussCols({
+            pkeyId: pkeyId,
+            type:classify.value,
         }, false)
         if (!error && code === 200) {
-            let keys = getArrValue(data);
+            let keys = getArrValue(data)
             for (let i = 0; i < keys.length; i++) {
                 if (keys[i].length <= 0) {
                     keys.splice(i, 1)
                 }
             }
-            colsKeys.value = keys;
+            colsKeys.value = keys
         } else {
-            colsKeys.value = [];
+            colsKeys.value = []
         }
     } else {
         colsKeys.value = []
@@ -197,8 +221,9 @@ const getHtmlBussColsApi = async (pkeyId) => {
 const excelHtml = ref('')
 const getExcelHtml = async (pkeyId) => {
     if (pkeyId) {
-        const {error, code, data} = await wbsApi.getExcelHtml({
-            pkeyId: pkeyId
+        const { error, code, data } = await landApi.getExcelHtml({
+            pkeyId: pkeyId,
+            type:classify.value,
         }, false)
         const resData = isString(data) ? data || '' : ''
         if (!error && code === 200 && resData) {
@@ -229,7 +254,7 @@ const tableFormRightTap = (item) => {
 //设置数据
 const setFormChangeData = (data) => {
     const form = deepClone(tableFormInfo.value)
-    tableFormInfo.value = {...form, ...data}
+    tableFormInfo.value = { ...form, ...data }
     //console.log('设置数据', {...form, ...data})
 }
 
@@ -280,6 +305,6 @@ defineExpose({
     getNodeName,
     setIsCtrlKey,
     setCopyKeyList,
-    setPasteKeyList
+    setPasteKeyList,
 })
 </script>

+ 162 - 145
src/views/agree/land/collapse-form/index.vue

@@ -1,28 +1,36 @@
 <template>
     <div class="data-fill-list-box">
         <el-collapse v-model="ActiveKey" accordion @change="CollapseChange">
-            <template v-for="(item,index) in listDatas" :key="item?.pkeyId">
-                <el-collapse-item :id="`item-${index}-${item?.pkeyId}`" :name="`item-${index}-${item?.pkeyId}`">
+            <template v-for="(item, index) in listDatas" :key="item?.pKeyId">
+                <el-collapse-item :id="`item-${index}-${item?.pKeyId}`" :name="`item-${index}-${item?.pKeyId}`">
                     <template #title>
                         <div class="hc-collapse-item-header">
-                            <div class="text-lg truncate item-title"> {{ item.nodeName }}</div>
+                            <div class="text-lg truncate item-title">
+                                {{ item.nodeName }}
+                            </div>
                             <div class="hc-extra-text-box">
-                                <el-button :loading="copyClickLoading" plain type="primary" @click.stop="copyClick(item,index)">复制本表</el-button>
+                                <el-button :loading="copyClickLoading" plain type="primary" @click.stop="copyClick(item, index)">
+                                    复制本表
+                                </el-button>
                             </div>
                         </div>
                     </template>
                     <div class="data-fill-list-item-content">
-                        <TableFormItem v-if="item.isTableRender"
-                                       :ref="(el) => setItemRefs(el, item)"
-                                       :classify="classifys"
-                                       :datas="changeFormDatas(item?.pkeyId, 'collapse')"
-                                       :kid="item?.pkeyId"
-                                       :nodeName="item.nodeName"
-                                       :pid="`table-form-${item?.pkeyId}`"
-                                       :tid="treeId"
-                                       @excelBodyTap="excelTableFormClick($event)"
-                                       @render="tableFormRender($event, item, index)"
-                                       @rightTap="tableFormRightTap($event, index)"
+                        <TableFormItem
+                            v-if="item.isTableRender"
+                            :ref="(el) => setItemRefs(el, item)"
+                            :classify="classifys"
+                            :datas="changeFormDatas(item?.pKeyId, 'collapse')"
+                            :kid="item?.pKeyId"
+                            :node-name="item.nodeName"
+                            :node-type="item.nodeType"
+                            :pid="`table-form-${item?.pKeyId}`"
+                            :area-id="areaId"
+                            :table-id="item.initTableId"
+                            style="width: 100%;"
+                            @excelBodyTap="excelTableFormClick($event)"
+                            @render="tableFormRender($event, item, index)"
+                            @rightTap="tableFormRightTap($event, index)"
                         />
                     </div>
                 </el-collapse-item>
@@ -32,70 +40,78 @@
 </template>
 
 <script setup>
-import {ref, watch, nextTick, onActivated, onDeactivated, onMounted, onUnmounted} from "vue";
-import HTableForm from "~src/plugins/HTableForm"
-import {useAppStore} from "~src/store";
-import wbsApi from "~api/data-fill/wbs"
-import TableFormItem from "./form-item.vue"
+import { nextTick, onActivated, onDeactivated, onMounted, onUnmounted, ref, watch } from 'vue'
+import HTableForm from '~src/plugins/HTableForm'
+import { useAppStore } from '~src/store'
+import landApi from '~api/agree/land.js'
+import TableFormItem from './form-item.vue'
 import {
-    getArrValue, getObjValue, getObjVal,
-    isNullES, deepClone, arrIndex, setPosRange
-} from "js-fast-way"
-
-//初始变量
-const useAppState = useAppStore()
+    arrIndex, deepClone, getArrValue,
+    getObjVal, getObjValue, isNullES, setPosRange,
+} from 'js-fast-way'
 
 //参数
 const props = defineProps({
     datas: {
         type: Array,
-        default: () => ([])
+        default: () => ([]),
     },
     classify: {
         type: [String, Number],
-        default: ''
+        default: '',
     },
     status: {
         type: [String, Number],
-        default: ''
+        default: '',
     },
     primaryKeyId: {
         type: [String, Number],
-        default: ''
+        default: '',
     },
     contractId: {
         type: [String, Number],
-        default: ''
+        default: '',
     },
     drawType: {
         type: Boolean,
-        default: false
+        default: false,
     },
     wbsTempId: {
         type: [String, Number],
-        default: ''
+        default: '',
     },
     tenantId: {
         type: [String, Number],
-        default: ''
+        default: '',
     },
     wbsType: {
         type: [String, Number],
-        default: ''
+        default: '',
     },
+    areaId:{
+        type: String,
+        default: '',
+    }, //当前树节点
 })
 
+//事件
+const emit = defineEmits(['renew', 'offsetTop'])
+
+//初始变量
+const useAppState = useAppStore()
+
 //全局变量
-const projectId = ref(useAppState.projectId);
+const projectId = ref(useAppState.projectId)
 const contract_id = ref(props.contractId)
 const treeId = ref(props.primaryKeyId)
 const classifys = ref(props.classify)
-const wbsTemp_id = ref(props.wbsTempId);
-const tenant_id = ref(props.tenantId);
-const wbs_type = ref(props.wbsType);
+const wbsTemp_id = ref(props.wbsTempId)
+const tenant_id = ref(props.tenantId)
+const wbs_type = ref(props.wbsType)
 const isStatus = ref(parseInt(props.status))
 const listDatas = ref([])
 const draw_type = ref(props.drawType)
+const areaId = ref(props.areaId)
 
 
 //表单变量
@@ -105,24 +121,24 @@ const formparentId = ref('')
 
 //处理ref
 const itemRefs = ref([])
-const setItemRefs = (el, {pkeyId}) => {
+const setItemRefs = (el, { pKeyId }) => {
     if (el) {
-        let index = arrIndex(itemRefs.value, 'pkeyId', pkeyId)
+        let index = arrIndex(itemRefs.value, 'pKeyId', pKeyId)
         if (index !== -1) {
             itemRefs.value[index].ref = el
         } else {
             itemRefs.value.push({
-                pkeyId: pkeyId,
-                ref: el
-            });
+                pKeyId: pKeyId,
+                ref: el,
+            })
         }
     }
 }
 
 //处理表单的ref
-const setSpliceItemRefs = async ({pkeyId}) => {
+const setSpliceItemRefs = async ({ pKeyId }) => {
     const refs = itemRefs.value
-    let index = arrIndex(refs, 'pkeyId', pkeyId)
+    let index = arrIndex(refs, 'pKeyId', pKeyId)
     if (index !== -1) {
         refs.splice(index, 1)
         itemRefs.value = refs
@@ -130,25 +146,22 @@ const setSpliceItemRefs = async ({pkeyId}) => {
 }
 
 const closeIconArr = [
-    {key: 'reduction', icon: 'picture-in-picture-2', name: '还原到面板内,并自动展开面板'}
+    { key: 'reduction', icon: 'picture-in-picture-2', name: '还原到面板内,并自动展开面板' },
 ]
 
-//事件
-const emit = defineEmits(['renew', 'offsetTop'])
-
 //组件参数变量
-const apis = ref({
-    dataInfo: wbsApi.getBussDataInfo,
-    bussCols: wbsApi.getHtmlBussCols,
-    excelHtml: wbsApi.getExcelHtml
-})
+// const apis = ref({
+//     dataInfo: wbsApi.getBussDataInfo,
+//     bussCols: wbsApi.getHtmlBussCols,
+//     excelHtml: wbsApi.getExcelHtml,
+// })
 
 //深度监听数据
 watch(() => [
     props.datas,
 ], ([datas]) => {
     setFormDataNum(datas)
-}, {deep: true})
+}, { deep: true })
 
 //监听变量值
 watch(() => [
@@ -160,7 +173,8 @@ watch(() => [
     props.status,
     props.classify,
     props.primaryKeyId,
-], ([pid, cid, temp_id, tid, type, status, class_id, tree_id]) => {
+    props.areaId,
+], ([pid, cid, temp_id, tid, type, status, class_id, tree_id, area_id]) => {
     projectId.value = pid
     contract_id.value = cid
     wbsTemp_id.value = temp_id
@@ -169,25 +183,26 @@ watch(() => [
     isStatus.value = parseInt(status)
     classifys.value = class_id
     treeId.value = tree_id
+    areaId.value = area_id
 })
 
 //渲染完成
 onMounted(() => {
     setFormDataNum(props.datas)
     setTableFormMenu(useAppState.projectInfo)
-    const {offsetHeight} = document.body
+    const { offsetHeight } = document.body
     DragModalHeight.value = offsetHeight - 200
     setMountOnEventKey()
 })
 
 //处理变动的数据
 const changeFormData = ref({
-    'window': [],
-    'collapse': [],
+    window: [],
+    collapse: [],
 })
-const changeFormDatas = (pkeyId, type) => {
+const changeFormDatas = (pKeyId, type) => {
     const changeData = changeFormData.value[type]
-    const index = arrIndex(changeData, 'pkeyId', pkeyId)
+    const index = arrIndex(changeData, 'pKeyId', pKeyId)
     if (index !== -1) {
         return changeData[index]
     } else {
@@ -196,11 +211,11 @@ const changeFormDatas = (pkeyId, type) => {
 }
 
 //设置变动的数据
-const setChangeFormDatas = async (pkeyId, type) => {
-    const refs = await getFormRef(pkeyId)
+const setChangeFormDatas = async (pKeyId, type) => {
+    const refs = await getFormRef(pKeyId)
     const formData = refs?.getFormData()
     const changeData = changeFormData.value[type]
-    const index = arrIndex(changeData, 'pkeyId', pkeyId)
+    const index = arrIndex(changeData, 'pKeyId', pKeyId)
     if (index !== -1) {
         changeData[index] = formData
     } else {
@@ -210,15 +225,17 @@ const setChangeFormDatas = async (pkeyId, type) => {
 }
 
 //展开事件
+
 const ActiveKey = ref('')
 const CollapseChange = (name) => {
     ActiveKey.value = name
     let index = getCollapseItemIndex(name)
     if (index > -1) {
-        getOffsetTop(name);
+        getOffsetTop(name)
         const item = listDatas.value[index]
-        formKeyIds.value = setToString(item.pkeyId)
+        formKeyIds.value = setToString(item.pKeyId)
         formparentId.value = setToString(item.parentId)
+    
         nextTick(() => {
             if (!item.isTableRender) {
                 item.isTableRender = true
@@ -235,9 +252,9 @@ const CollapseChange = (name) => {
 const setFormDataNum = (datas) => {
     itemRefs.value = []
     ActiveKey.value = ''
-    let newArr = [];
+    let newArr = []
     for (let i = 0; i < datas.length; i++) {
-        newArr.push({isCollapseLoad: false})
+        newArr.push({ isCollapseLoad: false })
     }
     formDataList.value = newArr
     listDatas.value = deepClone(datas)
@@ -262,24 +279,24 @@ const setTableFormMenu = (info) => {
     let newArr = [], infos = getObjValue(info)
     const isOpen = infos['isOpenRandomNumber'] ?? 0
     if (isOpen === 1 && isStatus.value !== 3) {
-        newArr.push({label: '插入设计值/频率', key: "design"})
+        newArr.push({ label: '插入设计值/频率', key: 'design' })
     }
-    newArr.push({label: '插入特殊字符', key: "special"})
-    newArr.push({label: '关联试验数据', key: "test"})
-    newArr.push({label: '关联试验文件', key: "file"})
-    newArr.push({label: '公式参数', key: "formula"})
+    newArr.push({ label: '插入特殊字符', key: 'special' })
+    newArr.push({ label: '关联试验数据', key: 'test' })
+    newArr.push({ label: '关联试验文件', key: 'file' })
+    newArr.push({ label: '公式参数', key: 'formula' })
     tableFormMenu.value = newArr
 }
 
 //鼠标右键事件
-const tableFormRightTap = ({event, KeyName, startPos, endPos, pkeyId}, index) => {
+const tableFormRightTap = ({ event, KeyName, startPos, endPos, pkeyId }, index) => {
     //存储临时信息
-    tableFormItemNode.value = {KeyName, index, startPos, endPos, pkeyId}
+    tableFormItemNode.value = { KeyName, index, startPos, endPos, pkeyId }
     contextMenuRef.value?.showMenu(event, false) //展开菜单
 }
 
 //鼠标右键菜单被点击
-const handleMenuSelect = ({key}) => {
+const handleMenuSelect = ({ key }) => {
     if (key === 'design') {
         setInitDesignForm()
         designModalLoading.value = false
@@ -291,7 +308,7 @@ const handleMenuSelect = ({key}) => {
         testModal.value = true
     } else if (key === 'file') {
         fileModalLoading.value = false
-        fileModal.value = true;
+        fileModal.value = true
     } else if (key === 'formula') {
         formulaModalLoading.value = false
         formulaModal.value = true
@@ -308,18 +325,18 @@ const setInitDesignForm = () => {
     formDesignModel.value = {
         type: 1, design: '', size: '',
         dev: '', key: '', capacity: '',
-        pass: '', pkId: ''
+        pass: '', pkId: '',
     }
 }
 
 //设计值频率计算
 const designModalLoading = ref(false)
 const designModalSave = async () => {
-    const {pkeyId, KeyName} = tableFormItemNode.value
+    const { pkeyId, KeyName } = tableFormItemNode.value
     if (pkeyId) {
         designModalLoading.value = true
         //const {design, size} = formDesignModel.value
-        const {error, code, data} = await wbsApi.queryFormulaRange({
+        const { error, code, data } = await wbsApi.queryFormulaRange({
             ...formDesignModel.value,
             // dev: (!design && !size) ? '±5': '',
             key: KeyName,
@@ -373,11 +390,11 @@ const specialRef = ref(null)
 const specialNodeClick = async () => {
     specialModalLoading.value = true
     const itemNode = tableFormItemNode.value
-    const {KeyName, pkeyId} = itemNode
+    const { KeyName, pkeyId } = itemNode
     try {
         const refs = await getFormRef(pkeyId)
         const itemFormData = refs?.getFormData()
-        const {code, val, posVal} = await specialRef.value?.getSpecialNode(itemNode, itemFormData[KeyName])
+        const { code, val, posVal } = await specialRef.value?.getSpecialNode(itemNode, itemFormData[KeyName])
         if (code === 200 && val) {
             itemFormData[KeyName] = val
             refs?.setFormData(itemFormData)
@@ -407,7 +424,7 @@ const testModalLoading = ref(false)
 //关联试验数据被点击
 const itinsertTableId = ref('')
 const itinsertTreeId = ref('')
-const testTableRowName = ({row, treeId}) => {
+const testTableRowName = ({ row, treeId }) => {
     itinsertTableId.value = row.id
     itinsertTreeId.value = treeId
     insertDataLoading.value = false
@@ -421,19 +438,19 @@ const testModalClose = () => {
 }
 
 //选择要插入的实验数据
-const insertDataShow = ref(false);
-const insertDataLoading = ref(false);
+const insertDataShow = ref(false)
+const insertDataLoading = ref(false)
 
 //确定关联试验数据数据
 const insertDataRef = ref(null)
 const submitinsertData = async () => {
     insertDataLoading.value = true
     const itemNode = tableFormItemNode.value
-    const {KeyName, pkeyId} = itemNode
+    const { KeyName, pkeyId } = itemNode
     try {
         const refs = await getFormRef(pkeyId)
         const itemFormData = refs?.getFormData()
-        const {code, val, posVal} = await insertDataRef.value?.submitinsertData(itemNode, itemFormData[KeyName])
+        const { code, val, posVal } = await insertDataRef.value?.submitinsertData(itemNode, itemFormData[KeyName])
         if (code === 200 && val) {
             itemFormData[KeyName] = val
             refs?.setFormData(itemFormData)
@@ -505,7 +522,7 @@ const windowClick = async (item, indexs) => {
         const formSize = getTableFormSize(item?.pkeyId)
         const newTableForm = {
             ...setInitDragModalTableForm(item, indexs),
-            ...formSize
+            ...formSize,
         }
         await setChangeFormDatas(item?.pkeyId, 'window')
         item.isWindow = true
@@ -549,12 +566,12 @@ const setInitDragModalTableForm = (item, index) => {
         title: item.nodeName,
         isShow: true,
         index: index,
-        item: item
+        item: item,
     }
 }
 
 //关闭窗口
-const TableFormClose = async ({pkeyId, index}, indexs) => {
+const TableFormClose = async ({ pkeyId, index }, indexs) => {
     const list = deepClone(DragModalTableForm.value)
     //取表单的数据
     await setChangeFormDatas(pkeyId, 'collapse')
@@ -565,21 +582,21 @@ const TableFormClose = async ({pkeyId, index}, indexs) => {
 }
 
 const dragNodeMoreMenu = [
-    {key: 'save', icon: 'save-2', name: '保存'},
-    {key: 'preview', icon: 'eye', name: '预览'},
+    { key: 'save', icon: 'save-2', name: '保存' },
+    { key: 'preview', icon: 'eye', name: '预览' },
 ]
 
 //还原窗口
 const closeIconTap = async (event, item, indexs) => {
-    const {index, pkeyId} = item
+    const { index, pkeyId } = item
     let KeyId = `item-${index}-${pkeyId}`
     await TableFormClose(item, indexs)
     ActiveKey.value = KeyId
 }
 
 //菜单被点击
-const dragNodeMoreMenuTap = ({key}, items) => {
-    const {item} = items
+const dragNodeMoreMenuTap = ({ key }, items) => {
+    const { item } = items
     if (key === 'save') {
         if (item?.isTableForm) {
             tableFormSaveClick(item, items)
@@ -597,11 +614,11 @@ const dragNodeMoreMenuTap = ({key}, items) => {
 
 //删除本表
 const tableFormDelLoading = ref(false)
-const delClick = async ({pkeyId}) => {
+const delClick = async ({ pkeyId }) => {
     if (pkeyId) {
         if (isStatus.value !== 3) {
             tableFormDelLoading.value = true
-            const {error, code} = await wbsApi.removeBussTabInfo({
+            const { error, code } = await wbsApi.removeBussTabInfo({
                 pkeyid: pkeyId,
                 classify: classifys.value,
             })
@@ -620,17 +637,17 @@ const delClick = async ({pkeyId}) => {
     }
 }
 //复制本表相关
-const showcopyModal=ref(false)
-const copyRefs=ref(null)
-const copyModalClose=()=>{
+const showcopyModal = ref(false)
+const copyRefs = ref(null)
+const copyModalClose = ()=>{
     // copyModal.value=false
 }
-const CopyModalType=ref('1')
+const CopyModalType = ref('1')
 
-const copySaveClick=async()=>{
+const copySaveClick = async ()=>{
     //本节点复制
-   if(CopyModalType.value==='2'){
-        const {pkeyId, isTableRender, isTableForm} =  copyItems.value
+   if (CopyModalType.value === '2') {
+        const { pkeyId, isTableRender, isTableForm } = copyItems.value
         if (pkeyId) {
             if (isStatus.value !== 3) {
                 if (!isTableRender) {
@@ -655,7 +672,7 @@ const copySaveClick=async()=>{
         } else {
             window?.$message?.warning('pkeyId为空')
     }
-   }else{
+   } else {
     window?.$message?.warning('暂无相关接口')
    }
 }
@@ -663,7 +680,7 @@ const copySaveClick=async()=>{
 const copyClickModalLoading = ref(false)
 const copyClickLoading = ref(false)
 const copyClick = async (items) => {
-    const {pkeyId, isTableRender, isTableForm} = items
+    const { pkeyId, isTableRender, isTableForm } = items
     if (pkeyId) {
         if (isStatus.value !== 3) {
             if (!isTableRender) {
@@ -689,7 +706,7 @@ const copyClick = async (items) => {
         window?.$message?.warning('pkeyId为空')
     }
  }
-const copyItems=ref([])
+const copyItems = ref([])
 //跨节点复制弹窗
 // const copyClick =  (items) => {
 //     showcopyModal.value=true
@@ -700,8 +717,8 @@ const copyItems=ref([])
 //复制表的请求
 const copeBussTab = async (pkeyId) => {
     copyClickLoading.value = true
-    const {error, code} = await wbsApi.copeBussTab({
-        pkeyId: pkeyId
+    const { error, code } = await wbsApi.copeBussTab({
+        pkeyId: pkeyId,
     })
     copyClickLoading.value = false
     if (!error && code === 200) {
@@ -712,14 +729,14 @@ const copeBussTab = async (pkeyId) => {
 
 //隐藏本表
 const tableFormHideLoading = ref(false)
-const hideClick = async ({pkeyId, isBussShow}) => {
+const hideClick = async ({ pkeyId, isBussShow }) => {
     if (pkeyId) {
         if (isStatus.value !== 3) {
             tableFormHideLoading.value = true
             const bussShow = isBussShow === 2 ? 1 : 2 //状态(1显示 2隐藏)
-            const {error, code} = await wbsApi.showBussTab({
+            const { error, code } = await wbsApi.showBussTab({
                 pkeyId: pkeyId,
-                status: bussShow
+                status: bussShow,
             })
             tableFormHideLoading.value = false
             if (!error && code === 200) {
@@ -748,11 +765,11 @@ const previewClick = async (item, dragItem = null) => {
 
 //上传变量
 const uploadModal = ref(false)
-const fileListData = ref([]);
+const fileListData = ref([])
 const uploadData = ref({})
 //上传附件
 const uploadClick = (items, index) => {
-    const {pkeyId, isTableForm, isTableRender} = items
+    const { pkeyId, isTableForm, isTableRender } = items
     const keyName = `item-${index}-${pkeyId}`
     if (pkeyId) {
         if (isStatus.value !== 3 && isTableForm) {
@@ -762,7 +779,7 @@ const uploadClick = (items, index) => {
                 contractId: contract_id.value,
                 classify: classifys.value,
                 pkeyId: pkeyId,
-                nodeId: treeId.value
+                nodeId: treeId.value,
             }
             //获取文件列表
             getBussFileList(pkeyId)
@@ -781,8 +798,8 @@ const uploadClick = (items, index) => {
 
 //获取文件列表
 const getBussFileList = async (pkeyId) => {
-    const {error, code, data} = await wbsApi.getBussFileList({
-        pkeyid: pkeyId
+    const { error, code, data } = await wbsApi.getBussFileList({
+        pkeyid: pkeyId,
     })
     if (!error && code === 200) {
         fileListData.value = getArrValue(data)
@@ -792,7 +809,7 @@ const getBussFileList = async (pkeyId) => {
 }
 
 //上传文件
-const uploadChange = async ({type}) => {
+const uploadChange = async ({ type }) => {
     if (type === 'success') {
         uploadModal.value = false
         renewData()
@@ -825,13 +842,13 @@ const tableFormSaveClick = async (item, dragItem = null) => {
 }
 
 //保存表单数据
-const saveExcelBussData = async ({pkeyId}, dragItem = null, showTip = true) => {
+const saveExcelBussData = async ({ pkeyId }, dragItem = null, showTip = true) => {
     setDragModalLoading(dragItem, '保存中...', true)
     const refs = await getFormRef(pkeyId)
     const isRegExp = await refs?.isFormRegExp()
     if (isRegExp) {
         const formData = refs?.getFormData()
-        const {error, code} = await wbsApi.saveExcelBussData(formData)
+        const { error, code } = await wbsApi.saveExcelBussData(formData)
         setDragModalLoading(dragItem)
         if (!error && code === 200) {
             if (showTip) {
@@ -848,10 +865,10 @@ const saveExcelBussData = async ({pkeyId}, dragItem = null, showTip = true) => {
 }
 
 //预览PDF
-const getBussPdfInfo = async ({pkeyId}, dragItem = null, showTip = true) => {
+const getBussPdfInfo = async ({ pkeyId }, dragItem = null, showTip = true) => {
     setDragModalLoading(dragItem, '获取pdf中...', true)
-    const {error, code, data} = await wbsApi.getBussPdfInfo({
-        pkeyId: pkeyId
+    const { error, code, data } = await wbsApi.getBussPdfInfo({
+        pkeyId: pkeyId,
     }, false)
     setDragModalLoading(dragItem)
     if (!error && code === 200) {
@@ -888,7 +905,7 @@ const setDragModalLoading = (dragItem, text = '保存中...', show = false) => {
 //获取表单的ref
 const getFormRef = async (pkeyId) => {
     const itemRef = itemRefs.value
-    const index = arrIndex(itemRef, 'pkeyId', pkeyId)
+    const index = arrIndex(itemRef, 'pKeyId', pkeyId)
     return itemRef[index].ref
 }
 
@@ -940,15 +957,15 @@ const getCollapseItemIndex = (name) => {
 const getTableFormSize = (pkeyId) => {
     let formId = `table-form-${pkeyId}`
     try {
-        const {clientWidth, clientHeight} = document.getElementById(formId).children[0]
+        const { clientWidth, clientHeight } = document.getElementById(formId).children[0]
         return {
             width: (clientWidth + 40) + 'px',
-            height: (clientHeight + 80) + 'px'
+            height: (clientHeight + 80) + 'px',
         }
     } catch {
         return {
             width: '100%',
-            height: '100%'
+            height: '100%',
         }
     }
 }
@@ -1014,29 +1031,29 @@ const setOnFuncFormRef = async () => {
     if (!isNullES(pkeyId)) {
         return await getFormRef(pkeyId)
     } else {
-        return;
+        return
     }
 }
 
 
 //获取已渲染的表单
 const getFilterFormData = async () => {
-    const formArr = formDataList.value;
+    const formArr = formDataList.value
     return formArr.filter((item) => {
-        return (item.pkeyId ?? '') !== '' && item.isCollapseLoad;
+        return (item.pkeyId ?? '') !== '' && item.isCollapseLoad
     })
 }
 
 //获取表单数据
 const getFormData = async () => {
-    const formArr = await getFilterFormData();
+    const formArr = await getFilterFormData()
     //获取表单数据
-    let newArr = [];
+    let newArr = []
     for (let i = 0; i < formArr.length; i++) {
         const pkeyId = formArr[i].pkeyId
         const refs = await getFormRef(pkeyId)
         const form = refs?.getFormData()
-        newArr.push({...form})
+        newArr.push({ ...form })
     }
     console.log('表单数据', newArr)
     return newArr
@@ -1044,21 +1061,21 @@ const getFormData = async () => {
 
 //获取表单效验数据
 const getFormRegExpJson = async () => {
-    const formArr = await getFilterFormData();
+    const formArr = await getFilterFormData()
     const list = listDatas.value
     //获取表单数据
-    let formRegExpJson = {};
+    let formRegExpJson = {}
     for (let i = 0; i < formArr.length; i++) {
-        const pkeyId = formArr[i].pkeyId
-        const refs = await getFormRef(pkeyId)
+        const pKeyId = formArr[i].pKeyId
+        const refs = await getFormRef(pKeyId)
         const regExp = refs?.getRegExpJson()
         const nodeName = refs?.getNodeName()
         if (getObjVal(regExp)) {
-            const index = arrIndex(list, 'pkeyId', pkeyId)
-            formRegExpJson[pkeyId] = {
+            const index = arrIndex(list, 'pKeyId', pKeyId)
+            formRegExpJson[pKeyId] = {
                 ...regExp,
-                itemId: `item-${index}-${pkeyId}`,
-                nodeName: nodeName
+                itemId: `item-${index}-${pKeyId}`,
+                nodeName: nodeName,
             }
         }
     }
@@ -1067,12 +1084,12 @@ const getFormRegExpJson = async () => {
 
 //获取当前展开项
 const getActiveKey = () => {
-    return ActiveKey.value;
+    return ActiveKey.value
 }
 
 //设置当前展开项
 const setActiveKey = (key) => {
-    return ActiveKey.value = key;
+    return ActiveKey.value = key
 }
 
 // 暴露出去
@@ -1080,7 +1097,7 @@ defineExpose({
     getFormData,
     getFormRegExpJson,
     getActiveKey,
-    setActiveKey
+    setActiveKey,
 })
 </script>
 

+ 113 - 23
src/views/agree/land/form.vue

@@ -1,35 +1,38 @@
 <template>
-    <HcCard actionUi="text-center">
+    <HcCard action-ui="text-center">
         <el-scrollbar ref="listItemScrollRef">
-            <CollapseForm ref="ListItemsRef"
-                          :classify="0"
-                          :contractId="0"
-                          :datas="[]"
-                          :primaryKeyId="0"
-                          :status="0"
-                          v-if="false"
+            <CollapseForm
+                v-if="ListItemDatas.length > 0"
+                ref="ListItemRef"
+                v-loading="ListItemLoading"
+                :classify="dataType"
+                :contract-id="0"
+                :datas="ListItemDatas"
+                :primary-key-id="0"
+                :status="0"
+                :area-id="areaId"
             />
-            <HcStatus text="暂无表单"/>
+            <HcStatus text="暂无表单" />
         </el-scrollbar>
         <template #action>
-            <!--el-button size="large" type="info" hc-btn @click="goBackClick">
+            <!-- el-button size="large" type="info" hc-btn @click="goBackClick">
                 <HcIcon name="arrow-go-back"/>
                 <span>取消并返回</span>
-            </el-button-->
-            <el-button size="large" type="primary" hc-btn>
-                <HcIcon name="check-double"/>
+            </el-button -->
+            <el-button size="large" type="primary" hc-btn :loading="tableFormSaveLoading" @click="tableFormSaveClick">
+                <HcIcon name="check-double" />
                 <span>提交保存</span>
             </el-button>
             <el-button size="large" type="primary" hc-btn>
-                <HcIcon name="draft"/>
+                <HcIcon name="draft" />
                 <span>一键生成协议</span>
             </el-button>
             <el-button size="large" type="warning" hc-btn>
-                <HcIcon name="eye"/>
+                <HcIcon name="eye" />
                 <span>预览</span>
             </el-button>
             <el-button size="large" type="success" hc-btn>
-                <HcIcon name="upload"/>
+                <HcIcon name="upload" />
                 <span>上传附件协议</span>
             </el-button>
         </template>
@@ -37,21 +40,35 @@
 </template>
 
 <script setup>
-import {onActivated, ref} from "vue";
-import {useRoute, useRouter} from 'vue-router'
-import CollapseForm from "./collapse-form/index.vue"
+import { 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'
 
+const useAppState = useAppStore()
+const projectId = ref(useAppState.getProjectId)
 const router = useRouter()
 const useRoutes = useRoute()
 
 //初始变量
-//const dataType = ref(useRoutes?.query?.type ?? 'view')
-//const dataId = ref(useRoutes?.query?.id ?? '')
+const dataType = ref(useRoutes?.query?.type ?? 'view')
+const dataId = ref(useRoutes?.query?.id ?? '')
+const areaId = ref(useRoutes?.query?.areaId ?? '')
 
 //缓存页面被激活时
 onActivated(() => {
-    //dataType.value = useRoutes?.query?.type ?? 'view'
-    //dataId.value = useRoutes?.query?.id ?? ''
+    dataType.value = useRoutes?.query?.type ?? 'view'
+    dataId.value = useRoutes?.query?.id ?? ''
+    areaId.value = useRoutes?.query?.areaId ?? ''
+    if (dataId.value.length > 0) {
+        updateGetTablesData()
+    } else {
+        searchNodeAllTable()
+    }
+    
+    
 })
 
 const listItemScrollRef = ref(null)
@@ -60,6 +77,79 @@ const listItemScrollRef = ref(null)
 const goBackClick = () => {
     router.back()
 }
+
+//获取数据列表
+const ListItemsRef = ref(null)
+const ListItemDatas = ref([])
+const ListItemLoading = ref(false)
+//新增获取表单列表
+const searchNodeAllTable = async () => {
+    ListItemDatas.value = []
+    ListItemLoading.value = true
+    const { error, code, data } = await landApi.addGetTables({
+        projectId: projectId.value,
+        type: 1,
+    
+    })
+    //处理数据
+    ListItemLoading.value = false
+    if (!error && code === 200) {
+        ListItemDatas.value = getArrValue(data)
+    } else {
+        ListItemDatas.value = []
+    }
+}
+//编辑获取表单列表
+const updateGetTablesData = async () => {
+    ListItemDatas.value = []
+    ListItemLoading.value = true
+    const { error, code, data } = await landApi.updateGetTables({
+        agreementId:dataId.value,
+    
+    })
+    //处理数据
+    ListItemLoading.value = false
+    if (!error && code === 200) {
+        ListItemDatas.value = getArrValue(data)
+    } else {
+        ListItemDatas.value = []
+    }
+}
+
+//保存
+const ListItemRef = ref(null)
+const tableFormSaveLoading = ref(false)
+const tableFormSaveClick = async () => {
+    //获取数据
+    let FormData = []
+        FormData = await ListItemRef.value?.getFormData()
+    //效验数据
+    console.log(ListItemRef.value, 'ListItemRef.value')
+
+    if (FormData.length > 0) {
+        console.log('保存')
+        tableFormSaveLoading.value = true
+        console.log('FormData', FormData)
+        FormData.forEach(ele => {
+            delete ele['pkeyId']
+        })
+        const { error, code, data } = await landApi.saveBussData({
+            dataInfo: { orderList: FormData },
+        })
+        tableFormSaveLoading.value = false
+        if (!error && code === 200) {
+            window?.$message?.success('保存成功')
+            dataId.value = data
+            dataType.value = 2
+             // await bussPdfsClick()
+            updateGetTablesData()
+            // goBackClick()
+        }
+    } else {
+        console.log('预览')
+        // await bussPdfsClick()
+    }
+}
 </script>
 
 <style lang="scss" scoped>

+ 11 - 2
src/views/agree/land/land.vue

@@ -62,10 +62,10 @@ import { getArrValue } from 'js-fast-way'
 const useAppState = useAppStore()
 const projectId = ref(useAppState.getProjectId)
 const router = useRouter()
-
+const areaId = ref('')
 //树节点被点击
 const treeNodeTap = ({ node, data }) => {
-
+    areaId.value = data.id
 }
 
 //搜索表单
@@ -129,6 +129,10 @@ const tableSelectionChange = (rows) => {
 const addRowClick = () => {
     router.push({
         name: 'lar-agree-land-form',
+        query:{
+            type:1,
+            areaId:areaId.value,
+        },
     })
 }
 
@@ -136,6 +140,11 @@ const addRowClick = () => {
 const editRowClick = (row) => {
     router.push({
         name: 'lar-agree-land-form',
+        query:{
+            type:2,
+            id:row.id,
+            areaId:areaId.value,
+        },
     })
 }
 </script>