WXL (wul)
3 天以前 b57c6c97c7de4cb5aeeb6c766a4642fac5b9b500
src/views/followvisit/discharge/index.vue
@@ -92,10 +92,11 @@
            v-model="topqueryParams.scopetype"
            placeholder="默认全部"
            :options="sourcetype"
            :props="{ expandTrigger: 'hover' }"
            :props="{ expandTrigger: 'hover', multiple: true }"
            @change="handleChange"
            filterable
            clearable
            collapse-tags
          ></el-cascader>
        </el-form-item>
@@ -1192,6 +1193,7 @@
          label: "全部",
        },
      ],
      lastScopeType: 3, // 患者范围上次选择的一级类型(1=科室,2=病区,3=全部)
      loading: false,
      cardlist: [
        {
@@ -1293,7 +1295,7 @@
        visitCount: 1,
        scopetype: [],
        managementDoctor:
          localStorage.getItem("orgname") == "缙云县人民医院"
          localStorage.getItem("orgname") == "缙云县人民医院"||localStorage.getItem("orgname") == "丽水市中医院"
            ? store.getters.nickName
            : "",
        leaveldeptcodes: [],
@@ -1493,13 +1495,7 @@
    /** 查询随访服务列表 */
    async getList(refresh) {
      // 默认全部
      if (this.topqueryParams.searchscope == 3) {
        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
          (obj) => obj.deptCode
        );
        this.topqueryParams.leavehospitaldistrictcodes =
          store.getters.belongWards.map((obj) => obj.districtCode);
      }
      this.applyDeptWardScope();
      if (this.endOut == 0) {
        this.topqueryParams.endSendDateTime = this.formatDateToYYYYMMDDHHMMSS(
          this.getEndOfDay()
@@ -1681,13 +1677,7 @@
      if (type) {
        this.resetQuerykj();
      }
      if (this.topqueryParams.searchscope == 3) {
        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
          (obj) => obj.deptCode
        );
        this.topqueryParams.leavehospitaldistrictcodes =
          store.getters.belongWards.map((obj) => obj.districtCode);
      }
      this.applyDeptWardScope();
      // 接受异常跳转
      if (this.errtype) {
        this.topqueryParams.leavehospitaldistrictcodes.push(
@@ -1795,13 +1785,7 @@
    },
    /** 搜索按钮操作 */
    handleQuery(refresh) {
      if (this.topqueryParams.searchscope == 3) {
        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
          (obj) => obj.deptCode
        );
        this.topqueryParams.leavehospitaldistrictcodes =
          store.getters.belongWards.map((obj) => obj.districtCode);
      }
      this.applyDeptWardScope();
      this.topqueryParams.pageNum = 1;
      // 判断是不是工作台快捷查询
      if (this.errtype != 2) {
@@ -1812,33 +1796,65 @@
      }
      this.getList(refresh);
    },
    // 患者范围处理
    // 患者范围处理:从多选级联 scopetype 解析科室/病区
    applyDeptWardScope() {
      const value = this.topqueryParams.scopetype || [];
      const deptCodes = [];
      const wardCodes = [];
      let isAll = false;
      value.forEach((item) => {
        const type = item[0];
        if (type == 3) {
          isAll = true;
        } else if (type == 1) {
          deptCodes.push(item[item.length - 1]);
        } else if (type == 2) {
          wardCodes.push(item[item.length - 1]);
        }
      });
      // 选了全部 或 未选择 → 用户全部科室/病区
      if (isAll || (!deptCodes.length && !wardCodes.length)) {
        this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map(
          (obj) => obj.deptCode
        );
        this.topqueryParams.leavehospitaldistrictcodes =
          store.getters.belongWards.map((obj) => obj.districtCode);
      } else {
        this.topqueryParams.leaveldeptcodes = deptCodes;
        this.topqueryParams.leavehospitaldistrictcodes = wardCodes;
      }
    },
    // 患者范围多选变更(科室/病区互斥)
    handleChange(value) {
      console.log("选择的患者范围:", value);
      const types = (value || []).map((item) => item[0]);
      const hasDept = types.includes(1);
      const hasWard = types.includes(2);
      // 清空之前的查询参数
      this.topqueryParams.leavehospitaldistrictcodes = [];
      this.topqueryParams.leaveldeptcodes = [];
      this.topqueryParams.searchscope = null;
      if (!value || value.length === 0) {
      // 互斥:科室和病区不能同时选
      if (hasDept && hasWard) {
        if (this.lastScopeType == 1) {
          // 上次选了科室,这次新增病区 → 保留病区
          this.topqueryParams.scopetype = value.filter(
            (item) => item[0] === 2
          );
          this.lastScopeType = 2;
          this.$message.warning("科室和病区不能同时选择,已切换为病区");
        } else {
          // 上次选了病区,这次新增科室 → 保留科室
          this.topqueryParams.scopetype = value.filter(
            (item) => item[0] === 1
          );
          this.lastScopeType = 1;
          this.$message.warning("科室和病区不能同时选择,已切换为科室");
        }
        this.applyDeptWardScope();
        return;
      }
      let type = value[0];
      let code = value.slice(-1)[0];
      if (type == 1) {
        this.topqueryParams.leaveldeptcodes.push(code);
        this.topqueryParams.leavehospitaldistrictcodes = [];
        this.topqueryParams.searchscope = 1;
      } else if (type == 2) {
        this.topqueryParams.leavehospitaldistrictcodes.push(code);
        this.topqueryParams.leaveldeptcodes = [];
        this.topqueryParams.searchscope = 2;
      } else {
        this.topqueryParams.searchscope = 3;
      }
      this.lastScopeType = hasDept ? 1 : hasWard ? 2 : 3;
      this.applyDeptWardScope();
    },
    // 服务状态变更处理
    handleServiceStatusChange(value) {
@@ -1876,6 +1892,7 @@
      this.dateRange = [];
      this.dateRangefs = [];
      this.serviceStatusValue = 10;
      this.lastScopeType = 3;
      this.topqueryParams = {
        pageNum: 1,
        pageSize: 10,
@@ -1895,6 +1912,7 @@
      this.dateRange = [];
      this.dateRangefs = [];
      this.serviceStatusValue = null;
      this.lastScopeType = 3;
      this.topqueryParams = {
        pageNum: 1,
        pageSize: 10,