| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573 |
- <template>
- <div>
- <el-row>
- <el-col :span="24" class="first-row">
- <div class="tag">商家对账</div>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24" class="second-row">
- <div class="total_balance">当日消费:{{today_xiaofei}}元</div>
- <el-link type="primary" class="xiaofei" @click="showxiaofeiDialog">年/月消费</el-link>
- <el-form :inline="true" class="demo-form-inline">
- <el-form-item label="楼栋号:" class="shuibiaoId">
- <el-select v-model="drom_options.value" @change="selectGetBuild(drom_options.value)"
- placeholder="请选择楼栋号" class="my-select">
- <el-option v-for="item in drom_options.builds" :key="item.value" :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="宿舍号:" class="shuibiaoId">
- <el-select v-model="room_options.room_value" @change="selectGetroom(room_options.room_value)"
- placeholder="请选择宿舍号" class="my-select">
- <el-option v-for="item in room_options.rooms" :key="item.value" :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="日期:" class="riqi">
- <el-date-picker v-model="select_datetime" type="daterange" range-separator="至"
- @change="dateChange" start-placeholder="开始日期" end-placeholder="结束日期"
- value-format="yyyy-MM-dd">
- </el-date-picker>
- </el-form-item>
- </el-form>
- </el-col>
- </el-row>
- <hr style="background-color: #CCCCCC;height: 1px;border: 0;">
- <el-row>
- <el-col :span="24" class="third-row">
- <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
- @selection-change="handleSelectionChange" highlight-current-row>
- <el-table-column type="selection" label="全选" align="center" width="55"></el-table-column>
- <el-table-column label="学号" align="center">
- <template slot-scope="scope">{{ scope.row.stu_number }}</template>
- </el-table-column>
- <el-table-column prop="user_name" label="姓名" align="center"></el-table-column>
- <el-table-column prop="use_amount" label="消费金额(元)" :formatter="formatDigit" align="center"
- show-overflow-tooltip>
- </el-table-column>
- <el-table-column prop="build" label="楼栋号" align="center" show-overflow-tooltip></el-table-column>
- <el-table-column prop="dom" label="宿舍号" align="center" show-overflow-tooltip></el-table-column>
- <el-table-column prop="begin_time" label="消费时间" align="center" show-overflow-tooltip>
- </el-table-column>
- </el-table>
- <div style="margin-top: 20px" class="table-footer">
- <div class="pages">
- <el-pagination :hide-on-single-page="true" layout="prev, pager, next" :current-page.sync="table.currentPage"
- :page-size="table.pageRows" :total="rows_total" @current-change="handleCurrentChange">
- </el-pagination>
- </div>
- <div class="export-table">
- <el-button type="primary" size="small" @click="handleDownloadTable">表格导出</el-button>
- </div>
- </div>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24" class="forth-row">
- <!-- 编辑对话框 -->
- <el-dialog title="消费情况" :visible.sync="xiaofeiDialog" :close-on-click-modal="false"
- :close-on-press-escape="false" width="640px" top="0vh" class="my-dialog">
- <hr
- style="width: 100%; position: absolute; top: 60px; left: 0px;background-color: #CCCCCC;height: 1px;border: 0;">
- <div class="view-balance">当日消费:{{ xiaofei.day_balance }}元</div>
- <div class="view-balance">当月消费:{{ xiaofei.month_balance }}元</div>
- <div class="view-balance">当年消费:{{ xiaofei.year_balance }}元</div>
- <div class="view-balance"></div>
- </el-dialog>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- // 今日消费
- today_xiaofei: 0.0.toFixed(2),
- // 年月日的消费
- xiaofei: {
- day_balance: 0.0.toFixed(2),
- month_balance: 0.0.toFixed(2),
- year_balance: 0.0.toFixed(2),
- },
- // 楼栋号下拉列表
- drom_options: { // 下拉列表的数据绑定
- builds: [{
- value: 0,
- label: '全部'
- }],
- value: 0,
- label: ''
- },
- // 宿舍号下拉列表
- room_options: {
- rooms: [{
- value: 0,
- label: '全部'
- }],
- room_value: 0,
- room_label: ''
- },
- select_datetime: [], // 起止日期
- startTime: '', // 开始日期
- endTime: '', // 结束日期
- select_riqi: {
- // 选择日期:年-月-日
- select_day: '',
- // 选择日期:年-月
- select_month: '',
- // 选择日期:年
- select_year: ''
- },
- // 控制消费对话框显示隐藏
- xiaofeiDialog: false,
- // 表格数据
- tableData: [],
- rows_total: 0,
- // 表格参数
- table: {
- currentPage: 1, // 当前所在页码
- pageRows: 8, // 每页显示的行数
- },
- // 多选后,选择的所有行的数据数组
- // multipleSelection: []
- }
- },
- created() {
- var statue = sessionStorage.getItem('uname')
- if (!statue || typeof(statue) == 'undefined' || statue == '' || statue == 'null') {
- this.$router.replace('/')
- } else {
- // 获取当天日期
- var myDate = this.getNowFormatDate();
- // 获取年月日,并获取消费总金额
- this.selectGetDate(myDate)
- // 取得楼栋号,填充下拉列表
- this.getBuildsFillSelect()
- }
- // 初始化日期为今天天 至 明天
- this.initDate()
- },
- methods: {
- /**
- * 初始化日期时间
- */
- initDate() {
- //当前设定的日期时间
- let d = new Date;
- var year1 = d.getFullYear(); // 获取当前年份
- var mon1 = d.getMonth() + 1; // 获取当前月份
- var day1 = d.getDate(); // 获取当前日
- //后一天设定的日期时间
- d.setTime(d.getTime() + 24 * 60 * 60 * 1000);
- var year2 = d.getFullYear(); // 获取当前年份
- var mon2 = d.getMonth() + 1; // 获取当前月份
- var day2 = d.getDate(); // 获取当前日
- this.startTime = this.getDate(year1, mon1, day1)
- this.endTime = this.getDate(year2, mon2, day2)
- this.select_datetime.push(this.startTime)
- this.select_datetime.push(this.endTime)
- // 显示列表
- this.handleCurrentChange(1)
- },
- /**
- * 获取指定格式 年、月、日
- * @param {Object} y
- * @param {Object} m
- * @param {Object} d
- */
- getDate(y, m, d) {
- m = m > 9 ? m : '0' + m;
- d = d > 9 ? d : '0' + d;
- return y + "-" + m + "-" + d;
- },
- /**
- * 选择起止日期
- * @param {Object} val
- */
- dateChange(val) {
- // console.log(val);
- this.startTime = val[0]
- this.endTime = val[1]
- if (this.startTime == this.endTime) {
- var d = new Date(this.endTime);
- d = d.setDate(d.getDate() + 1);
- d = new Date(d);
- let dt = this.getDate(d.getFullYear(), d.getMonth() + 1, d.getDate());
- this.endTime = dt;
- this.select_datetime[1] = dt;
- // this.$message.error('起止日期不能为同一天!');
- }
-
- // 选择日期后,马上搜索
- this.handleCurrentChange(1)
- // 获取选择的日期
- var selectDate = this.startTime;
- // 获取年月日,并获取消费总金额
- this.selectGetDate(selectDate)
- },
- /**
- * 导出表格
- */
- handleDownloadTable() {
- var _this = this
- var params = {
- data: {}
- }
- if (_this.drom_options.label) {
- params.data.build = _this.drom_options.label
- }
- if (_this.room_options.room_label) {
- params.data.dom = _this.room_options.room_label
- }
- if (_this.select_riqi.select_day) {
- params.data.begin_time = _this.select_riqi.select_day
- }
- if (JSON.stringify(params.data) == '{}') {
- params = ''
- }
- this.$axios.post('/jxch-smartmp-api/HotWaters/watertoComExcel.action', params)
- .then(res => {
- // console.log(res.data.downurl);
- if (typeof(res.data.downurl) != 'undefined' && res.data.downurl != '' && JSON.stringify(res
- .data) != '{}') {
- window.open('https://jtishfw.ncjti.edu.cn/jxch-smartmp' + res.data.downurl)
- } else {
- _this.$message.error('【未获得】表格!');
- }
- })
- .catch(err => {
- // console.log(err);
- _this.$message.error('【导出表格】请求异常: ' + err);
- })
- },
- /**
- * 改变页码
- * @param {Object} val
- */
- handleCurrentChange(val) {
- // console.log(val);
- this.table.currentPage = val
- // 组合参数,刷新消费表格
- this.selectParams()
- },
- /**
- * 1. 获取日期下拉列表选择的日期
- * 2. 拆分到对于的变量中,便于根据
- * @param {Object} val
- */
- selectGetDate(val) {
- // console.log(val);
- this.select_riqi.select_year = ''
- this.select_riqi.select_month = ''
- this.select_riqi.select_day = ''
- if (val) {
- this.select_riqi.select_year = val.split('-')[0]
- this.select_riqi.select_month = val.split('-')[0] + '-' + val.split('-')[1]
- this.select_riqi.select_day = val
- } else {
- this.select_riqi.select_year = ""
- this.select_riqi.select_month = ""
- this.select_riqi.select_day = ""
- }
- this.table.currentPage = 1
- // 获取年月日消费总金额
- this.get_year_month_day_amount()
- },
- /**
- * 获取当前时间,格式YYYY-MM-DD
- */
- getNowFormatDate() {
- var date = new Date();
- var seperator1 = "-";
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- var currentdate = year + seperator1 + month + seperator1 + strDate;
- return currentdate;
- },
- /**
- * 获取宿舍号,填充宿舍号下拉列表
- */
- getRooms() {
- var _this = this
- let params = {
- params: {
- build: this.drom_options.label
- }
- }
- this.$axios.get('/jxch-smartmp-api/HotWaters/watergetdoms.action', params)
- .then(res => {
- // console.log(res.data);
- if (typeof(res.data.doms) != 'undefined' && res.data.doms != '' && JSON.stringify(res.data) !=
- '{}') {
- this.room_options.rooms = [{
- value: 0,
- label: '全部'
- }]
- for (var i = 0; i < res.data.doms.length; i++) {
- let tmp = {
- value: i + 1,
- label: res.data.doms[i]
- }
- this.room_options.rooms.push(tmp)
- }
- } else {
- _this.$message.success('【宿舍号】暂无数据!');
- }
- })
- .catch(err => {
- // console.log(err);
- _this.$message.error('【宿舍号】请求异常: ' + err);
- })
- },
- /**
- * 1. 获取楼栋号下拉列表选择的id
- * 2. 刷新消费表格
- * 3. 获取宿舍号填充下拉列表
- * @param {Object} vId
- */
- selectGetBuild(vId) {
- // console.log(vId);
- let obj = {};
- obj = this.drom_options.builds.find((item) => {
- return item.value === vId; //筛选出匹配数据
- });
- // console.log(obj);
- this.drom_options.value = obj.value
- this.drom_options.label = obj.label
- this.table.currentPage = 1
- // 获取宿舍号,填充宿舍号下拉列表
- this.getRooms()
- // 组合参数,刷新消费表格
- this.selectParams()
- },
- /**
- * 1. 获取宿舍号下拉列表选择的id
- * 2. 刷新消费表格
- * @param {Object} vId
- */
- selectGetroom(vId) {
- // console.log(vId);
- let obj = {};
- obj = this.room_options.rooms.find((item) => {
- return item.value === vId; //筛选出匹配数据
- });
- // console.log(obj);
- this.room_options.room_value = obj.value
- this.room_options.room_label = obj.label
- this.table.currentPage = 1
- // 组合参数,刷新消费表格
- this.selectParams()
- },
- /**
- * 1. 组合参数
- * 2. 刷新消费表格
- */
- selectParams() {
- var params = {}
- params.page = this.table.currentPage
- params.rows = this.table.pageRows
- if (this.startTime != '' && typeof(this.startTime) != 'undefined') {
- params.begin_time = this.startTime
- }
- if (this.endTime != '' && typeof(this.endTime) != 'undefined') {
- params.end_time = this.endTime
- }
- if (this.drom_options.value != 0) {
- params.build = this.drom_options.label
- }
- if (this.room_options.room_value != 0) {
- params.dom = this.room_options.room_label
- }
- // 刷新消费表格
- this.getTodayXiaofei(params)
- },
- /**
- * 获取消费列表
- * @param {Object} params
- */
- getTodayXiaofei(params) {
- var _this = this
- this.$axios.get('/jxch-smartmp-api/HotWaters/waterfindConsume.action', {
- params: params
- })
- .then(res => {
- // console.log(res.data);
- this.tableData = []
- _this.rows_total = 0
- if (typeof(res.data.rows) != 'undefined' && res.data.rows != '' && JSON.stringify(res.data) !=
- '{}') {
- _this.tableData = res.data.rows
- _this.rows_total = res.data.total
- } else {
- _this.$message.success('【当日消费】暂无数据!');
- }
- })
- .catch(err => {
- // console.log(err);
- _this.$message.error('【当日消费】请求异常: ' + err);
- })
- },
- formatDigit: (row, column, cellValue, index) => {
- // row: 行数据
- // column: 列属性
- // cellValue: 单元格数据值
- // index: 行索引,注意:2.3.9版本以后才有。
- return cellValue.toFixed(2)
- },
- /**
- * 获取楼栋号,填充下拉列表
- */
- getBuildsFillSelect() {
- // 获取楼栋号,填充下拉列表
- var _this = this
- this.$axios.get('/jxch-smartmp-api/HotWaters/watergetBuilds.action')
- .then(res => {
- // console.log(res.data);
- if (typeof(res.data.builds) != 'undefined' && res.data.builds != '' && JSON.stringify(res
- .data) != '{}') {
- this.drom_options.builds = [{
- value: 0,
- label: '全部'
- }]
- for (var i = 0; i < res.data.builds.length; i++) {
- let tmp = {
- value: i + 1,
- label: res.data.builds[i]
- }
- this.drom_options.builds.push(tmp)
- }
- } else {
- _this.$message.success('【楼栋号】暂无数据!');
- }
- })
- .catch(err => {
- // console.log(err);
- _this.$message.error('【楼栋号】请求异常: ' + err);
- })
- },
- /**
- * 获取年月日消费总金额
- * @param {Object} params
- */
- get_year_month_day_amount() {
- var _this = this
- this.xiaofei.year_balance = 0.0.toFixed(2)
- this.xiaofei.month_balance = 0.0.toFixed(2)
- this.xiaofei.day_balance = 0.0.toFixed(2)
- this.today_xiaofei = 0.0.toFixed(2)
- // 年消费记录
- this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
- params: {
- year: this.select_riqi.select_year
- }
- })
- .then(res => {
- // console.log(res.data);
- if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
- // _this.$message.success('数据加载成功!');
- this.xiaofei.year_balance = parseFloat(res.data.money_year).toFixed(2)
- } else {
- _this.$message.success('【年消费】暂无数据!');
- }
- })
- .catch(err => {
- // console.log(err);
- _this.$message.error('【年消费】请求异常: ' + err);
- })
- // 月消费记录
- this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
- params: {
- month: this.select_riqi.select_month
- }
- })
- .then(res => {
- // console.log(res.data);
- if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
- // _this.$message.success('数据加载成功!');
- this.xiaofei.month_balance = parseFloat(res.data.money_month).toFixed(2)
- } else {
- _this.$message.success('【月消费】暂无数据!');
- }
- })
- .catch(err => {
- // console.log(err);
- _this.$message.error('【月消费】请求异常: ' + err);
- })
- // 日消费记录
- this.$axios.get('/jxch-smartmp-api/HotWaters/watertotalFeel.action', {
- params: {
- day: this.select_riqi.select_day
- }
- })
- .then(res => {
- // console.log(res.data);
- if (typeof(res.data) != 'undefined' && res.data != '' && JSON.stringify(res.data) != '{}') {
- // _this.$message.success('数据加载成功!');
- this.xiaofei.day_balance = parseFloat(res.data.money_day).toFixed(2)
- this.today_xiaofei = parseFloat(res.data.money_day).toFixed(2)
- } else {
- _this.$message.success('【日消费】暂无数据!');
- }
- })
- .catch(err => {
- // console.log(err);
- _this.$message.error('【日消费】请求异常: ' + err);
- })
- },
- toggleSelection(rows) {
- if (rows) {
- rows.forEach(row => {
- this.$refs.multipleTable.toggleRowSelection(row);
- });
- } else {
- this.$refs.multipleTable.clearSelection();
- }
- },
- // 显示消费对话框
- showxiaofeiDialog() {
- this.xiaofeiDialog = true
- },
- // 点击多选按钮获取的行数据数组
- handleSelectionChange(val) {
- // this.multipleSelection = val
- // console.log(val);
- }
- }
- }
- </script>
- <style scoped>
- @import url("shangjiaduizhang.css");
- </style>
|