index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <div id="order-check">
  3. <div class="order-check-body" v-loading.fullscreen.lock="fullscreenLoading">
  4. <div class="order-management-body">
  5. <div class="order-management-inner">
  6. <span>下单时间:</span>
  7. <el-date-picker size="large" v-model="searchDate" type="daterange" unlink-panels range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions2" value-format="yyyy-MM-dd" align="center">
  8. </el-date-picker>
  9. <div class="base-info">
  10. <span>订单号:</span>
  11. <el-input @keyup.enter.native="_searchOrderData(1)" ref="searchOrderNumber" v-model="searchOrderNumber" value="" placeholder="订单号"></el-input>
  12. <span>手机号:</span>
  13. <el-input @keyup.enter.native="_searchOrderData(1)" ref="searchPhone" v-model="searchPhone" value="" placeholder="手机号"></el-input>
  14. <span>快递号:</span>
  15. <el-input @keyup.enter.native="_searchOrderData(1)" ref="searchExpressNum" v-model="searchExpressNum" value="" placeholder="快递号"></el-input>
  16. <el-button type="primary" @click="_searchOrderData(1)" color='red'>筛选</el-button>
  17. </div>
  18. </div>
  19. <div class="order-check_bottom">
  20. <div class="order-management-table">
  21. <div class="order-check_tab">
  22. <ul>
  23. <li v-for="(item,index) in tabs" :key="index" :class="{'order-check_tab_li_active':item.idx==tabIndex}" @click="clickTabItem(item.idx)">{{item.name}}<span v-if="item.idx != 3" style="margin:0 10px;color: #999;font-weight: normal;">/</span></li>
  24. </ul>
  25. <div style="float: right;vertical-align: middle;">
  26. <!-- <el-select v-model="selectValue" placeholder="请选择">
  27. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  28. </el-option>
  29. </el-select> -->
  30. <el-button type="primary" @click="_exportExcelForOrder" color='red'>导出</el-button>
  31. </div>
  32. </div>
  33. <el-table ref="order_table" @expand-change="_getOrderDetail" class='e-table' :data="orders" style="width: 100%">
  34. <el-table-column label="时间">
  35. <template slot-scope="scope">
  36. <div>{{new Date(scope.row.orderTime).format('yyyy-MM-dd hh:mm:ss')}}</div>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="orderSn" label="订单号">
  40. </el-table-column>
  41. <el-table-column prop="userName" label="手机号/用户名">
  42. </el-table-column>
  43. <el-table-column prop="totalAmount" label="订单金额(元)">
  44. </el-table-column>
  45. <el-table-column prop="paymentTypeName" label="支付方式">
  46. <template slot-scope="scope">
  47. <div>{{payMap[scope.row.paymentTypeName]}}</div>
  48. </template>
  49. </el-table-column>
  50. <el-table-column prop="orderStatus" label="订单状态">
  51. <template slot-scope="scope">
  52. <div>{{paymentStatusMap[scope.row.paymentStatus]}}</div>
  53. </template>
  54. </el-table-column>
  55. <el-table-column type="expand" prop="operation" label="操作" width="150">
  56. <template slot-scope="scope">
  57. <div class="order_check_row">
  58. <div class="product_info">
  59. <div class="product_info_title">
  60. 商品信息
  61. </div>
  62. <div class="product_info_body" v-for="(item, i) in scope.row.items" :key="i">
  63. <div class="product_info_body_img">
  64. <img :src="item.product.url" class="product_img">
  65. </div>
  66. <div class="product_info_body_info">
  67. <div class="product_info_body_info_item">
  68. <span class="product_info_body_info_item_title">商品名称</span>
  69. <span class="product_info_body_info_item_content">{{item.product.name}}</span>
  70. </div>
  71. <div class="product_info_body_info_item">
  72. <span class="product_info_body_info_item_title">套餐</span>
  73. <span class="product_info_body_info_item_content" v-html="item.product.packageName"></span>
  74. </div>
  75. <div class="product_info_body_info_item">
  76. <span class="product_info_body_info_item_title">数量</span>
  77. <span class="product_info_body_info_item_content">{{item.product.count}}</span>
  78. </div>
  79. <div class="product_info_body_info_item">
  80. <span class="product_info_body_info_item_title">商品单价</span>
  81. <span class="product_info_body_info_item_content">{{item.product.amount}}</span>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="order_info">
  87. <div class="order_info_title">
  88. 下单信息
  89. </div>
  90. <div class="order_info_body" v-if="scope.row.items.length">
  91. <div class="order_info_body_info">
  92. <div class="order_info_body_info_item">
  93. <span class="order_info_body_info_item_title">顾客姓名</span>
  94. <span class="order_info_body_info_item_content">{{scope.row.items[0].receive.name}}</span>
  95. </div>
  96. <div class="order_info_body_info_item">
  97. <span class="order_info_body_info_item_title">电话</span>
  98. <span class="order_info_body_info_item_content">{{scope.row.items[0].receive.phone}}</span>
  99. </div>
  100. <div class="order_info_body_info_item">
  101. <span class="order_info_body_info_item_title">收货地址</span>
  102. <span class="order_info_body_info_item_content">{{scope.row.items[0].receive.address}}</span>
  103. </div>
  104. <div class="order_info_body_info_item">
  105. <span class="order_info_body_info_item_title">发票</span>
  106. <span class="order_info_body_info_item_content fix-order_info_body_info_item_content">{{scope.row.items[0].receive.invoice||'不需要发票'}}</span>
  107. </div>
  108. <div class="order_info_body_info_item" v-if="scope.row.paymentStatus != 'unpaid'">
  109. <span class="order_info_body_info_item_title">快递类别</span>
  110. <span class="order_info_body_info_item_content">
  111. <el-input
  112. v-model="scope.row.items[0].receive.expressName" maxlength="15" placeholder="请输入15位顺丰快单号"
  113. type="text" v-if="scope.row.items[0].shippingStatus != 'shipped'">
  114. </el-input>
  115. {{scope.row.items[0].shippingStatus == 'shipped'?scope.row.items[0].receive.expressName:""}}
  116. </span>
  117. </div>
  118. <div class="order_info_body_info_item" v-if="scope.row.paymentStatus != 'unpaid'">
  119. <span class="order_info_body_info_item_title">快递单号</span>
  120. <span class="order_info_body_info_item_content">
  121. <el-input
  122. v-model="scope.row.items[0].receive.expressNum" maxlength="15" placeholder="请输入15位顺丰快单号"
  123. type="text" v-if="scope.row.items[0].shippingStatus != 'shipped'">
  124. </el-input>
  125. {{scope.row.items[0].shippingStatus == 'shipped'?scope.row.items[0].receive.expressNum:""}}
  126. </span>
  127. </div>
  128. <div class="order_info_body_info_item" v-if="scope.row.paymentStatus != 'unpaid'&& scope.row.items[0].shippingStatus != 'shipped'">
  129. <span class="order_info_body_info_item_title"></span>
  130. <span class="order_info_body_info_item_content"><el-button @click="saveRow(scope.row, scope.row.items)" type="primary">保存</el-button><el-button @click="hideRow(scope.row)">取消</el-button></span>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <!-- <div v-if="">暂无数据</div> -->
  137. </template>
  138. </el-table-column>
  139. </el-table>
  140. </div>
  141. <div class="order-management-pagination">
  142. <el-pagination @current-change="handleCurrentChange" :current-page.sync="currentPage" :page-size="10" layout="total, prev, pager, next, jumper" :total="total">
  143. </el-pagination>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </template>
  150. <script>
  151. export default {
  152. name: 'order-check',
  153. data () {
  154. return {
  155. statusMap: {
  156. unprocessed: '未处理',
  157. processed: '已确认',
  158. completed: '已完成',
  159. invalid: '已取消'
  160. },
  161. payMap: {
  162. '0': '微信',
  163. '1': '支付宝',
  164. '2': 'paypal',
  165. '3': '其他',
  166. '4': '货到付款'
  167. },
  168. paymentStatusMap: {
  169. unpaid: '未付款',
  170. paid: '已付款',
  171. cancel: '已取消',
  172. partPayment: '部分支付',
  173. partRefund: '部分退款',
  174. refunded: '全额退款'
  175. },
  176. tabs: [{ name: '全部', idx: -1 }, { name: '未支付', idx: 0 }, { name: '待发货', idx: 1 }, { name: '已发货', idx: 2 }, { name: '已完成', idx: 3 }],
  177. expandedArr: [],
  178. orders: [],
  179. currentPage: 1,
  180. key_input: '',
  181. fullscreenLoading: false,
  182. product: {
  183. 'name': '',
  184. 'packageName': '',
  185. 'count': '',
  186. 'amount': '',
  187. 'url': ''
  188. },
  189. receive: {
  190. 'name': '',
  191. 'phone': '',
  192. 'address': '',
  193. 'invoice': '',
  194. 'expressNum': ''
  195. },
  196. total: 0,
  197. options: [{
  198. value: undefined,
  199. label: '全部筛选订单'
  200. }, {
  201. value: 0,
  202. label: '未支付筛选订单'
  203. }, {
  204. value: 1,
  205. label: '待发货筛选订单'
  206. }, {
  207. value: 2,
  208. label: '已发货筛选订单'
  209. }, {
  210. value: 3,
  211. label: '已完成筛选订单'
  212. }],
  213. selectValue: '',
  214. // expressNum_input: "",
  215. searchDate: [],
  216. searchOrderNumber: '',
  217. searchPhone: '',
  218. searchExpressNum: '',
  219. hasClickSearch: false,
  220. tabIndex: -1,
  221. pickerOptions2: {
  222. shortcuts: [{
  223. text: '最近一周',
  224. onClick (picker) {
  225. const end = new Date()
  226. const start = new Date()
  227. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  228. picker.$emit('pick', [start, end])
  229. }
  230. }, {
  231. text: '最近一个月',
  232. onClick (picker) {
  233. const end = new Date()
  234. const start = new Date()
  235. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  236. picker.$emit('pick', [start, end])
  237. }
  238. }, {
  239. text: '最近三个月',
  240. onClick (picker) {
  241. const end = new Date()
  242. const start = new Date()
  243. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  244. picker.$emit('pick', [start, end])
  245. }
  246. }]
  247. }
  248. }
  249. },
  250. methods: {
  251. handleClick (row) {
  252. console.log(this.status)
  253. console.log(this.selectValue)
  254. },
  255. async saveRow (row, items) {
  256. let item = items[0]
  257. let orderItemIds = items.map(item => item.id).join(',')
  258. let expressNum = item.receive.expressNum
  259. var pattern = /^[\u4E00-\u9FA5]{1,5}$/
  260. if (pattern.test(expressNum)) {
  261. this.$alert('快递单号不能为中文', '提示', {
  262. confirmButtonText: '确定',
  263. callback: action => {
  264. }
  265. });
  266. }
  267. let data = await this.$http.post('/manager/order/confirmDelivery', {
  268. orderId: row.id,
  269. orderItemIds: orderItemIds,
  270. expressName: item.receive.expressName,
  271. expressNum: expressNum
  272. })
  273. if (data.code === 0) {
  274. this.$message({
  275. message: '发货成功!',
  276. type: 'success'
  277. })
  278. } else {
  279. this.$alert('保存失败', '提示', {
  280. confirmButtonText: '确定',
  281. callback: action => {}
  282. })
  283. }
  284. // request['saveExpressNum']({
  285. // orderId,
  286. // expressNum
  287. // }, 'get').then(res => {
  288. // if (res === 1) {
  289. // // this.$refs.order_table.toggleRowExpansion(row, false)
  290. // row.status = '已发货'
  291. // this.$message({
  292. // message: '发货成功!',
  293. // type: 'success'
  294. // })
  295. // } else {
  296. // this.$alert('保存失败', '提示', {
  297. // confirmButtonText: '确定',
  298. // callback: action => {
  299. // }
  300. // })
  301. // }
  302. // })
  303. },
  304. hideRow (row) {
  305. this.$refs.order_table.toggleRowExpansion(row, false)
  306. },
  307. handleCurrentChange (val) {
  308. let page = val
  309. if (this.total > 0 && !this.hasClickSearch) {
  310. this._searchOrderData(page)
  311. } else {
  312. this._searchOrderData(page)
  313. }
  314. },
  315. clickTabItem (idx) {
  316. this.tabIndex = idx
  317. this.hasClickSearch = false
  318. this.total = 0
  319. this.currentPage = 1
  320. this.status = this.tabIndex === -1 ? null : this.tabIndex
  321. if (!this.searchDate || this.expressNum || !this.userName || !this.orderNum) {
  322. this._searchOrderData()
  323. }
  324. },
  325. async _searchOrderData (page) {
  326. this.hasClickSearch = true
  327. let date1, date2, userName, expressNum, orderNum
  328. this.date1 = this.searchDate ? this.searchDate[0] : null
  329. this.date2 = this.searchDate ? this.searchDate[1] : null
  330. date1 = this.date1 ? (this.date1 + ' 00:00:00') : null
  331. date2 = this.date2 ? (this.date2 + ' 23:59:59') : null
  332. this.userName = userName = this.searchPhone || null
  333. this.expressNum = expressNum = this.searchExpressNum || null
  334. this.orderNum = orderNum = this.searchOrderNumber || null
  335. // console.log(searchDate,searchPhone,searchExpressNum,searchOrderNumber)
  336. this.fullscreenLoading = true
  337. let status = this.status
  338. let data = (await this.$http.post('/manager/order/list', {
  339. pageNum: page,
  340. type: status,
  341. startDate: date1,
  342. endDate: date2,
  343. orderSn: orderNum,
  344. phoneNum: userName,
  345. expressNum,
  346. pageSize: 10
  347. })).data
  348. this.fullscreenLoading = false
  349. let temp = data.list
  350. for (var i = 0; i < temp.length; i++) {
  351. // temp[i]['expressNum_input'] = "";
  352. temp[i].items = []
  353. }
  354. this.orders = temp
  355. this.currentPage = page
  356. this.total = data.total
  357. },
  358. _exportExcelForOrder () {
  359. let date1, date2, userName, expressNum, orderNum
  360. this.date1 = this.searchDate ? this.searchDate[0] : null
  361. this.date2 = this.searchDate ? this.searchDate[1] : null
  362. date1 = this.date1 ? (this.date1 + ' 00:00:00') : null
  363. date2 = this.date2 ? (this.date2 + ' 23:59:59') : null
  364. this.userName = userName = this.searchPhone || null
  365. this.expressNum = expressNum = this.searchExpressNum || null
  366. this.orderNum = orderNum = this.searchOrderNumber || null
  367. let status = this.status
  368. let data = {
  369. "type": this.status,
  370. "startDate": date1,
  371. "endDate": date2,
  372. "orderSn": orderNum,
  373. "phoneNum": userName,
  374. "expressNum": expressNum,
  375. }
  376. this.fullscreenLoading = true
  377. console.error(data)
  378. this.$confirm('确定当前标签下的订单记录?', '导出订单', {
  379. confirmButtonText: '确定',
  380. cancelButtonText: '取消',
  381. type: 'warning'
  382. }).then(async () => {
  383. let exec = await this.$http({
  384. methods: 'get',
  385. params: data,
  386. url: '/manager/order/export',
  387. responseType: 'arraybuffer'
  388. })
  389. try {
  390. let blob = new Blob([exec], {type: 'application/vnd.ms-excel'})
  391. let url = URL.createObjectURL(blob)
  392. location.href = url
  393. } catch (e) {
  394. console.error(e)
  395. }
  396. this.fullscreenLoading = false
  397. }).catch(() => {
  398. this.$message({
  399. type: 'info',
  400. message: '已取消导出'
  401. })
  402. this.fullscreenLoading = false
  403. })
  404. },
  405. async _getOrderDetail (row) {
  406. this.fullscreenLoading = true
  407. let data = (await this.$http.post('/manager/order/detail', {orderId: row.id})).data
  408. let temp = this.orders.find(item => item.id === row.id)
  409. temp.items = data.orderItems.map(item => {
  410. return {
  411. ...item,
  412. product: {
  413. url: item.pic,
  414. name: item.goodsName,
  415. packageName: item.description,
  416. count: item.goodsCount,
  417. amount: item.goodsPrice
  418. },
  419. receive: {
  420. name: data.shipName,
  421. phone: data.shipMobile,
  422. address: data.shipAddress,
  423. invoice: data.invoice,
  424. expressNum: item.expressNum,
  425. expressName: item.expressName
  426. }
  427. }
  428. })
  429. console.log(temp)
  430. this.fullscreenLoading = false
  431. }
  432. },
  433. mounted () {
  434. // console.log(window.location.origin)
  435. // window.open(window.location.origin+'/main')
  436. this._searchOrderData(1)
  437. }
  438. }
  439. </script>
  440. <style scoped>
  441. @import url('./style.css');
  442. .el-icon-s-flag {
  443. cursor: pointer;
  444. }
  445. </style>
  446. <style type="text/css">
  447. .el-table__expand-icon--expanded {
  448. transform: rotate(0) !important;
  449. }
  450. .el-table__expand-icon>i {
  451. display: none !important;
  452. }
  453. .el-table__expand-icon:after {
  454. content: "\8BE6\7EC6";
  455. color: #09e1c0;
  456. cursor: pointer;
  457. }
  458. </style>