Browse Source

更新依赖和中间支付申请

ZaiZai 1 year ago
parent
commit
fc1205a66e

+ 15 - 0
src/utils/tools.js

@@ -1,3 +1,18 @@
+//删除提醒
+export const delMessage = (cbk) => {
+    window?.$messageBox?.alert('请谨慎考虑后,确认是否需要删除?', '删除提醒', {
+        showCancelButton: true,
+        confirmButtonText: '确认删除',
+        cancelButtonText: '取消',
+        type: 'warning',
+        callback: (action) => {
+            if (action === 'confirm') {
+                cbk()
+            }
+        },
+    })
+}
+
 //动态加载线上js文件
 export const addDocumentsJs = () => {
     return new Promise((resolve) => {

+ 28 - 4
src/views/debit-pay/admin/components/middlepay/addModal.vue

@@ -138,6 +138,7 @@
 
 <script setup>
 import { nextTick, ref, watch } from 'vue'
+import { useAppStore } from '~src/store'
 import { getStoreValue } from '~src/utils/storage'
 import HcBillBaseModal from './addBillBaseModal.vue'
 import { arrToId, getArrValue, getObjValue, getRandom } from 'js-fast-way'
@@ -177,6 +178,9 @@ const props = defineProps({
 //事件
 const emit = defineEmits(['finish', 'close'])
 
+const useAppState = useAppStore()
+const contractInfo = ref(useAppState.getContractInfo)
+
 const uuid = getRandom(4)
 const dataId = ref(props.ids)
 const dataType = ref(props.type)
@@ -284,10 +288,12 @@ const periodChange = () => {
 
 //计量期相关的数据
 const setBasePeriodForm = (periodId) => {
+    const { contractNumber } = contractInfo.value
     const periods = period.value
     baseForm.value.contractPeriodId = periodId
     const periodData = periods.find((item) => item.id === periodId)
-    baseForm.value.meterNumber = ''
+    baseForm.value.meterNumber = contractNumber + '-' + periodData.periodNumber + '-流水号'
+    baseForm.value.periodNumber = periodData.periodNumber
     baseForm.value.businessDate = periodData.endDate ?? null
 }
 
@@ -395,9 +401,27 @@ const uploadFileSuccess = ({ echoParams, resData }) => {
     }
 }
 
-const addModalSave = () => {
-    emit('finish')
-    addModalClose()
+//保存
+const addModalSave = async () => {
+    const form = baseForm.value
+    form.formList = addTableData.value
+    form.projectId = pid.value
+    form.contractId = cid.value
+    let res = {}
+    if (dataType.value === 'add') {
+        res = await mainApi.add(form)
+    } else if (dataType.value === 'edit') {
+        res = await mainApi.edit(form)
+    }
+    //处理数据
+    const { code, msg } = res
+    if (code === 200) {
+        window.$message.success('保存成功')
+        addModalClose()
+        emit('finish')
+    } else {
+        window.$message.error(msg ?? '保存失败')
+    }
 }
 
 //关闭弹窗

+ 59 - 11
src/views/debit-pay/admin/middlepay.vue

@@ -28,9 +28,15 @@
                     is-new is-check :check-style="{ width: 29 }" :index-style="{ width: 60 }"
                     @selection-change="tableCheckChange"
                 >
+                    <template #contractPeriodId="{ row }">
+                        {{ getTablePeriod(row) }}
+                    </template>
+                    <template #approveStatus="{ row }">
+                        {{ getTableStatus(row) }}
+                    </template>
                     <template #action="{ row }">
-                        <el-link type="success">修改</el-link>
-                        <el-link type="danger">删除</el-link>
+                        <el-link type="success" @click="rowEditClick(row)">修改</el-link>
+                        <el-link type="danger" @click="rowDelClick(row)">删除</el-link>
                     </template>
                 </hc-table>
                 <template #action>
@@ -39,7 +45,7 @@
             </hc-new-card>
         </div>
         <!-- 中间计量新增 -->
-        <HcAddModal v-model="addModalShow" :project-id="projectId" :contract-id="contractId" :type="isAddModalType" :all-periods="key1Data" :period-id="searchForm.contractPeriodId" />
+        <HcAddModal v-model="addModalShow" :project-id="projectId" :contract-id="contractId" :type="isAddModalType" :all-periods="key1Data" :period-id="searchForm.contractPeriodId" @finish="addModalFinish" />
 
         <!-- 清单明细 -->
         <HcDetailsModal v-model="detailsModalShow" />
@@ -55,10 +61,12 @@
 <script setup>
 import { nextTick, onMounted, ref } from 'vue'
 import { useAppStore } from '~src/store'
-import HcAddModal from './components/middlepay/addModal.vue'
-import HcDetailsModal from './components/middlepay/detailsModal.vue'
 import { getArrValue, getObjValue, getRandom } from 'js-fast-way'
 import { getStoreValue, setStoreValue } from '~src/utils/storage'
+import { delMessage } from '~uti/tools'
+
+import HcAddModal from './components/middlepay/addModal.vue'
+import HcDetailsModal from './components/middlepay/detailsModal.vue'
 
 import periodApi from '~api/debit-pay/material/periods'
 import unitApi from '~api/project/debit/contract/unit'
@@ -157,12 +165,12 @@ const pageChange = ({ current, size }) => {
 //表格数据
 const tableLoading = ref(false)
 const tableColumn = ref([
-    { key: 'key1', name: '计量单编号' },
-    { key: 'key2', name: '计量期' },
-    { key: 'key3', name: '工程划分部位' },
-    { key: 'key4', name: '计量金额' },
-    { key: 'key5', name: '业务日期' },
-    { key: 'key6', name: '审核状态' },
+    { key: 'meterNumber', name: '计量单编号' },
+    { key: 'contractPeriodId', name: '计量期' },
+    { key: 'engineerDivide', name: '工程划分部位' },
+    { key: 'meterMoney', name: '计量金额' },
+    { key: 'businessDate', name: '业务日期' },
+    { key: 'approveStatus', name: '审核状态' },
     { key: 'action', name: '操作', width: 130, align: 'center' },
 ])
 const tableData = ref([])
@@ -178,6 +186,26 @@ const getTableData = async () => {
     tableLoading.value = false
 }
 
+//获取表格计量期
+const getTablePeriod = ({ contractPeriodId }) => {
+    const periods = key1Data.value
+    const periodData = periods.find((item) => item.id === contractPeriodId)
+    return periodData?.periodName || ''
+}
+
+//获取表格状态
+const getTableStatus = ({ approveStatus }) => {
+    if (approveStatus === 0) {
+        return '未上报'
+    } else if (approveStatus === 1) {
+        return '待审批'
+    } else if (approveStatus === 2) {
+        return '已审批'
+    } else if (approveStatus === 3) {
+        return '已废除'
+    }
+}
+
 //表格选择
 const tableCheckChange = () => {
 
@@ -191,6 +219,26 @@ const addModalClick = () => {
     addModalShow.value = true
 }
 
+//修改
+const rowEditClick = (row) => {
+
+}
+
+//删除
+const rowDelClick = (row) => {
+    delMessage(() => {
+        console.log('删除')
+    })
+}
+
+
+//保存完成
+const addModalFinish = () => {
+    addModalShow.value = false
+    getTableData()
+}
+
+
 //收方清单明细
 const detailsModalShow = ref(false)
 const detailsModalClick = () => {