index_2.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  3. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  4. :operation="operation" :exportList="exportList">
  5. <div slot="moreSearch">
  6. <el-radio-group v-model="type" size="mini" @change="changeType">
  7. <el-radio-button label="">全部</el-radio-button>
  8. <el-radio-button :label="true">启用</el-radio-button>
  9. <el-radio-button :label="false">禁用</el-radio-button>
  10. </el-radio-group>
  11. <br><br>
  12. </div>
  13. </template-page>
  14. </template>
  15. <script>
  16. import TemplatePage from '@/components/template/template-page-1.vue'
  17. import import_mixin from '@/components/template/import_mixin.js'
  18. import { secKillGoodsSpecListPageV2, secKillGoodsSpecListPageV2Export, closeGoodsStatus, openGoodsStatus, deleteGoods } from '@/api/seckill'
  19. export default {
  20. components: { TemplatePage },
  21. mixins: [import_mixin],
  22. data() {
  23. return {
  24. type: "",
  25. statistics: {},
  26. // 事件组合
  27. optionsEvensGroup: [],
  28. // 表格属性
  29. tableAttributes: {
  30. // 启用勾选列
  31. selectColumn: false
  32. },
  33. // 表格事件
  34. tableEvents: {
  35. 'selection-change': this.selectionChange
  36. },
  37. // 勾选选中行
  38. recordSelected: [],
  39. }
  40. },
  41. computed: {
  42. // 更多参数
  43. moreParameters() {
  44. return []
  45. },
  46. },
  47. methods: {
  48. // 切换状态
  49. changeType(val) {
  50. this.$refs.pageRef.refreshList()
  51. },
  52. // 列表请求函数
  53. getList(p) {
  54. try {
  55. var pam = JSON.parse(JSON.stringify(p))
  56. if (this.type !== '') {
  57. pam.status = this.type
  58. pam.params.push({ "param": "a.status", "compare": "=", "value": this.type })
  59. }
  60. return secKillGoodsSpecListPageV2(pam)
  61. } catch (error) {
  62. console.log(error)
  63. } finally {
  64. }
  65. },
  66. // 列表导出函数
  67. exportList: secKillGoodsSpecListPageV2Export,
  68. // 表格列解析渲染数据更改
  69. columnParsing(item, defaultData) {
  70. if (item.jname === 'imgUrl') {
  71. defaultData.render = (h, { row, column, index }) => {
  72. return <div style="width: 100px; height: 100px; overflow: hidden">
  73. <el-image style="width: 100px; height: 100px" src={row.imgUrl} fit="fit"></el-image>
  74. </div>
  75. }
  76. }
  77. return defaultData
  78. },
  79. // 监听勾选变化
  80. selectionChange(data) {
  81. this.recordSelected = data
  82. },
  83. // 表格操作列
  84. operation(h, { row, index, column }) {
  85. return (
  86. <div class='operation-btns'>
  87. <el-popconfirm
  88. title={`是否确定${row.status ? "关闭" : "开启"}?`}
  89. onConfirm={() => {
  90. (row.status ? closeGoodsStatus : openGoodsStatus)({ secKillSpecId: row.secKillSpecId }).then(res => {
  91. this.$message({ type: 'success', message: `${row.status ? "关闭" : "开启"}成功!` })
  92. this.$refs.pageRef.refreshList()
  93. })
  94. }}
  95. >
  96. <el-button type="text" slot="reference">{row.status ? "关闭" : "开启"}</el-button>
  97. </el-popconfirm>
  98. <el-popconfirm
  99. title={`是否确定删除?`}
  100. onConfirm={() => {
  101. deleteGoods({ secKillSpecId: row.secKillSpecId }).then(res => {
  102. this.$message({ type: 'success', message: `删除成功!` })
  103. this.$refs.pageRef.refreshList()
  104. })
  105. }}
  106. >
  107. <el-button type="text" slot="reference">删除</el-button>
  108. </el-popconfirm>
  109. </div>
  110. )
  111. },
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped></style>