From a5cba9ab040f6f97558046885dce3017f9bab7e9 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期二, 11 八月 2026 14:12:29 +0800
Subject: [PATCH] 提交

---
 src/views/patient/propaganda/QuestionnaireTask.vue | 2611 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 1,683 insertions(+), 928 deletions(-)

diff --git a/src/views/patient/propaganda/QuestionnaireTask.vue b/src/views/patient/propaganda/QuestionnaireTask.vue
index 78551f2..763a462 100644
--- a/src/views/patient/propaganda/QuestionnaireTask.vue
+++ b/src/views/patient/propaganda/QuestionnaireTask.vue
@@ -69,23 +69,35 @@
                     placeholder="璇疯緭鍏ヤ换鍔℃弿杩�"
                   />
                 </el-form-item>
+
                 <el-form-item label="鏈嶅姟褰㈠紡">
-                  <el-checkbox-group v-model="checkList">
-                    <el-checkbox
-                      v-for="(item, index) in checkboxlist"
-                      :key="index"
-                      :label="item.value"
-                    >
-                      {{ item.label }}</el-checkbox
-                    >
-                  </el-checkbox-group>
+                  <SortCheckbox
+                    v-model="checkList"
+                    :options="checkboxlist"
+                    :initialselectedOrder="selectedOrder"
+                    value-key="value"
+                    label-key="label"
+                    @change="checkSelectionChange"
+                  />
                 </el-form-item>
-                <el-form-item label="鏄惁闀挎湡" prop="longTask">
+
+                <el-form-item label="鎵ц鍛ㄦ湡" prop="longTask">
                   <el-radio-group v-model="form.longTask">
-                    <el-radio :label="0">鏅�氫换鍔�</el-radio>
+                    <el-radio :label="0">鑷畾涔夊懆鏈�</el-radio>
                     <el-radio :label="1">闀挎湡浠诲姟</el-radio>
+                    <el-radio :label="2">鍥哄畾浠诲姟</el-radio>
                   </el-radio-group>
                 </el-form-item>
+                <el-row :gutter="20" v-if="form.longTask">
+                  <el-col :span="8">
+                    <el-form-item label="鍛ㄦ湡鏃堕棿" prop="name">
+                      <el-input
+                        v-model="form.sendDay"
+                        placeholder="榛樿5澶╁悗"
+                      ></el-input>
+                    </el-form-item>
+                  </el-col>
+                </el-row>
                 <el-form-item
                   label="鎵ц璁剧疆"
                   prop="sendType"
@@ -186,20 +198,66 @@
                     </div>
                   </div>
                 </el-form-item>
-                <el-row>
+
+                <el-form-item label="浠诲姟鍏宠仈" prop="longTask">
+                  <el-radio-group v-model="form.appltype">
+                    <el-radio label="1">绉戝鍏宠仈</el-radio>
+                    <el-radio label="2">鐥呭尯鍏宠仈</el-radio>
+                    <el-radio label="3">鐤剧梾鍏宠仈</el-radio>
+                    <el-radio label="4">鎵嬫湳鍏宠仈</el-radio>
+                    <el-radio label="6" v-if="orgname == '鐪佺珛鍚屽痉缈犺嫅闄㈠尯'"
+                      >鑽搧鍏宠仈</el-radio
+                    >
+                    <el-radio label="5">浠诲姟缁�</el-radio>
+                  </el-radio-group>
+                </el-form-item>
+
+                <!-- 鑽搧鍏宠仈 -->
+                <el-row v-if="form.appltype == 6">
+                  <el-col :span="20">
+                    <el-form-item label="鍏宠仈鑽搧" prop="region">
+                      <el-select
+                        v-model="medicalCodes"
+                        @remove-tag="removeMedical"
+                        style="width: 400px"
+                        size="medium"
+                        multiple
+                        filterable
+                        remote
+                        reserve-keyword
+                        :remote-method="remoteSearchMedical"
+                        placeholder="璇疯緭鍏ヨ嵂鍝佸悕绉版悳绱�"
+                        loading-text="鎼滅储涓�..."
+                      >
+                        <el-option
+                          v-for="item in medicalOptions"
+                          :key="item.id"
+                          :label="
+                            item.itemName + ' (' + item.manufacturerName + ')'
+                          "
+                          :value="item.itemCode"
+                        />
+                      </el-select>
+                    </el-form-item>
+                  </el-col>
+                </el-row>
+
+                <!-- 绉戝鍏宠仈 -->
+                <el-row v-if="form.appltype == 1">
                   <el-col :span="20"
                     ><el-form-item label="閫傜敤绉戝" prop="region">
                       <el-select
-                        v-model="form.deptcode"
+                        v-model="deptcodesWards"
+                        @remove-tag="removetag"
                         style="width: 400px"
                         size="medium"
+                        multiple
                         filterable
                         placeholder="璇烽�夋嫨绉戝"
                       >
                         <el-option
                           class="ruleFormaa"
                           v-for="item in belongDepts"
-                          :key="item.deptCode"
                           :label="item.deptName"
                           :value="item.deptCode"
                         >
@@ -207,35 +265,23 @@
                       </el-select> </el-form-item
                   ></el-col>
                 </el-row>
-                <el-row>
+
+                <!-- 鐥呭尯鍏宠仈 -->
+                <el-row v-if="form.appltype == 2">
                   <el-col :span="20"
                     ><el-form-item label="閫傜敤鐥呭尯" prop="region">
-                      <!-- <el-cascader
-                      style="width: 400px"
-                      v-model="form.leavehospitaldistrictcode"
-                      :options="topicoptions"
-                      :props="propstask"
-                      :show-all-levels="false"
-                      clearable
-                    >
-                      <template slot-scope="{ node, data }">
-                        <span>{{ data.deptName }}</span>
-                        <span v-if="!node.isLeaf">
-                          ({{ data.children.length }})
-                        </span>
-                      </template>
-                    </el-cascader> -->
                       <el-select
-                        v-model="form.leavehospitaldistrictcode"
+                        v-model="leavehospitaldistrictcodes"
                         style="width: 400px"
+                        @remove-tag="removehpsp"
                         size="medium"
+                        multiple
                         filterable
                         placeholder="璇烽�夋嫨鐥呭尯"
                       >
                         <el-option
                           class="ruleFormaa"
                           v-for="item in belongWards"
-                          :key="item.districtCode"
                           :label="item.districtName"
                           :value="item.districtCode"
                         >
@@ -243,6 +289,487 @@
                       </el-select> </el-form-item
                   ></el-col>
                 </el-row>
+
+                <!-- 鐤剧梾鍏宠仈 -->
+                <el-row v-if="form.appltype == 3">
+                  <div class="xinz-infs">
+                    <el-form-item>
+                      <template #label>
+                        <el-tooltip
+                          class="item"
+                          effect="light"
+                          content="閫夋嫨濂介�傜敤鐤剧梾鍚庯紝鍙互鏂逛究鎮ㄩ�氳繃鐤剧梾璇婃柇鏌ユ壘鍒板搴旂殑鐥呬汉!"
+                          placement="top-start"
+                        >
+                          <i class="el-icon-warning-outline"></i>
+                        </el-tooltip>
+                      </template>
+                      <div style="margin-bottom: 10px">
+                        <el-button
+                          type="warning"
+                          @click="$refs.child.handleAddpatient()"
+                          >娣诲姞鐤剧梾璇婃柇</el-button
+                        >
+                      </div>
+                      <el-tag
+                        v-for="tag in diagglist"
+                        @close="removediagg(tag.icd10code)"
+                        type="warning"
+                        closable
+                        :disable-transitions="false"
+                      >
+                        {{ tag.icdname }}
+                      </el-tag>
+                    </el-form-item>
+                  </div>
+                  <div
+                    style="
+                      margin-bottom: 20px;
+                      padding: 8px 12px;
+                      background-color: #f0f9ff;
+                      border-left: 4px solid #409eff;
+                    "
+                  >
+                    <p style="margin: 0; color: #606266; font-size: 13px">
+                      <i
+                        class="el-icon-info"
+                        style="color: #409eff; margin-right: 6px"
+                      ></i>
+                      閽堝鍚屼竴鐤剧梾鍦ㄥ绉戝/鐥呭尯涓嬪瓨鍦ㄧ殑鎯呭喌锛屽彲閫夋嫨鎬ч厤缃浐瀹氱瀹�/鐥呭尯
+                    </p>
+                  </div>
+                  <el-row :gutter="20" style="margin-top: 20px">
+                    <el-col :span="12">
+                      <el-form-item label="鍏宠仈绉戝" prop="diseaseDept">
+                        <el-select
+                          v-model="diseaseDept"
+                          style="width: 100%"
+                          clearable
+                          filterable
+                          placeholder="璇烽�夋嫨绉戝锛堝彲閫夛級"
+                          value-key="deptCode"
+                          @change="handleDiseaseDeptChange"
+                        >
+                          <el-option
+                            v-for="item in belongDepts"
+                            :key="item.deptCode"
+                            :label="item.deptName"
+                            :value="item"
+                          ></el-option>
+                        </el-select>
+                        <div v-if="diseaseDept" class="selected-info">
+                          宸查�夋嫨: {{ diseaseDept.deptName }} ({{
+                            diseaseDept.deptCode
+                          }})
+                        </div>
+                      </el-form-item>
+                    </el-col>
+                    <el-col :span="12">
+                      <el-form-item label="鍏宠仈鐥呭尯" prop="diseaseWard">
+                        <el-select
+                          v-model="diseaseWard"
+                          style="width: 100%"
+                          clearable
+                          filterable
+                          placeholder="璇烽�夋嫨鐥呭尯锛堝彲閫夛級"
+                          value-key="districtCode"
+                          @change="handleDiseaseWardChange"
+                        >
+                          <el-option
+                            v-for="item in belongWards"
+                            :key="item.districtCode"
+                            :label="item.districtName"
+                            :value="item"
+                          ></el-option>
+                        </el-select>
+                        <div v-if="diseaseWard" class="selected-info">
+                          宸查�夋嫨: {{ diseaseWard.districtName }} ({{
+                            diseaseWard.districtCode
+                          }})
+                        </div>
+                      </el-form-item>
+                    </el-col>
+                  </el-row>
+                </el-row>
+
+                <!-- 鎵嬫湳鍏宠仈 -->
+                <el-row v-if="form.appltype == 4">
+                  <el-form-item label="閫傜敤鎵嬫湳" prop="region">
+                    <el-select
+                      v-model="form.oplevelcode"
+                      style="width: 400px"
+                      @remove-tag="removeopera"
+                      size="medium"
+                      :remote-method="remoteopcode"
+                      filterable
+                      remote
+                      placeholder="璇烽�夋嫨鎵嬫湳"
+                    >
+                      <el-option
+                        class="ruleFormaa"
+                        v-for="item in baseoperaList"
+                        :label="item.label"
+                        :value="item.value"
+                      >
+                      </el-option>
+                    </el-select>
+                  </el-form-item>
+                  <div
+                    style="
+                      margin-bottom: 20px;
+                      padding: 8px 12px;
+                      background-color: #f0f9ff;
+                      border-left: 4px solid #409eff;
+                    "
+                  >
+                    <p style="margin: 0; color: #606266; font-size: 13px">
+                      <i
+                        class="el-icon-info"
+                        style="color: #409eff; margin-right: 6px"
+                      ></i>
+                      閽堝鍚屼竴鎵嬫湳绫诲瀷鍦ㄥ绉戝/鐥呭尯涓嬪瓨鍦ㄧ殑鎯呭喌锛屽彲閫夋嫨鎬ч厤缃浐瀹氱瀹�/鐥呭尯
+                    </p>
+                  </div>
+                  <el-row :gutter="20" style="margin-top: 20px">
+                    <el-col :span="12">
+                      <el-form-item label="鍏宠仈绉戝" prop="diseaseDept">
+                        <el-select
+                          v-model="diseaseDept"
+                          style="width: 100%"
+                          clearable
+                          filterable
+                          placeholder="璇烽�夋嫨绉戝锛堝彲閫夛級"
+                          value-key="deptCode"
+                          @change="handleDiseaseDeptChange"
+                        >
+                          <el-option
+                            v-for="item in belongDepts"
+                            :key="item.deptCode"
+                            :label="item.deptName"
+                            :value="item"
+                          ></el-option>
+                        </el-select>
+                        <div v-if="diseaseDept" class="selected-info">
+                          宸查�夋嫨: {{ diseaseDept.deptName }} ({{
+                            diseaseDept.deptCode
+                          }})
+                        </div>
+                      </el-form-item>
+                    </el-col>
+                    <el-col :span="12">
+                      <el-form-item label="鍏宠仈鐥呭尯" prop="diseaseWard">
+                        <el-select
+                          v-model="diseaseWard"
+                          style="width: 100%"
+                          clearable
+                          filterable
+                          placeholder="璇烽�夋嫨鐥呭尯锛堝彲閫夛級"
+                          value-key="districtCode"
+                          @change="handleDiseaseWardChange"
+                        >
+                          <el-option
+                            v-for="item in belongWards"
+                            :key="item.districtCode"
+                            :label="item.districtName"
+                            :value="item"
+                          ></el-option>
+                        </el-select>
+                        <div v-if="diseaseWard" class="selected-info">
+                          宸查�夋嫨: {{ diseaseWard.districtName }} ({{
+                            diseaseWard.districtCode
+                          }})
+                        </div>
+                      </el-form-item>
+                    </el-col>
+                  </el-row>
+                </el-row>
+
+                <!-- ========= 浠诲姟缁� (appltype=5) ========= -->
+                <div v-if="form.appltype == 5">
+                  <el-divider content-position="left">浠诲姟缁勪富璁″垝</el-divider>
+                  <el-form-item label="鎵ц鏂瑰紡">
+                    <el-radio-group
+                      v-model="form.serviceTaskScheduleVO.scheduleStyle"
+                    >
+                      <el-radio :label="0">闈炲惊鐜�</el-radio>
+                      <el-radio :label="1">寰幆</el-radio>
+                    </el-radio-group>
+                  </el-form-item>
+
+                  <div v-if="form.serviceTaskScheduleVO.scheduleStyle == 1">
+                    <el-row :gutter="20" style="margin-top: 20px">
+                      <el-col :span="12">
+                        <el-form-item label="寰幆闂撮殧">
+                          <el-input-number
+                            v-model="form.serviceTaskScheduleVO.scheduleTimeNum"
+                            :min="1"
+                            style="width: 120px"
+                          />
+                          <el-select
+                            v-model="
+                              form.serviceTaskScheduleVO.scheduleTimeUnit
+                            "
+                            placeholder="鍗曚綅"
+                            style="width: 100px; margin-left: 8px"
+                          >
+                            <el-option label="澶�" :value="1" />
+                            <el-option label="鍛�" :value="2" />
+                            <el-option label="鏈�" :value="3" />
+                            <el-option label="骞�" :value="4" />
+                          </el-select>
+                        </el-form-item>
+                      </el-col>
+                      <el-col :span="12">
+                        <el-form-item label="鏈�澶ц疆娆�">
+                          <el-input-number
+                            v-model="form.serviceTaskScheduleVO.maxLoopCount"
+                            :min="0"
+                            :step="1"
+                            placeholder="0琛ㄧず鏃犻檺"
+                          />
+                        </el-form-item>
+                      </el-col>
+                    </el-row>
+                  </div>
+                  <el-row :gutter="20" style="margin-top: 20px">
+                    <el-col :span="12">
+                      <el-form-item label="鍩哄噯鏃堕棿">
+                        <el-radio-group
+                          v-model="form.serviceTaskScheduleVO.scheduleBenchmark"
+                        >
+                          <el-radio :label="0">鑷畾涔�</el-radio>
+                          <el-radio :label="1">鍏ラ櫌鏃堕棿</el-radio>
+                          <el-radio :label="2">鍑洪櫌鏃堕棿</el-radio>
+                          <el-radio :label="3">灏辫瘖鏃堕棿</el-radio>
+                          <el-radio :label="4">鍏ョ粍鏃堕棿</el-radio>
+                        </el-radio-group>
+                      </el-form-item>
+                    </el-col>
+                    <el-col
+                      :span="12"
+                      v-if="form.serviceTaskScheduleVO.scheduleBenchmark == 0"
+                    >
+                      <el-form-item label="鑷畾涔夊熀鍑嗘椂闂�">
+                        <el-date-picker
+                          v-model="
+                            form.serviceTaskScheduleVO
+                              .scheduleBenchmarkCustomTime
+                          "
+                          type="datetime"
+                          placeholder="閫夋嫨鏃ユ湡鏃堕棿"
+                          value-format="yyyy-MM-dd HH:mm:ss"
+                        />
+                      </el-form-item>
+                    </el-col>
+
+                    <el-col :span="12">
+                      <el-form-item label="涓嬫鎵ц鏃堕棿">
+                        <el-date-picker
+                          v-model="form.serviceTaskScheduleVO.nextExecuteTime"
+                          type="datetime"
+                          placeholder="閫夋嫨棣栨鎵ц鏃堕棿"
+                          value-format="yyyy-MM-dd HH:mm:ss"
+                        />
+                      </el-form-item>
+                    </el-col>
+                  </el-row>
+                  <el-row :gutter="20" style="margin-top: 20px">
+                    <el-col :span="12">
+                      <el-form-item label="鍏宠仈绉戝" prop="diseaseDept">
+                        <el-select
+                          v-model="diseaseDept"
+                          style="width: 100%"
+                          clearable
+                          filterable
+                          placeholder="璇烽�夋嫨绉戝锛堝彲閫夛級"
+                          value-key="deptCode"
+                          @change="handleDiseaseDeptChange"
+                        >
+                          <el-option
+                            v-for="item in belongDepts"
+                            :key="item.deptCode"
+                            :label="item.deptName"
+                            :value="item"
+                          ></el-option>
+                        </el-select>
+                        <div v-if="diseaseDept" class="selected-info">
+                          宸查�夋嫨: {{ diseaseDept.deptName }} ({{
+                            diseaseDept.deptCode
+                          }})
+                        </div>
+                      </el-form-item>
+                    </el-col>
+                    <el-col :span="12">
+                      <el-form-item label="鍏宠仈鐥呭尯" prop="diseaseWard">
+                        <el-select
+                          v-model="diseaseWard"
+                          style="width: 100%"
+                          clearable
+                          filterable
+                          placeholder="璇烽�夋嫨鐥呭尯锛堝彲閫夛級"
+                          value-key="districtCode"
+                          @change="handleDiseaseWardChange"
+                        >
+                          <el-option
+                            v-for="item in belongWards"
+                            :key="item.districtCode"
+                            :label="item.districtName"
+                            :value="item"
+                          ></el-option>
+                        </el-select>
+                        <div v-if="diseaseWard" class="selected-info">
+                          宸查�夋嫨: {{ diseaseWard.districtName }} ({{
+                            diseaseWard.districtCode
+                          }})
+                        </div>
+                      </el-form-item>
+                    </el-col>
+                  </el-row>
+                  <el-row>
+                    <div class="xinz-infs">
+                      <el-form-item>
+                        <template #label>
+                          <el-tooltip
+                            class="item"
+                            effect="light"
+                            content="閫夋嫨濂介�傜敤鐤剧梾鍚庯紝鍙互鏂逛究鎮ㄩ�氳繃鐤剧梾璇婃柇鏌ユ壘鍒板搴旂殑鐥呬汉!"
+                            placement="top-start"
+                          >
+                            <i class="el-icon-warning-outline"></i>
+                          </el-tooltip>
+                        </template>
+                        <div style="margin-bottom: 10px">
+                          <el-button
+                            type="warning"
+                            @click="$refs.child.handleAddpatient()"
+                            >娣诲姞鐤剧梾璇婃柇</el-button
+                          >
+                        </div>
+                        <el-tag
+                          v-for="tag in diagglist"
+                          @close="removediagg(tag.icd10code)"
+                          type="warning"
+                          closable
+                          :disable-transitions="false"
+                        >
+                          {{ tag.icdname }}
+                        </el-tag>
+                      </el-form-item>
+                    </div>
+                  </el-row>
+                  <!-- 鏄庣粏鍒楄〃 -->
+                  <el-row :gutter="20" style="margin-top: 20px">
+                    <el-col :span="24">
+                      <el-divider content-position="left"
+                        >浠诲姟鏄庣粏鍒楄〃</el-divider
+                      >
+                      <el-button
+                        type="primary"
+                        size="small"
+                        icon="el-icon-plus"
+                        @click="addDetail"
+                        >娣诲姞鏄庣粏</el-button
+                      >
+                      <el-table
+                        :data="form.serviceTaskScheduleVO.detailList"
+                        border
+                        style="width: 100%; margin-top: 10px"
+                      >
+                        <el-table-column label="搴忓彿" width="80" align="center">
+                          <template slot-scope="scope">{{
+                            scope.row.seq
+                          }}</template>
+                        </el-table-column>
+                        <el-table-column label="闂撮殧澶╂暟" width="120">
+                          <template slot-scope="scope">
+                            <el-input-number
+                              v-model="scope.row.dayOffset"
+                              :min="0"
+                              size="small"
+                              controls-position="right"
+                            />
+                          </template>
+                        </el-table-column>
+                        <el-table-column label="妯℃澘" min-width="200">
+                          <template slot-scope="scope">
+                            <el-select
+                              v-model="scope.row.templateid"
+                              filterable
+                              remote
+                              :remote-method="remoteTemplate"
+                              placeholder="鎼滅储妯℃澘"
+                              size="small"
+                              @change="
+                                handleTemplateSelect(scope.$index, scope.row)
+                              "
+                            >
+                              <el-option
+                                v-for="item in templateOptions"
+                                :key="item.svyid"
+                                :label="item.svyname"
+                                :value="item.svyid"
+                              >
+                                <span style="float: left">{{
+                                  item.svyname
+                                }}</span>
+                                <span
+                                  style="
+                                    float: right;
+                                    color: #8492a6;
+                                    font-size: 12px;
+                                  "
+                                  >{{ item.createBy }}</span
+                                >
+                              </el-option>
+                            </el-select>
+                            <span
+                              style="
+                                margin-left: 5px;
+                                font-size: 12px;
+                                color: #909399;
+                              "
+                              >{{ scope.row.templatename }}</span
+                            >
+                          </template>
+                        </el-table-column>
+                        <el-table-column label="寮�鍦虹櫧" min-width="150">
+                          <template slot-scope="scope">
+                            <el-input
+                              v-model="scope.row.kcb"
+                              size="small"
+                              placeholder="鍙��"
+                            />
+                          </template>
+                        </el-table-column>
+                        <el-table-column label="缁撴潫璇�" min-width="150">
+                          <template slot-scope="scope">
+                            <el-input
+                              v-model="scope.row.jsy"
+                              size="small"
+                              placeholder="鍙��"
+                            />
+                          </template>
+                        </el-table-column>
+                        <el-table-column
+                          label="鎿嶄綔"
+                          width="100"
+                          align="center"
+                        >
+                          <template slot-scope="scope">
+                            <el-button
+                              size="mini"
+                              type="danger"
+                              icon="el-icon-delete"
+                              @click="removeDetail(scope.$index)"
+                            ></el-button>
+                          </template>
+                        </el-table-column>
+                      </el-table>
+                    </el-col>
+                  </el-row>
+                </div>
+                <!-- ===== 浠诲姟缁勭粨鏉� ===== -->
+
                 <el-row>
                   <el-col :span="12"
                     ><el-form-item label="寮�鍦虹櫧" prop="kcb">
