<template>
  <div>
    <DialogCom
      :visible.sync="isShow"
      :width="'500px'"
      :title="`${id ? '编辑' : '新增'}外包履职评价计划`"
      @close="closeHandler"
      
      destroy-on-close
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="评价类型" prop="contentType">
          <el-select v-model="ruleForm.contentType" placeholder="请选择评价类型">
            <el-option
              v-for="item in dict.type.evaluate_type"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="编号" prop="code">
          <el-input v-model.number="ruleForm.code"></el-input>
        </el-form-item>
        <el-form-item label="评价内容" prop="content">
          <el-input type="textarea" v-model="ruleForm.content"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button @click="resetFormHandler('ruleForm')">取消</el-button>
          <el-button type="primary" @click="submitForm('ruleForm')"
            >确定</el-button
          >
        </el-form-item>
      </el-form>
    </DialogCom>
  </div>
</template>
<script>
import { guid } from "@/utils/index.js";
export default {
  name: "SocWebAddEvaluate",
  dicts: ["evaluate_type"],
  data() {
    return {
      ruleForm: {},
      rules: {
        contentType: [{ required: true, message: "请选择评价类型" }],
        code: [
          { required: true, message: "请选择编号" },
          { type: "number", message: "编号必须为数字值" },
        ],
        content: [{ required: true, message: "请选择评价内容" }],
      },
      id: "", //编辑时候ID
      isShow: false,
    };
  },

  mounted() {},

  methods: {
    show() {
      this.isShow = true;
    },
    resetFormHandler() {
      this.isShow = false;
    },
    closeHandler() {
      this.ruleForm = {};
    },
  

    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.ruleForm.uid) {
            //当前是编辑
          } else {
            //当前是新增
            this.ruleForm.uid = guid();
          }
          this.$emit("submitHandler", this.ruleForm);
          this.isShow = false;
        } else {
          return false;
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.el-select {
  width: 100%;
}
</style>
