<template>
  <el-dialog
    :title="modalTitle"
    :visible.sync="modalVisible"
    :width="formLabelWidth"
    top="2vh"
    @close="handleCancel">
    <div class="mobile">
        <el-form label-width="90px" :model="form" ref="from" class="from">
                <el-form-item label="用户账号:" prop="typeName">
                    <el-input type="text" v-model="form.account" :disabled="limit.isRead"></el-input>
                </el-form-item>
                <el-form-item label="用户类型:">
                    <el-input type="text" v-model="form.customerType" :disabled="true" placeholder="类别值后台自动生成"></el-input>
                </el-form-item>
                <el-form-item label="用户昵称:">
                    <el-input type="text" v-model="form.nickName" :disabled="limit.isRead"></el-input>
                </el-form-item>
                <el-form-item label="用户姓名:">
                    <el-input type="text" v-model="form.customerName" :disabled="limit.isRead"></el-input>
                </el-form-item>
                <el-form-item label="性别:">
                    <el-radio-group v-model="form.sex" :disabled="limit.isRead">
                       <el-radio :label="1">男</el-radio>
                       <el-radio :label="0">女</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="绑定手机:">
                    <el-input type="text" v-model="form.phone" :disabled="limit.isRead"></el-input>
                </el-form-item>
                <el-form-item label="绑定微信:">
                    <el-input type="text" v-model="form.wxId" :disabled="limit.isRead"></el-input>
                </el-form-item>
                <el-form-item label="企业认证:">
                    <el-radio-group v-model="form.isCompany" :disabled="limit.isRead">
                       <el-radio :label="1">是</el-radio>
                       <el-radio :label="0">否</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="个人认证:">
                    <el-radio-group v-model="form.isValidate" :disabled="limit.isRead">
                       <el-radio :label="1">是</el-radio>
                       <el-radio :label="0">否</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="注册时间:">
                    <el-input type="text" v-model="form.createTime" :disabled="limit.isRead"></el-input>
                </el-form-item>
                <el-form-item label="用户状态:">
                    <el-radio-group v-model="form.isEnable" :disabled="limit.isRead">
                       <el-radio :label="1">启用</el-radio>
                       <el-radio :label="0">禁用</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancel">取 消</el-button>
      <el-button type="primary" @click="submit" v-if="!limit.isRead">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'addMobiel',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: 'title'
    },
    action: {
      type: String,
      default: 'add'
    },
    selectRow: {
      type: Object,
      default:null
    }
  },
  watch: {
    visible(newVal, oldVal) {
      this.modalVisible = newVal;
    },
    title(newVal, oldVal) {
      this.modalTitle = newVal;
    },
    action(newVal, oldVal) {
      this.modalAction = newVal;
    },
    selectRow(newVal, oldVal) {
      this.modalSelectRow = newVal;
    }
  },
  data() {
    return {
      modalTitle: this.title,
      modalVisible: this.visible,
      modalAction: this.action,
      modalSelectRow: this.selectRow,
      formLabelWidth: '1024px',
      //窗口权限
      limit: {
        isRead: false, //是否只读
        isAdd: false //是否可写
      },
      //表单
      form: {
        productTypeExpansions:[]
      }
    };
  },
  created() {
    switch (this.modalAction) {
      case 'view':
        this.limit.isRead = true;
        this.form = Object.assign({},this.modalSelectRow)
        break;
      default:
        break;
    }
  },
  methods: {
    //窗口关闭
    handleCancel() {
      this.$emit('closeModal', false);
    }
  }
};
</script>

<style lang="scss" scoped>

</style>
