﻿<template>
  <el-dialog
    title="研判建议"
    :close-on-click-modal="false"
    :visible.sync="visible"
    class="NCC-dialog NCC-dialog_center"
    lock-scroll
    width="60%"
    v-loading="loading"
  >
    <el-row :gutter="15" class="NCC-dialog-content">
      <el-col :span="10" style="border-right: 1px solid #e6e6e6">
        <el-row>
          <el-col :span="24" class="form_title"> 巡查上报详情 </el-col>
          <el-col :span="24">
            <div class="form-item">
              <div class="label w-100">问题来源</div>
              {{ dataForm.source || "--" }}
            </div>
          </el-col>
          <el-col :span="24">
            <div class="form-item">
              <div class="label w-100">系统名称</div>
              {{ dataForm.platformName || "--" }}
            </div>
          </el-col>
          <el-col :span="24">
            <div class="form-item">
              <div class="label w-100">系统类型</div>
              {{ dataForm.platformType || "--" }}
            </div>
          </el-col>
          <el-col :span="24">
            <div class="form-item">
              <div class="label w-100">问题类型</div>
              {{ dataForm.questionType || "--" }}
            </div>
          </el-col>
          <template v-if="dataForm.questionType == '错误表述'">
            <el-col :span="24">
              <div class="form-item">
                <div class="label w-100">正确描述</div>
                {{ dataForm.accurateDescription || "--" }}
              </div>
            </el-col>
            <el-col :span="24">
              <div class="form-item">
                <div class="label w-100">错误描述</div>
                {{ dataForm.incorrectDescription || "--" }}
              </div>
            </el-col>
          </template>
          <el-col :span="24">
            <div class="form-item">
              <div class="label w-100">关键词</div>
              {{ dataForm.questionClass || "--" }}
            </div>
          </el-col>
          <el-col :span="24">
            <div class="form-item">
              <div class="label w-100">问题内容</div>
              {{ dataForm.questionContent || "--" }}
            </div>
          </el-col>
          <el-col :span="24">
            <div class="form-item">
              <div class="label w-100">有害链接</div>
              {{ dataForm.link || "--" }}
            </div>
          </el-col>
          <el-col :span="24">
            <div class="form-item">
              <div class="label w-100">取证内容</div>
            </div>
          </el-col>
        </el-row>
      </el-col>
      <el-col :span="14">
        <el-row>
          <el-col :span="24" class="form_title"> 研判建议 </el-col>
          <el-form
            ref="suggestionForm"
            :rules="rules"
            :model="suggestionForm"
            size="small"
            label-width="100px"
            label-position="right"
          >
            <!-- <el-col :span="24">
              <el-form-item
                :label="isSHILevel ? '处置要求' : '处置建议'"
                prop="disposalSuggestions"
              >
                <el-input
                  v-model="suggestionForm.disposalSuggestions"
                  placeholder="请输入处置建议"
                  show-word-limit
                  :style="{ width: '100%' }"
                  type="textarea"
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  maxlength="200"
                >
                </el-input>
              </el-form-item>
            </el-col> -->
            <!-- <el-col :span="24">
              <el-form-item label="截止时间" prop="deadline">
                <el-date-picker
                  v-model="suggestionForm.deadline"
                  type="date"
                  placeholder="选择日期"
                ></el-date-picker>
              </el-form-item>
            </el-col> -->
            <el-col :span="24">
              <el-form-item label="研判类型" prop="reviewType">
                <el-radio-group
                  v-model="suggestionForm.reviewType"
                  size="medium"
                  @change="judgmentClassChange"
                >
                  <el-radio v-for="v in judgmentClassOption" :key="v.Id" :label="v.Id">{{v.FullName}}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="24" v-if="showSuggsetion">
              <el-form-item label="研判意见" prop="judgmentOpinions">
                <el-input
                  v-model="suggestionForm.judgmentOpinions"
                  placeholder="请输入研判意见"
                  show-word-limit
                  :style="{ width: '100%' }"
                  type="textarea"
                  :autosize="{ minRows: 4, maxRows: 4 }"
                  maxlength="200"
                >
                </el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </el-col>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
