<template>
  <div id="jg_xq">
    <template>
      <el-backtop
        target="#jg_xq"
        :right="80"
        :bottom="90"
        :visibility-height="600"
        title="回到顶部"
      >
      </el-backtop>
    </template>
    <!-- <img class="back" :src="back" @click="goBack" /> -->
    <el-button
      type="warning"
      v-if="!true_edit && s_switch"
      @click="update()"
      style="position: absolute; right: 10px; top: 20px"
      >编辑</el-button
    >
    <el-button
      type="success"
      v-if="true_edit"
      @click="edit_onSubmit()"
      style="position: absolute; right: 10px; top: 20px"
      >保存</el-button
    >
    <el-button
      v-if="true_edit"
      @click="qd_update()"
      style="position: absolute; right: 10px; top: 90px"
      >取消</el-button
    >
    <span
      v-if="!true_edit && form.updateTime"
      style="margin-left: 40px; line-height: 40px;font-size: 13px;"
      >更新时间：<span style="color: #ffc14e">{{ form.updateTime }}</span></span
    >
    <div
      style="float: left; background: #293c5a2e; padding: 20px"
      :style="{ width: 'calc(100% - 360px)' }"
    >
      <div style="width: calc(100% - 20px); float: left; padding: 20px">
        <div class="img-div">
          <el-upload
            class="avatar-uploader"
            action="1"
            :show-file-list="false"
            :on-change="handleChange"
            :disabled="!true_edit"
            :file-list="fileList_head"
            :accept="file_types_head"
            :auto-upload="false"
            :limit="1"
          >
            <img
              :src="imageUrl"
              class="avatar"
              :onerror="errimg"
            />
          </el-upload>
        </div>
        <table class="table_jbxx">
          <tr>
            <td class="pub-td1" style="width:60px">机构编号</td>
            <td class="pub-td2" colspan="3">
              <span v-if="!true_edit">{{
                form.jgbh ? form.jgbh.value:''
              }}</span>
              <el-badge v-if="true_edit" value="此项修改可能会影响此节点的下级无法展示" class="item">
                <el-input
                  v-model="form.jgbh.value"
                  placeholder="请输入内容"
                ></el-input>
              </el-badge>
            </td>
          </tr>
          <tr>
            <td class="pub-td1" style="width:60px">机构番号</td>
            <td class="pub-td2">
              <span v-if="!true_edit">{{form.jgfh ? form.jgfh.value:''}}</span>
              <i v-if="$route.meta.gly && !true_edit && form.jgfh?!form.jgfh.confirmed:false" class="el-icon-question" style="color: #9a9ca0;font-size: 20px;"></i>
              <i v-if="$route.meta.gly && !true_edit && form.jgfh?form.jgfh.confirmed:false" class="el-icon-success" style="color: #12dc00;font-size: 20px;"></i>
              <el-input
                v-if="true_edit"
                v-model="form.jgfh.value"
                placeholder="请输入内容"
                :readonly="form.jgfh.confirmed"
              ></el-input>
              <i v-if="true_edit && !arr_table_comment.jgfh" class="el-icon-circle-check" style="color: #56ff7a;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm('jgfh',true)"></i>
              <i v-if="true_edit && !arr_table_comment.jgfh" class="el-icon-circle-close" style="color: #ff5656;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm('jgfh',false)"></i>
            </td>
            <td class="pub-td1" style="width:60px">机构简称</td>
            <td class="pub-td2">
              <span v-if="!true_edit">{{
                form.jgjc ? form.jgjc.value:''
              }}</span>
              <i v-if="$route.meta.gly && !true_edit && form.jgjc?!form.jgjc.confirmed:false" class="el-icon-question" style="color: #9a9ca0;font-size: 20px;"></i>
              <i v-if="$route.meta.gly && !true_edit && form.jgjc?form.jgjc.confirmed:false" class="el-icon-success" style="color: #12dc00;font-size: 20px;"></i>
              <el-input
                v-if="true_edit"
                v-model="form.jgjc.value"
                placeholder="请输入内容"
                :readonly="form.jgjc.confirmed"
              ></el-input>
              <i v-if="true_edit && !arr_table_comment.jgjc" class="el-icon-circle-check" style="color: #56ff7a;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm('jgjc',true)"></i>
              <i v-if="true_edit && !arr_table_comment.jgjc" class="el-icon-circle-close" style="color: #ff5656;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm('jgjc',false)"></i>
            </td>
          </tr>
          <tr>
            <td class="pub-td1">国家地区</td>
            <td class="pub-td2">
              <span v-if="!true_edit">{{ form.gjdq ? form.gjdq.value:'' }}</span>
              <i v-if="$route.meta.gly && !true_edit && form.gjdq?!form.gjdq.confirmed:false" class="el-icon-question" style="color: #9a9ca0;font-size: 20px;"></i>
              <i v-if="$route.meta.gly && !true_edit && form.gjdq?form.gjdq.confirmed:false" class="el-icon-success" style="color: #12dc00;font-size: 20px;"></i>
              <el-input
                v-if="true_edit"
                v-model="form.gjdq.value"
                placeholder="请输入内容"
                :readonly="form.gjdq.confirmed"
              ></el-input>
                <i v-if="true_edit && !arr_table_comment.gjdq" class="el-icon-circle-check" style="color: #56ff7a;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm('gjdq',true)"></i>
                <i v-if="true_edit && !arr_table_comment.gjdq" class="el-icon-circle-close" style="color: #ff5656;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm('gjdq',false)"></i>
            </td>
            <td class="pub-td1">机构类别</td>
            <td class="pub-td2">
              <span v-if="!true_edit">{{ form.jglb ? form.jglb.value:'' }}</span>
              <i v-if="$route.meta.gly && !true_edit && form.jglb?!form.jglb.confirmed:false" class="el-icon-question" style="color: #9a9ca0;font-size: 20px;"></i>
              <i v-if="$route.meta.gly && !true_edit && form.jglb?form.jglb.confirmed:false" class="el-icon-success" style="color: #12dc00;font-size: 20px;"></i>
              <el-input
                v-if="true_edit"
                v-model="form.jglb.value"
                placeholder="请输入内容"
                :readonly="form.jglb.confirmed"
              ></el-input>
                <i v-if="true_edit && !arr_table_comment.jglb" class="el-icon-circle-check" style="color: #56ff7a;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm('jglb',true)"></i>
                <i v-if="true_edit && !arr_table_comment.jglb" class="el-icon-circle-close" style="color: #ff5656;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm('jglb',false)"></i>
            </td>
          </tr>
          <tr v-for="(item, index) in xzzd" style="position: relative" v-if="xzzd.length>0 && index<=Math.trunc(xzzd.length/2)+Math.trunc(xzzd.length%2)-1">
            <td class="pub-td1">{{ xzzd[2*index].comment }}</td>
            <td class="pub-td2" :colspan="index==Math.trunc(xzzd.length/2)+Math.trunc(xzzd.length%2)-1?xzzd.length%2==0?'':'3':''" v-if="form.extraProperty">
              <span v-if="!true_edit">{{
              form.extraProperty[xzzd[2*index].comment]?form.extraProperty[xzzd[2*index].comment].value:''
              }}</span>
              <i v-if="$route.meta.gly && !true_edit && form.extraProperty[xzzd[2*index].comment]?!form.extraProperty[xzzd[2*index].comment].confirmed:false" class="el-icon-question" style="color: #9a9ca0;font-size: 20px;"></i>
              <i v-if="$route.meta.gly && !true_edit && form.extraProperty[xzzd[2*index].comment]?form.extraProperty[xzzd[2*index].comment].confirmed:false" class="el-icon-success" style="color: #12dc00;font-size: 20px;"></i>
              <el-input
                v-if="true_edit"
                v-model="form.extraProperty[xzzd[2*index].comment].value"
                placeholder="请输入内容"
                :readonly="form.extraProperty[xzzd[2*index].comment]?form.extraProperty[xzzd[2*index].comment].confirmed:false"
              ></el-input>
                <i v-if="true_edit && !arr_table_comment[xzzd[2*index].comment]" class="el-icon-circle-check" style="color: #56ff7a;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm(xzzd[2*index].comment,true,true)"></i>
                <i v-if="true_edit && !arr_table_comment[xzzd[2*index].comment]" class="el-icon-circle-close" style="color: #ff5656;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm(xzzd[2*index].comment,false,true)"></i>
            </td>


            <td class="pub-td1" v-if="index==Math.trunc(xzzd.length/2)+Math.trunc(xzzd.length%2)-1?xzzd.length%2!=0?false:true:true">{{ xzzd[2*index+1].comment }}</td>
            <td class="pub-td2" v-if="form.extraProperty&&index==Math.trunc(xzzd.length/2)+Math.trunc(xzzd.length%2)-1?xzzd.length%2!=0?false:true:true">
              <span v-if="!true_edit">{{
              form.extraProperty[xzzd[2*index+1].comment]?form.extraProperty[xzzd[2*index+1].comment].value:''
              }}</span>
              <i v-if="$route.meta.gly && !true_edit && form.extraProperty[xzzd[2*index+1].comment]?!form.extraProperty[xzzd[2*index+1].comment].confirmed:false" class="el-icon-question" style="color: #9a9ca0;font-size: 20px;"></i>
              <i v-if="$route.meta.gly && !true_edit && form.extraProperty[xzzd[2*index+1].comment]?form.extraProperty[xzzd[2*index+1].comment].confirmed:false" class="el-icon-success" style="color: #12dc00;font-size: 20px;"></i>
              <el-input
                v-if="true_edit"
                v-model="form.extraProperty[xzzd[2*index+1].comment].value"
                placeholder="请输入内容"
                :readonly="form.extraProperty[xzzd[2*index+1].comment]?form.extraProperty[xzzd[2*index+1].comment].confirmed:false"
              ></el-input>
                <i v-if="true_edit && !arr_table_comment[xzzd[2*index+1].comment]" class="el-icon-circle-check" style="color: #56ff7a;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm(xzzd[2*index+1].comment,true,true)"></i>
                <i v-if="true_edit && !arr_table_comment[xzzd[2*index+1].comment]" class="el-icon-circle-close" style="color: #ff5656;font-size: 20px;margin-top: 10px;cursor: pointer;" @click="qr_Confirm(xzzd[2*index+1].comment,false,true)"></i>
            </td>
          </tr>
        </table>
      </div>
      <div class="mk-div" v-for="(item, index) in wzmk_data">
        <div class="title-div">
          <span v-text="item.comment + ':'"></span>
        </div>
        <div class="data-div" v-if="form.textareaProperty">
          <div
            :style="{
              'text-align':
                form.textareaProperty[item.comment].value == '' ||
                form.textareaProperty[item.comment].value == undefined
                  ? 'center'
                  : 'unset',
              color:
                form.textareaProperty[item.comment].value == '' ||
                form.textareaProperty[item.comment].value == undefined
                  ? '#909399'
                  : '',
            }"
            v-if="item.type == 1"
            class="div_s"
          >
            <span
              v-if="!true_edit"
              v-text="
                form.textareaProperty[item.comment].value == '' ||
                form.textareaProperty[item.comment].value == undefined
                  ? '暂无数据'
                  : form.textareaProperty[item.comment].value
              "
            ></span>
            <el-input
              v-if="true_edit"
              v-model="form.textareaProperty[item.comment].value"
              placeholder="请输入内容"
              type="textarea"
              :rows="6"
            ></el-input>
          </div>
          <div v-if="item.type == 2">
            <i
              class="el-icon-circle-plus"
              title="新增表格"
              @click="add_table(index)"
              v-if="true_edit"
              style="
                font-size: 23px;
                margin-bottom: 10px;
                color: #409eff;
                cursor: pointer;
              "
            ></i>
            <el-table style="width: 100%" :data="item.table_column">
              <el-table-column
                :prop="items"
                :label="items"
                v-for="(items, indexs) in item.table_tab"
                :key="indexs"
              >
                <template slot-scope="scope">
                  <span v-if="!true_edit">{{ scope.row[items] }}</span>
                  <el-input
                    v-if="true_edit"
                    v-model="scope.row[items]"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                prop="cz"
                label="操作"
                width="150"
                v-if="true_edit"
              >
                <template slot-scope="scope">
                  <i
                    class="el-icon-delete-solid"
                    title="删除"
                    @click="handleDelete(scope.$index, scope.row, index)"
                  ></i>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div v-if="item.type == 3" style="height: 400px">
            <component
              :is="currentRole_rw"
              :clientDetails="clientDetails_rw"
              ref="mychild_rw_datas"
            />
          </div>
          <div v-if="item.type == 4" style="height: 500px"></div>
        </div>
      </div>
    </div>
    <div style="width: 230px; float: left; margin-left: 20px">
      <!-- <div class="xgnr-span" style="margin-top:0px">
        <span>相关内容</span>
      </div>
      <div class="xgnr-div">
        <el-tabs type="border-card">
          <el-tab-pane label="人物">
            <ul>
              <li v-for="item in xgnr_wd">
                <span>{{ item.title }}</span>
              </li>
            </ul>
          </el-tab-pane>
        </el-tabs>
      </div> -->
      <div class="xgnr-span" style="margin-top: 0px">
        <span>相关人物</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_xgrw.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_xgrw.length != 0">
          <li v-for="item in xgnr_xgrw" :title="item.xm.value == undefined ||
            item.xm.value == '' ||
            item.xm.value == null
            ? item.wwm.value
            : item.xm.value
            ">
            <span>{{
              item.xm.value == undefined ||
              item.xm.value == "" ||
              item.xm.value == null
              ? item.wwm.value
              : item.xm.value + " 相关人员"
            }}</span>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>账号动态</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_wd.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_wd.length != 0">
          <li v-for="item in xgnr_wd" :title="item.txt_zh">
            <span>{{ item.txt_zh }}</span>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>所属基地</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_ssjd.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_ssjd.length != 0">
          <li v-for="item in xgnr_ssjd" :title="'出处：' + item.objectType">
            <span>{{ item.object }}</span>
            <i class="el-icon-delete" @click="delete_right_sj(item)"></i>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>所属部队</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_ssbd.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_ssbd.length != 0">
          <li v-for="item in xgnr_ssbd" :title="'出处：' + item.objectType">
            <span>{{ item.object }}</span>
            <i class="el-icon-delete" @click="delete_right_sj(item)"></i>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>所属装备</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_sszb.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_sszb.length != 0">
          <li v-for="item in xgnr_sszb" :title="'出处：' + item.objectType">
            <span>{{ item.object }}</span>
            <i class="el-icon-delete" @click="delete_right_sj(item)"></i>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>相关舆情</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_xgyq.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_xgyq.length != 0">
          <li v-for="item in xgnr_xgyq" :title="'出处：' + item.objectType">
            <span>{{ item.object }}</span>
            <i class="el-icon-delete" @click="delete_right_sj(item)"></i>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>证据资料</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_zjzl.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_zjzl.length != 0">
          <li v-for="item in xgnr_zjzl" :title="'出处：' + item.objectType">
            <span>{{ item.object }}</span>
            <i class="el-icon-delete" @click="delete_right_sj(item)"></i>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>关键影响人物</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_gjyxrw.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_gjyxrw.length != 0">
          <li
            v-for="item in xgnr_gjyxrw"
            :title="'出处：' + item.objectType"
            @click="showInfo(item)"
          >
            <span>{{ item.object }}</span>
            <span style="font-size: 12px; color: #737373">{{
              item.createTime
            }}</span>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>攻击建议</span>
        <el-button
          type="primary"
          size="mini"
          style="float: right; margin-top: 4px; margin-right: 5px"
          @click="add_gjjy()"
          >添加</el-button
        >
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_gjjy.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_gjjy.length != 0">
          <li v-for="item in xgnr_gjjy" :title="'出处：' + item.objectType">
            <span>{{ item.object }}</span>
            <i class="el-icon-delete" @click="delete_right_sj(item)"></i>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>评价言论</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_pjyl.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_pjyl.length != 0">
          <li v-for="item in xgnr_pjyl" :title="'出处：' + item.objectType">
            <span>{{ item.object }}</span>
            <i class="el-icon-delete" @click="delete_right_sj(item)"></i>
          </li>
        </ul>
      </div>
      <div class="xgnr-span">
        <span>机构分析报告</span>
      </div>
      <div class="xgnr-div">
        <div v-if="xgnr_jgfxbg.length == 0">
          <span>暂无数据接入</span>
        </div>
        <ul v-if="xgnr_jgfxbg.length != 0">
          <li v-for="item in xgnr_jgfxbg" :title="'出处：' + item.objectType">
            <span>{{ item.object }}</span>
            <i class="el-icon-delete" @click="delete_right_sj(item)"></i>
          </li>
        </ul>
      </div>
    </div>
    <el-dialog
      title="攻击建议"
      :visible.sync="dialogVisibleOrganization"
      width="30%"
    >
      <el-form ref="form" label-width="80px">
        <el-form-item label="建议">
          <el-input
            type="textarea"
            :autosize="{ minRows: 6, maxRows: 10 }"
            placeholder="请输入内容"
            v-model="selectText"
            style="width: 90%"
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleOrganization = false">取 消</el-button>
        <el-button type="primary" @click="defineRelatedOrganization"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
    

