<template>
  <!-- 弹出框表单 -->
  <el-drawer
    :title="title"
    :visible.sync="open"
    :direction="direction"
    size="50%"
  >
    <div class="dra_content">
      <div class="dra_top box">
        <div class="title">异常情况</div>
        <div class="content">
          <el-row>
            <el-col :span="12"
              >员工：{{ obj.staffName ? obj.staffName : "--" }}</el-col
            >
            <el-col :span="12"
              >所属部门：{{ obj.deptName ? obj.deptName : "--" }}</el-col
            >
          </el-row>
          <el-row>
            <el-col :span="12"
              >窗口编号：{{ obj.windowNum ? obj.windowNum : "--" }}</el-col
            >
            <el-col :span="12"
              >违规类型：{{
                obj.irregularType ? obj.irregularType : "--"
              }}</el-col
            >
          </el-row>
          <el-row>
            <el-col :span="12"
              >发生时间：{{ obj.happenTime ? obj.happenTime : "--" }}</el-col
            >
            <el-col :span="12"
              >时长：{{ obj.duration ? obj.duration : "--" }}</el-col
            >
          </el-row>

          <el-row>
            <el-col :span="12"
              >报警时间：{{ obj.alarmTime ? obj.alarmTime : "--" }}</el-col
            >
            <el-col :span="12"
              >扣分方式：{{ obj.subMethod ? obj.subMethod : "--" }}</el-col
            >
          </el-row>

          <el-row>
            <el-col :span="12"
              >扣分时间：{{ obj.deductTime ? obj.deductTime : "--" }}</el-col
            >
            <el-col :span="12">
              扣分人员：{{ obj.deductPerson ? obj.deductPerson : "--" }}</el-col
            >
          </el-row>
          <el-row>
            <el-col :span="24">
              图片凭证：{{ obj.snapPath ? obj.snapPath : "--" }}</el-col
            >
          </el-row>
        </div>
      </div>
      <div class="dra_down box">
        <div class="title">核查情况</div>
        <div class="content">
          <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
              <el-form-item label="核查结果：">
                <p v-if="obj.view == '查看'">{{ obj.checkResult }}</p>
                <el-radio-group v-model="form.checkResult" v-else>
                  <el-radio :label="1">扣分</el-radio>
                  <el-radio :label="2">不扣分</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="修改规则：">
                <p v-if="obj.view == '查看'">{{ obj.ruleName }}</p>
                <div v-else>
                  <el-col :span="22">
                    <el-select
                      v-model="form.attendanceGroupId"
                      style="width: 100%;"
                    >
                      <el-option
                        v-for="item in kaoqinArr"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option
                    ></el-select>
                  </el-col>
                  <el-col :span="22">
                    <el-select
                      v-model="form.attendanceGroupId"
                      style="width: 100%;margin-top: 10px;"
                    >
                      <el-option
                        v-for="item in kaoqinArr"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option></el-select
                  ></el-col>
                </div>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="扣除分值：">
                <p v-if="obj.view == '查看'">{{ obj.score }}</p>
                <p v-else>{{ form.score }}</p>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="说明：">
                <p v-if="obj.view == '查看'">{{ obj.checkDesc }}</p>
                <el-input
                  v-else
                  v-model="form.checkDesc"
                  type="textarea"
                ></el-input>
              </el-form-item>
            </el-row>
            <el-row v-if="obj.view == '查看'">
              <el-form-item label="核查人员：">
                <p>{{ obj.checkPerson }}</p>
              </el-form-item>
            </el-row>
            <el-row v-if="obj.view == '查看'">
              <el-form-item label="核查时间：">
                <p>{{ obj.checkTime }}</p>
              </el-form-item>
            </el-row>
            <form-buttons
              v-show="obj.view == '核查'"
              @submit="submitForm"
              v-if="pageInfo.type != 'view'"
              noCancelBtn
            />
          </el-form>
        </div>
      </div>
    </div>
    <!-- <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-row>
        <Field
          label="记录ID"
          prop="recordId"
          v-model="form.recordId"
          placeholder="请输入记录ID"
        />
        <Field
          label="员工ID"
          prop="staffId"
          v-model="form.staffId"
          placeholder="请输入员工ID"
        />
        <Field
          label="员工姓名"
          prop="staffName"
          v-model="form.staffName"
          placeholder="请输入员工姓名"
        />
        <Field
          label="工号"
          prop="workNum"
          v-model="form.workNum"
          placeholder="请输入工号"
        />
        <Field
          label="窗口编号"
          prop="windowNum"
          v-model="form.windowNum"
          placeholder="请输入窗口编号"
        />
        <Field
          label="所属部门"
          prop="deptId"
          v-model="form.deptId"
          placeholder="请输入所属部门"
        />
        <Field
          label="所属部门名称"
          prop="deptName"
          v-model="form.deptName"
          placeholder="请输入所属部门名称"
        />
        <Field
          label="违规类型"
          prop="irregularType"
          v-model="form.irregularType"
          type="select"
          :enumData="dict.irregularType"
          placeholder="请选择违规类型"
        />
        <Field
          label="发生时间"
          prop="happenTime"
          v-model="form.happenTime"
          type="date"
        />
        <Field
          label="持续时间，秒"
          prop="duration"
          v-model="form.duration"
          placeholder="请输入持续时间，秒"
        />
        <Field
          label="报警时间"
          prop="alarmTime"
          v-model="form.alarmTime"
          type="date"
        />
        <Field
          label="图片凭证地址"
          prop="snapPath"
          v-model="form.snapPath"
          type="textarea"
          placeholder="请输入图片凭证地址"
        />
        <Field
          label="绩效规则id"
          prop="ruleId"
          v-model="form.ruleId"
          placeholder="请输入绩效规则id"
        />
        <Field
          label="规则名称"
          prop="ruleName"
          v-model="form.ruleName"
          placeholder="请输入规则名称"
        />
        <Field
          label="扣分方式"
          prop="subMethod"
          v-model="form.subMethod"
          type="select"
          :enumData="dict.subMethod"
          placeholder="请选择扣分方式"
        />
        <Field
          label="扣分人员"
          prop="deductPerson"
          v-model="form.deductPerson"
          placeholder="请输入扣分人员"
        />
        <Field
          label="扣分时间"
          prop="deductTime"
          v-model="form.deductTime"
          type="date"
        />
        <Field
          label="扣分或增加分值"
          prop="score"
          v-model="form.score"
          placeholder="请输入扣分或增加分值"
        />
        <Field
          label="核查人员"
          prop="checkPerson"
          v-model="form.checkPerson"
          placeholder="请输入核查人员"
        />
        <Field
          label="核查时间"
          prop="checkTime"
          v-model="form.checkTime"
          type="date"
        />
        <Field
          label="核查说明"
          prop="checkDesc"
          v-model="form.checkDesc"
          type="textarea"
          placeholder="请输入核查说明"
        />
        <Field
          label="核查结果"
          prop="checkResult"
          v-model="form.checkResult"
          placeholder="请输入核查结果"
        />
        <Field
          label="处理状态"
          prop="checkStatus"
          v-model="form.checkStatus"
          type="select"
          :enumData="dict.checkStatus"
          placeholder="请选择处理状态"
        />
        <Field
          label="备注"
          prop="remark"
          v-model="form.remark"
          type="textarea"
          placeholder="请输入备注"
        />
      </el-row>

      <form-buttons
        @submit="submitForm"
        v-if="pageInfo.type != 'view'"
        noCancelBtn
      />
    </el-form> -->
  </el-drawer>
