WXL
2024-03-25 d84cde7ed98bf0c562a8631e660fd494de9a7d0b
src/views/patient/propaganda/particty.vue
@@ -14,6 +14,7 @@
            title="宣教对象"
            description="在本部选择宣教病人"
          ></el-step>
          <el-step icon="el-icon-user" title="模版确认"></el-step>
        </el-steps>
      </div>
    </div>
@@ -38,25 +39,85 @@
                <el-form-item label="模版名称:">
                  <el-input
                    style="width: 220px"
                    v-model="form.bt"
                    placeholder="请在下方选择"
                    v-model="form.templatename"
                    placeholder="请在下列选择"
                  />
                </el-form-item>
                <el-form-item label="发送时间:" v-if="currenttype != 2">
                <el-form-item label="发送设置:" v-if="currenttype != 2">
                  <el-radio-group v-model="form.sendType">
                    <el-radio :label="1">时间段发送</el-radio>
                    <el-radio :label="3">即刻发送</el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item
                  label="发送日期:"
                  v-if="currenttype != 2 && form.sendType == 1"
                >
                  <el-date-picker
                    v-model="form.name"
                    type="date"
                    placeholder="选择日期"
                    v-model="daytime"
                    @change="changeTimeday"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="发送时间段:" v-if="currenttype != 2">
                  <el-checkbox-group v-model="checkList">
                    <el-checkbox label="上午(8:30-11:30)"></el-checkbox>
                    <el-checkbox label="下午(14:30-16:30)"></el-checkbox>
                    <el-checkbox label="夜间(18:30-20:30)"></el-checkbox>
                    <el-checkbox label="不定时"></el-checkbox>
                  </el-checkbox-group>
                <el-form-item
                  label="发送时间段:"
                  v-if="currenttype != 2 && form.sendType == 1"
                >
                  <div style="display: flex">
                    <div style="margin-right: 10px">
                      <span style="font-size: 18px; margin-right: 10px"
                        >上午</span
                      >
                      <el-time-picker
                        is-range
                        @change="changeTime"
                        v-model="time1"
                        range-separator="至"
                        start-placeholder="开始时间"
                        end-placeholder="结束时间"
                        placeholder="选择时间范围"
                        value-format="HH:mm:ss"
                      >
                      </el-time-picker>
                    </div>
                    <div style="margin-right: 10px">
                      <span style="font-size: 18px; margin-right: 10px"
                        >下午</span
                      >
                      <el-time-picker
                        is-range
                        @change="changeTime"
                        v-model="time2"
                        range-separator="至"
                        start-placeholder="开始时间"
                        end-placeholder="结束时间"
                        placeholder="选择时间范围"
                        value-format="HH:mm:ss"
                      >
                      </el-time-picker>
                    </div>
                    <div style="margin-right: 10px">
                      <span style="font-size: 18px; margin-right: 10px"
                        >晚间</span
                      >
                      <el-time-picker
                        is-range
                        @change="changeTime"
                        v-model="time3"
                        range-separator="至"
                        start-placeholder="开始时间"
                        end-placeholder="结束时间"
                        placeholder="选择时间范围"
                        value-format="HH:mm:ss"
                      >
                      </el-time-picker>
                    </div>
                  </div>
                </el-form-item>
                <el-form-item label="服务形式">
                  <el-checkbox-group v-model="checkList">
@@ -66,18 +127,6 @@
                      :label="item"
                    ></el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
                <el-form-item label="组织形式">
                  <el-radio-group v-model="form.radio">
                    <el-radio :label="3">单人宣教</el-radio>
                    <el-radio :label="6">多人集中宣教</el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item label="语音模版" prop="region">
                  <el-select v-model="form.region" placeholder="请选择模版">
                    <el-option label="一号模版" value="shanghai"></el-option>
                    <el-option label="二号模版" value="beijing"></el-option>
                  </el-select>
                </el-form-item>
              </el-form>
            </div>
