shangjiaduizhang.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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="shuibiaoId">
  30. <div class="block">
  31. <el-date-picker v-model="select_riqi.select_day" :editable="false" @change="selectGetDate"
  32. value-format="yyyy-MM-dd" type="date" placeholder="当天日期"></el-date-picker>
  33. </div>
  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="消费金额(元)" align="center" show-overflow-tooltip>
  49. </el-table-column>
  50. <el-table-column prop="build" label="楼栋号" align="center" show-overflow-tooltip></el-table-column>
  51. <el-table-column prop="dom" label="宿舍号" align="center" show-overflow-tooltip></el-table-column>
  52. <el-table-column prop="begin_time" label="消费时间" align="center" show-overflow-tooltip>
  53. </el-table-column>
  54. </el-table>
  55. <div style="margin-top: 20px" class="table-footer">
  56. <div class="pages">
  57. <el-pagination :hide-on-single-page="true" layout="prev, pager, next"
  58. :page-size="table.pageRows" :total="rows_total" @current-change="handleCurrentChange">
  59. </el-pagination>
  60. </div>
  61. <div class="export-table">
  62. <el-button type="primary" size="small" @click="handleDownloadTable">表格导出</el-button>
  63. </div>
  64. </div>
  65. </el-col>
  66. </el-row>
  67. <el-row>
  68. <el-col :span="24" class="forth-row">
  69. <!-- 编辑对话框 -->
  70. <el-dialog title="消费情况" :visible.sync="xiaofeiDialog" :close-on-click-modal="false"
  71. :close-on-press-escape="false" width="640px" top="0vh" class="my-dialog">
  72. <hr
  73. style="width: 100%; position: absolute; top: 60px; left: 0px;background-color: #CCCCCC;height: 1px;border: 0;">
  74. <div class="view-balance">当日消费:{{ xiaofei.day_balance }}元</div>
  75. <div class="view-balance">当月消费:{{ xiaofei.month_balance }}元</div>
  76. <div class="view-balance">当年消费:{{ xiaofei.year_balance }}元</div>
  77. <div class="view-balance"></div>
  78. </el-dialog>
  79. </el-col>
  80. </el-row>
  81. </div>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. // 今日消费
  88. today_xiaofei: 0.0.toFixed(2),
  89. // 年月日的消费
  90. xiaofei: {
  91. day_balance: 0.0.toFixed(2),
  92. month_balance: 0.0.toFixed(2),
  93. year_balance: 0.0.toFixed(2),
  94. },
  95. // 楼栋号下拉列表
  96. drom_options: { // 下拉列表的数据绑定
  97. builds: [{
  98. value: 0,
  99. label: '全部'
  100. }],
  101. value: 0,
  102. label: ''
  103. },
  104. // 宿舍号下拉列表
  105. room_options: {
  106. rooms: [{
  107. value: 0,
  108. label: '全部'
  109. }],
  110. room_value: 0,
  111. room_label: ''
  112. },
  113. select_riqi: {
  114. // 选择日期:年-月-日
  115. select_day: '',
  116. // 选择日期:年-月
  117. select_month: '',
  118. // 选择日期:年
  119. select_year: ''
  120. },
  121. // 控制消费对话框显示隐藏
  122. xiaofeiDialog: false,
  123. // 表格数据
  124. tableData: [],
  125. rows_total: 0,
  126. // 表格参数
  127. table: {
  128. currentPage: 1, // 当前所在页码
  129. pageRows: 8, // 每页显示的行数
  130. },
  131. // 多选后,选择的所有行的数据数组
  132. // multipleSelection: []
  133. }
  134. },
  135. created() {
  136. var statue = sessionStorage.getItem('uname')
  137. if (!statue || typeof(statue) == 'undefined' || statue == '' || statue == 'null') {
  138. this.$router.replace('/')
  139. } else {
  140. // 获取当天日期
  141. var myDate = this.getNowFormatDate();
  142. let params = {
  143. page: this.table.currentPage,
  144. rows: this.table.pageRows,
  145. begin_time: myDate
  146. // begin_time: '2021-08-10'
  147. }
  148. // 获取当日消费列表
  149. this.getTodayXiaofei(params)
  150. // 获取年月日,并获取消费总金额
  151. this.selectGetDate(myDate)
  152. // 取得楼栋号,填充下拉列表
  153. this.getBuildsFillSelect()
  154. }
  155. },
  156. methods: {
  157. /**
  158. * 导出表格
  159. */
  160. handleDownloadTable() {
  161. var _this = this
  162. var params = { data: {}}
  163. if (_this.drom_options.label) {
  164. params.data.build = _this.drom_options.label
  165. }
  166. if (_this.room_options.room_label) {
  167. params.data.dom = _this.room_options.room_label
  168. }
  169. if (_this.select_riqi.select_day) {
  170. params.data.begin_time = _this.select_riqi.select_day
  171. }
  172. if (JSON.stringify(params.data) == '{}') {
  173. params = ''
  174. }
  175. this.$axios.post('/jxch-smartmp-api/HotWaters/watertoComExcel.action', params)
  176. .then(res => {
  177. console.log(res.data.downurl);
  178. if (typeof(res.data.downurl) != 'undefined' && res.data.downurl != '' && JSON.stringify(res
  179. .data) != '{}') {
  180. window.open('https://jtishfw.ncjti.edu.cn/jxch-smartmp' + res.data.downurl)
  181. } else {
  182. _this.$message.error('【未获得】表格!');
  183. }
  184. })
  185. .catch(err => {
  186. // console.log(err);
  187. _this.$message.error('【导出表格】请求异常: ' + err);
  188. })
  189. },
  190. /**
  191. * 改变页码
  192. * @param {Object} val
  193. */
  194. handleCurrentChange(val) {
  195. // console.log(val);
  196. this.table.currentPage = val
  197. // 组合参数,刷新消费表格
  198. this.selectParams(val)
  199. },
  200. /**
  201. * 1. 获取日期下拉列表选择的日期
  202. * 2. 拆分到对于的变量中,便于根据
  203. * @param {Object} val
  204. */
  205. selectGetDate(val) {
  206. // console.log(val);
  207. this.select_riqi.select_year = ''
  208. this.select_riqi.select_month = ''
  209. this.select_riqi.select_day = ''
  210. if (val) {
  211. this.select_riqi.select_year = val.split('-')[0]
  212. this.select_riqi.select_month = val.split('-')[0] + '-' + val.split('-')[1]
  213. this.select_riqi.select_day = val
  214. } else {
  215. this.select_riqi.select_year = ""
  216. this.select_riqi.select_month = ""
  217. this.select_riqi.select_day = ""
  218. }
  219. this.table.currentPage = 1
  220. // 获取年月日消费总金额
  221. this.get_year_month_day_amount()
  222. // 组合参数,刷新消费表格
  223. this.selectParams()
  224. },
  225. /**
  226. * 获取当前时间,格式YYYY-MM-DD
  227. */
  228. getNowFormatDate() {
  229. var date = new Date();
  230. var seperator1 = "-";
  231. var year = date.getFullYear();
  232. var month = date.getMonth() + 1;
  233. var strDate = date.getDate();
  234. if (month >= 1 && month <= 9) {
  235. month = "0" + month;
  236. }
  237. if (strDate >= 0 && strDate <= 9) {
  238. strDate = "0" + strDate;
  239. }
  240. var currentdate = year + seperator1 + month + seperator1 + strDate;
  241. return currentdate;
  242. },
  243. /**
  244. * 获取宿舍号,填充宿舍号下拉列表
  245. */
  246. getRooms() {
  247. var _this = this
  248. let params = {
  249. params: {
  250. build: this.drom_options.label
  251. }
  252. }
  253. this.$axios.get('/jxch-smartmp-api/HotWaters/watergetdoms.action', params)
  254. .then(res => {
  255. // console.log(res.data);
  256. if (typeof(res.data.doms) != 'undefined' && res.data.doms != '' && JSON.stringify(res.data) !=
  257. '{}') {
  258. this.room_options.rooms = [{
  259. value: 0,
  260. label: '全部'
  261. }]
  262. for (var i = 0; i < res.data.doms.length; i++) {
  263. let tmp = {
  264. value: i + 1,
  265. label: res.data.doms[i]
  266. }
  267. this.room_options.rooms.push(tmp)
  268. }
  269. } else {
  270. _this.$message.success('【宿舍号】暂无数据!');
  271. }
  272. })
  273. .catch(err => {
  274. // console.log(err);
  275. _this.$message.error('【宿舍号】请求异常: ' + err);
  276. })
  277. },
  278. /**
  279. * 1. 获取楼栋号下拉列表选择的id
  280. * 2. 刷新消费表格
  281. * 3. 获取宿舍号填充下拉列表
  282. * @param {Object} vId
  283. */
  284. selectGetBuild(vId) {
  285. // console.log(vId);
  286. let obj = {};
  287. obj = this.drom_options.builds.find((item) => {
  288. return item.value === vId; //筛选出匹配数据
  289. });
  290. // console.log(obj);
  291. this.drom_options.value = obj.value
  292. this.drom_options.label = obj.label
  293. this.table.currentPage = 1
  294. // 获取宿舍号,填充宿舍号下拉列表
  295. this.getRooms()
  296. // 组合参数,刷新消费表格
  297. this.selectParams()
  298. },
  299. /**
  300. * 1. 获取宿舍号下拉列表选择的id
  301. * 2. 刷新消费表格
  302. * @param {Object} vId
  303. */
  304. selectGetroom(vId) {
  305. // console.log(vId);
  306. let obj = {};
  307. obj = this.room_options.rooms.find((item) => {
  308. return item.value === vId; //筛选出匹配数据
  309. });
  310. // console.log(obj);
  311. this.room_options.room_value = obj.value
  312. this.room_options.room_label = obj.label
  313. this.table.currentPage = 1
  314. // 组合参数,刷新消费表格
  315. this.selectParams()
  316. },
  317. /**
  318. * 1. 组合参数
  319. * 2. 刷新消费表格
  320. */
  321. selectParams() {
  322. var params = {}
  323. params.page = this.table.currentPage
  324. params.rows = this.table.pageRows
  325. if (this.drom_options.value != 0) {
  326. params.build = this.drom_options.label
  327. }
  328. if (this.room_options.room_value != 0) {
  329. params.dom = this.room_options.room_label
  330. }
  331. if (this.select_riqi.select_day != '') {
  332. params.begin_time = this.select_riqi.select_day
  333. }
  334. // 刷新消费表格
  335. this.getTodayXiaofei(params)
  336. },
  337. /**
  338. * 获取消费列表
  339. * @param {Object} params
  340. */
  341. getTodayXiaofei(params) {
  342. var _this = this
  343. this.$axios.get('/jxch-smartmp-api/HotWaters/waterfindConsume.action', {
  344. params: params
  345. })
  346. .then(res => {
  347. // console.log(res.data);
  348. this.tableData = []
  349. _this.rows_total = 0
  350. if (typeof(res.data.rows) != 'undefined' && res.data.rows != '' && JSON.stringify(res.data) !=
  351. '{}') {
  352. _this.tableData = res.data.rows
  353. _this.rows_total = res.data.total
  354. } else {
  355. _this.$message.success('【当日消费】暂无数据!');
  356. }
  357. })
  358. .catch(err => {
  359. // console.log(err);
  360. _this.$message.error('【当日消费】请求异常: ' + err);
  361. })
  362. },
  363. /**
  364. * 获取楼栋号,填充下拉列表
  365. */
  366. getBuildsFillSelect() {
  367. // 获取楼栋号,填充下拉列表
  368. var _this = this
  369. this.$axios.get('/jxch-smartmp-api/HotWaters/watergetBuilds.action')
  370. .then(res => {
  371. // console.log(res.data);
  372. if (typeof(res.data.builds) != 'undefined' && res.data.builds != '' && JSON.stringify(res
  373. .data) != '{}') {
  374. this.drom_options.builds = [{
  375. value: 0,
  376. label: '全部'
  377. }]
  378. for (var i = 0; i < res.data.builds.length; i++) {
  379. let tmp = {
  380. value: i + 1,
  381. label: res.data.builds[i]
  382. }
  383. this.drom_options.builds.push(tmp)
  384. }
  385. } else {
  386. _this.$message.success('【楼栋号】暂无数据!');
  387. }
  388. })
  389. .catch(err => {
  390. // console.log(err);
  391. _this.$message.error('【楼栋号】请求异常: ' + err);
  392. })
  393. },
  394. /**
  395. * 获取年月日消费总金额
  396. * @param {Object} params
  397. */
  398. get_year_month_day_amount() {
  399. var _this = this
  400. this.xiaofei.year_balance = 0.0.toFixed(2)
  401. this.xiaofei.month_balance = 0.0.toFixed(2)
  402. this.xiaofei.day_balance = 0.0.toFixed(2)
  403. this.today_xiaofei = 0.0.toFixed(2)
  404. // 年消费记录
  405. this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
  406. params: {
  407. year: this.select_riqi.select_year
  408. }
  409. })
  410. .then(res => {
  411. // console.log(res.data);
  412. if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
  413. // _this.$message.success('数据加载成功!');
  414. this.xiaofei.year_balance = parseFloat(res.data.money_year).toFixed(2)
  415. } else {
  416. _this.$message.success('【年消费】暂无数据!');
  417. }
  418. })
  419. .catch(err => {
  420. // console.log(err);
  421. _this.$message.error('【年消费】请求异常: ' + err);
  422. })
  423. // 月消费记录
  424. this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
  425. params: {
  426. month: this.select_riqi.select_month
  427. }
  428. })
  429. .then(res => {
  430. // console.log(res.data);
  431. if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
  432. // _this.$message.success('数据加载成功!');
  433. this.xiaofei.month_balance = parseFloat(res.data.money_month).toFixed(2)
  434. } else {
  435. _this.$message.success('【月消费】暂无数据!');
  436. }
  437. })
  438. .catch(err => {
  439. // console.log(err);
  440. _this.$message.error('【月消费】请求异常: ' + err);
  441. })
  442. // 日消费记录
  443. this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
  444. params: {
  445. day: this.select_riqi.select_day
  446. }
  447. })
  448. .then(res => {
  449. // console.log(res.data);
  450. if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
  451. // _this.$message.success('数据加载成功!');
  452. this.xiaofei.day_balance = parseFloat(res.data.money_day).toFixed(2)
  453. this.today_xiaofei = parseFloat(res.data.money_day).toFixed(2)
  454. } else {
  455. _this.$message.success('【日消费】暂无数据!');
  456. }
  457. })
  458. .catch(err => {
  459. // console.log(err);
  460. _this.$message.error('【日消费】请求异常: ' + err);
  461. })
  462. },
  463. toggleSelection(rows) {
  464. if (rows) {
  465. rows.forEach(row => {
  466. this.$refs.multipleTable.toggleRowSelection(row);
  467. });
  468. } else {
  469. this.$refs.multipleTable.clearSelection();
  470. }
  471. },
  472. // 显示消费对话框
  473. showxiaofeiDialog() {
  474. this.xiaofeiDialog = true
  475. },
  476. // 点击多选按钮获取的行数据数组
  477. handleSelectionChange(val) {
  478. // this.multipleSelection = val
  479. // console.log(val);
  480. }
  481. }
  482. }
  483. </script>
  484. <style scoped>
  485. @import url("shangjiaduizhang.css");
  486. </style>