index.vue 14 KB

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