Переглянути джерело

开工计量单接口调用

duy 1 рік тому
батько
коміт
c164432a6b

+ 45 - 0
src/api/modules/debit-pay/start-work/order.js

@@ -0,0 +1,45 @@
+import { HcApi } from '../../../request/index'
+// 开工预付款计量单接口
+export default {
+    //分页
+    async getPage(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/startPayMeterForm/page',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+      //详情
+    async detail(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/startPayMeterForm/detail',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+    //新增
+    async add(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/startPayMeterForm/add',
+            method: 'post',
+            data: form,
+        }, msg)
+    },
+    //修改
+    async update(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/startPayMeterForm/update',
+            method: 'post',
+            data: form,
+        }, msg)
+    },
+    //删除
+    async remove(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/startPayMeterForm/remove',
+            method: 'post',
+            params: form,
+        }, msg)
+    },
+
+}

+ 108 - 15
src/views/debit-pay/start-work/components/order/dataModal.vue

@@ -1,25 +1,24 @@
 <template>
-    <hc-new-dialog widths="500px" :show="isShow" title="开工预付款计量单新增" @save="modalSave" @close="modalClose">
+    <hc-new-dialog widths="500px" :show="isShow" title="开工预付款计量单新增" :loading="modalSaving" @save="modalSave" @close="modalClose">
         <el-scrollbar>
             <hc-card-item>
                 <el-form ref="baseFormRef" :model="baseForm" :rules="baseFormRules" label-position="top" label-width="auto">
                     <el-form-item label="计量期:">
-                        <el-select v-model="baseForm.key1" block>
-                            <el-option label="第一期" value="1" />
-                            <el-option label="第二期" value="2" />
+                        <el-select v-model="baseForm.meterPeriodId" placeholder="选择计量期" filterable clearable block>
+                            <el-option v-for="item in key1Data" :key="item.id" :label="item.periodName" :value="item.id" />
                         </el-select>
                     </el-form-item>
                     <el-form-item label="业务日期:">
-                        <el-date-picker v-model="baseForm.key2" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" disabled />
+                        <el-date-picker v-model="baseForm.businessDate" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" disabled />
                     </el-form-item>
                     <el-form-item label="计量金额:">
-                        <el-input v-model="baseForm.key3" />
+                        <el-input v-model="baseForm.meterMoney" />
                     </el-form-item>
                     <el-form-item label="开工预付款总额:">
-                        <el-input v-model="baseForm.key4" />
+                        <el-input v-model="baseForm.startPayAmount" />
                     </el-form-item>
                     <el-form-item label="申请依据:">
-                        <el-input v-model="baseForm.key5" :autosize="{ minRows: 2, maxRows: 6 }" type="textarea" />
+                        <el-input v-model="baseForm.applyCause" :autosize="{ minRows: 2, maxRows: 6 }" type="textarea" />
                     </el-form-item>
                 </el-form>
             </hc-card-item>
@@ -27,27 +26,56 @@
             <hc-card-item class="mt-3" title="附件列表" extra-text="可上传:图片、Excel、PDF、Word文件">
                 <el-form :model="baseForm" label-position="top">
                     <el-form-item label="">
-                        <hc-form-upload type="list" :src="baseForm.key11" />
+                        <hc-form-upload type="list" :src="fileName" @upload="formItemUpload" />
                     </el-form-item>
                 </el-form>
             </hc-card-item>
         </el-scrollbar>
+        <HcUploadFile ref="HcUploadFileRef" @finish="HcUploadFileFinish" />
     </hc-new-dialog>
 </template>
 
 <script setup>
 import { ref, watch } from 'vue'
-
+import { useAppStore } from '~src/store'
+import { arrToKey, getArrValue, getObjValue } from 'js-fast-way'
+import periodApi from '~api/debit-pay/material/periods.js'
+import orderApi from '~api/debit-pay/start-work/order.js'
 const props = defineProps({
     ids: {
         type: [String, Number],
         default: '',
     },
+    infoData:{
+        type: Object,
+        default: () => ({}),
+    },
 })
