import { defineComponent, reactive, computed, toRefs, openBlock, createElementBlock, Fragment, renderList, normalizeClass, withModifiers, toDisplayString, ref, watch, createElementVNode, withDirectives, vModelText, createCommentVNode, createBlock, unref, createVNode, render, resolveComponent, withCtx, mergeProps, renderSlot } from "vue";
import WlSvg from "@wltech/svg";
import { Checkbox, CheckboxGroup, Cell, CellGroup, List, ActionSheet } from "vant";
var Tab_vue_vue_type_style_index_0_scoped_true_lang = "";
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _sfc_main$8 = defineComponent({
  props: {
    tabTypes: {
      type: Array,
      default: () => {
        return [1, 2, 3];
      }
    }
  },
  setup(props, { emit }) {
    var _a;
    const state = reactive({
      curTab: {
        type: ((_a = props.tabTypes) == null ? void 0 : _a[0]) || 1
      }
    });
    const tabList = computed(() => {
      const tabs = [
        {
          name: "\u4F01\u5FAE\u597D\u53CB",
          type: 1
        },
        {
          name: "\u4E2A\u5FAE\u4EBA\u8109",
          type: 2
        },
        {
          name: "\u8054\u7CFB\u4EBA",
          type: 3
        }
      ];
      return tabs.filter((e) => {
        var _a2;
        return (_a2 = props.tabTypes) == null ? void 0 : _a2.includes(e.type);
      });
    });
    const onClick = (res) => {
      state.curTab = res;
      emit("onTabChange", res);
    };
    return {
      ...toRefs(state),
      tabList,
      onClick
    };
  }
});
const _hoisted_1$6 = { class: "flex-row" };
const _hoisted_2$6 = ["onClick"];
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createElementBlock("ul", _hoisted_1$6, [
    (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.tabList, (item) => {
      return openBlock(), createElementBlock("li", {
        class: normalizeClass({ active: item.type == _ctx.curTab.type }),
        key: item.type,
        onClick: withModifiers(($event) => _ctx.onClick(item), ["stop"])
      }, toDisplayString(item.name), 11, _hoisted_2$6);
    }), 128))
  ]);
}
var TabMulte = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$6], ["__scopeId", "data-v-12fe7249"]]);
const formatCosUrl = (url) => {
  return `https://wlmvp-cos.weiling.cn${url}`;
};
var VSearch_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$7 = defineComponent({
  name: "Search",
  props: {
    value: {
      type: String,
      default: ""
    },
    icon: {
      type: String,
      default: formatCosUrl("/worktable-h5/icon/search-icon.png")
    },
    placeholder: {
      type: String,
      default: "\u641C\u7D22"
    },
    closable: {
      type: Boolean,
      default: true
    }
  },
  setup(props, { emit }) {
    const fieldValue = ref("");
    const delIcon = ref(formatCosUrl("/worktable-h5/icon/search_delete01.png"));
    const onInput = () => {
      if (!fieldValue.value)
        return;
      emit("update:value", fieldValue.value);
    };
    const onClear = () => {
      fieldValue.value = "";
      emit("onClear");
    };
    watch(
      () => props.value,
      (val) => fieldValue.value = val,
      { immediate: true }
    );
    watch(
      () => fieldValue.value,
      (val) => {
        emit("update:value", val);
        emit("onChange", val);
      }
    );
    return {
      fieldValue,
      onInput,
      onClear,
      delIcon
    };
  }
});
const _hoisted_1$5 = { class: "common-search" };
const _hoisted_2$5 = ["src"];
const _hoisted_3$4 = { class: "search-input" };
const _hoisted_4$4 = ["placeholder"];
const _hoisted_5$4 = ["src"];
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createElementBlock("div", _hoisted_1$5, [
    createElementVNode("img", {
      class: "search-icon",
      src: _ctx.icon,
      alt: ""
    }, null, 8, _hoisted_2$5),
    createElementVNode("div", _hoisted_3$4, [
      withDirectives(createElementVNode("input", {
        type: "text",
        placeholder: _ctx.placeholder,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.fieldValue = $event)
      }, null, 8, _hoisted_4$4), [
        [vModelText, _ctx.fieldValue]
      ])
    ]),
    _ctx.closable && _ctx.fieldValue ? (openBlock(), createElementBlock("img", {
      key: 0,
      class: "search-close-icon",
      onClick: _cache[1] || (_cache[1] = (...args) => _ctx.onClear && _ctx.onClear(...args)),
      alt: "",
      src: _ctx.delIcon
    }, null, 8, _hoisted_5$4)) : createCommentVNode("", true)
  ]);
}
var VSearch = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$5], ["__scopeId", "data-v-1793732c"]]);
var employeeSelector = {
  employeeData: null,
  topFiveEmployeeData: null,
  organization: null,
  organization_count: null,
  count: 0,
  dept_list: [],
  company_list: [],
  company_list_count: 0,
  companyEmployeeList: [],
  totalCompanyEmployeeList: [],
  totalCompanyEmployeeObjList: []
};
const Store = {
  sid: "",
  app_id: "",
  user_id: "",
  user_name: "",
  corp_id: "",
  node_env: "",
  domain: "",
  token: "",
  card_resource: "",
  employeeSelector
};
var Store$1 = new Proxy(Store, {
  get(target, name, property) {
    return Reflect.get(target, name, property);
  },
  set(target, name, value, property) {
    return Reflect.set(target, name, value, property);
  }
});
const proxy_api = {
  dev_uat: "/uat_api",
  dev_stg: "/stg_api",
  dev_prd: "/prd_api",
  dev_cos_api: "/cos_api",
  dev_uat_xsf: "/xsf_api",
  dev: "/uat_api",
  uat: "",
  stg: "",
  prd: "",
  gray: "",
  production: "",
  uat_xsf: "https://test.xsfapi.weiling.cn",
  stg_xsf: "https://pre-xsfapi.weiling.cn",
  prd_xsf: "https://xsfapi.weiling.cn",
  gray_xsf: "https://xsfapi.weiling.cn"
};
const token_key = {
  dev_uat: "auth-token-mp-test",
  dev_stg: "auth-token-mp",
  dev_prd: "auth-token-mp",
  dev_uat_xsf: "auth-token-se-test",
  dev_stg_xsf: "auth-token-se",
  dev_gray_xsf: "auth-token-se",
  dev_prd_xsf: "auth-token-se",
  uat: "auth-token-mp-test",
  stg: "auth-token-mp",
  prd: "auth-token-mp",
  gray: "auth-token-mp",
  uat_xsf: "auth-token-se-test",
  stg_xsf: "auth-token-se",
  prd_xsf: "auth-token-se",
  gray_xsf: "auth-token-se"
};
const __default__$1 = {
  name: "WlSvgIcon"
};
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    type: { default: "" },
    color: { default: "var(--wl-text-color-title-1)" },
    width: { default: "16" },
    height: { default: "16" }
  },
  setup(__props) {
    const sub = location.origin;
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(WlSvg), {
        type: __props.type,
        width: __props.width,
        height: __props.height,
        color: __props.color,
        sub: unref(sub)
      }, null, 8, ["type", "width", "height", "color", "sub"]);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$1 = "";
