<template>
  <div class="app-container">
    <el-descriptions title="编辑触发条件" />

    <div class="title">
      <!-- <div >触发条件</div> -->
      <div class="nodes">
        <!-- 一级 -->
        <div class="node" v-if="updata">
          <el-select
            v-model="updata.triggerConditionCode"
            style="width: 120px"
            disabled
            @change="changetriggerConditionName($event, index)"
          >
            <el-option
              v-for="item in optionsname"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-select
            disabled
            v-model="updata.triggerConditionOperator"
            style="width: 100px"
            @change="changetriggerLogic($event, index)"
          >
            <el-option
              v-for="item in optionstriggerConditionOperator"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>

          <el-input
            disabled
            v-if="updata.triggerConditionCode != 'DRESSING_CHANGE_DATE'"
            v-model="updata.triggerConditionValue"
            style="width: 300px"
          ></el-input>
          <el-date-picker
            v-if="updata.triggerConditionCode == 'DRESSING_CHANGE_DATE'"
            v-model="updata.triggerConditionValue"
            style="width: 300px"
            type="date"
            placeholder="选择日期时间"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
          <!-- <span class="icon"> -->
          <!-- <el-button
              type="danger"
              class="el-icon-remove-outline"
              plain
              @click="delitemlist(index)"
              v-if="index != 0"
            ></el-button> -->

          <!-- <i
              class="el-icon-delete"
              @click="delitem(index)"
              v-if="index != 0"
            ></i> -->
          <!-- <i
              v-if="index == 0"
              class="el-icon-circle-plus-outline"
              @click="addtriggerCondition(index)"
              >添加触发条件</i
            > -->
          <!-- <el-button
              type="primary"
              plain
              class="el-icon-circle-plus-outline"
              @click="addtriggerConditionlist(index)"
              v-if="index == 0"
              >添加属性</el-button
            > -->
          <!-- </span> -->
        </div>
        <!-- 二级 -->
        <div v-show="show3 == true">
          <div class="node" v-for="(item, index) in updatalist" :key="index">
            <div
              style="width: 60px; position: absolute; top: 8%"
              v-if="updatalist.length == 2"
            >
              <img src="@/assets/images/images.png" class="login-code-img" />
              <div class="selectname">
                <el-select
                  disabled
                  v-model="item.triggerLogic"
                  style="width: 60px"
                  @change="changetriggerLogicsname($event, index)"
                >
                  <el-option
                    v-for="item in optionslistS"
                    :key="item.dictValue"
                    :label="item.dictLabel"
                    :value="item.dictValue"
                  >
                  </el-option>
                </el-select>
              </div>
            </div>
            <div>
              <el-select
                v-model="item.triggerConditionCode"
                style="width: 120px"
                disabled
                @change="changetriggerConditionName($event, index)"
              >
                <el-option
                  v-for="item in optionsname"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
              <el-select
                disabled
                v-model="item.triggerConditionOperator"
                style="width: 100px"
                @change="changetriggerLogic($event, index)"
              >
                <el-option
                  v-for="item in optionstriggerConditionOperator"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>

              <el-input
                v-if="item.triggerConditionCode != 'DRESSING_CHANGE_DATE'"
                v-model="item.triggerConditionValue"
                style="width: 300px"
                disabled
              ></el-input>
              <el-date-picker
                disabled
                v-if="item.triggerConditionCode == 'DRESSING_CHANGE_DATE'"
                v-model="item.triggerConditionValue"
                style="width: 300px"
                type="date"
                placeholder="选择日期时间"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </div>
          </div>
        </div>
      </div>

      <div class="select">
        <span> 适用范围 </span>
        <el-select v-model="updata.suitRange" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
          >
          </el-option>
        </el-select>
      </div>
      <div class="addlistname">
        <i @click="edit()" class="el-icon-edit">编辑</i>

        <i
          @click="addlistname()"
          class="el-icon-arrow-down"
          v-if="show3 == false"
          >展开</i
        >
        <i @click="addlistname()" class="el-icon-arrow-up" v-else>关闭</i>
      </div>
    </div>
    <div class="list">
      <div class="timelist">
        <div class="timetitle">
          管理路径节点({{ lists.length }})
          <i class="el-icon-circle-plus-outline" @click="addlist"></i>
        </div>
        <el-timeline>
          <el-timeline-item
            v-for="(item, index) in lists"
            :key="index"
            :color="listindex == index ? '#409EFF' : ''"
          >
            <div class="top" @click="topclickevent(index)">
              <div class="toptop">
                <el-select v-model="item.routeNodeName" style="width: 87px">
                  <el-option label="出院后" value="AFTER_DISCHARGE" />
                  <el-option label="入院后" value="AFTER_ADMISSION" />
                  <el-option label="就诊后" value="AFTER_CONSULTATION" />
                  <el-option
                    label="就诊/出院后"
                    value="AFTER_VISIT_DISCHARGE"
                  />
                  <el-option label="术前" value="PREOPERATIVE" />
                  <el-option label="术后" value="POSTOPERATIVE" />
                </el-select>
                <el-input
                  v-model="item.routeNodeDay"
                  style="width: 50px"
                ></el-input>
                <span>天</span>
              </div>
              <div>
                <i class="el-icon-delete" @click="delitemh(item, index)"></i>
                <i
                  class="el-icon-circle-plus-outline"
                  @click="additem(item)"
                ></i>
              </div>
            </div>
            <el-card
              v-for="(uitem, uindex) in item.list"
              :key="uitem.id"
              @click.native="bottomclickevent(uitem, index, uindex)"
              :class="listindex == index && itemindex == uindex ? 'cards' : ''"
            >
              <h3 style="height: 20px">{{ uitem.taskTypeName }}</h3>
              <p style="height: 16px">{{ uitem.taskSubdivisionName }}</p>
            </el-card>
          </el-timeline-item>
        </el-timeline>
      </div>
      <div class="texts">
        <div class="topform">
          <el-form ref="form" :inline="true" :model="form" class="form">
            <el-form-item label="任务类型" prop="">
              <el-select
                v-model="form.taskType"
                style="width: 110px"
                @change="changeTaskType"
              >
                <el-option
                  v-for="item in selectTaskTypeList"
                  :key="item.id"
                  :label="item.taskTypeName"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="任务细分" prop="">
              <el-select
                v-model="form.taskSubdivision"
                style="width: 110px"
                @change="changetaskSubdivision"
              >
                <el-option
                  v-for="item in taskPartitionList"
                  :key="item.id"
                  :label="item.taskTypeName"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="任务状态" prop="">
              <el-select v-model="form.taskStatus" style="width: 100px">
                <el-option
                  v-for="item in taskStatusDictList"
                  :key="item.id"
                  :label="item.taskStatusName"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="二级分类描述" prop="">
              <el-input
                v-model="form.secondClassifyDescribe"
                style="width: 100px"
              ></el-input>
            </el-form-item>
            <el-form-item label="执行时间" prop="">
              <el-time-select
                v-model="form.executionTime"
                style="width: 120px"
                :picker-options="{
                  start: '08:30',
                  step: '00:30',
                  end: '18:30',
                }"
                placeholder="选择时间"
              >
              </el-time-select>
            </el-form-item>
            <el-form-item
              label="问卷库模板选择"
              prop=""
              v-if="form.taskSubdivisiontemplateType == 'QUESTIONNAIRE'"
            >
              <question @on-template="questionontemplate"></question>
            </el-form-item>
            <el-form-item
              label="宣教库模板选择"
              prop=""
              v-if="form.taskSubdivisiontemplateType == 'PROPAGANDA'"
            >
              <propaganda @on-template="propagandaontemplate"></propaganda>
            </el-form-item>
          </el-form>
        </div>
        <div class="bottomform">
          <wangeditor
            style="width: 100%"
            @on-nodeContent="onNodeContent"
            ref="wangeditor"
          />
          <div class="card">
            <div class="flex">
              <div class="pushMethod">
                推送方式：
                <span> 短信 </span>
              </div>
              <div class="pushMethod">
                模板：
                <message @on-template="messageontemplate"></message>
              </div>
              <div class="pushMethod">
                <el-switch
                  v-model="form.messagePushSign"
                  active-color="#13ce66"
                  active-value="1"
                  inactive-value="0"
                >
                </el-switch>
              </div>
            </div>
            <div class="flextwo">
              <div class="text">短信预览：</div>
              <el-input
                style="border: none"
                class="textarea"
                v-model="form.messagePreview"
              ></el-input>
            </div>
          </div>
          <div class="card">
            <div class="flex">
              <div class="pushMethod">
                推送方式：
                <span> 公众号 </span>
              </div>
              <div class="pushMethod">
                模板：
                <span>
                  <officialAccount
                    @on-template="officialAccountontemplate"
                  ></officialAccount>
                </span>
              </div>
              <div class="pushMethod">
                <el-switch
                  v-model="form.officialPushSign"
                  active-color="#13ce66"
                  active-value="1"
                  inactive-value="0"
                >
                </el-switch>
              </div>
            </div>
            <div class="flextwo">
              <div class="text">提醒内容：</div>
              <el-input
                v-model="form.officialRemindContent"
                placeholder=""
                class="textarea"
                style="border: none"
              ></el-input>
            </div>
          </div>
          <div class="card">
            <div class="flex">
              <div class="pushMethod">
                推送方式：
                <span> 小程序 </span>
              </div>
              <div class="pushMethod">
                模板：
                <span>
                  <miniProgram @on-template="miniProgramtemplate"></miniProgram>
                </span>
              </div>
              <div class="pushMethod">
                <el-switch
                  v-model="form.appletPushSign"
                  active-color="#13ce66"
                  active-value="1"
                  inactive-value="0"
                >
                </el-switch>
              </div>
            </div>
            <div class="flextwo">
              <div class="text">提醒内容：</div>
              <el-input
                v-model="form.input"
                placeholder=""
                class="textarea"
                style="border: none"
              ></el-input>
            </div>
            <div class="flextwo">
              <div class="text">提示说明：</div>
              <el-input
                v-model="form.input"
                placeholder=""
                class="textarea"
                style="border: none"
              ></el-input>
            </div>
          </div>
          <!-- <div class="card" style="height: 250px;">
                        <div class="flex">
                            <div class="pushMethod">
                                推送方式：
                                <span>
                                    AI电话
                                </span>
                            </div>
                            <div class="pushMethod">
                                模板：
                                <span>
                                    <el-select v-model="value" style="width:200px;">
                                        <el-option v-for="item in taskStatusDictList" :key="item.id" style="color:black"
                                            :label="item.taskStatusName" :value="item.id">
                                        </el-option>
                                    </el-select>
                                </span>
                            </div>
                            <div class="pushMethod">
                                <el-switch v-model="form.value" active-color="#13ce66"  active-value="1"
                                    inactive-value="0">
                                </el-switch>
                            </div>
                        </div>
                        <div class="flextwo">
                            <div class="text">
                                机构名称：
                            </div>
                            <div class="text">
                                我是
                            </div>
                            <el-input v-model="form.input" placeholder="" style="width:150px;padding:0 10px"></el-input>
                            <div class="text">
                                的工作人员
                            </div>
                        </div>
                        <div class="flextwo">
                            <div class="text">
                                重播次数：
                            </div>
                            <el-input v-model="form.input" placeholder="" style="width:200px;"></el-input>
                            <div class="text" style="padding-left: 100px;">
                                时间间隔：
                            </div>
                            <el-input v-model="form.input" placeholder="" style="width:200px;"></el-input>
                        </div>
                        <div class="flextwo">
                            <div class="text">
                                短信提醒：
                            </div>
                            <el-select v-model="value" style="width:200px;">
                                <el-option v-for="item in taskStatusDictList" :key="item.id" style="color:black"
                                    :label="item.taskStatusName" :value="item.id">
                                </el-option>
                            </el-select>
                            <div class="text" style="padding-left: 100px;">
                                短信模板：
                            </div>
                            <el-select v-model="value" style="width:200px;">
                                <el-option v-for="item in taskStatusDictList" :key="item.id" style="color:black"
                                    :label="item.taskStatusName" :value="item.id">
                                </el-option>
                            </el-select>
                        </div>
                    </div> -->
        </div>
      </div>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="TemporaryStorage">暂 存</el-button>
      <!-- <el-button
        type="primary"
        @click="dialogVisible = true"
        v-if="form.specialDiseaseNodeId"
        >审核完成 {{ agreeNumber ? agreeNumber : "0" }} /
        {{ totalNumber ? totalNumber : "0" }}</el-button
      > -->
    </div>
    <!-- 添加触发条件 -->
    <el-dialog
      title="添加触发条件"
      :visible.sync="open"
      width="800px"
      append-to-body
    >
      <el-form
        ref="openlist"
        :model="openlist"
        :rules="rules"
        label-width="80px"
      >
        <el-form-item label="适用范围:">
          <el-select
            v-model="openlist.suitRange"
            @change="changeoptions"
            style="width: 200px"
          >
            <el-option
              v-for="item in options"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-descriptions title="触发条件"> </el-descriptions>
        <div class="nodesname">
          <div
            class="node"
            v-for="(item, index) in openlist.triggerConditionList"
            :key="index"
          >
            <div
              style="width: 60px; position: absolute; left: 2%; top: 57%"
              v-if="openlist.triggerConditionList.length === 3"
            >
              <img src="@/assets/images/images.png" class="login-code" />
              <div class="selectnamelist">
                <el-select
                  v-model="item.triggerLogic"
                  style="width: 60px"
                  placeholder=""
                  @change="changetriggerLogicsname($event, index)"
                >
                  <el-option
                    v-for="item in optionslistS"
                    :key="item.dictValue"
                    :label="item.dictLabel"
                    :value="item.dictValue"
                  >
                  </el-option>
                </el-select>
              </div>
            </div>
            <el-select
              v-model="item.triggerConditionCode"
              style="width: 120px"
              @change="changetriggerConditionName($event, index)"
            >
              <el-option
                v-for="item in optionsname"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
            <el-select
              v-model="item.triggerConditionOperator"
              style="width: 100px"
              @change="changetriggerLogic($event, index)"
            >
              <el-option
                v-for="item in optionstriggerConditionOperator"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>

            <el-input
              v-if="item.triggerConditionCode != 'DRESSING_CHANGE_DATE'"
              v-model="item.triggerConditionValue"
              style="width: 300px"
              placeholder="请输入触发条件"
            ></el-input>
            <el-date-picker
              v-if="item.triggerConditionCode == 'DRESSING_CHANGE_DATE'"
              v-model="item.triggerConditionValue"
              style="width: 300px"
              type="date"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
            <span class="icon">
              <el-button
                type="danger"
                class="el-icon-remove-outline"
                plain
                @click="delitemlistname(index)"
                v-if="index != 0"
              ></el-button>

              <!-- <i
              class="el-icon-delete"
              @click="delitem(index)"
              v-if="index != 0"
            ></i> -->
              <!-- <i
              v-if="index == 0"
              class="el-icon-circle-plus-outline"
              @click="addtriggerCondition(index)"
              >添加触发条件</i
            > -->
              <el-button
                type="primary"
                plain
                class="el-icon-circle-plus-outline"
                @click="addtriggerCondition(index)"
                v-if="index == 0"
                >添加属性</el-button
              >
            </span>
          </div>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="upload">确 定</el-button>
        <el-button @click="openfalse">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 提交审核 -->
    <el-dialog
      title="提交审核完成"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-form
        ref="routeform"
        :model="routeform"
        label-width="120px"
        :rules="rules"
      >
        <el-form-item label="节点审核状态" prop="routeCheckStatus">
          <el-radio v-model="routeform.routeCheckStatus" label="AGREE"
            >同意</el-radio
          >
          <el-radio v-model="routeform.routeCheckStatus" label="DISAGREE"
            >不同意</el-radio
          >
        </el-form-item>
        <el-form-item label="节点审核备注">
          <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入节点审核备注"
            v-model="routeform.routeCheckRemark"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="auditing">确 定</el-button>
        <el-button @click="handleClose">取 消</el-button>
      </div>
    </el-dialog>
    <!-- <div slot="footer" class="dialog-footer">
      <el-button @click="TemporaryStorage">暂 存</el-button>
      <el-button
        type="primary"
        @click="dialogVisible = true"
        v-if="form.specialDiseaseNodeId"
        >审核完成 {{ agreeNumber ? agreeNumber : "0" }} /
        {{ totalNumber ? totalNumber : "0" }}</el-button
      >
    </div> -->
    <!-- <div slot="footer" class="dialog-footer">
            <el-button @click="TemporaryStorage">暂 存</el-button>
            <el-button type="primary">审核完成</el-button>
        </div> -->
  </div>