@@ -287,7 +814,7 @@
                     ></el-button>
 
                     <el-button
-                      v-if="form.templatename"
+                      v-if="form.templateid"
                       type="success"
                       icon="el-icon-search"
                       @click="previewfnmb"
@@ -323,11 +850,6 @@
                     </el-table-column>
                     <el-table-column label="鎿嶄綔" align="center">
                       <template slot-scope="scope">
-                        <!-- <el-button
-                          size="mini"
-                          @click="variableEdit(scope.$index, scope.row)"
-                          >缂栬緫</el-button
-                        > -->
                         <el-button
                           size="mini"
                           type="danger"
@@ -342,14 +864,19 @@
             </div>
           </div>
         </div>
-        <el-button type="success" @click="nextstep('ruleForm')">{{
-          quote ? "绔嬪嵆鍒涘缓" : "浠诲姟璇︽儏閰嶇疆"
+        <el-button type="primary" @click="nextstep('ruleForm')">{{
+          quote ? "绔嬪嵆鍒涘缓" : "娲惧彂鎮h�呴厤缃�"
         }}</el-button>
-        <el-button @click="resetForm('ruleForm')">閲嶇疆</el-button>
+        <el-button
+          :loading="submitLoading"
+          type="success"
+          @click="submitForm('ruleForm')"
+          >{{ quote ? "绔嬪嵆鍒涘缓" : "纭鏈嶅姟閰嶇疆" }}</el-button
+        >
       </div>
       <!-- 浠诲姟璇︽儏 -->
       <div v-if="Editprogress == 2">
-        <el-alert title="鍦ㄦ湰闃舵閫夋嫨瀹f暀鐥呬汉" type="success" effect="dark">
+        <el-alert title="鍦ㄦ湰闃舵閫夋嫨闅忚鐥呬汉" type="success" effect="dark">
         </el-alert>
         <div class="leftvlue-jbxx">
           <div class="examine-jic">
@@ -386,22 +913,7 @@
                         >鏂板</el-button
                       >
                     </el-col>
-
-                    <!-- <el-col :span="1.5">
-                      <el-button
-                        type="danger"
-                        plain
-                        icon="el-icon-delete"
-                        size="medium"
-                        :disabled="multiple"
-                        @click="handleDelete"
-                        >鍒犻櫎</el-button
-                      >
-                    </el-col> -->
-
-                    <!-- <el-col :span="1.5"> </el-col> -->
                   </el-row>
-                  <!-- 閫変腑鎮h�呭垪琛� -->
                   <SFtable
                     @details="detailhz"
                     @handleUpdate="handleUpdate"
@@ -413,23 +925,18 @@
                     :controlxz="false"
                     :typeinfo="2"
                   />
-                  <pagination
-                    v-show="total > 0"
-                    :total="total"
-                    :page.sync="topqueryParams.pageNum"
-                    :limit.sync="topqueryParams.pageSize"
-                    @pagination="getList"
-                  />
                 </el-row>
               </div>
             </div>
           </div>
         </div>
         <el-button type="primary" @click="laststep()">涓婁竴姝�</el-button>
-        <el-button type="success" @click="submitForm('ruleForm')">{{
-          quote ? "绔嬪嵆鍒涘缓" : "纭浠诲姟閰嶇疆"
-        }}</el-button>
-        <el-button @click="resetForm('ruleForm')">閲嶇疆</el-button>
+        <el-button
+          :loading="submitLoading"
+          type="success"
+          @click="submitForm('ruleForm')"
+          >{{ quote ? "绔嬪嵆鍒涘缓" : "纭鏈嶅姟閰嶇疆" }}</el-button
+        >
       </div>
     </div>
     <!-- 娣诲姞鎮h�� -->
@@ -443,7 +950,6 @@
       <div class="examine-jic">
         <div class="jic-value">
           <el-row :gutter="20">
-            <!--鐢ㄦ埛鏁版嵁-->
             <el-form
               :model="patientqueryParams"
               ref="queryForm"
@@ -455,6 +961,18 @@
               <el-form-item label="鎮h�咃細">
                 <el-input
                   v-model="patientqueryParams.name"
+                  @keyup.enter.native="handleQuery"
+                ></el-input>
+              </el-form-item>
+              <el-form-item label="鎮h�呰瘖鏂細">
+                <el-input
+                  v-model="patientqueryParams.leavediagname"
+                  @keyup.enter.native="handleQuery"
+                ></el-input>
+              </el-form-item>
+              <el-form-item label="涓绘不鍖荤敓锛�">
+                <el-input
+                  v-model="patientqueryParams.drname"
                   @keyup.enter.native="handleQuery"
                 ></el-input>
               </el-form-item>
@@ -487,20 +1005,19 @@
                 >
               </el-form-item>
             </el-form>
-            <!-- 閫夋嫨鎮h�呭垪琛� -->
             <SFtable
               ref="multipleTable"
-              @handleUpdate="handleUpdate"
               @handleSelectionChange="handleSelectionChange"
               :currentList="patientuserList"
               :tableLabel="tableLabelhz"
+              :heights="600"
               :serialnumber="false"
               :center="false"
               :typeinfo="3"
             />
           </el-row>
           <pagination
-            v-show="patienttotal > 0"
+            v-show="patienttotal > 0 && this.patientqueryParams.allhosp != 6"
             :total="patienttotal"
             :page.sync="patientqueryParams.pageNum"
             :limit.sync="patientqueryParams.pageSize"
@@ -518,8 +1035,8 @@
     <!-- 妯℃澘棰勮 -->
     <el-dialog title="妯℃澘棰勮" :visible.sync="previewtf" width="70%">
       <el-tabs type="border-card">
-        <el-tab-pane label="妯℃澘鍩虹鏁版嵁"
-          ><div class="preview-left">
+        <el-tab-pane label="妯℃澘鍩虹鏁版嵁">
+          <div class="preview-left">
             <el-form :model="objyl" label-width="100px" class="demo-objyl">
               <el-row :gutter="10">
                 <el-col :span="14">
@@ -589,116 +1106,7 @@
                   <el-input v-model="objyl.svyname"></el-input>
                 </div>
               </el-form-item>
-              <el-form-item label="闂嵎鏂瑰紡" prop="suitway">
-                <el-select
-                  style="width: 400px"
-                  v-model="objyl.suitway"
-                  size="medium"
-                  multiple
-                  filterable
-                  placeholder="璇烽�夋嫨鍒嗙被"
-                >
-                  <el-option
-                    class="ruleFormaa"
-                    v-for="item in mode"
-                    :key="item.value"
-                    :label="item.label"
-                    :value="item.value"
-                  >
-                  </el-option>
-                </el-select>
-              </el-form-item>
-              <el-row :gutter="20" v-if="form.longTask">
-                <el-col :span="14">
-                  <el-form-item label="闀挎湡浠诲姟" prop="longTemp">
-                    <el-radio-group v-model="objyl.longTemp">
-                      <el-radio
-                        v-for="(item, index) in longtype"
-                        :label="item.value"
-                        >{{ item.label }}</el-radio
-                      >
-                    </el-radio-group>
-                  </el-form-item>
-                </el-col>
-                <el-col :span="8">
-                  <el-form-item label="浠诲姟鍛ㄦ湡" prop="name">
-                    <el-input
-                      v-model="objyl.sendDay"
-                      placeholder="榛樿5澶╁悗"
-                    ></el-input>
-                  </el-form-item>
-                </el-col>
-              </el-row>
-              <el-row>
-                <el-col :span="20"
-                  ><el-form-item label="閫傜敤绉戝" prop="region">
-                    <el-select
-                      style="width: 400px"
-                      v-model="tempDetpRelevanceslist"
-                      size="medium"
-                      multiple
-                      filterable
-                      placeholder="璇烽�夋嫨绉戝"
-                    >
-                      <el-option
-                        class="ruleFormaa"
-                        v-for="item in belongDepts"
-                        :key="item.deptCode"
-                        :label="item.deptName"
-                        :value="item.deptCode"
-                      >
-                      </el-option>
-                    </el-select> </el-form-item
-                ></el-col>
-              </el-row>
-              <!-- <el-row>
-                <el-col :span="20"
-                  ><el-form-item label="閫傜敤鐥呭尯" prop="region">
-                    <el-select
-                      v-model="tempbelongWards"
-                      style="width: 400px"
-                      size="medium"
-                      multiple
-                      filterable
-                      placeholder="璇烽�夋嫨绉戝"
-                    >
-                      <el-option
-                        class="ruleFormaa"
-                        v-for="item in belongWards"
-                        :key="item.districtCode"
-                        :label="item.districtName"
-                        :value="item.districtCode"
-                      >
-                      </el-option>
-                    </el-select> </el-form-item
-                ></el-col>
-              </el-row> -->
 
-              <div class="xinz-infs">
-                <el-form-item>
-                  <template #label>
-                    閫傜敤鐤剧梾
-                    <el-tooltip
-                      class="item"
-                      effect="light"
-                      content="閫夋嫨濂介�傜敤鐤剧梾鍚庯紝鍙互鏂逛究鎮ㄩ�氳繃鐤剧梾璇婃柇鏌ユ壘鍒板搴旂殑鐥呬汉!"
-                      placement="top-start"
-                    >
-                      <i class="el-icon-warning-outline"></i>
-                    </el-tooltip>
-                  </template>
-
-                  <el-tag
-                    v-for="tag in illnesslist"
-                    :key="tag.icdid"
-                    type="warning"
-                    :disable-transitions="false"
-                  >
-                    {{ tag.icdname }}
-                  </el-tag>
-                  <!-- <el-tag v-if="hasMore" type="info">+{{ remaining }} more</el-tag> -->
-                </el-form-item>
-              </div>
               <el-form-item label="闂嵎鎻忚堪" prop="description">
                 <el-input
                   type="textarea"
@@ -718,10 +1126,11 @@
                 >
                 </el-input
               ></el-form-item>
-            </el-form></div
-        ></el-tab-pane>
-        <el-tab-pane label="闂灞曠ず"
-          ><div class="preview-left">
+            </el-form>
+          </div>
+        </el-tab-pane>
+        <el-tab-pane label="闂灞曠ず">
+          <div class="preview-left">
             <div v-for="item in questionList">
               <!-- 鍗曢�� -->
               <div
@@ -730,7 +1139,7 @@
                 v-if="item.scriptType == 1"
               >
                 <div class="dev-text">
-                  {{ item.sort }}銆乕鍗曢�塢<span>{{ item.scriptContent }}</span>
+                  {{ item.sort }}. [鍗曢�塢<span>{{ item.scriptContent }}</span>
                 </div>
                 <div class="dev-xx">
                   <el-radio-group v-model="item.remark">
@@ -750,10 +1159,10 @@
                 v-if="item.scriptType == 2"
               >
                 <div class="dev-text">
-                  {{ item.sort }}銆乕澶氶�塢<span>{{ item.scriptContent }}</span>
+                  {{ item.sort }}. [澶氶�塢<span>{{ item.scriptContent }}</span>
                 </div>
                 <div class="dev-xx">
-                  <el-checkbox-group v-model="qremark">
+                  <el-checkbox-group v-model="item.qremark">
                     <el-checkbox
                       v-for="(items, index) in item.svyLibTemplateTargetoptions"
                       :key="index"
@@ -771,7 +1180,7 @@
                 v-if="item.scriptType == 4"
               >
                 <div class="dev-text">
-                  {{ item.sort }}銆乕闂瓟]<span>{{ item.scriptContent }}</span>
+                  {{ item.sort }}. [闂瓟]<span>{{ item.scriptContent }}</span>
                 </div>
                 <div class="dev-xx">
                   <el-input
@@ -782,12 +1191,13 @@
                   </el-input>
                 </div>
               </div>
-            </div></div
-        ></el-tab-pane>
+            </div>
+          </div>
+        </el-tab-pane>
       </el-tabs>
 
       <span slot="footer" class="dialog-footer">
-        <!-- <el-button @click="previewGo">淇濆瓨妯℃澘璇︽儏淇敼</el-button> -->
+        <el-button @click="previewGo">淇濆瓨妯℃澘璇︽儏淇敼</el-button>
         <el-button type="primary" @click="Departmenttreatment"
           >淇濆瓨浣跨敤</el-button
         >
@@ -803,8 +1213,6 @@
       <div class="examine-jic">
         <div class="jic-value">
           <el-row :gutter="20">
-            <!--鐢ㄦ埛鏁版嵁-->
-
             <el-form
               :model="topqueryParams"
               ref="queryForm"
@@ -814,19 +1222,11 @@
               label-width="98px"
             >
               <el-form-item label="闂嵎鍚嶇О">
-                <el-input v-model="topqueryParams.svyname"></el-input>
+                <el-input
+                  v-model="topqueryParams.svyname"
+                  @keyup.enter.native="handleQuerymb"
+                ></el-input>
               </el-form-item>
-              <!-- <el-form-item label="閫傜敤褰㈠紡" prop="status">
-                <el-select v-model="topqueryParams.topica" placeholder="璇烽�夋嫨">
-                  <el-option
-                    v-for="item in taskoptions"
-                    :key="item.value"
-                    :label="item.label"
-                    :value="item.value"
-                  >
-                  </el-option>
-                </el-select>
-              </el-form-item> -->
               <el-form-item>
                 <el-button
                   type="primary"
@@ -838,13 +1238,12 @@
                 <el-button
                   icon="el-icon-refresh"
                   size="medium"
-                  @click="resetQuery"
+                  @click="resetQuerymb"
                   >閲嶇疆</el-button
                 >
               </el-form-item>
             </el-form>
             <el-divider></el-divider>
-            <!-- 閫夋嫨妯℃澘鍒楄〃 -->
             <SFtable
               @selectfn="selectfn"
               :currentList="userList"
@@ -865,18 +1264,28 @@
         </div>
       </div>
     </el-drawer>
+    <Optional-Form
+      ref="child"
+      :dialogVisiblepatient="dialogVisiblepatientjb"
+      :overallCase="diagglist"
+      @addoption="dialogVisiblepatientjb = false"
+      @kkoption="dialogVisiblepatientjb = true"
+    />
   </div>
 </template>
-
 <script>
 import { messagelistpatient } from "@/api/patient/homepage";
 import store from "@/store";
 import {
-  getTaskpatient,
-  getlibrarylist,
-  getFollowuplist,
+  getTaskpatientQC,
+  taskoperhospgetsondel,
+  taskdiaghospgetsondel,
+  getillnesslist,
+  getbaseopera,
+  Externallist,
   getQtemplatelist,
   getQtemplateobj,
+  taskgetQtemplateobj,
   TaskQuestioncomit,
   deleteTaskQuestioncomit,
   Questionnairetaskgetson,
@@ -885,38 +1294,60 @@
   getillness,
   Editsingletask,
   getQtemplateclassify,
-  depthospgetsonlist,
+  taskdepthospgetsondel,
+  taskdepthospgetsonlist,
+  taskdiaggetlist,
+  rwztaskdepthospgetsonlist,
+  rwztaskdiaggetlist,
+  taskopergetlist,
 } from "@/api/AiCentre/index";
-
-import SFtable from "@/components/SFtable"; //琛ㄦ牸缁勪欢
+import { listMedication } from "@/api/knowledge/drug";
+import OptionalForm from "@/components/OptionalForm";
+import SFtable from "@/components/SFtable";
+import SortCheckbox from "@/components/SortCheckbox";
+import { MessageBox } from "element-ui";
 
 export default {
   name: "ServiceDetails",
   data() {
     return {
       title: "瀹f暀鍐呭鍒楄〃",
-      currenttype: 1, //1瀹f暀2闂ㄨ瘖3鍑洪櫌4澶嶈瘖5浣撴6闂嵎
-      id: "", //
-      previewid: "", //浠诲姟妯℃澘浼犻�抜d
+      currenttype: 1,
+      id: "",
+      previewid: "",
       libName: "",
+      templateor: false,
+      submitLoading: false,
       objyl: {},
-      overallCase: [], //閫夋嫨鎮h�呮��
+      overallCase: [],
       allpids: [],
       appraiselist: [],
       optionsclass: [],
       illnesslist: [],
       mode: [],
-      libId: null, //妯℃澘搴撴ā鏉縤d
-      Editprogress: 1, //缂栬緫杩涘害
-      drawermb: false, //閫夋嫨妯℃澘寮圭獥
-      previewtf: false, //棰勮
-      loading: false, // 閬僵灞�
-      patientloading: false, // 閬僵灞�
-      dialogVisiblepatient: false, //娣诲姞鎮h�呭脊妗�
+      libId: null,
+      Editprogress: 1,
+      drawermb: false,
+      previewtf: false,
+      loading: false,
+      patientloading: false,
+      previewtftype: 0,
+      dialogVisiblepatient: false,
+      dialogVisiblepatientjb: false,
+      deptcodesWards: [],
+      leavehospitaldistrictcodes: [],
+      illnesscodes: [],
       radio: 1,
       checkboxlist: [],
       tableLabel: [],
       questionList: [],
+      donorchargeList: [],
+      baseoperaList: [
+        { value: "1", label: "涓�绾ф墜鏈�" },
+        { value: "2", label: "浜岀骇鎵嬫湳" },
+        { value: "3", label: "涓夌骇鎵嬫湳" },
+        { value: "4", label: "鍥涚骇鎵嬫湳" },
+      ],
       usable: [
         { value: "0", label: "鍙敤" },
         { value: "1", label: "鍋滅敤" },
@@ -927,39 +1358,39 @@
       ],
       props: { multiple: true, value: "deptCode", label: "deptName" },
       propstask: { value: "deptCode", label: "deptName" },
-      // 鎮h�呰〃鍗�
       tableLabelhz: [
         { label: "鍑洪櫌鏃ユ湡", width: "150", prop: "inhosptime" },
         { label: "鎮h��", width: "", prop: "name" },
+        { label: "鎮h�呰瘖鏂�", width: "", prop: "leavediagname" },
         { label: "韬唤璇�", width: "200", prop: "idcardno" },
         { label: "鎬у埆", width: "", prop: "sex" },
         { label: "骞撮緞", width: "", prop: "age" },
+        { label: "鐢佃瘽", width: "180", prop: "telcode" },
         { label: "璐d换鎶ゅ+", width: "", prop: "nurseName" },
         { label: "涓绘不鍖荤敓", width: "", prop: "drname" },
         { label: "绉戝", width: "240", prop: "dept" },
         { label: "鐥呭尯", width: "240", prop: "leavehospitaldistrictname" },
       ],
-      // 鎮h�呰〃鍗�
       tableLabelhzwb: [
         { label: "鍑洪櫌鏃ユ湡", width: "150", prop: "endtime" },
         { label: "鎮h��", width: "", prop: "name" },
+        { label: "鎮h�呰瘖鏂�", width: "", prop: "diagname" },
         { label: "韬唤璇�", width: "200", prop: "sfzh" },
         { label: "鎬у埆", width: "", prop: "sex" },
         { label: "骞撮緞", width: "", prop: "age" },
+        { label: "鐢佃瘽", width: "180", prop: "telcode" },
         { label: "鍑洪櫌澶╂暟", width: "", prop: "endDay" },
         { label: "璐d换鎶ゅ+", width: "", prop: "nurseName" },
         { label: "涓绘不鍖荤敓", width: "", prop: "drname" },
         { label: "绉戝", width: "180", prop: "deptName" },
         { label: "鐥呭尯", width: "150", prop: "leavehospitaldistrictname" },
       ],
-
       tableLabelwj: [
         { label: "闂嵎鏍囬", width: "", prop: "svyname" },
         { label: "闂嵎鎻忚堪", width: "", prop: "description" },
         { label: "淇敼鏃ユ湡", width: "", prop: "updateTime" },
         { label: "鍒涘缓浜�", width: "", prop: "createBy" },
       ],
-      // 鍙橀噺
       tableLabelvariable: [
         { label: "鍙橀噺鍚嶇О", width: "", prop: "variablename" },
         { label: "鍖归厤绗�", width: "", prop: "character" },
@@ -968,7 +1399,7 @@
       preachform: [
         { label: "澶氬獟浣�", value: 1 },
         { label: "绾歌川", value: 2 },
-        { label: "鐢佃瘽", value: 3 },
+        { label: "鏅鸿兘璇煶", value: 3 },
         { label: "鐭俊", value: 4 },
         { label: "寰俊鍏紬鍙�", value: 5 },
         { label: "寰俊灏忕▼搴�", value: 6 },
@@ -978,48 +1409,47 @@
         { label: "绾夸笅锛堢焊璐級", value: 10 },
         { label: "绾夸笂锛堢煭淇�/閽夐拤鐨勬枃鏈�侀棶鍗烽摼鎺ワ級", value: 11 },
       ],
-      // 鏃堕棿澶勭悊
-      daytime: [], //鏃ユ湡
-      applydaytime: [], //璁$畻鏃ユ湡
-      time1: "", //涓婂崍鏃堕棿娈�
-      time2: "", //涓嬪崍鏃堕棿娈�
-      time3: "", //鏅氫笂鏃堕棿娈�
-      time4: "", //鏅氫笂鏃堕棿娈�
+      daytime: [],
+      applydaytime: [],
+      diseaseDept: null,
+      diseaseWard: null,
+      diseaseDepts: "",
+      diseaseWards: "",
+      time1: "",
+      time2: "",
+      time3: "",
+      time4: "",
       topqueryParams: {
-        pageNum: 1, //
+        pageNum: 1,
         pageSize: 10,
       },
-      checkList: [],
+      checkList: "",
+      selectedOrder: [],
       deliverytopqueryParams: {
-        pageNum: 1, //
+        pageNum: 1,
         pageSize: 10,
       },
       patientqueryParams: {
-        pageNum: 1, //
+        pageNum: 1,
         pageSize: 10,
-        topica: 1, //0鍏ㄩ儴1绉戝2鐥呭尯
-        leavehospitaldistrictcodes:[],
-        leaveldeptcodes:[],
+        leavehospitaldistrictcodes: [],
+        leaveldeptcodes: [],
       },
       topicoptions: [{ children: [{ children: [] }] }],
-      showSearch: true, //
-      total: 0, //
-      sontotal: 0, //
-      patienttotal: 0, //
-      // 閫変腑鏁扮粍
+      showSearch: true,
+      total: 0,
+      sontotal: 0,
+      patienttotal: 0,
       ids: [],
-      // 闈炲崟涓鐢�
       single: true,
-      // 闈炲涓鐢�
       multiple: true,
-      // 鐢ㄦ埛琛ㄦ牸鏁版嵁
-      userList: [], //妯℃澘鍒楄〃
-      multiplechoice: [], //澶氶�夌粨鏋�
-      patientuserList: [], //閫夋嫨鎮h�呭垪琛�
-      sonuserList: [], //閫変腑鎮h�呭垪琛�
-      delvariableList: [], //鍒犻櫎鍙橀噺涓存椂瀛樺偍
+      userList: [],
+      multiplechoice: [],
+      patientuserList: [],
+      sonuserList: [],
+      delvariableList: [],
       longtype: [
-        { value: 0, label: "鏅�氫换鍔�" },
+        { value: 0, label: "鑷畾涔夊懆鏈�" },
         { value: 1, label: "闀挎湡浠诲姟" },
       ],
       variableList: [
@@ -1036,12 +1466,12 @@
           default: true,
         },
         {
-          name: "鐢佃瘽",
+          name: "鏅鸿兘璇煶",
           value: "${dhh}",
           fill: "娲惧彂鏃惰嚜鍔ㄥ尮閰�",
           default: true,
         },
-      ], //鍙橀噺鍒楄〃
+      ],
       transitionList: [
         {
           name: "濮撳悕",
@@ -1056,15 +1486,16 @@
           default: true,
         },
         {
-          name: "鐢佃瘽",
+          name: "鏅鸿兘璇煶",
           value: "${dhh}",
           fill: "娲惧彂鏃惰嚜鍔ㄥ尮閰�",
           default: true,
         },
       ],
       variableListTime: [],
-      tasktopic: null, //鏂板绫诲瀷
+      tasktopic: null,
       SelectPatientslist: [],
+      orgname: localStorage.getItem("orgname"),
       form: {
         patTaskRelevances: [],
         sendType: 1,
@@ -1072,86 +1503,51 @@
         templatename: "",
         templateid: null,
         libtemplateid: null,
-        kcb: "浜茬埍鐨勬偅鑰�/瀹跺睘锛屾偍濂斤紒鎴戜滑鏄禉涓尰澶т簩闄㈢殑鍖绘姢浜哄憳锛屼负浜嗘洿濂藉湴浜嗚В鎮ㄧ殑搴峰鎯呭喌锛岃鎮ㄦ娊涓�鐐瑰疂璐垫椂闂达紝瑙傜湅杩欎唤瀹f暀璧勮銆�",
+        kcb:
+          "浜茬埍鐨勬偅鑰�/瀹跺睘锛屾垜浠槸" +
+          localStorage.getItem("orgname") +
+          "鐨勫尰鎶や汉鍛橈紝涓轰簡鏇村ソ鍦颁簡瑙f偍鐨勫悍澶嶆儏鍐碉紝璇锋偍鎶戒竴鐐瑰疂璐垫椂闂达紝瑙傜湅杩欎唤瀹f暀璧勮銆�",
         jsy: "璇锋偍娉ㄦ剰浼戞伅鍜岃惀鍏伙紝鐢熸椿涓婅鍔抽�哥粨鍚堬紝閫傚綋閿荤偧锛屾垝鐑熼檺閰掞紝淇濇寔蹇冩儏鑸掔晠锛屽畾鏈熷璇娿�傞偅鏈瀹f暀鍐呭灏卞埌杩欓噷锛岀鎮ㄨ韩浣撳仴搴凤紒",
+        // ===== 浠诲姟缁勪富瀵硅薄 =====
+        serviceTaskScheduleVO: {
+          scheduleStyle: 0,
+          scheduleTimeNum: null,
+          scheduleTimeUnit: null,
+          maxLoopCount: 0,
+          currentLoopCount: 0,
+          currentSeq: 0,
+          nextSeq: 0,
+          nextExecuteTime: "",
+          scheduleBenchmark: 0,
+          scheduleBenchmarkCustomTime: "",
+          detailList: [],
+        },
       },
       taskoptions: [
-        {
-          value: "1",
-          label: "鍑洪櫌鐥呬汉",
-        },
-        {
-          value: "4",
-          label: "鍦ㄩ櫌鐥呬汉",
-        },
-        {
-          value: "2",
-          label: "闂ㄨ瘖鐥呬汉",
-        },
-        {
-          value: "3",
-          label: "浣撴鐥呬汉",
-        },
+        { value: "4", label: "鍑洪櫌鐥呬汉" },
+        { value: "1", label: "鍦ㄩ櫌鐥呬汉" },
+        { value: "2", label: "闂ㄨ瘖鐥呬汉" },
+        { value: "3", label: "浣撴鐥呬汉" },
+        { value: "6", label: "闄㈠鎮h��" },
+        { value: "5", label: "鎵嬫湳鐥呬汉" },
       ],
       source: [
-        {
-          value: 0,
-          label: "鎵�灞炴偅鑰�",
-        },
-        {
-          value: 1,
-          label: "绉戝鎮h��",
-        },
-        {
-          value: 2,
-          label: "鐥呭尯鎮h��",
-        },
+        { value: 0, label: "鎵�灞炴偅鑰�" },
+        { value: 1, label: "绉戝鎮h��" },
+        { value: 2, label: "鐥呭尯鎮h��" },
       ],
-
-      tasktypes: [
-        {
-          value: 1,
-          label: "鐩戞祴璇勪及",
-        },
-        {
-          value: 2,
-          label: "鍑洪櫌闅忚",
-        },
-        {
-          value: 3,
-          label: "闂ㄨ瘖闅忚",
-        },
-        {
-          value: 4,
-          label: "瀹f暀鍏虫��",
-        },
-        {
-          value: 5,
-          label: "澶嶈瘖绠$悊",
-        },
-        {
-          value: 6,
-          label: "婊℃剰搴﹁皟鏌�",
-        },
-        {
-          value: 7,
-          label: "鎮h�呮姤鍛�",
-        },
-
-        {
-          value: 8,
-          label: "鍏朵粬閫氱煡",
-        },
-      ],
-      // 绉戝/鐥呭尯
-      belongWards: [],
+      tasktypes: store.getters.tasktypes,
       belongWards: [],
       deptlist: [],
       hosplist: [],
-      tempDetpRelevanceslist: [], //绉戝鏁版嵁
-      tempDetpRelevanceslistform: [], //绉戝鏁版嵁
-      tempbelongWards: [], //鐥呭尯鏁版嵁
-      tempbelongWardsform: [], //鐥呭尯鏁版嵁
+      diagglist: [],
+      operlist: [],
+      medicalCodes: [],
+      medicalOptions: [],
+      tempDetpRelevanceslist: [],
+      tempDetpRelevanceslistform: [],
+      tempbelongWards: [],
+      tempbelongWardsform: [],
       rules: {
         taskName: [
           { required: true, message: "浠诲姟鍚嶇О涓嶈兘涓虹┖", trigger: "blur" },
@@ -1165,24 +1561,20 @@
         sendType: [
           { required: true, message: "鍙戦�佽缃笉鑳戒负绌�", trigger: "blur" },
         ],
-        deptcode: [
-          { required: true, message: "閫傜敤绉戝涓嶈兘涓虹┖", trigger: "blur" },
+        longTask: [
+          { required: true, message: "璇烽�夋嫨鎵ц鍛ㄦ湡", trigger: "blur" },
         ],
-        // leavehospitaldistrictcode: [
-        //   { required: true, message: "閫傜敤鐥呭尯涓嶈兘涓虹┖", trigger: "blur" },
-        // ],
       },
-      // 绉戝闄㈠尯鏌ヨ鍏ュ弬
-      queryParamsdept: {
-        tempid: "",
-        type: 11,
-      },
+      belongDepts: [],
+      queryParamsdept: {},
       quote: false,
       serviceType: null,
+      // 妯℃澘鎼滅储
+      templateOptions: [],
+      templateLoading: false,
     };
   },
-  components: { SFtable },
-
+  components: { SFtable, OptionalForm, SortCheckbox },
   created() {
     this.appraiselist = store.getters.appraiselist;
     this.belongWards = store.getters.belongWards;
@@ -1195,6 +1587,7 @@
     this.serviceType = Number(this.$route.query.serviceType);
     this.form.serviceType = Number(this.$route.query.serviceType);
     this.Acquisitiontype();
+    this.getillnesslist();
     this.Getdetails();
     this.getQtemplateclassify();
   },
@@ -1205,14 +1598,19 @@
       this.getQtemplateclassify();
     }
   },
-
+  computed: {
+    displayedTags() {
+      return this.illnesslist.slice(0, 10);
+    },
+    hasMore() {
+      return this.illnesslist.length > 10;
+    },
+    remaining() {
+      return this.illnesslist.length - 10;
+    },
+  },
   methods: {
-    // {
-    //   濮撳悕: { "${name}": "榫欏偛澶�" },
-    //   鍦板潃: { "${dzz}": "榫欏" },
-    //   鐢佃瘽: { "${dhh}": "鍏釜鍏�" },
-    // }
-    // 鍙橀噺杞崲瀵硅薄杞暟缁�
+    // ---------- 宸ュ叿鏂规硶 ----------
     convertFormat1ToFormat2(data) {
       let result = [];
       for (let key in data) {
@@ -1225,7 +1623,6 @@
       }
       return result;
     },
-    // 鏁扮粍杞璞�
     convertFormat2ToFormat1(data) {
       let result = {};
       data.forEach((item) => {
@@ -1235,7 +1632,15 @@
       });
       return result;
     },
-    // 鑾峰彇褰撳墠绫诲瀷
+    daysBetween(endDate) {
+      if (!endDate) return "";
+      const now = new Date();
+      const end = new Date(endDate);
+      const diff = Math.floor((now - end) / (1000 * 60 * 60 * 24));
+      return diff > 0 ? diff : 0;
+    },
+
+    // ---------- 鏁版嵁鍔犺浇 ----------
     Acquisitiontype() {
       let queryParams = {
         pageNum: this.topqueryParams.pageNum,
@@ -1247,106 +1652,57 @@
       this.tableLabel = this.tableLabelwj;
       if (this.form.serviceType == 1) {
         this.checkboxlist = [
-          {
-            value: "1",
-            label: "浜哄伐",
-          },
-
-          {
-            value: "2",
-            label: "绾歌川",
-          },
-          {
-            value: "4",
-            label: "鐭俊",
-          },
-          {
-            value: "5",
-            label: "寰俊鍏紬鍙�",
-          },
-          { label: "寰俊灏忕▼搴�", value: 6 },
+          { value: "1", label: "浜哄伐" },
+          { value: "2", label: "绾歌川" },
+          { value: "4", label: "鐭俊" },
+          { value: "5", label: "寰俊鍏紬鍙�" },
+          { label: "寰俊灏忕▼搴�", value: "6" },
         ];
-      } else if (this.form.serviceType == 6) {
+      } else if (
+        this.form.serviceType == 6 ||
+        this.form.serviceType == 14 ||
+        this.form.serviceType == 15
+      ) {
         this.checkboxlist = [
-          {
-            value: "3",
-            label: "鐢佃瘽",
-          },
-          {
-            value: "4",
-            label: "鐭俊",
-
-          },
-          {
-            value: "5",
-            label: "寰俊鍏紬鍙�",
-          },
-          {
-            value: "6",
-            label: "寰俊灏忕▼搴�",
-          },
-
-          {
-            value: "8",
-            label: "鏅鸿兘鏈哄櫒浜�",
-          },
+          { value: "1", label: "浜哄伐" },
+          { value: "3", label: "鏅鸿兘璇煶" },
+          { value: "4", label: "鐭俊" },
+          { value: "5", label: "寰俊鍏紬鍙�" },
+          { value: "6", label: "寰俊灏忕▼搴�" },
         ];
-      } else if (this.form.serviceType == 7) {
+      } else if (
+        this.form.serviceType == 7 ||
+        this.form.serviceType == 10 ||
+        this.form.serviceType == 11 ||
+        this.form.serviceType == 8 ||
+        this.form.serviceType == 12 ||
+        this.form.serviceType == 13 ||
+        this.form.serviceType == 9
+      ) {
         this.checkboxlist = [
-          {
-            value: "1",
-            label: "浜哄伐",
-          },
-          {
-            value: "2",
-            label: "绾歌川",
-          },
-          {
-            value: "3",
-            label: "鐢佃瘽",
-          },
-          {
-            value: "4",
-            label: "鐭俊",
-
-          },
-          {
-            value: "5",
-            label: "寰俊鍏紬鍙�",
-          },
-          {
-            value: "6",
-            label: "寰俊灏忕▼搴�",
-          },
+          { value: "1", label: "浜哄伐" },
+          { value: "2", label: "绾歌川" },
+          { value: "3", label: "鏅鸿兘璇煶" },
+          { value: "4", label: "鐭俊" },
+          { value: "5", label: "寰俊鍏紬鍙�" },
+          { value: "6", label: "寰俊灏忕▼搴�" },
+          { value: "7", label: "鏈悗闅忚" },
         ];
-      } else if (this.form.serviceType == 2 || this.form.serviceType == 3|| this.form.serviceType == 5|| this.form.serviceType == 4) {
+      } else if (
+        this.form.serviceType == 2 ||
+        this.form.serviceType == 3 ||
+        this.form.serviceType == 5 ||
+        this.form.serviceType == 16 ||
+        this.form.serviceType == 18 ||
+        this.form.serviceType == 19 ||
+        this.form.serviceType == 4
+      ) {
         this.checkboxlist = [
-          {
-            value: "1",
-            label: "浜哄伐",
-          },
-          {
-            value: "3",
-            label: "鐢佃瘽",
-          },
-          {
-            value: "4",
-            label: "鐭俊",
-
-          },
-          {
-            value: "5",
-            label: "寰俊鍏紬鍙�",
-          },
-          {
-            value: "6",
-            label: "寰俊灏忕▼搴�",
-          },
-
-          {
-            value: "8",
-            label: "鏅鸿兘鏈哄櫒浜�",
-          },
+          { value: "1", label: "浜哄伐" },
+          { value: "3", label: "鏅鸿兘璇煶" },
+          { value: "4", label: "鐭俊" },
+          { value: "5", label: "寰俊鍏紬鍙�" },
+          { value: "6", label: "寰俊灏忕▼搴�" },
         ];
       }
       getQtemplatelist(this.topqueryParams).then((response) => {
@@ -1354,171 +1710,14 @@
         this.total = response.total;
       });
     },
-    nextstep() {
-      this.$refs["form"].validate((valid) => {
-        if (valid) {
-          if (this.Editprogress <= 3) {
-            return this.Editprogress++;
-          }
-        } else {
-          this.$modal.msgError("琛ㄥ崟鍐呭鏈畬鍠勶紝璇锋鏌�");
-        }
+    getQtemplateclassify() {
+      getQtemplateclassify({}).then((res) => {
+        this.optionsclass = res.rows;
       });
     },
-    // 淇濆瓨
-    submitForm(formName) {
-      if (this.time4 && this.form.sendType == 3)
-        this.form.showTimeMorn = this.time4;
-      this.form.sendTimeslot = [
-        {
-          begantime: this.time4,
-          endtime: "",
-          xh: 1,
-        },
-      ];
-
-      if (this.checkList[0]) {
-        this.form.preachform = this.checkList.join(",");
-      } else {
-        this.$modal.msgError("璇烽�夋嫨鏈嶅姟绫诲瀷");
-        return;
-      }
-      if (!this.form.patTaskRelevances[0] && !this.form.longTask) {
-        this.$modal.msgError("璇烽�夋嫨鐥呬汉");
-        return;
-      }
-      if (!this.form.templatename) {
-        this.$modal.msgError("鏈�夋嫨妯℃澘");
-        return;
-      }
-      if ((this.form.sendType == 1 && this.time1) || this.form.sendType == 2) {
-      } else if (
-        (this.form.sendType == 3 && this.time4) ||
-        this.form.longTask
-      ) {
-      } else {
-        return this.$modal.msgError("鏃堕棿淇℃伅缂哄け");
-      }
-      const filteredArray = this.variableList.filter(
-        (item) =>
-          item.name !== "濮撳悕" && item.name !== "鐢佃瘽" && item.name !== "鍦板潃"
-      );
-      this.form.textParam = this.convertFormat2ToFormat1(filteredArray);
-      if (this.form.taskid) {
-        this.form.isoperation = 2;
-      } else {
-        this.form.isoperation = 1;
-      }
-      if (!this.form.type) {
-        this.form.type = this.$route.query.type;
-      }
-      this.form.serviceType = this.serviceType;
-      this.form.leaveldeptcodes = store.getters.belongDepts.map(
-        (obj) => obj.deptCode
-      );
-      this.form.leavehospitaldistrictcodes = store.getters.belongWards.map(
-        (obj) => obj.districtCode
-      );
-      console.log(this.form.longTask);
-      console.log(this.form.preachform);
-
-      if (this.form.longTask && this.form.preachform == 6) {
-        this.form.patCycle = 1;
-      }
-      Editsingletask(this.form).then((res) => {
-        if (res.code == 200) {
-          if (this.form.taskid) {
-            this.$modal.msgSuccess("淇敼鎴愬姛");
-          } else {
-            this.puttaskid(res.data);
-            this.$modal.msgSuccess("鏂板鎴愬姛");
-          }
-          this.$router.push({
-            path: "/followvisit/tasklist",
-            query: { tasktopic: this.form.serviceType },
-          });
-        }
-      });
-    },
-    // 缁欎换鍔℃ā鏉胯祴鍊间换鍔d
-    puttaskid(data) {
-      getTaskQuestioncomit(this.form.templateid).then((res) => {
-        if (res.code == 200) {
-          this.objyl = res.data;
-          if (this.objyl.taskid == data.taskId) {
-            this.objyl.isoperation = 2;
-          } else {
-            this.objyl.isoperation = 1;
-          }
-          this.objyl.taskid = data.taskId;
-          if (!this.objyl.sendDay) {
-        this.objyl.sendDay='5';
-      }
-          TaskQuestioncomit(this.objyl).then((response) => {
-            this.previewtf = false;
-            this.form.libtemplateid = this.objyl.svyid;
-            this.form.templateid = response.data;
-            // this.putbelongDepts(response.data);
-            this.form.templatename = this.objyl.svyname;
-            this.$modal.msgSuccess("閫夋嫨妯℃澘鎴愬姛");
-          });
-        }
-      });
-    },
-    // ----------------------琛ㄦ牸瀛愮粍浠朵簨浠�
-
-    // 閫夋嫨棰勮
-    selectfn(row, type) {
-      // 妯℃澘鎯呭喌涓嬭幏鍙栨ā鏉夸俊鎭�
-      if (type == 1) {
-        this.libName = row.svyname;
-        this.libId = row.svyid;
-        this.questionList = row.svyTemplateLibScripts;
-        getQtemplateobj({ svyid: row.svyid }).then((res) => {
-          if (res.code == 200) {
-            this.objyl = res.rows[0];
-            if (this.form.longTask) {
-              this.objyl.longTemp = 1;
-            }
-            this.queryParamsdept.type = 1;
-            this.queryParamsdept.tempid = row.svyid;
-            this.listDept();
-
-            this.objyl.suitway = this.objyl.suitway.split(",");
-            this.questionList = res.rows[0].svyTemplateLibScripts;
-            this.getillness(row.svyid);
-            this.previewtf = true;
-          }
-        });
-        console.log(row.svyTemplateLibScripts);
-        this.previewid = row.svyid;
-        this.Variablehandling(row.svyTemplateLibScripts, 1);
-      } else if (type == 2) {
-      } else if (type == 3) {
-      }
-    },
-    // 棰勮
-    previewfnmb() {
-      getTaskQuestioncomit(this.form.templateid).then((res) => {
-        if (res.code == 200) {
-          console.log(res, "棰勮鏁版嵁");
-          this.objyl = res.data;
-          if (this.objyl.suitway)
-            this.objyl.suitway = this.objyl.suitway.split(",");
-          this.queryParamsdept.tempid = this.form.templateid;
-          this.queryParamsdept.type = 11;
-          this.getillness(this.form.libtemplateid);
-          // 鎵ц鑾峰彇璇ヤ换鍔℃ā鏉縤d
-          this.listDept();
-          this.previewtf = true;
-          getQtemplateobj({ svyid: this.form.libtemplateid }).then((res) => {
-            if (res.code == 200) {
-              this.questionList = res.rows[0].svyTemplateLibScripts;
-              this.objyl.svyTemplateLibScripts =
-                res.rows[0].svyTemplateLibScripts;
-            }
-          });
-        }
+    getillnesslist() {
+      getillnesslist({ pageNum: 1, pageSize: 1000 }).then((res) => {
+        this.donorchargeList = res.rows;
       });
     },
     getillness(id) {
@@ -1531,64 +1730,525 @@
         });
       }
     },
-    // 澶勭悊闂灞傚彉閲�
+    Getdetails() {
+      this.form = {
+        patTaskRelevances: [],
+        sendType: 1,
+        sendDay: 5,
+        templatename: "",
+        templateid: null,
+        libtemplateid: null,
+        kcb:
+          "浜茬埍鐨勬偅鑰�/瀹跺睘锛屾垜浠槸" +
+          localStorage.getItem("orgname") +
+          "鐨勫尰鎶や汉鍛橈紝涓轰簡鏇村ソ鍦颁簡瑙f偍鐨勫悍澶嶆儏鍐碉紝璇锋偍鎶戒竴鐐瑰疂璐垫椂闂达紝瀹屾垚杩欎唤闅忚闂嵎銆�",
+        jsy: "璇锋偍娉ㄦ剰浼戞伅鍜岃惀鍏伙紝鐢熸椿涓婅鍔抽�哥粨鍚堬紝閫傚綋閿荤偧锛屾垝鐑熼檺閰掞紝淇濇寔蹇冩儏鑸掔晠锛屽畾鏈熷璇娿�傞偅鏈鍥炶灏卞埌杩欓噷锛岀鎮ㄨ韩浣撳仴搴凤紒",
+        serviceTaskScheduleVO: {
+          scheduleStyle: 0,
+          scheduleTimeNum: null,
+          scheduleTimeUnit: null,
+          maxLoopCount: 0,
+          currentLoopCount: 0,
+          currentSeq: 0,
+          nextSeq: 0,
+          nextExecuteTime: "",
+          scheduleBenchmark: 0,
+          scheduleBenchmarkCustomTime: "",
+          detailList: [],
+        },
+      };
+      this.questionList = [];
+      if (this.id) {
+        Questionnairetaskgetson({ taskid: this.id }).then((res) => {
+          if (res.code == 200) {
+            this.form = res.data;
+            // 濡傛灉杩斿洖浜� serviceTaskScheduleVO锛岃В鏋愭槑缁嗕腑鐨� content
+            if (
+              this.form.serviceTaskScheduleVO &&
+              this.form.serviceTaskScheduleVO.detailList
+            ) {
+              this.form.serviceTaskScheduleVO.detailList.forEach((item) => {
+                if (item.content) {
+                  try {
+                    const contentObj = JSON.parse(item.content);
+                    item.kcb = contentObj.kcb || "";
+                    item.jsy = contentObj.jsy || "";
+                    item.textParam = contentObj.text_param || {};
+                  } catch (e) {
+                    item.kcb = "";
+                    item.jsy = "";
+                    item.textParam = {};
+                  }
+                } else {
+                  item.kcb = "";
+                  item.jsy = "";
+                  item.textParam = {};
+                }
+              });
+            } else {
+              // 鑻ュ悗鍙版湭杩斿洖锛屽垯鍒濆鍖栦负绌�
+              this.form.serviceTaskScheduleVO = {
+                scheduleStyle: 0,
+                scheduleTimeNum: null,
+                scheduleTimeUnit: null,
+                maxLoopCount: 0,
+                currentLoopCount: 0,
+                currentSeq: 0,
+                nextSeq: 0,
+                nextExecuteTime: "",
+                scheduleBenchmark: 0,
+                scheduleBenchmarkCustomTime: "",
+                detailList: [],
+              };
+            }
+            this.form.serviceType = this.serviceType;
+            this.form.patTaskRelevances = this.form.patTaskRelevances
+              ? this.form.patTaskRelevances
+              : [];
+            this.diseaseDept = {
+              deptCode: this.form.deptcode,
+              deptName: this.form.deptname,
+            };
+            this.diseaseWard = {
+              districtCode: this.form.leavehospitaldistrictcode,
+              districtName: this.form.leavehospitaldistrictname,
+            };
+            // 鑽搧鍏宠仈鍥炴樉
+            if (this.form.medicalCode) {
+              this.medicalCodes = this.form.medicalCode
+                .split(",")
+                .filter(Boolean);
+              // 鍔犺浇宸查�夎嵂鍝佺殑閫夐」鍒楄〃锛堢敤浜庡睍绀� label锛�
+              const codes = this.form.medicalCode;
+              listMedication({
+                itemCode: codes,
+                pageNum: 1,
+                pageSize: 200,
+              }).then((res) => {
+                this.medicalOptions = res.rows || [];
+              });
+            }
+            this.overallCase = this.form.patTaskRelevances.concat();
+            this.checkList = this.form.preachform
+              ? this.form.preachform.split(",")
+              : "";
+            this.selectedOrder = this.form.preachformList || [];
+            this.overallCase.forEach((item) => {
+              if (item.endtime) {
+                item.endDay = this.daysBetween(item.endtime);
+              }
+            });
+            if (this.form.showDate)
+              this.daytime = this.form.showDate.split(",");
+            if (this.form.showTimeMorn) {
+              if (this.form.sendType == 3) {
+                this.time4 = this.form.showTimeMorn;
+              } else {
+                this.time1 = this.form.showTimeMorn.split(",");
+              }
+            }
+            if (this.form.taskid) {
+              this.listDept();
+            }
+            if (this.form.showTimeNoon)
+              this.time2 = this.form.showTimeNoon.split(",");
+            if (this.form.showTimeNight)
+              this.time3 = this.form.showTimeNight.split(",");
+            let filteredArray = this.convertFormat1ToFormat2(
+              this.form.textParam || {}
+            );
+            this.variableList = this.transitionList.concat(filteredArray);
+          } else {
+            this.$modal.msgError(res.code);
+          }
+          if (this.newadd) {
+            this.neWaddfn();
+          }
+        });
+      }
+    },
+    neWaddfn() {
+      this.id = null;
+      this.form.taskName = "";
+      this.form.taskid = null;
+      this.overallCase = [];
+      this.form.patTaskRelevances = [];
+      this.daytime = [];
+      this.applydaytime = [];
+      this.time1 = "";
+      this.time2 = "";
+      this.time3 = "";
+      this.time4 = "";
+      // 閲嶇疆浠诲姟缁�
+      this.form.serviceTaskScheduleVO = {
+        scheduleStyle: 0,
+        scheduleTimeNum: null,
+        scheduleTimeUnit: null,
+        maxLoopCount: 0,
+        currentLoopCount: 0,
+        currentSeq: 0,
+        nextSeq: 0,
+        nextExecuteTime: "",
+        scheduleBenchmark: 0,
+        scheduleBenchmarkCustomTime: "",
+        detailList: [],
+      };
+    },
+
+    // ---------- 浠诲姟缁勬槑缁嗘搷浣� ----------
+    addDetail() {
+      const detailList = this.form.serviceTaskScheduleVO.detailList;
+      const seq = detailList.length + 1;
+      detailList.push({
+        seq: seq,
+        dayOffset: 0,
+        templateid: null,
+        libtemplateid: null,
+        templatename: "",
+        content: "",
+        kcb: "",
+        jsy: "",
+        textParam: {},
+      });
+    },
+    removeDetail(index) {
+      this.form.serviceTaskScheduleVO.detailList.splice(index, 1);
+      this.form.serviceTaskScheduleVO.detailList.forEach((item, idx) => {
+        item.seq = idx + 1;
+      });
+    },
+    handleTemplateSelect(index, row) {
+      const selected = this.templateOptions.find(
+        (item) => item.svyid === row.templateid
+      );
+      if (selected) {
+        row.templatename = selected.svyname;
+        row.libtemplateid = selected.svyid; // 妯℃澘搴揑D
+      } else {
+        row.templatename = "";
+        row.libtemplateid = null;
+      }
+    },
+    remoteTemplate(query) {
+      if (query !== "") {
+        this.templateLoading = true;
+        getQtemplatelist({ svyname: query, pageNum: 1, pageSize: 20 })
+          .then((res) => {
+            this.templateOptions = res.rows;
+            this.templateLoading = false;
+          })
+          .catch(() => {
+            this.templateLoading = false;
+          });
+      } else {
+        this.templateOptions = [];
+      }
+    },
+
+    // ---------- 姝ラ瀵艰埅 ----------
+    nextstep() {
+      this.$refs["form"].validate((valid) => {
+        if (valid) {
+          if (this.Editprogress <= 3) this.Editprogress++;
+        } else {
+          this.$modal.msgError("琛ㄥ崟鍐呭鏈畬鍠勶紝璇锋鏌�");
+        }
+      });
+    },
+    laststep() {
+      this.Editprogress--;
+    },
+    resetForm(formName) {
+      this.$refs[formName].resetFields();
+    },
+
+    // ---------- 鍏宠仈閫夋嫨 ----------
+    handleDiseaseDeptChange(dept) {
+      this.diseaseDept = dept;
+    },
+    handleDiseaseWardChange(ward) {
+      this.diseaseWard = ward;
+    },
+
+    // ---------- 妯℃澘鐩稿叧 ----------
+    selectfn(row, type) {
+      if (type == 1) {
+        this.libName = row.svyname;
+        this.libId = row.svyid;
+        this.questionList = row.svyTemplateLibScripts;
+        getQtemplateobj({ svyid: row.svyid }).then((res) => {
+          if (res.code == 200) {
+            this.objyl = res.rows[0];
+            if (this.form.longTask) {
+              this.objyl.longTemp = 1;
+            }
+            this.tempDetpRelevanceslist = [];
+            this.tempbelongWards = [];
+            this.objyl.suitway = this.objyl.suitway
+              ? this.objyl.suitway.split(",")
+              : [];
+            this.questionList = res.rows[0].svyTemplateLibScripts;
+            this.questionList.forEach((item) => {
+              item.qremark = [];
+            });
+            this.getillness(row.svyid);
+            this.previewtf = true;
+          }
+        });
+        this.previewid = row.svyid;
+        this.Variablehandling(row.svyTemplateLibScripts, 1);
+      }
+    },
+    previewfnmb() {
+      getTaskQuestioncomit(this.form.templateid).then((res) => {
+        if (res.code == 200) {
+          this.objyl = res.data;
+          if (this.objyl.suitway)
+            this.objyl.suitway = this.objyl.suitway.split(",");
+          this.getillness(this.form.libtemplateid);
+          this.previewtf = true;
+          taskgetQtemplateobj({ id: this.form.templateid }).then((res) => {
+            if (res.code == 200) {
+              this.questionList = res.data.svyTaskTemplateScriptVOS;
+              this.questionList.forEach((item) => {
+                item.qremark = [];
+                item.svyLibTemplateTargetoptions =
+                  item.svyTaskTemplateTargetoptions;
+              });
+              this.previewtftype = 1;
+              this.objyl.svyTemplateLibScripts =
+                res.data.svyTaskTemplateScriptVOS;
+            }
+          });
+        }
+      });
+    },
     Variablehandling(arr, type) {
       let Variablist = [];
       if (type == 1) {
-        // 寰幆闂
         arr.forEach((res) => {
-          // 寰幆閫夐」
-          JSON.parse(res.otherdata).forEach((item) => {
-            if (item.default != 1) {
-              Variablist.push({
-                value: item.variate,
-                fill: "",
-                name: item.variatename,
-              });
-            }
-          });
+          if (res.otherdata) {
+            JSON.parse(res.otherdata).forEach((item) => {
+              if (item.default != 1) {
+                Variablist.push({
+                  value: item.variate,
+                  fill: "",
+                  name: item.variatename,
+                });
+              }
+            });
+          }
         });
         const Aarr = Variablist.filter(
           (obj, index, self) =>
             index ===
             self.findIndex((t) => t.name === obj.name && t.value === obj.value)
         );
-
         this.variableList = this.transitionList.concat(Aarr);
-        // this.form.textParam = this.convertFormat2ToFormat1(this.variableList);
       }
     },
-    // 瀛愪换鍔′簩绾у脊妗�
+    variableDelete(index, row) {
+      this.variableList.splice(index, 1);
+      row.isoperation = 3;
+      this.delvariableList.push(row);
+    },
+
+    // ---------- 绉戝/鐥呭尯/鐤剧梾/鎵嬫湳 鎿嶄綔 ----------
+    listDept() {
+      this.leavehospitaldistrictcodes = [];
+      this.deptcodesWards = [];
+      // this.queryParamsdept.taskId = this.form.taskid;
+      this.queryParamsdept.taskId = this.form.taskid;
+
+      if (this.form.appltype == 5) {
+        rwztaskdepthospgetsonlist(this.queryParamsdept).then((res) => {
+          if (res.code == 200) {
+            let arr = res.rows;
+            arr.forEach((item) => {
+              if (item.deptType == 1) {
+                this.deptlist.push(item);
+                this.deptcodesWards.push(item.deptCode);
+              } else if (item.deptType == 2) {
+                this.hosplist.push(item);
+                this.leavehospitaldistrictcodes.push(item.deptCode);
+              }
+            });
+          }
+        });
+        rwztaskdiaggetlist(this.queryParamsdept).then((res) => {
+          if (res.code == 200) {
+            let arr = res.rows;
+            arr.forEach((item) => {
+              if (localStorage.getItem("orgname") == "鍗楀崕澶у闄勫睘绗竴鍖婚櫌") {
+                item.icdname = item.icd10name;
+                this.diagglist.push(item);
+              } else {
+                this.diagglist.push(item);
+              }
+              this.illnesscodes.push(item.icd10code);
+            });
+          }
+        });
+      } else {
+        taskdepthospgetsonlist(this.queryParamsdept).then((res) => {
+          if (res.code == 200) {
+            let arr = res.rows;
+            arr.forEach((item) => {
+              if (item.deptType == 1) {
+                this.deptlist.push(item);
+                this.deptcodesWards.push(item.deptCode);
+              } else if (item.deptType == 2) {
+                this.hosplist.push(item);
+                this.leavehospitaldistrictcodes.push(item.deptCode);
+              }
+            });
+          }
+        });
+        taskdiaggetlist(this.queryParamsdept).then((res) => {
+          if (res.code == 200) {
+            let arr = res.rows;
+            arr.forEach((item) => {
+              if (localStorage.getItem("orgname") == "鍗楀崕澶у闄勫睘绗竴鍖婚櫌") {
+                item.icdname = item.icd10name;
+                this.diagglist.push(item);
+              } else {
+                getillnesslist({ icdname: item.icd10name }).then((res) => {
+                  item.icdname = res.rows[0].icdname;
+                  this.diagglist.push(item);
+                });
+              }
+              this.illnesscodes.push(item.icd10code);
+            });
+          }
+        });
+      }
+
+      taskopergetlist(this.queryParamsdept).then((res) => {
+        if (res.code == 200) {
+          let arr = res.rows;
+          arr.forEach((item) => {
+            this.operlist.push(item);
+            this.operationcodes.push(item.opcode);
+          });
+        }
+      });
+    },
+    removetag(row) {
+      let result = this.deptlist
+        .filter((item) => item.deptCode == row)
+        .map((item) => item.id);
+      if (result.length) {
+        taskdepthospgetsondel(result).then((res) => {
+          if (res.code) this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+        });
+      }
+    },
+    removehpsp(row) {
+      let result = this.hosplist
+        .filter((item) => item.deptCode == row)
+        .map((item) => item.id);
+      if (result.length) {
+        taskdepthospgetsondel(result).then((res) => {
+          if (res.code) this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+        });
+      }
+    },
+    removeopera(row) {
+      let result = this.operlist
+        .filter((item) => item.opcode == row)
+        .map((item) => item.id);
+      if (result.length) {
+        taskoperhospgetsondel(result).then((res) => {
+          if (res.code) this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+        });
+      }
+    },
+    removediagg(row) {
+      // 浠诲姟缁勶細鏈湴鍒犻櫎鍗冲彲锛屽悗绔繚瀛樻椂缁熶竴鏇存柊
+      if (this.form.appltype == 5) {
+        this.diagglist = this.diagglist.filter((item) => item.icd10code != row);
+        return;
+      }
+      // 鏅�氱柧鐥呭叧鑱旓細璋冨悗绔帴鍙i�愭潯鍒犻櫎
+      let result = this.diagglist
+        .filter((item) => item.icd10code == row)
+        .map((item) => item.id);
+      if (result.length) {
+        taskdiaghospgetsondel(result).then((res) => {
+          if (res.code) {
+            this.diagglist = this.diagglist.filter(
+              (item) => item.icd10code != row
+            );
+            this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+          }
+        });
+      }
+    },
+    remoteopcode(name) {
+      // 鍗犱綅
+    },
+    // 杩滅▼鎼滅储鑽搧
+    remoteSearchMedical(query) {
+      if (!query) {
+        this.medicalOptions = [];
+        return;
+      }
+      listMedication({ itemName: query, pageNum: 1, pageSize: 20 }).then(
+        (res) => {
+          this.medicalOptions = res.rows || [];
+        }
+      );
+    },
+    // 鍒犻櫎宸查�夎嵂鍝�
+    removeMedical(code) {
+      this.medicalCodes = this.medicalCodes.filter((c) => c !== code);
+    },
+
+    // ---------- 鎮h�呴�夋嫨 ----------
     handleAddpatient(row) {
       this.allpids = [];
       this.overallCase.forEach((item) => {
         this.allpids.push(item.patid);
       });
-      if (
-        this.patientqueryParams.allhosp == 1 ||
-        (this.patientqueryParams.allhosp == 1 &&
-          this.patientqueryParams.cry == 1)
-      ) {
+      if (this.patientqueryParams.allhosp == 4) {
         this.tableLabelhz = [
-          // { label: "鍏ラ櫌鏃ユ湡", width: "170", prop: "starttime" },
           { label: "鍑洪櫌鏃ユ湡", width: "150", prop: "endtime" },
           { label: "鎮h��", width: "", prop: "name" },
+          { label: "鎮h�呰瘖鏂�", width: "", prop: "leavediagname" },
           { label: "韬唤璇�", width: "200", prop: "idcardno" },
           { label: "鎬у埆", width: "", prop: "sex" },
           { label: "骞撮緞", width: "", prop: "age" },
+          { label: "鐢佃瘽", width: "180", prop: "telcode" },
           { label: "鍑洪櫌澶╂暟", width: "", prop: "endDay" },
           { label: "璐d换鎶ゅ+", width: "", prop: "nurseName" },
           { label: "鍖荤敓", width: "", prop: "drname" },
           { label: "绉戝", width: "180", prop: "dept" },
           { label: "鐥呭尯", width: "150", prop: "leavehospitaldistrictname" },
         ];
-      } else if (this.patientqueryParams.allhosp == 4) {
+      } else if (this.patientqueryParams.allhosp == 1) {
         this.tableLabelhz = [
           { label: "鍏ラ櫌鏃ユ湡", width: "150", prop: "starttime" },
           { label: "鎮h��", width: "", prop: "name" },
+          { label: "鎮h�呰瘖鏂�", width: "", prop: "leavediagname" },
           { label: "韬唤璇�", width: "200", prop: "idcardno" },
           { label: "鎬у埆", width: "", prop: "sex" },
           { label: "骞撮緞", width: "", prop: "age" },
+          { label: "鐢佃瘽", width: "180", prop: "telcode" },
+          { label: "鍑洪櫌澶╂暟", width: "", prop: "endDay" },
+          { label: "璐d换鎶ゅ+", width: "", prop: "nurseName" },
+          { label: "鍖荤敓", width: "", prop: "drname" },
+          { label: "绉戝", width: "180", prop: "dept" },
+          { label: "鐥呭尯", width: "150", prop: "leavehospitaldistrictname" },
+        ];
+      } else if (this.patientqueryParams.allhosp == 2) {
+        this.tableLabelhz = [
+          { label: "灏辫瘖鏃ユ湡", width: "150", prop: "admitdate" },
+          { label: "鎮h��", width: "", prop: "name" },
+          { label: "韬唤璇�", width: "200", prop: "idcardno" },
+          { label: "鐢佃瘽鍙风爜", width: "180", prop: "telcode" },
+          { label: "鎬у埆", width: "", prop: "sex" },
+          { label: "骞撮緞", width: "", prop: "age" },
+          { label: "鐢佃瘽", width: "180", prop: "telcode" },
           { label: "鍑洪櫌澶╂暟", width: "", prop: "endDay" },
           { label: "璐d换鎶ゅ+", width: "", prop: "nurseName" },
           { label: "鍖荤敓", width: "", prop: "drname" },
@@ -1601,32 +2261,18 @@
       } else {
         this.patientqueryParams.pids = null;
       }
-      // 绫诲瀷鍒ゆ柇
-      if (this.patientqueryParams.allhosp == 1) {
-        this.patientqueryParams.cry = 1;
-      } else if (this.patientqueryParams.allhosp == 4) {
-        this.patientqueryParams.cry = 0;
-        this.patientqueryParams.allhosp = "1";
-      }
-      // 鏉ユ簮鍒ゆ柇
-
-      if (this.patientqueryParams.searchscope == 1) {
-        this.patientqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
-          (obj) => obj.deptCode
-        );
+      if (this.patientqueryParams.allhosp == 4) {
+        this.patientqueryParams.hospitaldistrictcodes = [];
+        this.patientqueryParams.deptcodes = [];
+      } else if (this.patientqueryParams.allhosp == 1) {
+        this.patientqueryParams.deptcodes =
+          this.patientqueryParams.leaveldeptcodes;
+        this.patientqueryParams.hospitaldistrictcodes =
+          this.patientqueryParams.leavehospitaldistrictcodes;
         this.patientqueryParams.leavehospitaldistrictcodes = [];
-      } else if (this.patientqueryParams.searchscope == 2) {
-        this.patientqueryParams.leavehospitaldistrictcodes =
-          store.getters.belongWards.map((obj) => obj.districtCode);
         this.patientqueryParams.leaveldeptcodes = [];
-      } else {
-        this.patientqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
-          (obj) => obj.deptCode
-        );
-        this.patientqueryParams.leavehospitaldistrictcodes =
-          store.getters.belongWards.map((obj) => obj.districtCode);
       }
-      getTaskpatient(this.patientqueryParams).then((response) => {
+      getTaskpatientQC(this.patientqueryParams).then((response) => {
         this.patientuserList = response.rows;
         this.patientuserList.forEach((item) => {
           if (item.endtime) {
@@ -1639,15 +2285,9 @@
       });
       this.dialogVisiblepatient = true;
     },
-    handleUpdate() {},
-    handleDelete() {},
-    handleExport() {},
-    // 閫夋嫨鎮h�呰〃鏁版嵁
     handleSelectionChange(selection) {
       this.SelectPatientslist = structuredClone(selection);
       this.multiple = !selection.length;
-
-      // 璧嬪�肩粰鏁翠綋閫変腑鏁扮粍
       this.SelectPatientslist.forEach((item) => {
         const isExist = this.overallCase.find((obj) => obj.name == item.name);
         if (!isExist) {
@@ -1655,40 +2295,43 @@
           item.patid = item.id;
           item.hospType = this.patientqueryParams.allhosp;
           item.sfzh = item.idcardno;
+          item.telshortcode = item.telshortcode;
           item.deptCode = item.deptcode;
           item.deptName = item.dept;
           item.admindate = item.inhosptime;
+          item.diagname = item.leavediagname;
           item.sfzh = item.idcardno;
+          if (this.patientqueryParams.allhosp == 6) item.patfrom = 1;
+          if (this.patientqueryParams.allhosp == 1)
+            item.visittime = item.endtime;
+          else if (this.patientqueryParams.allhosp == 4)
+            item.visittime = item.starttime;
+          else if (this.patientqueryParams.allhosp == 2)
+            item.visittime = item.admitdate;
           this.overallCase.push(item);
           this.form.patTaskRelevances.push(item);
         }
       });
     },
-    // 鍒囨崲椤靛悗鎭㈠閫変腑
     Restorecheck() {
       const allid = this.overallCase.map((item) => item.patid);
-      const overlap = this.patientuserList.filter((value) => {
-        return allid.includes(value.patid);
-      });
-      // 淇濇寔ids鍜屽綋鍓嶉〉闈㈢殑鍚屾鎬�
+      const overlap = this.patientuserList.filter((value) =>
+        allid.includes(value.patid)
+      );
       this.SelectPatientslist = overlap;
       this.toggleSelection(overlap);
     },
-    // 鎸傝浇閫夋嫨鐘舵��
     toggleSelection(rows) {
       if (rows) {
-        this.decision = true;
         this.$nextTick(() => {
           rows.forEach((row) => {
             this.$refs.multipleTable.toggleRowSelection(row, true);
           });
-          this.decision = false;
         });
       } else {
         this.$refs.multipleTable.clearSelection();
       }
     },
-    // 鍒犻櫎閫変腑鎮h��
     detailhz(row, info) {
       this.$modal
         .confirm('鏄惁纭鍒犻櫎鎮h��"' + row.name + '"鐨勬湇鍔¢」锛�')
@@ -1704,30 +2347,78 @@
           this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
         });
     },
-    getList() {},
     handleQuery() {
-      if (this.patientqueryParams.topica == 0) {
-        this.patientqueryParams.leavehospitaldistrictcodes =
-          store.getters.leavehospitaldistrictcodes;
-        this.patientqueryParams.leaveldeptcodes = store.getters.leaveldeptcodes;
-      } else if (this.patientqueryParams.topica == 1) {
-        this.patientqueryParams.leavehospitaldistrictcodes = null;
-        this.patientqueryParams.leaveldeptcodes = store.getters.leaveldeptcodes;
-      } else if (this.patientqueryParams.topica == 2) {
-        this.patientqueryParams.leavehospitaldistrictcodes =
-          store.getters.leavehospitaldistrictcodes;
-        this.patientqueryParams.leaveldeptcodes = null;
+      if (this.patientqueryParams.allhosp == 6) {
+        this.Externallist();
+        return;
       }
-      console.log(this.patientqueryParams.leavehospitaldistrictcodes);
-      console.log(this.patientqueryParams.leaveldeptcodes);
-
-      if (!this.patientqueryParams.leavehospitaldistrictcodes||!this.patientqueryParams.leavehospitaldistrictcodes[0])
+      if (
+        this.patientqueryParams.searchscope == 1 ||
+        this.patientqueryParams.allhosp == 2
+      ) {
+        this.patientqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
+          (obj) => obj.deptCode
+        );
+        this.patientqueryParams.leavehospitaldistrictcodes = [];
+      } else if (this.patientqueryParams.searchscope == 2) {
+        this.patientqueryParams.leavehospitaldistrictcodes =
+          store.getters.belongWards.map((obj) => obj.districtCode);
+        this.patientqueryParams.leaveldeptcodes = [];
+      } else {
+        this.patientqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
+          (obj) => obj.deptCode
+        );
+        this.patientqueryParams.leavehospitaldistrictcodes =
+          store.getters.belongWards.map((obj) => obj.districtCode);
+      }
+      if (
+        !this.patientqueryParams.leavehospitaldistrictcodes ||
+        !this.patientqueryParams.leavehospitaldistrictcodes[0]
+      )
         this.patientqueryParams.leavehospitaldistrictcodes = null;
-      if (!this.patientqueryParams.leaveldeptcodes||!this.patientqueryParams.leaveldeptcodes[0])
+      if (
+        !this.patientqueryParams.leaveldeptcodes ||
+        !this.patientqueryParams.leaveldeptcodes[0]
+      )
         this.patientqueryParams.leaveldeptcodes = null;
       this.handleAddpatient();
     },
-    resetQuery() {},
+    Externallist() {
+      this.tableLabelhz = [
+        { label: "鎮h��", width: "", prop: "name" },
+        { label: "韬唤璇�", width: "200", prop: "idcardno" },
+        { label: "鎬у埆", width: "", prop: "sex" },
+        { label: "骞撮緞", width: "", prop: "age" },
+        { label: "鐢佃瘽", width: "180", prop: "telcode" },
+        { label: "鍑洪櫌澶╂暟", width: "", prop: "endDay" },
+      ];
+      this.patientqueryParams.pageSize = 1000;
+      Externallist(this.patientqueryParams).then((response) => {
+        this.patientuserList = response.rows;
+        this.patientuserList.forEach((item) => {
+          if (item.endtime) {
+            item.endDay = this.daysBetween(item.endtime);
+          }
+        });
+        this.dialogVisiblepatient = true;
+        this.patienttotal = response.total;
+        this.loading = false;
+      });
+    },
+    resetQuerymb() {
+      this.topqueryParams = { svyname: "" };
+      this.handleQuerymb();
+    },
+    resetQuery() {
+      this.patientqueryParams = {
+        pageNum: 1,
+        pageSize: 10,
+        topica: 1,
+        leavehospitaldistrictcodes: [],
+        leaveldeptcodes: [],
+      };
+      this.handleQuery();
+    },
     handleQuerymb() {
       getQtemplatelist(this.topqueryParams).then((response) => {
         this.userList = response.rows;
@@ -1737,129 +2428,20 @@
     handleClosehz() {
       this.dialogVisiblepatient = false;
     },
-    // 涓婁竴姝�
-    laststep() {
-      this.Editprogress--;
-    },
-    // 鎻愪氦琛ㄥ崟
-    resetForm(formName) {
-      this.$refs[formName].resetFields();
-    },
-    // 棰勮妯℃澘
-    PreviewTemplate() {},
-    Acknowledgereference() {
-      this.quote = true;
-    },
-    // 鑾峰彇璇︽儏
-    Getdetails() {
-      this.form = {
-        patTaskRelevances: [],
-        sendType: 1,
-        templatename: "",
-        templateid: null,
-        libtemplateid: null,
-        kcb: "浜茬埍鐨勬偅鑰�/瀹跺睘锛屾偍濂斤紒鎴戜滑鏄禉涓尰澶т簩闄㈢殑鍖绘姢浜哄憳锛屼负浜嗘洿濂藉湴浜嗚В鎮ㄧ殑搴峰鎯呭喌锛岃鎮ㄦ娊涓�鐐瑰疂璐垫椂闂达紝瀹屾垚杩欎唤闅忚闂嵎銆�",
-        jsy: "璇锋偍娉ㄦ剰浼戞伅鍜岃惀鍏伙紝鐢熸椿涓婅鍔抽�哥粨鍚堬紝閫傚綋閿荤偧锛屾垝鐑熼檺閰掞紝淇濇寔蹇冩儏鑸掔晠锛屽畾鏈熷璇娿�傞偅鏈鍥炶灏卞埌杩欓噷锛岀鎮ㄨ韩浣撳仴搴凤紒",
-      };
-
-      this.questionList = [];
-      if (this.id) {
-        Questionnairetaskgetson({ taskid: this.id }).then((res) => {
-          let filteredArray = "";
-          if (res.code == 200) {
-            this.form = res.data;
-            this.form.serviceType = this.serviceType;
-            this.form.patTaskRelevances = this.form.patTaskRelevances
-              ? this.form.patTaskRelevances
-              : [];
-            this.overallCase = this.form.patTaskRelevances.concat();
-            this.checkList = this.form.preachform.split(",");
-
-            this.overallCase.forEach((item) => {
-              if (item.endtime) {
-                item.endDay = this.daysBetween(item.endtime);
-              }
-            });
-            if (this.form.showDate)
-              this.daytime = this.form.showDate.split(",");
-            if (this.form.showTimeMorn) {
-              if (this.form.sendType == 3) {
-                this.time4 = this.form.showTimeMorn;
-              } else {
-                this.time1 = this.form.showTimeMorn.split(",");
-              }
-            }
-            if (this.form.showTimeNoon)
-              this.time2 = this.form.showTimeNoon.split(",");
-            if (this.form.showTimeNight)
-              this.time3 = this.form.showTimeNight.split(",");
-            filteredArray = this.convertFormat1ToFormat2(this.form.textParam);
-            this.variableList = this.transitionList.concat(filteredArray);
-          } else {
-            this.$modal.msgError(res.code);
-          }
-
-          if (this.newadd) {
-            this.neWaddfn();
-          }
-        });
-      }
-    },
-    // 渚濈収鏂板鏃跺鐞�
-    neWaddfn() {
-      this.id = null;
-      this.form.taskName = "";
-      this.form.taskid = null;
-      this.overallCase = [];
-      this.form.patTaskRelevances = [];
-      this.daytime = []; //鏃ユ湡
-      this.applydaytime = []; //璁$畻鏃ユ湡
-      this.time1 = ""; //涓婂崍鏃堕棿娈�
-      this.time2 = ""; //涓嬪崍鏃堕棿娈�
-      this.time3 = ""; //鏅氫笂鏃堕棿娈�
-      this.time4 = ""; //鏅氫笂鏃堕棿娈�
-    },
-    // 鑾峰彇绉戝鍒楄〃
-    listDept() {
-      this.tempDetpRelevanceslist = [];
-      this.tempbelongWards = [];
-      depthospgetsonlist(this.queryParamsdept).then((res) => {
-        if (res.code == 200) {
-          let arr = res.rows;
-          arr.forEach((item) => {
-            if (item.deptType == 1) {
-              this.deptlist.push(item);
-              this.tempDetpRelevanceslist.push(item.deptCode);
-            } else if (item.deptType == 2) {
-              this.hosplist.push(item);
-              this.tempbelongWards.push(item.deptCode);
-            }
-          });
-        }
-      });
-    },
-    getQtemplateclassify() {
-      getQtemplateclassify({}).then((res) => {
-        this.optionsclass = res.rows;
-      });
-    },
-    // 鏂板娲鹃�佹偅鑰�
     AddDispatchpatients() {
-      // this.SelectPatientslist.forEach((item) => {
-      //   item.isoperation = 1;
-      // });
-      // this.form.patTaskRelevances.push(...this.SelectPatientslist);
-      // this.overallCase.push(...this.SelectPatientslist);
       this.dialogVisiblepatient = false;
     },
+    handleUpdate() {},
+    handleDelete() {},
+    handleExport() {},
 
-    variableDelete(index, row) {
-      this.variableList.splice(index, 1);
-      row.isoperation = 3;
-      this.delvariableList.push(row);
+    // ---------- 鏈嶅姟褰㈠紡鎺掑簭 ----------
+    checkSelectionChange(selectedValues, selectedOrder) {
+      this.selectedOrder = selectedValues;
     },
-    // 鏃堕棿----------
-    changeTime(row) {
+
+    // ---------- 鏃堕棿澶勭悊 ----------
+    changeTime() {
       this.processingTime();
     },
     Totaldate(row) {
@@ -1875,27 +2457,19 @@
     getDates(startDate, endDate) {
       const dates = [];
       let currentDate = new Date(startDate);
-
       while (currentDate <= endDate) {
         dates.push(this.$moment(currentDate).format("YYYY-MM-DD"));
         currentDate.setDate(currentDate.getDate() + 1);
       }
-
       return dates;
     },
-    // 鏃堕棿鏈�缁堝鐞嗘柟娉�
     processingTime() {
       const combinedData = [];
       let serialnumber = 1;
-      if (this.time3[0]) {
-        serialnumber = 3;
-      } else if (this.time2[0]) {
-        serialnumber = 2;
-      } else if (this.time1[0]) {
-        serialnumber = 1;
-      } else {
-        return;
-      }
+      if (this.time3 && this.time3[0]) serialnumber = 3;
+      else if (this.time2 && this.time2[0]) serialnumber = 2;
+      else if (this.time1 && this.time1[0]) serialnumber = 1;
+      else return;
 
       for (let i = 0; i < this.applydaytime.length; i++) {
         combinedData.push({
@@ -1919,63 +2493,60 @@
         }
       }
       this.form.sendTimeslot = combinedData;
-      // 灞曠ず鏁版嵁涓存椂瀛樺偍鏃ユ湡銆佹棭銆佷腑銆佹櫄
-
       this.form.showDate = this.daytime.join(",");
       if (this.time1) this.form.showTimeMorn = this.time1.join(",");
       if (this.time2) this.form.showTimeNoon = this.time2.join(",");
       if (this.time3) this.form.showTimeNight = this.time3.join(",");
     },
-    // 鏌ョ湅妯℃澘
+
+    // ---------- 妯℃澘淇濆瓨涓庢浛鎹� ----------
     previewGo() {
-      this.$router.push({
-        path: "/knowledge/tpuconfigurat/",
-        query: { id: this.previewid, task: true, data: this.form },
+      this.$modal.confirm("鏄惁鍓嶅線淇敼浠诲姟妯℃澘璇︾粏鍐呭锛�").then(() => {
+        this.drawermb = false;
+        this.previewtf = false;
+        this.$router.push({
+          path: "/knowledge/tpuconfigurat/",
+          query: { id: this.previewid, task: true, data: this.form },
+        });
       });
     },
-    // 淇濆瓨/鏇存柊浠诲姟妯℃澘
     previewFn() {
       if (Array.isArray(this.objyl.suitway)) {
         this.objyl.suitway = this.objyl.suitway.join(",");
       }
+      this.objyl.templateid = this.objyl.svyid;
+      this.objyl.isoperation = 1;
+      this.objyl.taskid = this.form.taskid;
       this.objyl.svyTemplateLibScripts.forEach((item) => {
+        item.qremark = [];
         item.svyTaskTemplateTargetoptions = item.svyLibTemplateTargetoptions;
       });
       this.objyl.svyTaskTemplateScriptVOS = this.objyl.svyTemplateLibScripts;
-      this.objyl.templateid = this.objyl.svyid;
-
-      this.objyl.isoperation = 1;
-      console.log(this.objyl.id);
-      if (!this.objyl.sendDay) {
-        this.objyl.sendDay='5';
-      }
-
       if (this.objyl.id) {
         deleteTaskQuestioncomit(this.objyl.id).then((res) => {
           if (res.code == 200) {
-            (this.objyl.id = null),
-              TaskQuestioncomit(this.objyl).then((response) => {
-                this.previewtf = false;
-                this.form.libtemplateid = this.objyl.svyid;
-                this.form.templateid = response.data;
-                this.putbelongDepts(response.data);
-                this.form.templatename = this.objyl.svyname;
-                this.$modal.msgSuccess("閫夋嫨妯℃澘鎴愬姛");
-              });
+            this.objyl.id = null;
+            TaskQuestioncomit(this.objyl).then((response) => {
+              this.previewtf = false;
+              this.form.libtemplateid = this.objyl.svyid;
+              this.form.libtemplatename = this.objyl.svyname;
+              this.form.templateid = response.data;
+              this.form.templatename = this.objyl.svyname;
+              this.$modal.msgSuccess("閫夋嫨妯℃澘鎴愬姛");
+            });
           }
         });
       } else {
         TaskQuestioncomit(this.objyl).then((response) => {
           this.previewtf = false;
           this.form.libtemplateid = this.objyl.svyid;
+          this.form.libtemplatename = this.objyl.svyname;
           this.form.templateid = response.data;
-          this.putbelongDepts(response.data);
           this.form.templatename = this.objyl.svyname;
           this.$modal.msgSuccess("閫夋嫨妯℃澘鎴愬姛");
         });
       }
     },
-    // 淇濆瓨绉戝/鐥呭尯
     putbelongDepts(id) {
       this.tempDetpRelevanceslistform.forEach((item) => {
         item.tempid = id;
@@ -1996,74 +2567,262 @@
         }
       });
     },
-    // 澶勭悊鏈嶅姟褰㈠紡
-    formatFn(type) {
-      let list = [];
-      let formlist = [];
-      if (type == 1) {
-        this.preachform.forEach((item) => {
-          this.checkList.forEach((obj) => {
-            if (item.label == obj) {
-              list.push(item.value);
+    Departmenttreatment() {
+      if (!this.form.taskid) {
+        this.templateor = true;
+        MessageBox.confirm(
+          "褰撳墠涓烘柊澧炰换鍔℃湭淇濆瓨涓嶅彲鍏宠仈妯℃澘锛屾槸鍚﹀厛鏆傚瓨妯℃澘淇濆瓨浠诲姟鍚庣敓鏁堬紵",
+          "鍔熻兘鎻愮ず",
+          {
+            confirmButtonText: "鏆傚瓨妯℃澘",
+            cancelButtonText: "鍙栨秷",
+            type: "warning",
+          }
+        )
+          .then(() => {
+            if (Array.isArray(this.objyl.suitway)) {
+              this.objyl.suitway = this.objyl.suitway.join(",");
             }
+            this.objyl.templateid = this.objyl.svyid;
+            this.form.libtemplateid = this.objyl.svyid;
+            this.objyl.isoperation = 1;
+            this.objyl.svyTaskTemplateScriptVOS =
+              this.objyl.svyTemplateLibScripts;
+            this.objyl.svyTaskTemplateScriptVOS.forEach((item) => {
+              item.svyTaskTemplateTargetoptions =
+                item.svyLibTemplateTargetoptions;
+            });
+            this.form.svyTaskTemplateVO = this.objyl;
+            this.form.templatename = this.objyl.svyname;
+            this.$modal.msgSuccess("鏆傚瓨鎴愬姛淇濆瓨浠诲姟鍚庢ā鏉跨敓鏁�");
+            this.drawermb = false;
+            this.previewtf = false;
+          })
+          .catch(() => {
+            this.drawermb = false;
+            this.previewtf = false;
           });
-        });
-        console.log(list, "list");
-        this.form.preachform = list.join(",");
       } else {
-        console.log(this.form.preachform, "this.form.preachform");
-        formlist = this.form.preachform.split(",");
-        console.log(11);
-        this.preachform.forEach((item) => {
-          formlist.forEach((obj) => {
-            if (item.value == obj) {
-              list.push(item.label);
-            }
-          });
-        });
-        this.checkList = list;
+        setTimeout(() => {
+          this.previewFn();
+        }, 1000);
       }
     },
-    // 绉戝澶勭悊
-    Departmenttreatment() {
-      this.tempDetpRelevanceslist.forEach((item) => {
-        this.tempDetpRelevanceslistform.push({
-          deptType: 1,
-          longTemp: this.form.longTask,
-          deptCode: item,
-          tempid: null,
-          type: 11,
-        });
-      });
 
-      this.tempbelongWards.forEach((item) => {
-        this.tempbelongWardsform.push({
-          deptType: 2,
-          longTemp: this.form.longTask,
-          deptCode: item,
-          tempid: null,
-          type: 11,
-        });
-      });
-      console.log(33);
+    // ---------- 鎻愪氦琛ㄥ崟 ----------
+    submitForm(formName) {
+      if (this.submitLoading) return;
+      this.submitLoading = true;
 
-      setTimeout(() => {
-        this.previewFn();
-      }, 1000);
+      try {
+        if (this.time4 && this.form.sendType == 3) {
+          this.form.showTimeMorn = this.time4;
+        }
+        this.form.sendTimeslot = [
+          {
+            begantime: this.time4,
+            endtime: "",
+            xh: 1,
+          },
+        ];
+
+        if (this.form.appltype == 1) {
+          this.leavehospitaldistrictcodes = [];
+          this.form.oplevelcode = null;
+          this.illnesscodes = [];
+        } else if (this.form.appltype == 2) {
+          this.deptcodesWards = [];
+          this.form.oplevelcode = null;
+          this.illnesscodes = [];
+        } else if (this.form.appltype == 3) {
+          this.deptcodesWards = [];
+          this.leavehospitaldistrictcodes = [];
+          this.form.oplevelcode = null;
+        } else if (this.form.appltype == 4) {
+          this.deptcodesWards = [];
+          this.illnesscodes = [];
+          this.leavehospitaldistrictcodes = [];
+        } else if (this.form.appltype == 6) {
+          this.deptcodesWards = [];
+          this.leavehospitaldistrictcodes = [];
+          this.illnesscodes = [];
+          this.form.oplevelcode = null;
+        }
+
+        // 鏈嶅姟褰㈠紡鏍¢獙
+        if (this.checkList) {
+          this.form.preachform = this.checkList.join(",");
+          this.form.preachformList = this.selectedOrder;
+        } else {
+          this.$modal.msgError("璇烽�夋嫨鏈嶅姟绫诲瀷");
+          this.submitLoading = false;
+          return;
+        }
+
+        // 浠诲姟鍏宠仈鏉′欢鏍¢獙锛堜换鍔$粍璺宠繃寮哄埗鍏宠仈锛�
+        const hasCondition =
+          this.deptcodesWards[0] ||
+          this.leavehospitaldistrictcodes[0] ||
+          this.diagglist[0] ||
+          this.form.oplevelcode ||
+          this.medicalCodes[0] ||
+          this.form.longTask == 2 ||
+          this.serviceType == 3 ||
+          this.form.appltype == 5;
+
+        if (!hasCondition) {
+          this.$modal.msgError("璇烽�夋嫨浠诲姟鍏宠仈鏉′欢");
+          this.submitLoading = false;
+          return;
+        }
+
+        if (!this.form.templatename && !this.templateor) {
+          this.$modal.msgError("鏈�夋嫨妯℃澘");
+          this.submitLoading = false;
+          return;
+        }
+
+        const isValidTime =
+          (this.form.sendType == 1 && this.time1) ||
+          this.form.sendType == 2 ||
+          (this.form.sendType == 3 && this.time4) ||
+          this.form.longTask;
+        if (!isValidTime) {
+          this.submitLoading = false;
+          this.$modal.msgError("鏃堕棿淇℃伅缂哄け");
+          return;
+        }
+
+        // 澶勭悊鍙橀噺
+        const filteredArray = this.variableList.filter(
+          (item) =>
+            item.name !== "濮撳悕" && item.name !== "鐢佃瘽" && item.name !== "鍦板潃"
+        );
+        this.form.textParam = this.convertFormat2ToFormat1(filteredArray);
+
+        // 澶勭悊浠诲姟缁勬槑缁嗙殑 content
+        if (this.form.appltype == 5 && this.form.serviceTaskScheduleVO) {
+          this.form.serviceTaskScheduleVO.detailList.forEach((item) => {
+            const contentObj = {
+              kcb: item.kcb || "",
+              jsy: item.jsy || "",
+              text_param: item.textParam || {},
+            };
+            item.content = JSON.stringify(contentObj);
+            delete item.kcb;
+            delete item.jsy;
+            delete item.textParam;
+          });
+          // 灏嗕富瀵硅薄鏀惧叆 form 鎻愪氦锛堝凡瀛樺湪锛�
+        }
+
+        if (this.form.taskid) {
+          this.form.isoperation = 2;
+        } else {
+          this.form.isoperation = 1;
+        }
+        if (!this.form.type) {
+          this.form.type = this.$route.query.type;
+        }
+        console.log(this.diseaseDept, this.diseaseWard);
+
+        if (this.form.appltype == 1 || this.form.appltype == 2) {
+          this.form.deptcode = this.deptcodesWards.join(",");
+          this.form.leavehospitaldistrictcode =
+            this.leavehospitaldistrictcodes.join(",");
+        } else {
+          if (this.diseaseDept) {
+            this.form.deptcode = this.diseaseDept.deptCode;
+            this.form.deptname = this.diseaseDept.deptName;
+          }
+          if (this.diseaseWard) {
+            this.form.leavehospitaldistrictcode = this.diseaseWard.districtCode;
+            this.form.leavehospitaldistrictname = this.diseaseWard.districtName;
+          }
+        }
+
+        // 鑽搧鍏宠仈锛氱粍瑁呴�楀彿鍒嗛殧鐨勭紪鐮�/鍚嶇О/鍘傚
+        if (this.form.appltype == 6) {
+          const selectedMeds = this.medicalOptions.filter((m) =>
+            this.medicalCodes.includes(m.itemCode)
+          );
+          this.form.medicalCode = this.medicalCodes.join(",");
+          this.form.medicalName = selectedMeds.map((m) => m.itemName).join(",");
+          this.form.medicalCompany = selectedMeds
+            .map((m) => m.manufacturerName)
+            .join(",");
+        }
+
+        this.form.serviceType = this.serviceType;
+
+        this.form.icd10code = this.diagglist
+          .map((item) => item.icdcode)
+          .join(",");
+        this.form.icd10name = this.diagglist
+          .map((item) => item.icdname)
+          .join(",");
+        // 鐤剧梾/鎵嬫湳鍏宠仈鐨勭瀹�/鐥呭尯鏍¢獙
+        if (this.form.appltype == 3 || this.form.appltype == 4) {
+          const hasDept = this.diseaseDept?.deptCode;
+          const hasWard = this.diseaseWard?.districtCode;
+          if (!hasDept && !hasWard) {
+            this.$modal.msgError("闇�鍏宠仈绉戝鎴栫梾鍖�");
+            this.submitLoading = false;
+            return;
+          }
+
+          this.form.deptcode = hasDept;
+          this.form.leavehospitaldistrictcode = hasWard;
+        }
+        // 浠诲姟缁勭殑鏁版嵁澶勭悊
+        if (this.form.appltype == 5) {
+          this.form.serviceTaskScheduleVO.icd10codes = this.form.icd10code;
+          this.form.serviceTaskScheduleVO.wardCodes =
+            this.form.leavehospitaldistrictcode;
+          this.form.serviceTaskScheduleVO.deptCodes = this.form.deptcode;
+        }
+        Editsingletask(this.form)
+          .then((res) => {
+            if (res.code == 200) {
+              if (this.form.taskid) {
+                this.$modal.msgSuccess("淇敼鎴愬姛");
+              } else {
+                this.$modal.msgSuccess("鏂板鎴愬姛");
+              }
+              this.$router.push({
+                path: "/followvisit/tasklist",
+                query: { tasktopic: this.form.serviceType },
+              });
+            } else {
+              this.$modal.msgError(res.msg || "鎿嶄綔澶辫触");
+            }
+          })
+          .catch((error) => {
+            console.error("鎻愪氦澶辫触:", error);
+            this.$modal.msgError(error.message || "缃戠粶寮傚父锛岃绋嶅悗閲嶈瘯");
+          })
+          .finally(() => {
+            this.submitLoading = false;
+          });
+      } catch (error) {
+        console.error("琛ㄥ崟鎻愪氦寮傚父:", error);
+        this.$modal.msgError(error.message || "琛ㄥ崟鎻愪氦寮傚父");
+        this.submitLoading = false;
+      }
     },
   },
 };
 </script>
-
 <style lang="scss" scoped>
 .Questionnairemanagement {
 }
+
 .leftvlue-jbxx {
   margin-top: 10px;
 }
+
 .sidecolumn {
   width: 100%;
-  // min-height: 12vh;
   margin: 20px;
   margin-bottom: 0;
   padding: 30px;
@@ -2072,20 +2831,20 @@
   -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
     0 0 6px 0 rgba(0, 0, 0, 0.04);
 }
+
 .leftvlue {
-  //   display: flex;
-  //   flex: 1;
   width: 100%;
   margin-top: 20px;
-  //   margin: 20px;
   padding: 30px;
   background: #ffff;
   border: 1px solid #dcdfe6;
   -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
     0 0 6px 0 rgba(0, 0, 0, 0.04);
 }
+
 .examine-jic {
   margin: 20px;
+
   .headline {
     font-size: 24px;
     height: 40px;
@@ -2093,32 +2852,37 @@
     padding-left: 5px;
     margin-bottom: 10px;
     display: flex;
-    // justify-content: space-between;
+
     .Add-details {
       font-size: 18px;
       color: #02a7f0;
       cursor: pointer;
     }
   }
+
   .jic-value {
     font-size: 20px;
     border-top: 1px solid #a7abac;
     padding: 10px;
     margin-bottom: 10px;
+
     .details-jic {
       padding: 10px 15px;
       border: 1px solid #dcdfe6;
       -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
         0 0 6px 0 rgba(0, 0, 0, 0.04);
+
       .details-title {
         display: flex;
         justify-content: space-between;
         margin-bottom: 10px;
+
         div:nth-child(2) {
           color: #02a7f0;
           cursor: pointer;
         }
       }
+
       .details-renw {
         background: #e4ebfc;
         padding: 15px 5px;
@@ -2128,6 +2892,7 @@
     }
   }
 }
+
 .xinz-infs {
   font-size: 18px;
   line-height: 48px;
@@ -2136,58 +2901,45 @@
     margin-left: 10px;
   }
 }
-// .leftvlue-jbxx {
-//   margin-bottom: 50px;
-//   font-size: 20px;
-//   span {
-//     position: absolute;
-//     right: 80px;
-//   }
-//   .demo-cascader {
-//     margin-right: 20px;
-//   }
-//   .PreviewTemplate {
-//     color: #02a7f0;
-//     cursor: pointer;
-//     font-size: 20px;
-//     margin: 0 20px;
-//   }
-// }
+
 .preview-left {
   margin: 20px;
-  //   margin: 20px;
   padding: 30px;
   background: #ffff;
-  // border: 1px solid #dcdfe6;
-  // -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
-  //   0 0 6px 0 rgba(0, 0, 0, 0.04);
+
   .scriptTopic-dev {
     margin-bottom: 25px;
     font-size: 20px !important;
+
     .dev-text {
       margin-bottom: 10px;
     }
   }
 }
+
 .jic-value {
   font-size: 20px;
   border-top: 1px solid #a7abac;
   padding: 10px;
   margin-bottom: 10px;
+
   .details-jic {
     padding: 10px 15px;
     border: 1px solid #dcdfe6;
     -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
       0 0 6px 0 rgba(0, 0, 0, 0.04);
+
     .details-title {
       display: flex;
       justify-content: space-between;
       margin-bottom: 10px;
+
       div:nth-child(2) {
         color: #02a7f0;
         cursor: pointer;
       }
     }
+
     .details-renw {
       background: #e4ebfc;
       padding: 15px 5px;
@@ -2196,6 +2948,7 @@
     }
   }
 }
+
 ::v-deep .addtopic-input {
   input {
     background: #02a7f0;
@@ -2203,42 +2956,44 @@
     width: 150px;
   }
 }
+
 ::v-deep.el-step.is-vertical .el-step__title {
   font-size: 25px;
 }
+
 ::v-deep.el-row {
   margin-bottom: 10px;
 }
-// ::v-deep.el-input--medium {
-//   font-size: 24px !important;
-// }
+
 ::v-deep.ruleFormaa.el-select {
   display: inline-block;
   position: relative;
   width: 700px;
 }
+
 .el-select__tags {
   font-size: 20px;
   max-width: 888px !important;
 }
+
 ::v-deep.el-radio__inner {
   width: 22px;
   height: 22px;
 }
-// ::v-deep.topic-dev.el-radio__label {
-//   font-size: 24px;
-// }
+
 ::v-deep.el-radio-group {
   span {
     font-size: 18px;
   }
 }
+
 ::v-deep.el-input.is-disabled .el-input__inner {
   background-color: #f5f7fa;
   border-color: #dfe4ed;
   color: rgb(253, 66, 66);
   cursor: not-allowed;
 }
+
 ::v-deep.el-checkbox-group {
   span {
     font-size: 18px;

--
Gitblit v1.9.3