-
 //事件
 const emit = defineEmits(['close'])
+const useAppState = useAppStore()
+const contractId = ref(useAppState.getContractId)
+const projectId = ref(useAppState.getProjectId)
+const infoData = ref(props.infoData)
+const ids = ref(props.ids)
+const fileName = ref('')
+const baseForm = ref({})
+//监听
+watch(() => [
+    props.ids,
+    props.infoData,
+], ([Id, info]) => {
+    ids.value = Id
+    infoData.value = info
 
+    if (Id.length > 0) {
+        baseForm.value = info
+        fileName.value = arrToKey(info?.fileList, 'fileName', ',')
+    } else {
+        baseForm.value = {}
+        fileName.value = ''
+    }
+}, { immediate: true })
 //双向绑定
 // eslint-disable-next-line no-undef
 const isShow = defineModel('modelValue', {
@@ -65,15 +93,58 @@ watch(() => [
 watch(isShow, (val) => {
     if (val) {
         console.log('isShow', val)
+        getKey1Data()
     }
 })
-
+//计量期
+const key1Data = ref([])
+const getKey1Data = async ()=>{
+    const { error, code, data } = await periodApi.allPeriod({
+       contractId:contractId.value,
+       type:2,
+    })
+    if (!error && code === 200) {
+        key1Data.value = getArrValue(data)
+    } else {
+        key1Data.value = []
+    }
+}
 //基础表单
 const baseFormRef = ref(null)
-const baseForm = ref({})
+// const baseForm = ref({})
 const baseFormRules = {}
-
-const modalSave = () => {
+const modalSaving = ref(false)
+const modalSave = async () => {
+console.log(baseForm.value, 'baseForm.value')
+    modalSaving.value = true
+    if (ids.value.length < 1) {
+        const { error, code, msg } = await orderApi.add({
+        ...baseForm.value,
+        contractId:contractId.value,
+        projectId:projectId.value,
+        })
+        //判断状态
+        modalSaving.value = false
+        if (!error && code === 200) {
+            window?.$message?.success(msg)
+            
+         
+        }
+    } else if (ids.value.length > 0) {
+        const { error, code, msg } = await orderApi.update({
+        ...baseForm.value,
+        contractId:contractId.value,
+        projectId:projectId.value,
+        })
+        //判断状态
+        modalSaving.value = false
+        if (!error && code === 200) {
+            window?.$message?.success(msg)
+            
+         
+        }
+    }
+   
     modalClose()
 }
 
@@ -81,6 +152,28 @@ const modalClose = () => {
     isShow.value = false
     emit('close')
 }
+//上传
+const formItemUpload = () => {
+    HcUploadFileRef.value?.selectFile()
+}
+const HcUploadFileRef = ref(null)
+// const fileName = ref('')
+// 文件全部上传完成
+const HcUploadFileFinish = (res) => {
+ let arr = []
+ res.forEach((ele)=>{
+    arr.push(ele.resData)
+ })
+ arr.forEach((ele)=>{
+    ele.fileName = ele.originalName
+    ele.fileUrl = ele.link
+    ele.filePdfUrl = ele.pdfUrl
+ })
+ baseForm.value.fileList = arr
+fileName.value = arrToKey(arr, 'originalName', ',')
+
+  HcUploadFileRef?.value.setModalShow(false)
+}
 </script>
 
 <style scoped lang="scss">

+ 108 - 28
src/views/debit-pay/start-work/order.vue

@@ -2,8 +2,8 @@
     <hc-new-card>
         <template #header>
             <div class="w-40">
-                <el-select v-model="searchForm.key1" filterable block placeholder="选择计量期" @change="searchKey1Click">
-                    <el-option v-for="item in key1Data" :key="item.id" :label="item.name" :value="item.id" />
+                <el-select v-model="searchForm.meterPeriodId" placeholder="选择计量期" filterable clearable block @change="searchKey1Click">
+                    <el-option v-for="item in key1Data" :key="item.id" :label="item.periodName" :value="item.id" />
                 </el-select>
             </div>
         </template>
@@ -27,7 +27,7 @@
                     >
                         <template #action="{ row }">
                             <el-link type="success" @click="rowEditClick(row)">修改</el-link>
-                            <el-link type="danger">删除</el-link>
+                            <el-link type="danger" @click="delRowClick(row)">删除</el-link>
                         </template>
                     </hc-table>
                     <template #action>
@@ -40,33 +40,34 @@
                     <hc-info-table>
                         <tr>
                             <hc-info-table-td center is-title>计量期:</hc-info-table-td>
-                            <hc-info-table-td width="120px">第1期</hc-info-table-td>
+                            <hc-info-table-td width="120px">{{ infoData?.periodNumber }}</hc-info-table-td>
                             <hc-info-table-td center is-title>业务日期:</hc-info-table-td>
-                            <hc-info-table-td width="120px">2020-09-10</hc-info-table-td>
+                            <hc-info-table-td width="120px">{{ infoData?.businessDate }}</hc-info-table-td>
                         </tr>
                         <tr>
                             <hc-info-table-td center is-title>计量金额:</hc-info-table-td>
-                            <hc-info-table-td width="120px">2775000</hc-info-table-td>
+                            <hc-info-table-td width="120px">{{ infoData?.meterMoney }}</hc-info-table-td>
                             <hc-info-table-td center is-title>开工预付款总额:</hc-info-table-td>
-                            <hc-info-table-td width="120px">-</hc-info-table-td>
+                            <hc-info-table-td width="120px">{{ infoData?.startPayAmount }}</hc-info-table-td>
                         </tr>
                         <tr>
                             <hc-info-table-td center is-title>申请依据:</hc-info-table-td>
-                            <hc-info-table-td width="auto" colspan="3">-</hc-info-table-td>
+                            <hc-info-table-td width="auto" colspan="3">{{ infoData?.applyCause }}</hc-info-table-td>
                         </tr>
                     </hc-info-table>
                     <div class="mt-5">附件列表</div>
                     <div class="mt-3">
-                        <el-check-tag checked class="mr-2">文件名称1.jpg</el-check-tag>
-                        <el-check-tag checked class="mr-2">文件名称2.jpg</el-check-tag>
-                        <el-check-tag checked class="mr-2">文件名称3.jpg</el-check-tag>
-                        <el-check-tag checked class="mr-2">文件名称4.jpg</el-check-tag>
+                        <template v-if="infoData?.fileList?.length > 0">
+                            <el-check-tag v-for="item in infoData?.fileList" :key="item.id" checked class="mr-2">{{ item.fileName }}</el-check-tag>
+                        </template>
+                       
+                        <HcNoData v-else />
                     </div>
                 </hc-card-item>
             </div>
         </div>
         <!-- 新增/修改 -->
-        <HcDataModal v-model="isDataModal" />
+        <HcDataModal v-model="isDataModal" :info-data="infoData" :ids="editId" @close="finishData" />
 
         <!-- 上报弹窗 -->
         <hc-report-dialog v-model="isReport" />
@@ -74,8 +75,15 @@
 </template>
 
 <script setup>
-import { onMounted, ref } from 'vue'
+import { onActivated, onMounted, ref } from 'vue'
 import HcDataModal from './components/order/dataModal.vue'
+import { getArrValue, getObjValue } from 'js-fast-way'
+import mainApi from '~api/debit-pay/start-work/order.js'
+import periodApi from '~api/debit-pay/material/periods.js'
+import { useAppStore } from '~src/store'
+import { delMessageV2 } from '~com/message/index.js'
+const useAppState = useAppStore()
+const contractId = ref(useAppState.getContractId)
 
 defineOptions({
     name: 'DebitPayStartWorkOrder',
@@ -83,21 +91,35 @@ defineOptions({
 
 //渲染完成
 onMounted(() => {
-
+    getTableData()
 })
 
+onActivated(() => {
+    getKey1Data()
+})
+//计量期
+const key1Data = ref([])
+const getKey1Data = async ()=>{
+    const { error, code, data } = await periodApi.allPeriod({
+       contractId:contractId.value,
+       type:2,
+    })
+    tableLoading.value = false
+    if (!error && code === 200) {
+        key1Data.value = getArrValue(data)
+    } else {
+        key1Data.value = []
+    }
+}
 //搜索表单
 const searchForm = ref({
     key1: null, current: 1, size: 10, total: 0,
 })
 
 //计量期
-const key1Data = ref([
-    { id: 1, name: '计量期1' },
-    { id: 2, name: '计量期2' },
-])
-const searchKey1Click = () => {
 
+const searchKey1Click = () => {
+    getTableData()
 }
 
 //分页
@@ -109,16 +131,47 @@ const pageChange = ({ current, size }) => {
 //表格数据
 const tableLoading = ref(false)
 const tableColumn = ref([
-    { key: 'key1', name: '计量期' },
-    { key: 'key2', name: '业务日期' },
-    { key: 'key3', name: '计量金额' },
-    { key: 'key4', name: '审批状态' },
+    { key: 'periodNumber', name: '计量期' },
+    { key: 'businessDate', name: '业务日期' },
+    { key: 'meterMoney', name: '计量金额' },
+    { key: 'approveStatusName', name: '审批状态' },
     { key: 'action', name: '操作', width: 94 },
 ])
 const tableData = ref([
-    { key1: '1111' },
 ])
-
+const getTableData = async () => {
+    tableLoading.value = true
+    console.log(searchForm.value, 'searchForm.value')
+    const { error, code, data } = await mainApi.getPage({
+       ...searchForm.value,
+       contractId:contractId.value,
+    })
+    tableLoading.value = false
+    if (!error && code === 200) {
+        tableData.value = getArrValue(data['records'])
+        if (tableData.value.length > 0) {
+            getDetail(tableData.value[0].id)
+        } else {
+            infoData.value = {}
+        }
+    } else {
+        tableData.value = []
+       
+    }
+}
+//获取详情
+const infoData = ref({})
+const getDetail = async (id)=>{
+    const { error, code, data } = await mainApi.detail({
+       id,
+    })
+    if (!error && code === 200) {
+        infoData.value = getObjValue(data)
+   
+    } else {
+        infoData.value = {}
+    }
+}
 //表格选择
 const tableCheckChange = () => {
 
@@ -128,13 +181,40 @@ const tableCheckChange = () => {
 const isDataModal = ref(false)
 const addModalClick = () => {
     isDataModal.value = true
+    editId.value = ''
 }
-
+const editId = ref('')
 //修改
 const rowEditClick = (row) => {
     isDataModal.value = true
+    editId.value = row.id
+}
+const delRowClick = async (row)=>{
+    delMessageV2(async (action, instance, done) => {
+            if (action === 'confirm') {
+                instance.confirmButtonLoading = true
+                removeProPay(row.id)
+                instance.confirmButtonLoading = false
+                done()
+            } else {
+                done()
+            }
+    })
+}
+const removeProPay = async (id) => {
+    const { error, code } = await mainApi.remove({
+        ids: id, 
+    })
+    if (!error && code === 200) {
+        window?.$message?.success('删除成功')
+       getTableData()
+     
+    }
+}
+const finishData = ()=>{
+    isDataModal.value = false
+    getTableData()
 }
-
 //是否上报
 const isReport = ref(false)
 const reportClick = () => {