</template>

<script>
import wangeditor from "../components/wangEditor.vue";
import question from "../components/question.vue";
import message from "../components/message.vue";
import propaganda from "../components/propaganda.vue";
import officialAccount from "../components/officialAccount.vue";
import miniProgram from "../components/miniProgram.vue";
// import {
//   selectTaskTypeList,
//   taskPartitionList,
//   taskStatusDictList,
// } from "@/api/system/specialDiseaseNode";
import { triggerConditionedit } from "@/api/system/editorialSpecialization";
import { getAgencytype } from "@/api/system/agency";
import {
  selectTaskTypeList,
  taskPartitionList,
  taskStatusDictList,
  specialDiseaseNode,
  triggerCondition,
  selectSpecialDisease,
  updateRouteCheckStatus,
  list,
  triggerConditionList,
} from "@/api/system/specialDiseaseNode";
export default {
  components: {
    wangeditor,
    question,
    propaganda,
    message,
    officialAccount,
    miniProgram,
  },
  name: "specialDiseaseNode",
  data() {
    return {
      openlist: {
        suitRange: "",
        routeId: "",
        triggerConditionList: [],
      },
      open: false,
      show3: false,
      activeNames: ["1"],
      routeform: {
        routeCheckStatus: null,
        routeCheckRemark: "",
      },
      optionstriggerConditionOperator: [
        {
          value: "CONTAIN",
          label: "包含",
        },
        {
          value: "NOT_CONTAIN",
          label: "不包含",
        },
        {
          value: "EQUAL_TO",
          label: "等于",
        },
        {
          value: "NOT_EQUAL_TO",
          label: "不等于",
        },
      ],
      optionslistS: [],

      optionsname: [
        {
          value: "DIAGNOSIS",
          label: "诊断",
        },
        {
          value: "DRESSING_CHANGE_DATE",
          label: "换药日期",
        },
        {
          value: "TREATMENT_METHOD",
          label: "治疗方式",
        },
        {
          value: "SURGICAL_NAME",
          label: "手术名称",
        },
        {
          value: "DRUG_NAME",
          label: "药品名称",
        },
      ],
      updata: [],
      updatalists: [],
      updatalist: [],
      // triggerConditionList: [{}],
      form: {
        nodeContent: "",
        templateId: "",
        templateName: "",
        taskType: "",
        taskTypeName: "",
        taskSubdivision: "",
        taskSubdivisionName: "",
        taskStatus: "",
        secondClassifyDescribe: "",
        executionTime: "",
        appletPushSign: "0",
        officialPushSign: "0",
        messagePushSign: "0",
        taskSubdivisiontemplateType: "",
      },
      itemindex: 0,
      listindex: 0,
      lists: [
        {
          routeNodeName: "",
          routeNodeDay: "",
          list: [
            {
              nodeContent: "",
              templateId: "",
              templateName: "",
              taskType: "",
              taskTypeName: "",
              taskSubdivision: "",
              taskSubdivisionName: "",
              taskStatus: "",
              secondClassifyDescribe: "",
              executionTime: "",
              appletPushSign: "0",
              officialPushSign: "0",
              messagePushSign: "0",
              taskSubdivisiontemplateType: "",
            },
          ],
        },
      ],
      value: "",
      input: "",
      //任务类型
      selectTaskTypeList: [],
      //任务状态
      taskStatusDictList: [],
      //任务细分
      taskPartitionList: [],
      routeId: "",
      options: [],
      dialogVisible: false,
      rules: {
        routeCheckStatus: [
          { required: true, message: "请选择节点审核状态", trigger: "change" },
        ],
      },
    };
  },
  created() {
    if (this.$route.query) {
      this.$set(this.updata, "suitRange", this.$route.query.suitRange);
      this.$set(this.openlist, "suitRange", this.$route.query.suitRange);

      // console.log(this.updata.suitRange, "5555555555555555");
      this.form.specialDiseaseNodeId = this.$route.query.id;
      this.openlist.routeId = this.$route.query.id;

      // triggerCondition(this.$route.query.id).then(res => { })
    }
    this.info()
    this.infolists();
    this.infolist();
    this.infolistoptionslistS();
    // this.taskinfo();
  },
  beforeDestroy() {},
  watch: {},
  mounted() {
    this.form = this.lists[0].list[0];
  },
  methods: {
    upload() {
      // const loading = this.$loading({
      //   lock: true,
      //   text: "Loading",
      //   spinner: "el-icon-loading",
      //   background: "rgba(0, 0, 0, 0.7)",
      // });
      this.openlist.triggerConditionList.forEach((e) => {
        e.routeId = this.$route.query.id;
        e.routeName = this.$route.query.routeName;
      });

      console.log(this.openlist, "(this.triggerConditionList");
      triggerCondition(this.openlist).then((res) => {
        // loading.close();
        this.$notify({
          type: "success",
          title: "提示",
          message: "修改触发条件成功成功",
        });
        this.infolist();
        this.openfalse();
      });
    },
    openfalse() {
      this.openlist.triggerConditionList = [
        {
          routeId: "",
          routeName: "",
          triggerConditionName: "",
          triggerConditionOperator: "",
          triggerConditionValue: "",
          triggerConditionName: "",
          triggerConditionOperatorName: "",

          triggerLogic: "",
          triggerLogicName: "",
        },
      ];
      this.open = false;
      this.resetForm("openlist");
    },
    addtriggerCondition() {
      this.idd++;
      var obj = {
        routeId: "",
        routeName: "",
        triggerConditionName: "",
        triggerConditionOperator: "",
        triggerConditionValue: "",
        triggerConditionName: "",
        triggerConditionOperatorName: "",

        triggerLogic: "",
        triggerLogicName: "",
      };
      //   if (this.form.voList.length == 5) {
      //     this.$message.error("最多批量添加5条");
      //   } else {
      //     this.form.voList.push(obj);
      //     // console.log(this.form)
      //   }
      //   this.updata.triggerConditionList.push({

      //   });
      // },
      if (this.openlist.triggerConditionList.length == 3) {
        this.$message.error("最多批量添加2条");
      } else {
        this.openlist.triggerConditionList.push(obj);
        // console.log(this.form)
      }
    },
    delitemlistname(index, item) {
      this.openlist.triggerConditionList.splice(index, 1);
    },
    //取消
    handleClose() {
      this.dialogVisible = false;
      this.routeform = {
        routeCheckStatus: "",
        routeCheckRemark: "",
      };
      this.resetForm("routeform");
    },
    //审核
    auditing() {
      this.$refs["routeform"].validate((valid) => {
        if (valid) {
          const loading = this.$loading({
            lock: true,
            text: "审核中",
            spinner: "el-icon-loading",
            background: "rgba(0, 0, 0, 0.7)",
          });
          if (!this.form.routeNodeDay) {
            this.$message.error("请输入节点时间段天数");
            return loading.close();
          }
          if (!this.form.routeNodeName) {
            this.$message.error("请选择节点时间段");
            return loading.close();
          }
          if (!this.form.taskType) {
            this.$message.error("请选择任务类型");
            return loading.close();
          }
          if (!this.form.taskSubdivision) {
            this.$message.error("请选择任务细分");
            return loading.close();
          }
          if (!this.form.taskStatus) {
            this.$message.error("请选择任务状态");
            return loading.close();
          }
          updateRouteCheckStatus({
            routeCheckStatus: this.routeform.routeCheckStatus,
            id: this.form.specialDiseaseNodeId,
            routeCheckRemark: this.routeform.routeCheckRemark,
            routeCheckPerson: JSON.parse(localStorage.getItem("user")).nickName,
          }).then((res) => {
            loading.close();
            if (res.data == 1) {
              this.info();
              this.handleClose();
              this.$modal.msgSuccess("审核成功!");
            }
          });
        }
      });
    },
    // 保存触发条件
    addlistname() {
      this.show3 = !this.show3;
    },
    delitemlist(index, item) {
      this.updata.splice(index, 1);
    },
    // changeoptions(e) {
    //   this.parentDictCode = this.options.find(
    //     (el) => el.dictValue == e
    //   )?.dictCode;
    //   this.changelisy();
    // },
    // changelisy() {
    //   list(this.parentDictCode).then((res) => {
    //     this.parentDictCodelist = res.rows;
    //   });
    // },
    info() {
      const loading = this.$loading({
        lock: true,
        text: "数据加载中",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)",
      });
      this.lists = [];
      if (this.$route.query) {
        // this.updata.suitRange = this.$route.query.suitRange;
        // this.parentDictCode = this.options.find(
        //   (el) => el.dictValue == this.updata.suitRange
        // )?.dictCode;
        // this.changelisy();
        // this.updata.routeName = this.$route.query.routeName;
        // this.updata.specialDiseaseRouteId = this.$route.query.id;
        selectSpecialDisease(this.$route.query.id).then((res) => {
          loading.close();
          this.agreeNumber = res.data.agreeNumber;
          this.totalNumber = res.data.totalNumber;
          res.data.specialDiseaseNodeList.forEach((e) => {
            console.log(e, "eeeeeeeeeeeeeeeee");
            if (e.messagePushSign) {
              e.messagePushSign = "" + e.messagePushSign;
            }
            if (e.officialPushSign) {
              e.officialPushSign = "" + e.officialPushSign;
            }
            if (e.appletPushSign) {
              e.appletPushSign = "" + e.appletPushSign;
            }
            if (e.phonePushSign) {
              e.phonePushSign = "" + e.phonePushSign;
            }
          });
          this.lists = this.handleData(
            res.data.specialDiseaseNodeList,
            "routeNodeDay",
            "routeNodeName"
          );
          this.form = this.lists[0].list[0];
          if (this.form.taskType) {
            this.changeTaskType(this.form.taskType, this.form.taskSubdivision);
          }
        });
      } else {
        loading.close();
        this.lists.push({
          routeNodeName: "",
          routeNodeDay: "",
          list: [
            {
              nodeContent: "<p></p>",
              templateId: "",
              templateName: "",
              taskType: "",
              taskSubdivision: "",
              taskSubdivisionName: "",
              taskStatus: "",
              secondClassifyDescribe: "",
              executionTime: "",
              appletPushSign: "0",
              officialPushSign: "0",
              messagePushSign: "0",
              messagePreview: "",
              officialRemindContent: "",
              taskSubdivisiontemplateType: "",
              appletRemindContent: "",
              appletPromptDescription: "",
            },
          ],
        });
        this.form = this.lists[0].list[0];
        console.log(this.form, "6555555555555555");
      }
    },

    addtriggerConditionlist() {
      this.idd++;
      var obj = {
        routeId: "",
        routeName: "",
        triggerConditionName: "",
        triggerConditionOperator: "",
        triggerConditionValue: "",
        triggerConditionName: "",
        triggerConditionOperatorName: "",

        triggerLogic: "",
        triggerLogicName: "",
      };

      if (this.updata.length == 3) {
        this.$message.error("最多批量添加2条");
      } else {
        this.updata.push(obj);
        // console.log(this.form)
      }
    },
    // 且或
    infolistoptionslistS() {
      var dictType = "trigger_logic";
      getAgencytype(dictType).then((res) => {
        this.optionslistS = res.data;
      });
    },
    // 包含
    changetriggerLogic(e, index) {
      // console.log(e,index,'index')
      this.openlist.triggerConditionList[index].triggerConditionOperatorName =
        this.optionstriggerConditionOperator.find((el) => el.value == e).label;
      //   console.log( this.updata.triggerConditionList[index].triggerConditionOperatorName,"this.updata.triggerConditionList[index].triggerConditionOperatorName");
    },
    // 诊断
    changetriggerConditionName(e, index) {
      //   console.log(e,index, "eeeeeeeee");
      this.openlist.triggerConditionList[index].triggerConditionName =
        this.optionsname.find((el) => el.value == e).label;
      //   console.log(this.updata.triggerConditionList[index].triggerConditionName, " this.form.triggerConditionName");
    },
    changeoptions() {},
    // 且或
    changetriggerLogicsname(e, index) {
      console.log(e, index, "eeeeeeeeeeeeeeeeee");
      this.openlist.triggerConditionList[index].triggerLogic = e;
      this.openlist.triggerConditionList[index].triggerLogicName =
        this.optionslistS.find((el) => el.dictValue == e).dictLabel;
      console.log(
        this.openlist.triggerConditionList[index].triggerLogic,
        this.openlist.triggerConditionList[index].triggerLogicName,
        " this.form.triggerLogicName"
      );
    },
    // 适用范围
    infolists() {
      var dictType = "suit_range";
      getAgencytype(dictType).then((res) => {
        this.options = res.data;
      });
    },
    infolist() {
      this.routeId = this.$route.query.id;
      triggerConditionList(this.routeId).then((res) => {
        console.log(res, "res");
        this.openlist.triggerConditionList = res.data;

        if (res.data.length == 1) {
          this.updata = res.data[0];
        } else {
          this.updata = res.data[0];
          res.data.splice(0, 1);
          this.updatalist = res.data;
        }
        this.$set(this.updata, "suitRange", this.$route.query.suitRange);
      });
    },
    // 编辑接口
    infolistname() {
      this.routeId = this.$route.query.id;
      triggerConditionList(this.routeId).then((res) => {
        this.openlist.triggerConditionList = res.data;
        this.$set(this.openlist, "suitRange", this.$route.query.suitRange);
      });
    },
    // 编辑
    edit() {
      this.open = true;
      this.infolistname();
    },
    //wangeditor传值
    onNodeContent(item) {
      this.form.nodeContent = item.nodeContent;
    },
    //小程序传值
    miniProgramtemplate(item) {
      this.form.appletTemplateId = item.templateId;
      this.form.appletTemplateName = item.templateName;
      this.form.appletRemindContent = item.templateContent;
    },
    //短信传值
    messageontemplate(item) {
      this.form.messageTemplateId = item.templateId;
      this.form.messageTemplateName = item.templateName;
      this.form.messagePreview = item.templateContent;
    },
    //公众号传值
    officialAccountontemplate() {
      this.form.officialTemplateId = item.templateId;
      this.form.officialTemplateName = item.templateName;
      this.form.officialRemindContent = item.templateContent;
    },
    //暂存
    TemporaryStorage() {
      this.$refs.wangeditor.emit();
      triggerConditionedit(this.lists).then((res) => {});
    },
    //问卷传值
    questionontemplate(item) {
      this.form.templateId = item.templateId;
      this.form.templateName = item.templateName;
    },
    //宣教传值
    propagandaontemplate(item) {
      this.form.templateId = item.templateId;
      this.form.templateName = item.templateName;
    },
    topclickevent(index) {
      this.listindex = index;
      this.itemindex = 0;
    },
    bottomclickevent(uitem, index, uindex) {
      this.form = uitem;
      this.listindex = index;
      this.itemindex = uindex;
    },
    handleStep() {
      this.active = 2;
    },
    //任务类型 任务状态
    taskinfo() {
      selectTaskTypeList().then((res) => {
        this.selectTaskTypeList = res.data;
      });
      taskStatusDictList().then((res) => {
        this.taskStatusDictList = res.data;
      });
    },
     //任务类型
     changeTaskType(code, taskSubdivision) {
      let id = this.selectTaskTypeList?.find((e) => e.taskTypeCode == code)?.id;
      this.form.taskTypeName = this.selectTaskTypeList?.find(
        (e) => e.taskTypeCode == code
      )?.taskTypeName;
      taskPartitionList(id).then((res) => {
        this.taskPartitionList = res.data;
        this.form.taskSubdivision = "";
        this.form.taskSubdivisionName = "";
        this.form.taskSubdivisiontemplateType = "";
        this.taskStatusDictList = [];
        if (taskSubdivision) {
          this.form.taskSubdivision = taskSubdivision;
          this.changetaskSubdivision(taskSubdivision, 1);
        }
      });
    },
    //点击任务细分
    changetaskSubdivision(code, type) {
      console.log(code, type, "code, type");
      this.form.taskSubdivisionName = this.taskPartitionList?.find(
        (e) => e.taskPartitionCode == code
      )?.taskPartitionName;
      let id = this.taskPartitionList?.find(
        (e) => e.taskPartitionCode == code
      )?.id;
      this.form.secondClassifyDescribe = this.taskPartitionList?.find(
        (e) => e.taskPartitionCode == code
      )?.secondClassifyDescribe;
      this.form.executionTime = this.taskPartitionList?.find(
        (e) => e.taskPartitionCode == code
      )?.executionTime;
      taskStatusDictList(id).then((res) => {
        this.taskStatusDictList = res.data;
      });
      this.taskPartitionList.forEach((el) => {
        if (code == el.taskPartitionCode) {
          this.form.executionTime = el.executionTime;
          this.form.taskSubdivisiontemplateType = el.templateType;
          if (
            this.form.taskSubdivisiontemplateType == "SCRIPT" ||
            this.form.taskSubdivisiontemplateType == "PROPAGANDA" ||
            this.form.taskSubdivisiontemplateType == "QUESTIONNAIRE"
          ) {
            this.form.nodeContent = `<p></p>`;
          }
          console.log(
            this.form.taskSubdivisiontemplateType,
            "this.form.taskSubdivisiontemplateType"
          );
          if (!type) {
            this.form.templateId = "";
            this.form.templateName = "";
          }
        }
      });
    },
    // //任务细分
    // changeTaskType(id) {
    //   taskPartitionList(id).then((res) => {
    //     this.taskPartitionList = res.data;
    //   });
    //   this.selectTaskTypeList.forEach((el) => {
    //     if (id == el.id) {
    //       this.form.taskTypeName = el.taskTypeName;
    //     }
    //   });
    // },
    changetaskSubdivision(e) {
      this.taskPartitionList.forEach((el) => {
        if (e == el.id) {
          this.form.taskSubdivisionName = el.taskTypeName;
          this.form.taskSubdivisiontemplateType = el.templateType;
        }
      });
    },
    addlist() {
      this.lists.push({
        routeNodeName: "",
        routeNodeDay: "",
        list: [
          {
            nodeContent: "",
            templateId: "",
            templateName: "",
            taskType: "",
            taskTypeName: "",
            taskSubdivision: "",
            taskSubdivisionName: "",
            taskStatus: "",
            secondClassifyDescribe: "",
            executionTime: "",
            appletPushSign: "0",
            officialPushSign: "0",
            messagePushSign: "0",
            taskSubdivisiontemplateType: "",
          },
        ],
      });
    },
    additem(item) {
      item.list.push({
        nodeContent: "",
        templateId: "",
        templateName: "",
        taskType: "",
        taskTypeName: "",
        taskSubdivision: "",
        taskSubdivisionName: "",
        taskStatus: "",
        secondClassifyDescribe: "",
        executionTime: "",
        appletPushSign: "0",
        officialPushSign: "0",
        messagePushSign: "0",
        taskSubdivisiontemplateType: "",
      });
    },
    delitemh(item, index) {
      item.list.splice(this.itemindex, 1);
      if (item.list.length == 0) {
        this.lists.splice(index, 1);
      }
    },
    addtriggerCondition() {
      this.updata.push({});
    },
  },
};
</script>
<style scoped lang="scss">
.el-icon-arrow-down {
  margin-left: 50px;
}
.el-icon-arrow-up {
  margin-left: 50px;
}
.addlistname {
  color: #409eff;
  font-size: 12px;
  margin-left: 20px;
  margin-top: 10px;
}
.login-code {
  width: 62px;
  height: 81px;
  position: relative;
  z-index: 0;
  top: -30px;
  right: 56px;
}
.login-code-img {
  width: 62px;
  height: 81px;
  position: absolute;
  z-index: -1;
  top: 32px;
  right: 61px;
}
.selectnamelist {
  position: absolute;
  right: 54px;
  top: -8px;
}
.selectname {
  position: absolute;
  right: 70px;
  top: 55px;
}
.dialog-footer {
  padding: 0px 30px;
  text-align: right;
}
.nodesname {
  margin-left: 6%;
  width: 660px;
  display: flex;
  flex-wrap: wrap;
  position: relative;
  padding-left: 20px;

  .node {
    margin-bottom: 10px;
  }
}
.nodes {
  width: 660px;
  display: flex;
  flex-wrap: wrap;
  position: relative;
  padding-left: 20px;

  .node {
    margin-bottom: 10px;
  }
}

