<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      width="600px"
      :before-close="handleClose"
      :close-on-click-modal="false"
    >
      <el-form
        :model="form"
        status-icon
        :rules="rules"
        ref="form"
        label-width="120px"
        class="demo-ruleForm"
      >
        <el-form-item label="审核人：" prop="name">

          <el-select style="width:100%;" ref="select1" v-model="form.select1" clearable filterable remote placeholder="请输入审核人" >
              <el-option v-for="item in personnelList" :key="item.value" :label="item.label" :value="item.value" :disabled="!item.value">
                <span style="float: left" >{{ item.label }}</span>
                <span style="float: right; color: #8492a6; font-size: 13px;" v-if="!item.value"><el-button size="small" >创建</el-button></span>
              </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="抄送人：">
          <el-select
            multiple
            v-model="form.value"
            placeholder="请选择抄送人"
            style="width: 100%"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="截止时间：">
          <el-date-picker
            style="width: 100%"
            v-model="form.endTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择截止日期时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审核备注：">
          <el-input
            type="textarea"
            :rows="3"
            placeholder="请输入内容"
            v-model="form.remark"
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: "",
      dialogVisible: false,
      form: {},
      rules: {
        name: [
          { required: true, message: "请输入项目审核人", trigger: "blur" },
        ],
      },
      options: [],
      checked: [],
      queryParams: {},
      personnelList: [],
    };
  },
  mounted() {
    this.getList()
  },
  methods: {
    // 远程搜索
    remoteMethod(query) { },
    change() { },
    // 打开或关闭下拉时触发
    visibleChange(){},
    open() {
      this.title = "项目审核";
      this.dialogVisible = true;
    },
    getList() {
    //   // this.queryParams.tenant = this.userinfo.tenantId
      this.$api.getAllPersonnel()
        .then((response) => {
          let allPersonnelList = response.data;
          this.personnelList = allPersonnelList.map(item => {
            return { value: `${item.id}`, label: `${item.personnelName}<${item.personnelEmail}>` };
          });
        })
    },
    //
    submit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.handleClose();
        } else {
          this.$message.error("信息未输入完整");
        }
      });
    },
    // 关闭
    handleClose() {
      this.$refs.form.resetFields();
      this.form = {};
      this.dialogVisible = false;
    },
  },
};
</script>

<style lang="scss" scoped></style>
