<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; height: 400px;">
            <el-row>
              <el-col :span="24" class="form_title">线索详情{{dataForm.disteport}}</el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">问题来源：</div>
                  <div class="text">{{ dataForm.reportSourceName || "--" }}</div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">应用名称：</div>
                  <div class="text">{{ dataForm.platformNameStr || "--" }}</div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">运营主体：</div>
                  <div class="text">{{ dataForm.companyStr || "--" }}</div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">应用类型：</div>
                  <div class="text">{{ dataForm.platformTypeStr || "--" }}</div>
                </div>
              </el-col>
              <el-col
                :span="24"
                v-if="dataForm.platformType == '580634746028033285'"
              >
                <div class="form-item">
                  <div class="label w-100">归属平台：</div>
                  <div class="text">
                    {{ dataForm.selfMediaPlatformType || "--" }}
                  </div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">问题类型：</div>
                  <div class="text">{{ dataForm.questionTypeStr || "--" }}</div>
                </div>
              </el-col>
              <template v-if="dataForm.questionTypeStr == '错误表述'">
                <el-col :span="24">
                  <div class="form-item">
                    <div class="label w-100">正确描述：</div>
                    <div class="text">
                      {{ dataForm.accurateDescription || "--" }}
                    </div>
                  </div>
                </el-col>
                <el-col :span="24">
                  <div class="form-item">
                    <div class="label w-100">错误描述：</div>
                    <div class="text">
                      {{ dataForm.incorrectDescription || "--" }}
                    </div>
                  </div>
                </el-col>
              </template>
              <el-col :span="24">
            <div class="form-item">
                  <div class="label w-100">问题内容：</div>
                  <div class="text">{{ dataForm.questionContent || "--" }}</div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">链接：</div>
                  <div class="text">{{ dataForm.link || "--" }}</div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">关键词：</div>
                  <div class="text">{{ dataForm.questionClass || "--" }}</div>
                </div>
              </el-col>
              <el-col :span="24">
                <el-col class="form-item">
                  <div class="label w-100">附件：</div>
                  <div class="text">
                    <NCC-UploadFz
                    v-model="dataForm.annex"
                    :fileSize="5"
                    sizeUnit="MB"
                    :limit="9"
                    buttonText="点击上传"
                    disabled
                  />
                  </div>
                </el-col>
              </el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">所属区域：</div>
                  <div class="text">{{ dataForm.areaName || "--" }}</div>
                </div>
              </el-col>
              <el-col :span="24" v-for="(v, i) in dataForm.judgmentOpinions" :key="i" style="border: #f6f6f6 solid 1px; border-radius: 10px; padding: 8px; margin-bottom: 5px;">
                <div class="title">研判信息{{ i + 1 }}</div>
                <div class="form-item">
                  <div class="label w-120">处置类型：</div>
                  <div class="text">{{ v.State }}</div>
                </div>
                <div class="form-item">
                  <div class="label w-120">处置建议：</div>
                  <div class="text">{{ v.judgmentOpinion }}</div>
                </div>
                <div class="form-item" v-if="v.judgmentFileUrl">
                  <div class="label w-120">处置附件：</div>
                  <div class="text" style="width: calc(100% - 120px);">
                    <NCC-UploadFz v-model="v.judgmentFileUrl" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
                  </div>
                </div>
              </el-col>
              <el-col :span="24" v-for="(v, i) in dataForm.disposalSuggestions" :key="i" style="border: #f6f6f6 solid 1px; border-radius: 10px; padding: 8px; margin-bottom: 5px;">
                <div class="title">处置信息{{ i + 1 }}</div>
                <div class="form-item">
                  <div class="label w-120">处置结果：</div>
                  <div class="text">{{ v.disposalSuggestion }}</div>
                </div>
                <div class="form-item" v-if="v.disposalResultFileUrl">
                  <div class="label w-120">处置附件：</div>
                  <div class="text" style="width: calc(100% - 120px);">
                    <NCC-UploadFz v-model="v.disposalResultFileUrl" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" disabled/>
                  </div>
                </div>
              </el-col>
              <!-- <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">处置建议：</div>
                  <div class="text">
                    <div class="text" v-if="!dataForm.judgmentOpinions || !dataForm.judgmentOpinions.length">无</div>
                    <template v-else>
                      <div class="text"  v-for="v in dataForm.judgmentOpinions" :key="v">{{ v }}</div>
                    </template>
                  </div>
                </div>
              </el-col>
              <el-col :span="24">
                <div class="form-item">
                  <div class="label w-100">处置结果：</div>
                  <div class="text">
                    <div class="text" v-if="!dataForm.disposalSuggestions || !dataForm.disposalSuggestions.length">无</div>
                    <template v-else>
                      <div class="text"  v-for="v in dataForm.disposalSuggestions" :key="v">{{ v }}</div>
                    </template>
                  </div>
                </div>
              </el-col> -->
              <!-- <el-col :span="24">
                <el-col class="form-item">
                  <div class="label w-100">处置附件：</div>
                  <div class="text" v-if="dataForm.judgmentOpinions">
                    <NCC-UploadFz
                    v-model="dataForm.disposalResult"
                    :fileSize="5"
                    sizeUnit="MB"
                    :limit="9"
                    buttonText="点击上传"
                    disabled
                  />
                  </div>
                </el-col>
              </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="处置结果" 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="disposalResultFileUrl">
						      <NCC-UploadFz v-model="suggestionForm.disposalResultFileUrl" :fileSize="5" sizeUnit="MB" :limit="9" buttonText="点击上传" />
                </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()" :loading="btnLoading">确 定</el-button>
      </span>
    </el-dialog>
  </template>
  <script>
  import request from "@/utils/request";
  import infoMixin from "@/mixins/info";
  import { dynamicText } from "@/filters/index";
  import { getDictionaryDataSelector } from "@/api/systemData/dictionary";
  import { getDetail, disposalSuggestionsAPI } from "@/api/systemData/dataInterface";
  export default {
    components: {},
    mixins: [infoMixin], 
    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: "",
          area: '',
          disposalSuggestions: '', // 处置建议
          disposalResultFileUrl: [],
        },
        rules: {
          disposalSuggestions: [
            { required: true, message: "请输入处理说明", trigger: "blur" },
          ],
        },
        showSuggsetion: false,
        showarea: false,
        judgmentClassOption: [],
        areaOptions: [],
        btnLoading: false,
      };
    },
    computed: {
      isSHILevel() {
        // 判断角色是否为‘市级办公室’
        return this.$store.state.user.islader;
      },
    },
    watch: {},
    created() {
      this.initAreaTypeList();
      this.getSourceOptions();
      // this.getplatformTypeOptions();
      // this.getquestionTypeOptions();
      // this.getjudgmentClassOptions();
    },
    mounted() {},
    methods: {
      async getSourceOptions() {
        let { data } = await request({
          url: `/Extend/baseinspectionreport/GetReportSourceList`,
          method: "GET",
        });
        this.sourceOptions = data;
      },
      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;
            this.sourceOptions.length && this.dataForm.reportSource && (this.dataForm.reportSourceName = this.sourceOptions.find(v => v.Id == this.dataForm.reportSource).FullName);
            this.dataForm.areaName = dynamicText(res.data.areaId, this.areaOptions);
            console.log(this.dataForm.areaName);
            this.suggestionForm.area = res.data.areaId
            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"); // 进一步处置，不采纳
        this.showarea = Boolean(v == "590769199001896197" || v == "590769458901943557"); // 执法，进一步处置
      },
      dataFormSubmit() {
        this.$refs["suggestionForm"].validate(async (valid) => {
          if (valid) {
            let obj = {
              ...this.suggestionForm,
              id: this.dataForm.id,
            };
            this.btnLoading = true;
            let res = await disposalSuggestionsAPI(obj);
            if(res.code != 200) return this.btnLoading = false;
            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>
  