.bottomform {
  background-color: #f2f4f5;
  margin-top: 10px;

  .card {
    background-color: #fff;
    width: 100%;
    height: 200px;
    margin: 20px 0 0;
    padding: 20px 50px 0px 20px;

    .flextwo {
      display: flex;
      align-items: center;
      margin-top: 20px;

      .text {
        font-size: 13px;
        color: #64666a;
      }

      .textarea {
        width: 90%;
        padding: 0 10px;
        height: 50px;
        line-height: 50px;
        border: 1px solid #dcdfe6;
        border-radius: 5px;
        display: flex;
        align-items: center;

        ::v-deep .el-input {
          padding: 0 10px;
          width: 50%;
          color: black;
          font-size: 13px;
          height: 40px;
          line-height: 40px;
        }

        ::v-deep .el-input__inner {
          color: black;
          font-size: 13px;
        }
      }
    }

    .flex {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .pushMethod {
        height: 30px;
        line-height: 30px;
        font-size: 13px;
        color: #64666a;

        ::v-deep .el-input__inner {
          color: black;
          font-size: 13px;
        }

        span {
          color: black;
          font-size: 13px;
        }
      }
    }
  }
}

.topform {
  padding: 15px 0 0 15px;

  .form {
    ::v-deep .el-input__inner {
      height: 30px !important;
      line-height: 30px !important;
    }

    ::v-deep .el-form-item__label {
      font-size: 12px !important;
    }
  }
}

