<!--
 * @Author: zwq
 * @Date: 2023-06-29 14:12:48
 * @LastEditors: zwq
 * @LastEditTime: 2023-06-30 09:03:53
 * @Description: 
-->
<template>
  <base-table border :table-props="tableProps" :table-data="tableData" @emitFun="inputChange" />
</template>

<script>
import basicAdd from "@/mixins/basic-add";
import inputArea from "./inputArea";
import selectMember from "./selectMember";
import i18n from "@/i18n";
const tableProps = [
  {
    prop: "stepName",
    label: i18n.t("disqualification.step"),
    align: "center",
  },
  {
    prop: "member",
    label: "成员",
    align: "center",
    subcomponent: selectMember,
  },
  {
    prop: "time",
    label: "时间(小时)",
    align: "center",
    subcomponent: inputArea,
  },
  {
    prop: "approver",
    label: "审批人",
    align: "center",
    subcomponent: selectMember,
  },
  {
    prop: "terminationApprover",
    label: "终止审批人",
    align: "center",
    subcomponent: selectMember,
  },
];
export default {
  components: {
    inputArea,
    selectMember,
  },
  mixins: [basicAdd],
  props: {
    roleList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      urlOptions: {
        submitURL: "/code/startEightDisciplinePreliminaryAnalysis/",
      },
      tableProps,
      visible: false,
      tableData: [
        {
          stepName: "D3",
          step: 3,
          roleList: this.roleList,
        },
        {
          stepName: "D4",
          step: 4,
          roleList: this.roleList,
        },
        {
          stepName: "D5",
          step: 5,
          roleList: this.roleList,
        },
        {
          stepName: "D6",
          step: 6,
          roleList: this.roleList,
        },
        {
          stepName: "D7",
          step: 7,
          roleList: this.roleList,
        },
        {
          stepName: "D8",
          step: 8,
          roleList: this.roleList,
        },
      ],
      id: "",
    };
  },
  computed: {
    dataRule() {
      return {
        // description: [{ required: true, message: this.$t("validate.required"), trigger: "blur" }],
      };
    },
  },
  methods: {
    init(id) {
      this.id = id;
      this.visible = true;
      this.$nextTick(() => {});
    },

    inputChange(data) {
      switch (data.sType) {
        case 1:
          this.tableData[data._pageIndex - 1][data.prop] = data[data.prop];
          break;
        case 2:
          this.tableData[data._pageIndex - 1][data.prop] = data.string
            ? data.string.split("+")[0]
            : "";
          this.tableData[data._pageIndex - 1][data.prop + "Name"] = data.string
            ? data.string.split("+")[1]
            : "";
          break;
        default:
          console.log(val);
      }
    },
    formClear() {},
    // 表单提交
    dataFormSubmit() {
        let putData = {
          eightDisciplineStatus: 3,
          examineStatus: 1,
          id: this.id,
        };
        this.$http.put("/code/startEightDiscipline", putData).then(({ data }) => {
          if (data && data.code === 0) {
            
          } else {
            this.$message.error(data.msg);
          }
        });
      this.tableData.forEach((item) => {
        item.startEightDisciplineId = this.id;
      });
      this.$http.post("/code/startEightDisciplineCreateTeam/save/list", this.tableData)
      .then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        }
        this.$message({
          message: this.$t("prompt.success"),
          type: "success",
          duration: 500,
          onClose: () => {
            this.visible = false;
            this.$emit("refreshDataList");
          },
        });
      });
    },
  },
};
</script>

<style lang="scss">
.mod-sys__menu {
  .menu-list,
  .icon-list {
    .el-input__inner,
    .el-input__suffix {
      cursor: pointer;
    }
  }
  &-icon-popover {
    width: 458px;
    overflow: hidden;
  }
  &-icon-inner {
    width: 478px;
    max-height: 258px;
    overflow-x: hidden;
    overflow-y: auto;
  }
  &-icon-list {
    width: 458px;
    padding: 0;
    margin: -8px 0 0 -8px;
    > .el-button {
      padding: 8px;
      margin: 8px 0 0 8px;
      > span {
        display: inline-block;
        vertical-align: middle;
        width: 18px;
        height: 18px;
        font-size: 18px;
      }
    }
  }
}
</style>
