<template>
  <a-modal
    :visible="value"
    title="编辑分类"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-form
      :form="form"
    >
      <a-form-item
        label="分类"
        v-bind="formItemLayout"
      >
        <a-input
          v-decorator="[
            'name',
            {
              initialValue:curentItem.name,
              rules: [{ required: true, message: '请输入分类名' }]
            }
          ]"
        ></a-input>
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script>
import { updateSalesUserType } from '@/api/marketingSetting/salesUser'
import salesUserMixin from './salesUserMixin.js'

export default {
  mixins: [salesUserMixin],
  props: {
    curentItem: {
      type: Object,
      default: () => {}
    },
    value: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    isMazu () {
      return ['demo', 'YINXIANGMAZU'].includes(localStorage.mgt_project)
    }
  },
  methods: {
    handleOk (e) {
      e.preventDefault()
      this.form.validateFields((err, values) => {
        if (!err) {
          values.id = this.curentItem.id
          updateSalesUserType(values).then(res => {
            this.$message.success('编辑成功。')
            this.form.resetFields()
            this.$emit('input', false)
            this.$emit('update')
          })
        }
      })
    }
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
  }
}
</script>

<style scoped>

</style>
