index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. <span>关键字:</span>
  10. <el-input @keyup.enter.native="_searchOrderData(1)" ref="searchOrderNumber" v-model="searchOrderNumber" value="" placeholder="留言内容、备注"></el-input>
  11. <el-button type="primary" @click="_searchOrderData(1)" color='red'>筛选</el-button>
  12. <el-button type="success" @click="active = {file: ''}" color='red' style="float: right">上传</el-button>
  13. </div>
  14. <div class="order-check_bottom">
  15. <div class="order-management-table">
  16. <el-table ref="order_table" @expand-change="_getOrderDetail" class='e-table' :data="orders" style="width: 100%">
  17. <el-table-column prop="id" label="序号">
  18. </el-table-column>
  19. <!-- <el-table-column prop="name" label="名称">
  20. </el-table-column> -->
  21. <el-table-column prop="description" label="描述">
  22. </el-table-column>
  23. <el-table-column prop="version" label="版本">
  24. </el-table-column>
  25. <el-table-column prop="fileUrl" label="文件地址">
  26. </el-table-column>
  27. <el-table-column prop="state" label="状态">
  28. <template slot-scope="scope">
  29. <el-switch @change="updateAduitStatus(scope.row.id,scope.row.status)" :value="scope.row.status === 'A'" active-color="#13ce66" inactive-color="#ff4949">
  30. </el-switch>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="发布日期">
  34. <template slot-scope="scope">
  35. <div>{{new Date(scope.row.createTime).format('yyyy-MM-dd hh:mm:ss')}}</div>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. </div>
  40. <div class="order-management-pagination">
  41. <el-pagination @current-change="handleCurrentChange" :current-page.sync="currentPage" :page-size="10" layout="total, prev, pager, next, jumper" :total="total">
  42. </el-pagination>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <el-dialog width="750px" title="添加版本" :visible.sync="active">
  48. <el-form v-if="active" label-width="80px">
  49. <el-form-item label="版本" width="100%">
  50. <el-input v-model="active.version"></el-input>
  51. </el-form-item>
  52. <el-form-item label="描述" width="100%">
  53. <el-input type="textarea" v-model="active.description" :rows="5"></el-input>
  54. </el-form-item>
  55. <el-form-item label="文件" width="100%">
  56. <div class="upload-file">
  57. <el-button type="primary">文件上传</el-button>
  58. <input type="file" @change="active.file = $event.target.value" ref="file">
  59. <p>{{active.file}}</p>
  60. </div>
  61. </el-form-item>
  62. </el-form>
  63. <div slot="footer" class="dialog-footer">
  64. <el-button @click="active = null">取 消</el-button>
  65. <el-button type="primary" @click="updateMaker">确 定</el-button>
  66. </div>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. export default {
  72. name: 'order-check',
  73. data () {
  74. return {
  75. type: 3,
  76. active: null,
  77. colors: [
  78. '#08e2c0', '#39bafe', '#fce439', '#fda000', '#f96d6c'
  79. ],
  80. statusMap: {
  81. unprocessed: '未处理',
  82. processed: '已确认',
  83. completed: '已完成',
  84. invalid: '已取消'
  85. },
  86. payMap: {
  87. '0': '微信',
  88. '1': '支付宝',
  89. '2': 'paypal',
  90. '3': '其他',
  91. '4': '货到付款'
  92. },
  93. paymentStatusMap: {
  94. unpaid: '未付款',
  95. paid: '已付款',
  96. cancel: '已取消',
  97. partPayment: '部分支付',
  98. partRefund: '部分退款',
  99. refunded: '全额退款'
  100. },
  101. tabs: [{ name: '全部', idx: -1 }, { name: '未支付', idx: 0 }, { name: '待发货', idx: 1 }, { name: '已发货', idx: 2 }, { name: '已完成', idx: 3 }],
  102. expandedArr: [],
  103. orders: [],
  104. currentPage: 1,
  105. key_input: '',
  106. fullscreenLoading: false,
  107. product: {
  108. 'name': '',
  109. 'packageName': '',
  110. 'count': '',
  111. 'amount': '',
  112. 'url': ''
  113. },
  114. receive: {
  115. 'name': '',
  116. 'phone': '',
  117. 'address': '',
  118. 'invoice': '',
  119. 'expressNum': ''
  120. },
  121. total: 0,
  122. options: [{
  123. value: undefined,
  124. label: '全部筛选订单'
  125. }, {
  126. value: 0,
  127. label: '未支付筛选订单'
  128. }, {
  129. value: 1,
  130. label: '待发货筛选订单'
  131. }, {
  132. value: 2,
  133. label: '已发货筛选订单'
  134. }, {
  135. value: 3,
  136. label: '已完成筛选订单'
  137. }],
  138. selectValue: '',
  139. // expressNum_input: "",
  140. searchDate: [],
  141. searchOrderNumber: '',
  142. searchPhone: '',
  143. searchExpressNum: '',
  144. hasClickSearch: false,
  145. tabIndex: -1,
  146. pickerOptions2: {
  147. shortcuts: [{
  148. text: '最近一周',
  149. onClick (picker) {
  150. const end = new Date()
  151. const start = new Date()
  152. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  153. picker.$emit('pick', [start, end])
  154. }
  155. }, {
  156. text: '最近一个月',
  157. onClick (picker) {
  158. const end = new Date()
  159. const start = new Date()
  160. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  161. picker.$emit('pick', [start, end])
  162. }
  163. }, {
  164. text: '最近三个月',
  165. onClick (picker) {
  166. const end = new Date()
  167. const start = new Date()
  168. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  169. picker.$emit('pick', [start, end])
  170. }
  171. }]
  172. }
  173. }
  174. },
  175. methods: {
  176. makerClick (item) {
  177. this.active = item
  178. },
  179. async updateAduitStatus (id, status) {
  180. let m = status === 'A' ? 'I' : 'A'
  181. let data = (await this.$http.get('/manager/goods/version/update/' + id + '/' + m))
  182. this._searchOrderData(this.currentPage)
  183. },
  184. async updateMaker () {
  185. var formData = new FormData()
  186. formData.append('version', this.active.version)
  187. formData.append('type', this.type)
  188. formData.append('description', this.active.description)
  189. formData.append('file', this.$refs.file.files[0])
  190. await this.$http({
  191. url: '/manager/goods/version/upload',
  192. method: 'post',
  193. data: formData,
  194. processData: false,
  195. contentType: false
  196. })
  197. alert('添加成功')
  198. this.active = null
  199. this._searchOrderData(this.currentPage)
  200. },
  201. handleClick (row) {
  202. console.log(this.status)
  203. console.log(this.selectValue)
  204. },
  205. async saveRow (row, item) {
  206. let expressNum = item.receive.expressNum
  207. var pattern = /^[\u4E00-\u9FA5]{1,5}$/
  208. if (pattern.test(expressNum)) {
  209. this.$alert('快递单号不能为中文', '提示', {
  210. confirmButtonText: '确定',
  211. callback: action => {
  212. }
  213. })
  214. }
  215. let data = await this.$http.post('/manager/order/confirmDelivery', {
  216. orderId: row.id,
  217. orderItemIds: item.id,
  218. expressName: item.receive.expressName,
  219. expressNum: expressNum
  220. })
  221. if (data.code === 0) {
  222. this.$message({
  223. message: '发货成功!',
  224. type: 'success'
  225. })
  226. } else {
  227. this.$alert('保存失败', '提示', {
  228. confirmButtonText: '确定',
  229. callback: action => {}
  230. })
  231. }
  232. // request['saveExpressNum']({
  233. // orderId,
  234. // expressNum
  235. // }, 'get').then(res => {
  236. // if (res === 1) {
  237. // // this.$refs.order_table.toggleRowExpansion(row, false)
  238. // row.status = '已发货'
  239. // this.$message({
  240. // message: '发货成功!',
  241. // type: 'success'
  242. // })
  243. // } else {
  244. // this.$alert('保存失败', '提示', {
  245. // confirmButtonText: '确定',
  246. // callback: action => {
  247. // }
  248. // })
  249. // }
  250. // })
  251. },
  252. hideRow (row) {
  253. this.$refs.order_table.toggleRowExpansion(row, false)
  254. },
  255. handleCurrentChange (val) {
  256. let page = val
  257. if (this.total > 0 && !this.hasClickSearch) {
  258. this._searchOrderData(page)
  259. } else {
  260. this._searchOrderData(page)
  261. }
  262. },
  263. clickTabItem (idx) {
  264. this.tabIndex = idx
  265. this.hasClickSearch = false
  266. this.total = 0
  267. this.currentPage = 1
  268. this.status = this.tabIndex === -1 ? null : this.tabIndex
  269. if (!this.searchDate || this.expressNum || !this.userName || !this.orderNum) {
  270. this._searchOrderData()
  271. }
  272. },
  273. async _searchOrderData (page) {
  274. this.hasClickSearch = true
  275. let date1, date2, userName, expressNum, orderNum
  276. this.date1 = this.searchDate ? this.searchDate[0] : null
  277. this.date2 = this.searchDate ? this.searchDate[1] : null
  278. date1 = this.date1 ? (this.date1 + ' 00:00:00') : null
  279. date2 = this.date2 ? (this.date2 + ' 23:59:59') : null
  280. this.userName = userName = this.searchPhone || null
  281. this.expressNum = expressNum = this.searchExpressNum || null
  282. this.orderNum = orderNum = this.searchOrderNumber || null
  283. // console.log(searchDate,searchPhone,searchExpressNum,searchOrderNumber)
  284. this.fullscreenLoading = true
  285. let status = this.status
  286. let para = {
  287. pageNum: page - 1,
  288. // type: status,
  289. type: this.type,
  290. startDate: date1,
  291. endDate: date2,
  292. itemName: orderNum || '',
  293. // phoneNum: userName,
  294. pageSize: 10
  295. }
  296. let url = '/manager/goods/version/list'
  297. let method = 'get'
  298. let data
  299. if (para.startDate || para.endDate || para.itemName) {
  300. url = '/manager/goods/version/search'
  301. method = 'post'
  302. }
  303. console.log(method, para)
  304. if (method === 'get') {
  305. let paras = []
  306. Object.keys(para).forEach(k => {
  307. if (para[k] || typeof para[k] === 'number') {
  308. paras.push(`${k}=${para[k]}`)
  309. } else {
  310. paras.push(`${k}=''`)
  311. }
  312. })
  313. para = paras.join('&')
  314. data = (await this.$http[method](url + '?' + para)).data
  315. } else {
  316. data = (await this.$http[method](url, para)).data
  317. }
  318. this.fullscreenLoading = false
  319. let temp = data.list
  320. for (var i = 0; i < temp.length; i++) {
  321. // temp[i]['expressNum_input'] = "";
  322. temp[i].items = []
  323. }
  324. this.orders = temp
  325. this.currentPage = page
  326. this.total = data.total
  327. },
  328. _exportExcelForOrder () {
  329. let date1, date2, userName, expressNum, orderNum
  330. this.date1 = this.searchDate ? this.searchDate[0] : null
  331. this.date2 = this.searchDate ? this.searchDate[1] : null
  332. date1 = this.date1 ? (this.date1 + ' 00:00:00') : null
  333. date2 = this.date2 ? (this.date2 + ' 23:59:59') : null
  334. this.userName = userName = this.searchPhone || null
  335. this.expressNum = expressNum = this.searchExpressNum || null
  336. this.orderNum = orderNum = this.searchOrderNumber || null
  337. let status = this.status
  338. let data = {
  339. 'type': this.status,
  340. 'startDate': date1,
  341. 'endDate': date2,
  342. 'orderSn': orderNum,
  343. 'phoneNum': userName,
  344. 'expressNum': expressNum
  345. }
  346. this.fullscreenLoading = true
  347. console.error(data)
  348. this.$confirm('确定当前标签下的订单记录?', '导出订单', {
  349. confirmButtonText: '确定',
  350. cancelButtonText: '取消',
  351. type: 'warning'
  352. }).then(async () => {
  353. let exec = await this.$http({
  354. methods: 'get',
  355. params: data,
  356. url: '/manager/order/export',
  357. responseType: 'arraybuffer'
  358. })
  359. try {
  360. let blob = new Blob([exec], {type: 'application/vnd.ms-excel'})
  361. let url = URL.createObjectURL(blob)
  362. location.href = url
  363. } catch (e) {
  364. console.error(e)
  365. }
  366. this.fullscreenLoading = false
  367. }).catch(() => {
  368. this.$message({
  369. type: 'info',
  370. message: '已取消导出'
  371. })
  372. this.fullscreenLoading = false
  373. })
  374. },
  375. async _getOrderDetail (row) {
  376. this.fullscreenLoading = true
  377. let data = (await this.$http.post('/manager/order/detail', {orderId: row.id})).data
  378. let temp = this.orders.find(item => item.id === row.id)
  379. temp.items = data.orderItems.map(item => {
  380. return {
  381. ...item,
  382. product: {
  383. url: item.pic,
  384. name: item.goodsName,
  385. packageName: item.description,
  386. count: item.goodsCount,
  387. amount: item.goodsPrice
  388. },
  389. receive: {
  390. name: data.shipName,
  391. phone: data.shipMobile,
  392. address: data.shipAddress,
  393. invoice: data.invoice,
  394. expressNum: item.expressNum,
  395. expressName: item.expressName
  396. }
  397. }
  398. })
  399. console.log(temp)
  400. this.fullscreenLoading = false
  401. }
  402. },
  403. mounted () {
  404. // console.log(window.location.origin)
  405. // window.open(window.location.origin+'/main')
  406. this._searchOrderData(1)
  407. }
  408. }
  409. </script>
  410. <style scoped>
  411. @import url('./style.css');
  412. </style>
  413. <style type="text/css">
  414. .el-table__expand-icon>i {
  415. display: none !important;
  416. }
  417. </style>