option.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <fieldset>
  3. <legend>
  4. <el-tag type="info">按需操作</el-tag>
  5. </legend>
  6. <div class="op-header">
  7. <div class="left-panel">
  8. <el-button type="primary" icon="el-icon-plus" @click="table_add()">创建商品</el-button>
  9. <el-button icon="el-icon-unlock" @click="table_batch_status(1)" :disabled="dataSelect.length>0?false:true">上架</el-button>
  10. <el-button icon="el-icon-lock" type="danger" @click="table_batch_status(2)" :disabled="dataSelect.length>0?false:true">下架</el-button>
  11. </div>
  12. </div>
  13. </fieldset>
  14. <formMain ref="formMain" @success="handleSuccess"></formMain>
  15. </template>
  16. <script>
  17. import formMain from './form';
  18. export default {
  19. components: {
  20. formMain
  21. },
  22. props: {
  23. dataSelect: { type: Array, default: () => [] },
  24. dataSelectFull: { type: Array, default: () => [] }
  25. },
  26. data(){
  27. return {
  28. }
  29. },
  30. methods: {
  31. table_add(){
  32. this.$router.push('/merchant/goods/add')
  33. },
  34. table_sync(){
  35. this.$confirm(`发起同步后,请耐心等待1-2分钟后再刷新当前数据列表`, '提示', {
  36. type: 'warning'
  37. }).then(async () => {
  38. var resp = await this.$API.category.sync.get();
  39. if (resp.code == 0) {
  40. return this.$message.error(resp.msg);
  41. }
  42. this.$message.success(resp.msg);
  43. this.$emit("success");
  44. }).catch(() => {
  45. })
  46. },
  47. table_batch_status(status){
  48. if (this.dataSelect.length == 0) {
  49. return this.$message.error("请选择修改数据")
  50. }
  51. this.$confirm(`审核中的商品不支持该操作,请确认是否有勾选审核中的商品`, '提示', {
  52. type: 'warning'
  53. }).then(async () => {
  54. var loading = this.$loading()
  55. let submitData = {"id":this.dataSelect,"value":status,"field":"status","type":"batch"};
  56. loading.close()
  57. var resp = await this.$API.merGoods.batch.post(submitData);
  58. if (resp.code == 0) {
  59. return this.$message.error(resp.msg);
  60. }
  61. this.$message.success(resp.msg);
  62. this.$emit("success");
  63. }).catch(() => {
  64. })
  65. },
  66. handleSuccess(){
  67. this.$emit("success");
  68. }
  69. }
  70. }
  71. </script>