orderList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :span="24" class="first-row">
  5. <div id="first-left">
  6. <div id="logo"></div>
  7. <div class="tag">订单管理</div>
  8. <div>
  9. <el-select v-model="formInline.value" class="selectDate" placeholder="请选择" @change="selectTime">
  10. <el-option v-for="item in formInline.options" :key="item.value" :label="item.label" :value="item.value">
  11. </el-option>
  12. </el-select>
  13. </div>
  14. </div>
  15. <div id="first-right">
  16. <el-button type="primary" class="first-right-btn" @click="downLoadFile">导出已缴表单</el-button>
  17. </div>
  18. </el-col>
  19. </el-row>
  20. <hr style="background-color: #CCCCCC;height: 1px;border: 0;margin-top: 32px;">
  21. <el-row>
  22. <el-col :span="24" class="second-row">
  23. <div class="total_balance">总金额:<span class="all-money">{{all_money.toFixed(2)}}</span> 元</div>
  24. <el-form :inline="true" class="demo-form-inline">
  25. <el-form-item label="关键字:" class="order">
  26. <el-input v-model="selectOrder" placeholder="请输入订单号或者班级"></el-input>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="primary" @click="onSubmit">查找</el-button>
  30. </el-form-item>
  31. </el-form>
  32. </el-col>
  33. </el-row>
  34. <el-row>
  35. <el-col :span="24" class="third-row">
  36. <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" highlight-current-row>
  37. <el-table-column label="订单号" width="280" align="center">
  38. <template slot-scope="scope">{{ scope.row.order }}</template>
  39. </el-table-column>
  40. <el-table-column prop="id" label="学号" width="260"></el-table-column>
  41. <el-table-column prop="stuName" label="姓名" width="160"></el-table-column>
  42. <el-table-column prop="class" label="班级" width="180"></el-table-column>
  43. <el-table-column prop="money" label="金额(元)" width="160"></el-table-column>
  44. <el-table-column prop="time" label="时间" width="260" widshow-overflow-tooltip></el-table-column>
  45. <el-table-column label="状态" align="center" width="180">
  46. <template slot-scope="scope">
  47. <el-tag :type="scope.row.state === '支付失败' ? 'danger' : 'success'" disable-transitions>{{scope.row.state}}
  48. </el-tag>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <div style="margin-top: 20px" class="table-footer">
  53. <div class="pages">
  54. <el-pagination layout="prev, pager, next" :page-size="pageSize" :total="totalCount"
  55. @current-change="handleCurrentChange"></el-pagination>
  56. </div>
  57. </div>
  58. </el-col>
  59. </el-row>
  60. <el-row>
  61. <el-col :span="24" class="forth-row">
  62. <!-- 编辑对话框 -->
  63. <el-dialog v-if="selectM" title="请选择月份" :visible.sync="editdialogFormVisible" width="400px" top="0vh"
  64. class="my-dialog">
  65. <div id="month">
  66. <el-date-picker v-model="monthValue" type="month" placeholder="选择月" value-format="yyyy-MM"
  67. @change="handleSelectMonth">
  68. </el-date-picker>
  69. <div class="last-row">
  70. <el-button @click="selectMonth" class="submitBtn" :disabled="btnChangeEnableMonth">确定</el-button>
  71. <el-button @click="selectLogout" class="submitBtn">取消</el-button>
  72. </div>
  73. </div>
  74. </el-dialog>
  75. <el-dialog v-if="!selectM" title="请选择日期" :visible.sync="editdialogFormVisible" width="400px" top="0vh"
  76. class="my-dialog">
  77. <div id="month">
  78. <el-date-picker v-model="dayValue" type="date" placeholder="选择日期" value-format="yyyy-MM-dd"
  79. @change="handleSelectDay">
  80. </el-date-picker>
  81. <div class="last-row">
  82. <el-button @click="selectDay" class="submitBtn" :disabled="btnChangeEnableDay">确定</el-button>
  83. <el-button @click="selectLogout" class="submitBtn">取消</el-button>
  84. </div>
  85. </div>
  86. </el-dialog>
  87. </el-col>
  88. </el-row>
  89. </div>
  90. </template>
  91. <script>
  92. export default {
  93. data() {
  94. return {
  95. editdialogFormVisible: false, //月份
  96. btnChangeEnableMonth: true, //确定月份按钮
  97. btnChangeEnableDay: true , //确定日期按钮
  98. selectM: true, //显示月份
  99. formInline: {
  100. user: '',
  101. options: [{
  102. value: 'all',
  103. label: '全部'
  104. }, {
  105. value: 'month',
  106. label: '按月份选择'
  107. }, {
  108. value: 'day',
  109. label: '按日期选择'
  110. }],
  111. value: ''
  112. },
  113. tableData: [], //订单数据
  114. user_token: '', //token
  115. all_money: 0, //总钱数
  116. pageSize: 10, //每页订单数目
  117. totalCount: 0, //总订单数
  118. selectOrder: '', //查找订单号或姓名
  119. monthValue: '', //选择的月份
  120. dayValue: '', //选择的日期
  121. flag: 1, //选择的状态
  122. datestr: '', //选择的时间
  123. }
  124. },
  125. created: function() {
  126. this.user_info = JSON.parse(sessionStorage.getItem('usr_info'))
  127. this.user_token = this.user_info.token
  128. this.getTableData(this.$Api.orderList, this.flag)
  129. },
  130. methods: {
  131. //分页
  132. handleCurrentChange(val) {
  133. this.currentPage = val;
  134. this.tableData = []
  135. this.all_money = 0
  136. this.getTableData(this.$Api.orderList, this.flag, val)
  137. },
  138. //选择时间
  139. selectTime(val) {
  140. if (val == 'month') {
  141. this.editdialogFormVisible = true
  142. this.selectM = true
  143. this.flag = 2
  144. } else if (val == 'day') {
  145. this.editdialogFormVisible = true
  146. this.selectM = false
  147. this.flag = 3
  148. } else {
  149. this.tableData = []
  150. this.all_money = 0
  151. this.flag = 1
  152. this.getTableData(this.$Api.orderList, this.flag)
  153. }
  154. },
  155. //选择月份按钮
  156. handleSelectMonth() {
  157. // console.log(this.monthValue)
  158. if (this.monthValue != '') {
  159. this.btnChangeEnableMonth = false
  160. }
  161. },
  162. //确定选择日期
  163. handleSelectDay(){
  164. if (this.dayValue != '') {
  165. this.btnChangeEnableDay = false
  166. }
  167. },
  168. //确定选择月份
  169. selectMonth(val) {
  170. console.log(this.monthValue)
  171. this.formInline.value = this.monthValue
  172. this.editdialogFormVisible = false
  173. this.tableData = []
  174. this.all_money = 0
  175. this.getTableData(this.$Api.orderList, this.flag, 1, '', this.monthValue)
  176. },
  177. //确定选择日期
  178. selectDay() {
  179. console.log(this.dayValue)
  180. this.formInline.value = this.dayValue
  181. this.editdialogFormVisible = false
  182. this.tableData = []
  183. this.all_money = 0
  184. this.getTableData(this.$Api.orderList, this.flag, 1, '', this.dayValue)
  185. },
  186. //退出选择
  187. selectLogout() {
  188. this.editdialogFormVisible = false
  189. this.formInline.value = '请重新选择'
  190. },
  191. //根据关键字查找订单
  192. onSubmit() {
  193. // console.log(this.selectOrder)
  194. this.tableData = []
  195. this.all_money = 0
  196. this.getTableData(this.$Api.orderList, this.flag, 1, this.selectOrder)
  197. },
  198. //获取订单数据
  199. getTableData(url, flag, index, key, dateStr) {
  200. this.$axios.get(url + '?' + this.$qs.stringify({
  201. 'flag': flag,
  202. 'curPage': index,
  203. 'pageSize': this.pageSize,
  204. 'keyword': key,
  205. 'dateStr': dateStr
  206. }), {
  207. headers: {
  208. 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
  209. 'Author': 'codingliang',
  210. 'admin_token': this.user_token
  211. }
  212. }).then(res => {
  213. // console.log(res)
  214. this.totalCount = res.data.data.page.totalCount
  215. for (var i = 0; i < res.data.data.page.list.length; i++) {
  216. var list = {}
  217. list.order = res.data.data.page.list[i].orderNo
  218. list.id = res.data.data.page.list[i].payerIdentify
  219. list.stuName = res.data.data.page.list[i].studentName
  220. list.class = res.data.data.page.list[i].className
  221. list.money = res.data.data.page.list[i].orderAmount
  222. // this.all_money = (this.all_money + list.money).toFixed(2)
  223. this.all_money = this.all_money + list.money
  224. list.time = res.data.data.page.list[i].finishTime
  225. if (res.data.data.page.list[i].status == 2) {
  226. list.state = '支付成功'
  227. } else {
  228. list.state = '支付失败'
  229. }
  230. this.tableData.push(list)
  231. }
  232. // console.log(this.tableData)
  233. }).catch(err => {
  234. console.log(err)
  235. })
  236. },
  237. //下载文件
  238. downLoadFile() {
  239. if (this.flag == 1) {
  240. this.datestr = ''
  241. } else if (this.flag == 2) {
  242. this.datestr = this.monthValue
  243. } else if (this.flag == 3) {
  244. this.datestr = this.dayValue
  245. }
  246. this.$axios.get(this.$Api.orderDownload + '?' + this.$qs.stringify({
  247. 'flag': this.flag,
  248. 'dateStr': this.datestr
  249. }), {
  250. headers: {
  251. 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
  252. 'Author': 'codingliang',
  253. 'admin_token': this.user_token
  254. },
  255. responseType: 'blob'
  256. }).then(res => {
  257. // console.log(res)
  258. this.download(res.data)
  259. }).catch(err => {
  260. console.log(err)
  261. })
  262. },
  263. //下载
  264. download(data) {
  265. if (!data) {
  266. return
  267. }
  268. let url = window.URL.createObjectURL(new Blob([data]))
  269. let link = document.createElement('a')
  270. link.style.display = 'none'
  271. link.href = url
  272. link.setAttribute('download', '订单列表' + this.datestr + '.xlsx')
  273. document.body.appendChild(link)
  274. link.click()
  275. }
  276. },
  277. }
  278. </script>
  279. <style scoped>
  280. @import url("orderList.css");
  281. </style>