@@ -244,14 +293,14 @@
                    </el-form-item>
                  </el-form>
                  <el-divider></el-divider>
                  <!-- 选择任务列表 -->
                  <!-- 选择模版列表 -->
                  <SFtable
                    @handleUpdate="handleUpdate"
                    @handleSelectionChange="handleSelectionChange"
                    @selectfn="selectfn"
                    :currentList="userList"
                    :tableLabel="tableLabel"
                    :controlsc="false"
                    :multiplechoice="false"
                    :typeinfo="1"
                  />
                  <pagination
                    v-show="total > 0"
@@ -265,7 +314,7 @@
            </div>
          </div>
        </div>
        <el-button type="success" @click="submitForm('ruleForm')">{{
        <el-button type="success" @click="nextstep('ruleForm')">{{
          quote ? "立即创建" : "任务详情设置"
        }}</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
@@ -416,7 +465,7 @@
                  <el-row :gutter="10" class="mb8">
                    <el-col :span="1.5">
                      <el-select
                        v-model="tasktopic"
                        v-model="patientqueryParams.allhosp"
                        placeholder="请选择新增类型"
                      >
                        <el-option
@@ -434,7 +483,7 @@
                        plain
                        icon="el-icon-plus"
                        size="medium"
                        :disabled="!tasktopic"
                        :disabled="!patientqueryParams.allhosp"
                        @click="handleAddpatient"
                        >新增</el-button
                      >
@@ -458,9 +507,10 @@
                  <SFtable
                    @handleUpdate="handleUpdate"
                    @handleSelectionChange="handleSelectionChange"
                    :currentList="sonuserList"
                    :currentList="form.patTaskRelevances"
                    :tableLabel="tableLabelhz"
                    :controlxz="false"
                    :typeinfo="2"
                  />
                  <pagination
                    v-show="total > 0"
@@ -568,7 +618,9 @@
              @handleSelectionChange="handleSelectionChange"
              :currentList="patientuserList"
              :tableLabel="tableLabelhz"
              :serialnumber="false"
              :controlsc="false"
              :typeinfo="3"
            />
          </el-row>
          <pagination
@@ -592,6 +644,7 @@
<script>
import { messagelistpatient } from "@/api/patient/homepage";
import store from "@/store";
import {
  getTaskpatient,
  getlibrarylist,
@@ -601,6 +654,7 @@
  addhetask,
  gethetaskinfo,
  delhetaskinfo,
  Editsingletask,
} from "@/api/AiCentre/index";
import SFtable from "@/components/SFtable"; //表格组件
@@ -615,10 +669,12 @@
      loading: false, // 遮罩层
      patientloading: false, // 遮罩层
      dialogVisiblepatient: false, //添加患者弹框
      radio: 1,
      checkboxlist: [],
      tableLabel: [],
      // 患者表单
      tableLabelhz: [
        { label: "序号", width: "", prop: "patid" },
        { label: "患者名称", width: "", prop: "name" },
        { label: "性别", width: "", prop: "sex" },
        { label: "年龄", width: "", prop: "age" },
@@ -670,6 +726,12 @@
        { label: "匹配符", width: "", prop: "character" },
        { label: "替换值", width: "", prop: "Replacementvalue" },
      ],
      // 时间处理
      daytime: [], //日期
      applydaytime: [], //计算日期
      time1: "", //上午时间段
      time2: "", //下午时间段
      time3: "", //晚上时间段
      topqueryParams: {
        pageNum: 1, //
        pageSize: 10,
@@ -715,16 +777,15 @@
          Replacementvalue: "八个八",
        },
      ], //变量列表
      variableListTime: [],
      tasktopic: null, //新增类型
      SelectPatientslist: [],
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
        serviceform: [],
        patTaskRelevances: [],
        sendType: 1,
        templatename: "",
        templateid: null,
      },
      taskoptions: [
        {
@@ -747,13 +808,41 @@
  created() {
    this.id = this.$route.query.id;
    this.form.type = this.$route.query.type;
    this.Addsubtask();
    this.Getsubtask();
    this.Acquisitiontype();
  },
  methods: {
    // {
    //   姓名: { "${name}": "龙傲天" },
    //   地址: { "${dzz}": "龙宫" },
    //   电话: { "${dhh}": "八个八" },
    // }
    // 变量转换对象转数组
    convertFormat1ToFormat2(data) {
      let result = [];
      for (let key in data) {
        let innerKey = Object.keys(data[key])[0];
        result.push({
          name: key,
          value: innerKey,
          fill: data[key][innerKey],
        });
      }
      return result;
    },
    // 数组转对象
    convertFormat2ToFormat1(data) {
      let result = {};
      data.forEach((item) => {
        let innerObj = {};
        innerObj[item.value] = item.fill;
        result[item.name] = innerObj;
      });
      return result;
    },
    // 获取当前类型
    Acquisitiontype() {
      let queryParams = {
@@ -761,24 +850,21 @@
        pageSize: 10,
        isavailable: "",
      };
      getTaskpatient({ allhosp: 1 }).then((res) => {
        console.log(res);
      });
      this.currenttype = this.$route.query.type;
      console.log(this.currenttype);
      console.log(this.currenttype, "1");
      if (this.currenttype == 1) {
        this.title = "宣教内容列表";
        this.tableLabel = this.tableLabelxj;
        this.checkboxlist = [
          "当面",
          "多媒体",
          "线下",
          "视频",
          "纸质",
          "电话",
          "语音",
          "短信",
          "微信公众号",
          "微信小程序",
          "支付宝",
          "智能小程序",
          "二维码",
          "钉钉",
        ];
        getlibrarylist(queryParams).then((response) => {
@@ -788,7 +874,7 @@
      } else if (this.currenttype == 2) {
        this.title = "随访内容列表";
        this.tableLabel = this.tableLabelmz;
        this.checkboxlist = ["当面", "纸质", "电话", "短信", "微信公众号"];
        this.checkboxlist = ["线下", "纸质", "语音", "短信", "微信公众号"];
        getFollowuplist(queryParams).then((response) => {
          this.userList = response.rows;
          this.total = response.total;
@@ -796,7 +882,7 @@
      } else if (this.currenttype == 3) {
        this.title = "随访计划列表";
        this.tableLabel = this.tableLabelcy;
        this.checkboxlist = ["当面", "纸质", "电话", "短信", "微信公众号"];
        this.checkboxlist = ["线下", "纸质", "语音", "短信", "微信公众号"];
        getFollowuplist(queryParams).then((response) => {
          this.userList = response.rows;
          this.total = response.total;
@@ -804,7 +890,7 @@
      } else if (this.currenttype == 4) {
        this.title = "通知内容列表";
        this.tableLabel = this.tableLabelfz;
        this.checkboxlist = ["电话", "短信", "微信公众号"];
        this.checkboxlist = ["语音", "短信", "微信公众号"];
        getFollowuplist(queryParams).then((response) => {
          this.userList = response.rows;
          this.total = response.total;
@@ -812,7 +898,7 @@
      } else if (this.currenttype == 5) {
        this.title = "通知内容列表";
        this.tableLabel = this.tableLabeltj;
        this.checkboxlist = ["纸质", "电话", "短信", "微信公众号"];
        this.checkboxlist = ["纸质", "语音", "短信", "微信公众号"];
        getFollowuplist(queryParams).then((response) => {
          this.userList = response.rows;
          this.total = response.total;
@@ -821,10 +907,10 @@
        this.title = "问卷内容列表";
        this.tableLabel = this.tableLabelwj;
        this.checkboxlist = [
          "当面",
          "多媒体",
          "线下",
          "视频",
          "纸质",
          "电话",
          "语音",
          "短信",
          "微信公众号",
          "微信小程序",
@@ -836,11 +922,34 @@
        });
      }
    },
    // 下一步
    submitForm(formName) {
    nextstep() {
      if (this.Editprogress <= 3) {
        return this.Editprogress++;
      }
    },
    // 保存
    submitForm(formName) {
      this.form.serviceform = this.checkList.join(",");
      this.form.textParam = {
        姓名: { "${name}": "龙傲天" },
        地址: { "${dzz}": "龙宫" },
        电话: { "${dhh}": "八个八" },
      };
      if (this.form.id) {
        this.form.isoperation = 2;
      } else {
        this.form.isoperation = 1;
      }
      Editsingletask(this.form).then((response) => {
        if (res.code == 200) {
          if (this.form.id) {
            this.$modal.msgSuccess("新增成功");
          } else {
            this.$modal.msgSuccess("修改成功");
          }
          this.$router.go(-1);
        }
      });
      // 提交
      // this.$refs[formName].validate((valid, object) => {
      //   if (valid) {
@@ -851,10 +960,21 @@
      //   }
      // });
    },
    // ----------------------表格子组件事件
    // 选择
    selectfn(row, type) {
      console.log(row);
      console.log(type);
      if (type == 1) {
        this.form.templatename = row.preachname;
        this.form.templateid = row.templateid;
      } else if (type == 2) {
      } else if (type == 3) {
      }
    },
    // 子任务二级弹框
    handleAddpatient(row) {
      console.log(row, "子组件数据");
      messagelistpatient(this.patientqueryParams).then((response) => {
      getTaskpatient(this.patientqueryParams).then((response) => {
        console.log(response);
        this.patientuserList = response.rows;
        this.patienttotal = response.total;
@@ -867,6 +987,8 @@
    handleExport() {},
    // 多选框选中数据
    handleSelectionChange(selection) {
      console.log("多选患者");
      this.SelectPatientslist = selection;
      this.ids = null;
      this.ids = selection.map((item) => item.patid).join(",");
      // let result = this.ids.join(",");
@@ -901,23 +1023,21 @@
    },
    // 新增派送患者
    AddDispatchpatients() {
      let objictpint = {};
      objictpint.patientes = this.ids;
      objictpint.pguid = 2;
      // Addpatienttask(objictpint).then((res) => {
      //   console.log(res);
      // });
      this.SelectPatientslist.forEach((item) => {
        item.isoperation = 1;
      });
      this.form.patTaskRelevances.push(...this.SelectPatientslist);
      this.dialogVisiblepatient = false;
    },
    // 查询子任务列表
    Getsubtask() {
      this.topqueryParams.pguid = 2;
      console.log(this.topqueryParams);
      console.log(this.topqueryParams, "aa");
      messagelistpatient(this.topqueryParams).then((res) => {
        this.userList = res.rows;
        this.total = res.total;
        console.log(this.userList);
        console.log(this.userList, "ss");
      });
    },
    // 变量---------------
@@ -927,6 +1047,66 @@
    variableDelete(index, row) {
      console.log(index, row);
    },
    // 时间----------
    changeTime(row) {
      console.log(row, "时间");
      this.processingTime();
    },
    changeTimeday(row) {
      const startDate = new Date(row[0]);
      const endDate = new Date(row[1]);
      this.applydaytime = this.getDates(startDate, endDate);
      this.processingTime();
    },
    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;
      }
      for (let i = 0; i < this.applydaytime.length; i++) {
        combinedData.push({
          begantime: `${this.applydaytime[i]} ${this.time1[0]}`,
          endtime: `${this.applydaytime[i]} ${this.time1[1]}`,
          xh: serialnumber * i + 1,
        });
        if (serialnumber >= 2) {
          combinedData.push({
            begantime: `${this.applydaytime[i]} ${this.time2[0]}`,
            endtime: `${this.applydaytime[i]} ${this.time2[1]}`,
            xh: serialnumber * i + 2,
          });
        }
        if (serialnumber >= 3) {
          combinedData.push({
            begantime: `${this.applydaytime[i]} ${this.time3[0]}`,
            endtime: `${this.applydaytime[i]} ${this.time3[1]}`,
            xh: serialnumber * i + 3,
          });
        }
      }
      this.form.sendTimeslot = combinedData;
      console.log(combinedData, "combinedData");
    },
  },
};
</script>