balancebills.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot-scope="{type,size}" slot="createTimeSearch">
  22. <el-radio-group v-model="query.createTime" :size="size" style="float: left">
  23. <el-radio-button @click="searchStateChange" :label="-1">全部</el-radio-button>
  24. <el-radio-button @click="searchStateChange" :label="1">今天</el-radio-button>
  25. <el-radio-button @click="searchStateChange" :label="2">昨天</el-radio-button>
  26. <el-radio-button @click="searchStateChange" :label="3">最近七天</el-radio-button>
  27. <el-radio-button @click="searchStateChange" :label="4">最近30天</el-radio-button>
  28. <el-radio-button @click="searchStateChange" :label="5">本月</el-radio-button>
  29. <el-radio-button @click="searchStateChange" :label="6">本年</el-radio-button>
  30. </el-radio-group>
  31. <avue-date v-model="query.createTimeRange" type="datetimerange" format="yyyy年MM月dd日 hh:mm:ss"
  32. value-format="yyyy-MM-dd hh:mm:ss" placeholder="请选择日期"
  33. :size="size"
  34. @change="searchStateChange"
  35. style="width: 280px;margin-left:5px;float: left"
  36. range-separator="-"
  37. start-placeholder="开始日期"
  38. end-placeholder="结束日期"></avue-date>
  39. </template>
  40. <template slot-scope="{type,size}" slot="payStatusSearch">
  41. <el-radio-group v-model="query.payStatus" :size="size" @change="searchStateChange">
  42. <el-radio-button :label="select.value" v-for="(select,index) in option.column.find(ele=>{
  43. return ele.prop==='payStatus';
  44. }).dicData" :key="index">{{ select.label }}</el-radio-button>
  45. </el-radio-group>
  46. </template>
  47. <template slot-scope="{type,size}" slot="typeSearch">
  48. <el-radio-group v-model="query.type" :size="size" @change="searchStateChange">
  49. <el-radio-button :label="select.value" v-for="(select,index) in option.column.find(ele=>{
  50. return ele.prop==='type';
  51. }).dicData" :key="index">{{ select.label }}</el-radio-button>
  52. </el-radio-group>
  53. </template>
  54. <template slot-scope="{type,size}" slot="keySearch">
  55. <el-input type="text" placeholder="订单ID" v-model="query.key" :size="size"
  56. style="width: 300px;margin: 1px 5px 1px 0;">
  57. <el-button type="primary" :size="size" icon="el-icon-search" slot="append"
  58. @click="searchStateChange"></el-button>
  59. </el-input>
  60. <el-button type="primary" :size="size" icon="el-icon-top" @click="generateListAndDownload">生成列表</el-button>
  61. <!-- <el-button type="primary" :size="size">导出已生成列表</el-button>-->
  62. </template>
  63. <template slot="menuLeft">
  64. <IconFontComp :option="censusOption"></IconFontComp>
  65. </template>
  66. </avue-crud>
  67. </basic-container>
  68. </template>
  69. <script>
  70. import {getList, generateList, getDetail, censusPrice, add, update, remove} from "@/api/ldt_bills/balancebills";
  71. import IconFontComp from "./comps/iconfont";
  72. import {mapGetters} from "vuex";
  73. import moment from "moment";
  74. import FileUtil from "@/util/fileUtil";
  75. export default {
  76. components:{IconFontComp},
  77. data() {
  78. return {
  79. form: {},
  80. query: {
  81. createTime: -1,
  82. createTimeRange: [],
  83. type: -1,
  84. payStatus: -1,
  85. },
  86. loading: true,
  87. page: {
  88. pageSize: 10,
  89. currentPage: 1,
  90. total: 0
  91. },
  92. selectionList: [],
  93. option: {
  94. height:'auto',
  95. calcHeight: 30,
  96. tip: false,
  97. searchShow: true,
  98. searchMenuSpan: 6,
  99. searchSpan:4,
  100. border: true,
  101. index: true,
  102. addBtn: false,
  103. delBtn: false,
  104. editBtn: false,
  105. viewBtn: true,
  106. selection: true,
  107. searchBtn: false,
  108. emptyBtn: false,
  109. searchSize: "mini",
  110. dialogClickModal: false,
  111. column: [
  112. {
  113. label: "交易金额",
  114. prop: "price",
  115. rules: [{
  116. required: true,
  117. message: "请输入交易金额",
  118. trigger: "blur"
  119. }]
  120. },
  121. {
  122. label: "交易总金额",
  123. prop: "totalPrice",
  124. rules: [{
  125. required: true,
  126. message: "请输入交易总金额",
  127. trigger: "blur"
  128. }]
  129. },
  130. {
  131. label: "付款方ID",
  132. prop: "payId",
  133. hide: true,
  134. rules: [{
  135. required: true,
  136. message: "请输入交易账户--付款方",
  137. trigger: "blur"
  138. }]
  139. },
  140. {
  141. label: "付款方",
  142. prop: "payerName",
  143. rules: [{
  144. required: true,
  145. message: "请输入付款方",
  146. trigger: "blur"
  147. }]
  148. },
  149. {
  150. label: "交易方式",
  151. prop: "title",
  152. search: false,
  153. rules: [{
  154. required: true,
  155. message: "请输入交易方式",
  156. trigger: "blur"
  157. }]
  158. },
  159. {
  160. label: "手续费",
  161. prop: "fee",
  162. rules: [{
  163. required: true,
  164. message: "请输入手续费",
  165. trigger: "blur"
  166. }]
  167. },
  168. {
  169. label: "收款方ID",
  170. prop: "receiveId",
  171. hide: true,
  172. rules: [{
  173. required: true,
  174. message: "请输入交易账户--收款方",
  175. trigger: "blur"
  176. }]
  177. },
  178. {
  179. label: "收款方",
  180. prop: "receiverName",
  181. rules: [{
  182. required: true,
  183. message: "请输入收款方",
  184. trigger: "blur"
  185. }]
  186. },
  187. {
  188. label: "交易状态",
  189. prop: "payStatus",
  190. search: true,
  191. searchslot: true,
  192. searchSpan: 24,
  193. searchOrder: 3,
  194. dicData:[{
  195. label:"全部",
  196. value: -1
  197. },{
  198. label:"待付款",
  199. value:"待付款"
  200. },{
  201. label:"付款成功",
  202. value:"付款成功"
  203. },{
  204. label:"已完结",
  205. value:"已完结"
  206. },{
  207. label:"取消付款",
  208. value:"取消付款"
  209. }],
  210. rules: [{
  211. required: true,
  212. message: "请输入交易状态",
  213. trigger: "blur"
  214. }]
  215. },
  216. {
  217. label: "交易类型",
  218. prop: "type",
  219. search: true,
  220. searchslot: true,
  221. searchSpan: 24,
  222. searchOrder: 4,
  223. dicData:[{
  224. label:"全部",
  225. value: -1
  226. },{
  227. label:"用户付款",
  228. value:"PAY_CONSUMER"
  229. },{
  230. label:"商场交易",
  231. value:"MALL_SEND"
  232. },{
  233. label:"商户交易",
  234. value:"SHOP_SEND"
  235. }],
  236. rules: [{
  237. required: true,
  238. message: "请输入交易类型",
  239. trigger: "blur"
  240. }]
  241. },
  242. {
  243. label: "创建时间",
  244. prop: "createTime",
  245. type: "datetime",
  246. format: "yyyy-MM-dd hh:mm:ss",
  247. valueFormat: "yyyy-MM-dd hh:mm:ss",
  248. searchRange:true,
  249. addDisplay: false,
  250. editDisplay: false,
  251. search: true,
  252. searchSpan: 24,
  253. searchOrder: 0,
  254. searchslot: true,
  255. rules: [{
  256. required: true,
  257. message: "请输入通知时间",
  258. trigger: "blur"
  259. }]
  260. },
  261. {
  262. label: "关键字",
  263. prop: "key",
  264. hide: true,
  265. search: true,
  266. searchslot: true,
  267. searchOrder: 5,
  268. searchSpan: 24,
  269. editDisplay: false,
  270. },
  271. {
  272. label: "交易说明",
  273. prop: "billDesc",
  274. rules: [{
  275. required: true,
  276. message: "请输入交易说明",
  277. trigger: "blur"
  278. }]
  279. }
  280. ]
  281. },
  282. data: [],
  283. censusOption: {
  284. span: ()=>24/this.censusOption.data.length,
  285. data: [
  286. {
  287. title: '用户付款',
  288. prop: ["PAY_CONSUMER","WECHAT_PAY"],
  289. count: 0,
  290. decimals: 2,
  291. icon: 'el-icon-s-custom',
  292. color: '0, 167, 208',
  293. },
  294. {
  295. title: '商场交易',
  296. prop: "MALL_SEND",
  297. count: 0,
  298. decimals: 2,
  299. icon: 'el-icon-paperclip',
  300. color: '27, 201, 142',
  301. },
  302. {
  303. title: '商户交易',
  304. prop: "SHOP_SEND",
  305. count: 0,
  306. decimals: 2,
  307. icon: 'el-icon-s-shop',
  308. color: '230, 71, 88',
  309. }
  310. ]
  311. }
  312. };
  313. },
  314. computed: {
  315. ...mapGetters(["permission"]),
  316. permissionList() {
  317. return {
  318. addBtn: this.vaildData(this.permission.balancebills_add, false),
  319. viewBtn: this.vaildData(this.permission.balancebills_view, false),
  320. delBtn: this.vaildData(this.permission.balancebills_delete, false),
  321. editBtn: this.vaildData(this.permission.balancebills_edit, false)
  322. };
  323. },
  324. ids() {
  325. let ids = [];
  326. this.selectionList.forEach(ele => {
  327. ids.push(ele.id);
  328. });
  329. return ids.join(",");
  330. }
  331. },
  332. watch: {
  333. //监听创建时间变化
  334. "query.createTime": {
  335. handler(value) {
  336. //防止重复调用
  337. if (value !== undefined) {
  338. this.query.createTimeRange = [];
  339. switch (value) {
  340. case -1:
  341. this.query.createTimeStart = undefined;
  342. this.query.createTimeEnd = undefined;
  343. break;
  344. case 1: //今天
  345. this.query.createTimeStart = moment().format("yyyy-MM-DD 00:00:00");
  346. this.query.createTimeEnd = moment().format("yyyy-MM-DD HH:mm:ss");
  347. break;
  348. case 2: //昨天
  349. this.query.createTimeStart = moment().subtract(1, 'days').format("yyyy-MM-DD 00:00:00");
  350. this.query.createTimeEnd = moment().subtract(1, 'days').format("yyyy-MM-DD 23:59:59");
  351. break;
  352. case 3: //近7天
  353. this.query.createTimeStart = moment().subtract(7, 'days').format("yyyy-MM-DD HH:mm:ss");
  354. this.query.createTimeEnd = moment().format("yyyy-MM-DD HH:mm:ss");
  355. break;
  356. case 4: //近30天
  357. this.query.createTimeStart = moment().subtract(30, 'days').format("yyyy-MM-DD HH:mm:ss");
  358. this.query.createTimeEnd = moment().format("yyyy-MM-DD HH:mm:ss");
  359. break;
  360. case 5: //本月
  361. this.query.createTimeStart = moment().format("yyyy-MM-01 00:00:00");
  362. this.query.createTimeEnd = moment().format(`yyyy-MM-DD HH:mm:ss`);
  363. break;
  364. case 6: //本年
  365. this.query.createTimeStart = moment().format("yyyy-01-01 00:00:00");
  366. this.query.createTimeEnd = moment().format(`yyyy-MM-DD HH:mm:ss`);
  367. break;
  368. default:
  369. break;
  370. }
  371. }
  372. }
  373. },
  374. //监听创建时间变化
  375. "query.createTimeRange": {
  376. handler(value) {
  377. //防止重复调用
  378. if (value.length === 2) {
  379. this.query.createTimeStart = value[0];
  380. this.query.createTimeEnd = value[1];
  381. this.query.createTime = undefined;
  382. }
  383. }
  384. },
  385. },
  386. created() {
  387. this.getCensusPrice();
  388. },
  389. methods: {
  390. rowSave(row, done, loading) {
  391. add(row).then(() => {
  392. this.onLoad(this.page);
  393. this.$message({
  394. type: "success",
  395. message: "操作成功!"
  396. });
  397. done();
  398. }, error => {
  399. loading();
  400. window.console.log(error);
  401. });
  402. },
  403. rowUpdate(row, index, done, loading) {
  404. update(row).then(() => {
  405. this.onLoad(this.page);
  406. this.$message({
  407. type: "success",
  408. message: "操作成功!"
  409. });
  410. done();
  411. }, error => {
  412. loading();
  413. console.log(error);
  414. });
  415. },
  416. rowDel(row) {
  417. this.$confirm("确定将选择数据删除?", {
  418. confirmButtonText: "确定",
  419. cancelButtonText: "取消",
  420. type: "warning"
  421. })
  422. .then(() => {
  423. return remove(row.id);
  424. })
  425. .then(() => {
  426. this.onLoad(this.page);
  427. this.$message({
  428. type: "success",
  429. message: "操作成功!"
  430. });
  431. });
  432. },
  433. handleDelete() {
  434. if (this.selectionList.length === 0) {
  435. this.$message.warning("请选择至少一条数据");
  436. return;
  437. }
  438. this.$confirm("确定将选择数据删除?", {
  439. confirmButtonText: "确定",
  440. cancelButtonText: "取消",
  441. type: "warning"
  442. })
  443. .then(() => {
  444. return remove(this.ids);
  445. })
  446. .then(() => {
  447. this.onLoad(this.page);
  448. this.$message({
  449. type: "success",
  450. message: "操作成功!"
  451. });
  452. this.$refs.crud.toggleSelection();
  453. });
  454. },
  455. beforeOpen(done, type) {
  456. if (["edit", "view"].includes(type)) {
  457. getDetail(this.form.id).then(res => {
  458. this.form = res.data.data;
  459. });
  460. }
  461. done();
  462. },
  463. searchReset() {
  464. this.query = {};
  465. this.onLoad(this.page);
  466. },
  467. searchChange(params, done) {
  468. this.query = params;
  469. this.page.currentPage = 1;
  470. this.onLoad(this.page, params);
  471. done();
  472. },
  473. selectionChange(list) {
  474. this.selectionList = list;
  475. },
  476. selectionClear() {
  477. this.selectionList = [];
  478. this.$refs.crud.toggleSelection();
  479. },
  480. currentChange(currentPage){
  481. this.page.currentPage = currentPage;
  482. },
  483. sizeChange(pageSize){
  484. this.page.pageSize = pageSize;
  485. },
  486. refreshChange() {
  487. this.onLoad(this.page, this.query);
  488. },
  489. onLoad(page, params = {}) {
  490. let values = {};
  491. for (const item in params) {
  492. if (params[item] !== undefined && params[item] !== -1) {
  493. values[item] = params[item];
  494. }
  495. }
  496. values.createTime = null;
  497. values.createTimeRange = null;
  498. this.loading = true;
  499. getList(page.currentPage, page.pageSize, values).then(res => {
  500. const data = res.data.data;
  501. this.page.total = data.total;
  502. this.data = data.records;
  503. this.loading = false;
  504. this.selectionClear();
  505. });
  506. },
  507. getCensusPrice() {
  508. censusPrice().then(res => {
  509. res.data.data.forEach(ele => {
  510. const find = this.censusOption.data.find(ele2=>{
  511. return ele2.prop.indexOf(ele.type)!==-1;
  512. });
  513. if(find && ele.price){
  514. find.count = find.count + parseFloat(ele.price);
  515. }
  516. });
  517. });
  518. },
  519. //搜索状态改变
  520. searchStateChange() {
  521. setTimeout(() => {
  522. this.onLoad(this.page, this.query);
  523. }, 100);
  524. },
  525. //生成列表并到处
  526. generateListAndDownload() {
  527. const newQuery = {};
  528. for (const item in this.query) {
  529. if (this.query[item] !== undefined && this.query[item] !== -1) {
  530. newQuery[item] = this.query[item];
  531. }
  532. }
  533. newQuery.createTime = null;
  534. newQuery.createTimeRange = null;
  535. //获取列表键值对
  536. newQuery.keyValue = {};
  537. this.option.column.forEach(ele=>{
  538. newQuery.keyValue[ele.prop] = ele.label;
  539. });
  540. newQuery.keyValue = JSON.stringify(newQuery.keyValue);
  541. this.loading = true;
  542. //生成列表
  543. generateList(this.page.currentPage, this.page.pageSize, newQuery).then(res => {
  544. FileUtil.download(res.data,{
  545. type: "application/vnd.ms-excel"
  546. },`生成余额账单-${moment().format("yyyy-MM-DD HH:mm:ss")}.xls`);
  547. }).finally(()=>{
  548. this.loading = false;
  549. });
  550. },
  551. }
  552. };
  553. </script>
  554. <style>
  555. </style>