<template>
  <div class="againAssign">
    <div class="conentBox">
      <div class="header">处理方案</div>
      <div v-if="modelData.incident.id" class="conent">
        <div class="navBar">
          <div
            class="fl"
            :class="{ p50: modelData.incident.handlerUser.id != loginUser.id }"
          >
            <a
              :class="{ active: actives == 'info' }"
              href="javascript:;"
              @click="toInfo('info')"
              >事件信息</a
            >
          </div>
          <!-- <div
            class="fl"
            :class="{ p50: modelData.incident.handlerUser.id != loginUser.id }"
          >
            <a
              :class="{ active: actives == 'handlerLog' }"
              href="javascript:;"
              @click="toInfo('handlerLog')"
              >处理日志</a>
          </div> -->
          <div
            class="fl"
            :class="{ p50: modelData.incident.handlerUser.id != loginUser.id }"
          >
            <a
              :class="{ active: actives == 'progress' }"
              href="javascript:;"
              @click="toInfo('progress')"
              >处理进度</a
            >
          </div>

          <div
            class="fl"
            v-if="modelData.incident.handlerUser.id == loginUser.id"
          >
            <a
              :class="{ active: actives == 'handlerInfo' }"
              href="javascript:;"
              @click="toInfo('handlerInfo')"
              >处理信息</a
            >
          </div>
        </div>
        <div class="label headtop" id="info">事件信息</div>

        <div class="info">
          <EventInformation :model="modelData" :id="id"></EventInformation>
          <p class="info_hide">
            <span class="fl hide" @click="hides()" v-if="!item_hides"
              >展开详情 >></span
            >
            <span class="fl hide" @click="hides()" v-if="item_hides"
              >隐藏详情<<</span
            >
          </p>
          <div class="imgs-container" v-if="imgs.length">
            <div class="imgs-cont" @click="showImgs(imgs)">
              <img
                v-if="
                  img.suffix == 'jpeg' ||
                    img.suffix == 'jpg' ||
                    img.suffix == 'gif' ||
                    img.suffix == 'png' ||
                    img.suffix == 'svg' ||
                    img.suffix == 'pdf'
                "
                :src="img.previewUrl"
                v-for="(img, index) in imgs"
                class="imgs"
              />
              <p v-else>
                <a :href="[img.previewUrl]">{{ img.name }}</a>
              </p>
            </div>
          </div>
          <!-- <HandlerLog :data="modelData.incident.handlerLogs" id="handlerLog"></HandlerLog> -->
          <div class="label" id="progress">处理进度</div>
          <div
            :class="{ progress: true, progressHide: !pro_hides }"
            id="progressBox"
          >
            <div class="progress_info" v-for="item in progressInfo">
              <div class="progress_info_L">{{ item.activityName }}</div>
              <div class="progress_info_R">
                <div class="time">
                  <i
                    :class="{
                      iconfont: true,
                      'icon-icon_weizuo': item.endTime != '',
                      'icon-icon_zhengzaijinx': item.endTime == ''
                    }"
                  ></i>
                  <span class="text1">
                    {{ item.startTime | timeFormat("MM-dd HH:mm:ss") }}
                    <template v-if="item.userName">
                      ，{{ item.userName }}
                    </template>
                  </span>
                </div>
                <div :class="{ cont: true, blue: item.endTime != '' }">
                  <p class="text2" v-if="item.desc" v-html="item.desc"></p>
                </div>
              </div>
            </div>
          </div>

          <p class="info_hide">
            <span class="fl hide" @click="proHides()">{{
              pro_hides ? "隐藏详情 <<" : "展开详情 >>"
            }}</span>
          </p>
          <div v-if="modelData.incident.handlerUser.id == loginUser.id">
            <div class="label" id="handlerInfo">处理信息</div>
            <!-- 添加耗材 start -->
            <div style="margin-top:16px;margin-bottom:16px;">
              <div v-for="(item, i) in hcList" :key="i" class="hcList">
                <cube-select
                  placeholder="请选择耗材"
                  class="hcItem"
                  v-model="item.assetConsumablesId"
                  :options="hcs"
                ></cube-select>
                <cube-input
                  type="number"
                  v-model="item.extra1"
                  placeholder="请输入价格"
                  class="hcItem"
                ></cube-input>
                <cube-input
                  type="number"
                  v-model="item.consumablesSum"
                  placeholder="请输入数量"
                  class="hcItem"
                ></cube-input>
                <span
                  class="icon iconfont icon-shanchu hcItemClose"
                  @click="removeHc(item.id)"
                ></span>
              </div>
            </div>
            <div
              class="addHc"
              @click="addHc()"
              v-if="incidentWithConsumable == 1"
            >
              <i class="cubeic-add"></i>增加耗材
            </div>
            <!-- 添加耗材 end -->
            <div class="handlerInfo">
              <cube-form
                :model="model"
                @validate="validateHandler"
                @submit="submitHandler"
              >
                <cube-form-group>
                  <!-- <cube-form-item :field="fields[12]" class="btn_plcaeholde"> -->
                  <!-- <cube-button @click="showDatePicker">{{model.dateValue || 'Please select date'}}</cube-button> -->
                  <!-- <date-picker ref="datePicker" :min="[2008, 8, 8]" :max="[2020, 10, 20]" @select="dateSelectHandler"></date-picker> -->
                  <!-- </cube-form-item> -->
                  <!-- <cube-form-item :field="fields[13]" class="btn_plcaeholde"></cube-form-item> -->
                  <div class="handleRadio">
                    <cube-radio-group
                      v-model="order"
                      :options="handleTypes"
                      position="right"
                      :hollow-style="true"
                      @input="changeHandleTypes"
                    />
                  </div>

                  <cube-form-item
                    :field="fields[0]"
                    v-if="order == 1"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[1]"
                    class="btn_plcaeholde"
                    v-if="order == 1"
                  >
                    <cube-button @click="showCategoryPicker()">{{
                      selectedCategoryTxt
                        ? selectedCategoryTxt
                        : "请选择事件分类"
                    }}</cube-button>
                  </cube-form-item>
                  <cube-form-item
                    :field="fields[2]"
                    v-if="order == 1"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[3]"
                    class="incidentTitle"
                    v-if="order == 1 && isShowDes"
                  >
                    <div class="titleRefer">
                      <textarea
                        class="titleTxtArea fl"
                        placeholder="请输入处理方案"
                        v-model="incidentTitle"
                        @input="inpTitle()"
                      ></textarea>
                      <span class="abtn fl" @click="referKnowledge()"
                        >引入知识库</span
                      >
                    </div>
                  </cube-form-item>

                  <div class="label formLabel" v-if="order == 1">
                    报修图片
                    <span>(最多可上传3张JPG或PNG,每张不能超过10M)</span>
                  </div>
                  <div class="uplod" v-if="order == 1">
                    <cube-upload
                      ref="upload"
                      :max="3"
                      :action="action"
                      :simultaneous-uploads="3"
                      @files-added="filesAdded"
                      @file-submitted="fileSubmitted"
                    />
                  </div>
                  <cube-form-item
                    :field="fields[4]"
                    v-if="order == 1 && isShowDes"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[5]"
                    class="btn_plcaeholde"
                    v-if="order == 1 && !!model.knowledge"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[14]"
                    v-if="order == 1"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[10]"
                    v-if="order == 1 && !!model.isHelper"
                  >
                    <div class="synerBox">
                      <cube-checkbox-group
                        v-model="synergeticChecked"
                        :options="synergeticList"
                      />
                    </div>
                  </cube-form-item>
                  <cube-form-item
                    :field="fields[11]"
                    v-if="order == 1 && !!model.isHelper"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[6]"
                    v-if="order == 2"
                  ></cube-form-item>
                  <!-- <cube-form-item
                    :field="fields[15]"
                    v-if="order == 5"
                  ></cube-form-item> -->
                  <cube-form-item
                    :field="fields[7]"
                    v-if="order == 2"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[17]"
                    v-if="order == 3"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[18]"
                    v-if="model.transferMode == 2"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[19]"
                    v-if="model.transferMode == 2"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[8]"
                    v-if="order == 3"
                  ></cube-form-item>
                  <cube-form-item
                    :field="fields[9]"
                    v-if="order == 3"
                  ></cube-form-item>
                  <!-- <cube-form-item
                    :field="fields[16]"
                    class="incidentTitle"
                  >
                    <div class="titleRefer">
                      <textarea
                        style="margin-top:0.1rem;width:100%;"
                        class="titleTxtArea fl"
                        placeholder="请输入处理日志"
                        v-model="handlerLog"
                      ></textarea>
                    </div>
                  </cube-form-item> -->
                </cube-form-group>
                <cube-form-group class="sub">
                  <cube-button type="submit" @click="subVali()"
                    >提交</cube-button
                  >
                </cube-form-group>
              </cube-form>
            </div>
          </div>
        </div>
      </div>
      <load-ing v-if="loadShow"></load-ing>
      <promp-ting
        :conents="promptingConent"
        :status="promptingStatus"
      ></promp-ting>
    </div>
    <seiminModel ref="seiminModel"></seiminModel>
  </div>
