<template>
  <div>
    <el-form ref="form" :rules="rules"  :model="form" label-width="120px">
      <el-form-item
          label="角色名称："
          prop="role_name"
      >
        <el-input v-model="form.role_name"  placeholder="请输入角色名称"></el-input>
      </el-form-item>
     
      <el-form-item label="排序：" prop="sort">
        <el-input v-model="form.sort"  placeholder="输入排序" ></el-input>
      </el-form-item>
      <el-form-item label="备注信息：" prop="remark">
        <el-input v-model="form.remark"  placeholder="输入备注信息" ></el-input>
      </el-form-item>
      <el-form-item>
        <div style="text-align: center">
          <el-button type="primary" @click="onSubmit" :disabled="Isdisabled" :loading="isloading">保存</el-button>
          <el-button style="color: #5075FC " @click="closeDlg">取消</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  props: {
    roleDataForm: {
      type: Object,
      default: () => {}
    },
    isloading:{
      type:Boolean,
      default: true
    },
    closeDlg:{
      type:Function
    }
  },
  data() {
    return {
      form: {
        role_name: '',
        remark:"",
        sort:"",
      },
      rolelist: [],
      Isdisabled: false,
      rules: {
        role_name: [
          { required: true, message: '角色名称必填' },
        ],
        sort: [
          { pattern: /^[1-9]\d*$/, message: '排序值格式错误' },
        ]
      }
    }
  },
  mounted() {
    if(this.roleDataForm) {
      this.form = Object.assign({} , this.roleDataForm)
    }
  },
  methods: {
    closeDlg() {
      this.$emit('closeDlg',1)
    },
    onSubmit() {
      let that = this
      that.$refs['form'].validate((valid) => {
        if (valid) {
          this.$emit('roleSubmitClick', this.form)
        }
      })
    },
  }
}
</script>
<style>
.el-cascader-node>.el-radio{
  margin-top:25px;
}
</style>