const _hoisted_1$4 = { class: "icon" };
const _hoisted_2$4 = { class: "text" };
const __default__ = {
  name: "WlNotice"
};
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    show_toast: { type: Boolean, default: true },
    message: { default: "" },
    type: { default: "success" },
    duration: { default: 1500 }
  },
  setup(__props) {
    return (_ctx, _cache) => {
      return __props.show_toast ? (openBlock(), createElementBlock("div", {
        key: 0,
        class: normalizeClass(`notice ${__props.type}`),
        "data-weiling-mobile-ui-wl-notice": ""
      }, [
        createElementVNode("div", _hoisted_1$4, [
          __props.type === "success" ? (openBlock(), createBlock(_sfc_main$6, {
            key: 0,
            type: "successFill",
            width: "24",
            height: "24",
            color: "#45ce03"
          })) : __props.type === "warning" ? (openBlock(), createBlock(_sfc_main$6, {
            key: 1,
            type: "warningFill",
            width: "24",
            height: "24",
            color: "#f3a401"
          })) : __props.type === "alert" ? (openBlock(), createBlock(_sfc_main$6, {
            key: 2,
            type: "tipsFill",
            width: "24",
            height: "24",
            color: "#1b9fff"
          })) : __props.type === "error" ? (openBlock(), createBlock(_sfc_main$6, {
            key: 3,
            type: "closeFill",
            width: "24",
            height: "24",
            color: "#ff2a2d"
          })) : createCommentVNode("", true)
        ]),
        createElementVNode("p", _hoisted_2$4, toDisplayString(__props.message), 1)
      ], 2)) : createCommentVNode("", true);
    };
  }
});
let mountNode = null;
var WlNotice = (options) => {
  const duration = options.duration | 2e3;
  if (mountNode) {
    document.body.removeChild(mountNode);
    mountNode = null;
  }
  const app = createVNode(_sfc_main$5, {
    ...options,
    duration,
    show_toast: true
  });
  const timer = setTimeout(() => {
    if (mountNode) {
      document.body.removeChild(mountNode);
      mountNode = null;
    }
    clearTimeout(timer);
  }, duration);
  mountNode = document.createElement("div");
  render(app, mountNode);
  document.body.appendChild(mountNode);
};
const getQueryVariable = (variable) => {
  const query = window.location.search.substring(1);
  const vars = query.split("&");
  for (let i = 0; i < vars.length; i++) {
    const pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return "";
};
const removeEmptyField = (obj) => {
  let newObj = {};
  if (typeof obj === "string") {
    obj = JSON.parse(obj);
  }
  if (obj instanceof Array) {
    newObj = [];
  }
  if (obj instanceof Object) {
    for (const attr in obj) {
      if (obj[attr] !== "" && obj[attr] !== null && obj[attr] !== void 0) {
        if (obj[attr] instanceof Object) {
          if (JSON.stringify(obj[attr]) === "{}" || JSON.stringify(obj[attr]) === "[]") {
            continue;
          }
          newObj[attr] = removeEmptyField(obj[attr]);
        } else if (typeof obj[attr] === "string" && (obj[attr].indexOf("{") > -1 && obj[attr].indexOf("}") > -1 || obj[attr].indexOf("[") > -1 && obj[attr].indexOf("]") > -1)) {
          try {
            const attrObj = JSON.parse(obj[attr]);
            if (attrObj instanceof Object) {
              newObj[attr] = removeEmptyField(attrObj);
            }
          } catch (e) {
            newObj[attr] = obj[attr];
          }
        } else {
          newObj[attr] = obj[attr];
        }
      }
    }
  }
  return newObj;
};
const typeDetection = (data) => {
  return Object.prototype.toString.call(data).replace(/\[object\s(\w+)\]/, "$1").toLowerCase();
};
function obj2String(obj, arr = [], idx = 0) {
  for (const item in obj) {
    arr[idx++] = [item, obj[item]];
  }
  return new URLSearchParams(arr).toString();
}
function getOptions(options) {
  const { sid = "", corp_id = "", card_resource = "" } = Store$1 != null ? Store$1 : {};
  const params = {
    sid,
    corp_id,
    card_resource,
    ...options
  };
  return obj2String(params);
}
const onHandleUrl = (url) => {
  const { node_env } = Store$1;
  const isPersonMiniApp = node_env.includes("xsf");
  if (isPersonMiniApp) {
    return setPersonMiniAppUrl(url);
  }
  return url;
};
const setPersonMiniAppUrl = (url) => {
  let filterUrl = url;
  if (filterUrl.includes("/api/user/share/path")) {
    filterUrl = filterUrl.replace(
      "/api/user/share/path",
      "/apise/material/share/path"
    );
  } else if (filterUrl.includes("/interact/")) {
    filterUrl = filterUrl.replace("/interact/", "/apise/");
  } else if (filterUrl.includes("/api/")) {
    filterUrl = filterUrl.replace("/api/", "/apise/");
  } else if (filterUrl.includes("/wx/track")) {
    filterUrl = filterUrl.replace("/wx/track", "/apise/track/wx/track");
  }
  return filterUrl;
};
function request(url, options, method = "GET") {
  const staticOption = {
    sid: Store$1.sid,
    corp_id: Store$1.corp_id,
    tab_change: 0
  };
  const data = {
    ...staticOption,
    ...options
  };
  const searchStr = getOptions(removeEmptyField(data));
  const staticSearchStr = getOptions(removeEmptyField(staticOption));
  let initObj = {};
  let params = "";
  if (method === "GET") {
    initObj = {
      method,
      credentials: "include",
      headers: new Headers({
        "access-auth-token": getQueryVariable("msid"),
        [token_key[Store$1.node_env]]: Store$1.token
      })
    };
    params = searchStr;
  } else if (method === "FormPOST") {
    initObj = {
      method: "POST",
      credentials: "include",
      headers: new Headers({
        [token_key[Store$1.node_env]]: Store$1.token
      }),
      body: options
    };
    params = staticSearchStr;
  } else {
    initObj = {
      method,
      credentials: "include",
      headers: new Headers({
        "access-auth-token": getQueryVariable("msid"),
        Accept: "application/json, text/plain, */*",
        "Content-Type": "application/json",
        [token_key[Store$1.node_env]]: Store$1.token
      }),
      body: JSON.stringify(data)
    };
    params = staticSearchStr;
  }
  const filterUrl = onHandleUrl(url) + "?" + params;
  return fetch(filterUrl, initObj).then((res) => {
    const isArea = url.includes("region.json");
    return res.json().then((result) => {
      var _a;
      if (result.code === 200 || isArea) {
        return result;
      } else {
        WlNotice({
          message: (_a = result.msg) != null ? _a : "\u670D\u52A1\u5668\u5185\u90E8\u9519\u8BEF",
          type: "error",
          duration: 3e3
        });
        throw Error(result);
      }
    });
  }).then((res) => {
    return res;
  });
}
const POST = (url, options) => {
  return request(url, options, "POST");
};
var Api = {
  getBusinessRelatedCustomerList(paramas) {
    return POST(
      `${proxy_api[Store$1.node_env]}/crm_v2/web/company/related_customer_list`,
      paramas
    );
  }
};
const domain = "https://wlmvp-cos.weiling.cn";
const defaultAvatar = domain + "/worktable-h5/icon/lxx-icon/default_head.png";
var CustomerList_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$4 = defineComponent({
  components: { VanCheckbox: Checkbox, VanCheckboxGroup: CheckboxGroup, VanCell: Cell, VanCellGroup: CellGroup },
  props: {
    data: {
      type: Array,
      default() {
        return [];
      }
    },
    checkedData: {
      type: Array,
      default() {
        return [];
      }
    },
    isRadio: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const state = reactive({
      checked: [],
      defaultAvatar,
      qwIcon: formatCosUrl("/worktable-h5/icon/lxx-icon/qw.png"),
      wechatIcon: formatCosUrl("/worktable-h5/icon/lxx-icon/wechat.png"),
      checkboxRefs: null,
      checkedList: []
    });
    const onToggle = (index, item) => {
      if (props.isRadio) {
        state.checked = [item.id];
        state.checkedList = [item];
        emit("onUserChange", state.checkedList);
        state.checkboxRefs[index].toggle();
        return;
      }
      if (state.checkedList.find((res) => res.id == item.id)) {
        state.checkedList = state.checkedList.filter(
          (res) => res.id != item.id
        );
      } else {
        state.checkedList.push(item);
      }
      emit("onUserChange", state.checkedList);
      state.checkboxRefs[index].toggle();
    };
    watch(
      () => props.checkedData,
      (res) => {
        if (!res)
          return;
        state.checked = res.map((item) => item.id);
        state.checkedList = [...res];
      },
      {
        immediate: true
      }
    );
    return {
      ...toRefs(state),
      onToggle
    };
  }
});
const _hoisted_1$3 = { class: "user_wrap flex-row cross-center" };
const _hoisted_2$3 = { class: "user_avatar" };
const _hoisted_3$3 = ["src"];
const _hoisted_4$3 = ["src"];
const _hoisted_5$3 = { class: "user_info" };
const _hoisted_6$1 = { class: "name" };
const _hoisted_7$1 = {
  key: 0,
  class: "company"
};
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_van_checkbox = resolveComponent("van-checkbox");
  const _component_van_cell = resolveComponent("van-cell");
  const _component_van_cell_group = resolveComponent("van-cell-group");
  const _component_van_checkbox_group = resolveComponent("van-checkbox-group");
  return openBlock(), createBlock(_component_van_checkbox_group, {
    modelValue: _ctx.checked,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.checked = $event)
  }, {
    default: withCtx(() => [
      _ctx.data.length ? (openBlock(), createBlock(_component_van_cell_group, {
        key: 0,
        border: false
      }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (item, index) => {
            return openBlock(), createBlock(_component_van_cell, {
              clickable: "",
              key: item.id,
              onClick: ($event) => _ctx.onToggle(index, item)
            }, {
              title: withCtx(() => [
                createElementVNode("div", _hoisted_1$3, [
                  createElementVNode("div", _hoisted_2$3, [
                    createElementVNode("img", {
                      class: "avatar",
                      src: item.head_img_url || _ctx.defaultAvatar,
                      alt: ""
                    }, null, 8, _hoisted_3$3),
                    createElementVNode("img", {
                      class: "icon",
                      src: item.type == 2 ? _ctx.qwIcon : _ctx.wechatIcon,
                      alt: ""
                    }, null, 8, _hoisted_4$3)
                  ]),
                  createElementVNode("div", _hoisted_5$3, [
                    createElementVNode("p", _hoisted_6$1, toDisplayString(item.nick_name), 1),
                    item.corp_name ? (openBlock(), createElementBlock("p", _hoisted_7$1, "@" + toDisplayString(item.corp_name), 1)) : createCommentVNode("", true)
                  ])
                ])
              ]),
              "right-icon": withCtx(() => [
                createVNode(_component_van_checkbox, {
                  name: item.id,
                  ref_for: true,
                  ref: "checkboxRefs"
                }, null, 8, ["name"])
              ]),
              _: 2
            }, 1032, ["onClick"]);
          }), 128))
        ]),
        _: 1
      })) : createCommentVNode("", true)
    ]),
    _: 1
  }, 8, ["modelValue"]);
}
var CustomerList = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4], ["__scopeId", "data-v-fbab9ade"]]);
var ClueList_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$3 = defineComponent({
  components: { VanCheckbox: Checkbox, VanCheckboxGroup: CheckboxGroup, VanCell: Cell, VanCellGroup: CellGroup },
  props: {
    data: {
      type: Array,
      default() {
        return [];
      }
    },
    checkedData: {
      type: Array,
      default() {
        return [];
      }
    },
    isRadio: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const state = reactive({
      checked: [],
      checkboxRefs: null,
      checkedList: []
    });
    const onToggle = (index, item) => {
      if (props.isRadio) {
        state.checked = [item.id];
        state.checkedList = [item];
        emit("onUserChange", state.checkedList);
        state.checkboxRefs[index].toggle();
        return;
      }
      if (state.checkedList.find(
        (res) => (res.clue_id || res.id) == item.clue_id
      )) {
        state.checkedList = state.checkedList.filter(
          (res) => (res.clue_id || res.id) != item.clue_id
        );
      } else {
        state.checkedList.push(item);
      }
      emit("onUserChange", state.checkedList);
      state.checkboxRefs[index].toggle();
    };
    watch(
      () => props.checkedData,
      (res) => {
        if (!res)
          return;
        state.checked = res.map((item) => item.clue_id || item.id);
        state.checkedList = [...res];
      },
      {
        immediate: true
      }
    );
    return {
      ...toRefs(state),
      onToggle
    };
  }
});
const _hoisted_1$2 = { class: "user_wrap flex-row cross-center" };
const _hoisted_2$2 = { class: "user_avatar flex-center" };
const _hoisted_3$2 = { class: "user_info" };
const _hoisted_4$2 = { class: "name" };
const _hoisted_5$2 = { class: "name" };
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_van_checkbox = resolveComponent("van-checkbox");
  const _component_van_cell = resolveComponent("van-cell");
  const _component_van_cell_group = resolveComponent("van-cell-group");
  const _component_van_checkbox_group = resolveComponent("van-checkbox-group");
  return openBlock(), createBlock(_component_van_checkbox_group, {
    modelValue: _ctx.checked,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.checked = $event)
  }, {
    default: withCtx(() => [
      _ctx.data.length ? (openBlock(), createBlock(_component_van_cell_group, {
        key: 0,
        border: false
      }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (item, index) => {
            return openBlock(), createBlock(_component_van_cell, {
              clickable: "",
              key: item.clue_id || item.id,
              onClick: ($event) => _ctx.onToggle(index, item)
            }, {
              title: withCtx(() => [
                createElementVNode("div", _hoisted_1$2, [
                  createElementVNode("div", _hoisted_2$2, toDisplayString(item.user_name ? item.user_name.substr(0, 1) : "-"), 1),
                  createElementVNode("div", _hoisted_3$2, [
                    createElementVNode("p", _hoisted_4$2, toDisplayString(item.user_name), 1),
                    createElementVNode("p", _hoisted_5$2, toDisplayString(item.mobile), 1)
                  ])
                ])
              ]),
              "right-icon": withCtx(() => [
                createVNode(_component_van_checkbox, {
                  name: item.clue_id || item.id,
                  ref_for: true,
                  ref: "checkboxRefs"
                }, null, 8, ["name"])
              ]),
              _: 2
            }, 1032, ["onClick"]);
          }), 128))
        ]),
        _: 1
      })) : createCommentVNode("", true)
    ]),
    _: 1
  }, 8, ["modelValue"]);
}
var ClueList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__scopeId", "data-v-2118816b"]]);
var WechatList_vue_vue_type_style_index_0_scoped_true_lang = "";
const _sfc_main$2 = defineComponent({
  components: { VanCheckbox: Checkbox, VanCheckboxGroup: CheckboxGroup, VanCell: Cell, VanCellGroup: CellGroup },
  props: {
    data: {
      type: Array,
      default() {
        return [];
      }
    },
    checkedData: {
      type: Array,
      default() {
        return [];
      }
    },
    isRadio: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const state = reactive({
      checked: [],
      defaultAvatar,
      qwIcon: formatCosUrl("/worktable-h5/icon/lxx-icon/qw.png"),
      wechatIcon: formatCosUrl("/worktable-h5/icon/lxx-icon/wechat.png"),
      checkboxRefs: null,
      checkedList: []
    });
    const onToggle = (index, item) => {
      if (props.isRadio) {
        state.checked = [item.id];
        state.checkedList = [item];
        emit("onUserChange", state.checkedList);
        state.checkboxRefs[index].toggle();
        return;
      }
      if (state.checkedList.find((res) => res.id == item.id)) {
        state.checkedList = state.checkedList.filter(
          (res) => res.id != item.id
        );
      } else {
        state.checkedList.push(item);
      }
      emit("onUserChange", state.checkedList);
      state.checkboxRefs[index].toggle();
    };
    watch(
      () => props.checkedData,
      (res) => {
        if (!res)
          return;
        state.checked = res.map((item) => item.id);
        state.checkedList = [...res];
      },
      {
        immediate: true
      }
    );
    return {
      ...toRefs(state),
      onToggle
    };
  }
});
const _hoisted_1$1 = { class: "user_wrap flex-row cross-center" };
const _hoisted_2$1 = { class: "user_avatar" };
const _hoisted_3$1 = ["src"];
const _hoisted_4$1 = ["src"];
const _hoisted_5$1 = { class: "user_info" };
const _hoisted_6 = { class: "name" };
const _hoisted_7 = {
  key: 0,
  class: "company"
};
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_van_checkbox = resolveComponent("van-checkbox");
  const _component_van_cell = resolveComponent("van-cell");
  const _component_van_cell_group = resolveComponent("van-cell-group");
  const _component_van_checkbox_group = resolveComponent("van-checkbox-group");
  return openBlock(), createBlock(_component_van_checkbox_group, {
    modelValue: _ctx.checked,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.checked = $event)
  }, {
    default: withCtx(() => [
      _ctx.data.length ? (openBlock(), createBlock(_component_van_cell_group, {
        key: 0,
        border: false
      }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (item, index) => {
            return openBlock(), createBlock(_component_van_cell, {
              clickable: "",
              key: item.id,
              onClick: ($event) => _ctx.onToggle(index, item)
            }, {
              title: withCtx(() => [
                createElementVNode("div", _hoisted_1$1, [
                  createElementVNode("div", _hoisted_2$1, [
                    createElementVNode("img", {
                      class: "avatar",
                      src: item.headimgurl || _ctx.defaultAvatar,
                      alt: ""
                    }, null, 8, _hoisted_3$1),
                    createElementVNode("img", {
                      class: "icon",
                      src: item.user_type == 1 ? _ctx.wechatIcon : _ctx.qwIcon,
                      alt: ""
                    }, null, 8, _hoisted_4$1)
                  ]),
                  createElementVNode("div", _hoisted_5$1, [
                    createElementVNode("p", _hoisted_6, toDisplayString(item.nickname), 1),
                    item.corp_name ? (openBlock(), createElementBlock("p", _hoisted_7, "@" + toDisplayString(item.corp_name), 1)) : createCommentVNode("", true)
                  ])
                ])
              ]),
              "right-icon": withCtx(() => [
                createVNode(_component_van_checkbox, {
                  name: item.id,
                  ref_for: true,
                  ref: "checkboxRefs"
                }, null, 8, ["name"])
              ]),
              _: 2
            }, 1032, ["onClick"]);
          }), 128))
        ]),
        _: 1
      })) : createCommentVNode("", true)
    ]),
    _: 1
  }, 8, ["modelValue"]);
}
var WechatList = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-6109b698"]]);
const _sfc_main$1 = defineComponent({
  name: "VLoadMore",
  props: {
    value: {
      type: Boolean,
      default: false
    },
    "finished-text": {
      type: String,
      default: "\u6CA1\u6709\u66F4\u591A\u4E86"
    }
  },
  components: { VanList: List },
  setup(props, { emit }) {
    const loadShow = ref(false);
    watch(
      () => props.value,
      (val) => loadShow.value = val
    );
    watch(
      () => loadShow.value,
      (val) => emit("update:value", val)
    );
    return {
      loadShow
    };
  }
});
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_van_list = resolveComponent("van-list");
  return openBlock(), createBlock(_component_van_list, mergeProps({
    loading: _ctx.loadShow,
    "onUpdate:loading": _cache[0] || (_cache[0] = ($event) => _ctx.loadShow = $event)
  }, _ctx.$attrs, { "finished-text": _ctx.finishedText }), {
    default: withCtx(() => [
      renderSlot(_ctx.$slots, "default")
    ]),
    _: 3
  }, 16, ["loading", "finished-text"]);
}
var VLoadMore = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
const usePagination = () => {
  const State = reactive({
    limit: 10,
    page_count: 1,
    isLoading: false,
    isFinished: false,
    cursor: ""
  });
  const judgeLoadStatus = (result) => {
    const { data_list, cursor } = result;
    State.isLoading = false;
    State.cursor = cursor || "";
    if ("data_list" in result && data_list && data_list.length < State.limit)
      State.isFinished = true;
    if ("cursor" in result && !cursor) {
      State.isFinished = true;
    }
    State.page_count++;
  };
  return {
    ...toRefs(State),
    judgeLoadStatus
  };
};
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
var freeGlobal$1 = freeGlobal;
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
var root = freeGlobal$1 || freeSelf || Function("return this")();
var root$1 = root;
var Symbol$1 = root$1.Symbol;
var Symbol$2 = Symbol$1;
var objectProto$1 = Object.prototype;
var hasOwnProperty = objectProto$1.hasOwnProperty;
var nativeObjectToString$1 = objectProto$1.toString;
var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0;
function getRawTag(value) {
  var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
  try {
    value[symToStringTag$1] = void 0;
    var unmasked = true;
  } catch (e) {
  }
  var result = nativeObjectToString$1.call(value);
  if (unmasked) {
    if (isOwn) {
      value[symToStringTag$1] = tag;
    } else {
      delete value[symToStringTag$1];
    }
  }
  return result;
}
var objectProto = Object.prototype;
var nativeObjectToString = objectProto.toString;
function objectToString(value) {
  return nativeObjectToString.call(value);
}
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
function baseGetTag(value) {
  if (value == null) {
    return value === void 0 ? undefinedTag : nullTag;
  }
  return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
}
function isObjectLike(value) {
  return value != null && typeof value == "object";
}
var symbolTag = "[object Symbol]";
function isSymbol(value) {
  return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
}
var reWhitespace = /\s/;
function trimmedEndIndex(string) {
  var index = string.length;
  while (index-- && reWhitespace.test(string.charAt(index))) {
  }
  return index;
}
var reTrimStart = /^\s+/;
function baseTrim(string) {
  return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
}
function isObject(value) {
  var type = typeof value;
  return value != null && (type == "object" || type == "function");
}
var NAN = 0 / 0;
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
var reIsBinary = /^0b[01]+$/i;
var reIsOctal = /^0o[0-7]+$/i;
var freeParseInt = parseInt;
function toNumber(value) {
  if (typeof value == "number") {
    return value;
  }
  if (isSymbol(value)) {
    return NAN;
  }
  if (isObject(value)) {
    var other = typeof value.valueOf == "function" ? value.valueOf() : value;
    value = isObject(other) ? other + "" : other;
  }
  if (typeof value != "string") {
    return value === 0 ? value : +value;
  }
  value = baseTrim(value);
  var isBinary = reIsBinary.test(value);
  return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
}
var now = function() {
  return root$1.Date.now();
};
var now$1 = now;
var FUNC_ERROR_TEXT = "Expected a function";
var nativeMax = Math.max, nativeMin = Math.min;
function debounce(func, wait, options) {
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
  if (typeof func != "function") {
    throw new TypeError(FUNC_ERROR_TEXT);
  }
  wait = toNumber(wait) || 0;
  if (isObject(options)) {
    leading = !!options.leading;
    maxing = "maxWait" in options;
    maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
    trailing = "trailing" in options ? !!options.trailing : trailing;
  }
  function invokeFunc(time) {
    var args = lastArgs, thisArg = lastThis;
    lastArgs = lastThis = void 0;
    lastInvokeTime = time;
    result = func.apply(thisArg, args);
    return result;
  }
  function leadingEdge(time) {
    lastInvokeTime = time;
    timerId = setTimeout(timerExpired, wait);
    return leading ? invokeFunc(time) : result;
  }
  function remainingWait(time) {
    var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
    return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
  }
  function shouldInvoke(time) {
    var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
    return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
  }
  function timerExpired() {
    var time = now$1();
    if (shouldInvoke(time)) {
      return trailingEdge(time);
    }
    timerId = setTimeout(timerExpired, remainingWait(time));
  }
  function trailingEdge(time) {
    timerId = void 0;
    if (trailing && lastArgs) {
      return invokeFunc(time);
    }
    lastArgs = lastThis = void 0;
    return result;
  }
  function cancel() {
    if (timerId !== void 0) {
      clearTimeout(timerId);
    }
    lastInvokeTime = 0;
    lastArgs = lastCallTime = lastThis = timerId = void 0;
  }
  function flush() {
    return timerId === void 0 ? result : trailingEdge(now$1());
  }
  function debounced() {
    var time = now$1(), isInvoking = shouldInvoke(time);
    lastArgs = arguments;
    lastThis = this;
    lastCallTime = time;
    if (isInvoking) {
      if (timerId === void 0) {
        return leadingEdge(lastCallTime);
      }
      if (maxing) {
        clearTimeout(timerId);
        timerId = setTimeout(timerExpired, wait);
        return invokeFunc(lastCallTime);
      }
    }
    if (timerId === void 0) {
      timerId = setTimeout(timerExpired, wait);
    }
    return result;
  }
  debounced.cancel = cancel;
  debounced.flush = flush;
  return debounced;
}
var index_vue_vue_type_style_index_0_lang = "";
var index_vue_vue_type_style_index_1_scoped_true_lang = "";
const _sfc_main = defineComponent({
  components: { TabMulte, CustomerList, ClueList, WechatList, VSearch, VanActionSheet: ActionSheet, VLoadMore },
  props: {
    value: {
      type: Boolean,
      default: false
    },
    data: {
      type: Array || Object,
      default() {
        return [];
      }
    },
    title: {
      type: String,
      default: "\u9009\u62E9\u5BF9\u63A5\u4EBA"
    },
    env_data: {
      type: Object,
      default: () => {
        return {
          sid: "",
          domain: "",
          corp_id: "",
          node_env: "uat",
          app_id: "",
          token: "",
          card_resource: ""
        };
      }
    },
    tabChangeClear: {
      type: Boolean,
      default: false
    },
    tabTypes: {
      type: Array,
      default: () => {
        return [1, 2, 3];
      }
    },
    isRadio: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    var _a;
    const { limit, page_count, isLoading, isFinished, judgeLoadStatus } = usePagination();
    Store$1.corp_id = props.env_data.corp_id;
    Store$1.node_env = props.env_data.node_env;
    Store$1.sid = props.env_data.sid;
    Store$1.token = props.env_data.token;
    Store$1.card_resource = props.env_data.card_resource;
    const state = reactive({
      show: false,
      keyword: "",
      checkCustomer: [],
      checkClue: [],
      type: ((_a = props.tabTypes) == null ? void 0 : _a[0]) || 1,
      checkWechat: [],
      clueList: [],
      wechatList: [],
      customerList: []
    });
    let EnumType;
    ((EnumType2) => {
      EnumType2[EnumType2["customerList"] = 1] = "customerList";
      EnumType2[EnumType2["wechatList"] = 2] = "wechatList";
      EnumType2[EnumType2["clueList"] = 3] = "clueList";
    })(EnumType || (EnumType = {}));
    const Methods = {
      onTabChange(res) {
        const { type } = res;
        state.type = type;
        page_count.value = 1;
        isFinished.value = false;
        Methods.onGetList();
      },
      onGetList: async () => {
        isLoading.value = true;
        const params = {
          type: state.type,
          page: {
            page_count: page_count.value,
            limit: limit.value,
            keyword: state.keyword
          },
          version_flag: 2
        };
        if (page_count.value == 1)
          state[EnumType[params.type]] = [];
        const { data } = await Api.getBusinessRelatedCustomerList(params);
        const data_list = data.data_list || [];
        state[EnumType[params.type]] = [
          ...state[EnumType[params.type]],
          ...data_list
        ];
        judgeLoadStatus({ data_list });
      },
      onCustomerChange(res) {
        console.log(res, "cuatomer");
        if (props.isRadio) {
          state.checkClue = [];
          state.checkWechat = [];
        }
        state.checkCustomer = res;
      },
      onClueChange(res) {
        console.log(res, "clue");
        if (props.isRadio) {
          state.checkCustomer = [];
          state.checkWechat = [];
        }
        state.checkClue = res;
      },
      onWechatChange(res) {
        if (props.isRadio) {
          state.checkCustomer = [];
          state.checkClue = [];
        }
        state.checkWechat = res;
      },
      onInput: debounce((res) => {
        state.keyword = res;
        page_count.value = 1;
        Methods.onGetList();
      }, 300),
      onSub() {
        var _a2, _b, _c;
        let arr1 = (_a2 = state.checkCustomer) == null ? void 0 : _a2.map((item) => {
          return {
            user_type: 1,
            ...item
          };
        });
        let arr2 = (_b = state.checkWechat) == null ? void 0 : _b.map((item) => {
          return {
            ...item,
            user_type: 2
          };
        });
        let arr3 = (_c = state.checkClue) == null ? void 0 : _c.map((item) => {
          return {
            user_type: 3,
            id: item.clue_id,
            ...item
          };
        });
        if (props.isRadio) {
          emit("onHandleChoose", ...[...arr1, ...arr2, ...arr3]);
          state.show = false;
          return;
        }
        if (!props.tabChangeClear) {
          emit("onHandleChoose", [...arr1, ...arr2, ...arr3]);
          state.show = false;
          return;
        }
        if (state.type == 1) {
          emit("onHandleChoose", arr1);
        }
        if (state.type == 2) {
          emit("onHandleChoose", arr2);
        }
        if (state.type == 3) {
          emit("onHandleChoose", arr3);
        }
        state.show = false;
      }
    };
    watch(
      () => props.value,
      (val) => {
        state.show = val;
      }
    );
    watch(
      () => state.show,
      (bol) => {
        if (!bol)
          emit("update:value", false);
      }
    );
    watch(
      () => props.data,
      (res) => {
        let val = res;
        if (typeDetection(res) === "object")
          val = [res];
        state.checkCustomer = val.filter((item) => item.user_type == 1) || [];
        state.checkWechat = val.filter((item) => item.user_type == 2) || [];
        state.checkClue = val.filter((item) => {
          return item.user_type == 3;
        }) || [];
      },
      {
        deep: true,
        immediate: true
      }
    );
    return {
      ...toRefs(state),
      isLoading,
      isFinished,
      ...Methods
    };
  }
});
const _hoisted_1 = { class: "content flex-column" };
const _hoisted_2 = { class: "search_wrap flex0" };
const _hoisted_3 = { class: "tab_wrap flex0" };
const _hoisted_4 = { class: "flex1 info_wrap" };
const _hoisted_5 = { class: "flex-center flex0" };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_VSearch = resolveComponent("VSearch");
  const _component_TabMulte = resolveComponent("TabMulte");
  const _component_CustomerList = resolveComponent("CustomerList");
  const _component_WechatList = resolveComponent("WechatList");
  const _component_ClueList = resolveComponent("ClueList");
  const _component_VLoadMore = resolveComponent("VLoadMore");
  const _component_van_action_sheet = resolveComponent("van-action-sheet");
  return openBlock(), createBlock(_component_van_action_sheet, {
    show: _ctx.show,
    "onUpdate:show": _cache[3] || (_cache[3] = ($event) => _ctx.show = $event),
    title: _ctx.title,
    class: "BCMulteTypePersonnerSelect",
    teleport: "body"
  }, {
    default: withCtx(() => [
      createElementVNode("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          createVNode(_component_VSearch, {
            placeholder: "\u641C\u7D22",
            modelValue: _ctx.keyword,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.keyword = $event),
            onOnChange: _ctx.onInput,
            closable: ""
          }, null, 8, ["modelValue", "onOnChange"])
        ]),
        createElementVNode("div", _hoisted_3, [
          createVNode(_component_TabMulte, {
            tabTypes: _ctx.tabTypes,
            onOnTabChange: _ctx.onTabChange
          }, null, 8, ["tabTypes", "onOnTabChange"])
        ]),
        createElementVNode("div", _hoisted_4, [
          createVNode(_component_VLoadMore, {
            value: _ctx.isLoading,
            "onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.isLoading = $event),
            finished: _ctx.isFinished,
            onLoad: _ctx.onGetList
          }, {
            default: withCtx(() => [
              _ctx.type == 1 && _ctx.customerList.length ? (openBlock(), createBlock(_component_CustomerList, {
                key: 0,
                data: _ctx.customerList,
                isRadio: _ctx.isRadio,
                onOnUserChange: _ctx.onCustomerChange,
                checkedData: _ctx.checkCustomer
              }, null, 8, ["data", "isRadio", "onOnUserChange", "checkedData"])) : createCommentVNode("", true),
              _ctx.type == 2 && _ctx.wechatList.length ? (openBlock(), createBlock(_component_WechatList, {
                key: 1,
                data: _ctx.wechatList,
                isRadio: _ctx.isRadio,
                onOnUserChange: _ctx.onWechatChange,
                checkedData: _ctx.checkWechat
              }, null, 8, ["data", "isRadio", "onOnUserChange", "checkedData"])) : createCommentVNode("", true),
              _ctx.type == 3 && _ctx.clueList.length ? (openBlock(), createBlock(_component_ClueList, {
                key: 2,
                data: _ctx.clueList,
                isRadio: _ctx.isRadio,
                onOnUserChange: _ctx.onClueChange,
                checkedData: _ctx.checkClue
              }, null, 8, ["data", "isRadio", "onOnUserChange", "checkedData"])) : createCommentVNode("", true)
            ]),
            _: 1
          }, 8, ["value", "finished", "onLoad"])
        ]),
        createElementVNode("footer", _hoisted_5, [
          createElementVNode("p", {
            class: "flex-center",
            onClick: _cache[2] || (_cache[2] = withModifiers((...args) => _ctx.onSub && _ctx.onSub(...args), ["stop"]))
          }, "\u786E\u8BA4\u9009\u62E9")
        ])
      ])
    ]),
    _: 1
  }, 8, ["show", "title"]);
}
var Comp = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-b1b50190"]]);
var __uno = "";
Comp.install = (app) => {
  app.component(Comp.name, Comp);
};
export { Comp as default };