</template>
<script>
import seiminModel from "./../custom/seiminModel";
import CubePage from "./../components/cube-page.vue";
import CubeButtonGroup from "./../components/cube-button-group.vue";
import DatePicker from "./../components/date-picker.vue";
import CubeExtendPopup from "./../components/extend-popup.vue";
import LoadIng from "./../views/loading.vue";
import PrompTing from "./../views/prompting.vue";
import EventInformation from "./../components/EventInformation/index.vue";
// import HandlerLog from "./../views/handlerLog.vue";
// import host from '../request/host'

// 知识库类型
const solution = {
  props: {
    value: {
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      selected: [],
      selectData: [],
      initVal: JSON.parse(localStorage.getItem("solution")) || [0, 0, 0]
    };
  },
  render(createElement) {
    return createElement(
      "cube-button",
      {
        on: {
          click: this.showPicker
        }
      },
      this.selected.length
        ? this.selected[this.selected.length - 1]
        : "请选择知识库类型"
    );
  },
  created() {
    this.getTree();
  },
  mounted() {},
  methods: {
    showPicker() {
      this.picker.show();
    },
    selectHandler(selectedVal, selectedIndex, selectedTxt) {
      var selected = [];
      selectedTxt.forEach(function(v, i) {
        if (v != "") {
          selected.push(v);
        }
      });
      this.selected = selected;
      this.$emit("input", selectedVal);
      localStorage.setItem("solution", JSON.stringify(selectedIndex));
    },
    // 获取事件分类数据
    getTree() {
      let that = this;
      that.$http
        .post("service/solution/fetchDataList/solutionType", {
          idx: 0,
          sum: 100
        })
        .then(function(res) {
          // console.log(res);
          var list = res.data.list;
          var tree = [];
          list.forEach((v, i) => {
            if (!v.parent) {
              tree[i] = {
                value: v.id,
                text: v.typeName,
                children: []
              };
            } else {
              tree.forEach((val, idx) => {
                if (
                  v.parent &&
                  !v.parent.parent &&
                  val.text == v.parent.typeName
                ) {
                  tree[idx].children.push({
                    value: v.id,
                    text: v.typeName,
                    children: []
                  });
                } else if (v.parent.parent) {
                  tree[idx].children.forEach((value, index) => {
                    if (value.text == v.parent.typeName) {
                      tree[idx].children[index].children.push({
                        value: v.id,
                        text: v.typeName
                      });
                    }
                  });
                }
              });
            }
          });

          that.selectData = tree;
          that.picker = that.$createCascadePicker({
            title: "知识库类型选择",
            data: that.selectData,
            selectedIndex: that.initVal,
            onSelect: that.selectHandler
          });
        });
    }
  }
};
export default {
  data() {
    return {
      initSjList: [], //原始事件列表
      integralMechanism: localStorage.getItem("integralMechanism"),
      loginUser: JSON.parse(localStorage.getItem("loginUser")),
      incidentWithConsumable: localStorage.getItem("incidentWithConsumable"), //是否绑定耗材
      id: "",
      resignComment: "", //重新指派原因
      item_hides: false,
      actives: "info",
      processInstanceId: "",
      progressInfo: [], //处理进度
      imgs: [], //图片
      model: {}, //提交数据
      validity: {},
      valid: undefined,
      action: {
        target:
          this.$host + "/service/common/common/uploadAttachment/incident/",
        data: {}
      },
      isUploading: false,
      loadShow: false,
      pro_hides: false, //展开/收起处理进度
      name: "",
      phone: "",
      label: "incidentInfo", //顶部快速定位
      modelData: {
        incident: {}
      }, //上传的model
      incidentTitle: "", //处理方案
      handlerLog: "", //处理日志
      referenceInfo: {}, //引用信息
      selectedCategoryTxt: "", //事件分类选中展示
      selectedAreaId: "", //区域选中id--seimin
      selectedAreaName: "", //区域选中名称--seimin
      selectedPlaceId: "", //地点选中id--seimin
      selectedPlaceName: "", //地点选中名称--seimin
      model: {
        handleCategory: "", //处理方式
        closecode: "", //关闭代码
        category: [], //确认事件分类
        handleDescription: "", //处理方案
        knowledge: false, //是否提交知识库
        isHelper: false, //是否需要协同
        solutionType: [], //知识库类型
        handlerUser: "", //升级/转派对象
        isupreason: "", //升级原因
        transferReason: "", //转派原因
        synergeticChecked: [], //选中协同对象
        synergeticReason: "", //协同原因
        selectArea: "",
        selectPlace: "",
        transferMode:'',//转派方式
        branch:'',//院区
        duty:'',//责任科室
      },
      // showPrompting:false,
      promptingConent: "",
      promptingStatus: "",
      order: 1, //处理方式  1：直接处理，2:升级，3:转派，4:协同
      handleCategoryArr: [], //处理方式数组
      closecodeArr: [], //关闭代码数组
      // handlerUserArr: [], //处理人数组
      synergeticList: [], //协同对象列表
      synergeticChecked: [], //选中协同对象
      handleTypes: [
        {
          label: "直接处理",
          value: 1
        },
        {
          label: "升级",
          value: 2
        },
        {
          label: "转派",
          value: 3
        }
        // {
        //   label: "指派",
        //   value: 5
        // }
        // {
        //   label: "协同",
        //   value: 4
        // }
      ],
      vali: false,
      fields: [
        {
          type: "select",
          modelKey: "handleCategory",
          label: "处理方式:",
          props: {
            options: this.handleCategoryArr,
            title: "请选择处理方式",
            placeholder: "请选择处理方式"
          },
          rules: {
            required: true
          }
        },
        {
          component: "button",
          modelKey: "category",
          label: "确认事件分类:",
          rules: {
            required: true
          }
        },
        {
          type: "select",
          modelKey: "closecode",
          label: "关闭代码:",
          props: {
            options: this.closecodeArr,
            title: "请选择关闭代码",
            placeholder: "请选择关闭代码"
          },
          rules: {
            required: true
          }
        },
        {
          type: "textarea",
          modelKey: "handleDescription",
          label: "处理方案:",
          props: {
            placeholder: "请填写处理方案"
          },
          rules: {
            required: true
          },
          debounce: 100
        },
        {
          type: "switch",
          modelKey: "knowledge",
          label: "是否提交知识库:",
          rules: {
            required: false
          }
        },
        {
          component: solution,
          modelKey: "solutionType",
          label: "知识库类型:",
          rules: {
            required: true
          },
          messages: {
            required: ""
          }
        },
        {
          type: "select",
          modelKey: "handlerUser",
          label: "升级对象:",
          props: {
            options: [],
            placeholder: "请选择升级对象"
          },
          rules: {
            required: true
          }
        },
        {
          type: "input",
          modelKey: "isupreason",
          label: "升级原因:",
          props: {
            placeholder: "请输入升级原因"
          },
          rules: {
            required: true
          }
        },
        {
          type: "select",
          modelKey: "handlerUser",
          label: "转派对象:",
          props: {
            options: [],
            placeholder: "请选择转派对象"
          },
          rules: {
            required: true
          }
        },
        {
          type: "input",
          modelKey: "transferReason",
          label: "转派原因:",
          props: {
            placeholder: "请输入转派原因"
          },
          rules: {
            required: true
          }
        },
        {
          type: "checkbox-group",
          modelKey: "synergeticChecked",
          label: "协同对象:",
          props: {
            options: [],
            placeholder: "请选择协同对象"
          },
          rules: {
            required: false
          }
        },
        {
          type: "input",
          modelKey: "synergeticReason",
          label: "协同原因:",
          props: {
            placeholder: "请输入协同原因"
          },
          rules: {
            required: false
          }
        },
        {
          type: "select",
          modelKey: "selectArea",
          label: "区域:",
          props: {
            options: [],
            title: "请选择区域:",
            placeholder: "请选择区域:"
          },
          events: {
            change: (id, index, text) => {
              // console.log(id,index,text,9999)
              this.getPlaceList(id).then(res => {
                this.selectedAreaId = id;
                this.selectedAreaName = text;
                // {{modelData.incident.place?modelData.incident.place.area.area:'--'}}
                console.log(this.modelData, "asad");
                if (this.modelData.incident.place) {
                  this.$set(this.modelData.incident.place, "area", {
                    id,
                    area: text
                  });
                } else {
                  this.$set(this.modelData.incident, "place", {
                    area: {
                      id,
                      area: text
                    }
                  });
                }
              });
            }
          },
          rules: {
            required: true
          }
        },
        {
          type: "select",
          modelKey: "selectPlace",
          label: "地点:",
          props: {
            options: [],
            title: "请选择地点:",
            placeholder: "请选择地点:"
          },
          events: {
            change: (id, index, text) => {
              this.selectedPlaceId = id;
              this.selectedPlaceName = text;
              this.$set(
                this.modelData.incident,
                "houseNumber",
                this.selectedAreaName + this.selectedPlaceName
              );
              if (this.modelData.incident.place) {
                this.$set(this.modelData.incident.place, "place", text);
                this.$set(this.modelData.incident.place, "id", id);
              } else {
                this.$set(this.modelData.incident, "place", {
                  id,
                  place: text
                });
              }
            }
          },
          rules: {
            required: true
          }
        },
        {
          type: "switch",
          modelKey: "isHelper",
          label: "是否需要协同:",
          rules: {
            required: false
          }
        },
        {
          type: "select",
          modelKey: "handlerUser",
          label: "指派对象:",
          props: {
            options: [],
            placeholder: "请选择指派对象"
          },
          rules: {
            required: true
          }
        },
        {
          type: "textarea",
          modelKey: "handlerLog",
          label: "处理日志:",
          props: {
            placeholder: "请填写处理日志"
          },
          rules: {
            required: false
          },
          debounce: 100
        },
        {
          type: "select",
          modelKey: "transferMode",
          label: "转派方式:",
          props: {
            options: [],
            placeholder: "请选择转派方式"
          },
          events: {
            change: (id, index, text) => {
              // console.log(id,index,text,9999);
              if(id == 1){
                this.getRotateUser(id);
              }else if(id == 2){
                this.getRotateBranch();
              }
            }
          },
          rules: {
            required: true
          }
        },
        {
          type: "select",
          modelKey: "branch",
          label: "院区:",
          props: {
            options: [],
            placeholder: "请选择院区"
          },
          events: {
            change: (id, index, text) => {
              // console.log(id,index,text,9999);
              this.getRotateDuty(id);
            }
          },
          rules: {
            required: true
          }
        },
        {
          type: "select",
          modelKey: "duty",
          label: "责任科室:",
          props: {
            options: [],
            placeholder: "请选择责任科室"
          },
          events: {
            change: (id, index, text) => {
              // console.log(id,index,text,9999);
              this.getRotateUser(this.model.transferMode);
            }
          },
          rules: {
            required: true
          }
        },
      ],
      isShowDes: false,
      hcList: [], //绑定的耗材列表
      idMock: 0, //自增id,mock
      hcs: [] //耗材列表
    };
  },
  watch: {
    // 监听synergeticChecked变化
    synergeticChecked: {
      handler: function(n, o) {
        this.model.synergeticChecked = n;
      }
    }
  },
  methods: {
    // 切换处理方式
    changeHandleTypes() {
      let reverseArr = this.model.category.filter(Boolean).reverse(); //数组翻转，取第一项不为空的
      let sjId = reverseArr[0]; //事件Id
      let sj = this.initSjList.filter(v => v.id == sjId)[0];
      console.log(this.order, sj);
      this.isShowDes = !(this.order == 1 && sj && sj.hasSimple == 1);
    },
    // 获取耗材列表
    getHcs() {
      this.$http
        .post("service/bpm/data/fetchDataList/consumable", {
          idx: 0,
          sum: 1000,
          consumable: { isInventory: 1 }
        })
        .then(res => {
          if (res.data.status == 200) {
            this.hcs = res.data.list.map(v => ({
              value: v.id,
              text:
                v.name +
                "【" +
                v.brandModel +
                "】" +
                "【" +
                v.specification +
                "】"
            }));
          }
        });
    },
    // 增加耗材
    addHc() {
      let sourceId = this.modelData.incident.id;
      // consumablesSum 耗材数量
      // assetConsumablesId 耗材id
      // sourceId 事件id
      this.hcList.push({
        id: ++this.idMock,
        type: 2,
        consumablesSum: null,
        assetConsumablesId: null,
        sourceId,
        extra1: null,
        source: 1627
      });
    },
    // 删除耗材
    removeHc(id) {
      this.hcList = this.hcList.filter(v => v.id != id);
    },
    //获取区域
    getAreaList() {
      return new Promise((resolve, reject) => {
        this.$http
          .post("service/user/data/fetchDataList/area", { idx: 0, sum: 1000 })
          .then(res => {
            if (res.data.status == 200) {
              let arr = res.data.list.map(item => {
                return { value: item.id, text: item.area };
              });
              // console.log(arr,2222)
              // this.selectedAreaArr = arr;
              this.fields.forEach(item => {
                if (item.modelKey === "selectArea") {
                  item.props.options = arr;
                }
              });
              resolve(res);
            }
          });
      });
    },
    //根据区域获取地点
    getPlaceList(id) {
      return new Promise((resolve, reject) => {
        this.$http
          .post("service/user/data/fetchDataList/place", {
            idx: 0,
            sum: 1000,
            place: { area: { id } }
          })
          .then(res => {
            if (res.data.status == 200) {
              let arr = res.data.list.map(item => {
                return { value: item.id, text: item.place };
              });
              // console.log(arr,2222)
              // this.selectedAreaArr = arr;
              this.fields.forEach(item => {
                if (item.modelKey === "selectPlace") {
                  item.props.options = arr;
                }
              });
              resolve(res);
            }
          });
      });
    },
    //   获取事件数据
    getParamsData() {
      var that = this;
      that.$http
        .get(
          "/service/form/renderForm/handlerform/" +
            that.processInstanceId +
            "/" +
            that.loginUser.id +
            "/" +
            that.id,
          {}
        )
        .then(res => {
          console.log(res.data, 666);
          that.modelData = res.data.model;
          if (
            that.modelData.incident.category.hasSimple == 1 &&
            this.order == 1
          ) {
            this.isShowDes = false;
          } else {
            this.isShowDes = true;
          }
          //seimin
          localStorage.setItem("modelData", JSON.stringify(that.modelData));
        });
    },
    //展示图片
    showImgs(imgs) {
      this.$createImagePreview({
        imgs: imgs.map(v => v.previewUrl)
      }).show();
    },
    // 获取图片
    getImgs() {
      var that = this;
      that.$http
        .get(
          "service/common/common/listAttachment/incident/" +
            that.processInstanceId,
          {}
        )
        .then(function(res) {
          that.imgs = res.data.data.splice(0, 3);
        });
    },
    // 事件分类回显
    setCategory() {
      let that = this;
      // console.log(898);
      // console.log(that.modelData.incident.category);
      // let cate = that.modelData.incident.category;
      if (localStorage.getItem("referenceInfo")) {
        that.referenceInfo = JSON.parse(localStorage.getItem("referenceInfo"));
        // that.incidentTitle = that.model.handleDescription =
        // that.referenceInfo.content;
        //baba
        var selectedVal = []; //存id,对应value
        var selectedIndex = []; //存索引
        var selectedTxt = []; //存名称
        if (this.referenceInfo.category) {
          console.log(this.selectData, "所有事件分类");
          console.log(this.referenceInfo.category, "返回的数据");
          var category = this.referenceInfo.category;
          selectedVal = [category.id]; //存id,对应value
          // selectedVal
          if (category.parentCategory) {
            //上级
            selectedVal.unshift(category.parentCategory.id);
            if (category.parentCategory.parentCategory) {
              //上上级
              selectedVal.unshift(category.parentCategory.parentCategory.id);
            }
          }
          // selectedIndex selectedTxt
          //一级
          if (selectedVal[0]) {
            this.selectData.forEach(function(v, i) {
              if (v.value == selectedVal[0]) {
                selectedIndex.push(i);
                selectedTxt.push(v.text);
              }
            });
            // 二级
            if (selectedVal[1]) {
              this.selectData[selectedIndex[0].toString()].children.forEach(
                function(v, i) {
                  if (v.value == selectedVal[1]) {
                    selectedIndex.push(i);
                    selectedTxt.push(v.text);
                  }
                }
              );
              // 三级
              if (selectedVal[2]) {
                this.selectData[selectedIndex[0].toString()].children[
                  selectedIndex[1].toString()
                ].children.forEach(function(v, i) {
                  if (v.value == selectedVal[2]) {
                    selectedIndex.push(i);
                    selectedTxt.push(v.text);
                  }
                });
              }
            }
          }
          console.log(selectedVal, selectedIndex, selectedTxt, "获取的数据");
        }
        //回显
        var selected = [];
        selectedTxt.forEach(function(v, i) {
          if (v != "") {
            selected.push(v);
          }
        });
        this.selected = selected;
        this.selectedCategoryTxt = selected.length
          ? selected[selected.length - 1]
          : "";
        this.model.category = selectedVal;
        // localStorage.setItem("category", JSON.stringify(selectedIndex));
        // localStorage.setItem("categoryVal", JSON.stringify(selectedVal));
        // localStorage.setItem(
        //   "selectedCategoryTxt",
        //   JSON.stringify(this.selectedCategoryTxt)
        // );
      }
    },
    // 获取处理进度
    getProgressInfo() {
      var that = this;
      that.$http
        .post(
          "/service/bpm/bpm/flowTracingCustom/" + that.processInstanceId,
          {}
        )
        .then(function(res) {
          console.log(res.data);
          that.progressInfo = res.data.data;
          //处理日志startcaca
          if (that.modelData.incident.handlerLogs) {
            //添加日志
            that.modelData.incident.handlerLogs.forEach(v => {
              that.progressInfo.push({
                startTime: v.opTime,
                endTime: 1,
                desc: v.opValue,
                userName: v.userName,
                activityName: "事件处理"
              });
            });
          }
          //处理数据
          that.progressInfo.forEach(v => {
            if (!v.endTime) {
              v.endTime = 1;
            }
            v.startTime = new Date(v.startTime).getTime();
          });
          var kaishi = that.progressInfo.shift();
          var jiedan = that.progressInfo.shift();
          that.progressInfo.sort(function(o, c) {
            return c.startTime - o.startTime;
          });
          that.progressInfo.length && (that.progressInfo[0].endTime = "");
          that.progressInfo.push(jiedan);
          that.progressInfo.push(kaishi);
          console.log(that.progressInfo);
          //处理日志end
        });
    },
    //隐藏显示详情
    hides() {
      this.item_hides = !this.item_hides;
      $("#shows").slideToggle();
    },
    // 处理进度隐藏/展开
    proHides() {
      if (!this.pro_hides) {
        $("#progressBox").animate({
          height: $("#progressBox")[0].scrollHeight
        });
      } else {
        $("#progressBox").animate({ height: "1.7rem" });
      }
      this.pro_hides = !this.pro_hides;
    },
    // 快速定位
    toInfo(id) {
      this.actives = id;
      $("body,html").animate(
        {
          scrollTop:
            $("#" + id).offset().top -
            $(".header")[0].offsetHeight -
            $(".navBar")[0].offsetHeight
        },
        260
      );
    },
    // 输入处理方案
    inpTitle() {
      this.model.handleDescription = this.incidentTitle;
    },

    subVali() {
      this.vali = true;
    },
    // 获取处理方式
    getHandleCategory() {
      var that = this;
      this.$http
        .post("service/common/common/getDictionary", {
          key: "incident_handleCategory",
          type: "list"
        })
        .then(function(res) {
          res.data.forEach(function(v, i) {
            that.handleCategoryArr.push({
              text: v.name,
              value: v.id
            });
          });
          that.fields[0].props.options = that.handleCategoryArr;
        });
    },
    // 获取关闭代码
    getClosecode() {
      var that = this;
      this.$http
        .post("service/common/common/getDictionary", {
          key: "incident_closecode",
          type: "list"
        })
        .then(function(res) {
          res.data.forEach(function(v, i) {
            that.closecodeArr.push({
              text: v.desc,
              value: v.id
            });
          });
          that.fields[2].props.options = that.closecodeArr;
          that.model.closecode = 1572;//设计如此，默认“完全解决”
        });
    },
    // 获取指派对象baba
    getZpUser() {
      var that = this;
      var postData = {
        idx: 0,
        sum: 1000,
        user: {
          roledata: { rolecode: "first-line support" },
          roledata2: { rolecode: "second-line support" },
          selectType: "1"
        }
      };
      this.$http
        .post("service/user/data/fetchDataList/user", postData)
        .then(function(res) {
          var handlerUserArr = [];
          res.data.list.forEach(function(v, i) {
            handlerUserArr.push({
              text: v.name,
              value: v.id
            });
          });
          that.fields[15].props.options = handlerUserArr;
        });
    },
    // 获取升级对象
    getUpUser() {
      var that = this;
      var postData = {
        idx: 0,
        sum: 1000,
        user: {
          roledata: { rolecode: "second-line support" },
          selectType: "1"
        }
      };
      this.$http
        .post("service/user/data/fetchDataList/user", postData)
        .then(function(res) {
          var handlerUserArr = [];
          res.data.list.forEach(function(v, i) {
            handlerUserArr.push({
              text: v.name,
              value: v.id
            });
          });
          that.fields[6].props.options = handlerUserArr;
        });
    },
    // 获取转派对象 liaomingming
    getRotateUser(transferModeId) {
      console.log(transferModeId,this.model);
      this.fields[8].props.options = [];
      this.model.handlerUser = '';
      const postData = {
        idx: 0,
        sum: 1000,
        user: {
          roledata: { rolecode: "first-line support" },
          selectType: "1"
        }
      };
      if(transferModeId == 2){
        // 跨科室转派
        postData.user.duty = {id:this.model.duty};
      }
      this.$http
        .post("service/user/data/fetchDataList/user", postData)
        .then((res) => {
          const handlerUserArr = [];
          res.data.list.forEach(function(v, i) {
            handlerUserArr.push({
              text: v.name,
              value: v.id
            });
          });
          this.fields[8].props.options = handlerUserArr;
        });
    },
    // 获取院区
    getRotateBranch() {
      console.log(this.model);
      this.fields[8].props.options = [];
      this.model.handlerUser = '';
      this.fields[19].props.options = [];
      this.model.duty = '';
      const postData = {
        idx: 0,
        sum: 1000,
      };
      this.$http
        .post("service/user/data/fetchDataList/branch", postData)
        .then((res) => {
          const branchs = [];
          res.data.list.forEach(function(v, i) {
            branchs.push({
              text: v.hosName,
              value: v.id
            });
          });
          this.fields[18].props.options = branchs;
          if(this.loginUser.duty){
            this.model.branch = this.loginUser.duty.branch;
          }else if(this.loginUser.branch){
            this.model.branch = this.loginUser.branch?this.loginUser.branch.id:undefined;
          }
          this.getRotateDuty(this.model.branch);
        });
    },
    // 获取责任科室
    getRotateDuty(branchId) {
      console.log(this.model);
      this.fields[8].props.options = [];
      this.model.handlerUser = '';
      const postData = {
        idx: 0,
        sum: 1000,
        dutyDepartment:{
          branch:branchId
        }
      };
      this.$http
        .post("service/user/data/fetchDataList/dutyDepartment", postData)
        .then((res) => {
          const dutys = [];
          res.data.list.forEach(function(v, i) {
            dutys.push({
              text: v.dept,
              value: v.id
            });
          });
          this.fields[19].props.options = dutys;
        });
    },
    // 获取协同对象
    getSynerUser() {
      var that = this;
      var postData = {
        idx: 0,
        sum: 1000
      };
      this.$http
        .post("service/user/data/fetchDataList/user", postData)
        .then(function(res) {
          var handlerUserArr = [];
          res.data.list.forEach(function(v, i) {
            handlerUserArr.push({
              label: v.name,
              value: v.id
            });
          });
          that.fields[10].props.options = handlerUserArr;
          that.synergeticList = handlerUserArr;
        });
    },
    // 获取页面数据
    getMessage() {
      var that = this;
      if (localStorage.getItem("model")) {
        that.model = JSON.parse(localStorage.getItem("model"));
      }
      if (localStorage.getItem("modelData")) {
        that.modelData = JSON.parse(localStorage.getItem("modelData"));
      }
      if (localStorage.getItem("referenceInfo")) {
        that.referenceInfo = JSON.parse(localStorage.getItem("referenceInfo"));
        that.incidentTitle = that.model.handleDescription =
          that.referenceInfo.content;
      }
      if (localStorage.getItem("order")) {
        that.order = localStorage.getItem("order") - 0;
      }
      // if (localStorage.getItem("selectedCategoryTxt")) {
      //   that.selectedCategoryTxt = JSON.parse(
      //     localStorage.getItem("selectedCategoryTxt")
      //   );
      // }
      that.getProgressInfo();
    },
    // 事件分类
    showCategoryPicker() {
      this.categoryPicker.show();
    },
    selectCategoryHandler(selectedVal, selectedIndex, selectedTxt) {
      console.log(selectedVal, selectedIndex, selectedTxt);
      let reverseArr = selectedVal.filter(Boolean).reverse(); //数组翻转，取第一项不为空的
      let sjId = reverseArr[0]; //事件Id baba
      let sj = this.initSjList.filter(v => v.id == sjId)[0];
      var selected = [];
      selectedTxt.forEach(function(v, i) {
        if (v != "") {
          selected.push(v);
        }
      });
      this.selected = selected;
      this.selectedCategoryTxt = selected.length
        ? selected[selected.length - 1]
        : "";
      this.model.category = selectedVal;
      // localStorage.setItem("category", JSON.stringify(selectedIndex));
      // localStorage.setItem("categoryVal", JSON.stringify(selectedVal));
      // localStorage.setItem(
      //   "selectedCategoryTxt",
      //   JSON.stringify(this.selectedCategoryTxt)
      // );
      if (this.order == 1 && sj.hasSimple == 1) {
        this.isShowDes = false;
      } else {
        this.isShowDes = true;
      }
    },
    getIncidentcategory() {
      this.loadShow = true;
      var that = this;
      this.$http
        .post("service/bpm/data/fetchDataList/incidentcategory", {
          idx: 0,
          sum: 1000
        })
        .then(function(res) {
          that.initSjList = JSON.parse(JSON.stringify(res.data.list));
          var list = res.data.list;
          var tree = [];
          list.forEach((v, i) => {
            if (!v.parent) {
              tree[i] = {
                value: v.id,
                text: v.category,
                children: []
              };
            } else {
              tree.forEach((val, idx) => {
                if (
                  v.parent &&
                  !v.parent.parent &&
                  val.text == v.parent.category
                ) {
                  tree[idx].children.push({
                    value: v.id,
                    text: v.category,
                    children: []
                  });
                } else if (v.parent.parent) {
                  tree[idx].children.forEach((value, index) => {
                    if (value.text == v.parent.category) {
                      tree[idx].children[index].children.push({
                        value: v.id,
                        text: v.category
                      });
                    }
                  });
                }
              });
            }
          });

          // if (!localStorage.getItem("category")) {
          if (true) {
            let cate = that.modelData.incident.category;
            let cateGrand =
              cate.parentCategory &&
              cate.parentCategory.parentCategory &&
              cate.parentCategory.parentCategory.id;
            let cateFa = cate.parentCategory && cate.parentCategory.id;
            let cateSelf = cate.id;
            console.log(cate, tree);
            var i1 = 0,
              i2 = 0,
              i3 = 0;
            var selectedVal = [];
            var selectedIndex = [];
            var selectedTxt = [];
            tree.forEach((v, i) => {
              if (v.value == cateGrand) {
                selectedVal.push(v.value);
                selectedIndex.push(i);
                selectedTxt.push(v.text);
                v.children.forEach((va, ind) => {
                  if (va.value == cateFa) {
                    selectedVal.push(va.value);
                    selectedIndex.push(ind);
                    selectedTxt.push(va.text);
                    va.children.forEach((val, idx) => {
                      if (val.value == cateSelf) {
                        selectedVal.push(val.value);
                        selectedIndex.push(idx);
                        selectedTxt.push(val.text);
                      }
                    });
                  }
                });
              }
            });

            console.log(selectedVal, selectedIndex, selectedTxt);
            // console.log(i1,i2,i3);
            // var cateData=[i1,i2,i3]

            that.selectData = tree;
            // 获取事件分类并设置
            that.setCategory();
            that.categoryPicker = that.$createCascadePicker({
              title: "事件分类选择",
              data: that.selectData,
              selectedIndex: selectedIndex,
              onSelect: that.selectCategoryHandler
            });

            setTimeout(() => {
              that.selectCategoryHandler(
                selectedVal,
                selectedIndex,
                selectedTxt
              );
            }, 500);
          } else {
            // that.selectData = tree;
            // // 获取事件分类并设置
            // that.setCategory();
            // that.categoryPicker = that.$createCascadePicker({
            //   title: "事件分类选择",
            //   data: that.selectData,
            //   selectedIndex: JSON.parse(localStorage.getItem("category")) || [
            //     0,
            //     0,
            //     0
            //   ],
            //   onSelect: that.selectCategoryHandler
            // });
            // that.model.category = JSON.parse(
            //   localStorage.getItem("categoryVal")
            // );
          }
          that.loadShow = false;
        });
    },
    // 暂时存值
    setLocalStroageData() {
      var that = this;
      var a1 = [],
        a2 = [],
        a3 = [],
        category = [],
        solutionType = [],
        synergeticChecked = [];
      that.model.category.forEach(function(v, i) {
        if (v) {
          a1.push(v);
        }
      });
      category = a1;
      that.model.solutionType.forEach(function(v, i) {
        if (v) {
          a2.push(v);
        }
      });
      solutionType = a2;

      that.synergeticChecked.forEach(function(v, i) {
        a3.push({ id: v });
      });
      synergeticChecked = a3;

      that.modelData.incident.category = {
        id: category[category.length - 1]
      };
      that.modelData.loginUser = that.loginUser;
      if (that.order == 1) {
        // 直接处理
        that.modelData.handler_code = "resolve";
        that.modelData.msgflag = "申请关闭";
        that.modelData.submit = "申请关闭";
        that.modelData.incident.handleDescription =
          that.model.handleDescription;
        that.modelData.incident.handleCategory = {
          id: that.model.handleCategory
        };
        that.modelData.incident.closecode = { id: that.model.closecode };
        that.modelData.isSolution = that.model.knowledge;
        that.modelData.bpm_activiti = {
          solutionType: {
            id: solutionType[solutionType.length - 1]
          }
        };
        // 协同
        that.modelData.incident.synergeticReason = that.model.synergeticReason;
        delete that.modelData.isupreason;
        delete that.modelData.examine;
        delete that.modelData.assignee;
        delete that.modelData.transferReason;
        that.modelData.incident.synergetic = synergeticChecked;
      } else if (that.order == 2) {
        // 升级
        that.modelData.handler_code = "function";
        that.modelData.msgflag = "升级";
        that.modelData.submit = "升级";
        that.modelData.isupreason = that.model.isupreason;
        that.modelData.assignee = that.model.handlerUser;
        that.modelData.examine = {
          upgradeAuditor: { id: that.modelData.assignee }
        };
        delete that.modelData.transferReason;
        delete that.modelData.incident.synergetic;
        delete that.modelData.incident.synergeticReason;
        if (that.modelData.isSolution) {
          delete that.modelData.isSolution;
        }
      } else if (that.order == 3) {
        // 转派
        that.modelData.handler_code = "forward";
        that.modelData.msgflag = "转派";
        that.modelData.submit = "转派";
        that.modelData.transferReason = that.model.transferReason;
        that.modelData.assignee = that.model.handlerUser;
        delete that.modelData.isupreason;
        delete that.modelData.examine;
        delete that.modelData.incident.synergetic;
        delete that.modelData.incident.synergeticReason;
        if (that.modelData.isSolution) {
          delete that.modelData.isSolution;
        }
      }
      that.model.fileUrl = "url";
      that.loadShow = true;
    },
    // 处理方案引入知识库
    referKnowledge() {
      var that = this;
      if (!that.model.handleDescription) {
        alert("请输入处理方案");
        return;
      }
      that.setLocalStroageData();
      localStorage.setItem("modelData", JSON.stringify(that.modelData));
      localStorage.setItem("model", JSON.stringify(that.model));
      localStorage.setItem("order", that.order);
      this.$router.push({
        name: "ReferenceList",
        params: { data: that.model.handleDescription }
      });
    },
    // 新增耗材
    addHcPost() {
      //添加耗材发送请求 start
      let data = JSON.parse(JSON.stringify(this.hcList));
      data.forEach(v => {
        delete v.id;
      });
      return this.$http.post("service/cmdb/inOutStore/out", { data });
      //添加耗材发送请求 end
    },
    async basePost() {
      if (this.hcList.length) {
        let flag = this.hcList.every(
          v => v.consumablesSum && v.assetConsumablesId && v.extra1
        );
        if (!flag) {
          this.$createDialog({
            type: "alert",
            title: "请填写必填项",
            content: "耗材信息填写不完整",
            icon: "cubeic-wrong"
          }).show();
          return;
        }
        console.log(this.hcList);
        let re = await this.addHcPost();
        if (re.data.status != 200) {
          this.$createDialog({
            type: "alert",
            title: "提示",
            content: re.data.msg,
            icon: "cubeic-wrong"
          }).show();
          return;
        }
      }
      let that = this;
      if (this.order == 5) {
        that.$http
          .post(
            "service/bpm/bpm/delegateTask/" + that.modelData.incident.taskId,
            { assginee: that.model.handlerUser }
          )
          .then(function(res) {
            if (res.data) {
              $("#fade").fadeIn();
              that.promptingConent = "恭喜您,提交成功!";
              that.promptingStatus = true;
              that.dialog = that
                .$createDialog({
                  type: "alert",
                  title: "提交成功",
                  content: "点击返回首页",
                  icon: "cubeic-right",
                  onConfirm: (e, promptValue) => {
                    that.$router.push({ path: "/main" });
                  }
                })
                .show();
              // localStorage.removeItem("category");
              localStorage.removeItem("model");
              localStorage.removeItem("modelData");
              localStorage.removeItem("referenceInfo");
              localStorage.removeItem("solution");
              localStorage.removeItem("order");
              setTimeout(function() {
                $("#fade").fadeOut();
              }, 2000);
            } else {
              $("#fade").fadeIn();
              that.promptingConent = "系统错误,请稍后再试!";
              that.promptingStatus = false;
              that.loadShow = false;
              that.dialog = that
                .$createDialog({
                  type: "alert",
                  title: "系统错误,请稍后再试!",
                  content: "点击返回首页",
                  icon: "cubeic-wrong",
                  onConfirm: (e, promptValue) => {
                    that.$router.push({ path: "/main" });
                  }
                })
                .show();
              setTimeout(function() {
                $("#fade").fadeOut();
              }, 2000);
            }
          });
      } else {
        that.$http
          .post(
            "service/bpm/bpm/completeTask/" +
              that.modelData.incident.taskId +
              "/" +
              that.loginUser.id,
            that.modelData
          )
          .then(function(res) {
            if (res.data) {
              setTimeout(function() {
                that.$refs.upload.start();
              }, 100);
              $("#fade").fadeIn();
              that.promptingConent = "恭喜您,提交成功!";
              that.promptingStatus = true;
              that.dialog = that
                .$createDialog({
                  type: "alert",
                  title: "提交成功",
                  content: "点击返回首页",
                  icon: "cubeic-right",
                  onConfirm: (e, promptValue) => {
                    that.$router.push({ path: "/main" });
                  }
                })
                .show();
              // localStorage.removeItem("category");
              localStorage.removeItem("model");
              localStorage.removeItem("modelData");
              localStorage.removeItem("referenceInfo");
              localStorage.removeItem("solution");
              localStorage.removeItem("order");
              setTimeout(function() {
                $("#fade").fadeOut();
              }, 2000);
            } else {
              $("#fade").fadeIn();
              that.promptingConent = "系统错误,请稍后再试!";
              that.promptingStatus = false;
              that.loadShow = false;
              that.dialog = that
                .$createDialog({
                  type: "alert",
                  title: "系统错误,请稍后再试!",
                  content: "点击返回首页",
                  icon: "cubeic-wrong",
                  onConfirm: (e, promptValue) => {
                    that.$router.push({ path: "/main" });
                  }
                })
                .show();
              setTimeout(function() {
                $("#fade").fadeOut();
              }, 2000);
            }
          });
      }
    },
    handlerFn() {
      let that = this;
      //填写了处理日志，并且是处理中状态
      if (
        that.handlerLog &&
        that.handlerLog.trim() &&
        that.modelData.incident.state.value == "handler"
      ) {
        that.$http
          .post("service/bpm/data/addData/operationLog", {
            operationLog: {
              opType: "handlerLog",
              opValue: that.handlerLog,
              extra1: that.modelData.incident.id
            }
          })
          .then(function(result1) {
            that.basePost();
          });
      } else {
        that.basePost();
      }
    },
    // 提交
    submitHandler() {
      var that = this;

      that.setLocalStroageData();
      // that.modelData.incident.place = {
      //   area:{
      //     id:this.selectedAreaId,
      //     area:this.selectedAreaName
      //   },
      //   id:this.selectedPlaceId,
      //   place:this.selectedPlaceName
      // };//增加区域地点
      console.log(that.model, that.modelData, 11111);
      // console.log(this.selectedPlaceId,this.selectedAreaId,8888);//2020年4月25日16:12:55
      that.model.fileUrl = "url";
      that.loadShow = true;
      //处理中,积分机制
      if (
        this.order == 1 &&
        (this.integralMechanism == 1 ||
          (this.integralMechanism == 2 && this.loginUser.userType.value == 2))
      ) {
        let category = this.initSjList.find(
          v => v.id == this.modelData.incident.category.id
        );
        this.$refs.seiminModel.show({
          category,
          type: "handler",
          btns: [
            {
              click: () => {
                this.loadShow = false;
                this.$refs.seiminModel.close();
              }
            },
            {
              click: () => {
                if (!this.$refs.seiminModel.complexity) {
                  this.$createDialog({
                    type: "alert",
                    title: "操作失败",
                    content: "请选择工时!",
                    icon: "cubeic-wrong"
                  }).show();
                  return;
                }
                console.log(this.$refs.seiminModel);
                if (
                  this.$refs.seiminModel.complexitySource !=
                    this.$refs.seiminModel.complexity &&
                  !this.$refs.seiminModel.updateReason.trim()
                ) {
                  this.$createDialog({
                    type: "alert",
                    title: "操作失败",
                    content: "请填写升级原因!",
                    icon: "cubeic-wrong"
                  }).show();
                  return;
                }
                this.$http
                  .post("service/common/common/getDictionary", {
                    key: "incident_integral_state",
                    type: "list"
                  })
                  .then(result => {
                    result = result.data;
                    // let auditState =
                    //   this.$refs.seiminModel.complexitySource ==
                    //   this.$refs.seiminModel.complexity
                    //     ? result.find(v => v.value == 1)
                    //     : result.find(v => v.value == 0);
                    let auditState = result.find(v => v.value == 0);
                    let postData = {
                      incidentIntegral: {
                        incidentId: this.modelData.incident.id,
                        auditState: auditState,
                        handlerUser: this.loginUser.id,
                        handlerUserName: this.loginUser.name,
                        sourceScore: this.$refs.seiminModel.complexitySource,
                        currentScore: this.$refs.seiminModel.complexity,
                        updateReason:
                          this.$refs.seiminModel.updateReason.trim() ||
                          undefined
                      }
                    };
                    this.$http
                      .post(
                        "service/bpm/data/addData/incidentIntegral",
                        postData
                      )
                      .then(result1 => {
                        if (result1.data.status == 200) {
                          this.$refs.seiminModel.close();
                          this.handlerFn();
                        } else {
                          this.$createDialog({
                            type: "alert",
                            title: "系统错误,请稍后再试!",
                            content: "",
                            icon: "cubeic-wrong"
                          }).show();
                        }
                      });
                  });
              }
            }
          ]
        });
      } else {
        this.handlerFn();
      }

      event.preventDefault();
    },
    validateHandler(result) {
      // console.log(result);
      this.validity = result.validity;
      this.valid = result.valid;
      // if (this.vali == true) {
      //   $("#fade").fadeIn();
      //   this.promptingConent = "提交失败,请填写必填信息!";
      //   this.promptingStatus = false;
      //   setTimeout(function() {
      //     $("#fade").fadeOut();
      //   }, 2000);
      // }
      // this.vali = false;
    },

    dateSelectHandler(selectedVal) {
      this.model.dateValue = new Date(
        selectedVal[0],
        selectedVal[1] - 1,
        selectedVal[2]
      ).toDateString();
    },
    filesAdded(files) {
      let hasIgnore = false;
      const maxSize = 1000 * 1024 * 1024; // 1M
      for (let k in files) {
        const file = files[k];
        if (file.size > maxSize) {
          file.ignore = true;
          hasIgnore = true;
        }
      }
      hasIgnore &&
        this.$createToast({
          type: "warn",
          time: 1000,
          txt: "不能上传超过100M的文件"
        }).show();
      // 暂停上传
      this.$refs.upload.pause();
    },
    fileSubmitted(files) {
      this.action.data = { fileName: files.name };
    }
  },
  created() {
    this.processInstanceId = this.$route.params.data
      ? this.$route.params.data.processInstanceId
      : JSON.parse(localStorage.getItem("modelData")).incident
          .processInstanceId;
    this.id = this.$route.params.data
      ? this.$route.params.data.id
      : JSON.parse(localStorage.getItem("modelData")).incident.id;

    this.action.target += this.processInstanceId;
    this.getParamsData();
    this.getHcs();
    this.getImgs();
    // 处理方式
    this.getHandleCategory();
    // 关闭代码
    this.getClosecode();
    // 升级对象
    this.getUpUser();
    // 指派对象
    this.getZpUser();
    // 获取转派方式
    this.fields[17].props.options = [{text:'科室内转派',value:1},{text:'跨科室转派',value:2}];
    this.model.transferMode = 1;
    this.getRotateUser(this.model.transferMode);
    // 转派对象
    // this.getRotateUser();
    // 协同对象
    this.getSynerUser();
    // 获取页面数据
    this.getMessage();
    // 事件分类
    this.getIncidentcategory();
  },
  mounted() {
    console.log(this.modelData, this.model, 999);
    // 获取区域列表
    // this.getAreaList().then(res=>{
    //   if(this.modelData.incident.place){
    //     // 获取地点列表
    //     this.getPlaceList(this.modelData.incident.place.area.id)
    //     .then(res1=>{
    //       this.selectedAreaId = this.modelData.incident.place.area.id;
    //       this.selectedAreaName = this.modelData.incident.place.area.area;
    //       this.model.selectArea = this.modelData.incident.place.area.id;
    //       this.selectedPlaceId = this.modelData.incident.place.id;
    //       this.selectedPlaceName = this.modelData.incident.place.place;
    //       this.model.selectPlace = this.modelData.incident.place.id;
    //     });
    //   }
    // })
  },
  components: {
    seiminModel,
    CubePage,
    CubeButtonGroup,
    DatePicker,
    // JsonView
    CubeExtendPopup,
    LoadIng,
    PrompTing,
    EventInformation
    // HandlerLog
  }
};
</script>

