|
@@ -2,15 +2,28 @@
|
|
|
<HcCard>
|
|
|
<template #header>
|
|
|
<div class="w-72">
|
|
|
- <el-select v-model="searchForm.projectType" block clearable placeholder="项目名称" size="large">
|
|
|
- <el-option v-for="item in projectType" :label="item.name" :value="item.key"/>
|
|
|
+ <el-select v-model="searchForm.projectId" block clearable placeholder="项目名称" size="large">
|
|
|
+ <el-option v-for="item in projectType" :label="item.projectName" :value="item.projectId"/>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
+ <div class="ml-4">
|
|
|
+ <el-button type="primary" @click="searchClick" size="large">
|
|
|
+ <HcIcon name="search-2"/>
|
|
|
+ <span>搜索</span>
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <div class="ml-2">
|
|
|
+ <el-button size="large" @click="resetClick">
|
|
|
+ <HcIcon name="close-circle"/>
|
|
|
+ <span>重置</span>
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <el-alert title="上传接口报错、查看接口返回有误、分页接口缺少状态值返回,用于判断上传条件" type="error" show-icon />
|
|
|
</template>
|
|
|
<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"/>
|
|
@@ -19,13 +32,10 @@
|
|
|
</template>
|
|
|
|
|
|
<HcTable :column="tableColumn" :datas="tableData" :loading="tableLoading">
|
|
|
- <template #key="{row}">
|
|
|
- <span class="text-blue" @click="rowNameTap(row)">{{row.key}}</span>
|
|
|
- </template>
|
|
|
<template #action="{row,index}">
|
|
|
- <el-button size="small" type="success">上传</el-button>
|
|
|
- <el-button size="small" type="primary">查看</el-button>
|
|
|
- <el-button size="small" type="danger">删除</el-button>
|
|
|
+ <el-button size="small" type="success" @click="invoiceItemUpload(row)">上传</el-button>
|
|
|
+ <el-button size="small" type="primary" @click="invoiceItemPdf(row)">查看</el-button>
|
|
|
+ <el-button size="small" type="danger" @confirm="rowCancel(row)">删除</el-button>
|
|
|
</template>
|
|
|
</HcTable>
|
|
|
|
|
@@ -34,39 +44,69 @@
|
|
|
</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>
|
|
|
</HcDialog>
|
|
|
+
|
|
|
+ <!--上传控件-->
|
|
|
+ <HcUploadFile ref="HcUploadFileRef"
|
|
|
+ :options="uploadFileOptions"
|
|
|
+ :echoParams="uploadEchoParams"
|
|
|
+ @success="HcUploadFileSuccess"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!--发票PDF-->
|
|
|
+ <HcDialog isToBody isTable bgColor="#ffffff" widths="62rem" :footer="false" :show="pdfModal" title="发票PDF" @close="pdfCloseClick">
|
|
|
+ <HcPdf src="http://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230504/911982ba85e66cfa58fb02d5a738bb2b.pdf"/>
|
|
|
+ </HcDialog>
|
|
|
</HcCard>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import {ref} from "vue";
|
|
|
+import {onActivated, ref} from "vue";
|
|
|
import {useRouter} from 'vue-router'
|
|
|
+import mainApi from "~api/expense/invoice";
|
|
|
+import {getProjectList} from "~api/other";
|
|
|
+import {getArrValue} from "js-fast-way";
|
|
|
+import {delMessage} from "~uti/tools";
|
|
|
+import {getTokenHeader} from "~src/api/request/header";
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
+onActivated(() => {
|
|
|
+ getApi()
|
|
|
+})
|
|
|
+
|
|
|
+const getApi = () => {
|
|
|
+ getProjectData()
|
|
|
+ getTableData()
|
|
|
+ getDraftNum()
|
|
|
+}
|
|
|
+
|
|
|
//项目类型
|
|
|
-const projectType = ref([
|
|
|
- {name: '二级路', key: '二级路'},
|
|
|
- {name: '国道', key: '国道'},
|
|
|
- {name: '水利水电', key: '水利水电'},
|
|
|
- {name: '市政', key: '市政'},
|
|
|
-])
|
|
|
+const projectType = ref([])
|
|
|
+const getProjectData = async () => {
|
|
|
+ const {error, code, data} = await getProjectList()
|
|
|
+ //判断状态
|
|
|
+ if (!error && code === 200) {
|
|
|
+ projectType.value = getArrValue(data)
|
|
|
+ } else {
|
|
|
+ projectType.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
//搜索表单
|
|
|
-const searchForm = ref({
|
|
|
- projectType: null, user: null, project: null,
|
|
|
- current: 1, size: 20, total: 0
|
|
|
-})
|
|
|
+const searchForm = ref({projectId: null, current: 1, size: 20, total: 0})
|
|
|
|
|
|
//搜索
|
|
|
const searchClick = () => {
|
|
@@ -89,59 +129,170 @@ const pageChange = ({current, size}) => {
|
|
|
//获取数据
|
|
|
const tableLoading = ref(false)
|
|
|
const tableColumn = [
|
|
|
- {key: 'key1', name: '申请时间', width: '160'},
|
|
|
- {key: 'key2', name: '关联项目', minWidth: '220'},
|
|
|
- {key: 'key3', name: '开票内容', minWidth: '160'},
|
|
|
- {key: 'key4', name: '开票金额', width: '160', align: 'center'},
|
|
|
- {key: 'key5', name: '发票类型', width: '160', align: 'center'},
|
|
|
- {key: 'key6', name: '开票人', width: '160', align: 'center'},
|
|
|
- {key: 'key7', name: '审批结果', width: '160', align: 'center'},
|
|
|
- {key: 'key8', name: '审批状态', width: '140', align: 'center'},
|
|
|
- {key: 'key9', name: '报销时间', width: '160', align: 'center'},
|
|
|
- {key: 'key10', name: '创建人', width: '140', align: 'center'},
|
|
|
- {key: 'key11', name: '创建时间', width: '160', align: 'center'},
|
|
|
+ {key: 'invoiceDate', name: '申请时间', width: '160'},
|
|
|
+ {key: 'projectName', name: '关联项目', minWidth: '220'},
|
|
|
+ {key: 'invoiceContentType', name: '开票内容', minWidth: '160'},
|
|
|
+ {key: 'invoiceMoney', name: '开票金额', width: '160', align: 'center'},
|
|
|
+ {key: 'invoiceTypeName', name: '发票类型', width: '160', align: 'center'},
|
|
|
+ {key: 'invoiceUserName', name: '开票人', width: '160', align: 'center'},
|
|
|
+ {key: 'approvalResultName', name: '审批结果', width: '160', align: 'center'},
|
|
|
+ {key: 'approvalStatusName', name: '审批状态', width: '140', align: 'center'},
|
|
|
+ {key: 'createUser', name: '创建人', width: '140', align: 'center'},
|
|
|
+ {key: 'createTime', name: '创建时间', width: '160', align: 'center'},
|
|
|
{key: 'action', name: '操作', width: '220', align: 'center', fixed: 'right'},
|
|
|
]
|
|
|
-const tableData = ref([
|
|
|
- {id: 1, key: 'YS-01', key1: 'xxxx', key2: 'xxxx', key3: '65632', key4: '35654', key5: '12312', key6: 'xxxx'},
|
|
|
- {id: 2, key: 'YS-01', key1: 'xxxx', key2: 'xxxx', key3: '65632', key4: '35654', key5: '12312', key6: 'xxxx'},
|
|
|
- {id: 3, key: 'YS-01', key1: 'xxxx', key2: 'xxxx', key3: '65632', key4: '35654', key5: '12312', key6: 'xxxx'},
|
|
|
- {id: 4, key: 'YS-01', key1: 'xxxx', key2: 'xxxx', key3: '65632', key4: '35654', key5: '12312', key6: 'xxxx'},
|
|
|
- {id: 5, key: 'YS-01', key1: 'xxxx', key2: 'xxxx', key3: '65632', key4: '35654', key5: '12312', key6: 'xxxx'},
|
|
|
- {id: 6, key: 'YS-01', key1: 'xxxx', key2: 'xxxx', key3: '65632', key4: '35654', key5: '12312', key6: 'xxxx'},
|
|
|
-])
|
|
|
+const tableData = ref([])
|
|
|
+const getTableData = async () => {
|
|
|
+ tableLoading.value = true
|
|
|
+ const {error, code, data} = await mainApi.page(searchForm.value)
|
|
|
+ //判断状态
|
|
|
+ tableLoading.value = false
|
|
|
+ if (!error && code === 200) {
|
|
|
+ tableData.value = getArrValue(data['records'])
|
|
|
+ searchForm.value.total = data['total'] || 0
|
|
|
+ } else {
|
|
|
+ tableData.value = []
|
|
|
+ searchForm.value.total = 0
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//新增预算
|
|
|
+const addRowClick = () => {
|
|
|
+ router.push({
|
|
|
+ name: 'expense-invoice-billing'
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
-const getTableData = () => {
|
|
|
+//上传配置
|
|
|
+const HcUploadFileRef = ref(null)
|
|
|
+const uploadEchoParams = ref({})
|
|
|
+const uploadFileOptions = {
|
|
|
+ headers: getTokenHeader(),
|
|
|
+ multiple: false,
|
|
|
+}
|
|
|
|
|
|
+//电子发票
|
|
|
+const invoiceItemUpload = ({id}) => {
|
|
|
+ uploadEchoParams.value = {rowId: id}
|
|
|
+ HcUploadFileRef.value?.selectFile();
|
|
|
}
|
|
|
|
|
|
-//预览
|
|
|
-const rowNameTap = (row) => {
|
|
|
+//上传完成
|
|
|
+const HcUploadFileSuccess = async ({echoParams, resData}) => {
|
|
|
+ const {rowId} = echoParams, {pdfUrl} = resData
|
|
|
+ if (rowId && pdfUrl) {
|
|
|
+ const {error, code, msg} = await mainApi.upload({
|
|
|
+ id: rowId,
|
|
|
+ pdfUrl: pdfUrl
|
|
|
+ })
|
|
|
+ //判断状态
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message?.success(msg)
|
|
|
+ getTableData().then()
|
|
|
+ } else {
|
|
|
+ window.$message?.error(msg)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ window.$message?.error('上传发票失败了')
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+//查看发票
|
|
|
+const pdfModal = ref(false)
|
|
|
+const invoicePdfUrl = ref('')
|
|
|
+const invoiceItemPdf = async (row) => {
|
|
|
+ const {error, code, data, msg} = await mainApi.pdf({
|
|
|
+ id: row.id
|
|
|
+ })
|
|
|
+ //判断状态
|
|
|
+ if (!error && code === 200) {
|
|
|
+ console.log(data)
|
|
|
+ invoicePdfUrl.value = data
|
|
|
+ pdfModal.value = true
|
|
|
+ } else {
|
|
|
+ invoicePdfUrl.value = ''
|
|
|
+ window.$message?.error(msg)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-//新增预算
|
|
|
-const addRowClick = () => {
|
|
|
- router.push({
|
|
|
- name: 'expense-invoice-billing'
|
|
|
+const pdfCloseClick = () => {
|
|
|
+ invoicePdfUrl.value = ''
|
|
|
+ pdfModal.value = false
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//删除
|
|
|
+const rowCancel = (row) => {
|
|
|
+ delMessage(async () => {
|
|
|
+ const {error, code, msg} = await mainApi.cancel({
|
|
|
+ id: row.id
|
|
|
+ })
|
|
|
+ //判断状态
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message?.success(msg)
|
|
|
+ getTableData().then()
|
|
|
+ } else {
|
|
|
+ window.$message?.error(msg)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
//草稿箱
|
|
|
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}) => {
|
|
|
+ draftsModal.value = false
|
|
|
+ router.push({
|
|
|
+ name: 'expense-invoice-billing',
|
|
|
+ query: {id: id}
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
+//删除草稿
|
|
|
+const delDraftClick = ({id}) => {
|
|
|
+ delMessage(async () => {
|
|
|
+ const {error, code, msg} = await mainApi.remove({
|
|
|
+ id: id
|
|
|
+ })
|
|
|
+ //判断状态
|
|
|
+ if (!error && code === 200) {
|
|
|
+ window.$message?.success(msg)
|
|
|
+ getDraftNum().then()
|
|
|
+ } else {
|
|
|
+ window.$message?.error(msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|