|
@@ -1,10 +1,41 @@
|
|
|
<template>
|
|
|
<div id="index">
|
|
|
- <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @view="toView" @sign="toSign">
|
|
|
- <template slot="selfbtn">
|
|
|
- <el-button type="primary" size="small" @click="toAdd()">添加</el-button>
|
|
|
- </template>
|
|
|
- </data-table>
|
|
|
+ <el-row v-if="show_type == '1'">
|
|
|
+ <data-table
|
|
|
+ :fields="fields"
|
|
|
+ :opera="opera"
|
|
|
+ @query="search"
|
|
|
+ :data="list"
|
|
|
+ :total="total"
|
|
|
+ @view="toView"
|
|
|
+ :select="true"
|
|
|
+ :selected="selected"
|
|
|
+ @handleSelect="handleSelect"
|
|
|
+ >
|
|
|
+ <template slot="selfbtn">
|
|
|
+ <el-button type="primary" size="small" @click="toExport()">导出采购单</el-button>
|
|
|
+ <el-button type="primary" size="small" @click="toAdd()">添加</el-button>
|
|
|
+ </template>
|
|
|
+ <template #options="{ item }">
|
|
|
+ <template v-if="item.prop === 'status'">
|
|
|
+ <el-option v-for="(item, index) in statusList" :key="index" :label="item.name" :value="item.num"></el-option>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </data-table>
|
|
|
+ </el-row>
|
|
|
+ <el-row v-else-if="show_type == '2'">
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
+ <el-button type="primary" size="small" @click="back()">返回</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="download()">PDF下载</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="info">
|
|
|
+ <el-col :span="24" class="demo" id="demo">
|
|
|
+ <pdf-1 :selected="selected"></pdf-1>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
<el-dialog :title="dialog.title" :visible.sync="dialog.show" :width="dialog.width" :before-close="toClose" :close-on-click-modal="false">
|
|
|
<info-1 v-if="dialog.type == '1'" :info="info"></info-1>
|
|
|
</el-dialog>
|
|
@@ -12,7 +43,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import htmlToPdf from '@/unit/htmlToPdf.js';
|
|
|
import info1 from './parts/info-1.vue';
|
|
|
+import pdf1 from './parts/pdf-1.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: mapBuy } = createNamespacedHelpers('buy');
|
|
|
export default {
|
|
@@ -20,9 +53,12 @@ export default {
|
|
|
props: {},
|
|
|
components: {
|
|
|
info1,
|
|
|
+ pdf1,
|
|
|
},
|
|
|
data: function () {
|
|
|
return {
|
|
|
+ // 页面展示
|
|
|
+ show_type: '1',
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
fields: [
|
|
@@ -41,19 +77,38 @@ export default {
|
|
|
{
|
|
|
label: '审核状态',
|
|
|
prop: 'status',
|
|
|
+ filter: 'select',
|
|
|
format: (i) => {
|
|
|
return i === '0' ? '待收货' : i === '1' ? '已收货,待付款' : i === '2' ? '付款中,待财务确认' : '财务确认,已付款';
|
|
|
},
|
|
|
},
|
|
|
],
|
|
|
- opera: [
|
|
|
- { label: '查看信息', method: 'view' },
|
|
|
- // { label: '收货', method: 'sign' },
|
|
|
- ],
|
|
|
+ opera: [{ label: '查看信息', method: 'view' }],
|
|
|
// 弹框
|
|
|
dialog: { title: '详细信息', show: false, type: '1', width: '50%' },
|
|
|
// 详细信息
|
|
|
info: {},
|
|
|
+ // 导出
|
|
|
+ selected: [],
|
|
|
+ // 审核状态
|
|
|
+ statusList: [
|
|
|
+ {
|
|
|
+ name: '待收货',
|
|
|
+ num: '0',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '已收货,待付款',
|
|
|
+ num: '1',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '付款中,待财务确认',
|
|
|
+ num: '2',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '财务确认,已付款',
|
|
|
+ num: '3',
|
|
|
+ },
|
|
|
+ ],
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -73,7 +128,7 @@ export default {
|
|
|
},
|
|
|
// 查看信息
|
|
|
toView({ data }) {
|
|
|
- data.type = data.type == '0' ? '统一收' : '申请人';
|
|
|
+ data.type_copy = data.type == '0' ? '统一收' : '申请人';
|
|
|
this.$set(this, `info`, data);
|
|
|
this.dialog = { title: '详细信息', show: true, type: '1', width: '50%' };
|
|
|
},
|
|
@@ -81,22 +136,40 @@ export default {
|
|
|
toClose() {
|
|
|
this.dialog = { title: '详细信息', show: false, type: '1', width: '50%' };
|
|
|
},
|
|
|
- // 收货
|
|
|
- async toSign({ data }) {
|
|
|
- this.$confirm(`您确认提交签收吗?`, '提示', {
|
|
|
+ // 导出
|
|
|
+ handleSelect(data) {
|
|
|
+ for (const val of data) {
|
|
|
+ val.type_copy = val.type == '0' ? '统一收' : '申请人';
|
|
|
+ }
|
|
|
+ this.$set(this, `selected`, data);
|
|
|
+ },
|
|
|
+ // 导出采购单
|
|
|
+ toExport() {
|
|
|
+ if (this.selected.length > 0) {
|
|
|
+ this.show_type = '2';
|
|
|
+ } else {
|
|
|
+ this.$message({ type: `error`, message: `缺少导出必填项` });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 返回
|
|
|
+ back() {
|
|
|
+ this.show_type = '1';
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ // pdf下载
|
|
|
+ async download() {
|
|
|
+ this.$confirm(`您确认提交下载采购审批单吗?`, '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning',
|
|
|
})
|
|
|
.then(async () => {
|
|
|
- data.status = '1';
|
|
|
- let res = await this.update(data);
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$message({ type: `success`, message: `操作成功` });
|
|
|
- this.search();
|
|
|
- } else {
|
|
|
- this.$message({ type: `error`, message: `${res.errmsg}` });
|
|
|
+ for (const val of this.selected) {
|
|
|
+ val.status = '2';
|
|
|
+ let res = await this.update(val);
|
|
|
+ if (this.$checkRes(res, '提交成功', '提交失败'));
|
|
|
}
|
|
|
+ htmlToPdf.downloadPDF(document.querySelector('#demo'), '采购单');
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
},
|
|
@@ -117,4 +190,17 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="less" scoped></style>
|
|
|
+<style lang="less" scoped>
|
|
|
+.two {
|
|
|
+ .btn {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ }
|
|
|
+ .info {
|
|
|
+ padding: 0 200px;
|
|
|
+ .demo {
|
|
|
+ border: 1px solid #000;
|
|
|
+ border-bottom: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|