@cgboiler/biz-mobile 1.6.0 → 1.7.1

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.7.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.7.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,46 @@ 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
+ if (!newValue) {
28
+ selectedItems.value = [];
29
+ return;
30
+ }
31
+ setTimeout(() => {
32
+ var _a;
33
+ if ((_a = userList.value) == null ? void 0 : _a.length) {
34
+ selectedItems.value = newValue.map((id) => {
35
+ return userList.value.find((item) => item.id === id);
36
+ });
37
+ }
38
+ }, 500);
39
+ }, {
40
+ immediate: true
41
+ });
24
42
  const handleSelect = (item) => {
25
43
  if (item.type === "dept") {
26
44
  getOrgList(item.id);
27
45
  return;
28
46
  }
29
47
  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);
48
+ const currentValue = props.modelValue ? [...props.modelValue] : [];
49
+ const index = currentValue.indexOf(item.id);
32
50
  if (index > -1) {
33
51
  currentValue.splice(index, 1);
52
+ selectedItems.value = selectedItems.value.filter((selected) => selected.id !== item.id);
34
53
  } else {
35
- currentValue.push(item);
54
+ currentValue.push(item.id);
55
+ selectedItems.value.push(item);
36
56
  }
37
57
  emit("update:modelValue", currentValue);
38
58
  } else {
39
- emit("update:modelValue", item);
59
+ selectedItems.value = [item];
60
+ emit("update:modelValue", [item.id]);
40
61
  emit("update:show", false);
41
62
  }
42
63
  };
@@ -62,15 +83,9 @@ var stdin_default = defineComponent({
62
83
  return [...personnel, ...departments];
63
84
  });
64
85
  const isSelected = (item) => {
65
- var _a;
66
86
  if (!props.modelValue)
67
87
  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
- }
88
+ return props.modelValue.includes(item.id);
74
89
  };
75
90
  const onLoad = () => {
76
91
  finished.value = true;
@@ -139,9 +154,9 @@ var stdin_default = defineComponent({
139
154
  "class": "empty-search-result"
140
155
  }, [_createTextVNode("\u672A\u627E\u5230\u76F8\u5173\u4EBA\u5458")])]), props.multiple && _createVNode("div", {
141
156
  "class": "bottom-section"
142
- }, [Array.isArray(props.modelValue) && props.modelValue.length > 0 && _createVNode("div", {
157
+ }, [selectedItems.value.length > 0 && _createVNode("div", {
143
158
  "class": "selected-items"
144
- }, [props.modelValue.map((item) => _createVNode("div", {
159
+ }, [selectedItems.value.map((item) => _createVNode("div", {
145
160
  "key": item.id,
146
161
  "class": "selected-tag",
147
162
  "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.7.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.7.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,46 @@ 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
+ if (!newValue) {
60
+ selectedItems.value = [];
61
+ return;
62
+ }
63
+ setTimeout(() => {
64
+ var _a;
65
+ if ((_a = userList.value) == null ? void 0 : _a.length) {
66
+ selectedItems.value = newValue.map((id) => {
67
+ return userList.value.find((item) => item.id === id);
68
+ });
69
+ }
70
+ }, 500);
71
+ }, {
72
+ immediate: true
73
+ });
56
74
  const handleSelect = (item) => {
57
75
  if (item.type === "dept") {
58
76
  getOrgList(item.id);
59
77
  return;
60
78
  }
61
79
  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);
80
+ const currentValue = props.modelValue ? [...props.modelValue] : [];
81
+ const index = currentValue.indexOf(item.id);
64
82
  if (index > -1) {
65
83
  currentValue.splice(index, 1);
84
+ selectedItems.value = selectedItems.value.filter((selected) => selected.id !== item.id);
66
85
  } else {
67
- currentValue.push(item);
86
+ currentValue.push(item.id);
87
+ selectedItems.value.push(item);
68
88
  }
69
89
  emit("update:modelValue", currentValue);
70
90
  } else {
71
- emit("update:modelValue", item);
91
+ selectedItems.value = [item];
92
+ emit("update:modelValue", [item.id]);
72
93
  emit("update:show", false);
73
94
  }
74
95
  };
@@ -94,15 +115,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
94
115
  return [...personnel, ...departments];
95
116
  });
96
117
  const isSelected = (item) => {
97
- var _a;
98
118
  if (!props.modelValue)
99
119
  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
- }
120
+ return props.modelValue.includes(item.id);
106
121
  };
107
122
  const onLoad = () => {
108
123
  finished.value = true;
@@ -171,9 +186,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
171
186
  "class": "empty-search-result"
172
187
  }, [(0, import_vue.createTextVNode)("\u672A\u627E\u5230\u76F8\u5173\u4EBA\u5458")])]), props.multiple && (0, import_vue.createVNode)("div", {
173
188
  "class": "bottom-section"
174
- }, [Array.isArray(props.modelValue) && props.modelValue.length > 0 && (0, import_vue.createVNode)("div", {
189
+ }, [selectedItems.value.length > 0 && (0, import_vue.createVNode)("div", {
175
190
  "class": "selected-items"
176
- }, [props.modelValue.map((item) => (0, import_vue.createVNode)("div", {
191
+ }, [selectedItems.value.map((item) => (0, import_vue.createVNode)("div", {
177
192
  "key": item.id,
178
193
  "class": "selected-tag",
179
194
  "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.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",