.title {
  display: flex;
  // align-items: center;
  padding-left: 100px;
  // height: 400px;

  // div {
  //   // display: flex;
  //   // padding-left: 27px;
  //   // margin-left: 3%;
  //   font-weight: 600;
  //   // align-items: center;
  // }
  .el-icon-arrow-down {
    // color: #409EFF;
    // margin-top: 10px;
    // margin-left: 30px;
  }
  .select {
    font-weight: 550;
    // margin-left: 10%;
    position: relative;
    right: 20px;
    // width: 300px;
    font-size: 12px;

    .el-input {
      width: 200px;
      height: 30px !important;
      line-height: 30px !important;
    }
  }
}
.container {
  padding: 20px;
}
.list {
  margin: 14px auto;
  width: 100%;
  // height: calc(100% - 80px);
  background-color: #f2f4f5;
  display: flex;
  padding-top: 15px;
  justify-content: space-evenly;

  .timelist {
    width: 22%;
    background-color: #fff;
    padding: 0 20px 20px;
    height: calc(100vh - 280px);

    overflow: scroll;

    .timetitle {
      height: 60px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    ::v-deep .el-timeline {
      width: 100%;
      padding: 15px 0 0 !important;
    }
  }

  .texts {
    width: 75%;
    height: calc(100vh - 280px);

    overflow: scroll;
    background-color: #fff;
  }
}

.cards {
  border: 1px solid #409eff;
  border-left: 5px solid #409eff;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;

  .toptop {
    display: flex;
    align-items: center;
  }

  span {
    padding: 0 4px;
  }

  i {
    font-size: 17px;
  }

  i:nth-child(2) {
    padding-left: 12px;
  }
}

::v-deep .el-timeline-item__timestamp {
  margin: 0 !important;
  padding: 0 !important;
}

::v-deep .el-timeline-item__wrapper {
  padding-left: 14px !important;
}

::v-deep .el-timeline-item__content {
  transform: translateY(-2%);
}

::v-deep .el-card {
  margin-top: 20px !important;
}
</style>