<template>
  <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="120px">
    <el-form-item prop="problemType" label="问题类型">
      <el-input type="textarea" :rows="2" placeholder="请输入工艺问题" v-model="dataForm.problemType">
      </el-input>
    </el-form-item>
  </el-form>
</template>

<script>
import basicAdd from "@/mixins/basic-add";
export default {
  mixins: [basicAdd],
  data() {
    return {
      urlOptions: {
        submitURL: "/code/startEightDisciplineRootCauseAnalysis",
      },
      visible: false,
      dataForm: {
        problemType: "",
        startEightDisciplineId: "",
      },
    };
  },
  computed: {
    dataRule() {
      return {
        problemType: [{ required: true, message: this.$t("validate.required"), trigger: "blur" }],
      };
    },
  },
  methods: {
    init(data) {
      this.dataForm.startEightDisciplineId = data.id;
      this.visible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].resetFields();
      });
    },
    // 表单提交
    dataFormSubmit() {
      this.$refs["dataForm"].validate((valid) => {
        if (!valid) {
          return false;
        }
        let putData = {
          eightDisciplineStatus: 5,
          examineStatus: 1,
          id: this.dataForm.startEightDisciplineId,
        };
        this.$http.put("/code/startEightDiscipline", putData).then(({ data }) => {
          if (data && data.code === 0) {
          } else {
            this.$message.error(data.msg);
          }
        });
        this.$http
          .post(this.urlOptions.submitURL, this.dataForm)
          .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");
              },
            });
          })
          .catch(() => {});
      });
    },
  },
};
</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>
