index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :export-list="exportList" :column-parsing="columnParsing"
  3. :more-parameters="moreParameters" :operation="operation()" :operation-column-width="240" :replace-or-not-map="false"
  4. :optionsEvensGroup="optionsEvensGroup" :tableAttributes="tableAttributes" :tableEvents="tableEvents">
  5. <div class="cartographer_big">
  6. <el-dialog title="编辑" width="100%" :modal="false" :visible.sync="visible" :before-close="handleClose">
  7. <Form v-if="visible" :detail-id="detailId" @back="handleClose" />
  8. </el-dialog>
  9. </div>
  10. </template-page>
  11. </template>
  12. <script>
  13. import TemplatePage from '@/components/template/template-page-1.vue'
  14. import import_mixin from '@/components/template/import_mixin.js'
  15. import operation_mixin from '@/components/template/operation_mixin.js'
  16. import Form from './form.vue'
  17. import { esGoodsList, esGoodsListExport, esGoodsDel, esGoodsTop, esGoodsBatchUpdateStatus } from '@/api/commodityManagement'
  18. export default {
  19. components: { TemplatePage, Form },
  20. mixins: [import_mixin, operation_mixin],
  21. props: {},
  22. data() {
  23. return {
  24. // 事件组合
  25. optionsEvensGroup: [
  26. [
  27. [
  28. this.optionsEvensAuth('batchListing', {
  29. click: () => {
  30. if (this.recordSelected.length === 0) {
  31. this.$message.warning('请勾选')
  32. return
  33. }
  34. esGoodsBatchUpdateStatus({
  35. ids:this.recordSelected.map(item=>item.id).join(","),
  36. status:"ON"
  37. }).then(res => {
  38. this.$message({ type: 'success', message: `设置成功!` })
  39. this.$refs.pageRef.refreshList()
  40. })
  41. }
  42. })
  43. ],
  44. [
  45. this.optionsEvensAuth('batchDelist', {
  46. click: () => {
  47. if (this.recordSelected.length === 0) {
  48. this.$message.warning('请勾选')
  49. return
  50. }
  51. esGoodsBatchUpdateStatus({
  52. ids:this.recordSelected.map(item=>item.id).join(","),
  53. status:"OFF"
  54. }).then(res => {
  55. this.$message({ type: 'success', message: `设置成功!` })
  56. this.$refs.pageRef.refreshList()
  57. })
  58. }
  59. })
  60. ]
  61. ]
  62. ],
  63. visible: false,
  64. detailId: '',
  65. // 表格属性
  66. tableAttributes: {
  67. // 启用勾选列
  68. selectColumn: true,
  69. selectable: this.selectable
  70. },
  71. // 表格事件
  72. tableEvents: {
  73. 'selection-change': this.selectionChange
  74. },
  75. recordSelected: []
  76. }
  77. },
  78. computed: {
  79. moreParameters() {
  80. return [
  81. {
  82. name: '状态',
  83. key: 'orderType',
  84. value: '',
  85. conditions: [
  86. {
  87. label: `全部`,
  88. value: ''
  89. },
  90. {
  91. label: `上架`,
  92. value: 'ON'
  93. },
  94. {
  95. label: `下架`,
  96. value: 'OFF'
  97. },
  98. {
  99. label: `已卖出`,
  100. value: 'SALE'
  101. }
  102. ]
  103. }
  104. ]
  105. }
  106. },
  107. methods: {
  108. selectable(row, index) {
  109. return ["ON", "OFF"].includes(Object.entries(row.selectMapData.status).find(([key, val]) => val == row.status)?.[0])
  110. },
  111. // 监听勾选变化
  112. selectionChange(data) {
  113. this.recordSelected = data
  114. },
  115. // 列表请求函数
  116. getList(p, cb) {
  117. if (p.orderType) {
  118. p.params.push({ param: 'a.status', compare: '=', value: p.orderType })
  119. }
  120. cb && cb(p)
  121. return esGoodsList(p)
  122. },
  123. // 列表导出函数
  124. exportList: esGoodsListExport,
  125. // 表格列解析渲染数据更改
  126. columnParsing(item, defaultData) {
  127. return defaultData
  128. },
  129. operation() {
  130. return this.operationBtn({
  131. edit: {
  132. click: ({ row, index, column }) => {
  133. this.detailId = row.id
  134. this.visible = true
  135. }
  136. },
  137. del: {
  138. prompt: "是否确定删除?",
  139. conditions: ({ row, index, column }) => {
  140. return row.status == "SALE"
  141. },
  142. click: ({ row, index, column }) => {
  143. esGoodsDel({ id: row.id }).then(res => {
  144. this.$message({ type: 'success', message: `删除成功!` })
  145. this.$refs.pageRef.refreshList()
  146. })
  147. }
  148. },
  149. topFix: {
  150. prompt: "是否确定置顶?",
  151. conditions: ({ row, index, column }) => {
  152. return !row.isTop
  153. },
  154. click: ({ row, index, column }) => {
  155. esGoodsTop({ id: row.id, isTop: true }).then(res => {
  156. this.$message({ type: 'success', message: `设置成功!` })
  157. this.$refs.pageRef.refreshList()
  158. })
  159. }
  160. },
  161. unTopFix: {
  162. prompt: "是否确定取消置顶?",
  163. conditions: ({ row, index, column }) => {
  164. return row.isTop
  165. },
  166. click: ({ row, index, column }) => {
  167. esGoodsTop({ id: row.id, isTop: false }).then(res => {
  168. this.$message({ type: 'success', message: `设置成功!` })
  169. this.$refs.pageRef.refreshList()
  170. })
  171. }
  172. }
  173. })
  174. },
  175. handleClose(obj) {
  176. this.detailId = ''
  177. this.visible = false
  178. this.$refs.pageRef.refreshList()
  179. if(obj && obj.detailId){
  180. this.$nextTick(()=>{
  181. this.detailId = obj.detailId
  182. this.visible = true
  183. })
  184. }
  185. }
  186. }
  187. }
  188. </script>
  189. <style scoped></style>