ZaiZai 1 an în urmă
părinte
comite
3a2caa93f8

+ 1 - 1
public/version.json

@@ -1,3 +1,3 @@
 {
-  "value": "20231214111847"
+  "value": "20231215103347"
 }

+ 22 - 25
src/views/debit-pay/admin/components/middlepay/addModal.vue

@@ -1,7 +1,7 @@
 <template>
     <hc-new-dialog is-table widths="95%" :show="isShow" title="中间计量新增" @save="addModalSave" @close="addModalClose">
         <div class="relative h-full flex">
-            <div v-if="dataType === 'add'" :id="`hc_tree_card_${uuid}`" class="hc_tree_card_border relative">
+            <div v-if="!dataId" :id="`hc_tree_card_${uuid}`" class="hc_tree_card_border relative">
                 <hc-body scrollbar padding="0px">
                     <hc-lazy-tree :h-props="treeProps" tree-key="id" :auto-expand-keys="treeAutoExpandKeys" @load="treeLoadNode" @node-tap="treeNodeTap" />
                 </hc-body>
@@ -149,10 +149,6 @@ import unitApi from '~api/project/debit/contract/unit'
 import mainApi from '~api/debit-pay/admin/middlepay'
 
 const props = defineProps({
-    type: {
-        type: String,
-        default: 'add',
-    },
     projectId: {
         type: [String, Number],
         default: '',
@@ -179,7 +175,6 @@ const props = defineProps({
 const emit = defineEmits(['finish', 'close'])
 const uuid = getRandom(4)
 const dataId = ref(props.ids)
-const dataType = ref(props.type)
 const period = ref(props.allPeriods)
 const period_id = ref(props.periodId)
 const pid = ref(props.projectId)
@@ -193,20 +188,16 @@ const isShow = defineModel('modelValue', {
 
 //监听
 watch(() => [
-    props.type,
     props.projectId,
     props.contractId,
     props.allPeriods,
     props.periodId,
-], ([type, projectId, contractId, periods, periodId]) => {
-    dataType.value = type
+], ([projectId, contractId, periods, periodId]) => {
     period.value = periods
     pid.value = projectId
     cid.value = contractId
     period_id.value = periodId
-    if (type === 'add' ) {
-        setBasePeriodForm(periodId)
-    }
+    setBasePeriodForm(periodId)
 }, { deep: true })
 
 //监听
@@ -216,12 +207,15 @@ watch(() => props.ids, (id) => {
 
 //监听
 watch(isShow, (val) => {
-    baseForm.value = { fileList: [] }
-    if (val && dataType.value === 'add' ) {
-        setSplitRef()
-        setBasePeriodForm(period_id.value)
-    } else if (val && dataType.value === 'edit') {
-        getDataDetail()
+    if (val) {
+        if (dataId.value ) {
+            getDataDetail()
+        } else {
+            setBasePeriodForm(period_id.value)
+            setSplitRef()
+        }
+    } else {
+        baseForm.value = { fileList: [], pictureUrl: '' }
     }
 })
 
@@ -239,15 +233,17 @@ const setSplitRef = () => {
 
 //基础表单
 const baseFormRef = ref(null)
-const baseForm = ref({ fileList: [] })
+const baseForm = ref({ fileList: [], pictureUrl: '' })
 const baseFormRules = {}
 
 //获取数据详情
 const getDataDetail = async () => {
     if (!dataId.value) return
     const { data } = await mainApi.getDetail({ id: dataId.value })
-    baseForm.value = getObjValue(data)
-    addTableData.value = getArrValue(data.formList)
+    const res = getObjValue(data)
+    res.pictureUrl = res.pictureUrl ?? ''
+    baseForm.value = res
+    addTableData.value = getArrValue(res.formList)
 }
 
 //数据格式
@@ -300,6 +296,7 @@ const periodChange = () => {
 
 //计量期相关的数据
 const setBasePeriodForm = (periodId) => {
+    if (dataId.value) return
     const periods = period.value
     baseForm.value.contractPeriodId = periodId
     const periodData = periods.find((item) => item.id === periodId)
@@ -457,10 +454,10 @@ const addModalSave = async () => {
     form.projectId = pid.value
     form.contractId = cid.value
     let res = {}
-    if (dataType.value === 'add') {
-        res = await mainApi.add(form)
-    } else if (dataType.value === 'edit') {
+    if (dataId.value) {
         res = await mainApi.edit(form)
+    } else {
+        res = await mainApi.add(form)
     }
     //处理数据
     const { code, msg } = res
@@ -476,7 +473,7 @@ const addModalSave = async () => {
 //关闭弹窗
 const addModalClose = () => {
     isShow.value = false
-    baseForm.value = { fileList: [] }
+    baseForm.value = { fileList: [], pictureUrl: '' }
     addTableData.value = []
     emit('close')
 }

+ 8 - 8
src/views/debit-pay/admin/middlepay.vue

@@ -7,13 +7,13 @@
                         <el-option v-for="item in key1Data" :key="item.id" :label="item.periodNumber" :value="item.id" clearable />
                     </el-select>
                 </template>
-                <hc-lazy-tree :h-props="treeProps" tree-key="id" :auto-expand-keys="TreeAutoExpandKeys" @load="treeLoadNode" @nodeTap="treeNodeTap" />
+                <hc-lazy-tree :h-props="treeProps" tree-key="id" :auto-expand-keys="TreeAutoExpandKeys" @load="treeLoadNode" @node-tap="treeNodeTap" />
             </hc-new-card>
         </div>
         <div :id="`hc_table_card_${uuid}`" class="flex-1">
             <hc-new-card>
                 <template #header>
-                    <div class="font-400 text-orange">收方总金额:0元</div>
+                    <div class="text-orange font-400">收方总金额:0元</div>
                 </template>
                 <template #extra>
                     <el-button hc-btn type="primary" @click="addModalClick">新增</el-button>
@@ -45,7 +45,7 @@
             </hc-new-card>
         </div>
         <!-- 中间计量新增 -->
-        <HcAddModal v-model="addModalShow" :ids="addModalIds" :project-id="projectId" :contract-id="contractId" :type="isAddModalType" :all-periods="key1Data" :period-id="searchForm.contractPeriodId" @finish="addModalFinish" />
+        <HcAddModal v-model="addModalShow" :ids="addModalIds" :project-id="projectId" :contract-id="contractId" :all-periods="key1Data" :period-id="searchForm.contractPeriodId" @finish="addModalFinish" />
 
         <!-- 清单明细 -->
         <HcDetailsModal v-model="detailsModalShow" :project-id="projectId" :contract-id="contractId" :period-id="searchForm.contractPeriodId" />
@@ -211,19 +211,19 @@ const tableCheckChange = () => {
 
 //中间收方新增
 const addModalShow = ref(false)
-const isAddModalType = ref('add')
 const addModalClick = () => {
     addModalIds.value = ''
-    isAddModalType.value = 'add'
     addModalShow.value = true
 }
 
 //修改
 const addModalIds = ref('')
 const rowEditClick = (row) => {
-    addModalIds.value = row.id
-    isAddModalType.value = 'edit'
-    addModalShow.value = true
+    addModalIds.value = ''
+    nextTick(() => {
+        addModalIds.value = row.id
+        addModalShow.value = true
+    })
 }
 
 //删除