pointsConfig.vue 1.78 KB
<template>
  <GLDialog
    mode="big"
    class="points-panel"
    bigTitle="选择"
    okText="提交"
    :before-close="handleGiftClose"
    @onCancel="handleGiftClose"
    @onOk="handleConfirm"
    :visible.sync="configParams.show"
  >
    <GLTabs
      v-model="currentComponent"
      :tabPaneList="tabPaneList"
    ></GLTabs>
    <div class="component">
      <gas
        v-show="currentComponent == 'gas'"
        ref="gasRef"
      />
      <service
        v-show="currentComponent == 'service'"
        ref="serviceRef"
      />
    </div>
  </GLDialog>
</template>

<script type='text/ecmascript-6'>
import service from './service.vue'
import gas from './gas.vue'
export default {
  name: '',
  components: {
    service,
    gas
  },
  props: {
    configParams: {
      type: Object,
      default: () => { }
    }
  },
  data () {
    return {
      giftVisible: true,
      currentComponent: 'gas',
      tabPaneList: [
        {
          label: '油卡',
          name: 'gas'
        },
        {
          label: '自店服务',
          name: 'service'
        }
      ]
    }
  },
  mounted () {
  },
  methods: {
    handleGiftClose () {
      this.$emit('update:configParams', {
        show: false
      })
    },
    handleConfirm () {
      const { gasRef, serviceRef } = this.$refs
      this.$emit('confirm', [...gasRef.selectedList, ...serviceRef.selectedList].map(e => {
        return {
          couponId: e.id,
          couponAmount: 1,
          couponAnticipatedCost: e.denomination || e.anticipatedCost || e.couponAnticipatedCost
        }
      }))
      this.handleGiftClose()
    }
  }
}
</script>

<style scoped lang='scss'>
.points-panel {
  /deep/.el-dialog__wrapper {
    .el-dialog__body {
      padding-top: 0;
    }
  }
}
.component {
  padding-top: 20px;
}
</style>