reconciliation.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div class="reconciliation">
  3. <el-card>
  4. <div style="margin-bottom:20px;">
  5. <el-select
  6. v-model="value"
  7. placeholder="请选择日期类型"
  8. style="margin-right:10px" clearable>
  9. <el-option
  10. v-for="item in RecTime"
  11. :key="item.value"
  12. :label="item.label"
  13. :value="item.value">
  14. </el-option>
  15. </el-select>
  16. <el-date-picker
  17. v-model="dataRange"
  18. clearable
  19. value-format="timestamp"
  20. format="yyyy-MM-dd"
  21. placeholder="请选择日期"
  22. type="date"
  23. style="width:260px;"
  24. @focus="hFocusDate"
  25. :disabled="isDisabled"></el-date-picker>
  26. <el-button style="margin-left:10px;" type="primary" @click="onSearch" :loading="searchLoading">查询</el-button>
  27. <el-button style="margin-left:10px;" type="danger" @click="onReset">重置</el-button>
  28. <el-button style="margin-left:10px;" type="primary" @click="onExportOrder">导出订单</el-button>
  29. </div>
  30. <div style="font-size:16px;margin-bottom:10px;">查询结果</div>
  31. <el-table :data="tableData" border style="width: 100%;font-size:13px;" v-loading="isLoading">
  32. <el-table-column align="center" prop="count" label="订单总数" />
  33. <el-table-column align="center" prop="successCount" label="成功订单数" />
  34. <el-table-column align="center" prop="errorCount" label="失败订单数" />
  35. <el-table-column align="center" prop="sendCount" label="充值中订单数"></el-table-column>
  36. <el-table-column align="center" prop="refill_amounts" label="总充值金额"></el-table-column>
  37. <el-table-column align="center" prop="mch_amounts" label="总扣款金额"></el-table-column>
  38. </el-table>
  39. <el-divider />
  40. <span style="font-size:16px;margin-right:10px;">导出订单记录</span><el-button type="primary" style="margin-bottom:10px;" @click="getExportOrderList">更新状态</el-button>
  41. <el-table :data="exportOrderList" border style="width: 100%;font-size:13px;" v-loading="isLoading">
  42. <el-table-column align="center" prop="title" label="记录名称" width="550" />
  43. <el-table-column align="center" prop="state" label="状态">
  44. <template slot-scope="scope">
  45. <el-tag type="info" v-if="scope.row.state == 1">待处理</el-tag>
  46. <el-tag v-if="scope.row.state == 2">处理中</el-tag>
  47. <el-tag type="success" v-if="scope.row.state == 3">已处理</el-tag>
  48. <el-tag type="danger" v-if="scope.row.state == 4">处理错误</el-tag>
  49. </template>
  50. </el-table-column>
  51. <el-table-column align="center" prop="stage" label="进度" />
  52. <el-table-column align="center" prop="errorCount" label="操作">
  53. <template slot-scope="scope">
  54. <el-button size="mini" disabled v-if="scope.row.state != 3">下载</el-button>
  55. <el-button type="primary" size="mini" v-if="scope.row.state == 3" @click="downloadfile(scope.row.file_path)">下载</el-button>
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. <el-row style="margin-top:10px;" type="flex" justify="end">
  60. <el-pagination background layout="prev, pager, next" :page-count="total" @current-change="onPageChange" :current-page="curpage"></el-pagination>
  61. </el-row>
  62. </el-card>
  63. </div>
  64. </template>
  65. <script>
  66. // getRec-对账管理
  67. import { getRec,getExportOrder,getExportOrderList } from '@/api'
  68. import { RecTime } from '@/utils/constants'
  69. export default {
  70. name: 'reconciliation',
  71. data () {
  72. return {
  73. dataRange: '',
  74. startTime: '',
  75. endTime: '',
  76. value: '',
  77. RecTime,
  78. recForm: {
  79. // 订单总数
  80. count: 0,
  81. // 成功
  82. successCount: 0,
  83. // 失败
  84. errorCount: 0,
  85. // 充值中
  86. sendCount: 0,
  87. // 总充值金额
  88. refill_amounts: 0,
  89. // 扣款金额
  90. mch_amounts: 0,
  91. },
  92. isDisabled: false,
  93. tableData: [],
  94. isLoading: false,
  95. searchLoading: false,
  96. exportOrderList: [],
  97. curpage:1,
  98. total:5
  99. }
  100. },
  101. created() {
  102. this.getExportOrderList();
  103. },
  104. // 监听器
  105. watch: {
  106. dataRange(newVal) {
  107. // console.log(newVal);
  108. if (newVal == null) {
  109. this.startTime = '';
  110. this.endTime = '';
  111. }
  112. },
  113. value: {
  114. handler(newVal) {
  115. // console.log('newVal', newVal);
  116. if (!newVal) {
  117. this.isDisabled = true
  118. } else {
  119. this.isDisabled = false
  120. }
  121. },
  122. immediate: true
  123. }
  124. },
  125. methods: {
  126. onPageChange(page){
  127. if(page == this.curpage) return;
  128. this.curpage = page;
  129. this.getExportOrderList();
  130. },
  131. async getExportOrderList(){
  132. this.isLoading = true;
  133. const res = await getExportOrderList(this.curpage);
  134. this.isLoading = false;
  135. if(res && res.code == 200) {
  136. console.log('getExportOrderList',res.datas);
  137. this.exportOrderList = res.datas.data;
  138. this.total = res.datas.total;
  139. }
  140. else {
  141. this.$message.warning('获取导出列表失败')
  142. }
  143. },
  144. async onExportOrder(){
  145. try {
  146. if (!this.value) {
  147. if (this.timer) {
  148. window.clearTimeout(this.timer)
  149. }
  150. this.timer = setTimeout(() => {
  151. this.$message.warning('请选择日期类型')
  152. }, 1000)
  153. return
  154. }
  155. if(!this.dataRange) {
  156. this.$message.warning('请选择日期')
  157. return;
  158. }
  159. this.searchLoading = true
  160. this.isLoading = true
  161. console.log('this.dataRange',this.dataRange);
  162. this.startTime = this.dataRange/1000
  163. this.endTime = (this.dataRange+86400000)/1000
  164. let param = new URLSearchParams()
  165. param.append('time_type', this.value)
  166. param.append('start_time', this.startTime)
  167. param.append('end_time', this.endTime)
  168. let res = await getExportOrder(param)
  169. if (res && res.code == 200) {
  170. console.log('导出订单', res.datas.file_path);
  171. if(res.datas.file_path) {
  172. this.downloadfile(res.datas.file_path)
  173. }
  174. else{
  175. this.$message.warning('导出任务生成成功')
  176. this.curpage = 1;
  177. this.getExportOrderList();
  178. }
  179. }
  180. this.isLoading = false
  181. this.searchLoading = false
  182. } catch (error) {
  183. console.log(error);
  184. this.isLoading = false
  185. this.searchLoading = false
  186. }
  187. },
  188. downloadfile(file_path){
  189. const a = document.createElement('a');
  190. a.href = file_path;
  191. a.download = '导出订单';
  192. a.style.display = 'none';
  193. document.body.appendChild(a);
  194. a.click();
  195. document.body.removeChild(a);
  196. },
  197. // 查询
  198. async onSearch() {
  199. try {
  200. if (!this.value) {
  201. if (this.timer) {
  202. window.clearTimeout(this.timer)
  203. }
  204. this.timer = setTimeout(() => {
  205. this.$message.warning('请选择日期类型')
  206. }, 1000)
  207. return
  208. }
  209. if(!this.dataRange) {
  210. this.$message.warning('请选择日期')
  211. return;
  212. }
  213. this.searchLoading = true
  214. this.isLoading = true
  215. this.startTime = this.dataRange/1000
  216. this.endTime = (this.dataRange+86400000)/1000
  217. let param = new URLSearchParams()
  218. param.append('time_type', this.value)
  219. param.append('start_time', this.startTime)
  220. param.append('end_time', this.endTime)
  221. let res = await getRec(param)
  222. console.log('对账管理', res);
  223. if (res && res.code == 200) {
  224. this.recForm = res.datas
  225. if (!this.tableData.length) {
  226. this.tableData.push(res.datas)
  227. } else {
  228. const obj = this.tableData[0]
  229. // console.log('obj', obj);
  230. this.tableData[0] = Object.assign(obj, res.datas)
  231. }
  232. }
  233. this.isLoading = false
  234. this.searchLoading = false
  235. } catch (error) {
  236. console.log(error);
  237. this.isLoading = false
  238. this.searchLoading = false
  239. }
  240. },
  241. // 重置
  242. onReset() {
  243. this.dataRange = [];
  244. this.startTime = ''
  245. this.endTime = ''
  246. this.value = ''
  247. this.recForm.count = 0
  248. this.recForm.successCount = 0
  249. this.recForm.errorCount = 0
  250. this.recForm.sendCount = 0
  251. this.recForm.refill_amounts = 0
  252. this.recForm.mch_amounts = 0
  253. this.tableData = []
  254. },
  255. // 时间获取焦点
  256. hFocusDate() {
  257. if (!this.value) {
  258. if (this.timer) {
  259. window.clearTimeout(this.timer)
  260. }
  261. this.timer = setTimeout(() => {
  262. this.$message.warning('请选择日期类型')
  263. }, 1000)
  264. }
  265. }
  266. }
  267. }
  268. </script>
  269. <style scoped>
  270. /deep/.el-date-editor .el-range-separator {
  271. padding: 0;
  272. width: 20px;/*no */
  273. }
  274. /deep/.el-date-editor .el-range-input {
  275. width: 100px;/*no */
  276. }
  277. /deep/.el-form-item {
  278. margin-bottom: 5px;/*no */
  279. }
  280. /deep/.el-card {
  281. padding-bottom: 0;
  282. }
  283. /deep/.el-date-editor .el-range-input {
  284. width: 100px;/*no */
  285. }
  286. /deep/.el-form-item__label {
  287. text-align: left;
  288. }
  289. /deep/.el-table td,
  290. /deep/.el-table th {
  291. padding: 7px 0;
  292. }
  293. /deep/.el-table .cell,
  294. /deep/.el-table--border td:first-child .cell,
  295. /deep/.el-table--border th:first-child .cell {
  296. padding-left: 7px;
  297. }
  298. /deep/.el-table .cell {
  299. padding-right: 7px;
  300. }
  301. </style>
  302. <style>
  303. .el-table td, .el-table th.is-leaf,.el-table--border, .el-table--group{
  304. border-color: #ccc;
  305. }
  306. .el-table--border::after, .el-table--group::after, .el-table::before{
  307. background-color: #ccc;
  308. }
  309. .el-table td, .el-table th.is-leaf {
  310. border-bottom: 1px solid #ccc;
  311. border-right: 1px solid #ccc;
  312. }
  313. .el-table thead {
  314. color: #606266;
  315. }
  316. </style>