Browse Source

费用管理,财务报销

ZaiZai 2 years ago
parent
commit
ccb39d1699

+ 14 - 6
src/api/modules/expense/finReimburse.js

@@ -15,7 +15,7 @@ export default {
             url: '/api/blade-control/expense/financial/draft/list',
             method: 'get',
             params: form
-        },msg);
+        }, msg);
     },
     //财务报销信息详情
     async detail(form, msg = false) {
@@ -23,7 +23,7 @@ export default {
             url: '/api/blade-control/expense/financial/detail',
             method: 'get',
             params: form
-        },msg);
+        }, msg);
     },
     //财务报销信息提交
     async submit(form, msg = false) {
@@ -31,14 +31,22 @@ export default {
             url: '/api/blade-control/expense/financial/submit',
             method: 'post',
             data: form
-        },msg);
+        }, msg);
     },
-     //财务报销记录上报撤销
-     async cancel(form, msg = false) {
+    //财务报销记录物理删除
+    async remove(form, msg = false) {
+        return httpApi({
+            url: '/api/blade-control/expense/financial/remove',
+            method: 'post',
+            params: form
+        }, msg);
+    },
+    //财务报销记录上报撤销
+    async cancel(form, msg = false) {
         return httpApi({
             url: '/api/blade-control/expense/financial/cancel',
             method: 'post',
             params: form
-        },msg);
+        }, msg);
     },
 }

+ 87 - 17
src/views/expense/finReimburse/index.vue

@@ -28,7 +28,7 @@
         <template #extra>
             <el-button size="large" type="warning" hc-btn @click="draftsClick">
                 <HcIcon name="draft"/>
-                <span>草稿箱(1)</span>
+                <span>草稿箱{{draftNum > 0 ? `(${draftNum})` : ''}}</span>
             </el-button>
             <el-button size="large" type="primary" hc-btn @click="addRowClick">
                 <HcIcon name="add"/>
@@ -37,11 +37,18 @@
         </template>
 
         <HcTable :isIndex="false" :column="tableColumn" :datas="tableData" :loading="tableLoading">
-            <template #key="{row}">
-                <span class="text-blue" @click="rowNameTap(row)">{{row.key}}</span>
+            <template #frNumber="{row}">
+                <span class="text-blue text-hover" @click="rowNameTap(row)">{{row.frNumber}}</span>
             </template>
             <template #action="{row,index}">
-                <el-button size="small" type="primary">撤销</el-button>
+                <el-popconfirm title="是否确认撤销?" hide-icon @confirm="rowCancel(row)">
+                    <template #reference>
+                        <el-button size="small" type="primary"
+                                   :disabled="row.status !== 1"
+                                   :loading="row.isCancelLoading"
+                        >撤销</el-button>
+                    </template>
+                </el-popconfirm>
             </template>
         </HcTable>
 
@@ -50,13 +57,15 @@
         </template>
 
         <!--草稿箱-->
-        <HcDialog bgColor="#ffffff" isToBody isTable :footer="false" :show="draftsModal" title="草稿箱(1)" widths="62rem" @close="draftsCloseClick">
+        <HcDialog isToBody isTable bgColor="#ffffff" widths="62rem" :footer="false" :show="draftsModal"
+                  :title="draftNum > 0 ? `草稿箱(${draftNum})` : '草稿箱'" @close="draftsCloseClick"
+        >
             <el-alert title="3个月内未更新的草稿将被自动删除" type="warning" show-icon />
             <div style="position: relative;height: calc(100% - 44px);">
                 <HcTable :isIndex="false" :column="tableDraftsColumn" :datas="tableDraftsData">
                     <template #action="{row,index}">
-                        <el-button size="small" type="primary">继续编辑</el-button>
-                        <el-button size="small" type="danger">删除</el-button>
+                        <el-button size="small" type="primary" @click="editDraftClick(row)">继续编辑</el-button>
+                        <el-button size="small" type="danger" @click="delDraftClick(row)">删除</el-button>
                     </template>
                 </HcTable>
             </div>
@@ -71,16 +80,21 @@ import mainApi from "~api/expense/finReimburse";
 import projectApi from "~api/project/project-list";
 import {getArrValue} from "js-fast-way";
 import {getChildList} from "~api/system/parameter";
+import {delMessage} from "~uti/tools";
 
 const router = useRouter()
 
 onActivated(() => {
+    getApi()
+})
+
+const getApi = () => {
     getProjectData()
     getTableData()
-
+    getDraftNum()
     //测试查字典
     getChildListApi()
-})
+}
 
 //测试查字典
 const getChildListApi = () => {
@@ -104,7 +118,6 @@ const getProjectData = async () => {
     }
 }
 
-
 //搜索表单
 const searchForm = ref({userIdVesting: null, projectId: null, current: 1, size: 20, total: 0})
 
@@ -138,7 +151,7 @@ const tableColumn = [
     {key: 'approvalStatusName', name: '审批状态', width: '140', align: 'center'},
     {key: 'frDate', name: '报销时间', width: '160', align: 'center'},
     {key: 'createName', name: '创建人', width: '140', align: 'center'},
-    {key: 'createTime', name: '创建时间', width: '160', align: 'center'},
+    {key: 'createTime', name: '创建时间', width: '180', align: 'center'},
     {key: 'action', name: '操作', width: '90', align: 'center', fixed: 'right'},
 ]
 const tableData = ref([])
@@ -156,11 +169,28 @@ const getTableData = async () => {
     }
 }
 
-
-
 //预览
