<template>
  <div>
    <el-dialog title="规格变更" append-to-body :visible.sync="addData.dialog" width="70%">
      <spec :item-data="addData.data" ref="spec"></spec>
      <span slot="footer" class="dialog-footer">
        <el-button type="ghost" @click="addData.dialog = false">取 消</el-button>
        <el-button type="primary" @click="ok">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
/* global $ */
import { modifyResource } from 'services/services/product'

import spec from '@/views/personal/apply/components/UpgradePublicSpec.vue'
export default {
  components: { spec },
  props: {
    addData: {
      type: Object,
      default: function () {
        return {
          data: {
            labelIds: []
          },
          dialog: false
        }
      }
    }
  },
  data() {
    return {
      flavorList: []
    }
  },
  methods: {
    ok() {
      const obj = this.$refs.spec.ok()
      if (!obj) return
      this.loading = true
      modifyResource(obj).then(data => {
        if (data.success) {
          this.$message.success(data.message)
          this.addData.dialog = false
          // if (data.data) this.$router.push({ path: `/order/${data.data}` })
        }
        this.loading = false
      })
    }
  }
}
</script>

<style></style>