<script>
import back from "../../assets/img/setting/back.png";
import SeeksRelationGraph from "relation-graph";
import {
  get,
  post,
  fileUpload,
  delete_util,
} from "../../util/http_util";
import * as echarts from "echarts";
import jh_bg from "../../assets/img/dfzy/zwtp.png";
import { uuid } from "../../util/data_util";
import navs_rwk from "./gxt.vue";
import Vue from "vue";
import { imgUrl } from "../../api/publicUrl";
export default {
  components: { navs_rwk },
  data() {
    return {
      currentRole_rw: "navs_rwk",
      clientDetails_rw: {},
      back: back,
      isShowCodePanel: false,
      form: {
        bddh: "",
        bdfh: "",
        jgbh: "",
        bdfc: "",
        bzfh: "",
        bdjc: "",
        zsdh: "",
        mj: "",
        bdlb: "",
        bz: "",
        gjdq: "",
        jz: "",
        dm: "",
        jdqf: "",
        qbtgdw: "",
        bddj: "",
        zbdj: "",
        avatar: "",
      },
      jh_bg: jh_bg,
      zt_id: "",
      db_zt_id: "",
      xgnr_wd: [],
      xgnr_xgrw: [],
      xgnr_zhdt: [],
      xgnr_ssjd: [],
      xgnr_ssbd: [],
      xgnr_sszb: [],
      xgnr_xgyq: [],
      xgnr_zjzl: [],
      xgnr_gjjy: [],
      xgnr_pjyl: [],
      xgnr_jgfxbg: [],
      xgnr_gjyxrw: [],
      educationHistory: [],
      workingHistory: [],
      twitterUsers: [],
      xzzd: [],
      wzmk_data: [],
      true_edit: false,
      imageUrl: "",
      fileList_head: [],
      file_head: {},
      file_types_head: ".PNG,.JPG,.JPEG",
      errimg: "this.src='" + jh_bg + "'",
      obj_dx: {},
      ids_tree: "",
      templateId: "",
      s_switch: false,
      module_name: "",
      dialogVisibleOrganization: false,
      selectText: "",
      organization: {},
      arr_table_comment_jgk: {
        jgfh:false,
        jgjc:false,
        gjdq:false,
        jglb:false,
      },
      arr_table_comment:{

      },
      NodeMould:{},
    };
  },
  methods: {
    qr_Confirm(a, b,c) {
      let obj = {
        confirmed:b,
        id:this.organization._id,
      }
      if(c){
        this.form.extraProperty[a].confirmed = b;
        obj.property = 'extraProperty.'+a;
      }else{
        this.form[a].confirmed = b;
        obj.property = a;
      }
      post(`api/rest/mongo/organization/updateConfirmed`, obj)
        .then((res) => {
          if(res==1){
            // this.$message.success('字段内容确定成功');
            this.arr_table_comment[a] = true;
          }
        })
        .catch((err) => {
          this.$message.warning(err.message);
        });
    },
    handleDelete(index, row, indexs) {
      this.wzmk_data[indexs].table_column.splice(index, 1);
    },
    //添加攻击建议
    add_gjjy() {
      this.selectText = "";
      this.dialogVisibleOrganization = true;
    },
    defineRelatedOrganization() {
      if (this.selectText == "") {
        this.$message.warning("建议项必填！");
      } else {
        let obj = {};
        obj["object"] = this.selectText;
        obj["objectFrom"] = "";
        obj["subject"] = this.form.jgbh.value;
        obj["relation"] = "攻击建议";
        obj["objectType"] = "攻击建议";
        post(`api/rest/3z/resource/addRelatedInfo`, obj)
          .then((res) => {
            if (res == 1) {
              this.$message.success("攻击建议新增成功！");
              this.dialogVisibleOrganization = false;
              this.query_xgyl(this.form.jgbh.value);
            } else {
              this.$message.error("关联机构失败！");
            }
          })
          .catch((err) => {
            this.$message.warning(err.message);
          });
      }
    },
    //删除右侧数据
    delete_right_sj(item) {
      this.$confirm("此操作将永久该字段对应的数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let paramDatas = [item.id];
          // return
          delete_util("api/rest/resource/removeRelatedInfo", paramDatas)
            .then((data) => {
              this.query_xgyl(this.form.jgbh.value);
              this.$message({
                message: "删除成功！！！",
                type: "success",
              });
            })
            .catch((err) => {
              this.$message.warning(err.message);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //上传头像
    upload_head(obj_from,forms) {
      let id = obj_from.jgbh.value;
      if (JSON.stringify(this.file_head) != "{}") {
        if(obj_from.avatar!=''&&obj_from.avatar!=null){
          this.delete_head(obj_from.avatar);
        }
        let fd = new FormData();
        fd.append("bucket",'AVATAR');//文件存储位置
        fd.append("filename", id);
        // fd.append("folder", this.folder);
        fd.append("file", this.file_head.raw);
        fileUpload("api/rest/file/upload", fd)
          .then((data) => {
              console.log("头像上传成功");
              obj_from.avatar = data;
              this.query_head(obj_from,forms,data)
          })
          .catch((err) => {
            console.log(err);
          });
      } else {
        this.edit(obj_from,forms);
      }
    },
    //查询头像路径
    query_head(obj_from,forms,name){
      post("api/rest/file/path?bucket=AVATAR&filename=" + name)
        .then((data) => {
          obj_from.avatarUrl = data;
          forms.avatarUrl = data;
          this.edit(obj_from,forms);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    //删除之前的头像
    delete_head(name) {
      post("api/rest/file/remove?bucket=AVATAR&filename=" + name)
        .then((data) => {
          console.log(data);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    //选择文件
    handleChange(file, fileList) {
      this.imageUrl = URL.createObjectURL(file.raw);
      this.file_head = file;
      this.fileList_head = [];
    },
    //新增表格字段
    add_table(index, comment) {
      let obj = {};
      this.wzmk_data[index].table_tab.forEach((item) => {
        obj[item] = "";
      });
      this.wzmk_data[index].table_column.push(obj);
    },
    edit_onSubmit() {
      let obj_from = JSON.parse(JSON.stringify(this.form));
      obj_from.label = obj_from.jgfh.value;
      obj_from.code = obj_from.jgbh.value;
      let obj_froms = JSON.parse(JSON.stringify(obj_from));
      let obj_mouldTables = {};
      let textareas = {};
      let extra = {};
      if (this.wzmk_data.length > 0) {
        this.wzmk_data.forEach((item) => {
          if (item.type == 2) {
            if (item.table_column.length > 0) {
              var object_column = [];
              //清除板块表格数据中都是空值的一行
              item.table_column.forEach(function (itema) {
                var result = Object.values(itema).every(function (item1) {
                  return item1 === "";
                });
                if (!result) {
                  object_column.push(itema);
                }
              });
              //板块表格的数据
              let _columns_rows = {};
              _columns_rows.columns = item.table_tab;
              let arrs = [];
              object_column.forEach((items) => {
                let arrs1 = [];
                item.table_tab.forEach((itema) => {
                  arrs1.push(items[itema]);
                });
                arrs.push(arrs1);
              });
              _columns_rows.rows = arrs;
              obj_mouldTables[item.comment] = _columns_rows;
            }
          }else if(item.type == 1){
            textareas[item.comment] = obj_from.textareaProperty[item.comment].value;
          }
        });
      }
      if(this.xzzd.length>0){
        this.xzzd.forEach((item)=>{
          extra[item.comment] = obj_from.extraProperty[item.comment].value;
        })
      }
      obj_from.extraProperty = extra;
      obj_from.textareaProperty = textareas;
      obj_from.tableProperty = obj_mouldTables;
      obj_froms.tableProperty = obj_mouldTables;
      this.upload_head(obj_from,obj_froms);
    },
    edit(obj_from,forms) {
      obj_from.jgfh = obj_from.jgfh.value;
      obj_from.jgjc = obj_from.jgjc.value;
      obj_from.jgbh = obj_from.jgbh.value;
      obj_from.gjdq = obj_from.gjdq.value;
      obj_from.jglb = obj_from.jglb.value;
      let paramDatas = {
        ...obj_from
      };
      post("api/rest/mongo/organization/updateTreeItem", paramDatas)
        .then((data) => {
          if (data == 1) {
            this.$message({
              message: "修改成功",
              type: "success",
            });
            this.organization = forms;
            this.query_CharacterMould(this.templateId,false);
            this.$parent.updata_tree({
              code: obj_from.code,
              info: forms,
              label:obj_from.label,
            });
          }
        })
        .catch((err) => {
          this.$message.warning(err.message);
          this.query_CharacterMould(this.templateId);
        });
      this.true_edit = false;
    },
    update() {
      this.true_edit = true;
    },
    qd_update() {
      this.true_edit = false;
      this.query_CharacterMould(this.templateId);
    },
    query_CharacterMould(id) {
      get("api/rest/mongo/template/query?id=" + id)
        .then((datas) => {
          this.xzzd = [];
          this.wzmk_data = [];
          this.arr_table_comment = JSON.parse(JSON.stringify(this.arr_table_comment_jgk));
          if (datas != null && datas.length != 0) {
            let data = datas[0];
            if (data.extraProperty.length > 0) {
              data.extraProperty.forEach((item) => {
                this.xzzd.push({ comment: item, value: "" });
                this.arr_table_comment[item] = false;//设置当前字段是否确定
              });
            }
            this.arr_table_comment = JSON.parse(JSON.stringify(this.arr_table_comment));
            if (data.textareaProperty.length > 0) {
              data.textareaProperty.forEach((item) => {
                if (item == "大五画像") {
                  this.wzmk_data.push({
                    comment: item,
                    type: "4",
                    table_tab: [],
                    value: "",
                    table_column: [],
                  });
                } else if (item == "关系图谱") {
                  this.wzmk_data.push({
                    comment: item,
                    type: "3",
                    table_tab: [],
                    value: "",
                    table_column: [],
                  });
                } else {
                  this.wzmk_data.push({
                    comment: item,
                    type: "1",
                    table_tab: [],
                    value: "",
                    table_column: [],
                  });
                }
              });
            }
            if (data.tableProperty.length > 0) {
              data.tableProperty.forEach((items) => {
                let arr = [];
                items.columnName.forEach((items1) => {
                  arr.push(items1);
                });
                this.wzmk_data.forEach((item, index) => {
                  if (items.tableName == item.comment) {
                    this.wzmk_data[index].type = "2";
                    this.wzmk_data[index].table_tab = arr;
                  }
                });
              });
            }
          }
          this.query_grxx();
        })
        .catch((err) => {
          this.$message.warning(err.message);
        });
    },
    query_avatar(avatar){
      get("api/rest/file/viewPicture/AVATAR?objectName=" + avatar)
      .then((arr) => {
        this.imageUrl=arr;
      }).catch(err=>{
        this.imageUrl=''
      })
    },
    query_grxx() {
      this.form = JSON.parse(JSON.stringify(this.organization));
      // this.imageUrl = imgUrl + this.form.avatar;
      // this.form.avatar==null?(this.imageUrl=''):this.query_avatar(this.form.avatar);
      this.form.avatar==null?(this.imageUrl=''):(this.imageUrl = 'api/rest/file/viewPicture/AVATAR?objectName='+this.form.avatar);
      if (
        this.wzmk_data.length > 0 &&
        JSON.stringify(this.form.tableProperty) != "{}"
      ) {
        this.wzmk_data.forEach((item) => {
          if (item.type == 2) {
            if (this.form.tableProperty[item.comment] != undefined) {
              if (this.form.tableProperty[item.comment].rows.length > 0) {
                this.form.tableProperty[item.comment].rows.forEach((items) => {
                    let obj = {};
                    this.form.tableProperty[item.comment].columns.forEach((itemsb,index)=>{
                      obj[itemsb] = items[index];
                    })
                    item.table_column.push(obj);
                });
              }
            }
          }
        });
        if (this.wzmk_data.length > 0) {
          this.wzmk_data.forEach((item) => {
            if (item.type == 3) {
              this.clientDetails_rw = {
                module_id: this.form.jgbh.value,
                types: "1",
                peopleOrOrganization: "organization",
              };
            }
          });
        }
      }
      this.xgnr_wd = [];
      this.xgnr_ssjd = [];
      this.xgnr_ssbd = [];
      this.xgnr_xgyq = [];
      this.xgnr_zjzl = [];
      this.xgnr_gjjy = [];
      this.xgnr_pjyl = [];
      this.xgnr_jgfxbg = [];
      this.xgnr_gjyxrw = [];
      this.organization.extraProperty['Twitter账号'].value!=''?this.query_Twitter(this.organization.extraProperty['Twitter账号'].value):'';
      // this.query_xgyl(this.form.jgbh.value);//右侧信息
    },
    query_Twitter(account) {
      get("api/rest/elastic/queryRelationTwitter?pageNum=1&pageSize=10&twitterAccount=" + account)
        .then((data) => {
          let arr_news_twitter = [];
          if (data.list.length > 0) {
            data.list.forEach((item) => {
              arr_news_twitter.push({
                title: "", //标题
                txt: item.txt_zh, //内容
                site_name: item.fullname, //来自
                pubdate: item.timestr, //发布时间
                snatch_time: item.input_time, //抓取时间
                highLight: item.highLight, //高亮
                cmtcnt: item.cmtcnt, //评论数
                rpscnt: item.rpscnt, //转发数
                atdcnt: item.atdcnt, //点赞数
                isori: item.isori, //是否原创
                tweets_id: item.tweets_id, //是twitter_id
                blogger_id: item.blogger_id, //用户查询用户信息
                tweets_url: item.tweets_url, //原文链接
                txt_zh: item.txt_zh,
                title_zh: "", //标题
                emotion1: item.emotion1,
              });
            });
          }
          this.xgnr_wd = arr_news_twitter;
        })
        .catch((err) => {
          this.$message.warning(err.message);
        });
    },
    query_tree() {
      get("api/rest/mongo/template/query?type=1")
        .then((datas) => {
          this.option_rwmb = [];
          if (datas.length > 0) {
            datas.forEach((item) => {
              this.option_rwmb.push({ value: item.id, label: item.name });
            });
          }
        })
        .catch((err) => {
          this.$message.warning(err.message);
        });
    },
    jsonToArray(nodes) {
      var r = [];
      if (Array.isArray(nodes)) {
        for (var i = 0, l = nodes.length; i < l; i++) {
          r.push(nodes[i]); // 取每项数据放入一个新数组
          if (
            Array.isArray(nodes[i]["children"]) &&
            nodes[i]["children"].length > 0
          )
            // 若存在children则递归调用，把数据拼接到新数组中，并且删除该children
            r = r.concat(this.jsonToArray(nodes[i]["children"]));
          delete nodes[i]["children"];
        }
      }
      return r;
    },
    query_rw() {
      post(
        `api/rest/mongo/character/query?pageNum=${1}&pageSize=${20}`,
        {
          module: this.form.module,
          orgId: this.form.jgbh.value,
        }
      )
        .then((res) => {
          this.xgnr_xgrw = [];
          res.records.forEach((item) => {
            this.xgnr_xgrw.push(item);
          });
        })
        .catch((err) => {
          this.$message.warning(err.message);
        });
    },
    query_xgyl(id) {
      this.query_tree();
      this.query_rw();
      get(
        "api/rest/3z/resource/queryRelatedInfo?subject=" +
          id +
          "&relation=" +
          "所属基地"
      )
        .then((data) => {
          this.xgnr_ssjd = data.list;
        })
        .catch((err) => {
          this.$message.warning(err.message);
        });
      get(
        "api/rest/3z/resource/queryRelatedInfo?subject=" +
          id +
          "&relation=" +
          "所属部队"
      )
        .then((data) => {
          this.xgnr_ssbd = data.list;
        })
        .catch((err) => {
          console.log(err);
        });
      get(
        "api/rest/3z/resource/queryRelatedInfo?subject=" +
          id +
          "&relation=" +
          "相关舆情"
      )
        .then((data) => {
          this.xgnr_xgyq = data.list;
        })
        .catch((err) => {
          console.log(err);
        });
      get(
        "api/rest/3z/resource/queryRelatedInfo?subject=" +
          id +
          "&relation=" +
          "证据资料"
      )
        .then((data) => {
          this.xgnr_zjzl = data.list;
        })
        .catch((err) => {
          console.log(err);
        });
      get(
        "api/rest/3z/resource/queryRelatedInfo?subject=" +
          id +
          "&relation=" +
          "攻击建议"
      )
        .then((data) => {
          this.xgnr_gjjy = data.list;
        })
        .catch((err) => {
          console.log(err);
        });
      get(
        "api/rest/3z/resource/queryRelatedInfo?subject=" +
          id +
          "&relation=" +
          "评价言论"
      )
        .then((data) => {
          this.xgnr_pjyl = data.list;
        })
        .catch((err) => {
          console.log(err);
        });
      get(
        "api/rest/3z/resource/queryRelatedInfo?subject=" +
          id +
          "&relation=" +
          "关键影响人物"
      )
        .then((data) => {
          this.xgnr_gjyxrw = data.list;
        })
        .catch((err) => {
          console.log(err);
        });
      get(
        "api/rest/3z/resource/queryRelatedInfo?subject=" +
          id +
          "&relation=" +
          "机构分析报告"
      )
        .then((data) => {
          this.xgnr_jgfxbg = data.list;
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  props: {
    clientDetails: {
      type: Object,
      default: {},
    },
  },
  watch: {
    clientDetails: function (val) {
      if(val.NodeKey != ''){
        this.true_edit = false;
        this.ids_tree = val.NodeKey;
        this.templateId = val.NodeMould.info.templateId;
        this.organization = val.NodeMould.info;
        this.NodeMould = val.NodeMould;
        this.s_switch = val.type;
        this.imageUrl = "";
        val.NodeMould.info.templateId != ""
          ? this.query_CharacterMould(val.NodeMould.info.templateId)
          : "";
      }
    },
  },
  mounted() {},
  activated() {
    this.true_edit = false;
  },
};
</script>
<style lang="scss">
#jg_xq {
  width: 100%;
  height: 100%;
  position: relative;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  border: 2px solid #2d4c50;
  border-radius: 5px;
  box-shadow: 0px 0px 10px #2a617b;
  padding: 20px 20px;

  .el-input__inner {
    color: white !important;
    background: none !important;
    border: 1px solid #146a80 !important;
    box-shadow: 0 0 10px #1b6097;
  }
  .el-textarea__inner {
    color: white !important;
    background: none !important;
    border: 1px solid #146a80 !important;
    box-shadow: 0 0 10px #1b6097;
    white-space: pre-line;
  }
  #aa2 {
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    border-radius: 19px;
    background-color: white;
    margin-top: -40px;
  }
  .top-title {
    width: 100%;
    float: left;
    // height: 95px;
    .top-left-div {
      width: 50%;
      float: left;
      span {
        width: 100%;
        font-weight: 900;
        float: left;
        color: #3bc0ff;
        word-break: break-all;
      }
    }
    .top-right-div {
      width: calc(50% - 20px);
      margin-left: 20px;
      float: right;
    }
  }
  .title-div {
    float: left;
    width: 100%;
    height: 25px;
    background-size: 100% 100%;
    position: relative;
    margin-top: 10px;
    span {
      position: absolute;
      //   left: 50px;
      //   top: -10px;
      font-weight: 700;
      font-size: 18px;
      color: #50d7ec;
    }
  }
  .mk-div {
    width: 100%;
    // height: 206px;
    float: left;
    margin-bottom: 20px;
    .data-div {
      width: calc(100% - 40px);
      float: left;
      padding: 20px;
      .div_s {
        width: 100%;
        span {
          font-size: 14px;
          white-space: pre-line;
          word-break: break-all;
        }
      }
      .pub-div-data {
        margin: 10px calc(50% - 28px);
        color: #909399;
        font-size: 14px;
      }
      .el-table tr {
        background-color: #1d2d46 !important;
        color: #ffffffc7;
      }
      .el-table td {
        border-bottom: 1px solid #127a89;
        border-right: unset;
        .cell {
          font-size: 12px;
        }
      }
      .el-table--enable-row-hover .el-table__body tr:hover > td {
        background-color: #82848a3d;
      }
      .el-table th {
        border: unset;
        background-color: #1f3350c4 !important;
        padding: 5px 0;
        .cell {
          font-size: 14px;
        }
      }
      .el-table--fit {
        background: none !important;
        border: unset;
        .el-table__empty-block {
          height: 100px !important;
        }
      }
      .el-icon-delete-solid {
        color: red;
        cursor: pointer;
        font-size: 18px;
      }
      .el-icon-download {
        color: #1172d8;
        cursor: pointer;
        font-size: 20px;
      }
      .el-icon-edit {
        color: #1172d8;
        cursor: pointer;
        font-size: 20px;
      }
      .el-icon-view {
        color: #00ffff;
        font-size: 20px;
        cursor: pointer;
      }
      .el-table--group::after,
      .el-table--border::after,
      .el-table::before {
        background-color: unset;
      }
    }
  }
  .el-card__body {
    padding: 0px;
  }
  .img-div {
    width: 230px;
    height: 230px;
    float: left;
    .el-upload{
      width: 100%;
    }
    img {
        background-size: 100% 100%;
        width: 100%;
    }
  }
  .table_jbxx {
    border-collapse: collapse;
    width: calc(100% - 260px);
    margin-left: 20px;
    float: left;
    td {
      border: 1px solid #00648c;
      padding: 12px 20px;
      font-size: 14px;
      // max-width: 1;
    }
    .pub-td1 {
      color: #d6d6d6;
      font-weight: 900;
      width: 85px;
    }
    .pub-td2 {
      color: #8cd4ff;
      text-overflow: ellipsis;
      overflow: hidden;
    }
  }
  .title-divs {
    float: left;
    height: 25px;
    width: calc(100% - 0px);
    // background-image: url("../../assets/img/dfzy/02.png");
    // background-size: 100% 100%;
  }
  .el-card {
    border-radius: unset;
    border: 1px solid #1d2d4600;
    background-color: unset;
    overflow: hidden;
    color: #ffff;
    transition: 0.3s;
    opacity: 0.93;
    .textitem {
      padding-top: 5px;
      cursor: pointer;
      span {
        font-size: 15px;
        color: #8cd4ff;
      }
    }
  }
  .el-card.is-always-shadow {
    box-shadow: none;
  }
  .xgnr-span {
    height: 37px;
    line-height: 37px;
    padding-left: 20px;
    font-weight: 700;
    margin-top: 20px;
    background: #293f63b5;
    color: #f1f1f1;
    font-size: 12px;
  }
  .xgnr-div {
    width: 100%;
    height: 100px;
    text-align: center;
    background: #293c5a2e;
    overflow-y: auto;
    overflow-x: hidden;
    div {
      margin-top: 40px;
      display: inline-table;
      color: #adadad;
      font-size: 12px;
    }
    .el-tabs--border-card {
      background: #ececec;
      border: 1px solid #1d2d46;
      > .el-tabs__header {
        background-color: #c1c1c1;
        .el-tabs__item.is-active {
          color: #009df9;
          background-color: #ececec;
        }
        .el-tabs__item {
          color: #777777;
        }
      }
    }
    ul {
      padding: 0px 35px;
      margin: 0px;
      width: calc(100% - 70px);
      height: 100%;
      li {
        color: #26adcc;
        float: left;
        width: calc(100% + 19px);
        line-height: 33px;
        text-align: left;
        span {
          color: #71d4ff;
          float: left;
          cursor: pointer;
          width: calc(100% - 20px);
          font-size: 14px;
          line-height: 33px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        span:hover {
          color: #65add6;
        }
        .el-icon-delete {
          color: red;
          cursor: pointer;
          font-size: 20px;
        }
      }
      li:nth-child(even) {
        background: #2b4064;
      }
    }
  }
  .back {
    width: 40px;
    height: 40px;
    position: absolute;
    top: 11%;
    right: 80px;
    cursor: pointer;
  }
}
</style>