-const rowNameTap = (row) => {
+const rowNameTap = ({id}) => {
+    router.push({
+        name: 'expense-finReimburse-record',
+        query: {id: id}
+    })
+}
 
+//撤销
+const rowCancel = async (row) => {
+    row.isCancelLoading = true
+    const {error, code, msg} = await mainApi.page({
+        id: row.id
+    })
+    //判断状态
+    row.isCancelLoading = false
+    if (!error && code === 200) {
+        window.$message?.success(msg)
+        getTableData().then()
+    } else {
+        window.$message?.error(msg)
+    }
 }
 
 //新增预算
@@ -173,18 +203,58 @@ const addRowClick = () => {
 //草稿箱
 const draftsModal = ref(false)
 const draftsClick = () => {
+    tableDraftsData.value = []
     draftsModal.value = true
+    getDraftNum()
 }
 const draftsCloseClick = () => {
     draftsModal.value = false
 }
 
 //草稿箱数据
+const draftNum = ref(0)
 const tableDraftsColumn = [
-    {key: 'key1', name: '标题'},
-    {key: 'key2', name: '更新时间', width: '200'},
+    {key: 'title', name: '标题'},
+    {key: 'updateTime', name: '更新时间', width: '200'},
     {key: 'action', name: '操作', width: '170', align: 'center'},
 ]
-const tableDraftsData = ref([{id: 1, key1: 'xxxx', key2: 'xxxx'}, {id: 2, key1: 'xxxx', key2: 'xxxx'}, {id: 3, key1: 'xxxx', key2: 'xxxx'}])
+const tableDraftsData = ref([])
+
+//获取草稿数量
+const getDraftNum = async () => {
+    const {error, code, data} = await mainApi.draft()
+    //判断状态
+    if (!error && code === 200) {
+        const res = getArrValue(data)
+        tableDraftsData.value = res
+        draftNum.value = res.length
+    } else {
+        tableDraftsData.value = []
+        draftNum.value = 0
+    }
+}
 
+//继续编辑
+const editDraftClick = ({id}) => {
+    router.push({
+        name: 'expense-finReimburse-record',
+        query: {id: id}
+    })
+}
+
+//删除草稿
+const delDraftClick = (row) => {
+    delMessage(async () => {
+        const {error, code, msg} = await mainApi.remove({
+            id: row.id
+        })
+        //判断状态
+        if (!error && code === 200) {
+            window.$message?.success(msg)
+            getDraftNum().then()
+        } else {
+            window.$message?.error(msg)
+        }
+    })
+}
 </script>

+ 55 - 8
src/views/expense/finReimburse/record.vue

@@ -6,13 +6,12 @@
         <div class="hac-expense-record-body">
             <div class="record-form-box">
                 <el-scrollbar>
-                    <HcCardItem title="报销明细1" ui="hac-bg-grey">
+                    <HcCardItem :title="'报销明细' + (index + 1)" v-for="(item, index) in detailsArr" ui="hac-bg-grey mb-5">
                         <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="left" label-width="auto" size="large">
                             <div class="hc-form-item">
                                 <el-form-item label="所属项目:" prop="key1">
                                     <el-select block v-model="formModel.key1">
-                                        <el-option label="选项1" value="选项1"/>
-                                        <el-option label="选项2" value="选项2"/>
+                                        <el-option v-for="item in projectData" :label="item.name" :value="item.id"/>
                                     </el-select>
                                 </el-form-item>
                                 <div class="ml-2">
@@ -51,10 +50,9 @@
                             </el-form-item>
                         </el-form>
                     </HcCardItem>
-
-                    <div class="record-form-action-box mt-16">
+                    <div class="record-form-action-box mt-11">
                         <el-divider content-position="right" border-style="dashed">
-                            <el-button type="primary" hc-btn>
+                            <el-button type="primary" hc-btn @click="detailsArr.push({})">
                                 <HcIcon name="add"/>
                                 <span>添加明细</span>
                             </el-button>
@@ -133,11 +131,60 @@
 </template>
 
 <script setup>
-import {ref} from "vue";
-import {useRouter} from 'vue-router'
+import {onActivated, ref} from "vue";
+import {useRoute, useRouter} from 'vue-router'
+import mainApi from "~api/expense/finReimburse";
+import projectApi from "~api/project/project-list";
 import {getTokenHeader} from "~src/api/request/header";
+import {getArrValue} from "js-fast-way";
 
 const router = useRouter()
+const useRoutes = useRoute()
+
+const dataId = ref(useRoutes?.query?.id ?? '')
+
+onActivated(() => {
+    dataId.value = useRoutes?.query?.id ?? ''
+    getApi()
+})
+
+const getApi = () => {
+    getProjectData()
+    if (dataId.value > 0) {
+        getDetailsData()
+    }
+}
+
+//项目类型
+const projectData = ref([])
+const getProjectData = async () => {
+    const {error, code, data} = await projectApi.getProjectList({
+        current: 1,
+        size: 1000,
+    })
+    //判断状态
+    if (!error && code === 200) {
+        projectData.value = getArrValue(data?.records)
+    } else {
+        projectData.value = []
+    }
+}
+
+//获取详情数据
+const detailsArr = ref([{}])
+const getDetailsData = async () => {
+    const {error, code, data} = await mainApi.detail({
+        id: dataId.value
+    })
+    //判断状态
+    console.log(data)
+    if (!error && code === 200) {
+
+    } else {
+
+    }
+}
+
 
 //上传配置
 const HcUploadFileRef = ref(null)