Balance.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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">余额共计:{{total_amount}}元</div>
  11. <el-form :inline="true" class="demo-form-inline">
  12. <el-form-item label="姓名:" class="shuibiaoId">
  13. <el-input v-model="searchformUser" placeholder="请输入姓名" maxlength="16"></el-input>
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="primary" @click="onSearch">查找</el-button>
  17. </el-form-item>
  18. </el-form>
  19. </el-col>
  20. </el-row>
  21. <hr style="background-color: #CCCCCC;height: 1px;border: 0;">
  22. <el-row>
  23. <el-col :span="24" class="third-row">
  24. <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
  25. highlight-current-row>
  26. <el-table-column align="center" label="学号" width="260">
  27. <template slot-scope="scope">{{ scope.row.stu_number }}</template>
  28. </el-table-column>
  29. <el-table-column prop="user_name" label="姓名" align="center" width="400"></el-table-column>
  30. <el-table-column prop="balance" label="余额(元)" :formatter="formatBalance" show-overflow-tooltip></el-table-column>
  31. <el-table-column label="操作" align="center" width="280">
  32. <el-button type="text" slot-scope="scope" @click="handleShowDialog(scope.$index, scope.row)">
  33. 查看记录
  34. </el-button>
  35. </el-table-column>
  36. </el-table>
  37. <div style="margin-top: 20px" class="table-footer">
  38. <div class="pages">
  39. <el-pagination layout="prev, pager, next" :current-page.sync="currentPage"
  40. :hide-on-single-page="true" :page-size="pageRows" :total="rows_total"
  41. @current-change="handleCurrentChange"></el-pagination>
  42. </div>
  43. </div>
  44. </el-col>
  45. </el-row>
  46. <el-row>
  47. <el-col :span="24" class="forth-row">
  48. <!-- 充值记录对话框 -->
  49. <el-dialog title="充值记录" :visible.sync="viewdialogFormVisible" :close-on-click-modal="false"
  50. :close-on-press-escape="false" width="640px" top="0vh" class="my-dialog">
  51. <hr
  52. style="width: 100%; position: absolute; top: 60px; left: 0px;background-color: #CCCCCC;height: 1px;border: 0;">
  53. <div class="right-tip">共计:{{ view_total_amount }}元</div>
  54. <el-form :inline="true" class="demo-form-inline">
  55. <el-form-item label="筛选条件:">
  56. <div class="block">
  57. <el-date-picker v-model="select_month" value-format="yyyy-MM" type="month"
  58. placeholder="选择月" @change="handleChangeMonth">
  59. </el-date-picker>
  60. </div>
  61. </el-form-item>
  62. </el-form>
  63. <el-table ref="multipleTable" :data="view_tableData" tooltip-effect="dark" style="width: 100%"
  64. highlight-current-row>
  65. <el-table-column align="center" label="时间">
  66. <template slot-scope="scope">{{ scope.row.re_time }}</template>
  67. </el-table-column>
  68. <el-table-column align="center" prop="account" label="金额" :formatter="formatBalance" show-overflow-tooltip>
  69. </el-table-column>
  70. </el-table>
  71. <div slot="footer" class="dialog-footer">
  72. <div class="dialog-pages">
  73. <el-pagination layout="prev, pager, next" :current-page.sync="currentPage"
  74. :hide-on-single-page="true" :page-size="pageRows" :total="view_rows_total"
  75. @current-change="handleViewCurrentChange"></el-pagination>
  76. </div>
  77. </div>
  78. </el-dialog>
  79. </el-col>
  80. </el-row>
  81. </div>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. total_amount: 0.0.toFixed(2), // 余额共计
  88. view_total_amount: 0.0.toFixed(2), // 查看记录对话框中的余额共计
  89. searchformUser: '', // 查找的姓名
  90. viewdialogFormVisible: false, // 显示隐藏查看记录对话框
  91. select_month: '', // 选择的月份
  92. formLabelWidth: '120px',
  93. // 余额列表
  94. tableData: [], // 余额列表
  95. rows_total: 0, // 余额列表总记录数
  96. currentPage: 1, // 余额列表当前页
  97. // 查看记录
  98. view_tableData: [], // 查看记录列表
  99. view_rows_total: 0, // 查看记录列表总记录数
  100. view_currentPage: 1, // 查看记录当前页
  101. pageRows: 8, // 每页记录数
  102. stu_number: '' // 学号
  103. }
  104. },
  105. created() {
  106. // 获取总金额
  107. this.get_total_amount()
  108. // 获取余额列表
  109. let params = {
  110. page: this.currentPage,
  111. rows: this.pageRows
  112. }
  113. this.get_amount_list(params)
  114. },
  115. methods: {
  116. formatBalance: (row, column, cellValue, index) => {
  117. // row: 行数据
  118. // column: 列属性
  119. // cellValue: 单元格数据值
  120. // index: 行索引,注意:2.3.9版本以后才有。
  121. return cellValue.toFixed(2)
  122. },
  123. /**
  124. * 获取当月,格式YYYY-MM
  125. */
  126. getNowFormatDate() {
  127. var date = new Date();
  128. var seperator1 = "-";
  129. var year = date.getFullYear();
  130. var month = date.getMonth() + 1;
  131. var strDate = date.getDate();
  132. if (month >= 1 && month <= 9) {
  133. month = "0" + month;
  134. }
  135. if (strDate >= 0 && strDate <= 9) {
  136. strDate = "0" + strDate;
  137. }
  138. var currentdate = year + seperator1 + month;
  139. return currentdate;
  140. },
  141. /**
  142. * 获取余额列表
  143. */
  144. get_amount_list(params) {
  145. var _this = this
  146. _this.tableData = []
  147. // _this.rows_total = 0
  148. this.$axios.get('/jxch-smartmp-api/HotWaters/waterMoney.action', {
  149. params: params
  150. })
  151. .then(res => {
  152. // console.log(res.data);
  153. if (typeof(res.data.rows) != 'undefined' && res.data.rows != '' && JSON.stringify(res.data) !=
  154. '{}') {
  155. // _this.$message.success('数据加载成功!');
  156. _this.tableData = res.data.rows
  157. _this.rows_total = res.data.total
  158. } else {
  159. _this.$message.success('【获取余额列表】暂无数据!');
  160. }
  161. })
  162. .catch(err => {
  163. // console.log(err);
  164. _this.$message.error('【获取余额列表】请求异常: ' + err);
  165. })
  166. },
  167. /**
  168. * 获取总金额
  169. */
  170. get_total_amount() {
  171. var _this = this
  172. this.$axios.get('/jxch-smartmp-api/HotWaters/waterfindMoneyTotal.action')
  173. .then(res => {
  174. // console.log(res.data);
  175. if (typeof(res.data.money) != 'undefined' && res.data.money != '' && JSON.stringify(res
  176. .data) != '{}') {
  177. // _this.$message.success('数据加载成功!');
  178. let amount = res.data.money
  179. _this.total_amount = parseFloat(amount).toFixed(2)
  180. } else {
  181. _this.$message.success('【获取总金额】暂无数据!');
  182. }
  183. })
  184. .catch(err => {
  185. // console.log(err);
  186. _this.$message.error('【获取总金额】请求异常: ' + err);
  187. })
  188. },
  189. /**
  190. * 余额列表改变页码
  191. * @param {Object} val
  192. */
  193. handleCurrentChange(val) {
  194. // console.log(val);
  195. this.currentPage = val
  196. var params = {}
  197. if (this.searchformUser != '' & typeof(this.searchformUser) != 'undefined') {
  198. params = {
  199. page: this.currentPage,
  200. rows: this.pageRows,
  201. user_name: this.searchformUser
  202. }
  203. } else {
  204. params = {
  205. page: this.currentPage,
  206. rows: this.pageRows
  207. }
  208. }
  209. // 获取余额列表
  210. this.get_amount_list(params)
  211. },
  212. /**
  213. * 查找姓名对应的 余额列表
  214. */
  215. onSearch() {
  216. // console.log(this.searchformUser);
  217. this.currentPage = 1
  218. this.handleCurrentChange(this.currentPage)
  219. },
  220. /**
  221. * 查看充值记录列表
  222. * @param {Object} index
  223. * @param {Object} row
  224. */
  225. handleShowDialog(index, row) {
  226. // console.log(index, row)
  227. // 获取当月
  228. this.select_month = this.getNowFormatDate();
  229. this.stu_number = row.stu_number
  230. // 显示查看充值记录对话框
  231. this.viewdialogFormVisible = true
  232. // 组合参数
  233. let params = {
  234. stu_number: this.stu_number,
  235. time: this.select_month,
  236. page: 1,
  237. rows: this.pageRows
  238. }
  239. // 获取查看记录列表
  240. this.get_view_list(params)
  241. // 充值记录总计
  242. this.get_view_total_amount()
  243. },
  244. /**
  245. * 充值记录总计
  246. */
  247. get_view_total_amount() {
  248. var _this = this
  249. _this.view_total_amount = 0.0.toFixed(2)
  250. this.$axios.get('/jxch-smartmp-api/HotWaters/waterrechargeTotal.action', {
  251. params: {
  252. re_time: this.select_month,
  253. stu_number: this.stu_number
  254. }
  255. })
  256. .then(res => {
  257. // console.log(res.data);
  258. if (typeof(res.data.money) != 'undefined' && res.data.money != '' && JSON.stringify(res
  259. .data) != '{}') {
  260. // _this.$message.success('数据加载成功!');
  261. let amount = res.data.money
  262. _this.view_total_amount = parseFloat(amount).toFixed(2)
  263. } else {
  264. _this.$message.success('【充值记录总计】暂无数据!');
  265. }
  266. })
  267. .catch(err => {
  268. // console.log(err);
  269. _this.$message.error('【充值记录总计】请求异常: ' + err);
  270. })
  271. },
  272. /**
  273. * 选择月份,更新查看记录列表
  274. */
  275. handleChangeMonth() {
  276. // console.log(this.select_month);
  277. this.currentPage = 1
  278. // 组合参数
  279. let params = {
  280. stu_number: this.stu_number,
  281. time: this.select_month,
  282. page: this.currentPage,
  283. rows: this.pageRows
  284. }
  285. // 获取查看记录列表
  286. this.get_view_list(params)
  287. // 充值记录总计
  288. this.get_view_total_amount()
  289. },
  290. /**
  291. * 获取查看记录列表
  292. */
  293. get_view_list(params) {
  294. var _this = this
  295. _this.view_tableData = []
  296. // _this.view_rows_total = 0
  297. this.$axios.get('/jxch-smartmp-api/HotWaters/waterfindRecharge.action', {
  298. params: params
  299. })
  300. .then(res => {
  301. // console.log(res.data);
  302. if (typeof(res.data.rows) != 'undefined' && res.data.rows != '' && JSON.stringify(res.data) !=
  303. '{}') {
  304. // _this.$message.success('数据加载成功!');
  305. _this.view_tableData = res.data.rows
  306. _this.view_rows_total = res.data.total
  307. } else {
  308. _this.$message.success('【获取查看记录列表】暂无数据!');
  309. }
  310. })
  311. .catch(err => {
  312. // console.log(err);
  313. _this.$message.error('【获取查看记录列表】请求异常: ' + err);
  314. })
  315. },
  316. /**
  317. * 查看记录对话框改变页码
  318. * @param {Object} val
  319. */
  320. handleViewCurrentChange(val) {
  321. // console.log(val);
  322. this.view_currentPage = val
  323. // 组合参数
  324. let params = {
  325. stu_number: this.stu_number,
  326. time: this.select_month,
  327. page: this.view_currentPage,
  328. rows: this.pageRows
  329. }
  330. // 获取余额列表
  331. this.get_view_list(params)
  332. }
  333. }
  334. }
  335. </script>
  336. <style scoped>
  337. @import url("Balance.css");
  338. </style>