@cgboiler/biz-mobile 1.6.0 → 1.7.0

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
@@ -6,7 +6,7 @@ declare namespace _default {
6
6
  }
7
7
  export default _default;
8
8
  export function install(app: any): void;
9
- export const version: "1.5.0";
9
+ export const version: "1.6.0";
10
10
  import OrgPicker from './org-picker';
11
11
  import ProjectSelect from './project-select';
12
12
  export { OrgPicker, ProjectSelect };
package/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import OrgPicker from "./org-picker";
2
2
  import ProjectSelect from "./project-select";
3
- const version = "1.5.0";
3
+ const version = "1.6.0";
4
4
  function install(app) {
5
5
  const components = [
6
6
  OrgPicker,
@@ -1,8 +1,7 @@
1
- import { type OrgItem } from './types';
2
1
  import './index.less';
3
2
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
3
  modelValue: {
5
- type: import("vue").PropType<OrgItem | OrgItem[] | null>;
4
+ type: import("vue").PropType<(string | number)[] | null>;
6
5
  default: () => null;
7
6
  };
8
7
  show: {
@@ -14,14 +13,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
14
13
  default: boolean;
15
14
  };
16
15
  'onUpdate:modelValue': {
17
- type: import("vue").PropType<(val: OrgItem | OrgItem[] | null) => void>;
16
+ type: import("vue").PropType<(val: (string | number)[] | null) => void>;
18
17
  };
19
18
  'onUpdate:show': {
20
19
  type: import("vue").PropType<(val: boolean) => void>;
21
20
  };
22
21
  }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:show" | "update:modelValue")[], "update:show" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
23
22
  modelValue: {
24
- type: import("vue").PropType<OrgItem | OrgItem[] | null>;
23
+ type: import("vue").PropType<(string | number)[] | null>;
25
24
  default: () => null;
26
25
  };
27
26
  show: {
@@ -33,7 +32,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
33
32
  default: boolean;
34
33
  };
35
34
  'onUpdate:modelValue': {
36
- type: import("vue").PropType<(val: OrgItem | OrgItem[] | null) => void>;
35
+ type: import("vue").PropType<(val: (string | number)[] | null) => void>;
37
36
  };
38
37
  'onUpdate:show': {
39
38
  type: import("vue").PropType<(val: boolean) => void>;
@@ -42,7 +41,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
42
41
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
43
42
  "onUpdate:show"?: ((...args: any[]) => any) | undefined;
44
43
  }>, {
45
- modelValue: OrgItem | OrgItem[] | null;
44
+ modelValue: (string | number)[] | null;
46
45
  show: boolean;
47
46
  multiple: boolean;
48
47
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -18,25 +18,44 @@ var stdin_default = defineComponent({
18
18
  getOrgList,
19
19
  currentDeptId,
20
20
  deptPath,
21
- searchOrgList
21
+ searchOrgList,
22
+ userList
22
23
  } = useApi();
23
24
  getOrgList();
25
+ const selectedItems = ref([]);
26
+ watch(() => props.modelValue, (newValue) => {
27
+ var _a;
28
+ if (!newValue) {
29
+ selectedItems.value = [];
30
+ return;
31
+ }
32
+ if ((_a = userList.value) == null ? void 0 : _a.length) {
33
+ selectedItems.value = newValue.map((id) => {
34
+ return userList.value.find((item) => item.id === id);
35
+ });
36
+ }
37
+ }, {
38
+ immediate: true
39
+ });
24
40
  const handleSelect = (item) => {
25
41
  if (item.type === "dept") {
26
42
  getOrgList(item.id);
27
43
  return;
28
44
  }
29
45
  if (props.multiple) {
30
- const currentValue = props.modelValue ? [...Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue]] : [];
31
- const index = currentValue.findIndex((selected) => selected.id === item.id);
46
+ const currentValue = props.modelValue ? [...props.modelValue] : [];
47
+ const index = currentValue.indexOf(item.id);
32
48
  if (index > -1) {
33
49
  currentValue.splice(index, 1);
50
+ selectedItems.value = selectedItems.value.filter((selected) => selected.id !== item.id);
34
51
  } else {
35
- currentValue.push(item);
52
+ currentValue.push(item.id);
53
+ selectedItems.value.push(item);
36
54
  }
37
55
  emit("update:modelValue", currentValue);
38
56
  } else {
39
- emit("update:modelValue", item);
57
+ selectedItems.value = [item];
58
+ emit("update:modelValue", [item.id]);
40
59
  emit("update:show", false);
41
60
  }
42
61
  };
@@ -62,15 +81,9 @@ var stdin_default = defineComponent({
62
81
  return [...personnel, ...departments];
63
82
  });
64
83
  const isSelected = (item) => {
65
- var _a;
66
84
  if (!props.modelValue)
67
85
  return false;
68
- if (props.multiple) {
69
- const selectedItems = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue];
70
- return selectedItems.some((selected) => selected.id === item.id);
71
- } else {
72
- return ((_a = props.modelValue) == null ? void 0 : _a.id) === item.id;
73
- }
86
+ return props.modelValue.includes(item.id);
74
87
  };
75
88
  const onLoad = () => {
76
89
  finished.value = true;
@@ -139,9 +152,9 @@ var stdin_default = defineComponent({
139
152
  "class": "empty-search-result"
140
153
  }, [_createTextVNode("\u672A\u627E\u5230\u76F8\u5173\u4EBA\u5458")])]), props.multiple && _createVNode("div", {
141
154
  "class": "bottom-section"
142
- }, [Array.isArray(props.modelValue) && props.modelValue.length > 0 && _createVNode("div", {
155
+ }, [selectedItems.value.length > 0 && _createVNode("div", {
143
156
  "class": "selected-items"
144
- }, [props.modelValue.map((item) => _createVNode("div", {
157
+ }, [selectedItems.value.map((item) => _createVNode("div", {
145
158
  "key": item.id,
146
159
  "class": "selected-tag",
147
160
  "onClick": () => handleSelect(item)
@@ -7,7 +7,7 @@ export interface OrgItem {
7
7
  }
8
8
  export declare const orgPickerProps: {
9
9
  modelValue: {
10
- type: PropType<OrgItem | OrgItem[] | null>;
10
+ type: PropType<(string | number)[] | null>;
11
11
  default: () => null;
12
12
  };
13
13
  show: {
@@ -19,7 +19,7 @@ export declare const orgPickerProps: {
19
19
  default: boolean;
20
20
  };
21
21
  'onUpdate:modelValue': {
22
- type: PropType<(val: OrgItem | OrgItem[] | null) => void>;
22
+ type: PropType<(val: (string | number)[] | null) => void>;
23
23
  };
24
24
  'onUpdate:show': {
25
25
  type: PropType<(val: boolean) => void>;
@@ -1,6 +1,6 @@
1
1
  const orgPickerProps = {
2
2
  modelValue: {
3
- type: [Object, Array],
3
+ type: Array,
4
4
  default: () => null
5
5
  },
6
6
  show: {
@@ -1,5 +1,6 @@
1
1
  import { type OrgItem } from './types';
2
2
  export declare const useApi: () => {
3
+ userList: import("vue").Ref<never[], never[]>;
3
4
  orgList: import("vue").Ref<{
4
5
  id: string | number;
5
6
  name: string;
@@ -35,6 +35,14 @@ const fetchOrgList = (deptId) => __async(void 0, null, function* () {
35
35
  orgListCache.set(deptId || "", res);
36
36
  return res;
37
37
  });
38
+ const userList = ref([]);
39
+ const fetchUserList = () => __async(void 0, null, function* () {
40
+ const res = (yield useFetch(`https://wflow.cgboiler.com/v1/oa/org/alluserbycompanyid`, {
41
+ method: "GET"
42
+ })) || [];
43
+ userList.value = res;
44
+ });
45
+ fetchUserList();
38
46
  const useApi = () => {
39
47
  const orgList = ref([]);
40
48
  const currentDeptId = ref("1");
@@ -69,6 +77,7 @@ const useApi = () => {
69
77
  orgList.value = res || [];
70
78
  }), 300);
71
79
  return {
80
+ userList,
72
81
  orgList,
73
82
  getOrgList,
74
83
  currentDeptId,
package/lib/index.d.ts CHANGED
@@ -6,7 +6,7 @@ declare namespace _default {
6
6
  }
7
7
  export default _default;
8
8
  export function install(app: any): void;
9
- export const version: "1.5.0";
9
+ export const version: "1.6.0";
10
10
  import OrgPicker from './org-picker';
11
11
  import ProjectSelect from './project-select';
12
12
  export { OrgPicker, ProjectSelect };
package/lib/index.js CHANGED
@@ -39,7 +39,7 @@ var import_org_picker = __toESM(require("./org-picker"));
39
39
  var import_project_select = __toESM(require("./project-select"));
40
40
  __reExport(stdin_exports, require("./org-picker"), module.exports);
41
41
  __reExport(stdin_exports, require("./project-select"), module.exports);
42
- const version = "1.5.0";
42
+ const version = "1.6.0";
43
43
  function install(app) {
44
44
  const components = [
45
45
  import_org_picker.default,
@@ -1,8 +1,7 @@
1
- import { type OrgItem } from './types';
2
1
  import './index.less';
3
2
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
3
  modelValue: {
5
- type: import("vue").PropType<OrgItem | OrgItem[] | null>;
4
+ type: import("vue").PropType<(string | number)[] | null>;
6
5
  default: () => null;
7
6
  };
8
7
  show: {
@@ -14,14 +13,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
14
13
  default: boolean;
15
14
  };
16
15
  'onUpdate:modelValue': {
17
- type: import("vue").PropType<(val: OrgItem | OrgItem[] | null) => void>;
16
+ type: import("vue").PropType<(val: (string | number)[] | null) => void>;
18
17
  };
19
18
  'onUpdate:show': {
20
19
  type: import("vue").PropType<(val: boolean) => void>;
21
20
  };
22
21
  }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:show" | "update:modelValue")[], "update:show" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
23
22
  modelValue: {
24
- type: import("vue").PropType<OrgItem | OrgItem[] | null>;
23
+ type: import("vue").PropType<(string | number)[] | null>;
25
24
  default: () => null;
26
25
  };
27
26
  show: {
@@ -33,7 +32,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
33
32
  default: boolean;
34
33
  };
35
34
  'onUpdate:modelValue': {
36
- type: import("vue").PropType<(val: OrgItem | OrgItem[] | null) => void>;
35
+ type: import("vue").PropType<(val: (string | number)[] | null) => void>;
37
36
  };
38
37
  'onUpdate:show': {
39
38
  type: import("vue").PropType<(val: boolean) => void>;
@@ -42,7 +41,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
42
41
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
43
42
  "onUpdate:show"?: ((...args: any[]) => any) | undefined;
44
43
  }>, {
45
- modelValue: OrgItem | OrgItem[] | null;
44
+ modelValue: (string | number)[] | null;
46
45
  show: boolean;
47
46
  multiple: boolean;
48
47
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -50,25 +50,44 @@ var stdin_default = (0, import_vue2.defineComponent)({
50
50
  getOrgList,
51
51
  currentDeptId,
52
52
  deptPath,
53
- searchOrgList
53
+ searchOrgList,
54
+ userList
54
55
  } = (0, import_useApi.useApi)();
55
56
  getOrgList();
57
+ const selectedItems = (0, import_vue2.ref)([]);
58
+ (0, import_vue2.watch)(() => props.modelValue, (newValue) => {
59
+ var _a;
60
+ if (!newValue) {
61
+ selectedItems.value = [];
62
+ return;
63
+ }
64
+ if ((_a = userList.value) == null ? void 0 : _a.length) {
65
+ selectedItems.value = newValue.map((id) => {
66
+ return userList.value.find((item) => item.id === id);
67
+ });
68
+ }
69
+ }, {
70
+ immediate: true
71
+ });
56
72
  const handleSelect = (item) => {
57
73
  if (item.type === "dept") {
58
74
  getOrgList(item.id);
59
75
  return;
60
76
  }
61
77
  if (props.multiple) {
62
- const currentValue = props.modelValue ? [...Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue]] : [];
63
- const index = currentValue.findIndex((selected) => selected.id === item.id);
78
+ const currentValue = props.modelValue ? [...props.modelValue] : [];
79
+ const index = currentValue.indexOf(item.id);
64
80
  if (index > -1) {
65
81
  currentValue.splice(index, 1);
82
+ selectedItems.value = selectedItems.value.filter((selected) => selected.id !== item.id);
66
83
  } else {
67
- currentValue.push(item);
84
+ currentValue.push(item.id);
85
+ selectedItems.value.push(item);
68
86
  }
69
87
  emit("update:modelValue", currentValue);
70
88
  } else {
71
- emit("update:modelValue", item);
89
+ selectedItems.value = [item];
90
+ emit("update:modelValue", [item.id]);
72
91
  emit("update:show", false);
73
92
  }
74
93
  };
@@ -94,15 +113,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
94
113
  return [...personnel, ...departments];
95
114
  });
96
115
  const isSelected = (item) => {
97
- var _a;
98
116
  if (!props.modelValue)
99
117
  return false;
100
- if (props.multiple) {
101
- const selectedItems = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue];
102
- return selectedItems.some((selected) => selected.id === item.id);
103
- } else {
104
- return ((_a = props.modelValue) == null ? void 0 : _a.id) === item.id;
105
- }
118
+ return props.modelValue.includes(item.id);
106
119
  };
107
120
  const onLoad = () => {
108
121
  finished.value = true;
@@ -171,9 +184,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
171
184
  "class": "empty-search-result"
172
185
  }, [(0, import_vue.createTextVNode)("\u672A\u627E\u5230\u76F8\u5173\u4EBA\u5458")])]), props.multiple && (0, import_vue.createVNode)("div", {
173
186
  "class": "bottom-section"
174
- }, [Array.isArray(props.modelValue) && props.modelValue.length > 0 && (0, import_vue.createVNode)("div", {
187
+ }, [selectedItems.value.length > 0 && (0, import_vue.createVNode)("div", {
175
188
  "class": "selected-items"
176
- }, [props.modelValue.map((item) => (0, import_vue.createVNode)("div", {
189
+ }, [selectedItems.value.map((item) => (0, import_vue.createVNode)("div", {
177
190
  "key": item.id,
178
191
  "class": "selected-tag",
179
192
  "onClick": () => handleSelect(item)
@@ -7,7 +7,7 @@ export interface OrgItem {
7
7
  }
8
8
  export declare const orgPickerProps: {
9
9
  modelValue: {
10
- type: PropType<OrgItem | OrgItem[] | null>;
10
+ type: PropType<(string | number)[] | null>;
11
11
  default: () => null;
12
12
  };
13
13
  show: {
@@ -19,7 +19,7 @@ export declare const orgPickerProps: {
19
19
  default: boolean;
20
20
  };
21
21
  'onUpdate:modelValue': {
22
- type: PropType<(val: OrgItem | OrgItem[] | null) => void>;
22
+ type: PropType<(val: (string | number)[] | null) => void>;
23
23
  };
24
24
  'onUpdate:show': {
25
25
  type: PropType<(val: boolean) => void>;
@@ -22,7 +22,7 @@ __export(stdin_exports, {
22
22
  module.exports = __toCommonJS(stdin_exports);
23
23
  const orgPickerProps = {
24
24
  modelValue: {
25
- type: [Object, Array],
25
+ type: Array,
26
26
  default: () => null
27
27
  },
28
28
  show: {
@@ -1,5 +1,6 @@
1
1
  import { type OrgItem } from './types';
2
2
  export declare const useApi: () => {
3
+ userList: import("vue").Ref<never[], never[]>;
3
4
  orgList: import("vue").Ref<{
4
5
  id: string | number;
5
6
  name: string;
@@ -57,6 +57,14 @@ const fetchOrgList = (deptId) => __async(void 0, null, function* () {
57
57
  orgListCache.set(deptId || "", res);
58
58
  return res;
59
59
  });
60
+ const userList = (0, import_vue.ref)([]);
61
+ const fetchUserList = () => __async(void 0, null, function* () {
62
+ const res = (yield (0, import_core.useFetch)(`https://wflow.cgboiler.com/v1/oa/org/alluserbycompanyid`, {
63
+ method: "GET"
64
+ })) || [];
65
+ userList.value = res;
66
+ });
67
+ fetchUserList();
60
68
  const useApi = () => {
61
69
  const orgList = (0, import_vue.ref)([]);
62
70
  const currentDeptId = (0, import_vue.ref)("1");
@@ -91,6 +99,7 @@ const useApi = () => {
91
99
  orgList.value = res || [];
92
100
  }), 300);
93
101
  return {
102
+ userList,
94
103
  orgList,
95
104
  getOrgList,
96
105
  currentDeptId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-mobile",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",