index.vue 13 KB

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