<template>
  <basic-container>
    <div class="do-task">
      <div class="title"><span>服务商合规体系上传与查阅</span></div>
      <div class="form-wrapper">
        <el-form ref="formRef" :model="formData" label-width="200px">
          <el-form-item label="员工规范手册：" prop="employeeCodeHandbook">
            <uploadCom
              @updateInfo="list => updateInfo(list, 'employeeCodeHandbook')"
              :info="formData.employeeCodeHandbook"
              key="employeeCodeHandbook"
            />
          </el-form-item>
          <el-form-item label="内部控制制度手册：" prop="controlSystemManual">
            <uploadCom
              @updateInfo="list => updateInfo(list, 'controlSystemManual')"
              :info="formData.controlSystemManual"
              key="controlSystemManual"
            />
          </el-form-item>
          <el-form-item label="内部审计文件：" prop="internalAuditDocuments">
            <uploadCom
              @updateInfo="list => updateInfo(list, 'internalAuditDocuments')"
              :info="formData.internalAuditDocuments"
              key="internalAuditDocuments"
            />
          </el-form-item>
          <el-form-item label="合规管理制度：" prop="complianceMantSystem">
            <uploadCom
              @updateInfo="list => updateInfo(list, 'complianceMantSystem')"
              :info="formData.complianceMantSystem"
              key="complianceMantSystem"
            />
          </el-form-item>
          <el-form-item
            label="反腐败及反贿赂管理制度："
            prop="antiCorrAndAntiBriManSys"
          >
            <uploadCom
              @updateInfo="list => updateInfo(list, 'antiCorrAndAntiBriManSys')"
              :info="formData.antiCorrAndAntiBriManSys"
              key="antiCorrAndAntiBriManSys"
            />
          </el-form-item>
          <el-form-item
            label="员工招待管理制度："
            prop="employeeEntertainManSys"
          >
            <uploadCom
              @updateInfo="list => updateInfo(list, 'employeeEntertainManSys')"
              :info="formData.employeeEntertainManSys"
              key="employeeEntertainManSys"
            />
          </el-form-item>
          <el-form-item label="合规承诺函：" prop="complianceCommitLet">
            <uploadCom
              @updateInfo="list => updateInfo(list, 'complianceCommitLet')"
              :info="formData.complianceCommitLet"
              key="complianceCommitLet"
            />
          </el-form-item>
          <el-form-item label="内部合规培训材料：" prop="internalComTrainMater">
            <uploadCom
              @updateInfo="list => updateInfo(list, 'internalComTrainMater')"
              :info="formData.internalComTrainMater"
              key="internalComTrainMater"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <!-- <el-button size="small" @click="saveFn">保 存</el-button> -->
          <el-button type="primary" size="small" @click="submitFn"
            >提 交</el-button
          >
        </div>
      </div>
    </div>
  </basic-container>
</template>

<script>
import ElImageViewer from "element-ui/packages/image/src/image-viewer";
import uploadCom from "../components/uploadCom.vue";
import {
  compDocCreateApi,
  getCompDocApi
} from "@/api/servicePackageMonitoring/compliantUploads/index.js";
import { mapGetters } from "vuex";
export default {
  components: { ElImageViewer, uploadCom },
  data() {
    return {
      formData: {
        deptId: "",
        documentId: "",
        employeeCodeHandbook: [],
        controlSystemManual: [],
        internalAuditDocuments: [],
        complianceMantSystem: [],
        antiCorrAndAntiBriManSys: [],
        employeeEntertainManSys: [],
        complianceCommitLet: [],
        internalComTrainMater: []
      }
    };
  },
  computed: mapGetters(["userInfo"]),
  mounted() {
    this.getInfo();
  },
  methods: {
    updateInfo(list, type) {
      // console.log("list", list);
      this.formData[type] = list;
    },
    async getInfo() {
      const res = await getCompDocApi(this.userInfo.deptId);
      if (res.data.data) {
        this.formData = res.data.data;
      }
    },
    async submitFn() {
      this.formData.deptId = this.userInfo.deptId;
      const res = await compDocCreateApi(this.formData);
      if (res.data.data) {
        this.$message.success("保存成功");
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.do-task {
  position: relative;

  .title {
    font-weight: 600;
    font-size: 18px;
    color: #333;
  }
  .form-wrapper {
    margin-top: 36px;

    .input-num-box {
      ::v-deep .el-input__inner {
        text-align: left;
      }
    }
  }
}
</style>
