| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 |
- <template>
- <basic-container>
- <avue-crud :option="option"
- :table-loading="loading"
- :data="data"
- :page.sync="page"
- :permission="permissionList"
- :before-open="beforeOpen"
- v-model="form"
- ref="crud"
- @row-update="rowUpdate"
- @row-save="rowSave"
- @row-del="rowDel"
- @search-change="searchChange"
- @search-reset="searchReset"
- @selection-change="selectionChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad">
- <template slot-scope="{type,size}" slot="createTimeSearch">
- <el-radio-group v-model="query.createTime" :size="size" style="float: left">
- <el-radio-button @click="searchStateChange" :label="-1">全部</el-radio-button>
- <el-radio-button @click="searchStateChange" :label="1">今天</el-radio-button>
- <el-radio-button @click="searchStateChange" :label="2">昨天</el-radio-button>
- <el-radio-button @click="searchStateChange" :label="3">最近七天</el-radio-button>
- <el-radio-button @click="searchStateChange" :label="4">最近30天</el-radio-button>
- <el-radio-button @click="searchStateChange" :label="5">本月</el-radio-button>
- <el-radio-button @click="searchStateChange" :label="6">本年</el-radio-button>
- </el-radio-group>
- <avue-date v-model="query.createTimeRange" type="datetimerange" format="yyyy年MM月dd日 hh:mm:ss"
- value-format="yyyy-MM-dd hh:mm:ss" placeholder="请选择日期"
- :size="size"
- @change="searchStateChange"
- style="width: 280px;margin-left:5px;float: left"
- range-separator="-"
- start-placeholder="开始日期"
- end-placeholder="结束日期"></avue-date>
- </template>
- <template slot-scope="{type,size}" slot="payStatusSearch">
- <el-radio-group v-model="query.payStatus" :size="size" @change="searchStateChange">
- <el-radio-button :label="select.value" v-for="(select,index) in option.column.find(ele=>{
- return ele.prop==='payStatus';
- }).dicData" :key="index">{{ select.label }}</el-radio-button>
- </el-radio-group>
- </template>
- <template slot-scope="{type,size}" slot="typeSearch">
- <el-radio-group v-model="query.type" :size="size" @change="searchStateChange">
- <el-radio-button :label="select.value" v-for="(select,index) in option.column.find(ele=>{
- return ele.prop==='type';
- }).dicData" :key="index">{{ select.label }}</el-radio-button>
- </el-radio-group>
- </template>
- <template slot-scope="{type,size}" slot="keySearch">
- <el-input type="text" placeholder="订单ID" v-model="query.key" :size="size"
- style="width: 300px;margin: 1px 5px 1px 0;">
- <el-button type="primary" :size="size" icon="el-icon-search" slot="append"
- @click="searchStateChange"></el-button>
- </el-input>
- <el-button type="primary" :size="size" icon="el-icon-top" @click="generateListAndDownload">生成列表</el-button>
- <!-- <el-button type="primary" :size="size">导出已生成列表</el-button>-->
- </template>
- <template slot="menuLeft">
- <IconFontComp :option="censusOption"></IconFontComp>
- </template>
- </avue-crud>
- </basic-container>
- </template>
- <script>
- import {getList, generateList, getDetail, censusPrice, add, update, remove} from "@/api/ldt_bills/balancebills";
- import IconFontComp from "./comps/iconfont";
- import {mapGetters} from "vuex";
- import moment from "moment";
- import FileUtil from "@/util/fileUtil";
- export default {
- components:{IconFontComp},
- data() {
- return {
- form: {},
- query: {
- createTime: -1,
- createTimeRange: [],
- type: -1,
- payStatus: -1,
- },
- loading: true,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- selectionList: [],
- option: {
- height:'auto',
- calcHeight: 30,
- tip: false,
- searchShow: true,
- searchMenuSpan: 6,
- searchSpan:4,
- border: true,
- index: true,
- addBtn: false,
- delBtn: false,
- editBtn: false,
- viewBtn: true,
- selection: true,
- searchBtn: false,
- emptyBtn: false,
- searchSize: "mini",
- dialogClickModal: false,
- column: [
- {
- label: "交易金额",
- prop: "price",
- rules: [{
- required: true,
- message: "请输入交易金额",
- trigger: "blur"
- }]
- },
- {
- label: "交易总金额",
- prop: "totalPrice",
- rules: [{
- required: true,
- message: "请输入交易总金额",
- trigger: "blur"
- }]
- },
- {
- label: "付款方ID",
- prop: "payId",
- hide: true,
- rules: [{
- required: true,
- message: "请输入交易账户--付款方",
- trigger: "blur"
- }]
- },
- {
- label: "付款方",
- prop: "payerName",
- rules: [{
- required: true,
- message: "请输入付款方",
- trigger: "blur"
- }]
- },
- {
- label: "交易方式",
- prop: "title",
- search: false,
- rules: [{
- required: true,
- message: "请输入交易方式",
- trigger: "blur"
- }]
- },
- {
- label: "手续费",
- prop: "fee",
- rules: [{
- required: true,
- message: "请输入手续费",
- trigger: "blur"
- }]
- },
- {
- label: "收款方ID",
- prop: "receiveId",
- hide: true,
- rules: [{
- required: true,
- message: "请输入交易账户--收款方",
- trigger: "blur"
- }]
- },
- {
- label: "收款方",
- prop: "receiverName",
- rules: [{
- required: true,
- message: "请输入收款方",
- trigger: "blur"
- }]
- },
- {
- label: "交易状态",
- prop: "payStatus",
- search: true,
- searchslot: true,
- searchSpan: 24,
- searchOrder: 3,
- dicData:[{
- label:"全部",
- value: -1
- },{
- label:"待付款",
- value:"待付款"
- },{
- label:"付款成功",
- value:"付款成功"
- },{
- label:"已完结",
- value:"已完结"
- },{
- label:"取消付款",
- value:"取消付款"
- }],
- rules: [{
- required: true,
- message: "请输入交易状态",
- trigger: "blur"
- }]
- },
- {
- label: "交易类型",
- prop: "type",
- search: true,
- searchslot: true,
- searchSpan: 24,
- searchOrder: 4,
- dicData:[{
- label:"全部",
- value: -1
- },{
- label:"用户付款",
- value:"PAY_CONSUMER"
- },{
- label:"商场交易",
- value:"MALL_SEND"
- },{
- label:"商户交易",
- value:"SHOP_SEND"
- }],
- rules: [{
- required: true,
- message: "请输入交易类型",
- trigger: "blur"
- }]
- },
- {
- label: "创建时间",
- prop: "createTime",
- type: "datetime",
- format: "yyyy-MM-dd hh:mm:ss",
- valueFormat: "yyyy-MM-dd hh:mm:ss",
- searchRange:true,
- addDisplay: false,
- editDisplay: false,
- search: true,
- searchSpan: 24,
- searchOrder: 0,
- searchslot: true,
- rules: [{
- required: true,
- message: "请输入通知时间",
- trigger: "blur"
- }]
- },
- {
- label: "关键字",
- prop: "key",
- hide: true,
- search: true,
- searchslot: true,
- searchOrder: 5,
- searchSpan: 24,
- editDisplay: false,
- },
- {
- label: "交易说明",
- prop: "billDesc",
- rules: [{
- required: true,
- message: "请输入交易说明",
- trigger: "blur"
- }]
- }
- ]
- },
- data: [],
- censusOption: {
- span: ()=>24/this.censusOption.data.length,
- data: [
- {
- title: '用户付款',
- prop: ["PAY_CONSUMER","WECHAT_PAY"],
- count: 0,
- decimals: 2,
- icon: 'el-icon-s-custom',
- color: '0, 167, 208',
- },
- {
- title: '商场交易',
- prop: "MALL_SEND",
- count: 0,
- decimals: 2,
- icon: 'el-icon-paperclip',
- color: '27, 201, 142',
- },
- {
- title: '商户交易',
- prop: "SHOP_SEND",
- count: 0,
- decimals: 2,
- icon: 'el-icon-s-shop',
- color: '230, 71, 88',
- }
- ]
- }
- };
- },
- computed: {
- ...mapGetters(["permission"]),
- permissionList() {
- return {
- addBtn: this.vaildData(this.permission.balancebills_add, false),
- viewBtn: this.vaildData(this.permission.balancebills_view, false),
- delBtn: this.vaildData(this.permission.balancebills_delete, false),
- editBtn: this.vaildData(this.permission.balancebills_edit, false)
- };
- },
- ids() {
- let ids = [];
- this.selectionList.forEach(ele => {
- ids.push(ele.id);
- });
- return ids.join(",");
- }
- },
- watch: {
- //监听创建时间变化
- "query.createTime": {
- handler(value) {
- //防止重复调用
- if (value !== undefined) {
- this.query.createTimeRange = [];
- switch (value) {
- case -1:
- this.query.createTimeStart = undefined;
- this.query.createTimeEnd = undefined;
- break;
- case 1: //今天
- this.query.createTimeStart = moment().format("yyyy-MM-DD 00:00:00");
- this.query.createTimeEnd = moment().format("yyyy-MM-DD HH:mm:ss");
- break;
- case 2: //昨天
- this.query.createTimeStart = moment().subtract(1, 'days').format("yyyy-MM-DD 00:00:00");
- this.query.createTimeEnd = moment().subtract(1, 'days').format("yyyy-MM-DD 23:59:59");
- break;
- case 3: //近7天
- this.query.createTimeStart = moment().subtract(7, 'days').format("yyyy-MM-DD HH:mm:ss");
- this.query.createTimeEnd = moment().format("yyyy-MM-DD HH:mm:ss");
- break;
- case 4: //近30天
- this.query.createTimeStart = moment().subtract(30, 'days').format("yyyy-MM-DD HH:mm:ss");
- this.query.createTimeEnd = moment().format("yyyy-MM-DD HH:mm:ss");
- break;
- case 5: //本月
- this.query.createTimeStart = moment().format("yyyy-MM-01 00:00:00");
- this.query.createTimeEnd = moment().format(`yyyy-MM-DD HH:mm:ss`);
- break;
- case 6: //本年
- this.query.createTimeStart = moment().format("yyyy-01-01 00:00:00");
- this.query.createTimeEnd = moment().format(`yyyy-MM-DD HH:mm:ss`);
- break;
- default:
- break;
- }
- }
- }
- },
- //监听创建时间变化
- "query.createTimeRange": {
- handler(value) {
- //防止重复调用
- if (value.length === 2) {
- this.query.createTimeStart = value[0];
- this.query.createTimeEnd = value[1];
- this.query.createTime = undefined;
- }
- }
- },
- },
- created() {
- this.getCensusPrice();
- },
- methods: {
- rowSave(row, done, loading) {
- add(row).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- }, error => {
- loading();
- window.console.log(error);
- });
- },
- rowUpdate(row, index, done, loading) {
- update(row).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- }, error => {
- loading();
- console.log(error);
- });
- },
- rowDel(row) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(row.id);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- });
- },
- handleDelete() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(this.ids);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$refs.crud.toggleSelection();
- });
- },
- beforeOpen(done, type) {
- if (["edit", "view"].includes(type)) {
- getDetail(this.form.id).then(res => {
- this.form = res.data.data;
- });
- }
- done();
- },
- searchReset() {
- this.query = {};
- this.onLoad(this.page);
- },
- searchChange(params, done) {
- this.query = params;
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- selectionClear() {
- this.selectionList = [];
- this.$refs.crud.toggleSelection();
- },
- currentChange(currentPage){
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize){
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- this.onLoad(this.page, this.query);
- },
- onLoad(page, params = {}) {
- let values = {};
- for (const item in params) {
- if (params[item] !== undefined && params[item] !== -1) {
- values[item] = params[item];
- }
- }
- values.createTime = null;
- values.createTimeRange = null;
- this.loading = true;
- getList(page.currentPage, page.pageSize, values).then(res => {
- const data = res.data.data;
- this.page.total = data.total;
- this.data = data.records;
- this.loading = false;
- this.selectionClear();
- });
- },
- getCensusPrice() {
- censusPrice().then(res => {
- res.data.data.forEach(ele => {
- const find = this.censusOption.data.find(ele2=>{
- return ele2.prop.indexOf(ele.type)!==-1;
- });
- if(find && ele.price){
- find.count = find.count + parseFloat(ele.price);
- }
- });
- });
- },
- //搜索状态改变
- searchStateChange() {
- setTimeout(() => {
- this.onLoad(this.page, this.query);
- }, 100);
- },
- //生成列表并到处
- generateListAndDownload() {
- const newQuery = {};
- for (const item in this.query) {
- if (this.query[item] !== undefined && this.query[item] !== -1) {
- newQuery[item] = this.query[item];
- }
- }
- newQuery.createTime = null;
- newQuery.createTimeRange = null;
- //获取列表键值对
- newQuery.keyValue = {};
- this.option.column.forEach(ele=>{
- newQuery.keyValue[ele.prop] = ele.label;
- });
- newQuery.keyValue = JSON.stringify(newQuery.keyValue);
- this.loading = true;
- //生成列表
- generateList(this.page.currentPage, this.page.pageSize, newQuery).then(res => {
- FileUtil.download(res.data,{
- type: "application/vnd.ms-excel"
- },`生成余额账单-${moment().format("yyyy-MM-DD HH:mm:ss")}.xls`);
- }).finally(()=>{
- this.loading = false;
- });
- },
- }
- };
- </script>
- <style>
- </style>
|