tab.vue 1.37 KB
<template>
  <div>
    <select-comp :cb="onClick">
      <img src="~assets/floor-recommend.png" alt="" srcset="" width="100%">
    </select-comp>

    <Modal
      v-model="show"
      title="商品池资源位"
      @on-ok="onOk"
      @on-cancel="onCancel"
    >
      <tab-editor :list.sync="list"></tab-editor>
    </Modal>
  </div>
</template>

<script>
import selectComp from './select-comp';
import tabEditor from './tab-editor';
import ResourceService from '@/service/resource-service';
import util from '@/libs/util';

export default {
  name: 'tab',
  props: ['data'],
  data() {
    return {
      show: false,
      list: util.clone(this.data)
    }
  },
  mounted() {
    this.resourceService = new ResourceService();
  },
  methods: {
    onClick() {
      this.show = true;
    },
    onOk() {
      const updateVal = this.list.map((i) => {
        return {
          id: i.id,
          poolId: i.poolId
        }
      })

      this.resourceService.editGoodsPool(updateVal).then(result => {
        this.$bus.$emit('updated');

        if (result.code !== 200) {
          this.$Message.error('保存失败')
          return;
        }
        this.$Message.success('保存成功')
      })
    },
    onCancel() {
      this.list = util.clone(this.data)
      this.$bus.$emit('updated');
    },
  },
  components: {
    selectComp,
    tabEditor
  }
}
</script>

<style>

</style>