</template>

<script>
import form from "@/assets/mixins/formdialog";
export default {
  name: "CheckEffectRecordDetail",
  mixins: [form],
  components: {},
  created() {
    this.changePath("check/effect/record");
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 弹出层标题
      title: "效能绩效核查信息",
      // 是否显示弹出层
      open: false,
      direction: "rtl",
      toString: ["irregularType", "subMethod", "checkStatus"],
      toDate: ["happenTime", "alarmTime", "deductTime", "checkTime"],
      // 表单校验
      rules: {
        staffName: [
          { required: true, message: "请输入员工姓名", trigger: "blur" },
          { max: 64, message: "最多只能录入64个字符", trigger: "blur" },
        ],
        createTime: [{ required: true, message: "请选择创建时间" }],
      },
      obj: {},
    };
  },

  methods: {
    /** 编辑 */
    edit(row) {
      this.obj = row;
      this.reset();
      this.query = { id: row.id };
      this.urls.currUrl = "check/effect/record/edit";
      this.getData();
      this.pageInfo.type = "edit";
      row.view == "核查"
        ? (this.title = "效能绩效核查")
        : (this.title = "修改效能绩效核查信息");
    },
    /** 新增 */
    add(row) {
      this.reset();
      this.urls.currUrl = "check/effect/record/add";
      this.getData();
      this.pageInfo.type = "add";
      this.title = "新增效能绩效核查信息";
    },
    /** 查看*/
    view(row) {
      this.obj = row;
      this.reset();
      this.query = { id: row.id };
      this.urls.currUrl = "check/effect/record/view";
      this.getData();
      this.pageInfo.type = "view";
      this.title = "效能绩效核查信息详细";
    },
    /**取消按钮 */
    cancel() {
      this.open = false;
    },
    /**获取数据后弹框 */
    afterRender(data) {
      this.open = true;
    },

    afterSubmit(data) {
      this.open = false;
      this.$emit("ok");
    },

    // 表单重置
    reset() {
      this.form = {
        recordId: null,
        staffId: null,
        staffName: "",
        workNum: "",
        windowNum: "",
        deptId: null,
        deptName: "",
        irregularType: null,
        happenTime: null,
        duration: 0,
        alarmTime: null,
        snapPath: "",
        ruleId: null,
        ruleName: "",
        subMethod: 1,
        deductPerson: "",
        deductTime: null,
        score: 0.0,
        checkPerson: "",
        checkTime: null,
        checkDesc: "",
        checkResult: "",
        checkStatus: 1,
        remark: "",
      };
      this.resetForm("form");
    },
    resetForm(refName) {
      if (this.$refs[refName]) {
        this.$refs[refName].resetFields();
      }
    },
  },
};
</script>

<style lang="less" scoped>
.dra_content {
  width: 100%;
  height: 100%;
  padding: 20px;
  .box {
    width: 100%;
    height: auto;
    .title {
      color: #1890ff;
      font-size: 16px;
      padding-left: 10px;
      position: relative;
      margin-bottom: 30px;
      &::after {
        content: "";
        display: block;
        border-left: 3px solid #1890ff;
        left: 0;
        top: 0;
        bottom: 0;
        position: absolute;
      }
    }
    .content {
      width: 100%;
      padding: 10px;
      font-family: "微软雅黑", sans-serif;
      font-weight: 400;
      font-style: normal;
      font-size: 14px;
      margin-left: 0 auto;
      margin-bottom: 30px;
      /deep/.el-row {
        margin-bottom: 20px;
      }
    }
  }
}
</style>
