WXL (wul)
6 天以前 a5cba9ab040f6f97558046885dce3017f9bab7e9
src/views/patient/propaganda/particty.vue
@@ -69,20 +69,7 @@
                    placeholder="请输入任务描述"
                  />
                </el-form-item>
                <!-- <el-form-item label="服务形式">
                  <el-radio-group
                    v-model="checkList"
                    @change="handleCheckedCitiesChange"
                  >
                    <el-radio
                      v-for="(item, index) in checkboxlist"
                      :key="index"
                      :label="item.value"
                    >
                      {{ item.label }}</el-radio
                    >
                  </el-radio-group>
                </el-form-item> -->
                <el-form-item label="服务形式">
                  <SortCheckbox
                    v-model="checkList"
@@ -93,20 +80,7 @@
                    @change="checkSelectionChange"
                  />
                </el-form-item>
                <!-- <div class="xinz-infs">
                  <el-form-item label="服务执行顺序" prop="daytime">
                    <el-tag
                      :key="tag.label"
                      type="success"
                      v-for="(tag, index) in foncheckList"
                      closable
                      :disable-transitions="false"
                      @close="handleClosetag(tag)"
                    >
                      ({{ index + 1 }}){{ tag.label }}
                    </el-tag>
                  </el-form-item>
                </div> -->
                <el-form-item label="执行周期" prop="longTask">
                  <el-radio-group v-model="form.longTask">
                    <el-radio :label="0">自定义周期</el-radio>
@@ -223,14 +197,47 @@
                    </div>
                  </div>
                </el-form-item>
                <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="5">任务组</el-radio>
                    <el-radio label="6">药品关联</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">
@@ -254,6 +261,8 @@
                      </el-select> </el-form-item
                  ></el-col>
                </el-row>
                <!-- 病区关联 -->
                <el-row v-if="form.appltype == 2">
                  <el-col :span="20"
                    ><el-form-item label="适用病区" prop="region">
@@ -277,6 +286,8 @@
                      </el-select> </el-form-item
                  ></el-col>
                </el-row>
                <!-- 疾病关联 -->
                <el-row v-if="form.appltype == 3">
                  <div class="xinz-infs">
                    <el-form-item>
@@ -307,35 +318,455 @@
                      >
                        {{ tag.icdname }}
                      </el-tag>
                      <!-- <el-tag v-if="hasMore" type="info">+{{ remaining }} more</el-tag> -->
                    </el-form-item>
                  </div>
                </el-row>
                <el-row v-if="form.appltype == 4">
                  <el-col :span="20"
                    ><el-form-item label="适用手术" prop="region">
                      <el-select
                        v-model="operationcodes"
                        style="width: 400px"
                        @remove-tag="removeopera"
                        :remote-method="remoteopcode"
                        size="medium"
                        multiple
                        filterable
                        remote
                        placeholder="请选择手术"
                      >
                        <el-option
                          class="ruleFormaa"
                          v-for="item in baseoperaList"
                          :key="item.icdcode"
                          :label="item.icdname"
                          :value="item.icdcode"
                  <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>
                      </el-select> </el-form-item
                  ></el-col>
                          <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.id"
                                :label="item.templateName"
                                :value="item.id"
                              >
                                <span style="float: left">{{
                                  item.templateName
                                }}</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">
@@ -372,17 +803,12 @@
                      placeholder="请点击右侧选择"
                    />
                    <el-button
                      v-if="
                        (form.templateid && form.sendState == 1) ||
                        !form.templateid
                      "
                      style="margin-left: 10px"
                      type="primary"
                      icon="el-icon-edit"
                      @click="drawermb = true"
                      circle
                    ></el-button>
                    <el-button
                      v-if="form.templateid"
                      type="success"
@@ -398,17 +824,18 @@
            <div class="examine-jic">
              <div class="jic-value">
                <div style="margin-bottom: 10px">模板中使用的变量:</div>
                <el-row :gutter="20">
                  <el-table :data="variableList" style="width: 100%">
                    <el-table-column
                      prop="name"
                      align="center"
                      label="变量名称"
                    >
                    </el-table-column>
                    <el-table-column prop="value" align="center" label="匹配符">
                    </el-table-column>
                    ></el-table-column>
                    <el-table-column
                      prop="value"
                      align="center"
                      label="匹配符"
                    ></el-table-column>
                    <el-table-column label="替换值" align="center">
                      <template slot-scope="scope">
                        <el-input
@@ -420,11 +847,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"
@@ -442,7 +864,6 @@
        <el-button type="success" @click="nextstep('ruleForm')">{{
          quote ? "立即创建" : "任务详情配置"
        }}</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </div>
      <!-- 任务详情 -->
      <div v-if="Editprogress == 2">
@@ -471,7 +892,6 @@
                        </el-option>
                      </el-select>
                    </el-col>
                    <el-col :span="1.5">
                      <el-button
                        type="primary"
@@ -483,22 +903,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>
                  <!-- 选中患者列表 -->
                  <SFtable
                    @details="detailhz"
                    @handleUpdate="handleUpdate"
@@ -523,10 +928,12 @@
          </div>
        </div>
        <el-button type="primary" @click="laststep()">上一步</el-button>
        <el-button type="success" @click="submitForm('11')">{{
          quote ? "立即创建" : "确认任务配置"
        }}</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
        <el-button
          :loading="submitLoading"
          type="success"
          @click="submitForm('11')"
          >{{ quote ? "立即创建" : "确认任务配置" }}</el-button
        >
      </div>
    </div>
    <!-- 添加患者 -->
