"use strict";
const common_vendor = require("../../common/vendor.js");
const api_api = require("../../api/api.js");
const utils_navTo = require("../../utils/navTo.js");
const common_assets = require("../../common/assets.js");
if (!Array) {
  const _easycom_up_dropdown_item2 = common_vendor.resolveComponent("up-dropdown-item");
  const _easycom_up_dropdown2 = common_vendor.resolveComponent("up-dropdown");
  const _easycom_up__image2 = common_vendor.resolveComponent("up--image");
  const _easycom_z_paging2 = common_vendor.resolveComponent("z-paging");
  (_easycom_up_dropdown_item2 + _easycom_up_dropdown2 + _easycom_up__image2 + _easycom_z_paging2)();
}
const _easycom_up_dropdown_item = () => "../../node-modules/uview-plus/components/u-dropdown-item/u-dropdown-item.js";
const _easycom_up_dropdown = () => "../../node-modules/uview-plus/components/u-dropdown/u-dropdown.js";
const _easycom_up__image = () => "../../node-modules/uview-plus/components/u--image/u--image.js";
const _easycom_z_paging = () => "../../uni_modules/z-paging/components/z-paging/z-paging.js";
if (!Math) {
  (navBarSearch + _easycom_up_dropdown_item + _easycom_up_dropdown + _easycom_up__image + _easycom_z_paging)();
}
const navBarSearch = () => "../../components/navBarSearch/navBarSearch.js";
const _sfc_main = {
  __name: "searchList",
  setup(__props) {
    const paging = common_vendor.ref(null);
    const uDropdownRef = common_vendor.ref(null);
    const dataList = common_vendor.ref([]);
    const total = common_vendor.ref(0);
    common_vendor.ref("");
    const keyWord = common_vendor.ref("");
    common_vendor.ref(true);
    const type = common_vendor.ref("doctor");
    const navName = common_vendor.ref("医生临床病例库");
    const options = common_vendor.ref([
      {
        label: "正序",
        value: "asc"
      },
      {
        label: "倒序",
        value: "desc"
      }
    ]);
    const order = common_vendor.reactive({
      read_num: "",
      push_date: ""
    });
    common_vendor.onLoad((options2) => {
      if (options2.type == "hospital") {
        type.value = "hospital";
      }
      keyWord.value = options2.name;
      if (options2.name) {
        navName.value = options2.name + "临床病例库";
      }
      if ((options2.name = "医生") && !options2.id) {
        keyWord.value = "";
      }
      if (options2.order == "new") {
        order.push_date = "asc";
      }
      if (options2.order == "read") {
        order.read_num = "desc";
      }
    });
    const change = (e) => {
      paging.value.reload();
    };
    const formatdate = (date) => {
      if (!date)
        return common_vendor.dayjs().format("YYYY-MM-DD");
      return common_vendor.dayjs(date).format("YYYY-MM-DD");
    };
    const searchHospital = async (params) => {
      let searchForm = {
        hospital_name: keyWord.value
      };
      if (!order.read_num) {
        delete order.read_num;
      }
      if (!order.push_date) {
        delete order.push_date;
      }
      if (order.read_num || order.push_date) {
        searchForm.order = order;
      }
      api_api.api.searchHospital({
        ...searchForm,
        ...params
      }).then((res) => {
        paging.value.complete(res.data.data.data);
        total.value = res.data.data.total;
      }).catch((err) => {
        paging.value.complete(false);
      });
    };
    const searchDoctor = async (params) => {
      let searchForm = {
        doctor_name: keyWord.value
      };
      if (!order.read_num) {
        delete order.read_num;
      }
      if (!order.push_date) {
        delete order.push_date;
      }
      if (order.read_num || order.push_date) {
        searchForm.order = order;
      }
      api_api.api.searchDoctor({
        ...searchForm,
        ...params
      }).then((res) => {
        paging.value.complete(res.data.data.data);
        total.value = res.data.data.total;
      }).catch((err) => {
        paging.value.complete(false);
      });
    };
    const queryList = (pageNo, pageSize) => {
      const params = {
        page: pageNo,
        page_size: pageSize
      };
      type.value == "hospital" ? searchHospital(params) : searchDoctor(params);
    };
    const goDetail = (id, name) => {
      let url = "";
      if (type.value == "doctor") {
        url = `/pages/search/search?doctor_id=${id}&doctor_name=${name}`;
      } else {
        url = `/pages/search/search?hospital_id=${id}&hospital_name=${name}`;
      }
      utils_navTo.navTo({
        url
      });
    };
    const changeWord = (value) => {
      common_vendor.index.__f__("log", "at pages/searchList/searchList.vue:259", value);
      if (value) {
        navName.value = value + "临床病例库";
        keyWord.value = value;
        dataList.value = [];
        order.read_num = "";
        order.push_date = "";
        paging.value.reload();
      }
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.o(changeWord),
        b: common_vendor.p({
          searchWord: keyWord.value,
          navName: navName.value,
          type: type.value
        }),
        c: common_vendor.o(change),
        d: common_vendor.o(($event) => order.push_date = $event),
        e: common_vendor.p({
          title: "发布时间",
          options: options.value,
          modelValue: order.push_date
        }),
        f: common_vendor.sr(uDropdownRef, "5d2f7987-2,5d2f7987-0", {
          "k": "uDropdownRef"
        }),
        g: common_vendor.f(dataList.value, (item, index, i0) => {
          return common_vendor.e(type.value == "hospital" ? {
            a: common_vendor.t(item.basic_hospital.hospital_name)
          } : {
            b: common_vendor.t(item.case_clinical_doctor.doctor_name),
            c: common_vendor.t(item.case_clinical_doctor.hospital_name)
          }, {
            d: common_vendor.f(item.author, (tag, k1, i1) => {
              return {
                a: common_vendor.t(tag.doctor_name),
                b: tag.author_id
              };
            }),
            e: common_vendor.t(item.video_num + item.article_num),
            f: "5d2f7987-4-" + i0 + ",5d2f7987-0",
            g: common_vendor.t(formatdate(item.last_push_date)),
            h: index,
            i: common_vendor.o(($event) => type.value == "hospital" ? goDetail(item.basic_hospital.hospital_id, item.basic_hospital.hospital_name) : goDetail(item.case_clinical_doctor.doctor_id, item.case_clinical_doctor.doctor_name), index)
          });
        }),
        h: type.value == "hospital",
        i: common_vendor.p({
          src: common_vendor.unref(common_assets.arrowrightImg),
          width: "32rpx",
          height: "32rpx"
        }),
        j: common_vendor.sr(paging, "5d2f7987-0", {
          "k": "paging"
        }),
        k: common_vendor.o(queryList),
        l: common_vendor.o(($event) => dataList.value = $event),
        m: common_vendor.p({
          ["inside-more"]: true,
          ["loading-more-no-more-text"]: "咱也是有底线的！",
          ["auto-show-back-to-top"]: true,
          modelValue: dataList.value
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5d2f7987"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/searchList/searchList.js.map
