order-list.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <div class="filter-box">
  5. <filter-user :filter-types="filterTypes" @select-value="handleFilterUser"></filter-user>
  6. </div>
  7. <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;"
  8. @selection-change="handleSelectionChange"
  9. :height="tool.getTableHeight()">
  10. <el-table-column type="selection" width="70" v-if="tableHeaders"></el-table-column>
  11. <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''" :prop="tableHeader.other.prop ? tableHeader.other.prop : null">
  12. <template slot-scope="scope">
  13. <template v-if="scope.row[tableHeader.index].other.tag" >
  14. <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
  15. </template>
  16. <template v-else>
  17. <div v-html="scope.row[tableHeader.index].value"></div>
  18. </template>
  19. </template>
  20. </el-table-column>
  21. <!-- <el-table-column fixed="right" label="operation" width="180">&lt;!&ndash; 操作 &ndash;&gt;-->
  22. <!-- <template slot-scope="scope">-->
  23. <!-- <el-dropdown size="small" trigger="click">-->
  24. <!-- <el-button type="primary" size="small" @click.stop="">-->
  25. <!-- Operate on this data&lt;!&ndash; 操作该数据 &ndash;&gt;<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
  26. <!-- </el-button>-->
  27. <!-- <el-dropdown-menu slot="dropdown">-->
  28. <!-- <el-dropdown-item command="edit" @click.native="handleEdit(scope.row)" v-if="permission.hasPermission(`shop/edit`)">Edit order&lt;!&ndash; 编辑订单 &ndash;&gt;</el-dropdown-item>-->
  29. <!-- <el-dropdown-item command="delivery" @click.native="handleShowDeliveryDialog(scope.row)" v-if="permission.hasPermission(`shop/order-delivery`) && scope.row['STATUS'] === '1' && scope.row['DELIVERY_STATUS'] === '0' ">deliver goods&lt;!&ndash; 发货 &ndash;&gt;</el-dropdown-item>-->
  30. <!-- <el-dropdown-item command="refund" @click.native="handleRefund(scope.row.SN)" v-if="permission.hasPermission(`shop/order-delivery`) && scope.row['PAY_TYPE'] === 'pay_stack' && scope.row['STATUS'] === '1' && scope.row['DELIVERY_STATUS'] === '0' ">Refund&lt;!&ndash; 退款 &ndash;&gt;</el-dropdown-item>-->
  31. <!-- </el-dropdown-menu>-->
  32. <!-- </el-dropdown>-->
  33. <!-- </template>-->
  34. <!-- </el-table-column>-->
  35. </el-table>
  36. <div class="white-box-footer">
  37. <el-button type="success" size="small" @click="handleExport" v-show="permission.hasPermission(`shop/order-list-export`)">Export Excel</el-button>
  38. <el-button type="primary" size="small" @click="handleExportPDF" v-show="permission.hasPermission(`shop/order-list-export`)">Export PDF</el-button>
  39. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange"
  40. @current-change="handleCurrentChange"></pagination>
  41. </div>
  42. </div>
  43. <el-dialog title="deliver goods" :visible.sync="dialogDeliveryVisible"><!-- 发货 -->
  44. <el-form :model="deliveryForm" label-width="150px" class="form-dialog">
  45. <el-form-item label="Courier Services Company"><!-- 快递公司 -->
  46. <el-input v-model="deliveryForm.expressCompany"></el-input>
  47. </el-form-item>
  48. <el-form-item label="courier number"><!-- 快递单号 -->
  49. <el-input v-model="deliveryForm.orderTrackNo"></el-input>
  50. </el-form-item>
  51. </el-form>
  52. <div slot="footer" class="dialog-footer">
  53. <el-button @click="dialogDeliveryVisible = false">Cancel<!-- 取 消 --></el-button>
  54. <el-button type="primary" @click.native="handleDelivery">deliver goods<!-- 发货 --></el-button>
  55. </div>
  56. </el-dialog>
  57. </div>
  58. </template>
  59. <script>
  60. import network from '@/utils/network'
  61. import tool from '@/utils/tool'
  62. import baseInfo from '@/utils/baseInfo'
  63. import FilterUser from '@/components/FilterUser'
  64. import permission from '@/utils/permission'
  65. import Pagination from '@/components/Pagination'
  66. import filterHelper from '@/utils/filterHelper'
  67. export default {
  68. name: 'shop_order-list',
  69. components: {FilterUser, Pagination},
  70. mounted() {
  71. this.getData()
  72. },
  73. data() {
  74. return {
  75. tableHeaders: null,
  76. tableData: null,
  77. tableHeight: window.innerHeight - 310,
  78. loading: true,
  79. multipleSelection: [],
  80. currentPage: 1,
  81. totalPages: 1,
  82. totalCount: 1,
  83. pageSize: 20,
  84. tool: tool,
  85. permission: permission,
  86. filterTypes: null,
  87. filterModel: {},
  88. dialogDeliveryVisible: false,
  89. deliveryForm: {
  90. sn: '',
  91. expressCompany: '',
  92. orderTrackNo: '',
  93. },
  94. }
  95. },
  96. methods: {
  97. handleSelectionChange(val) {
  98. this.multipleSelection = val
  99. },
  100. handleCurrentChange(page) {
  101. this.getData(page, this.pageSize)
  102. },
  103. handleSizeChange(pageSize) {
  104. this.getData(this.currentPage, pageSize)
  105. },
  106. handleFilterUser(filterData) {
  107. filterHelper.handleFilterUser(this, filterData)
  108. },
  109. getData(page, pageSize) {
  110. let filterData = this.filterModel
  111. network.getPageData(this, 'shop/order-list', page, pageSize, filterData, response => {
  112. this.filterTypes = response.filterTypes
  113. this.allData = response
  114. })
  115. },
  116. handleExport(){
  117. this.$confirm(`Are you sure you want to export the current data?`, 'Hint', {//`确定要导出当前数据吗?`, '提示'
  118. confirmButtonText: 'confirm',//确定
  119. cancelButtonText: 'cancel',//取消
  120. type: 'warning'
  121. }).then(() => {
  122. return network.getData(`shop/order-list-export`, this.filterModel)
  123. }).then(response => {
  124. this.$message({
  125. message: response,
  126. type: 'success'
  127. })
  128. }).catch(response => {
  129. })
  130. },
  131. handleExportPDF() {
  132. if (this.multipleSelection.length === 0) {
  133. this.$message({
  134. message: 'Please select an order to export',//请选择一条订单导出
  135. type: 'error'
  136. })
  137. return false
  138. }
  139. // 提取订单ID
  140. let orderSnList = this.multipleSelection.map((item) => item.SN.value || '');
  141. // 去重
  142. let orderSnSet = Array.from(new Set(orderSnList))
  143. if (orderSnSet.length !== 1) {
  144. this.$message({
  145. message: 'Only one order can be exported at a time',//每次只能导出一条订单
  146. type: 'error'
  147. })
  148. return false
  149. }
  150. this.$confirm(`Are you sure you want to export the current data?`, 'Hint', {//`确定要导出当前数据吗?`, '提示'
  151. confirmButtonText: 'confirm',//确定
  152. cancelButtonText: 'cancel',//取消
  153. type: 'info'
  154. }).then(() => {
  155. // 导出时只需要订单ID即可
  156. let orderSn = orderSnSet[0]
  157. network.getData(`shop/order-list-export-pdf/${orderSn}`).then(response => {
  158. this.$message({
  159. message: response,
  160. type: 'success'
  161. })
  162. })
  163. }).catch(response => {
  164. this.$message({
  165. message: response,
  166. type: 'error'
  167. })
  168. })
  169. },
  170. handleEdit() {
  171. // 进入修改订单页面
  172. },
  173. // 显示发货对话框
  174. handleShowDeliveryDialog(row) {
  175. this.dialogDeliveryVisible = true
  176. this.deliveryForm.sn = row['SN'].value
  177. },
  178. // 发货
  179. handleDelivery() {
  180. network.postData('shop/order-delivery', this.deliveryForm).then(response => {
  181. this.$message({
  182. message: response,
  183. type: 'success'
  184. })
  185. this.dialogDeliveryVisible = false
  186. this.getData(this.currentPage, this.pageSize)
  187. }).catch(response => {
  188. this.dialogDeliveryVisible = false
  189. })
  190. },
  191. // 退款
  192. handleRefund(orderSn) {
  193. this.$confirm(`Are you sure you want to refund this order?`, 'Hint', {//`确定要将此订单退款吗?`, '提示',
  194. confirmButtonText: 'confirm',//确定
  195. cancelButtonText: 'cancel',//取消
  196. type: 'warning'
  197. }).then(() => {
  198. return network.postData(`shop/order-refund`, { sn: orderSn.value })
  199. }).then(response => {
  200. this.$message({
  201. message: response,
  202. type: 'success'
  203. })
  204. this.getData(this.currentPage, this.pageSize)
  205. }).catch(response => {
  206. this.$message({
  207. message: response,
  208. type: 'error'
  209. })
  210. })
  211. },
  212. }
  213. }
  214. </script>
  215. <style scoped>
  216. </style>