@@ -540,7 +947,6 @@
      <div class="examine-jic">
        <div class="jic-value">
          <el-row :gutter="20">
            <!--用户数据-->
            <el-form
              :model="patientqueryParams"
              ref="queryForm"
@@ -573,7 +979,6 @@
                >
                </el-option>
              </el-select>
              <el-form-item>
                <el-button
                  type="primary"
@@ -590,7 +995,6 @@
                >
              </el-form-item>
            </el-form>
            <!-- 选择患者列表 -->
            <SFtable
              ref="multipleTable"
              @handleUpdate="handleUpdate"
@@ -621,8 +1025,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">
@@ -676,7 +1080,6 @@
                  <el-input v-model="objyl.templateName"></el-input>
                </div>
              </el-form-item>
              <div class="xinz-infs">
                <el-form-item>
                  <template #label>
@@ -690,7 +1093,6 @@
                      <i class="el-icon-warning-outline"></i>
                    </el-tooltip>
                  </template>
                  <el-tag
                    v-for="tag in illnesslist"
                    :key="tag.icdid"
@@ -699,7 +1101,6 @@
                  >
                    {{ 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">
@@ -711,7 +1112,6 @@
                >
                </el-input
              ></el-form-item>
              <el-form-item label="随访结束语" prop="conclusion">
                <el-input
                  type="textarea"
@@ -721,10 +1121,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
@@ -733,7 +1134,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">
@@ -755,7 +1156,7 @@
                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">
@@ -778,7 +1179,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
@@ -789,12 +1190,11 @@
                  </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
          v-if="(form.templateid && form.sendState == 1) || !form.templateid"
          type="primary"
@@ -810,6 +1210,7 @@
        >
      </span>
    </el-dialog>
    <!-- 模板列表抽屉 -->
    <el-drawer
      title="随访内容列表"
      :visible.sync="drawermb"
@@ -820,8 +1221,6 @@
      <div class="examine-jic">
        <div class="jic-value">
          <el-row :gutter="20">
            <!--用户数据-->
            <el-form
              :model="topqueryParams"
              ref="queryForm"
@@ -833,17 +1232,6 @@
              <el-form-item label="随访名称">
                <el-input v-model="topqueryParams.templateName"></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"
@@ -855,13 +1243,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"
@@ -891,7 +1278,6 @@
    />
  </div>
</template>
<script>
import { messagelistpatient } from "@/api/patient/homepage";
import store from "@/store";
@@ -901,6 +1287,7 @@
  getbaseopera,
  getFollowuplist,
  getvFollowup,
  selectInfoByCondition,
  Taskparticty,
  deleteTaskparticty,
  getTaskInfo,
@@ -915,54 +1302,61 @@
  taskdiaghospgetsondel,
  taskdiaggetlist,
  taskopergetlist,
  rwztaskdepthospgetsonlist,
  rwztaskdiaggetlist,
  getQtemplatelist,
} from "@/api/AiCentre/index";
import { listMedication } from "@/api/knowledge/drug";
import { deptTreeSelect } from "@/api/system/user";
import OptionalForm from "@/components/OptionalForm";
import SortCheckbox from "@/components/SortCheckbox"; //表格组件
import SortCheckbox from "@/components/SortCheckbox";
import { MessageBox } from "element-ui";
import SFtable from "@/components/SFtable"; //表格组件
import SFtable from "@/components/SFtable";
export default {
  name: "particty",
  data() {
    return {
      title: "宣教内容列表",
      currenttype: 1, //1宣教2门诊3出院4复诊5体检6随访
      id: "", //
      previewid: "", //任务模板传递id
      currenttype: 1,
      id: "",
      previewid: "",
      libName: "",
      username: "",
      templateor: false,
      submitLoading: false,
      objyl: {},
      overallCase: [], //选择患者总
      overallCase: [],
      allpids: [],
      appraiselist: [],
      optionsclass: [],
      illnesslist: [],
      mode: [],
      libId: null, //模板库模板id
      Editprogress: 1, //编辑进度
      drawermb: false, //选择模板弹窗
      previewtf: false, //预览
      previewtftype: 0, //预览情况0新模板预览1已选择模板修改
      loading: false, // 遮罩层
      patientloading: false, // 遮罩层
      dialogVisiblepatient: false, //添加患者弹框
      libId: null,
      Editprogress: 1,
      drawermb: false,
      previewtf: false,
      previewtftype: 0,
      dialogVisiblepatient: false,
      dialogVisiblepatientjb: false,
      deptcodesWards: [], //科室数据
      leavehospitaldistrictcodes: [], //病区数据
      operationcodes: [], //手术数据
      illnesscodes: [], //疾病数据
      deptcodesWards: [],
      leavehospitaldistrictcodes: [],
      operationcodes: [],
      illnesscodes: [],
      radio: 1,
      checkboxlist: [],
      tableLabel: [],
      questionList: [],
      skip: false,
      donorchargeList: [],
      baseoperaList: [],
      baseoperaList: [
        { value: "1", label: "一级手术" },
        { value: "2", label: "二级手术" },
        { value: "3", label: "三级手术" },
        { value: "4", label: "四级手术" },
      ],
      selectedOrder: [],
      diseaseDept: null,
      diseaseWard: null,
      usable: [
        { value: "0", label: "可用" },
        { value: "1", label: "停用" },
@@ -973,7 +1367,6 @@
      ],
      props: { multiple: true, value: "deptCode", label: "deptName" },
      propstask: { value: "deptCode", label: "deptName" },
      // 患者表单
      tableLabelhz: [
        { label: "出院日期", width: "150", prop: "inhosptime" },
        { label: "患者", width: "", prop: "name" },
@@ -981,12 +1374,12 @@
        { label: "电话号码", width: "180", prop: "telcode" },
        { label: "性别", width: "", prop: "sex" },
        { label: "年龄", width: "", prop: "age" },
        { label: "电话", width: "180", prop: "telcode" },
        { label: "责任护士", width: "", prop: "nurseName" },
        { label: "主治医生", width: "", prop: "drname" },
        { label: "科室", width: "240", prop: "dept" },
        { label: "病区", width: "240", prop: "leavehospitaldistrictname" },
      ],
      // 患者表单
      tableLabelhzwb: [
        { label: "出院日期", width: "150", prop: "endtime" },
        { label: "患者", width: "", prop: "name" },
@@ -1000,14 +1393,12 @@
        { label: "科室", width: "180", prop: "deptName" },
        { label: "病区", width: "150", prop: "leavehospitaldistrictname" },
      ],
      tableLabelwj: [
        { label: "创建人", width: "", prop: "createBy" },
        { label: "模板标题", width: "", prop: "templateName" },
        { label: "随访描述", width: "", prop: "note" },
        { label: "修改日期", width: "", prop: "updateTime" },
      ],
      // 变量
      tableLabelvariable: [
        { label: "变量名称", width: "", prop: "variablename" },
        { label: "匹配符", width: "", prop: "character" },
@@ -1026,15 +1417,14 @@
        { label: "线下(纸质)", value: 10 },
        { label: "线上(短信/钉钉的文本、随访链接)", value: 11 },
      ],
      // 时间处理
      daytime: [], //日期
      applydaytime: [], //计算日期
      time1: "", //上午时间段
      time2: "", //下午时间段
      time3: "", //晚上时间段
      time4: "", //晚上时间段
      daytime: [],
      applydaytime: [],
      time1: "",
      time2: "",
      time3: "",
      time4: "",
      topqueryParams: {
        pageNum: 1, //
        pageNum: 1,
        pageSize: 10,
      },
      checkList: [],
@@ -1045,33 +1435,29 @@
        format3: "",
      },
      deliverytopqueryParams: {
        pageNum: 1, //
        pageNum: 1,
        pageSize: 10,
      },
      patientqueryParams: {
        pageNum: 1, //
        pageNum: 1,
        pageSize: 10,
        topica: 1, //0全部1科室2病区
        topica: 1,
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
      },
      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: [], //选择患者列表
      sonuserList: [], //选中患者列表
      delvariableList: [], //删除变量临时存储
      userList: [],
      multiplechoice: [],
      patientuserList: [],
      sonuserList: [],
      delvariableList: [],
      longtype: [
        { value: 0, label: "自定义周期" },
        { value: 1, label: "长期任务" },
@@ -1095,7 +1481,7 @@
          fill: "派发时自动匹配",
          default: true,
        },
      ], //变量列表
      ],
      transitionList: [
        {
          name: "姓名",
@@ -1117,7 +1503,7 @@
        },
      ],
      variableListTime: [],
      tasktopic: null, //新增类型
      tasktopic: null,
      SelectPatientslist: [],
      form: {
        patTaskRelevances: [],
@@ -1131,55 +1517,45 @@
          localStorage.getItem("orgname") +
          "的医护人员,为了更好地了解您的康复情况,请您抽一点宝贵时间,进行本次回访服务。",
        jsy: "请您注意休息和营养,生活上要劳逸结合,适当锻炼,戒烟限酒,保持心情舒畅,定期复诊。那本次回访内容就到这里,祝您身体健康!",
        // 任务组主对象
        serviceTaskScheduleVO: {
          scheduleStyle: 0,
          scheduleTimeNum: null,
          scheduleTimeUnit: null,
          maxLoopCount: 0,
          currentLoopCount: 0,
          currentSeq: 0,
          nextSeq: 0,
          nextExecuteTime: "",
          scheduleBenchmark: 0,
          scheduleBenchmarkCustomTime: "",
          detailList: [],
        },
      },
      taskoptions: [
        {
          value: "4",
          label: "出院病人",
        },
        {
          value: "1",
          label: "在院病人",
        },
        {
          value: "2",
          label: "门诊病人",
        },
        {
          value: "3",
          label: "体检病人",
        },
        {
          value: "5",
          label: "手术病人",
        },
        { value: "4", label: "出院病人" },
        { value: "1", label: "在院病人" },
        { value: "2", label: "门诊病人" },
        { value: "3", label: "体检病人" },
        { value: "5", label: "手术病人" },
      ],
      source: [
        {
          value: 0,
          label: "所属患者",
        },
        {
          value: 1,
          label: "科室患者",
        },
        {
          value: 2,
          label: "病区患者",
        },
        { value: 0, label: "所属患者" },
        { value: 1, label: "科室患者" },
        { value: 2, label: "病区患者" },
      ],
      tasktypes: store.getters.tasktypes,
      // 科室/病区
      belongWards: [],
      deptlist: [],
      hosplist: [],
      diagglist: [],
      operlist: [],
      tempDetpRelevanceslist: [], //科室数据
      tempDetpRelevanceslistform: [], //科室数据
      tempbelongWards: [], //病区数据
      tempbelongWardsform: [], //病区数据
      medicalCodes: [],
      medicalOptions: [],
      tempDetpRelevanceslist: [],
      tempDetpRelevanceslistform: [],
      tempbelongWards: [],
      tempbelongWardsform: [],
      rules: {
        taskName: [
          { required: true, message: "任务名称不能为空", trigger: "blur" },
@@ -1193,14 +1569,10 @@
        sendType: [
          { required: true, message: "发送设置不能为空", trigger: "blur" },
        ],
        // deptcode: [
        //   { required: true, message: "适用科室不能为空", trigger: "blur" },
        // ],
        // leavehospitaldistrictcode: [
        //   { required: true, message: "适用病区不能为空", trigger: "blur" },
        // ],
        longTask: [
          { required: true, message: "请选择执行周期", trigger: "blur" },
        ],
      },
      // 科室院区查询入参
      queryParamsdept: {
        tempid: "",
        type: 2,
@@ -1208,10 +1580,12 @@
      belongDepts: [],
      quote: false,
      serviceType: null,
      // 模板搜索
      templateOptions: [],
      templateLoading: false,
    };
  },
  components: { SFtable, OptionalForm, SortCheckbox },
  created() {
    this.appraiselist = store.getters.appraiselist;
    this.belongWards = store.getters.belongWards;
@@ -1224,15 +1598,12 @@
    this.form.typename = this.$route.query.typename;
    this.serviceType = Number(this.$route.query.serviceType);
    this.form.serviceType = Number(this.$route.query.serviceType);
    console.log(localStorage.getItem("orgid"), "orgid");
    this.Acquisitiontype();
    this.getillnesslist();
    this.Getdetails();
    this.getFollowupclassify();
  },
  activated() {
    console.log(this.id, "CS", this.$route.query.id);
    if (this.id != this.$route.query.id) {
      this.id = this.$route.query.id;
      this.newadd = this.$route.query.newadd;
@@ -1240,15 +1611,13 @@
      this.form.typename = this.$route.query.typename;
      this.serviceType = Number(this.$route.query.serviceType);
      this.form.serviceType = Number(this.$route.query.serviceType);
      this.Acquisitiontype();
      this.Getdetails();
      this.getFollowupclassify();
    }
  },
  methods: {
    // 变量转换对象转数组
    // ---------- 工具方法 ----------
    convertFormat1ToFormat2(data) {
      let result = [];
      for (let key in data) {
@@ -1261,7 +1630,6 @@
      }
      return result;
    },
    // 数组转对象
    convertFormat2ToFormat1(data) {
      let result = {};
      data.forEach((item) => {
@@ -1271,27 +1639,28 @@
      });
      return result;
    },
    flattenArray(multiArray) {
      let result = [];
      // 递归函数,用于将多级数组转换为一维数组,只包含最底层的元素
      function flatten(element) {
        // 如果当前元素有子元素,继续递归
        if (element.children && element.children.length > 0) {
          element.children.forEach((child) => flatten(child));
        } else {
          // 克隆元素以避免修改原始数据
          let item = JSON.parse(JSON.stringify(element));
          result.push(item); // 将最底层的元素添加到结果数组
          result.push(item);
        }
      }
      // 从顶层元素开始递归
      multiArray.forEach((element) => flatten(element));
      return result; // 返回只包含最底层元素的一维数组
      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,
@@ -1300,49 +1669,25 @@
      };
      this.currenttype = this.$route.query.type;
      this.title = "随访内容列表";
      this.tableLabel = this.tableLabelwj;
      this.tableLabel = this.tableLabelwj || [];
      if (this.form.serviceType == 1) {
        this.checkboxlist = [
          {
            value: "1",
            label: "人工",
          },
          {
            value: "2",
            label: "纸质",
          },
          {
            value: "4",
            label: "短信",
          },
          {
            value: "5",
            label: "微信公众号",
          },
          { value: "1", label: "人工" },
          { value: "2", label: "纸质" },
          { value: "4", label: "短信" },
          { value: "5", label: "微信公众号" },
        ];
      } 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 ||
@@ -1354,67 +1699,28 @@
        this.form.serviceType == 10
      ) {
        this.checkboxlist = [
          {
            value: "1",
            label: "人工",
          },
          {
            value: "2",
            label: "纸质",
          },
          {
            value: "3",
            label: "智能语音",
          },
          {
            value: "4",
            label: "短信",
          },
          {
            value: "5",
            label: "微信公众号",
          },
          {
            value: "6",
            label: "微信小程序",
          },
          {
            value: "7",
            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 == 18 ||
        this.form.serviceType == 19 ||
        this.form.serviceType == 3 ||
        this.form.serviceType == 16 ||
        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: "微信小程序" },
        ];
      }
      getFollowuplist(this.topqueryParams).then((response) => {
@@ -1422,172 +1728,17 @@
        this.total = response.total;
      });
    },
    nextstep() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.Editprogress <= 3) {
            return this.Editprogress++;
          }
        } else {
          this.$modal.msgError("表单内容未完善,请检查");
        }
    getFollowupclassify() {
      getFollowupclassify({}).then((res) => {
        this.optionsclass = res.rows;
      });
    },
    // 保存
    submitForm(type) {
      if (this.templateor && type) this.templateor = false;
      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.operationcodes = [];
        this.illnesscodes = [];
      } else if (this.form.appltype == 2) {
        this.deptcodesWards = [];
        this.operationcodes = [];
        this.illnesscodes = [];
      } else if (this.form.appltype == 3) {
        this.deptcodesWards = [];
        this.leavehospitaldistrictcodes = [];
        this.operationcodes = [];
      } else if (this.form.appltype == 4) {
        this.deptcodesWards = [];
        this.illnesscodes = [];
        this.leavehospitaldistrictcodes = [];
      }
      if (this.checkList) {
        this.form.preachform = this.checkList.join(",");
        this.form.preachformList = this.selectedOrder;
      } else {
        this.$modal.msgError("请选择服务类型");
        return;
      }
      if (
        this.deptcodesWards[0] ||
        this.leavehospitaldistrictcodes[0] ||
        this.diagglist[0] ||
        this.operationcodes[0]
      ) {
      } else {
        this.$modal.msgError("请选择任务关联条件");
        return;
      }
      // if (!this.form.patTaskRelevances[0] && !this.form.longTask) {
      //   this.$modal.msgError("请选择病人");
      //   return;
      // }
      if (!this.form.templatename && !this.templateor) {
        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.deptcode = this.deptcodesWards.join(",");
      this.form.leavehospitaldistrictcode =
        this.leavehospitaldistrictcodes.join(",");
      this.form.opcode = this.operationcodes.join(",");
      this.form.icd10code = this.diagglist
        .map((item) => item.icdcode)
        .join(",");
      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 },
          });
        }
      });
    },
    // ----------------------表格子组件事件
    // 选择预览
    selectfn(row, type) {
      // 模板情况下获取模板信息
      if (type == 1) {
        this.libName = row.templateName;
        this.libId = row.id;
        this.questionList = row.ivrLibaTemplateScriptVOList;
        getvFollowup({ id: row.id }).then((res) => {
          if (res.code == 200) {
            this.objyl = res.data;
            // if (this.form.longTask) {
            //   this.objyl.sendDay = 5;
            // }
            this.queryParamsdept.type = 2;
            this.queryParamsdept.tempid = row.id;
            this.tempDetpRelevanceslist = [];
            this.tempbelongWards = [];
            this.objyl.suitway = this.objyl.suitway.split(",");
            this.questionList = res.data.ivrLibaTemplateScriptVOList;
            this.getillness(row.id);
            this.Variablehandling(res.data.ivrLibaTemplateScriptVOList, 1);
            this.previewtf = true;
          }
        });
        this.previewid = row.id;
      } else if (type == 2) {
      } else if (type == 3) {
      }
    },
    // 预览
    previewfnmb() {
      getTaskparticty(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.queryParamsdept.tempid = this.form.templateid;
          this.queryParamsdept.type = 21;
          // 疾病
          this.getillness(this.form.libtemplateid);
          getvFollowup({ id: this.form.libtemplateid }).then((res) => {
            if (res.code == 200) {
              this.previewtf = true;
              this.previewtftype = 1;
              this.questionList = res.data.ivrLibaTemplateScriptVOList;
              this.objyl.ivrLibaTemplateScriptVOList =
                res.data.ivrLibaTemplateScriptVOList;
            } else {
            }
          });
        }
    getillnesslist() {
      getillnesslist({
        pageNum: 1,
        pageSize: 1000,
      }).then((res) => {
        this.donorchargeList = res.rows;
      });
    },
    getillness(id) {
@@ -1600,35 +1751,466 @@
        });
      }
    },
    // 处理问题层变量
    Getdetails() {
      this.form = {
        patTaskRelevances: [],
        sendType: 1,
        sendDay: 5,
        templatename: "",
        templateid: null,
        libtemplateid: null,
        kcb:
          "亲爱的患者/家属,您好!我们是" +
          localStorage.getItem("orgname") +
          "的医护人员,为了更好地了解您的康复情况,请您抽一点宝贵时间,进行本次回访服务。",
        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) {
        getTaskInfo({ 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.diseaseDept = {
              deptCode: this.form.deptcode,
              deptName: this.form.deptname,
            };
            this.diseaseWard = {
              districtCode: this.form.leavehospitaldistrictcode,
              districtName: this.form.leavehospitaldistrictname,
            };
            this.form.serviceType = this.serviceType;
            this.form.patTaskRelevances = this.form.patTaskRelevances
              ? this.form.patTaskRelevances
              : [];
            // 药品关联回显
            if (this.form.medicalCode) {
              this.medicalCodes = this.form.medicalCode.split(",").filter(Boolean);
              listMedication({ itemCode: this.form.medicalCode, 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.sendState = null;
      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) {
      // 从 templateOptions 中查找选中项
      const selected = this.templateOptions.find(
        (item) => item.id === row.templateid
      );
      if (selected) {
        row.templatename = selected.templateName;
        row.libtemplateid = selected.libtemplateid || selected.id; // 假设有 libtemplateid
      } else {
        row.templatename = "";
        row.libtemplateid = null;
      }
    },
    remoteTemplate(query) {
      if (query !== "") {
        this.templateLoading = true;
        getFollowuplist({ templateName: query, pageNum: 1, pageSize: 20 })
          .then((res) => {
            this.templateOptions = res.rows;
            this.templateLoading = false;
          })
          .catch(() => {
            this.templateLoading = false;
          });
      } else {
        this.templateOptions = [];
      }
    },
    // ---------- 列表与搜索 ----------
    handleQuerymb() {
      getFollowuplist(this.topqueryParams).then((response) => {
        this.userList = response.rows;
        this.total = response.total;
      });
    },
    resetQuerymb() {
      this.topqueryParams = { pageNum: 1, pageSize: 10 };
      this.handleQuerymb();
    },
    getList() {
      // 占位
    },
    // ---------- 模板相关 ----------
    selectfn(row, type) {
      if (type == 1) {
        this.libName = row.templateName;
        this.libId = row.id;
        this.questionList = row.ivrLibaTemplateScriptVOList;
        getvFollowup({ id: row.id }).then((res) => {
          if (res.code == 200) {
            this.objyl = res.data;
            this.queryParamsdept.type = 2;
            this.queryParamsdept.tempid = row.id;
            this.tempDetpRelevanceslist = [];
            this.tempbelongWards = [];
            this.objyl.suitway = this.objyl.suitway
              ? this.objyl.suitway.split(",")
              : [];
            this.questionList = res.data.ivrLibaTemplateScriptVOList;
            this.getillness(row.id);
            this.Variablehandling(res.data.ivrLibaTemplateScriptVOList, 1);
            this.previewtf = true;
          }
        });
        this.previewid = row.id;
      }
    },
    previewfnmb() {
      getTaskparticty(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.queryParamsdept.tempid = this.form.templateid;
          this.queryParamsdept.type = 21;
          this.getillness(this.form.libtemplateid);
          selectInfoByCondition({ id: this.form.templateid }).then((res) => {
            if (res.code == 200) {
              this.previewtf = true;
              this.previewtftype = 1;
              this.questionList = res.data.ivrTaskTemplateScriptVOList;
              this.questionList.forEach((item) => {
                item.qremark = [];
                item.ivrLibaScriptTargetoptionList =
                  item.ivrTaskScriptTargetoptionList;
              });
              this.objyl.ivrLibaScriptTargetoptionList =
                res.data.ivrTaskScriptTargetoptionList;
            }
          });
        }
      });
    },
    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);
    },
    // ---------- 关联选择 ----------
    handleDiseaseDeptChange(dept) {
      this.diseaseDept = dept;
    },
    handleDiseaseWardChange(ward) {
      this.diseaseWard = ward;
    },
    // ---------- 科室/病区/疾病/手术 操作 ----------
    listDept() {
      this.leavehospitaldistrictcodes = [];
      this.deptcodesWards = [];
      this.queryParamsdept.taskId = this.form.taskid;
      if (this.form.appltype == 5) {
        // 任务组:使用 rwz 前缀的专属接口
        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;
      }
      // 普通疾病关联:调后端接口逐条删除
      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);
    },
    // ---------- 患者选择 ----------
    handleAddpatient(row) {
      this.allpids = [];
      this.overallCase.forEach((item) => {
@@ -1636,13 +2218,13 @@
      });
      if (this.patientqueryParams.allhosp == 1) {
        this.tableLabelhz = [
          // { label: "入院日期", width: "170", prop: "starttime" },
          { label: "出院日期", width: "150", prop: "endtime" },
          { label: "患者", 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: "责任护士", width: "", prop: "nurseName" },
          { label: "医生", width: "", prop: "drname" },
@@ -1657,6 +2239,7 @@
          { label: "电话号码", width: "180", prop: "telcode" },
          { label: "性别", width: "", prop: "sex" },
          { label: "年龄", width: "", prop: "age" },
          { label: "电话", width: "180", prop: "telcode" },
          { label: "出院天数", width: "", prop: "endDay" },
          { label: "责任护士", width: "", prop: "nurseName" },
          { label: "医生", width: "", prop: "drname" },
@@ -1671,6 +2254,7 @@
          { label: "电话号码", width: "180", prop: "telcode" },
          { label: "性别", width: "", prop: "sex" },
          { label: "年龄", width: "", prop: "age" },
          { label: "电话", width: "180", prop: "telcode" },
          { label: "出院天数", width: "", prop: "endDay" },
          { label: "责任护士", width: "", prop: "nurseName" },
          { label: "医生", width: "", prop: "drname" },
@@ -1685,12 +2269,7 @@
      }
      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
@@ -1715,20 +2294,13 @@
          }
        });
        this.patienttotal = response.total;
        this.loading = false;
        this.Restorecheck();
      });
      this.dialogVisiblepatient = true;
    },
    handleUpdate() {},
    handleDelete() {},
    handleExport() {},
    // 选择患者表数据
    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) {
@@ -1739,47 +2311,37 @@
          item.deptCode = item.deptcode;
          item.deptName = item.dept;
          item.admindate = item.inhosptime;
          item.sfzh = item.idcardno;
          if (this.patientqueryParams.allhosp == 6) {
            item.patfrom = 1;
          }
          if (this.patientqueryParams.allhosp == 1) {
          if (this.patientqueryParams.allhosp == 6) item.patfrom = 1;
          if (this.patientqueryParams.allhosp == 1)
            item.visittime = item.endtime;
          } else if (this.patientqueryParams.allhosp == 4) {
          else if (this.patientqueryParams.allhosp == 4)
            item.visittime = item.starttime;
          } else if (this.patientqueryParams.allhosp == 2) {
          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();
      }
    },
    // 删除选中患者
    detailhz(row, info) {
      this.$modal
        .confirm('是否确认删除患者"' + row.name + '"的服务项?')
@@ -1795,12 +2357,7 @@
          this.$modal.msgSuccess("删除成功");
        });
    },
    getList() {},
    handleQuery() {
      console.log(
        "this.patientqueryParams.allhosp",
        this.patientqueryParams.allhosp
      );
      if (this.patientqueryParams.topica == 0) {
        this.patientqueryParams.leavehospitaldistrictcodes =
          store.getters.leavehospitaldistrictcodes;
@@ -1824,274 +2381,51 @@
      )
        this.patientqueryParams.leaveldeptcodes = null;
      this.handleAddpatient();
      console.log(
        "this.patientqueryParams.allhosp",
        this.patientqueryParams.allhosp
      );
    },
    resetQuerymb() {
      this.topqueryParams = { svyname: "" };
      this.handleQuerymb();
    },
    resetQuery() {
      this.patientqueryParams = {
        pageNum: 1, //
        pageNum: 1,
        pageSize: 10,
        topica: 1, //0全部1科室2病区
        topica: 1,
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
      };
      this.handleQuery();
    },
    handleQuerymb() {
      getFollowuplist(this.topqueryParams).then((response) => {
        this.userList = response.rows;
        this.total = response.total;
      });
    },
    handleClosehz() {
      this.dialogVisiblepatient = false;
    },
    // 上一步
    AddDispatchpatients() {
      this.dialogVisiblepatient = false;
    },
    handleUpdate() {},
    handleDelete() {},
    handleExport() {},
    // ---------- 步骤导航 ----------
    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();
    },
    // 预览模板
    PreviewTemplate() {},
    Acknowledgereference() {
      this.quote = true;
    },
    // 获取详情
    Getdetails() {
      this.form = {
        patTaskRelevances: [],
        sendType: 1,
        sendDay: 5,
        templatename: "",
        templateid: null,
        libtemplateid: null,
        kcb:
          "亲爱的患者/家属,您好!我们是" +
          localStorage.getItem("orgname") +
          "的医护人员,为了更好地了解您的康复情况,请您抽一点宝贵时间,进行本次回访服务。",
        jsy: "请您注意休息和营养,生活上要劳逸结合,适当锻炼,戒烟限酒,保持心情舒畅,定期复诊。那本次回访就到这里,祝您身体健康!",
      };
      this.questionList = [];
      if (this.id) {
        getTaskInfo({ 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.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(",");
            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.sendState = null;
      this.form.taskid = null;
      this.overallCase = [];
      this.form.patTaskRelevances = [];
      this.daytime = []; //日期
      this.applydaytime = []; //计算日期
      this.time1 = ""; //上午时间段
      this.time2 = ""; //下午时间段
      this.time3 = ""; //晚上时间段
      this.time4 = ""; //晚上时间段
    },
    // 获取科室列表
    listDept() {
      this.leavehospitaldistrictcodes = [];
      this.deptcodesWards = [];
      this.queryParamsdept.taskId = this.form.taskid;
      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) => {
            getillnesslist({
              icdcode: item.icd10code,
            }).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);
          });
        }
      });
    },
    getillnesslist() {
      getillnesslist({
        pageNum: 1,
        pageSize: 1000,
      }).then((row) => {
        this.donorchargeList = res.rows;
      });
      getbaseopera({
        pageNum: 1,
        pageSize: 1000,
      }).then((row) => {
        this.baseoperaList = res.rows;
      });
    },
    // 手术查询
    remoteopcode(name) {
      if (name) {
        getbaseopera({
          pageNum: 1,
          pageSize: 1000,
          opdesc: name,
        }).then((res) => {
          this.baseoperaList = res.rows;
        });
      }
    // ---------- 服务形式排序 ----------
    checkSelectionChange(selectedValues, selectedOrder) {
      this.selectedOrder = selectedValues || [];
    },
    // 任务科室删除触发
    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) {
      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("删除成功");
          }
        });
      }
    },
    getFollowupclassify() {
      getFollowupclassify({}).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;
    },
    variableDelete(index, row) {
      this.variableList.splice(index, 1);
      row.isoperation = 3;
      this.delvariableList.push(row);
    },
    // 时间----------
    changeTime(row) {
    // ---------- 时间处理 ----------
    changeTime() {
      this.processingTime();
    },
    Totaldate(row) {
@@ -2107,27 +2441,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({
@@ -2151,15 +2477,13 @@
        }
      }
      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(",");
    },
    // 保存/更新任务模板
    // ---------- 模板保存与替换 ----------
    previewFn() {
      if (Array.isArray(this.objyl.suitway)) {
        this.objyl.suitway = this.objyl.suitway.join(",");
@@ -2173,23 +2497,20 @@
      if (this.form.id) {
        this.objyl.taskid = this.form.id;
      }
      // if (!this.objyl.sendDay) {
      //   this.objyl.sendDay = "5";
      // }
      if (this.form.templateid) {
        deleteTaskparticty(this.form.templateid).then((res) => {
          if (res.code == 200) {
            Taskparticty(this.objyl).then((response) => {
              this.previewtf = false;
              this.form.libtemplateid = this.objyl.id;
              this.form.libtemplatename = this.objyl.templateName;
              this.form.templateid = response.data;
              this.putbelongDepts(response.data);
              this.form.templatename = this.objyl.templateName;
              this.$modal.msgSuccess("替换模板成功");
              this.drawermb = false; //选择模板弹窗
              this.previewtf = false; //预览
              this.drawermb = false;
              this.previewtf = false;
              if (this.skip) {
                // 跳转前往修改
                this.$router.push({
                  path: "/knowledge/taskub/",
                  query: { id: response.data },
@@ -2202,14 +2523,14 @@
        Taskparticty(this.objyl).then((response) => {
          this.previewtf = false;
          this.form.libtemplateid = this.objyl.id;
          this.form.libtemplatename = this.objyl.templateName;
          this.form.templateid = response.data;
          this.putbelongDepts(response.data);
          this.form.templatename = this.objyl.templateName;
          this.$modal.msgSuccess("选择模板成功");
          this.drawermb = false; //选择模板弹窗
          this.previewtf = false; //预览
          this.drawermb = false;
          this.previewtf = false;
          if (this.skip) {
            // 跳转前往修改
            this.$router.push({
              path: "/knowledge/taskub/",
              query: { id: response.data },
@@ -2218,7 +2539,6 @@
        });
      }
    },
    // 保存科室/病区
    putbelongDepts(id) {
      this.tempDetpRelevanceslistform.forEach((item) => {
        item.tempid = id;
@@ -2239,28 +2559,6 @@
        }
      });
    },
    checkSelectionChange(selectedValues, selectedOrder) {
      this.selectedOrder = selectedValues;
      console.log("当前选中:", selectedValues);
      console.log("选中顺序:", selectedOrder);
    },
    // 服务形式选取
    handleCheckedCitiesChange(row) {
      console.log(row, "服务");
      this.foncheckList = this.checkboxlist.filter((obj) =>
        row.includes(obj.value)
      );
    },
    // 服务形式删除
    handleClosetag(tag) {
      console.log(tag, "tag");
      console.log(this.foncheckList, "foncheckList");
      this.checkList = this.checkList.filter((item) => item != tag.value);
      this.foncheckList = this.foncheckList.filter(
        (obj) => obj.value !== tag.value
      );
    },
    // 科室处理
    Departmenttreatment() {
      if (!this.form.taskid) {
        this.templateor = true;
@@ -2277,7 +2575,8 @@
            if (Array.isArray(this.objyl.suitway)) {
              this.objyl.suitway = this.objyl.suitway.join(",");
            }
            this.objyl.templateid = this.objyl.id;
            this.objyl.libtemplateid = this.objyl.id;
            this.form.libtemplateid = this.objyl.id;
            this.objyl.isoperation = 1;
            this.objyl.ivrLibaTemplateScriptVOList.forEach((item) => {
              item.ivrTaskScriptTargetoptionList =
@@ -2301,12 +2600,11 @@
        }, 1000);
      }
    },
    // 前往修改
    Modifytemplate() {
      if (this.form.templateid && this.previewtftype) {
        this.$modal.confirm("是否前往修改任务模板详细内容?").then(() => {
          this.drawermb = false; //选择模板弹窗
          this.previewtf = false; //预览
          this.drawermb = false;
          this.previewtf = false;
          this.$router.push({
            path: "/knowledge/taskub/",
            query: { id: this.form.templateid },
@@ -2316,25 +2614,228 @@
        this.$modal
          .confirm("当前为基础预览是否创建任务模板并前往修改详情?")
          .then(() => {
            // 走取先绑定后修改操作
            this.Departmenttreatment();
            this.skip = true;
          });
      }
    },
    // ---------- 提交表单 ----------
    submitForm(type) {
      if (this.submitLoading) return;
      this.submitLoading = true;
      try {
        if (this.templateor && type) {
          this.templateor = false;
        }
        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.operationcodes = [];
          this.illnesscodes = [];
        } else if (this.form.appltype == 2) {
          this.deptcodesWards = [];
          this.operationcodes = [];
          this.illnesscodes = [];
        } else if (this.form.appltype == 3) {
          this.deptcodesWards = [];
          this.leavehospitaldistrictcodes = [];
          this.operationcodes = [];
        } 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.operationcodes = [];
        }
        // 服务形式校验
        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.operationcodes[0] ||
          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.form.appltype != 5
        ) {
          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) => {
            // 组装 content
            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.appltype == 5) {
          console.log(this.form,'进入任务组配置');
          this.form.serviceTaskScheduleVO.icd10codes = this.form.icd10code;
          this.form.serviceTaskScheduleVO.wardCodes =
            this.form.leavehospitaldistrictcode;
          this.form.serviceTaskScheduleVO.deptCodes = this.form.deptcode;
        }
        if (this.form.taskid) {
          this.form.isoperation = 2;
        } else {
          this.form.isoperation = 1;
        }
        if (!this.form.type) {
          this.form.type = this.$route.query.type;
        }
        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.opcode = this.operationcodes.join(",");
        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;
        }
        Editsingletask(this.form)
          .then((res) => {
            if (res.code == 200) {
              if (this.form.taskid) {
                this.$modal.msgSuccess("修改成功");
              } else {
                this.$modal.msgSuccess("新增成功");
              }
              this.submitLoading = false;
              this.$router.push({
                path: "/followvisit/tasklist",
                query: { tasktopic: this.form.serviceType },
              });
            } else {
              this.$modal.msgError(res.msg || "操作失败");
              this.submitLoading = false;
            }
          })
          .catch((error) => {
            console.error("提交失败:", error);
            this.$modal.msgError(error.message || "网络异常,请稍后重试");
            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;
@@ -2344,17 +2845,15 @@
    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 {
@@ -2364,7 +2863,6 @@
    padding-left: 5px;
    margin-bottom: 10px;
    display: flex;
    // justify-content: space-between;
    .Add-details {
      font-size: 18px;
      color: #02a7f0;
@@ -2399,10 +2897,10 @@
    }
  }
}
.xinz-infs {
  font-size: 18px;
  line-height: 48px;
  .el-tag + .el-tag {
    margin-left: 10px;
  }
@@ -2410,12 +2908,8 @@
.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;
@@ -2424,6 +2918,7 @@
    }
  }
}
.jic-value {
  font-size: 20px;
  border-top: 1px solid #a7abac;
@@ -2451,6 +2946,7 @@
    }
  }
}
::v-deep .addtopic-input {
  input {
    background: #02a7f0;
@@ -2464,9 +2960,6 @@
::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;
@@ -2480,9 +2973,6 @@
  width: 22px;
  height: 22px;
}
// ::v-deep.topic-dev.el-radio__label {
//   font-size: 24px;
// }
::v-deep.el-radio-group {
  span {
    font-size: 18px;