index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <div class='container'>
  3. <el-form :inline="true"
  4. v-model="topForm">
  5. <el-form-item label="分部">
  6. <el-select v-model="topForm.team" @change="handleItemChange" placeholder="请选择分部名称">
  7. <el-option v-for='(item,index) in brancheList'
  8. :key='index'
  9. :label="item.label"
  10. :value="item.value"></el-option>
  11. </el-select>
  12. <!-- <el-select v-model="topForm.instruments" placeholder="请选择乐团名称">
  13. <el-option v-for='(item,index) in instrumentList'
  14. :key='index'
  15. :label="item.label"
  16. :value="item.value"></el-option>
  17. </el-select> -->
  18. </el-form-item>
  19. <el-form-item label="支付时间">
  20. <el-date-picker
  21. v-model="paymentTime"
  22. type="datetimerange"
  23. :picker-options="pickerOptions"
  24. range-separator="至"
  25. format="yyyy-MM-dd"
  26. value-format="yyyy-MM-dd"
  27. start-placeholder="开始日期"
  28. end-placeholder="结束日期"
  29. align="right">
  30. </el-date-picker>
  31. </el-form-item>
  32. <el-button type="primary"
  33. icon="el-icon-search"
  34. plain
  35. @click="getstudentList">搜索</el-button>
  36. <el-button type="success"
  37. icon="el-icon-refresh"
  38. plain
  39. @click="resetStudentList">重置</el-button>
  40. <el-button plain
  41. @click="exportis">导出</el-button>
  42. <br />
  43. <p>
  44. <span style="padding-right: 12px;">总金额:{{ amountAll.amount }}元</span>
  45. <span style="padding-right: 12px;">课程:{{ amountAll.tuiFeeAmount }}元</span>
  46. <span style="padding-right: 12px;">商品:{{ amountAll.goodsFeeAmount }}元</span>
  47. <span style="padding-right: 12px;">教辅:{{ amountAll.sdFeeAmount }}元</span>
  48. <span style="padding-right: 12px;">手续费:{{ amountAll.commissionAmount }}元</span>
  49. <span style="padding-right: 12px;">实际到账:{{ (parseFloat(amountAll.amount) - parseFloat(amountAll.commissionAmount)).toFixed(2) }}元</span>
  50. </p>
  51. </el-form>
  52. <div class="tableWrap">
  53. <!-- height="calc(100vh - 174px)"
  54. show-summary
  55. :summary-method="getSummaries" -->
  56. <el-table :data='tableList'
  57. id='tableid'>
  58. <el-table-column type="index"
  59. width="55"></el-table-column>
  60. <el-table-column align="center"
  61. label="学生姓名"
  62. prop='userName'></el-table-column>
  63. <el-table-column align="center"
  64. label="订单编号"
  65. width="200"
  66. prop='orderNo'></el-table-column>
  67. <el-table-column align="center"
  68. label="收款账户"
  69. prop='account'></el-table-column>
  70. <el-table-column align="center"
  71. label="支付金额"
  72. prop='amount'></el-table-column>
  73. <el-table-column align="center"
  74. label="到账时间"
  75. prop='payTime'></el-table-column>
  76. <el-table-column align="center"
  77. label="课程费用"
  78. prop='tuiFee'></el-table-column>
  79. <el-table-column align="center"
  80. label="商品"
  81. prop="goodsFee"></el-table-column>
  82. <el-table-column align="center"
  83. label="教辅费用"
  84. prop="sdFee"></el-table-column>
  85. <el-table-column align="center"
  86. label="手续费"
  87. prop="commission"></el-table-column>
  88. <el-table-column align="center"
  89. label="专业"
  90. prop="voicyPart"></el-table-column>
  91. <el-table-column align="center"
  92. label="分部"
  93. prop="branchName"></el-table-column>
  94. <el-table-column align="left"
  95. label="单位/学校"
  96. prop="poName"></el-table-column>
  97. <el-table-column align="left"
  98. label="备注"
  99. width="300"
  100. :formatter="filterRemark">
  101. </el-table-column>
  102. </el-table>
  103. <div class="paginationWrap">
  104. <el-pagination background
  105. class="pagination"
  106. layout="prev, pager, next"
  107. :total="total"
  108. :current-page.sync="currentPage"
  109. :page-size.sync="rows"
  110. @current-change="handleCurrentChange"></el-pagination>
  111. </div>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. import { getBranches, orderListPage, getMusicTeams } from "@/api/table";
  117. import qs from "qs";
  118. import { scrollTo } from '@/utils/scroll-to'
  119. export default {
  120. data () {
  121. return {
  122. pickerOptions: {
  123. shortcuts: [{
  124. text: '最近一周',
  125. onClick(picker) {
  126. const end = new Date();
  127. const start = new Date();
  128. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  129. picker.$emit('pick', [start, end]);
  130. }
  131. }, {
  132. text: '最近一个月',
  133. onClick(picker) {
  134. const end = new Date();
  135. const start = new Date();
  136. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  137. picker.$emit('pick', [start, end]);
  138. }
  139. }, {
  140. text: '最近三个月',
  141. onClick(picker) {
  142. const end = new Date();
  143. const start = new Date();
  144. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  145. picker.$emit('pick', [start, end]);
  146. }
  147. }]
  148. },
  149. paymentTime: '',
  150. topForm: {},
  151. tableList: [],
  152. rows: 20,
  153. total: 0,
  154. page: 1,
  155. brancheList: [],// 分部列表
  156. instrumentList: [], // 乐团列表
  157. idTmr: '',
  158. tableId: '',
  159. props: {
  160. value: 'value',
  161. label: 'label',
  162. children: 'children'
  163. },//cascader 数据格式化
  164. branchId: '',
  165. classId: '',
  166. account: this.$route.query.account, // 财务唯一标识
  167. amountAll: {
  168. amoun: 0,
  169. tuiFeeAmount: 0,
  170. goodsFeeAmount: 0,
  171. sdFeeAmount: 0,
  172. commissionAmount: 0,
  173. }, // 金额集合
  174. }
  175. },
  176. computed: {
  177. currentPage: {
  178. get () {
  179. return this.page
  180. },
  181. set (val) {
  182. this.$emit('update:page', val)
  183. }
  184. },
  185. },
  186. mounted() {
  187. if(this.account) {
  188. this.getBranches();
  189. this.getstudentList()
  190. }
  191. },
  192. methods: {
  193. handleCurrentChange (val) {
  194. this.page = val;
  195. // this.rows = pageSize;
  196. this.getstudentList();
  197. },
  198. // 获取选项卡
  199. getBranches () {
  200. getBranches().then(res => {
  201. if (res.code == 200) {
  202. let arr = [];
  203. res.data.map(item => {
  204. arr.push({
  205. value: item.branchId,
  206. label: item.branchName,
  207. children: []
  208. })
  209. })
  210. this.brancheList = arr
  211. }
  212. });
  213. },
  214. getstudentList (rows, callBack) {
  215. if(!this.account) {
  216. this.$message.error('您没有权限')
  217. return false
  218. }
  219. if(this.account != 'per' && this.account != 'com') {
  220. this.$message.error('您没有权限')
  221. return false
  222. }
  223. if(rows && typeof rows == 'number' ) {
  224. this.rows = rows
  225. } else {
  226. this.rows = 20
  227. }
  228. let startTime = '', endTime = ''
  229. if(this.paymentTime) {
  230. startTime = this.paymentTime[0]
  231. endTime = this.paymentTime[1]
  232. }
  233. let params = this.topForm
  234. orderListPage(qs.stringify({
  235. account: this.account,
  236. page: this.page,
  237. rows: this.rows,
  238. branchId: params.team,
  239. classId: params.instruments,
  240. type: params.money,
  241. startTime: startTime,
  242. endTime: endTime})).then(res => {
  243. let data = res.data
  244. this.tableList = data.rows;
  245. this.total = data.total;
  246. this.amountAll = {
  247. amount: data.amount,
  248. tuiFeeAmount: data.tuiFeeAmount,
  249. goodsFeeAmount: data.goodsFeeAmount,
  250. sdFeeAmount: data.sdFeeAmount,
  251. commissionAmount: data.commissionAmount
  252. }
  253. // 回调函数
  254. if(callBack && typeof callBack == 'function') {
  255. callBack()
  256. }
  257. })
  258. },
  259. resetStudentList () {
  260. this.branchId = "";
  261. this.classId = '';
  262. this.topForm.money = "";
  263. this.topForm.team = '';
  264. this.topForm.instruments = '';
  265. this.page = 1;
  266. this.getstudentList();
  267. },
  268. filterRemark (val) {
  269. let remark = val.remark ? val.remark : '';
  270. let sdName = val.sdName ? val.sdName : '';
  271. return remark + ' ' + sdName;
  272. },
  273. exportis () {
  274. // this.topForm.money = "";
  275. // this.topForm.team = '';
  276. // this.topForm.instruments = '';
  277. this.rows = 9999
  278. this.page = 1
  279. this.getstudentList(9999, () => {
  280. setTimeout(() => {
  281. this.method5('tableid');
  282. }, 100);
  283. })
  284. // this.method5('tableid');
  285. },
  286. // 导出
  287. getExplorer () {
  288. var explorer = window.navigator.userAgent;
  289. //ie
  290. if (explorer.indexOf("MSIE") >= 0) {
  291. return 'ie';
  292. }
  293. //firefox
  294. else if (explorer.indexOf("Firefox") >= 0) {
  295. return 'Firefox';
  296. }
  297. //Chrome
  298. else if (explorer.indexOf("Chrome") >= 0) {
  299. return 'Chrome';
  300. }
  301. //Opera
  302. else if (explorer.indexOf("Opera") >= 0) {
  303. return 'Opera';
  304. }
  305. //Safari
  306. else if (explorer.indexOf("Safari") >= 0) {
  307. return 'Safari';
  308. }
  309. },
  310. method5 (tableid) {
  311. if (this.getExplorer() == 'ie') {
  312. var curTbl = document.getElementById(tableid);
  313. var oXL = new ActiveXObject("Excel.Application");
  314. var oWB = oXL.Workbooks.Add();
  315. var xlsheet = oWB.Worksheets(1);
  316. var sel = document.body.createTextRange();
  317. sel.moveToElementText(curTbl);
  318. sel.select();
  319. sel.execCommand("Copy");
  320. xlsheet.Paste();
  321. oXL.Visible = true;
  322. try {
  323. var fname = oXL.Application.GetSaveAsFilename("哈哈哈.xls", "Excel Spreadsheets (*.xls), *.xls");
  324. } catch (e) {
  325. print("Nested catch caught " + e);
  326. } finally {
  327. oWB.SaveAs(fname);
  328. oWB.Close(savechanges = false);
  329. oXL.Quit();
  330. oXL = null;
  331. this.idTmr = window.setInterval("Cleanup();", 1);
  332. }
  333. }
  334. else {
  335. this.tableToExcel();
  336. }
  337. },
  338. Cleanup () {
  339. window.clearInterval(this.idTmr);
  340. this.CollectGarbage();
  341. },
  342. tableToExcel () {
  343. (function () {
  344. var uri = 'data:application/vnd.ms-excel;base64,',
  345. template = '<html><head><meta charset="UTF-8"></head><body><table>{table}</table></body></html>',
  346. base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) },
  347. format = function (s, c) {
  348. return s.replace(/{(\w+)}/g,
  349. function (m, p) { return c[p]; }) }
  350. // table name
  351. let table = document.getElementById('tableid')
  352. // || name
  353. var ctx = { worksheet: 'Worksheet', table: table.innerHTML }
  354. window.location.href = uri + base64(format(template, ctx))
  355. //
  356. // return function () {
  357. // }
  358. })()
  359. },
  360. // 多选框选项卡
  361. handleItemChange (val) {
  362. // 发请求 获取分部下的乐团
  363. if (!val) {
  364. return false
  365. }
  366. // getMusicTeams(qs.stringify({ branchId: val })).then(res => {
  367. // this.topForm.instruments = ''
  368. // if (res.code == 200) {
  369. // let arr = [];
  370. // res.data.rows.map(item => {
  371. // arr.push({
  372. // label: item.name,
  373. // value: item.id
  374. // })
  375. // })
  376. // this.instrumentList = arr
  377. // for (let item in this.brancheList) {
  378. // if (this.brancheList[item].value == val) {
  379. // this.brancheList[item].children = arr;
  380. // }
  381. // }
  382. // }
  383. // })
  384. },
  385. handleChange (val) {
  386. if (val) {
  387. this.branchId = val[0];
  388. this.classId = val[1];
  389. }
  390. },
  391. getSummaries(param) {
  392. const { columns, data } = param;
  393. const sums = [];
  394. columns.forEach((column, index) => {
  395. if (index === 0) {
  396. sums[index] = '总价';
  397. return;
  398. }
  399. if(index === 2 || index === 3 || index === 9 || index === 10) {
  400. sums[index] = 'N/A'
  401. return
  402. }
  403. const values = data.map(item => Number(item[column.property]));
  404. if (!values.every(value => isNaN(value))) {
  405. sums[index] = values.reduce((prev, curr) => {
  406. const value = Number(curr);
  407. let temp
  408. if (!isNaN(value)) {
  409. temp = parseFloat(prev) + parseFloat(curr);
  410. } else {
  411. temp = prev;
  412. }
  413. return parseFloat(temp).toFixed(2)
  414. }, 0);
  415. sums[index] += ' 元';
  416. } else {
  417. sums[index] = 'N/A';
  418. }
  419. });
  420. return sums;
  421. }
  422. }
  423. }
  424. </script>
  425. <style lang="scss">
  426. .container {
  427. padding: 30px;
  428. .paginationWrap {
  429. display: flex;
  430. flex-direction: row;
  431. justify-content: flex-end;
  432. }
  433. .pagination {
  434. margin-top: 20px;
  435. }
  436. }
  437. </style>