<style>
.hcList {
  display: flex;
  align-items: center;
  margin-top: 0.1rem;
}
.hcItem {
  flex: 4;
  margin: 0 0.05rem;
}
.hcItemClose {
  flex: 1;
  font-size: 0.4rem;
}
.addHc {
  width: 90%;
  height: 1rem;
  margin: 0 auto;
  border: 0.02rem solid #ccc;
  display: flex;
  justify-content: center;
  align-items: center;
}
.addHc .cubeic-add {
  font-size: 0.8rem;
}
.newIncident .cube-form-group {
  border-bottom: 0.02rem solid rgb(245, 245, 245);
}
.newIncident .sub .cube-btn {
  margin-top: 1.1rem;
}
.btn_plcaeholde .cube-btn {
  padding-left: 0;
  padding-right: 0;
  text-align: left;
  color: inherit;
  background: none;
  border: none;
}
.btn_plcaeholde .cube-btn:active {
  background-color: #fff;
}
.btn_plcaeholde .cube-btn::after {
  content: ">";
  float: right;
  margin-right: 0.15rem;
}
.cube-form_standard .cube-upload-def .cube-upload-btn,
.cube-form_standard .cube-upload-def .cube-upload-file {
  margin-left: 3% !important;
}
.sub .cube-btn {
  background-color: #005395 !important;
  width: 90%;
  margin: 0 auto;
  border-radius: 8px;
}
.cube-picker-wheel-item {
  text-overflow: ellipsis;
}
</style>
<style lang="less" scoped>
.header {
  width: 100%;
  height: 0.88rem;
  line-height: 0.88rem;
  text-align: center;
  color: #fff;
  font-size: 0.37rem;
  background: linear-gradient(#2e2f32, #414246);
  position: fixed;
  top: 0;
  z-index: 6;
}
.incidentTitle {
  .titleRefer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .titleTxtArea {
      font-size: 0.3rem;
      color: #333;
      height: 2rem;
      width: 62%;
      &:focus {
        outline: none;
      }
    }
    .abtn {
      display: inline-block;
      width: 37%;
      text-align: center;
      height: 0.48rem;
      color: #005395;
      font-size: 0.28rem;
    }
  }
}
.form-custom {
  .cube-form-item {
    .cube-btn {
      padding-left: 0;
      padding-right: 0;
      text-align: left;
      color: inherit;
      background: none;
      border: none;
    }
  }
}

