batchOperation.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <a-space>
  3. <a-button type="primary" @click="onOpen({condition:'',isonsale:0,status:'审核'})">批量上架</a-button>
  4. <a-button type="default" @click="onOpen({condition:'',isonsale:1})">批量下架</a-button>
  5. </a-space>
  6. <a-drawer
  7. v-model:open="open"
  8. class="custom-class"
  9. root-class-name="root-class-name"
  10. :root-style="{ color: 'blue' }"
  11. width="800px"
  12. title="商品信息"
  13. placement="right"
  14. @close="onClose"
  15. :closable="false"
  16. >
  17. <normalTable :noQuery="true" ref="list" rowKey="itemid" :param="param" size="small" :columns="utils.TBLayout('batchTable')" :tableid="utils.TBLayoutID('batchTable')" @onSelect="onSelect">
  18. <template #tb_cell="{data}">
  19. <span v-if="data.column.dataIndex == 'isonsale'">
  20. {{data.record.isonsale == 1?'上架':'下架'}}
  21. </span>
  22. </template>
  23. </normalTable>
  24. <template #extra>
  25. <a-space>
  26. <a-button @click="onClose">取消</a-button>
  27. <a-button type="primary" @click="changeIsOnSale">确定</a-button>
  28. </a-space>
  29. </template>
  30. </a-drawer>
  31. </template>
  32. <script setup>
  33. import { nextTick, ref,createVNode,defineEmits } from 'vue';
  34. import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  35. import { Modal } from 'ant-design-vue';
  36. import Api from '@/api/api'
  37. import utils from '@/utils/utils'
  38. import normalTable from '@/template/normalTable/index.vue';
  39. const emit = defineEmits(['onSuccess'])
  40. const open = ref(false)
  41. const param = ref({
  42. id:2024052710185203,
  43. content:{
  44. nocache:true,
  45. pageNumber:1,
  46. pageSize:20,
  47. where:{}
  48. }
  49. })
  50. const list = ref()
  51. const onOpen = (val)=>{
  52. open.value = true
  53. nextTick(()=>{
  54. param.value.content.where = val
  55. list.value.listData()
  56. })
  57. }
  58. const onClose = () =>{
  59. open.value = false
  60. list.value.reloadSelect()
  61. }
  62. const selection = ref([])
  63. const onSelect = (val)=>{
  64. selection.value = val
  65. }
  66. const changeIsOnSale = async ()=> {
  67. Modal.confirm({
  68. title: `${param.value.content.where.isonsale == 1?'下架':'上架'}商品`,
  69. icon: createVNode(ExclamationCircleOutlined),
  70. content: `共选择了${selection.value.length}个商品`,
  71. okText: '确认',
  72. cancelText: '取消',
  73. async onOk() {
  74. try {
  75. console.log(param.value.content.where)
  76. const res = await Api.post({
  77. id:2024052710133903,
  78. content:{
  79. isonsale:param.value.content.where.isonsale == 1?0:1,
  80. itemids:selection.value.map(e=>e.itemid)
  81. }
  82. })
  83. utils.message(res,`${param.value.content.where.isonsale == 1?'下架':'上架'}成功`,()=>{
  84. list.value.listData()
  85. list.value.reloadSelect()
  86. emit('onSuccess')
  87. })
  88. } catch(err) {
  89. return console.log(err);
  90. }
  91. },
  92. onCancel() {},
  93. });
  94. }
  95. </script>
  96. <style>
  97. </style>