@cgboiler/biz-mobile 1.17.7 → 1.17.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.d.ts CHANGED
@@ -7,7 +7,7 @@ declare namespace _default {
7
7
  }
8
8
  export default _default;
9
9
  export function install(app: any): void;
10
- export const version: "1.17.6";
10
+ export const version: "1.17.7";
11
11
  import MdPreview from './md-preview';
12
12
  import OrgPicker from './org-picker';
13
13
  import ProjectSelect from './project-select';
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import MdPreview from "./md-preview";
2
2
  import OrgPicker from "./org-picker";
3
3
  import ProjectSelect from "./project-select";
4
- const version = "1.17.6";
4
+ const version = "1.17.7";
5
5
  function install(app) {
6
6
  const components = [
7
7
  MdPreview,
@@ -1,32 +1,12 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
1
  import { createVNode as _createVNode, createTextVNode as _createTextVNode, Fragment as _Fragment } from "vue";
22
2
  import "./_atomic.css";
23
- import { defineComponent, ref, computed, watch, nextTick } from "vue";
3
+ import { defineComponent, ref, computed, watch } from "vue";
24
4
  import { ActionSheet, Search, List, Image, Empty, Tabs, Tab } from "vant";
25
5
  import DeptImg from "./components/DeptImg";
26
6
  import { orgPickerProps } from "./types";
27
7
  import { useApi } from "./useApi";
28
8
  import "./index.css";
29
- import { watchEffect, h } from "vue";
9
+ import { useSearch } from "./useSearch";
30
10
  var stdin_default = defineComponent({
31
11
  name: "OrgPicker",
32
12
  props: orgPickerProps,
@@ -34,19 +14,29 @@ var stdin_default = defineComponent({
34
14
  setup(props, {
35
15
  emit
36
16
  }) {
17
+ const api = useApi();
37
18
  const {
38
- orgList,
39
19
  getOrgList,
40
- currentDeptId,
20
+ orgList,
41
21
  deptPath,
42
- searchOrgList,
43
22
  userList,
44
- getRecentSelectedUsers,
45
23
  setRecentSelectedUsers
46
- } = useApi();
24
+ } = api;
47
25
  getOrgList();
48
- const activeTab = ref("zjxz");
26
+ const activeTab = ref("txl");
27
+ const {
28
+ keyword,
29
+ searchRef,
30
+ recentSelectedHistory,
31
+ highlightText,
32
+ renderSearchResult
33
+ } = useSearch(props, api);
49
34
  const selectedItems = ref([]);
35
+ const sortOrgList = computed(() => {
36
+ const departments = orgList.value.filter((item) => item.type === "dept");
37
+ const personnel = orgList.value.filter((item) => item.type !== "dept");
38
+ return [...personnel, ...departments];
39
+ });
50
40
  watch(() => props.modelValue, (newValue) => {
51
41
  var _a;
52
42
  if (!newValue) {
@@ -88,65 +78,9 @@ var stdin_default = defineComponent({
88
78
  emit("update:modelValue", selectedItems.value.map((item) => item.id));
89
79
  setRecentSelectedUsers(selectedItems.value);
90
80
  };
91
- const keyword = ref("");
92
- const loading = ref(false);
93
- const finished = ref(true);
94
- const searchRef = ref();
95
- const recentSelectedHistory = ref([]);
96
- const filterRecentSelectedHistory = ref([]);
97
- watchEffect(() => {
98
- if (activeTab.value === "zjxz") {
99
- recentSelectedHistory.value = getRecentSelectedUsers();
100
- }
101
- });
102
- watchEffect(() => {
103
- if (activeTab.value === "zjxz") {
104
- if (keyword.value) {
105
- filterRecentSelectedHistory.value = recentSelectedHistory.value.filter((item) => item.selectedUsers.some((user) => keyword.value.split("").some((char) => user.name.includes(char))));
106
- } else {
107
- filterRecentSelectedHistory.value = recentSelectedHistory.value;
108
- }
109
- }
110
- });
111
- watch(() => props.show, (newVal) => __async(this, null, function* () {
112
- if (newVal && props.autoFocus) {
113
- yield nextTick();
114
- setTimeout(() => {
115
- var _a;
116
- (_a = searchRef.value) == null ? void 0 : _a.focus();
117
- }, 300);
118
- }
119
- }));
120
- watch(keyword, (newKeyword) => {
121
- if (newKeyword) {
122
- searchOrgList(newKeyword);
123
- } else {
124
- getOrgList(currentDeptId.value);
125
- }
126
- });
127
- const filteredOrgList = computed(() => {
128
- if (keyword.value) {
129
- return orgList.value;
130
- }
131
- const departments = orgList.value.filter((item) => item.type === "dept");
132
- const personnel = orgList.value.filter((item) => item.type !== "dept");
133
- return [...personnel, ...departments];
134
- });
135
81
  const isSelected = (item) => {
136
82
  return selectedItems.value.some((s) => s.id === item.id);
137
83
  };
138
- const onLoad = () => {
139
- finished.value = true;
140
- };
141
- const highlightText = (text, keyword2) => {
142
- if (!keyword2) {
143
- return text;
144
- }
145
- const keywordChars = keyword2.split("");
146
- return Array.from(text).map((char, index) => keywordChars.some((kChar) => char.toLowerCase() === kChar.toLowerCase()) ? h("span", {
147
- class: "highlight"
148
- }, char) : char);
149
- };
150
84
  return () => _createVNode(ActionSheet, {
151
85
  "show": props.show,
152
86
  "onUpdate:show": (val) => emit("update:show", val),
@@ -174,28 +108,30 @@ var stdin_default = defineComponent({
174
108
  "class": "close-icon"
175
109
  }, [_createTextVNode("X")])])) : _createVNode("p", {
176
110
  "class": "color-[#aaa] text-[14px] text-center w-full leading-[38px]"
177
- }, [_createTextVNode("\u672A\u9009\u62E9\u4EBA\u5458")])]), _createVNode(Tabs, {
111
+ }, [_createTextVNode("\u672A\u9009\u62E9\u4EBA\u5458")])]), _createVNode("div", {
112
+ "class": "flex-1 flex flex-col overflow-hidden relative"
113
+ }, [_createVNode(Tabs, {
178
114
  "active": activeTab.value,
179
115
  "onUpdate:active": ($event) => activeTab.value = $event
180
116
  }, {
181
117
  default: () => [_createVNode(Tab, {
182
- "title": "\u6700\u8FD1\u9009\u62E9",
183
- "name": "zjxz"
184
- }, null), _createVNode(Tab, {
185
118
  "title": "\u901A\u8BAF\u5F55",
186
119
  "name": "txl"
120
+ }, null), _createVNode(Tab, {
121
+ "title": "\u6700\u8FD1\u9009\u62E9",
122
+ "name": "zjxz"
187
123
  }, null)]
188
124
  }), _createVNode("div", {
189
125
  "class": "org-content-wrap"
190
126
  }, [activeTab.value === "zjxz" ? _createVNode("div", {
191
127
  "class": "recent-list-wrap flex-1 overflow-auto px-[16px] py-[8px]"
192
- }, [filterRecentSelectedHistory.value.length === 0 ? _createVNode(Empty, {
128
+ }, [recentSelectedHistory.value.length === 0 ? _createVNode(Empty, {
193
129
  "description": "\u6682\u65E0\u6700\u8FD1\u9009\u62E9\u8BB0\u5F55"
194
- }, null) : filterRecentSelectedHistory.value.map((historyItem) => _createVNode("div", {
130
+ }, null) : recentSelectedHistory.value.map((historyItem) => _createVNode("div", {
195
131
  "key": historyItem.id,
196
132
  "onClick": () => handleHistorySelect(historyItem),
197
133
  "class": "px-16px py-8px border-b border-[#eee]"
198
- }, [_createVNode("span", null, [historyItem.selectedUsers.map((user) => highlightText(user.name, keyword.value)).reduce((prev, curr) => [prev, "\uFF0C", curr])])]))]) : _createVNode(_Fragment, null, [!keyword.value && _createVNode("div", {
134
+ }, [_createVNode("span", null, [historyItem.selectedUsers.map((user) => highlightText(user.name, keyword.value)).reduce((prev, curr) => [prev, "\uFF0C", curr])])]))]) : _createVNode(_Fragment, null, [_createVNode("div", {
199
135
  "class": "breadcrumb-nav"
200
136
  }, [deptPath.value.map((dept, index) => _createVNode("span", {
201
137
  "key": dept.id
@@ -209,14 +145,10 @@ var stdin_default = defineComponent({
209
145
  "class": "separator"
210
146
  }, [_createTextVNode(" / ")])]))]), _createVNode("div", {
211
147
  "class": "feed-list-wrap"
212
- }, [filteredOrgList.value.length === 0 ? _createVNode(Empty, {
213
- "description": keyword.value ? "\u672A\u627E\u5230\u76F8\u5173\u4EBA\u5458" : "\u8BE5\u90E8\u95E8\u4E0B\u6CA1\u6709\u4EBA\u5458"
214
- }, null) : _createVNode(List, {
215
- "loading": loading.value,
216
- "finished": finished.value,
217
- "onLoad": onLoad
218
- }, {
219
- default: () => [filteredOrgList.value.map((item) => _createVNode("div", {
148
+ }, [sortOrgList.value.length === 0 ? _createVNode(Empty, {
149
+ "description": "\u8BE5\u90E8\u95E8\u4E0B\u6CA1\u6709\u4EBA\u5458"
150
+ }, null) : _createVNode(List, null, {
151
+ default: () => [sortOrgList.value.map((item) => _createVNode("div", {
220
152
  "class": ["org-item", isSelected(item) ? "selected" : ""],
221
153
  "onClick": () => handleSelect(item)
222
154
  }, [item.type === "dept" && !keyword.value ? _createVNode("div", {
@@ -229,7 +161,11 @@ var stdin_default = defineComponent({
229
161
  }, [item.name, _createVNode("span", {
230
162
  "class": "org-item-select-icon"
231
163
  }, [_createTextVNode("\u2713")])])]))]
232
- })])])]), props.multiple && _createVNode("div", {
164
+ })])])]), keyword.value && renderSearchResult({
165
+ handleHistorySelect,
166
+ isSelected,
167
+ handleSelect
168
+ })]), props.multiple && _createVNode("div", {
233
169
  "class": "bottom-section"
234
170
  }, [_createVNode("div", {
235
171
  "class": "action-buttons"
@@ -31,9 +31,33 @@
31
31
  }
32
32
 
33
33
  /* layer: default */
34
+ .cgx-atm .absolute{position:absolute;}
35
+ .cgx-atm .bottom-0{bottom:0rem;}
36
+ .cgx-atm .left-0{left:0rem;}
37
+ .cgx-atm .right-0{right:0rem;}
38
+ .cgx-atm .top-0{top:0rem;}
39
+ .cgx-atm .z-1{z-index:1;}
40
+ .cgx-atm .flex-1{flex:1 1 0%;}
41
+ .cgx-atm .overflow-auto{overflow:auto;}
42
+ .cgx-atm .border-b{border-bottom-width:1px;border-bottom-style:solid;}
43
+ .cgx-atm .border-\[\#eee\]{--un-border-opacity:1;border-color:rgba(238,238,238,var(--un-border-opacity));}
44
+ .cgx-atm .bg-\[\#fff\]{--un-bg-opacity:1;background-color:rgba(255,255,255,var(--un-bg-opacity));}
45
+ .cgx-atm .px-\[16px\],
46
+ .cgx-atm .px-16px{padding-left:16px;padding-right:16px;}
47
+ .cgx-atm .py-\[12px\]{padding-top:12px;padding-bottom:12px;}
48
+ .cgx-atm .py-\[8px\],
49
+ .cgx-atm .py-8px{padding-top:8px;padding-bottom:8px;}
50
+ .cgx-atm .text-\[14px\]{font-size:14px;}
51
+ .cgx-atm .font-bold{font-weight:700;}
52
+ .cgx-atm .text-\[\#333\]{--un-text-opacity:1;color:rgba(51,51,51,var(--un-text-opacity));}
53
+ /* layer: default */
54
+ .cgx-atm .relative{position:relative;}
34
55
  .cgx-atm .w-full{width:100%;}
56
+ .cgx-atm .flex{display:flex;}
35
57
  .cgx-atm .flex-1{flex:1 1 0%;}
58
+ .cgx-atm .flex-col{flex-direction:column;}
36
59
  .cgx-atm .overflow-auto{overflow:auto;}
60
+ .cgx-atm .overflow-hidden{overflow:hidden;}
37
61
  .cgx-atm .border-b{border-bottom-width:1px;border-bottom-style:solid;}
38
62
  .cgx-atm .border-\[\#eee\]{--un-border-opacity:1;border-color:rgba(238,238,238,var(--un-border-opacity));}
39
63
  .cgx-atm .px-\[16px\],
@@ -1 +1 @@
1
- :root:root{--van-action-sheet-max-height: 100%}.org-list{height:85vh;display:flex;flex-direction:column}.org-list .highlight{color:var(--van-primary-color);font-weight:700}.org-list .breadcrumb-nav{margin-bottom:4px;padding:2px 16px;border-radius:4px;font-size:12px}.org-list .breadcrumb-nav .dept-name.current-dept{color:#969799}.org-list .breadcrumb-nav .separator{color:#969799;margin:0 4px}.org-list .search-bar{position:-webkit-sticky;position:-webkit-sticky;position:sticky;top:0;z-index:1}.org-list .org-selected-items{display:flex;flex-wrap:nowrap;padding:12px 16px;gap:12px;background-color:#fff;overflow-x:auto;height:68px;border-bottom:1px solid #eee}.org-list .org-selected-items .selected-tag{flex-shrink:0;background:none;border:none;padding:0;margin:0;position:relative}.org-list .org-selected-items .selected-tag .close-icon{position:absolute;top:0;right:0;z-index:1;background-color:#fff;border-radius:50%;border:1px solid #eee;width:10px;height:10px;display:flex;align-items:center;justify-content:center;font-size:6px;color:#969799}.org-list .org-selected-items .selected-tag .tag-avatar{width:40px;height:40px}.org-list .org-selected-items .selected-tag .tag-avatar img{border-radius:4px;border:1px solid #eee;object-fit:contain}.org-list .bottom-section{border-top:1px solid #eee;background-color:#fff}.org-list .van-list{flex:1;overflow-y:auto;padding:0 16px}.org-list .org-content-wrap{flex:1;display:flex;flex-direction:column;overflow:hidden}.org-list .feed-list-wrap{flex:1;display:flex;overflow:hidden;position:relative;justify-content:center}.org-list .search-result-list{position:absolute;top:0;left:0;right:0;bottom:0;z-index:1;background-color:#fff;overflow-y:auto;padding:0 16px}.org-list .org-item{padding:12px 0;border-bottom:1px solid #eee;cursor:pointer;display:flex;align-items:center;gap:12px}.org-list .org-item .org-item-select-icon{display:none;padding-left:4px}.org-list .org-item.selected{color:var(--van-primary-color)}.org-list .org-item.selected .org-item-select-icon{display:inline}.org-list .org-item .org-avatar{flex-shrink:0;width:40px;height:40px;display:flex;align-items:center;justify-content:center}.org-list .org-item .org-avatar img{border-radius:4px;border:1px solid #eee;object-fit:contain}.org-list .org-item .org-name{font-size:14px;flex:1}.org-list .org-item:last-child{border-bottom:none}.org-list .action-buttons{padding:16px;display:flex;justify-content:center}.org-list .action-buttons .confirm-button{background-color:var(--van-primary-color);color:#fff;padding:10px 0;border-radius:4px;text-align:center;width:100%;font-size:14px}
1
+ :root:root{--van-action-sheet-max-height: 100%}.org-list{height:85vh;display:flex;flex-direction:column}.org-list .highlight{color:var(--van-primary-color);font-weight:700}.org-list .breadcrumb-nav{margin-bottom:4px;padding:2px 16px;border-radius:4px;font-size:12px}.org-list .breadcrumb-nav .dept-name.current-dept{color:#969799}.org-list .breadcrumb-nav .separator{color:#969799;margin:0 4px}.org-list .search-bar{position:-webkit-sticky;position:-webkit-sticky;position:sticky;top:0;z-index:1}.org-list .org-selected-items{display:flex;flex-wrap:nowrap;padding:12px 16px;gap:12px;background-color:#fff;overflow-x:auto;height:68px;border-bottom:1px solid #eee}.org-list .org-selected-items .selected-tag{flex-shrink:0;background:none;border:none;padding:0;margin:0;position:relative}.org-list .org-selected-items .selected-tag .close-icon{position:absolute;top:0;right:0;z-index:1;background-color:#fff;border-radius:50%;border:1px solid #eee;width:10px;height:10px;display:flex;align-items:center;justify-content:center;font-size:6px;color:#969799}.org-list .org-selected-items .selected-tag .tag-avatar{width:40px;height:40px}.org-list .org-selected-items .selected-tag .tag-avatar img{border-radius:4px;border:1px solid #eee;object-fit:contain}.org-list .bottom-section{border-top:1px solid #eee;background-color:#fff}.org-list .van-list{flex:1;overflow-y:auto;padding:0 16px}.org-list .org-content-wrap{flex:1;display:flex;flex-direction:column;overflow:hidden;position:relative}.org-list .feed-list-wrap{flex:1;display:flex;overflow:hidden;position:relative;justify-content:center}.org-list .search-result-list{position:absolute;top:0;left:0;right:0;bottom:0;z-index:1;background-color:#fff;overflow-y:auto;padding:0 16px}.org-list .org-item{padding:12px 0;border-bottom:1px solid #eee;cursor:pointer;display:flex;align-items:center;gap:12px}.org-list .org-item .org-item-select-icon{display:none;padding-left:4px}.org-list .org-item.selected{color:var(--van-primary-color)}.org-list .org-item.selected .org-item-select-icon{display:inline}.org-list .org-item .org-avatar{flex-shrink:0;width:40px;height:40px;display:flex;align-items:center;justify-content:center}.org-list .org-item .org-avatar img{border-radius:4px;border:1px solid #eee;object-fit:contain}.org-list .org-item .org-name{font-size:14px;flex:1}.org-list .org-item:last-child{border-bottom:none}.org-list .action-buttons{padding:16px;display:flex;justify-content:center}.org-list .action-buttons .confirm-button{background-color:var(--van-primary-color);color:#fff;padding:10px 0;border-radius:4px;text-align:center;width:100%;font-size:14px}
@@ -97,6 +97,7 @@
97
97
  display: flex;
98
98
  flex-direction: column;
99
99
  overflow: hidden;
100
+ position: relative;
100
101
  }
101
102
 
102
103
  .feed-list-wrap {
@@ -34,5 +34,4 @@ export type OrgPickerProps = ExtractPropTypes<typeof orgPickerProps>;
34
34
  export interface RecentSelection {
35
35
  id: string;
36
36
  selectedUsers: OrgItem[];
37
- timestamp: number;
38
37
  }
@@ -27,6 +27,19 @@ export declare const useApi: () => {
27
27
  type: string;
28
28
  avatar?: string | undefined;
29
29
  }[]>;
30
+ orgSearchList: Ref<{
31
+ [x: string]: any;
32
+ id: string | number;
33
+ name: string;
34
+ type: string;
35
+ avatar?: string | undefined;
36
+ }[], OrgItem[] | {
37
+ [x: string]: any;
38
+ id: string | number;
39
+ name: string;
40
+ type: string;
41
+ avatar?: string | undefined;
42
+ }[]>;
30
43
  getOrgList: (deptId?: string) => Promise<void>;
31
44
  currentDeptId: Ref<string, string>;
32
45
  deptPath: Ref<{
@@ -40,6 +53,6 @@ export declare const useApi: () => {
40
53
  name: string;
41
54
  }[]>;
42
55
  searchOrgList: import("lodash-es").DebouncedFunc<(userName: string) => Promise<void>>;
43
- getRecentSelectedUsers: () => RecentSelection[];
44
- setRecentSelectedUsers: (users: OrgItem[]) => void;
56
+ getRecentSelectedUsers: () => Promise<RecentSelection[]>;
57
+ setRecentSelectedUsers: (users: OrgItem[]) => Promise<void>;
45
58
  };
@@ -19,7 +19,7 @@ var __async = (__this, __arguments, generator) => {
19
19
  });
20
20
  };
21
21
  import { ref } from "vue";
22
- import { useFetch, getUserList } from "@cgboiler/core";
22
+ import { useFetch, getUserList, getStorage, setStorage } from "@cgboiler/core";
23
23
  import { debounce } from "lodash-es";
24
24
  const orgListCache = /* @__PURE__ */ new Map();
25
25
  const fetchData = (url, cacheKey) => __async(void 0, null, function* () {
@@ -45,6 +45,7 @@ function initUserList() {
45
45
  initUserList();
46
46
  const useApi = () => {
47
47
  const orgList = ref([]);
48
+ const orgSearchList = ref([]);
48
49
  const currentDeptId = ref("1");
49
50
  const deptPath = ref([{ id: "1", name: "\u5DDD\u9505\u516C\u53F8" }]);
50
51
  const getOrgList = (deptId) => __async(void 0, null, function* () {
@@ -65,32 +66,31 @@ const useApi = () => {
65
66
  });
66
67
  const searchOrgList = debounce((userName) => __async(void 0, null, function* () {
67
68
  if (!userName) {
68
- orgList.value = [];
69
+ orgSearchList.value = [];
69
70
  return;
70
71
  }
71
72
  const url = `https://wflow.cgboiler.com/v1/oa/org/tree/user/search/cloud?userName=${userName}`;
72
- orgList.value = yield fetchData(url);
73
+ orgSearchList.value = yield fetchData(url);
73
74
  }), 300);
74
75
  const RECENT_SELECTED_USERS_KEY = "recent_selected_users_history";
75
76
  const MAX_RECENT_SELECTIONS = 15;
76
- const getRecentSelectedUsers = () => {
77
+ const getRecentSelectedUsers = () => __async(void 0, null, function* () {
77
78
  try {
78
- const data = localStorage.getItem(RECENT_SELECTED_USERS_KEY);
79
- return data ? JSON.parse(data) : [];
79
+ const data = yield getStorage(RECENT_SELECTED_USERS_KEY);
80
+ return data || [];
80
81
  } catch (error) {
81
82
  console.error("Failed to get recent selected users history from localStorage", error);
82
83
  return [];
83
84
  }
84
- };
85
- const setRecentSelectedUsers = (users) => {
85
+ });
86
+ const setRecentSelectedUsers = (users) => __async(void 0, null, function* () {
86
87
  if (!users || users.length === 0)
87
88
  return;
88
- const history = getRecentSelectedUsers();
89
+ const history = yield getRecentSelectedUsers();
89
90
  const newSelection = {
90
91
  id: Date.now().toString(),
91
92
  // 使用时间戳作为唯一ID
92
- selectedUsers: users,
93
- timestamp: Date.now()
93
+ selectedUsers: users
94
94
  };
95
95
  const filteredHistory = history.filter((item) => {
96
96
  return !(item.selectedUsers.length === newSelection.selectedUsers.length && item.selectedUsers.every(
@@ -99,14 +99,15 @@ const useApi = () => {
99
99
  });
100
100
  const updatedHistory = [newSelection, ...filteredHistory].slice(0, MAX_RECENT_SELECTIONS);
101
101
  try {
102
- localStorage.setItem(RECENT_SELECTED_USERS_KEY, JSON.stringify(updatedHistory));
102
+ yield setStorage(RECENT_SELECTED_USERS_KEY, JSON.parse(JSON.stringify(updatedHistory)));
103
103
  } catch (error) {
104
104
  console.error("Failed to set recent selected users history to localStorage", error);
105
105
  }
106
- };
106
+ });
107
107
  return {
108
108
  userList,
109
109
  orgList,
110
+ orgSearchList,
110
111
  getOrgList,
111
112
  currentDeptId,
112
113
  deptPath,
@@ -0,0 +1,9 @@
1
+ export declare function useSearch(props: any, api: any): {
2
+ keyword: import("vue").Ref<string, string>;
3
+ searchRef: import("vue").Ref<any, any>;
4
+ renderSearchResult: ({ handleHistorySelect, isSelected, handleSelect }: any) => import("vue/jsx-runtime").JSX.Element;
5
+ filteredOrgList: import("vue").ComputedRef<any>;
6
+ recentSelectedHistory: import("vue").Ref<any[], any[]>;
7
+ filterRecentSelectedHistory: import("vue").Ref<any[], any[]>;
8
+ highlightText: (text: string, keyword: string) => string | (string | import("vue/jsx-runtime").JSX.Element)[];
9
+ };
@@ -0,0 +1,125 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { createVNode as _createVNode, Fragment as _Fragment, createTextVNode as _createTextVNode } from "vue";
22
+ import "./_atomic.css";
23
+ import { ref, computed, watch, watchEffect, nextTick } from "vue";
24
+ import { Empty, List, Image } from "vant";
25
+ function useSearch(props, api) {
26
+ const {
27
+ orgSearchList,
28
+ getOrgList,
29
+ currentDeptId,
30
+ searchOrgList,
31
+ getRecentSelectedUsers
32
+ } = api;
33
+ const keyword = ref("");
34
+ const searchRef = ref();
35
+ const recentSelectedHistory = ref([]);
36
+ const filterRecentSelectedHistory = ref([]);
37
+ watchEffect(() => __async(this, null, function* () {
38
+ recentSelectedHistory.value = yield getRecentSelectedUsers();
39
+ }));
40
+ watchEffect(() => {
41
+ if (keyword.value) {
42
+ filterRecentSelectedHistory.value = recentSelectedHistory.value.filter((item) => item.selectedUsers.some((user) => keyword.value.split("").some((char) => user.name.includes(char))));
43
+ } else {
44
+ filterRecentSelectedHistory.value = recentSelectedHistory.value;
45
+ }
46
+ });
47
+ watch(() => props.show, (newVal) => __async(this, null, function* () {
48
+ if (newVal && props.autoFocus) {
49
+ yield nextTick();
50
+ setTimeout(() => {
51
+ var _a;
52
+ (_a = searchRef.value) == null ? void 0 : _a.focus();
53
+ }, 300);
54
+ }
55
+ }));
56
+ watch(keyword, (newKeyword) => {
57
+ if (newKeyword) {
58
+ searchOrgList(newKeyword);
59
+ } else {
60
+ getOrgList(currentDeptId.value);
61
+ }
62
+ });
63
+ const filteredOrgList = computed(() => {
64
+ if (keyword.value) {
65
+ return orgSearchList.value;
66
+ }
67
+ return [];
68
+ });
69
+ const highlightText = (text, keyword2) => {
70
+ if (!keyword2) {
71
+ return text;
72
+ }
73
+ const keywordChars = keyword2.split("");
74
+ return Array.from(text).map((char, index) => keywordChars.some((kChar) => char.toLowerCase() === kChar.toLowerCase()) ? _createVNode("span", {
75
+ "class": "highlight"
76
+ }, [char]) : char);
77
+ };
78
+ const renderSearchResult = ({
79
+ handleHistorySelect,
80
+ isSelected,
81
+ handleSelect
82
+ }) => {
83
+ return _createVNode("div", {
84
+ "class": "absolute top-0 left-0 right-0 bottom-0 bg-[#fff] z-1"
85
+ }, [filterRecentSelectedHistory.value.length ? _createVNode(_Fragment, null, [_createVNode("p", {
86
+ "class": "text-[14px] text-[#333] font-bold px-[16px] py-[12px] border-b border-[#eee]"
87
+ }, [_createTextVNode("\u6700\u8FD1\u9009\u62E9")]), _createVNode("div", {
88
+ "class": "recent-list-wrap flex-1 overflow-auto px-[16px] py-[8px]"
89
+ }, [filterRecentSelectedHistory.value.map((historyItem) => _createVNode("div", {
90
+ "key": historyItem.id,
91
+ "onClick": () => handleHistorySelect(historyItem),
92
+ "class": "px-16px py-8px border-b border-[#eee]"
93
+ }, [_createVNode("span", null, [historyItem.selectedUsers.map((user) => highlightText(user.name, keyword.value)).reduce((prev, curr) => [prev, "\uFF0C", curr])])]))])]) : "", filteredOrgList.value.length ? _createVNode(_Fragment, null, [" ", _createVNode("p", {
94
+ "class": "text-[14px] text-[#333] font-bold px-[16px] py-[12px] border-b border-[#eee]"
95
+ }, [_createTextVNode("\u901A\u8BAF\u5F55")]), _createVNode("div", {
96
+ "class": "feed-list-wrap"
97
+ }, [filteredOrgList.value.length === 0 ? _createVNode(Empty, {
98
+ "description": "\u672A\u627E\u5230\u76F8\u5173\u4EBA\u5458"
99
+ }, null) : _createVNode(List, null, {
100
+ default: () => [filteredOrgList.value.map((item) => _createVNode("div", {
101
+ "class": ["org-item", isSelected(item) ? "selected" : ""],
102
+ "onClick": () => handleSelect(item)
103
+ }, [_createVNode(Image, {
104
+ "class": "org-avatar",
105
+ "src": item.avatar
106
+ }, null), _createVNode("div", {
107
+ "class": "org-name"
108
+ }, [item.name, _createVNode("span", {
109
+ "class": "org-item-select-icon"
110
+ }, [_createTextVNode("\u2713")])])]))]
111
+ })])]) : ""]);
112
+ };
113
+ return {
114
+ keyword,
115
+ searchRef,
116
+ renderSearchResult,
117
+ filteredOrgList,
118
+ recentSelectedHistory,
119
+ filterRecentSelectedHistory,
120
+ highlightText
121
+ };
122
+ }
123
+ export {
124
+ useSearch
125
+ };
package/lib/index.d.ts CHANGED
@@ -7,7 +7,7 @@ declare namespace _default {
7
7
  }
8
8
  export default _default;
9
9
  export function install(app: any): void;
10
- export const version: "1.17.6";
10
+ export const version: "1.17.7";
11
11
  import MdPreview from './md-preview';
12
12
  import OrgPicker from './org-picker';
13
13
  import ProjectSelect from './project-select';
package/lib/index.js CHANGED
@@ -42,7 +42,7 @@ var import_project_select = __toESM(require("./project-select"));
42
42
  __reExport(stdin_exports, require("./md-preview"), module.exports);
43
43
  __reExport(stdin_exports, require("./org-picker"), module.exports);
44
44
  __reExport(stdin_exports, require("./project-select"), module.exports);
45
- const version = "1.17.6";
45
+ const version = "1.17.7";
46
46
  function install(app) {
47
47
  const components = [
48
48
  import_md_preview.default,
@@ -25,26 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
28
  var stdin_exports = {};
49
29
  __export(stdin_exports, {
50
30
  default: () => stdin_default
@@ -58,7 +38,7 @@ var import_DeptImg = __toESM(require("./components/DeptImg"));
58
38
  var import_types = require("./types");
59
39
  var import_useApi = require("./useApi");
60
40
  var import_index = require("./index.css");
61
- var import_vue3 = require("vue");
41
+ var import_useSearch = require("./useSearch");
62
42
  var stdin_default = (0, import_vue2.defineComponent)({
63
43
  name: "OrgPicker",
64
44
  props: import_types.orgPickerProps,
@@ -66,19 +46,29 @@ var stdin_default = (0, import_vue2.defineComponent)({
66
46
  setup(props, {
67
47
  emit
68
48
  }) {
49
+ const api = (0, import_useApi.useApi)();
69
50
  const {
70
- orgList,
71
51
  getOrgList,
72
- currentDeptId,
52
+ orgList,
73
53
  deptPath,
74
- searchOrgList,
75
54
  userList,
76
- getRecentSelectedUsers,
77
55
  setRecentSelectedUsers
78
- } = (0, import_useApi.useApi)();
56
+ } = api;
79
57
  getOrgList();
80
- const activeTab = (0, import_vue2.ref)("zjxz");
58
+ const activeTab = (0, import_vue2.ref)("txl");
59
+ const {
60
+ keyword,
61
+ searchRef,
62
+ recentSelectedHistory,
63
+ highlightText,
64
+ renderSearchResult
65
+ } = (0, import_useSearch.useSearch)(props, api);
81
66
  const selectedItems = (0, import_vue2.ref)([]);
67
+ const sortOrgList = (0, import_vue2.computed)(() => {
68
+ const departments = orgList.value.filter((item) => item.type === "dept");
69
+ const personnel = orgList.value.filter((item) => item.type !== "dept");
70
+ return [...personnel, ...departments];
71
+ });
82
72
  (0, import_vue2.watch)(() => props.modelValue, (newValue) => {
83
73
  var _a;
84
74
  if (!newValue) {
@@ -120,65 +110,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
120
110
  emit("update:modelValue", selectedItems.value.map((item) => item.id));
121
111
  setRecentSelectedUsers(selectedItems.value);
122
112
  };
123
- const keyword = (0, import_vue2.ref)("");
124
- const loading = (0, import_vue2.ref)(false);
125
- const finished = (0, import_vue2.ref)(true);
126
- const searchRef = (0, import_vue2.ref)();
127
- const recentSelectedHistory = (0, import_vue2.ref)([]);
128
- const filterRecentSelectedHistory = (0, import_vue2.ref)([]);
129
- (0, import_vue3.watchEffect)(() => {
130
- if (activeTab.value === "zjxz") {
131
- recentSelectedHistory.value = getRecentSelectedUsers();
132
- }
133
- });
134
- (0, import_vue3.watchEffect)(() => {
135
- if (activeTab.value === "zjxz") {
136
- if (keyword.value) {
137
- filterRecentSelectedHistory.value = recentSelectedHistory.value.filter((item) => item.selectedUsers.some((user) => keyword.value.split("").some((char) => user.name.includes(char))));
138
- } else {
139
- filterRecentSelectedHistory.value = recentSelectedHistory.value;
140
- }
141
- }
142
- });
143
- (0, import_vue2.watch)(() => props.show, (newVal) => __async(this, null, function* () {
144
- if (newVal && props.autoFocus) {
145
- yield (0, import_vue2.nextTick)();
146
- setTimeout(() => {
147
- var _a;
148
- (_a = searchRef.value) == null ? void 0 : _a.focus();
149
- }, 300);
150
- }
151
- }));
152
- (0, import_vue2.watch)(keyword, (newKeyword) => {
153
- if (newKeyword) {
154
- searchOrgList(newKeyword);
155
- } else {
156
- getOrgList(currentDeptId.value);
157
- }
158
- });
159
- const filteredOrgList = (0, import_vue2.computed)(() => {
160
- if (keyword.value) {
161
- return orgList.value;
162
- }
163
- const departments = orgList.value.filter((item) => item.type === "dept");
164
- const personnel = orgList.value.filter((item) => item.type !== "dept");
165
- return [...personnel, ...departments];
166
- });
167
113
  const isSelected = (item) => {
168
114
  return selectedItems.value.some((s) => s.id === item.id);
169
115
  };
170
- const onLoad = () => {
171
- finished.value = true;
172
- };
173
- const highlightText = (text, keyword2) => {
174
- if (!keyword2) {
175
- return text;
176
- }
177
- const keywordChars = keyword2.split("");
178
- return Array.from(text).map((char, index) => keywordChars.some((kChar) => char.toLowerCase() === kChar.toLowerCase()) ? (0, import_vue3.h)("span", {
179
- class: "highlight"
180
- }, char) : char);
181
- };
182
116
  return () => (0, import_vue.createVNode)(import_vant.ActionSheet, {
183
117
  "show": props.show,
184
118
  "onUpdate:show": (val) => emit("update:show", val),
@@ -206,28 +140,30 @@ var stdin_default = (0, import_vue2.defineComponent)({
206
140
  "class": "close-icon"
207
141
  }, [(0, import_vue.createTextVNode)("X")])])) : (0, import_vue.createVNode)("p", {
208
142
  "class": "color-[#aaa] text-[14px] text-center w-full leading-[38px]"
209
- }, [(0, import_vue.createTextVNode)("\u672A\u9009\u62E9\u4EBA\u5458")])]), (0, import_vue.createVNode)(import_vant.Tabs, {
143
+ }, [(0, import_vue.createTextVNode)("\u672A\u9009\u62E9\u4EBA\u5458")])]), (0, import_vue.createVNode)("div", {
144
+ "class": "flex-1 flex flex-col overflow-hidden relative"
145
+ }, [(0, import_vue.createVNode)(import_vant.Tabs, {
210
146
  "active": activeTab.value,
211
147
  "onUpdate:active": ($event) => activeTab.value = $event
212
148
  }, {
213
149
  default: () => [(0, import_vue.createVNode)(import_vant.Tab, {
214
- "title": "\u6700\u8FD1\u9009\u62E9",
215
- "name": "zjxz"
216
- }, null), (0, import_vue.createVNode)(import_vant.Tab, {
217
150
  "title": "\u901A\u8BAF\u5F55",
218
151
  "name": "txl"
152
+ }, null), (0, import_vue.createVNode)(import_vant.Tab, {
153
+ "title": "\u6700\u8FD1\u9009\u62E9",
154
+ "name": "zjxz"
219
155
  }, null)]
220
156
  }), (0, import_vue.createVNode)("div", {
221
157
  "class": "org-content-wrap"
222
158
  }, [activeTab.value === "zjxz" ? (0, import_vue.createVNode)("div", {
223
159
  "class": "recent-list-wrap flex-1 overflow-auto px-[16px] py-[8px]"
224
- }, [filterRecentSelectedHistory.value.length === 0 ? (0, import_vue.createVNode)(import_vant.Empty, {
160
+ }, [recentSelectedHistory.value.length === 0 ? (0, import_vue.createVNode)(import_vant.Empty, {
225
161
  "description": "\u6682\u65E0\u6700\u8FD1\u9009\u62E9\u8BB0\u5F55"
226
- }, null) : filterRecentSelectedHistory.value.map((historyItem) => (0, import_vue.createVNode)("div", {
162
+ }, null) : recentSelectedHistory.value.map((historyItem) => (0, import_vue.createVNode)("div", {
227
163
  "key": historyItem.id,
228
164
  "onClick": () => handleHistorySelect(historyItem),
229
165
  "class": "px-16px py-8px border-b border-[#eee]"
230
- }, [(0, import_vue.createVNode)("span", null, [historyItem.selectedUsers.map((user) => highlightText(user.name, keyword.value)).reduce((prev, curr) => [prev, "\uFF0C", curr])])]))]) : (0, import_vue.createVNode)(import_vue.Fragment, null, [!keyword.value && (0, import_vue.createVNode)("div", {
166
+ }, [(0, import_vue.createVNode)("span", null, [historyItem.selectedUsers.map((user) => highlightText(user.name, keyword.value)).reduce((prev, curr) => [prev, "\uFF0C", curr])])]))]) : (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)("div", {
231
167
  "class": "breadcrumb-nav"
232
168
  }, [deptPath.value.map((dept, index) => (0, import_vue.createVNode)("span", {
233
169
  "key": dept.id
@@ -241,14 +177,10 @@ var stdin_default = (0, import_vue2.defineComponent)({
241
177
  "class": "separator"
242
178
  }, [(0, import_vue.createTextVNode)(" / ")])]))]), (0, import_vue.createVNode)("div", {
243
179
  "class": "feed-list-wrap"
244
- }, [filteredOrgList.value.length === 0 ? (0, import_vue.createVNode)(import_vant.Empty, {
245
- "description": keyword.value ? "\u672A\u627E\u5230\u76F8\u5173\u4EBA\u5458" : "\u8BE5\u90E8\u95E8\u4E0B\u6CA1\u6709\u4EBA\u5458"
246
- }, null) : (0, import_vue.createVNode)(import_vant.List, {
247
- "loading": loading.value,
248
- "finished": finished.value,
249
- "onLoad": onLoad
250
- }, {
251
- default: () => [filteredOrgList.value.map((item) => (0, import_vue.createVNode)("div", {
180
+ }, [sortOrgList.value.length === 0 ? (0, import_vue.createVNode)(import_vant.Empty, {
181
+ "description": "\u8BE5\u90E8\u95E8\u4E0B\u6CA1\u6709\u4EBA\u5458"
182
+ }, null) : (0, import_vue.createVNode)(import_vant.List, null, {
183
+ default: () => [sortOrgList.value.map((item) => (0, import_vue.createVNode)("div", {
252
184
  "class": ["org-item", isSelected(item) ? "selected" : ""],
253
185
  "onClick": () => handleSelect(item)
254
186
  }, [item.type === "dept" && !keyword.value ? (0, import_vue.createVNode)("div", {
@@ -261,7 +193,11 @@ var stdin_default = (0, import_vue2.defineComponent)({
261
193
  }, [item.name, (0, import_vue.createVNode)("span", {
262
194
  "class": "org-item-select-icon"
263
195
  }, [(0, import_vue.createTextVNode)("\u2713")])])]))]
264
- })])])]), props.multiple && (0, import_vue.createVNode)("div", {
196
+ })])])]), keyword.value && renderSearchResult({
197
+ handleHistorySelect,
198
+ isSelected,
199
+ handleSelect
200
+ })]), props.multiple && (0, import_vue.createVNode)("div", {
265
201
  "class": "bottom-section"
266
202
  }, [(0, import_vue.createVNode)("div", {
267
203
  "class": "action-buttons"
@@ -31,9 +31,33 @@
31
31
  }
32
32
 
33
33
  /* layer: default */
34
+ .cgx-atm .absolute{position:absolute;}
35
+ .cgx-atm .bottom-0{bottom:0rem;}
36
+ .cgx-atm .left-0{left:0rem;}
37
+ .cgx-atm .right-0{right:0rem;}
38
+ .cgx-atm .top-0{top:0rem;}
39
+ .cgx-atm .z-1{z-index:1;}
40
+ .cgx-atm .flex-1{flex:1 1 0%;}
41
+ .cgx-atm .overflow-auto{overflow:auto;}
42
+ .cgx-atm .border-b{border-bottom-width:1px;border-bottom-style:solid;}
43
+ .cgx-atm .border-\[\#eee\]{--un-border-opacity:1;border-color:rgba(238,238,238,var(--un-border-opacity));}
44
+ .cgx-atm .bg-\[\#fff\]{--un-bg-opacity:1;background-color:rgba(255,255,255,var(--un-bg-opacity));}
45
+ .cgx-atm .px-\[16px\],
46
+ .cgx-atm .px-16px{padding-left:16px;padding-right:16px;}
47
+ .cgx-atm .py-\[12px\]{padding-top:12px;padding-bottom:12px;}
48
+ .cgx-atm .py-\[8px\],
49
+ .cgx-atm .py-8px{padding-top:8px;padding-bottom:8px;}
50
+ .cgx-atm .text-\[14px\]{font-size:14px;}
51
+ .cgx-atm .font-bold{font-weight:700;}
52
+ .cgx-atm .text-\[\#333\]{--un-text-opacity:1;color:rgba(51,51,51,var(--un-text-opacity));}
53
+ /* layer: default */
54
+ .cgx-atm .relative{position:relative;}
34
55
  .cgx-atm .w-full{width:100%;}
56
+ .cgx-atm .flex{display:flex;}
35
57
  .cgx-atm .flex-1{flex:1 1 0%;}
58
+ .cgx-atm .flex-col{flex-direction:column;}
36
59
  .cgx-atm .overflow-auto{overflow:auto;}
60
+ .cgx-atm .overflow-hidden{overflow:hidden;}
37
61
  .cgx-atm .border-b{border-bottom-width:1px;border-bottom-style:solid;}
38
62
  .cgx-atm .border-\[\#eee\]{--un-border-opacity:1;border-color:rgba(238,238,238,var(--un-border-opacity));}
39
63
  .cgx-atm .px-\[16px\],
@@ -1 +1 @@
1
- :root:root{--van-action-sheet-max-height: 100%}.org-list{height:85vh;display:flex;flex-direction:column}.org-list .highlight{color:var(--van-primary-color);font-weight:700}.org-list .breadcrumb-nav{margin-bottom:4px;padding:2px 16px;border-radius:4px;font-size:12px}.org-list .breadcrumb-nav .dept-name.current-dept{color:#969799}.org-list .breadcrumb-nav .separator{color:#969799;margin:0 4px}.org-list .search-bar{position:-webkit-sticky;position:-webkit-sticky;position:sticky;top:0;z-index:1}.org-list .org-selected-items{display:flex;flex-wrap:nowrap;padding:12px 16px;gap:12px;background-color:#fff;overflow-x:auto;height:68px;border-bottom:1px solid #eee}.org-list .org-selected-items .selected-tag{flex-shrink:0;background:none;border:none;padding:0;margin:0;position:relative}.org-list .org-selected-items .selected-tag .close-icon{position:absolute;top:0;right:0;z-index:1;background-color:#fff;border-radius:50%;border:1px solid #eee;width:10px;height:10px;display:flex;align-items:center;justify-content:center;font-size:6px;color:#969799}.org-list .org-selected-items .selected-tag .tag-avatar{width:40px;height:40px}.org-list .org-selected-items .selected-tag .tag-avatar img{border-radius:4px;border:1px solid #eee;object-fit:contain}.org-list .bottom-section{border-top:1px solid #eee;background-color:#fff}.org-list .van-list{flex:1;overflow-y:auto;padding:0 16px}.org-list .org-content-wrap{flex:1;display:flex;flex-direction:column;overflow:hidden}.org-list .feed-list-wrap{flex:1;display:flex;overflow:hidden;position:relative;justify-content:center}.org-list .search-result-list{position:absolute;top:0;left:0;right:0;bottom:0;z-index:1;background-color:#fff;overflow-y:auto;padding:0 16px}.org-list .org-item{padding:12px 0;border-bottom:1px solid #eee;cursor:pointer;display:flex;align-items:center;gap:12px}.org-list .org-item .org-item-select-icon{display:none;padding-left:4px}.org-list .org-item.selected{color:var(--van-primary-color)}.org-list .org-item.selected .org-item-select-icon{display:inline}.org-list .org-item .org-avatar{flex-shrink:0;width:40px;height:40px;display:flex;align-items:center;justify-content:center}.org-list .org-item .org-avatar img{border-radius:4px;border:1px solid #eee;object-fit:contain}.org-list .org-item .org-name{font-size:14px;flex:1}.org-list .org-item:last-child{border-bottom:none}.org-list .action-buttons{padding:16px;display:flex;justify-content:center}.org-list .action-buttons .confirm-button{background-color:var(--van-primary-color);color:#fff;padding:10px 0;border-radius:4px;text-align:center;width:100%;font-size:14px}
1
+ :root:root{--van-action-sheet-max-height: 100%}.org-list{height:85vh;display:flex;flex-direction:column}.org-list .highlight{color:var(--van-primary-color);font-weight:700}.org-list .breadcrumb-nav{margin-bottom:4px;padding:2px 16px;border-radius:4px;font-size:12px}.org-list .breadcrumb-nav .dept-name.current-dept{color:#969799}.org-list .breadcrumb-nav .separator{color:#969799;margin:0 4px}.org-list .search-bar{position:-webkit-sticky;position:-webkit-sticky;position:sticky;top:0;z-index:1}.org-list .org-selected-items{display:flex;flex-wrap:nowrap;padding:12px 16px;gap:12px;background-color:#fff;overflow-x:auto;height:68px;border-bottom:1px solid #eee}.org-list .org-selected-items .selected-tag{flex-shrink:0;background:none;border:none;padding:0;margin:0;position:relative}.org-list .org-selected-items .selected-tag .close-icon{position:absolute;top:0;right:0;z-index:1;background-color:#fff;border-radius:50%;border:1px solid #eee;width:10px;height:10px;display:flex;align-items:center;justify-content:center;font-size:6px;color:#969799}.org-list .org-selected-items .selected-tag .tag-avatar{width:40px;height:40px}.org-list .org-selected-items .selected-tag .tag-avatar img{border-radius:4px;border:1px solid #eee;object-fit:contain}.org-list .bottom-section{border-top:1px solid #eee;background-color:#fff}.org-list .van-list{flex:1;overflow-y:auto;padding:0 16px}.org-list .org-content-wrap{flex:1;display:flex;flex-direction:column;overflow:hidden;position:relative}.org-list .feed-list-wrap{flex:1;display:flex;overflow:hidden;position:relative;justify-content:center}.org-list .search-result-list{position:absolute;top:0;left:0;right:0;bottom:0;z-index:1;background-color:#fff;overflow-y:auto;padding:0 16px}.org-list .org-item{padding:12px 0;border-bottom:1px solid #eee;cursor:pointer;display:flex;align-items:center;gap:12px}.org-list .org-item .org-item-select-icon{display:none;padding-left:4px}.org-list .org-item.selected{color:var(--van-primary-color)}.org-list .org-item.selected .org-item-select-icon{display:inline}.org-list .org-item .org-avatar{flex-shrink:0;width:40px;height:40px;display:flex;align-items:center;justify-content:center}.org-list .org-item .org-avatar img{border-radius:4px;border:1px solid #eee;object-fit:contain}.org-list .org-item .org-name{font-size:14px;flex:1}.org-list .org-item:last-child{border-bottom:none}.org-list .action-buttons{padding:16px;display:flex;justify-content:center}.org-list .action-buttons .confirm-button{background-color:var(--van-primary-color);color:#fff;padding:10px 0;border-radius:4px;text-align:center;width:100%;font-size:14px}
@@ -97,6 +97,7 @@
97
97
  display: flex;
98
98
  flex-direction: column;
99
99
  overflow: hidden;
100
+ position: relative;
100
101
  }
101
102
 
102
103
  .feed-list-wrap {
@@ -34,5 +34,4 @@ export type OrgPickerProps = ExtractPropTypes<typeof orgPickerProps>;
34
34
  export interface RecentSelection {
35
35
  id: string;
36
36
  selectedUsers: OrgItem[];
37
- timestamp: number;
38
37
  }
@@ -27,6 +27,19 @@ export declare const useApi: () => {
27
27
  type: string;
28
28
  avatar?: string | undefined;
29
29
  }[]>;
30
+ orgSearchList: Ref<{
31
+ [x: string]: any;
32
+ id: string | number;
33
+ name: string;
34
+ type: string;
35
+ avatar?: string | undefined;
36
+ }[], OrgItem[] | {
37
+ [x: string]: any;
38
+ id: string | number;
39
+ name: string;
40
+ type: string;
41
+ avatar?: string | undefined;
42
+ }[]>;
30
43
  getOrgList: (deptId?: string) => Promise<void>;
31
44
  currentDeptId: Ref<string, string>;
32
45
  deptPath: Ref<{
@@ -40,6 +53,6 @@ export declare const useApi: () => {
40
53
  name: string;
41
54
  }[]>;
42
55
  searchOrgList: import("lodash-es").DebouncedFunc<(userName: string) => Promise<void>>;
43
- getRecentSelectedUsers: () => RecentSelection[];
44
- setRecentSelectedUsers: (users: OrgItem[]) => void;
56
+ getRecentSelectedUsers: () => Promise<RecentSelection[]>;
57
+ setRecentSelectedUsers: (users: OrgItem[]) => Promise<void>;
45
58
  };
@@ -67,6 +67,7 @@ function initUserList() {
67
67
  initUserList();
68
68
  const useApi = () => {
69
69
  const orgList = (0, import_vue.ref)([]);
70
+ const orgSearchList = (0, import_vue.ref)([]);
70
71
  const currentDeptId = (0, import_vue.ref)("1");
71
72
  const deptPath = (0, import_vue.ref)([{ id: "1", name: "\u5DDD\u9505\u516C\u53F8" }]);
72
73
  const getOrgList = (deptId) => __async(void 0, null, function* () {
@@ -87,32 +88,31 @@ const useApi = () => {
87
88
  });
88
89
  const searchOrgList = (0, import_lodash_es.debounce)((userName) => __async(void 0, null, function* () {
89
90
  if (!userName) {
90
- orgList.value = [];
91
+ orgSearchList.value = [];
91
92
  return;
92
93
  }
93
94
  const url = `https://wflow.cgboiler.com/v1/oa/org/tree/user/search/cloud?userName=${userName}`;
94
- orgList.value = yield fetchData(url);
95
+ orgSearchList.value = yield fetchData(url);
95
96
  }), 300);
96
97
  const RECENT_SELECTED_USERS_KEY = "recent_selected_users_history";
97
98
  const MAX_RECENT_SELECTIONS = 15;
98
- const getRecentSelectedUsers = () => {
99
+ const getRecentSelectedUsers = () => __async(void 0, null, function* () {
99
100
  try {
100
- const data = localStorage.getItem(RECENT_SELECTED_USERS_KEY);
101
- return data ? JSON.parse(data) : [];
101
+ const data = yield (0, import_core.getStorage)(RECENT_SELECTED_USERS_KEY);
102
+ return data || [];
102
103
  } catch (error) {
103
104
  console.error("Failed to get recent selected users history from localStorage", error);
104
105
  return [];
105
106
  }
106
- };
107
- const setRecentSelectedUsers = (users) => {
107
+ });
108
+ const setRecentSelectedUsers = (users) => __async(void 0, null, function* () {
108
109
  if (!users || users.length === 0)
109
110
  return;
110
- const history = getRecentSelectedUsers();
111
+ const history = yield getRecentSelectedUsers();
111
112
  const newSelection = {
112
113
  id: Date.now().toString(),
113
114
  // 使用时间戳作为唯一ID
114
- selectedUsers: users,
115
- timestamp: Date.now()
115
+ selectedUsers: users
116
116
  };
117
117
  const filteredHistory = history.filter((item) => {
118
118
  return !(item.selectedUsers.length === newSelection.selectedUsers.length && item.selectedUsers.every(
@@ -121,14 +121,15 @@ const useApi = () => {
121
121
  });
122
122
  const updatedHistory = [newSelection, ...filteredHistory].slice(0, MAX_RECENT_SELECTIONS);
123
123
  try {
124
- localStorage.setItem(RECENT_SELECTED_USERS_KEY, JSON.stringify(updatedHistory));
124
+ yield (0, import_core.setStorage)(RECENT_SELECTED_USERS_KEY, JSON.parse(JSON.stringify(updatedHistory)));
125
125
  } catch (error) {
126
126
  console.error("Failed to set recent selected users history to localStorage", error);
127
127
  }
128
- };
128
+ });
129
129
  return {
130
130
  userList,
131
131
  orgList,
132
+ orgSearchList,
132
133
  getOrgList,
133
134
  currentDeptId,
134
135
  deptPath,
@@ -0,0 +1,9 @@
1
+ export declare function useSearch(props: any, api: any): {
2
+ keyword: import("vue").Ref<string, string>;
3
+ searchRef: import("vue").Ref<any, any>;
4
+ renderSearchResult: ({ handleHistorySelect, isSelected, handleSelect }: any) => import("vue/jsx-runtime").JSX.Element;
5
+ filteredOrgList: import("vue").ComputedRef<any>;
6
+ recentSelectedHistory: import("vue").Ref<any[], any[]>;
7
+ filterRecentSelectedHistory: import("vue").Ref<any[], any[]>;
8
+ highlightText: (text: string, keyword: string) => string | (string | import("vue/jsx-runtime").JSX.Element)[];
9
+ };
@@ -0,0 +1,144 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __async = (__this, __arguments, generator) => {
19
+ return new Promise((resolve, reject) => {
20
+ var fulfilled = (value) => {
21
+ try {
22
+ step(generator.next(value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ };
27
+ var rejected = (value) => {
28
+ try {
29
+ step(generator.throw(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ };
34
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
+ step((generator = generator.apply(__this, __arguments)).next());
36
+ });
37
+ };
38
+ var stdin_exports = {};
39
+ __export(stdin_exports, {
40
+ useSearch: () => useSearch
41
+ });
42
+ module.exports = __toCommonJS(stdin_exports);
43
+ var import_vue = require("vue");
44
+ var import_atomic = require("./_atomic.css");
45
+ var import_vue2 = require("vue");
46
+ var import_vant = require("vant");
47
+ function useSearch(props, api) {
48
+ const {
49
+ orgSearchList,
50
+ getOrgList,
51
+ currentDeptId,
52
+ searchOrgList,
53
+ getRecentSelectedUsers
54
+ } = api;
55
+ const keyword = (0, import_vue2.ref)("");
56
+ const searchRef = (0, import_vue2.ref)();
57
+ const recentSelectedHistory = (0, import_vue2.ref)([]);
58
+ const filterRecentSelectedHistory = (0, import_vue2.ref)([]);
59
+ (0, import_vue2.watchEffect)(() => __async(this, null, function* () {
60
+ recentSelectedHistory.value = yield getRecentSelectedUsers();
61
+ }));
62
+ (0, import_vue2.watchEffect)(() => {
63
+ if (keyword.value) {
64
+ filterRecentSelectedHistory.value = recentSelectedHistory.value.filter((item) => item.selectedUsers.some((user) => keyword.value.split("").some((char) => user.name.includes(char))));
65
+ } else {
66
+ filterRecentSelectedHistory.value = recentSelectedHistory.value;
67
+ }
68
+ });
69
+ (0, import_vue2.watch)(() => props.show, (newVal) => __async(this, null, function* () {
70
+ if (newVal && props.autoFocus) {
71
+ yield (0, import_vue2.nextTick)();
72
+ setTimeout(() => {
73
+ var _a;
74
+ (_a = searchRef.value) == null ? void 0 : _a.focus();
75
+ }, 300);
76
+ }
77
+ }));
78
+ (0, import_vue2.watch)(keyword, (newKeyword) => {
79
+ if (newKeyword) {
80
+ searchOrgList(newKeyword);
81
+ } else {
82
+ getOrgList(currentDeptId.value);
83
+ }
84
+ });
85
+ const filteredOrgList = (0, import_vue2.computed)(() => {
86
+ if (keyword.value) {
87
+ return orgSearchList.value;
88
+ }
89
+ return [];
90
+ });
91
+ const highlightText = (text, keyword2) => {
92
+ if (!keyword2) {
93
+ return text;
94
+ }
95
+ const keywordChars = keyword2.split("");
96
+ return Array.from(text).map((char, index) => keywordChars.some((kChar) => char.toLowerCase() === kChar.toLowerCase()) ? (0, import_vue.createVNode)("span", {
97
+ "class": "highlight"
98
+ }, [char]) : char);
99
+ };
100
+ const renderSearchResult = ({
101
+ handleHistorySelect,
102
+ isSelected,
103
+ handleSelect
104
+ }) => {
105
+ return (0, import_vue.createVNode)("div", {
106
+ "class": "absolute top-0 left-0 right-0 bottom-0 bg-[#fff] z-1"
107
+ }, [filterRecentSelectedHistory.value.length ? (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)("p", {
108
+ "class": "text-[14px] text-[#333] font-bold px-[16px] py-[12px] border-b border-[#eee]"
109
+ }, [(0, import_vue.createTextVNode)("\u6700\u8FD1\u9009\u62E9")]), (0, import_vue.createVNode)("div", {
110
+ "class": "recent-list-wrap flex-1 overflow-auto px-[16px] py-[8px]"
111
+ }, [filterRecentSelectedHistory.value.map((historyItem) => (0, import_vue.createVNode)("div", {
112
+ "key": historyItem.id,
113
+ "onClick": () => handleHistorySelect(historyItem),
114
+ "class": "px-16px py-8px border-b border-[#eee]"
115
+ }, [(0, import_vue.createVNode)("span", null, [historyItem.selectedUsers.map((user) => highlightText(user.name, keyword.value)).reduce((prev, curr) => [prev, "\uFF0C", curr])])]))])]) : "", filteredOrgList.value.length ? (0, import_vue.createVNode)(import_vue.Fragment, null, [" ", (0, import_vue.createVNode)("p", {
116
+ "class": "text-[14px] text-[#333] font-bold px-[16px] py-[12px] border-b border-[#eee]"
117
+ }, [(0, import_vue.createTextVNode)("\u901A\u8BAF\u5F55")]), (0, import_vue.createVNode)("div", {
118
+ "class": "feed-list-wrap"
119
+ }, [filteredOrgList.value.length === 0 ? (0, import_vue.createVNode)(import_vant.Empty, {
120
+ "description": "\u672A\u627E\u5230\u76F8\u5173\u4EBA\u5458"
121
+ }, null) : (0, import_vue.createVNode)(import_vant.List, null, {
122
+ default: () => [filteredOrgList.value.map((item) => (0, import_vue.createVNode)("div", {
123
+ "class": ["org-item", isSelected(item) ? "selected" : ""],
124
+ "onClick": () => handleSelect(item)
125
+ }, [(0, import_vue.createVNode)(import_vant.Image, {
126
+ "class": "org-avatar",
127
+ "src": item.avatar
128
+ }, null), (0, import_vue.createVNode)("div", {
129
+ "class": "org-name"
130
+ }, [item.name, (0, import_vue.createVNode)("span", {
131
+ "class": "org-item-select-icon"
132
+ }, [(0, import_vue.createTextVNode)("\u2713")])])]))]
133
+ })])]) : ""]);
134
+ };
135
+ return {
136
+ keyword,
137
+ searchRef,
138
+ renderSearchResult,
139
+ filteredOrgList,
140
+ recentSelectedHistory,
141
+ filterRecentSelectedHistory,
142
+ highlightText
143
+ };
144
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-mobile",
3
- "version": "1.17.7",
3
+ "version": "1.17.8",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",