orderList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <div class="order-wrapper">
  3. <!-- <breadcrumb :item-name="['订单管理', '订单列表']"></breadcrumb> -->
  4. <div class="empty-order" v-if="orderToken.length == 0">
  5. <div class="dr-wrap hand">
  6. <i class="el-icon-document dr-icon"></i>
  7. <div class="dr-tit">点击上传token获取订单</div>
  8. <input type="file" ref="fileInput" @change="readTxtFile('fileInput')" class="dr-int" />
  9. </div>
  10. </div>
  11. <el-card v-else>
  12. <!-- 搜索区域 -->
  13. <el-row>
  14. <el-col>
  15. <div class="flex" style="justify-content: flex-end;padding-bottom: 20px;">
  16. <div class="redr">
  17. <el-button>重新导入</el-button>
  18. <input type="file" ref="fileInputt" @change="readTxtFile('fileInputt')" class="dr-int" />
  19. </div>
  20. <el-button type="primary" @click="oneWork(list)" :loading="yjloading">一键处理订单</el-button>
  21. </div>
  22. </el-col>
  23. <!-- <el-col :span="8">
  24. <el-input placeholder="请输入内容" v-model="queryInfo.query" class="input-with-select">
  25. <el-button slot="append" icon="el-icon-search" @click="getList()"></el-button>
  26. </el-input>
  27. </el-col> -->
  28. </el-row>
  29. <!-- 订单表格区域 -->
  30. <el-table :data="list" border style="width: 100%" max-height="620">
  31. <!-- <el-table-column fixed="left" type="selection" width="55">
  32. </el-table-column> -->
  33. <el-table-column prop="id" label="id" width="80">
  34. </el-table-column>
  35. <el-table-column prop="order_id" label="订单编号" width="200">
  36. </el-table-column>
  37. <el-table-column prop="goods_name" label="商品名称" width="200">
  38. <template slot-scope="scope">
  39. <span>{{scope.row.goods_name.length > 10 ? (scope.row.goods_name.substr(0, 10) + '...') : scope.row.goods_name}}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="sys_address" label="是否系统默认" width="170">
  43. <template slot-scope="scope">
  44. <span
  45. :style="{'color': (scope.row.sys_address == 1 || scope.row.sys_phone == 1 )? '': '#67c23a'}">{{(scope.row.sys_address == 1 || scope.row.sys_phone == 1 )? '是': '否'}}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="status" label="订单状态" width="170">
  49. <template slot-scope="scope">
  50. {{scope.row.status| showStatus}}
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop="consignee_name" label="收货人" width="200">
  54. </el-table-column>
  55. <el-table-column prop="consignee_phone" label="收货手机号" width="200">
  56. </el-table-column>
  57. <el-table-column prop="consignee_address" label="收货地址" width="350">
  58. </el-table-column>
  59. <el-table-column prop="pay_price" label="支付金额(元)" width="150">
  60. </el-table-column>
  61. <el-table-column prop="commission" label="手续费(元)" width="150">
  62. </el-table-column>
  63. <el-table-column prop="compensation" label="赔付金额(元)" width="150">
  64. <template slot-scope="scope">
  65. {{scope.row.status == 5 ? scope.row.compensation: ''}}
  66. </template>
  67. </el-table-column>
  68. <!-- <el-table-column prop="token" label="Token" width="350">
  69. </el-table-column> -->
  70. <!-- <el-table-column prop="status" label="是否已使用">
  71. <template slot-scope="scope">
  72. <el-tag type="success" v-if="scope.row.status == 0">待使用</el-tag>
  73. <el-tag type="info" v-if="scope.row.status == 1">已使用</el-tag>
  74. </template>
  75. </el-table-column> -->
  76. <el-table-column prop="createtime" label="创建时间" width="300">
  77. <template slot-scope="scope">
  78. {{showTime(scope.row.createtime)}}
  79. </template>
  80. </el-table-column>
  81. <el-table-column fixed="right" label="操作" width="250">
  82. <template slot-scope="scope">
  83. <div class="flex"
  84. style="width: 250px;justify-content: center;align-items: center;flex-direction: column;">
  85. <i class="el-icon-loading" style="font-size: 30px;" v-if="scope.row.loading"></i>
  86. <div class="flex">
  87. <el-button v-if="scope.row.status > 2"
  88. @click="getExpressDelivery(scope.row)">查看物流</el-button>
  89. <!-- showBtn -->
  90. <template v-if="scope.row.status <= 4">
  91. <el-button v-if="showBtn(scope.row.refund_time_check) && scope.row.status > 2"
  92. @click="handleOrder('您确定立即申请退货?',scope.row)" type="primary">退货</el-button>
  93. <el-button v-else type="danger">退货</el-button>
  94. </template>
  95. </div>
  96. <el-tag type="danger" v-if="scope.row.tag"
  97. style="margin-top: 10px;">{{scope.row.tag}}</el-tag>
  98. </div>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <!-- 分页区域 -->
  103. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
  104. :current-page="queryInfo.page" :page-sizes="[10, 20, 50, 100]" :page-size="queryInfo.limit"
  105. layout="total, sizes, prev, pager, next, jumper" :total="total">
  106. </el-pagination>
  107. </el-card>
  108. <!-- 修改地址对话框 -->
  109. <el-dialog title="购买Token" :visible.sync="dialogTableVisible">
  110. <el-form :model="form">
  111. <el-form-item label="购买数量" :label-width="formLabelWidth">
  112. <el-input v-model="form.num" type="number"></el-input>
  113. </el-form-item>
  114. <el-form-item label="交易密码" :label-width="formLabelWidth">
  115. <el-input v-model="form.transaction" type="password"></el-input>
  116. </el-form-item>
  117. </el-form>
  118. <div slot="footer" class="dialog-footer">
  119. <el-button @click="dialogTableVisible = false">取 消</el-button>
  120. <el-button type="primary" @click="goBuy">确 定</el-button>
  121. </div>
  122. </el-dialog>
  123. <el-dialog title="物流进度" :visible.sync="logProgDialogVisible" width="30%">
  124. <el-timeline>
  125. <el-timeline-item v-for="(activity, index) in logProgInfo" :key="index" :timestamp="activity.time">
  126. {{ activity.context }}
  127. </el-timeline-item>
  128. </el-timeline>
  129. </el-dialog>
  130. <div class="mb" v-if="yjloading"></div>
  131. </div>
  132. </template>
  133. <script>
  134. import {
  135. mapState,
  136. mapMutations
  137. } from 'vuex';
  138. import {
  139. createCode,
  140. getCodeList,
  141. createToken,
  142. getTokenList,
  143. getExpressDelivery
  144. } from '@/request/agent.js'
  145. import {
  146. getOrderList,
  147. batchOrder
  148. } from '@/request/user.js'
  149. import {
  150. showTime
  151. } from '@/assets/js/tools.js'
  152. import {
  153. Switch
  154. } from 'element-ui'
  155. export default {
  156. name: 'Order',
  157. data() {
  158. return {
  159. today: new Date(new Date().setHours(0,0,0,0)-0*24*60*60*1000).getTime(),
  160. newTime: new Date().getTime(),
  161. yjloading: false,
  162. logProgInfo: [],
  163. logProgDialogVisible: false,
  164. loading: false,
  165. formLabelWidth: '80px',
  166. form: {
  167. num: '',
  168. transaction: ''
  169. },
  170. dialogTableVisible: false,
  171. queryInfo: {
  172. token: '',
  173. page: 1,
  174. limit: 10
  175. },
  176. list: [],
  177. total: 0,
  178. dataloading: false,
  179. sqtkitem: {},
  180. num: 0,
  181. }
  182. },
  183. created() {
  184. },
  185. computed: {
  186. ...mapState(['orderToken'])
  187. },
  188. mounted() {
  189. if (this.orderToken.length == 0) {
  190. } else {
  191. this.queryInfo.token = this.orderToken.join(',')
  192. this.getList()
  193. }
  194. },
  195. filters: {
  196. showStatus(val) {
  197. let str = ''
  198. if (val) {
  199. switch (val) {
  200. case 0:
  201. str = '待支付'
  202. break;
  203. case 1:
  204. str = '待发货'
  205. break;
  206. case 2:
  207. str = '待收货'
  208. break;
  209. case 3:
  210. str = '已收货'
  211. break;
  212. case 4:
  213. str = '退款'
  214. break;
  215. case 5:
  216. str = '赔付'
  217. break;
  218. case 6:
  219. str = '结算'
  220. break;
  221. case 7:
  222. str = '结束'
  223. break;
  224. default:
  225. break;
  226. }
  227. }
  228. return str
  229. }
  230. },
  231. methods: {
  232. ...mapMutations(['setOrderToken']),
  233. showTime,
  234. showBtn(time) {
  235. return this.newTime >= time * 1000
  236. },
  237. //加载token文件
  238. readTxtFile(refs) {
  239. let that = this
  240. const input = this.$refs[refs]
  241. const file = input.files[0]
  242. const reader = new FileReader()
  243. reader.onload = (e) => {
  244. let srt = e.target.result.replace(/\n\r/g, ',').replace(/\r\n/g, ',')
  245. let arr = srt.split(',').filter(item => item !== '')
  246. that.setOrderToken(arr)
  247. that.queryInfo.token = that.orderToken.join(',')
  248. that.getList('reload')
  249. }
  250. reader.readAsText(file)
  251. },
  252. getExpressDelivery(item) {
  253. getExpressDelivery({
  254. code: item.deliverycode,
  255. sn: item.delivery_sn
  256. }).then(res => {
  257. console.log(res);
  258. this.logProgInfo = res.data.data.map(item => {
  259. item.time = item.time.split(' ')[1]
  260. return item
  261. })
  262. this.logProgDialogVisible = true
  263. })
  264. },
  265. handleOrder(tit, item) {
  266. // batchOrder({
  267. // id: item.id,
  268. // status: item.status
  269. // }).then(res => {
  270. // // console.log(res);
  271. // item.tag = res.msg
  272. // })
  273. if (item.loading || this.loading) {
  274. return
  275. }
  276. this.$confirm(tit, '提示', {
  277. confirmButtonText: '确定',
  278. cancelButtonText: '取消',
  279. callback: action => {
  280. if (action == 'confirm') {
  281. item.loading = true
  282. this.loading = true
  283. batchOrder({
  284. id: item.id,
  285. }).then(res => {
  286. // console.log(res);
  287. item.loading = false
  288. item.tag = res.msg
  289. this.$msg.success('已提交,请等待审核处理')
  290. this.loading = false
  291. }).catch(err => {
  292. item.loading = false
  293. this.loading = false
  294. })
  295. }
  296. }
  297. });
  298. },
  299. sqlp(item) {
  300. },
  301. oneWork(arr, i = 0) {
  302. // batchOrder({
  303. // id: 0
  304. // }).then(res => {
  305. // this.$msg.success(res.msg)
  306. // this.getList()
  307. // })
  308. console.log('ddd');
  309. let that = this
  310. that.yjloading = true
  311. if (i < arr.length) {
  312. if(arr[i].lasttime*1000 > this.today) {
  313. ++this.num
  314. }
  315. if (arr[i].status < 5 && arr[i].lasttime*1000 < this.today) {
  316. if (arr[i].loaded) {
  317. that.oneWork(arr, ++i)
  318. } else {
  319. arr[i].loading = true
  320. setTimeout(() => {
  321. batchOrder({
  322. id: arr[i].id,
  323. status: arr[i].status
  324. }).then(res => {
  325. arr[i].tag = res.msg
  326. arr[i].loading = false
  327. arr[i].loaded = true
  328. that.oneWork(arr, ++i)
  329. }).catch(err => {
  330. console.log(i);
  331. arr[i].loading = false
  332. that.yjloading = false
  333. })
  334. }, 2000)
  335. }
  336. } else {
  337. that.oneWork(arr, ++i)
  338. }
  339. } else {
  340. that.yjloading = false
  341. console.log(that.num);
  342. if(that.num != that.list.length) {
  343. that.num = 0
  344. this.getList('yjcl')
  345. }else {
  346. that.$msg.success('一键处理完成')
  347. }
  348. }
  349. },
  350. handleSelectionChange(val) {
  351. console.log(val);
  352. },
  353. openBuy() {
  354. this.dialogTableVisible = true
  355. },
  356. goBuy() {
  357. let that = this
  358. if (that.loading) {
  359. return
  360. }
  361. if (!that.form.num) {
  362. return that.$msg.error('请输入购买数量')
  363. }
  364. if (!that.form.transaction) {
  365. return that.$msg.error('请输入交易密码')
  366. }
  367. that.loading = true
  368. createToken(that.form).then(res => {
  369. console.log(res);
  370. that.$msg.success('购买成功')
  371. that.dialogTableVisible = false
  372. that.loading = false
  373. that.getList('reload')
  374. }).catch(err => {
  375. that.loading = false
  376. })
  377. },
  378. getList(type) {
  379. let that = this
  380. if (that.dataloading) {
  381. return
  382. }
  383. if (type == 'reload') {
  384. that.queryInfo.page = 1
  385. }
  386. that.dataloading = true
  387. getOrderList(that.queryInfo).then(res => {
  388. that.total = res.data.count
  389. that.list = res.data.data.map(item => {
  390. item.loading = false
  391. item.loaded = false
  392. return item
  393. })
  394. that.dataloading = false
  395. if (type == 'yjcl') {
  396. that.oneWork(this.list)
  397. }
  398. }).catch(err => {
  399. that.dataloading = false
  400. })
  401. },
  402. handleSizeChange(newPageSize) {
  403. this.queryInfo.limit = newPageSize
  404. this.queryInfo.page = 1
  405. this.getList()
  406. },
  407. handleCurrentChange(newPageNum) {
  408. this.queryInfo.page = newPageNum
  409. this.getList()
  410. },
  411. qrsh() {
  412. }
  413. },
  414. }
  415. </script>
  416. <style scoped lang="scss">
  417. .empty-order {
  418. width: 1376px;
  419. height: 567px;
  420. background-color: #fff;
  421. margin: auto;
  422. position: relative;
  423. }
  424. .dr-wrap {
  425. width: 140px;
  426. height: 125px;
  427. position: absolute;
  428. top: 0;
  429. left: 0;
  430. right: 0;
  431. bottom: 0;
  432. margin: auto;
  433. border: 1px #999 dashed;
  434. border-radius: 5px;
  435. display: flex;
  436. flex-direction: column;
  437. justify-content: center;
  438. align-items: center;
  439. font-size: 12px;
  440. .dr-icon {
  441. font-size: 32px;
  442. color: #007aff;
  443. }
  444. .dr-tit {
  445. margin-top: 20px;
  446. }
  447. // .dr-int {
  448. // width: 140px;
  449. // height: 125px;
  450. // }
  451. }
  452. .dr-int {
  453. position: absolute;
  454. top: 0;
  455. left: 0;
  456. width: 100%;
  457. height: 100%;
  458. outline: medium none;
  459. cursor: pointer;
  460. -moz-opacity: 0;
  461. opacity: 0;
  462. filter: alpha(opacity=0);
  463. }
  464. .redr {
  465. position: relative;
  466. margin-right: 20px;
  467. }
  468. .mb {
  469. position: absolute;
  470. top: 0;
  471. left: 0;
  472. z-index: 999;
  473. margin: auto;
  474. width: 100%;
  475. height: 100%;
  476. }
  477. /deep/ .el-table__cell {
  478. button {
  479. padding: 6px 10px;
  480. }
  481. }
  482. </style>