Browse Source

材料预付款计量期调接口

duy 1 year ago
parent
commit
22c1b5c615
2 changed files with 165 additions and 36 deletions
  1. 44 0
      src/api/modules/debit-pay/material/periods.js
  2. 121 36
      src/views/debit-pay/material/periods.vue

+ 44 - 0
src/api/modules/debit-pay/material/periods.js

@@ -0,0 +1,44 @@
+import { HcApi } from '../../../request/index'
+//  合同材料
+export default {
+    //分页
+    async getPage(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/meterPeriod/periodPage',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+    //修改
+    async edit(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/meterPeriod/edit',
+            method: 'post',
+            data: form,
+        }, msg)
+    },
+    //计量期列表-全部
+    async allPeriod(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/meterPeriod/allPeriod',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+    //计量期列表-未关联报表
+    async conditionPeriod(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/meterPeriod/conditionPeriod',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+    //锁定
+    async locking(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/meterPeriod/locking',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+}

+ 121 - 36
src/views/debit-pay/material/periods.vue

@@ -8,14 +8,15 @@
         </template>
         <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" is-new :index-style="{ width: 60 }">
             <template #action="{ row }">
-                <el-link type="danger">锁定</el-link>
+                <el-link v-if="row?.isLock === 0" type="danger" @click="lockRow(row)">锁定</el-link>
+                <el-link v-if="row?.isLock === 1" type="danger" @click="lockRow(row)">解锁</el-link>
             </template>
         </hc-table>
         <template #action>
             <hc-pages :pages="searchForm" @change="pageChange" />
         </template>
         <!-- 编辑修改 -->
-        <hc-new-dialog is-table widths="1200px" :show="editModalShow" title="材料预付款计量期编辑" @save="editModalSave" @close="editModalClose">
+        <hc-new-dialog is-table widths="1200px" :show="editModalShow" title="材料预付款计量期编辑" :loading="saveLoading" @save="editModalSave" @close="editModalClose">
             <hc-card-item>
                 <template #header>
                     <el-tooltip :visible="editVisible" effect="light" placement="bottom-start">
@@ -32,37 +33,37 @@
                     </el-tooltip>
                 </template>
                 <template #extra>
-                    <el-button type="primary">
+                    <el-button type="primary" @click="addPreRow">
                         <HcIcon name="page-separator" :line="false" />
                         <span>插入上一行</span>
                     </el-button>
-                    <el-button type="primary">
+                    <el-button type="primary" @click="addNextRow">
                         <HcIcon name="page-separator" :line="false" />
                         <span>插入下一行</span>
                     </el-button>
                 </template>
-                <hc-table :column="tableEditColumn" :datas="tableEditData" is-new :index-style="{ width: 60 }">
-                    <template #key1="{ row }">
-                        <hc-table-input v-model="row.key1" disabled is-new :index-style="{ width: 60 }" />
+                <hc-table :column="tableEditColumn" :datas="tableEditData" is-new is-current-row :index-style="{ width: 60 }" :loading="tableEditLoading" @row-click="hangeRow">
+                    <template #periodNumber="{ row }">
+                        <hc-table-input v-model="row.periodNumber" is-new :index-style="{ width: 60 }" :disabled="row.isLock === 1" />
                     </template>
-                    <template #key2="{ row }">
-                        <hc-table-input v-model="row.key2" disabled is-new :index-style="{ width: 60 }" />
+                    <template #periodName="{ row }">
+                        <hc-table-input v-model="row.periodName" is-new :index-style="{ width: 60 }" :disabled="row.isLock === 1" />
                     </template>
-                    <template #key3="{ row }">
-                        <el-select v-model="row.key3" placeholder="选择年份" filterable disabled block>
+                    <template #periodYear="{ row }">
+                        <el-select v-model="row.periodYear" placeholder="选择年份" filterable block :disabled="row.isLock === 1">
                             <el-option v-for="item in yearData" :key="item" :label="item" :value="item" />
                         </el-select>
                     </template>
-                    <template #key4="{ row }">
-                        <el-select v-model="row.key4" placeholder="选择月份" filterable disabled block>
+                    <template #periodMonth="{ row }">
+                        <el-select v-model="row.periodMonth" placeholder="选择月份" filterable block :disabled="row.isLock === 1">
                             <el-option v-for="item in monthData" :key="item" :label="item" :value="item" />
                         </el-select>
                     </template>
-                    <template #key5="{ row }">
-                        <el-date-picker v-model="row.key5" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" disabled />
+                    <template #formPrintDate="{ row }">
+                        <el-date-picker v-model="row.formPrintDate" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" :disabled="row.isLock === 1" />
                     </template>
-                    <template #action="{ row }">
-                        <el-button plain size="small" type="danger">删除</el-button>
+                    <template #action="{ row, index }">
+                        <el-button plain size="small" type="danger" :disabled="row?.isLock === 1 || !row?.isNew" @click="delRow(row, index)">删除</el-button>
                     </template>
                 </hc-table>
             </hc-card-item>
@@ -73,7 +74,12 @@
 <script setup>
 import { onMounted, ref } from 'vue'
 import dayjs from 'dayjs'
-import { getMonthList, getYearList } from 'js-fast-way'
+import { getArrValue, getMonthList, getYearList } from 'js-fast-way'
+import mainApi from '~api/debit-pay/material/periods.js'
+import { useAppStore } from '~src/store'
+const useAppState = useAppStore()
+const contractId = ref(useAppState.getContractId)
+const projectId = ref(useAppState.getProjectId)
 
 defineOptions({
     name: 'DebitPayMaterialPeriods',
@@ -84,9 +90,10 @@ const year = Number(dayjs().format('YYYY')) + 8
 const yearData = getYearList(year, 2010)
 const monthData = getMonthList()
 
+//渲染完成
 //渲染完成
 onMounted(() => {
-
+    getTableData()
 })
 
 //搜索表单
@@ -103,39 +110,117 @@ 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: 'periodNumber', name: '期号' },
+    { key: 'periodName', name: '期名称' },
+    { key: 'periodYear', name: '年份' },
+    { key: 'periodMonth', name: '月份' },
+    { key: 'formPrintDate', name: '报表打印日期' },
     { key: 'action', name: '操作', width: 80 },
 ])
 const tableData = ref([
     { key1: '1111' },
 ])
-
+const getTableData = async () => {
+    tableLoading.value = true
+    const { error, code, data } = await mainApi.getPage({
+       ...searchForm.value,
+       contractId:contractId.value,
+       type:1,
+    })
+    tableLoading.value = false
+    if (!error && code === 200) {
+        tableData.value = getArrValue(data['records'])
+    } else {
+        tableData.value = []
+    }
+}
 //计量期编辑
 const editVisible = ref(false)
 const editModalShow = ref(false)
 const editModalClick = () => {
     editModalShow.value = true
+    getTableEditData()
+}
+//锁定
+const lockLoading = ref(false)
+const lockRow = async (row)=>{
+    lockLoading.value = true
+    const { error, code, msg } = await mainApi.locking({
+        isLock:row?.isLock,
+        id:row?.id,
+        })
+        //判断状态
+        lockLoading.value = false
+        if (!error && code === 200) {
+            window?.$message?.success(msg)
+        }
+        getTableData()
 }
 
 //编辑的表格
 const tableEditColumn = [
-    { key: 'key1', name: '期号' },
-    { key: 'key2', name: '期名称' },
-    { key: 'key3', name: '年份' },
-    { key: 'key4', name: '月份' },
-    { key: 'key5', name: '报表打印日期' },
+    { key: 'periodNumber', name: '期号' },
+    { key: 'periodName', name: '期名称' },
+    { key: 'periodYear', name: '年份' },
+    { key: 'periodMonth', name: '月份' },
+    { key: 'formPrintDate', name: '报表打印日期' },
     { key: 'action', name: '操作', width: 80, align: 'center' },
 ]
-const tableEditData = ref([
-    { key1: '11' },
-    { key1: '222' },
-])
-
-const editModalSave = () => {
+const tableEditData = ref([])
+const tableEditLoading = ref(false)
+const getTableEditData = async () => {
+    tableEditLoading.value = true
+    const { error, code, data } = await mainApi.allPeriod({
+       ...searchForm.value,
+       contractId:contractId.value,
+       type:1,
+    })
+    tableEditLoading.value = false
+    if (!error && code === 200) {
+        tableEditData.value = getArrValue(data)
+        if (tableEditData.value.length === 0) {
+            tableEditData.value.push({ isNew:true })
+        }
+    } else {
+        tableEditData.value = []
+    }
+}
+const delRow = (row, index)=>{
+    tableEditData.value.splice(index, 1)
+    if ( tableEditData.value.length === 0) {
+        tableEditData.value.push({})
+    }
+}
+const curIndex = ref(0)
+const hangeRow = ({ row })=>{
+    tableEditData.value.forEach((ele, index)=>{
+        if (row.id === ele.id) {
+            curIndex.value = index
+        }
+    })
+}
+const addPreRow = ()=>{
+    tableEditData.value.splice( curIndex.value, 0, { isNew:true })
+}
+const addNextRow = ()=>{
+    tableEditData.value.splice( curIndex.value + 1, 0, { isNew:true })
+}
+const saveLoading = ref(false)
+const editModalSave = async () => {
+    saveLoading.value = true
+    const { error, code, msg } = await mainApi.edit({
+        list: tableEditData.value,
+        contractId:contractId.value,
+        projectId:projectId.value,
+        type:1,
+       
+        })
+        //判断状态
+        saveLoading.value = false
+        if (!error && code === 200) {
+            window?.$message?.success(msg)
+        }
+        getTableData()
     editModalClose()
 }
 const editModalClose = () => {