|
@@ -2,154 +2,101 @@
|
|
|
<div id="card-1">
|
|
|
<el-row>
|
|
|
<el-col :span="24" class="main">
|
|
|
- <el-col :span="24" class="one">
|
|
|
- <search-1 :form="searchForm" @onSubmit="search" @toReset="toClose"></search-1>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" v-if="afterSaleList.length != '0' || orderList.length != '0'">
|
|
|
- <el-button type="primary" @click="toFile()">对账</el-button>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="two">
|
|
|
- 净销售额:<span>{{ info.total || '0' }}</span> 元
|
|
|
- </el-col>
|
|
|
- <el-col :span="24">
|
|
|
- <el-tabs type="border-card">
|
|
|
- <el-tab-pane label="订单">
|
|
|
- <data-table :fields="orderfields" @query="search" :data="orderList" :usePage="false" rowKey="key"> </data-table>
|
|
|
- </el-tab-pane>
|
|
|
- <el-tab-pane label="售后单">
|
|
|
- <data-table :fields="afterSalefields" @query="search" :data="afterSaleList" :usePage="false"> </data-table>
|
|
|
- </el-tab-pane>
|
|
|
- </el-tabs>
|
|
|
- </el-col>
|
|
|
+ <span v-if="view === 'list'">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <el-col :span="24">
|
|
|
+ <p>
|
|
|
+ 账户余额:<span>{{ info.total }}</span>
|
|
|
+ </p>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-button type="success" @click="toCash()"> 提现 </el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <data-table :fields="fields" @query="search" :data="list" :total="total"> </data-table>
|
|
|
+ </el-col>
|
|
|
+ </span>
|
|
|
+ <detail v-if="view === 'info'" :canGet="canGet" @toBack="toBack"></detail>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
-
|
|
|
<script>
|
|
|
const _ = require('lodash');
|
|
|
-import FileSaver from 'file-saver';
|
|
|
-const ExcelJS = require('exceljs');
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
-const { mapActions } = createNamespacedHelpers('getBill');
|
|
|
-const { mapActions: outBill } = createNamespacedHelpers('outBill');
|
|
|
+const { mapActions } = createNamespacedHelpers('shopInBill');
|
|
|
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
|
|
|
export default {
|
|
|
name: 'card-1',
|
|
|
props: {},
|
|
|
- components: { search1: () => import('./parts/search-1.vue') },
|
|
|
+ components: {
|
|
|
+ detail: () => import('./detail.vue'),
|
|
|
+ },
|
|
|
data: function () {
|
|
|
return {
|
|
|
- searchForm: {},
|
|
|
+ view: 'list',
|
|
|
+ // 账户余额
|
|
|
info: {},
|
|
|
- afterSaleList: [],
|
|
|
- orderList: [],
|
|
|
- orderfields: [
|
|
|
- { label: '订单号', model: 'no', showTip: false },
|
|
|
- { label: '订单类型', model: 'type' },
|
|
|
- { label: '支付时间', model: 'pay_time' },
|
|
|
- { label: '商品', model: 'goods', showTip: false },
|
|
|
- { label: '规格', model: 'spec', showTip: false },
|
|
|
- { label: '购买数量', model: 'buy_num' },
|
|
|
- { label: '单价', model: 'price' },
|
|
|
- { label: '优惠金额', model: 'discount' },
|
|
|
- { label: '运费', model: 'freight' },
|
|
|
- { label: '总价', model: 'total' },
|
|
|
+ // 账户流水
|
|
|
+ list: [],
|
|
|
+ // 来源列表
|
|
|
+ sourceList: [],
|
|
|
+ fields: [
|
|
|
+ {
|
|
|
+ label: '来源',
|
|
|
+ model: 'source',
|
|
|
+ format: (i) => {
|
|
|
+ let data = this.sourceList.find((f) => f.value == i);
|
|
|
+ if (data) return data.label;
|
|
|
+ else return '暂无';
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { label: '金额', model: 'receipts' },
|
|
|
+ { label: '余额', model: 'total' },
|
|
|
+ { label: '抽成比例(%)', model: 'cut' },
|
|
|
+ { label: '时间', model: 'time' },
|
|
|
],
|
|
|
- afterSalefields: [
|
|
|
- { label: '订单号', model: 'no', showTip: false },
|
|
|
- { label: '商品', model: 'goods', showTip: false },
|
|
|
- { label: '规格', model: 'spec', showTip: false },
|
|
|
- { label: '退款时间', model: 'end_time' },
|
|
|
- { label: '退款金额', model: 'money' },
|
|
|
- ],
|
|
|
- // 多选值
|
|
|
- selected: [],
|
|
|
+ canGet: 0,
|
|
|
+ total: 0,
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
|
- await this.search();
|
|
|
await this.searchOther();
|
|
|
+ await this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
|
|
|
- ...outBill({ outQuery: 'query', outCreate: 'create' }),
|
|
|
+ ...mapActions(['query', 'fetch', 'create', 'update', 'delete', 'bill']),
|
|
|
+ ...dictData({ dictQuery: 'query' }),
|
|
|
// 查询
|
|
|
async search({ skip = 0, limit = this.$limit, ...info } = {}) {
|
|
|
- let condition = _.cloneDeep(this.searchForm);
|
|
|
- if (condition.buy_time) {
|
|
|
- condition[`start`] = _.head(condition.buy_time);
|
|
|
- condition[`end`] = _.last(condition.buy_time);
|
|
|
- delete condition.buy_time;
|
|
|
- let res = await this.query({ skip, limit, ...condition, ...info, shop: this.user.shop.id });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- const orderList = res.data.orderList.map((i) => ({ ...i, key: `${i.no}-${i.spec_id}` }));
|
|
|
- this.$set(this, 'info', res.data);
|
|
|
- this.$set(this, 'afterSaleList', res.data.afterSaleList);
|
|
|
- this.$set(this, 'orderList', res.data.orderList);
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- toClose() {
|
|
|
- this.searchForm = {};
|
|
|
- this.search();
|
|
|
- },
|
|
|
- // 导出清单
|
|
|
- toFile() {
|
|
|
- const workbook = new ExcelJS.Workbook();
|
|
|
- let orderList = this.orderList;
|
|
|
- const worksheet_one = workbook.addWorksheet('订单');
|
|
|
- let data_one = [['订单号', '订单类型', '支付时间', '商品', '规格', '购买数量', '单价', '优惠金额', '总价']];
|
|
|
- for (const p1 of orderList) {
|
|
|
- let p2 = [[p1.no, p1.type, p1.pay_time, p1.goods, p1.spec, p1.buy_num, p1.price, p1.discount, p1.total]];
|
|
|
- data_one.push(...p2);
|
|
|
+ let arr = await this.bill(this.user.shop.id);
|
|
|
+ if (this.$checkRes(arr)) {
|
|
|
+ this.$set(this, `info`, arr.data);
|
|
|
}
|
|
|
- for (const val of data_one) {
|
|
|
- worksheet_one.addRow(val);
|
|
|
+ let res = await this.query({ skip, limit, ...info, shop: this.user.shop._id });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
}
|
|
|
- let afterSaleList = this.afterSaleList;
|
|
|
- const worksheet_two = workbook.addWorksheet('售后单');
|
|
|
- let data_two = [['订单号', '商品', '规格', '退款时间', '退款金额']];
|
|
|
- for (const p1 of afterSaleList) {
|
|
|
- let p2 = [[p1.no, p1.goods, p1.spec, p1.end_time, p1.money]];
|
|
|
- data_two.push(...p2);
|
|
|
- }
|
|
|
- for (const val of data_two) {
|
|
|
- worksheet_two.addRow(val);
|
|
|
+ },
|
|
|
+ toCash() {
|
|
|
+ this.$set(this, `canGet`, this.info.canGet);
|
|
|
+ if (this.info.canGet > 0) {
|
|
|
+ this.$set(this, `view`, 'info');
|
|
|
+ } else {
|
|
|
+ this.$message({ type: `warning`, message: `您没有可提现金额` });
|
|
|
}
|
|
|
- worksheet_one.columns.forEach(function (column, i) {
|
|
|
- column.width = 20;
|
|
|
- });
|
|
|
- worksheet_two.columns.forEach(function (column, i) {
|
|
|
- column.width = 20;
|
|
|
- });
|
|
|
- workbook.xlsx.writeBuffer().then((buffer) => {
|
|
|
- FileSaver.saveAs(
|
|
|
- new Blob([buffer], {
|
|
|
- type: 'application/octet-stream',
|
|
|
- }),
|
|
|
- `对账单.xlsx`
|
|
|
- );
|
|
|
- });
|
|
|
- this.$confirm('是否确认对账?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- }).then(async () => {
|
|
|
- let order = [];
|
|
|
- for (const p1 of this.orderList) {
|
|
|
- order.push(p1._id);
|
|
|
- }
|
|
|
- let afterSale = [];
|
|
|
- for (const p1 of this.afterSaleList) {
|
|
|
- afterSale.push(p1._id);
|
|
|
- }
|
|
|
- let res;
|
|
|
- res = await this.outCreate({ order, afterSale });
|
|
|
- if (this.$checkRes(res)) this.$message({ type: `success`, message: `对账成功` });
|
|
|
- });
|
|
|
+ },
|
|
|
+ // 执行返回
|
|
|
+ toBack() {
|
|
|
+ this.view = 'list';
|
|
|
},
|
|
|
// 查询其他信息
|
|
|
- async searchOther() {},
|
|
|
+ async searchOther() {
|
|
|
+ let res = await this.dictQuery({ code: 'cashBack_source' });
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `sourceList`, res.data);
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
@@ -168,13 +115,27 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
+.main {
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
.one {
|
|
|
margin: 0 0 10px 0;
|
|
|
+ p {
|
|
|
+ font-size: 24px;
|
|
|
+ font-weight: 700;
|
|
|
+ span {
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
.two {
|
|
|
span {
|
|
|
color: red;
|
|
|
}
|
|
|
+ .sp1 {
|
|
|
+ font-size: 18px;
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
}
|
|
|
.title {
|
|
|
text-align: center;
|