balance-record.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <template>
  2. <div class="page-box" v-loading="loading > 0">
  3. <Header :title="title"></Header>
  4. <div class="container">
  5. <!-- tab -->
  6. <div class="content">
  7. <!-- 表格 -->
  8. <div class="filter-box">
  9. <div class="filter">
  10. <!-- <div class="filter-item">
  11. <p class="label">系统:</p>
  12. <el-select
  13. v-model="filter.sys"
  14. placeholder="全部"
  15. size="small"
  16. class="input"
  17. style="margin: 0 10px"
  18. >
  19. <el-option
  20. v-for="item in system"
  21. :key="item.value"
  22. :label="item.labelName"
  23. :value="item.value"
  24. >
  25. </el-option>
  26. </el-select>
  27. </div> -->
  28. <div class="filter-item">
  29. <p class="label">变动类型:</p>
  30. <el-select
  31. v-model="filter.fundType"
  32. placeholder="全部"
  33. size="small"
  34. class="input"
  35. style="margin: 0 10px"
  36. >
  37. <el-option
  38. v-for="item in typeList"
  39. :key="item.value"
  40. :label="item.name"
  41. :value="item.value"
  42. >
  43. </el-option>
  44. </el-select>
  45. </div>
  46. <div class="filter-item">
  47. <p class="label">变动时间段:</p>
  48. <el-date-picker
  49. style="margin: 0 10px"
  50. size="small"
  51. class="date-input"
  52. v-model="date"
  53. type="datetimerange"
  54. align="right"
  55. unlink-panels
  56. start-placeholder="开始日期"
  57. end-placeholder="结束日期"
  58. value-format="yyyy-MM-dd HH:mm:ss"
  59. >
  60. </el-date-picker>
  61. </div>
  62. <div class="filter-item">
  63. <!-- <div class="label">用户ID:</div> -->
  64. <el-input
  65. class="input"
  66. type="number"
  67. v-model="filter.uid"
  68. placeholder="用户id"
  69. size="small"
  70. >
  71. <template slot="prepend"
  72. >QY</template
  73. >
  74. </el-input>
  75. </div>
  76. <!-- <div class="filter-item">
  77. <div class="label">查询时间:</div>
  78. <el-date-picker
  79. v-model="date"
  80. type="datetimerange"
  81. align="right"
  82. unlink-panels
  83. class="date-input"
  84. range-separator="至"
  85. start-placeholder="开始日期"
  86. end-placeholder="结束日期"
  87. value-format="yyyy-MM-dd HH:mm:ss"
  88. :default-time="['00:00:00', '23:59:59']"
  89. size="small"
  90. >
  91. </el-date-picker>
  92. </div> -->
  93. </div>
  94. <div class="btn-box">
  95. <button class="search" @click="search">筛选</button>
  96. <button class="reset" @click="reset">重置</button>
  97. <button
  98. class="search"
  99. style="margin-left: 60px"
  100. @click="order2excel"
  101. >
  102. 导出
  103. </button>
  104. </div>
  105. </div>
  106. <el-table
  107. :data="list"
  108. class="order-table table no-border-table"
  109. ref="orderTable"
  110. :header-cell-style="{
  111. border: 'none',
  112. color: '#333',
  113. background: '#f6f6f6',
  114. borderBottom: '1px solid #E8E8E8',
  115. height: '54px',
  116. }"
  117. :row-style="{
  118. height: '54px',
  119. }"
  120. >
  121. <el-table-column
  122. prop="nickname"
  123. align="center"
  124. label="用户昵称"
  125. ></el-table-column>
  126. <el-table-column prop="uid" align="center" label="用户ID">
  127. <div slot-scope="scope">
  128. {{ uidFormat(scope.row.uid) }}
  129. </div>
  130. </el-table-column>
  131. <el-table-column
  132. prop="describe"
  133. align="center"
  134. label="变动类型"
  135. ></el-table-column>
  136. <el-table-column
  137. prop="amount"
  138. align="center"
  139. label="操作金额/元"
  140. ></el-table-column>
  141. <el-table-column
  142. prop="afterAmount"
  143. align="center"
  144. label="操作后金额"
  145. ></el-table-column>
  146. <!-- <el-table-column prop="status" align="center" label="状态">
  147. <div slot-scope="scope">
  148. {{ statusMap[scope.row.status] }}
  149. </div>
  150. </el-table-column> -->
  151. <el-table-column
  152. prop="created"
  153. align="center"
  154. label="变更时间"
  155. ></el-table-column>
  156. <el-table-column prop="adminUid" align="center" label="操作人ID">
  157. <div slot-scope="scope">
  158. {{ uidFormat(scope.row.adminUid) }}
  159. </div>
  160. </el-table-column>
  161. </el-table>
  162. </div>
  163. <!-- 分页按钮 -->
  164. <div class="footer">
  165. <el-pagination
  166. @current-change="handleCurrentChange"
  167. :current-page.sync="currentPage"
  168. background
  169. layout="total, prev, pager, next, jumper"
  170. :page-size="size"
  171. :total="total"
  172. ></el-pagination>
  173. </div>
  174. </div>
  175. <el-dialog
  176. :show-close="false"
  177. :close-on-click-modal="false"
  178. title="生成中..."
  179. :visible.sync="showProgressDialog"
  180. width="30%"
  181. center
  182. >
  183. <el-progress
  184. :percentage="progress"
  185. :text-inside="true"
  186. :stroke-width="18"
  187. ></el-progress>
  188. </el-dialog>
  189. </div>
  190. </template>
  191. <script type="text/ecmascript-6">
  192. import Header from '../../components/common/header';
  193. import myUtils from '../../components/common/whatever2excel';
  194. import { role, roleMap } from '@/config.js';
  195. export default {
  196. components: {
  197. Header
  198. },
  199. name: 'balanceRecord',
  200. data() {
  201. return {
  202. currentPage: 1, // 当前页码
  203. size: 20, // 每页条数
  204. total: 0, // 总页数
  205. loading: 0, // 加载中
  206. title: {
  207. // 页面标题
  208. firstTitile: '资金管理',
  209. secondTitle: '余额变动记录'
  210. },
  211. filter: {
  212. uid: null,
  213. fundType: null,
  214. begin: '',
  215. end: ''
  216. },
  217. role: [
  218. {
  219. name: '全部',
  220. id: -1
  221. },
  222. ...role
  223. ],
  224. roleMap: roleMap,
  225. tabActive: 1,
  226. statusType: [],
  227. list: [], // 列表
  228. date: [],
  229. showProgressDialog: false,
  230. progress: 0,
  231. system: [],
  232. systemMap: {},
  233. typeList: [],
  234. typeMap: {},
  235. statusMap: {
  236. 0: '冻结中',
  237. 5: '已解冻'
  238. }
  239. };
  240. },
  241. mounted() {
  242. // this.statusType = this.hzType;
  243. // 获取列表
  244. this.getList();
  245. // this.getDictionary();
  246. this.getFundTypeMap();
  247. },
  248. computed: {},
  249. methods: {
  250. // 切换页码
  251. handleCurrentChange(page) {
  252. this.currentPage = page;
  253. this.getList();
  254. },
  255. // 获取列表
  256. getList() {
  257. this.filter.begin = this.date[0] || '';
  258. this.filter.end = this.date[1] || '';
  259. this.loading++;
  260. this.httpGet(this.$root.getBalance, {
  261. page: this.currentPage,
  262. size: this.size,
  263. ...this.filter
  264. }).then(
  265. (res) => {
  266. this.loading--;
  267. this.list = res.list;
  268. this.total = res.total;
  269. },
  270. (res) => {
  271. this.loading--;
  272. this.$message.error(res);
  273. }
  274. );
  275. },
  276. getFundTypeMap() {
  277. this.loading++;
  278. this.httpGet(this.$root.getFundTypeMap, {}).then(
  279. (res) => {
  280. this.loading--;
  281. this.typeMap = res.balanceLog.balance;
  282. let list = [];
  283. for(let key in this.typeMap){
  284. list.push({
  285. name: this.typeMap[key],
  286. value: key
  287. });
  288. };
  289. this.typeList = list;
  290. },
  291. (res) => {
  292. this.loading--;
  293. this.$message.error(res);
  294. }
  295. );
  296. },
  297. getDictionary(){
  298. this.getDictionaryByName('system');
  299. },
  300. getDictionaryByName(dataName){
  301. this.loading++;
  302. this.httpGet(this.$root.getDictionaryByName, {
  303. dataName
  304. }).then(
  305. (res) => {
  306. this.loading--;
  307. this[dataName] = res.list;
  308. let obj = {};
  309. res.list.forEach(item => {
  310. obj[item.value] = item.labelName;
  311. });
  312. this[dataName + 'Map'] = obj;
  313. },
  314. (res) => {
  315. this.loading--;
  316. this.$message.error(res);
  317. }
  318. );
  319. },
  320. // 过滤
  321. search() {
  322. this.currentPage = 1;
  323. this.getList();
  324. },
  325. // 重置过滤
  326. reset() {
  327. this.filter = {
  328. uid: null,
  329. fundType: null,
  330. begin: '',
  331. end: ''
  332. };
  333. this.date = [];
  334. this.getList();
  335. },
  336. uidFormat(val) {
  337. if (!val) return '-';
  338. let str = val + '';
  339. let length = 6 - str.length;
  340. for (let i = 0; i < length; i++) {
  341. str = '0' + str;
  342. }
  343. return 'QY' + str;
  344. },
  345. async order2excel() {
  346. if(!(await this.exportLog())) return;
  347. this.loading++;
  348. let list = [];
  349. let totalPage = null;
  350. let data = {
  351. page: this.currentPage,
  352. size: this.size,
  353. ...this.filter
  354. };
  355. await this.httpGet(this.$root.getBalance, data).then(
  356. (res) => {
  357. this.loading--;
  358. totalPage = Math.ceil(parseInt(res.total) / this.size);
  359. },
  360. () => {
  361. this.loading--;
  362. }
  363. );
  364. this.showProgressDialog = true;
  365. this.progress = 0;
  366. await this.getAllPages(totalPage, list).then(
  367. () => {
  368. this.showProgressDialog = false;
  369. this.jsonFormatAndToExcel(list);
  370. },
  371. (err) => {
  372. console.error(err);
  373. this.showProgressDialog = false;
  374. }
  375. );
  376. },
  377. async getAllPages(totalPage, list) {
  378. for (let i = 1; i <= totalPage; i++) {
  379. let data = {
  380. page: i,
  381. size: this.size,
  382. ...this.filter
  383. };
  384. await this.httpGet(this.$root.getBalance, data).then((res) => {
  385. list.push(...res.list);
  386. this.progress = Math.floor((i / totalPage) * 100);
  387. console.log('page' + i, list.length);
  388. });
  389. // console.log(5555, list);
  390. }
  391. },
  392. jsonFormatAndToExcel(list) {
  393. let formatList = [];
  394. list.forEach((item) => {
  395. let obj = {
  396. 用户昵称: item.nickname,
  397. 用户ID: this.uidFormat(item.uid),
  398. 变动类型: item.describe,
  399. '操作金额/元': +item.amount,
  400. 操作后金额: +item.afterAmount,
  401. 变更时间: item.created,
  402. 操作人ID: this.uidFormat(item.adminUid),
  403. };
  404. formatList.push(obj);
  405. });
  406. myUtils.json2excel(formatList);
  407. },
  408. exportLog(){
  409. this.loading++;
  410. return this.httpGet(this.$root.getBalance + '/export', {}).then(
  411. (res) => {
  412. this.loading--;
  413. return true;
  414. },
  415. (res) => {
  416. this.loading--;
  417. this.$message.error(res);
  418. return false;
  419. }
  420. );
  421. },
  422. }
  423. };
  424. </script>
  425. <style lang="stylus" rel="stylesheet/stylus">
  426. @import '~assets/public.styl';
  427. </style>
  428. <style lang="stylus" rel="stylesheet/stylus" scoped>
  429. @import '~assets/main.styl';
  430. .page-box {
  431. height: 100%;
  432. width: 100%;
  433. flex-y(flex-start, flex-start);
  434. overflow-y: hidden;
  435. background: bg-color;
  436. .container {
  437. box-sizing: border-box;
  438. height: 100%;
  439. width: 100%;
  440. overflow-y: auto;
  441. flex-y(flex-start, flex-start);
  442. padding: 0 20px 20px;
  443. // content 表格
  444. .content {
  445. flex: 1;
  446. width: 100%;
  447. font-size: 14px;
  448. background: white;
  449. box-sizing: border-box;
  450. padding: 24px 32px;
  451. border-radius: 2px;
  452. // 按钮
  453. .btn {
  454. width: 100px;
  455. height: 32px;
  456. line-height: 32px;
  457. confirm-btn();
  458. font-size: 14px;
  459. margin: 16px 0;
  460. }
  461. // 表格按钮
  462. .table-btn {
  463. // width: 65px;
  464. height: 24px;
  465. line-height: 24px;
  466. color: gray3;
  467. font-size: 12px;
  468. margin-right: 8px;
  469. cancel-btn();
  470. padding: 0 8px;
  471. }
  472. .filter-item {
  473. margin-right: 12px;
  474. }
  475. .select, .input {
  476. width: 160px;
  477. }
  478. .date-input {
  479. width: 360px;
  480. }
  481. .btn-box {
  482. margin: 0;
  483. }
  484. .table {
  485. margin-top: 24px !important;
  486. }
  487. }
  488. }
  489. .footer {
  490. width: 100%;
  491. padding: 24px;
  492. box-sizing: border-box;
  493. flex-x(flex-end);
  494. background: white;
  495. }
  496. .dialog-content {
  497. flex-y();
  498. }
  499. .form {
  500. width: 100%;
  501. flex-center();
  502. margin: 8px 0;
  503. }
  504. }
  505. .tabs {
  506. width: 100%;
  507. background: #fff;
  508. height: 60px;
  509. flex-x(flex-start);
  510. padding: 0 30px;
  511. box-sizing: border-box;
  512. margin-top: 8px;
  513. flex-shrink: 0;
  514. .tab {
  515. background: #fff;
  516. cursor: pointer;
  517. padding: 0 15px;
  518. position: relative;
  519. width: auto;
  520. margin-right: 100px;
  521. height: 100%;
  522. flex-x(center);
  523. word(16px, #999);
  524. &.active {
  525. word(16px, #333);
  526. .tab-line {
  527. width: 100%;
  528. position: absolute;
  529. background: #4678E6;
  530. height: 4px;
  531. border-radius: 2px;
  532. left: 0;
  533. bottom: 3px;
  534. }
  535. }
  536. }
  537. }
  538. </style>