import request from "@/utils/request";
import { getDictionaryDataSelector } from "@/api/systemData/dictionary";
import { getDetail, disposalSuggestions } from "@/api/systemData/dataInterface";
export default {
  components: {},
  props: [],
  data() {
    return {
      loading: true,
      visible: false,
      isDetail: true,
      dataForm: {
        id: undefined,
        platformName: undefined,
        platformType: undefined,
        questionType: undefined,
        questionClass: undefined,
        questionContent: undefined,
        link: undefined,
        obtainEvidence: [],
        annex: [],
      },
      sourceOptions: [
        { fullName: "市网信办线索", id: "市网信办线索" },
        { fullName: "自主巡查发现", id: "自主巡查发现" },
      ],
      platformTypeOptions: [],
      questionTypeOptions: [],
      questionClassOptions: [
        { fullName: "选项一", id: "1" },
        { fullName: "选项二", id: "2" },
      ],
      stageOptions: [
        { fullName: "选项一", id: "1" },
        { fullName: "选项二", id: "2" },
      ],

      suggestionForm: {
        disposalSuggestions: "", //处置建议
        judgmentOpinions: "", //判断意见
        reviewType: "", //判断分类
        deadline: "",
      },
      rules: {
        reviewType: [
          { required: true, message: "请选择审核类型", trigger: "change" },
        ],
        judgmentOpinions: [
          { required: true, message: "请填写研判意见", trigger: "bulr" }
        ]
      },
      showSuggsetion: false,
      judgmentClassOption: [],
    };
  },
  computed: {
    isSHILevel() {
      // 判断角色是否为‘市级办公室’
      return this.$store.state.user.islader;
    },
  },
  watch: {},
  created() {
    this.getplatformTypeOptions();
    this.getquestionTypeOptions();
    this.getjudgmentClassOptions();
  },
  mounted() {},
  methods: {
    getplatformTypeOptions() {
      getDictionaryDataSelector("576279943168656645").then((res) => {
        this.platformTypeOptions = res.data.list;
      });
    },
    getquestionTypeOptions() {
      getDictionaryDataSelector("577006814432855301").then((res) => {
        this.questionTypeOptions = res.data.list;
      });
    },
    getjudgmentClassOptions() {
      request({
        url: `/Extend/BaseInspectionReport/GetReviewTypeList`,
        method: 'GET',
      }).then(res => {
        this.judgmentClassOption = res.data;
      })
    },
    goBack() {
      this.$emit("refresh");
    },
    init(id, isDetail) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.showSuggsetion = false;
      this.$nextTick(async () => {
        this.$refs["suggestionForm"].resetFields();
        if (this.dataForm.id) {
          this.loading = true;
          let res = await getDetail(this.dataForm.id);
          this.dataForm = res.data;
          this.loading = false;
          if (!this.dataForm.obtainEvidence) this.dataForm.obtainEvidence = [];
          if (!this.dataForm.annex) this.dataForm.annex = [];
        }
      });
    },
    judgmentClassChange(v) {
      this.suggestionForm.judgmentOpinions = '';
      this.showSuggsetion = Boolean(v == "590769458901943557" || v == "590769521820697861");
    },
    dataFormSubmit() {
      if (
        !this.suggestionForm.disposalSuggestions &&
        !this.suggestionForm.judgmentOpinions &&
        !this.suggestionForm.reviewType
      ) {
        this.$message({
          message: "研判建议不能为空！",
          type: "danger",
        });
      }
      this.$refs["suggestionForm"].validate(async (valid) => {
        if (valid) {
          let res = await disposalSuggestions(this.dataForm);
          this.$message({
            message: res.msg,
            type: "success",
            duration: 1000,
            onClose: () => {
              (this.visible = false), this.$emit("refresh", true);
            },
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.form_title {
  line-height: 30px;
  padding-left: 40px;
  color: #409eff;
}
</style>
