shangjiaduizhang.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :span="24" class="first-row">
  5. <div class="tag">商家对账</div>
  6. </el-col>
  7. </el-row>
  8. <el-row>
  9. <el-col :span="24" class="second-row">
  10. <div class="total_balance">当日消费:{{today_xiaofei}}元</div>
  11. <el-link type="primary" class="xiaofei" @click="showxiaofeiDialog">年/月消费</el-link>
  12. <el-form :inline="true" class="demo-form-inline">
  13. <el-form-item label="楼栋号:" class="shuibiaoId">
  14. <el-select v-model="drom_options.value" @change="selectGetBuild(drom_options.value)"
  15. placeholder="请选择楼栋号" class="my-select">
  16. <el-option v-for="item in drom_options.builds" :key="item.value" :label="item.label"
  17. :value="item.value">
  18. </el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="宿舍号:" class="shuibiaoId">
  22. <el-select v-model="room_options.room_value" @change="selectGetroom(room_options.room_value)"
  23. placeholder="请选择宿舍号" class="my-select">
  24. <el-option v-for="item in room_options.rooms" :key="item.value" :label="item.label"
  25. :value="item.value">
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="日期:" class="riqi">
  30. <el-date-picker v-model="select_datetime" type="daterange" range-separator="至"
  31. @change="dateChange" start-placeholder="开始日期" end-placeholder="结束日期"
  32. value-format="yyyy-MM-dd">
  33. </el-date-picker>
  34. </el-form-item>
  35. </el-form>
  36. </el-col>
  37. </el-row>
  38. <hr style="background-color: #CCCCCC;height: 1px;border: 0;">
  39. <el-row>
  40. <el-col :span="24" class="third-row">
  41. <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
  42. @selection-change="handleSelectionChange" highlight-current-row>
  43. <el-table-column type="selection" label="全选" align="center" width="55"></el-table-column>
  44. <el-table-column label="学号" align="center">
  45. <template slot-scope="scope">{{ scope.row.stu_number }}</template>
  46. </el-table-column>
  47. <el-table-column prop="user_name" label="姓名" align="center"></el-table-column>
  48. <el-table-column prop="use_amount" label="消费金额(元)" :formatter="formatDigit" align="center"
  49. show-overflow-tooltip>
  50. </el-table-column>
  51. <el-table-column prop="build" label="楼栋号" align="center" show-overflow-tooltip></el-table-column>
  52. <el-table-column prop="dom" label="宿舍号" align="center" show-overflow-tooltip></el-table-column>
  53. <el-table-column prop="begin_time" label="消费时间" align="center" show-overflow-tooltip>
  54. </el-table-column>
  55. </el-table>
  56. <div style="margin-top: 20px" class="table-footer">
  57. <div class="pages">
  58. <el-pagination :hide-on-single-page="true" layout="prev, pager, next" :current-page.sync="table.currentPage"
  59. :page-size="table.pageRows" :total="rows_total" @current-change="handleCurrentChange">
  60. </el-pagination>
  61. </div>
  62. <div class="export-table">
  63. <el-button type="primary" size="small" @click="handleDownloadTable">表格导出</el-button>
  64. </div>
  65. </div>
  66. </el-col>
  67. </el-row>
  68. <el-row>
  69. <el-col :span="24" class="forth-row">
  70. <!-- 编辑对话框 -->
  71. <el-dialog title="消费情况" :visible.sync="xiaofeiDialog" :close-on-click-modal="false"
  72. :close-on-press-escape="false" width="640px" top="0vh" class="my-dialog">
  73. <hr
  74. style="width: 100%; position: absolute; top: 60px; left: 0px;background-color: #CCCCCC;height: 1px;border: 0;">
  75. <div class="view-balance">当日消费:{{ xiaofei.day_balance }}元</div>
  76. <div class="view-balance">当月消费:{{ xiaofei.month_balance }}元</div>
  77. <div class="view-balance">当年消费:{{ xiaofei.year_balance }}元</div>
  78. <div class="view-balance"></div>
  79. </el-dialog>
  80. </el-col>
  81. </el-row>
  82. </div>
  83. </template>
  84. <script>
  85. export default {
  86. data() {
  87. return {
  88. // 今日消费
  89. today_xiaofei: 0.0.toFixed(2),
  90. // 年月日的消费
  91. xiaofei: {
  92. day_balance: 0.0.toFixed(2),
  93. month_balance: 0.0.toFixed(2),
  94. year_balance: 0.0.toFixed(2),
  95. },
  96. // 楼栋号下拉列表
  97. drom_options: { // 下拉列表的数据绑定
  98. builds: [{
  99. value: 0,
  100. label: '全部'
  101. }],
  102. value: 0,
  103. label: ''
  104. },
  105. // 宿舍号下拉列表
  106. room_options: {
  107. rooms: [{
  108. value: 0,
  109. label: '全部'
  110. }],
  111. room_value: 0,
  112. room_label: ''
  113. },
  114. select_datetime: [], // 起止日期
  115. startTime: '', // 开始日期
  116. endTime: '', // 结束日期
  117. select_riqi: {
  118. // 选择日期:年-月-日
  119. select_day: '',
  120. // 选择日期:年-月
  121. select_month: '',
  122. // 选择日期:年
  123. select_year: ''
  124. },
  125. // 控制消费对话框显示隐藏
  126. xiaofeiDialog: false,
  127. // 表格数据
  128. tableData: [],
  129. rows_total: 0,
  130. // 表格参数
  131. table: {
  132. currentPage: 1, // 当前所在页码
  133. pageRows: 8, // 每页显示的行数
  134. },
  135. // 多选后,选择的所有行的数据数组
  136. // multipleSelection: []
  137. }
  138. },
  139. created() {
  140. var statue = sessionStorage.getItem('uname')
  141. if (!statue || typeof(statue) == 'undefined' || statue == '' || statue == 'null') {
  142. this.$router.replace('/')
  143. } else {
  144. // 获取当天日期
  145. var myDate = this.getNowFormatDate();
  146. // 获取年月日,并获取消费总金额
  147. this.selectGetDate(myDate)
  148. // 取得楼栋号,填充下拉列表
  149. this.getBuildsFillSelect()
  150. }
  151. // 初始化日期为今天天 至 明天
  152. this.initDate()
  153. },
  154. methods: {
  155. /**
  156. * 初始化日期时间
  157. */
  158. initDate() {
  159. //当前设定的日期时间
  160. let d = new Date;
  161. var year1 = d.getFullYear(); // 获取当前年份
  162. var mon1 = d.getMonth() + 1; // 获取当前月份
  163. var day1 = d.getDate(); // 获取当前日
  164. //后一天设定的日期时间
  165. d.setTime(d.getTime() + 24 * 60 * 60 * 1000);
  166. var year2 = d.getFullYear(); // 获取当前年份
  167. var mon2 = d.getMonth() + 1; // 获取当前月份
  168. var day2 = d.getDate(); // 获取当前日
  169. this.startTime = this.getDate(year1, mon1, day1)
  170. this.endTime = this.getDate(year2, mon2, day2)
  171. this.select_datetime.push(this.startTime)
  172. this.select_datetime.push(this.endTime)
  173. // 显示列表
  174. this.handleCurrentChange(1)
  175. },
  176. /**
  177. * 获取指定格式 年、月、日
  178. * @param {Object} y
  179. * @param {Object} m
  180. * @param {Object} d
  181. */
  182. getDate(y, m, d) {
  183. m = m > 9 ? m : '0' + m;
  184. d = d > 9 ? d : '0' + d;
  185. return y + "-" + m + "-" + d;
  186. },
  187. /**
  188. * 选择起止日期
  189. * @param {Object} val
  190. */
  191. dateChange(val) {
  192. // console.log(val);
  193. this.startTime = val[0]
  194. this.endTime = val[1]
  195. if (this.startTime == this.endTime) {
  196. var d = new Date(this.endTime);
  197. d = d.setDate(d.getDate() + 1);
  198. d = new Date(d);
  199. let dt = this.getDate(d.getFullYear(), d.getMonth() + 1, d.getDate());
  200. this.endTime = dt;
  201. this.select_datetime[1] = dt;
  202. // this.$message.error('起止日期不能为同一天!');
  203. }
  204. // 选择日期后,马上搜索
  205. this.handleCurrentChange(1)
  206. // 获取选择的日期
  207. var selectDate = this.startTime;
  208. // 获取年月日,并获取消费总金额
  209. this.selectGetDate(selectDate)
  210. },
  211. /**
  212. * 导出表格
  213. */
  214. handleDownloadTable() {
  215. var _this = this
  216. var params = {
  217. data: {}
  218. }
  219. if (_this.drom_options.label) {
  220. params.data.build = _this.drom_options.label
  221. }
  222. if (_this.room_options.room_label) {
  223. params.data.dom = _this.room_options.room_label
  224. }
  225. if (_this.select_riqi.select_day) {
  226. params.data.begin_time = _this.select_riqi.select_day
  227. }
  228. if (JSON.stringify(params.data) == '{}') {
  229. params = ''
  230. }
  231. this.$axios.post('/jxch-smartmp-api/HotWaters/watertoComExcel.action', params)
  232. .then(res => {
  233. // console.log(res.data.downurl);
  234. if (typeof(res.data.downurl) != 'undefined' && res.data.downurl != '' && JSON.stringify(res
  235. .data) != '{}') {
  236. window.open('https://jtishfw.ncjti.edu.cn/jxch-smartmp' + res.data.downurl)
  237. } else {
  238. _this.$message.error('【未获得】表格!');
  239. }
  240. })
  241. .catch(err => {
  242. // console.log(err);
  243. _this.$message.error('【导出表格】请求异常: ' + err);
  244. })
  245. },
  246. /**
  247. * 改变页码
  248. * @param {Object} val
  249. */
  250. handleCurrentChange(val) {
  251. // console.log(val);
  252. this.table.currentPage = val
  253. // 组合参数,刷新消费表格
  254. this.selectParams()
  255. },
  256. /**
  257. * 1. 获取日期下拉列表选择的日期
  258. * 2. 拆分到对于的变量中,便于根据
  259. * @param {Object} val
  260. */
  261. selectGetDate(val) {
  262. // console.log(val);
  263. this.select_riqi.select_year = ''
  264. this.select_riqi.select_month = ''
  265. this.select_riqi.select_day = ''
  266. if (val) {
  267. this.select_riqi.select_year = val.split('-')[0]
  268. this.select_riqi.select_month = val.split('-')[0] + '-' + val.split('-')[1]
  269. this.select_riqi.select_day = val
  270. } else {
  271. this.select_riqi.select_year = ""
  272. this.select_riqi.select_month = ""
  273. this.select_riqi.select_day = ""
  274. }
  275. this.table.currentPage = 1
  276. // 获取年月日消费总金额
  277. this.get_year_month_day_amount()
  278. },
  279. /**
  280. * 获取当前时间,格式YYYY-MM-DD
  281. */
  282. getNowFormatDate() {
  283. var date = new Date();
  284. var seperator1 = "-";
  285. var year = date.getFullYear();
  286. var month = date.getMonth() + 1;
  287. var strDate = date.getDate();
  288. if (month >= 1 && month <= 9) {
  289. month = "0" + month;
  290. }
  291. if (strDate >= 0 && strDate <= 9) {
  292. strDate = "0" + strDate;
  293. }
  294. var currentdate = year + seperator1 + month + seperator1 + strDate;
  295. return currentdate;
  296. },
  297. /**
  298. * 获取宿舍号,填充宿舍号下拉列表
  299. */
  300. getRooms() {
  301. var _this = this
  302. let params = {
  303. params: {
  304. build: this.drom_options.label
  305. }
  306. }
  307. this.$axios.get('/jxch-smartmp-api/HotWaters/watergetdoms.action', params)
  308. .then(res => {
  309. // console.log(res.data);
  310. if (typeof(res.data.doms) != 'undefined' && res.data.doms != '' && JSON.stringify(res.data) !=
  311. '{}') {
  312. this.room_options.rooms = [{
  313. value: 0,
  314. label: '全部'
  315. }]
  316. for (var i = 0; i < res.data.doms.length; i++) {
  317. let tmp = {
  318. value: i + 1,
  319. label: res.data.doms[i]
  320. }
  321. this.room_options.rooms.push(tmp)
  322. }
  323. } else {
  324. _this.$message.success('【宿舍号】暂无数据!');
  325. }
  326. })
  327. .catch(err => {
  328. // console.log(err);
  329. _this.$message.error('【宿舍号】请求异常: ' + err);
  330. })
  331. },
  332. /**
  333. * 1. 获取楼栋号下拉列表选择的id
  334. * 2. 刷新消费表格
  335. * 3. 获取宿舍号填充下拉列表
  336. * @param {Object} vId
  337. */
  338. selectGetBuild(vId) {
  339. // console.log(vId);
  340. let obj = {};
  341. obj = this.drom_options.builds.find((item) => {
  342. return item.value === vId; //筛选出匹配数据
  343. });
  344. // console.log(obj);
  345. this.drom_options.value = obj.value
  346. this.drom_options.label = obj.label
  347. this.table.currentPage = 1
  348. // 获取宿舍号,填充宿舍号下拉列表
  349. this.getRooms()
  350. // 组合参数,刷新消费表格
  351. this.selectParams()
  352. },
  353. /**
  354. * 1. 获取宿舍号下拉列表选择的id
  355. * 2. 刷新消费表格
  356. * @param {Object} vId
  357. */
  358. selectGetroom(vId) {
  359. // console.log(vId);
  360. let obj = {};
  361. obj = this.room_options.rooms.find((item) => {
  362. return item.value === vId; //筛选出匹配数据
  363. });
  364. // console.log(obj);
  365. this.room_options.room_value = obj.value
  366. this.room_options.room_label = obj.label
  367. this.table.currentPage = 1
  368. // 组合参数,刷新消费表格
  369. this.selectParams()
  370. },
  371. /**
  372. * 1. 组合参数
  373. * 2. 刷新消费表格
  374. */
  375. selectParams() {
  376. var params = {}
  377. params.page = this.table.currentPage
  378. params.rows = this.table.pageRows
  379. if (this.startTime != '' && typeof(this.startTime) != 'undefined') {
  380. params.begin_time = this.startTime
  381. }
  382. if (this.endTime != '' && typeof(this.endTime) != 'undefined') {
  383. params.end_time = this.endTime
  384. }
  385. if (this.drom_options.value != 0) {
  386. params.build = this.drom_options.label
  387. }
  388. if (this.room_options.room_value != 0) {
  389. params.dom = this.room_options.room_label
  390. }
  391. // 刷新消费表格
  392. this.getTodayXiaofei(params)
  393. },
  394. /**
  395. * 获取消费列表
  396. * @param {Object} params
  397. */
  398. getTodayXiaofei(params) {
  399. var _this = this
  400. this.$axios.get('/jxch-smartmp-api/HotWaters/waterfindConsume.action', {
  401. params: params
  402. })
  403. .then(res => {
  404. // console.log(res.data);
  405. this.tableData = []
  406. _this.rows_total = 0
  407. if (typeof(res.data.rows) != 'undefined' && res.data.rows != '' && JSON.stringify(res.data) !=
  408. '{}') {
  409. _this.tableData = res.data.rows
  410. _this.rows_total = res.data.total
  411. } else {
  412. _this.$message.success('【当日消费】暂无数据!');
  413. }
  414. })
  415. .catch(err => {
  416. // console.log(err);
  417. _this.$message.error('【当日消费】请求异常: ' + err);
  418. })
  419. },
  420. formatDigit: (row, column, cellValue, index) => {
  421. // row: 行数据
  422. // column: 列属性
  423. // cellValue: 单元格数据值
  424. // index: 行索引,注意:2.3.9版本以后才有。
  425. return cellValue.toFixed(2)
  426. },
  427. /**
  428. * 获取楼栋号,填充下拉列表
  429. */
  430. getBuildsFillSelect() {
  431. // 获取楼栋号,填充下拉列表
  432. var _this = this
  433. this.$axios.get('/jxch-smartmp-api/HotWaters/watergetBuilds.action')
  434. .then(res => {
  435. // console.log(res.data);
  436. if (typeof(res.data.builds) != 'undefined' && res.data.builds != '' && JSON.stringify(res
  437. .data) != '{}') {
  438. this.drom_options.builds = [{
  439. value: 0,
  440. label: '全部'
  441. }]
  442. for (var i = 0; i < res.data.builds.length; i++) {
  443. let tmp = {
  444. value: i + 1,
  445. label: res.data.builds[i]
  446. }
  447. this.drom_options.builds.push(tmp)
  448. }
  449. } else {
  450. _this.$message.success('【楼栋号】暂无数据!');
  451. }
  452. })
  453. .catch(err => {
  454. // console.log(err);
  455. _this.$message.error('【楼栋号】请求异常: ' + err);
  456. })
  457. },
  458. /**
  459. * 获取年月日消费总金额
  460. * @param {Object} params
  461. */
  462. get_year_month_day_amount() {
  463. var _this = this
  464. this.xiaofei.year_balance = 0.0.toFixed(2)
  465. this.xiaofei.month_balance = 0.0.toFixed(2)
  466. this.xiaofei.day_balance = 0.0.toFixed(2)
  467. this.today_xiaofei = 0.0.toFixed(2)
  468. // 年消费记录
  469. this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
  470. params: {
  471. year: this.select_riqi.select_year
  472. }
  473. })
  474. .then(res => {
  475. // console.log(res.data);
  476. if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
  477. // _this.$message.success('数据加载成功!');
  478. this.xiaofei.year_balance = parseFloat(res.data.money_year).toFixed(2)
  479. } else {
  480. _this.$message.success('【年消费】暂无数据!');
  481. }
  482. })
  483. .catch(err => {
  484. // console.log(err);
  485. _this.$message.error('【年消费】请求异常: ' + err);
  486. })
  487. // 月消费记录
  488. this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
  489. params: {
  490. month: this.select_riqi.select_month
  491. }
  492. })
  493. .then(res => {
  494. // console.log(res.data);
  495. if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
  496. // _this.$message.success('数据加载成功!');
  497. this.xiaofei.month_balance = parseFloat(res.data.money_month).toFixed(2)
  498. } else {
  499. _this.$message.success('【月消费】暂无数据!');
  500. }
  501. })
  502. .catch(err => {
  503. // console.log(err);
  504. _this.$message.error('【月消费】请求异常: ' + err);
  505. })
  506. // 日消费记录
  507. this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
  508. params: {
  509. day: this.select_riqi.select_day
  510. }
  511. })
  512. .then(res => {
  513. // console.log(res.data);
  514. if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
  515. // _this.$message.success('数据加载成功!');
  516. this.xiaofei.day_balance = parseFloat(res.data.money_day).toFixed(2)
  517. this.today_xiaofei = parseFloat(res.data.money_day).toFixed(2)
  518. } else {
  519. _this.$message.success('【日消费】暂无数据!');
  520. }
  521. })
  522. .catch(err => {
  523. // console.log(err);
  524. _this.$message.error('【日消费】请求异常: ' + err);
  525. })
  526. },
  527. toggleSelection(rows) {
  528. if (rows) {
  529. rows.forEach(row => {
  530. this.$refs.multipleTable.toggleRowSelection(row);
  531. });
  532. } else {
  533. this.$refs.multipleTable.clearSelection();
  534. }
  535. },
  536. // 显示消费对话框
  537. showxiaofeiDialog() {
  538. this.xiaofeiDialog = true
  539. },
  540. // 点击多选按钮获取的行数据数组
  541. handleSelectionChange(val) {
  542. // this.multipleSelection = val
  543. // console.log(val);
  544. }
  545. }
  546. }
  547. </script>
  548. <style scoped>
  549. @import url("shangjiaduizhang.css");
  550. </style>