.label {
  background-color: rgb(238, 238, 238);
  height: 0.6rem;
  line-height: 0.6rem;
  padding-left: 0.2rem;
  font-size: 0.24rem;
  color: #666666;
  span {
    font-size: 0.2rem;
    display: inline-block;
    margin-left: 0.08rem;
    color: #999999;
  }
  &.formLabel {
    background-color: #fff;
  }
}

.zhidu {
  display: flex;
  height: 0.7rem;
  line-height: 0.7rem;
  border-bottom: 0.02rem solid rgb(245, 245, 245);
  div:nth-child(1) {
    width: 27.5%;
    padding-left: 6%;
  }
}

.bgColor {
  background-color: white;
  &.newIncident {
    padding-top: 1.84rem;
  }
}

.uplod {
  padding: 0 0.24rem;
  border-bottom: 0.02rem solid rgb(245, 245, 245);
}
.handleRadio {
  border-bottom: 0.02rem solid rgb(245, 245, 245);
}
.synerBox {
  height: 3rem;
  overflow: scroll;
}

i.iconfont.blue {
  color: #005395;
  // &::after {
  //   content: "";
  //   width: 0.01rem;
  //   height: 0.4rem;
  //   background: #005395;
  //   position: relative;
  //   display: block;
  //   left: 0.14rem;
  // }
}
.againAssign {
  .header {
    width: 100%;
    height: 0.88rem;
    line-height: 0.88rem;
    text-align: center;
    color: #fff;
    font-size: 0.37rem;
    background: linear-gradient(#2e2f32, #414246);
    position: fixed;
    top: 0;
    z-index: 6;
  }
  .navBar {
    width: 100%;
    height: 0.96rem;
    line-height: 0.96rem;
    background-color: #fafafa;
    font-size: 0.28rem;
    position: fixed;
    top: 0.88rem;
    z-index: 9;
    div {
      width: 33.33%;
      text-align: center;
      &.p50 {
        width: 49.99%;
      }
      a {
        display: inline-block;
        height: 0.9rem;
        width: 1.7rem;
        padding: 0 0.1rem;
        &.active {
          color: #005395;
          border-bottom: 0.06rem solid #005395;
        }
      }
    }
  }

  .headtop {
    margin-top: 1.84rem;
  }
  .label {
    background-color: #eeeeee;
    height: 0.6rem;
    line-height: 0.58rem;
    padding-left: 0.2rem;
    font-size: 0.24rem;
    color: #666666;
    span {
      font-size: 0.2rem;
      display: inline-block;
      margin-left: 0.08rem;
      color: #999999;
    }
    &.formLabel {
      background-color: #fff;
    }
  }
  .conentBox {
    width: 100%;
    .conent {
      font-size: 0.32rem;
      font-weight: 400;
      line-height: 0.45rem;
      // border-bottom: 0.16rem solid #e5e5e5;

      .shows {
        display: none;
      }
      .boeder_B {
        border-bottom: 0.01rem solid #ccc;
      }
      p {
        &.desc {
          overflow: hidden;
        }
        .grayFont {
          width: 75%;
          text-align: right;
          overflow-x: scroll;
        }
      }
      .bottom {
        overflow: hidden;
        line-height: 0.86rem;
        border-bottom: 0.01rem solid #e6e6e6;
        font-size: 0.24rem;
        color: #999;
        padding: 0 0.24rem 0 0.48rem;
      }
      .info {
        color: #999;
        font-size: 0.28rem;
        overflow: hidden;
        .head {
          border-bottom: 0.01rem solid #e6e6e6;
          p {
            padding: 0.24rem 0.3rem;
            i {
              color: #00559d;
            }
          }
        }
        p {
          line-height: 0.4rem;
          padding: 0.1rem 0.24rem;
          overflow: hidden;
          .overflowEllipsis2 {
            margin-left: 1.96rem;
          }
        }
        .info_hide {
          padding: 0.2rem 0.24rem;
          border-bottom: 0.01rem solid #e6e6e6;
          .hide {
            color: #00559d;
          }
        }
        .imgs-container {
          a {
            color: #03c !important;
            &:visited {
              color: #551a8b !important;
            }
          }
          img {
            width: 1.5rem;
            height: 1.5rem;
            margin-right: 0.7rem;
            &:nth-child(1) {
              margin-left: 0.75rem;
            }
          }
        }
        .progress {
          padding: 0.2rem 0.2rem;
          overflow: hidden;
          transition-duration: 0.2s;
          transition-timing-function: linear;
          &.progressHide {
            height: 1.7rem;
          }
          .progress_info {
            overflow: hidden;
            margin-bottom: 0.1rem;
            &:nth-last-child(1) {
              .cont {
                border: none !important;
              }
            }
            .progress_info_L {
              float: left;
              color: #333;
              max-width: 18%;
            }
            .progress_info_R {
              float: right;
              margin-left: 0.09rem;
              width: 80%;
              font-size: 0.25rem;
              .time {
                i {
                  margin-left: -0.15rem;
                  &.icon-icon_weizuo {
                    color: #005495;
                  }
                  &.icon-icon_zhengzaijinx {
                    color: #48a843;
                    font-size: 0.37rem;
                  }
                }
                span {
                  margin-left: 0.15rem;
                }
              }
              .cont {
                border-left: 1px solid #999;
                padding-left: 0.4rem;
                min-height: 0.4rem;
                &.blue {
                  border-left: 1px solid #005395;
                }
              }

              .text1 {
                font-size: 0.15rem;
              }
              .text2 {
                color: #666;
                word-break: break-all;
              }
              p {
                padding: 0;
              }
            }
          }
        }
      }
      .txtLabel {
        width: 100%;
        overflow: hidden;
        padding: 0.32rem 0.24rem 0.32rem 0.32rem;
        .txt {
          width: 30%;
          color: #666;
        }
        .cube-textarea-wrapper {
          width: 62%;
        }
      }
      .sub {
        background: #ececec;
        .cube-btn {
          background-color: #005395 !important;
          width: 90%;
          margin: 0.2rem auto;
          border-radius: 8px;
        }
      }
    }
  }
  .showwrap {
    width: 75%;
    text-align: right;
  }
}
</style>
