@power-xa/m-ui 0.0.6 → 0.0.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/README.md +37 -17
- package/dist/ActionSheet/index.js +5 -3
- package/dist/Breadcrumb/index.js +4 -2
- package/dist/Calendar/Date/index.d.ts +8 -0
- package/dist/Calendar/Date/index.js +246 -0
- package/dist/Calendar/Date/index.less +146 -0
- package/dist/Calendar/Month/index.d.ts +7 -0
- package/dist/Calendar/Month/index.js +199 -0
- package/dist/Calendar/Month/index.less +96 -0
- package/dist/Calendar/Week/index.d.ts +7 -0
- package/dist/Calendar/Week/index.js +200 -0
- package/dist/Calendar/Week/index.less +96 -0
- package/dist/Calendar/index.d.ts +10 -0
- package/dist/Calendar/index.js +9 -0
- package/dist/ConfigProvider/index.d.ts +1 -0
- package/dist/Drawer/index.d.ts +1 -0
- package/dist/Drawer/index.js +38 -20
- package/dist/Drawer/index.less +2 -1
- package/dist/Filter/index.d.ts +3 -0
- package/dist/Filter/index.js +8 -6
- package/dist/ProForm/Controls/Cascader/index.d.ts +28 -0
- package/dist/ProForm/Controls/Cascader/index.js +159 -0
- package/dist/ProForm/Controls/Cascader/index.less +106 -0
- package/dist/ProForm/Controls/Date/index.d.ts +6 -1
- package/dist/ProForm/Controls/Date/index.js +12 -4
- package/dist/ProForm/Controls/Date/index.less +18 -0
- package/dist/ProForm/Controls/List/index.d.ts +2 -8
- package/dist/ProForm/Controls/List/index.js +17 -9
- package/dist/ProForm/Controls/List/index.less +0 -0
- package/dist/ProForm/Controls/Select/index.d.ts +50 -1
- package/dist/ProForm/Controls/Select/index.js +289 -211
- package/dist/ProForm/Controls/Select/index.less +29 -0
- package/dist/ProForm/Controls/Stepper/index.d.ts +10 -0
- package/dist/ProForm/Controls/Stepper/index.js +72 -0
- package/dist/ProForm/Controls/Stepper/index.less +31 -0
- package/dist/ProForm/Controls/Switch/index.d.ts +5 -0
- package/dist/ProForm/Controls/Switch/index.js +21 -0
- package/dist/ProForm/Controls/Switch/index.less +3 -0
- package/dist/ProForm/Controls/Text/index.d.ts +9 -2
- package/dist/ProForm/Controls/Text/index.js +12 -12
- package/dist/ProForm/Controls/Text/index.less +0 -0
- package/dist/ProForm/Controls/TextArea/index.d.ts +6 -1
- package/dist/ProForm/Controls/TextArea/index.js +10 -11
- package/dist/ProForm/Controls/Upload/index.d.ts +32 -9
- package/dist/ProForm/Controls/Upload/index.js +14 -6
- package/dist/ProForm/Controls/Upload/index.less +0 -0
- package/dist/ProForm/Field/index.d.ts +27 -4
- package/dist/ProForm/Field/index.js +12 -13
- package/dist/ProForm/Field/index.less +0 -4
- package/dist/ProForm/Form/index.d.ts +41 -6
- package/dist/ProForm/Form/index.js +294 -172
- package/dist/ProForm/Form/index.less +0 -0
- package/dist/ProForm/Group/index.d.ts +22 -3
- package/dist/ProForm/Group/index.js +8 -30
- package/dist/ProForm/Group/index.less +0 -0
- package/dist/ProForm/index.d.ts +4 -4
- package/dist/ProForm/index.js +5 -5
- package/dist/ProList/index.d.ts +8 -2
- package/dist/ProList/index.js +6 -4
- package/dist/Tabbar/index.d.ts +4 -2
- package/dist/Tabbar/index.js +14 -5
- package/dist/Tabs/index.d.ts +8 -5
- package/dist/Tabs/index.js +6 -6
- package/dist/Tabs/index.less +4 -1
- package/dist/UserView/index.d.ts +15 -0
- package/dist/UserView/index.js +62 -0
- package/dist/UserView/index.less +41 -0
- package/dist/ValidMobilePopup/index.d.ts +9 -0
- package/dist/ValidMobilePopup/index.js +147 -0
- package/dist/ValidMobilePopup/index.less +58 -0
- package/dist/hooks/index.d.ts +22 -0
- package/dist/hooks/index.js +51 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +9 -1
- package/dist/services/CommonController/index.d.ts +5 -0
- package/dist/services/CommonController/index.js +21 -0
- package/dist/services/CommonController/typings.d.ts +0 -0
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +2 -1
- package/package.json +6 -3
- package/dist/ProForm/typings.d.ts +0 -164
- package/dist/RefreshList/index.d.ts +0 -17
- package/dist/RefreshList/index.js +0 -43
- package/dist/RefreshList/index.less +0 -19
- package/dist/assets/fonts/PingFangSC-Light.ttf +0 -0
- package/dist/assets/fonts/PingFangSC-Medium.ttf +0 -0
- package/dist/assets/fonts/PingFangSC-Regular.ttf +0 -0
|
@@ -1,10 +1,59 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
|
+
import type { ProFormFieldProps } from "../../Field";
|
|
2
3
|
import "./index.less";
|
|
3
|
-
type
|
|
4
|
+
type Location = {
|
|
5
|
+
longitude: number;
|
|
6
|
+
latitude: number;
|
|
7
|
+
address: string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
type SourceType = {
|
|
11
|
+
user?: "ALL" | "IN" | "OUT" | "OTHER" | "SEAT" | "NO-SEAT";
|
|
12
|
+
unit?: "ALL" | "USER" | "UNIT";
|
|
13
|
+
organization?: "ALL" | "USER" | "DEPT";
|
|
14
|
+
external?: "ALL" | "USER" | "EXTERNAL";
|
|
15
|
+
rule?: "ALL" | "USER" | "RULE";
|
|
16
|
+
};
|
|
17
|
+
export type ProFormSelectProps = ProFormFieldProps & {
|
|
18
|
+
options?: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}[];
|
|
21
|
+
renderOptions?: (option: {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}) => ReactNode;
|
|
24
|
+
multiple?: boolean;
|
|
25
|
+
params?: {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
request?: (params?: {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}) => Promise<{
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}[]>;
|
|
33
|
+
fieldNames?: {
|
|
34
|
+
label: string;
|
|
35
|
+
value: string;
|
|
36
|
+
children?: string;
|
|
37
|
+
};
|
|
38
|
+
optionType?: boolean;
|
|
39
|
+
projectId?: string;
|
|
40
|
+
companyId?: string;
|
|
41
|
+
source?: SourceType | string;
|
|
42
|
+
filter?: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
4
45
|
popupExtra?: {
|
|
5
46
|
top?: ReactNode;
|
|
6
47
|
bottom?: ReactNode;
|
|
7
48
|
};
|
|
49
|
+
location?: {
|
|
50
|
+
text?: string;
|
|
51
|
+
onChange?: (location: Location) => Location;
|
|
52
|
+
renderLocation?: (location: Location, index: number, option: {
|
|
53
|
+
onDelete: (index: number) => void;
|
|
54
|
+
onEdit: (index: number, location: Location) => void;
|
|
55
|
+
}) => ReactNode;
|
|
56
|
+
};
|
|
8
57
|
};
|
|
9
58
|
declare const ProFormSelect: FC<ProFormSelectProps>;
|
|
10
59
|
export default ProFormSelect;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
var _excluded = ["children", "optionType", "request", "disabled", "multiple", "onChange", "fieldNames", "placeholder", "companyId", "projectId", "source", "popupExtra", "filter", "location", "renderOptions", "dependencies", "getFieldValue", "params"];
|
|
1
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -9,260 +9,338 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
9
9
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
11
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
13
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
14
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
15
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
16
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
17
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
17
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
20
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
|
+
import React, { Fragment, useCallback, useMemo, useState } from "react";
|
|
22
|
+
import { navigateTo, chooseLocation } from "@tarojs/taro";
|
|
20
23
|
import { ScrollView, Text, View } from "@tarojs/components";
|
|
21
|
-
import { getListAssignField, Popup, SearchInput } from "../../..";
|
|
24
|
+
import { Empty, getListAssignField, Popup, SearchInput } from "../../..";
|
|
25
|
+
import { isArray, isEqual, set } from "lodash";
|
|
26
|
+
import { useDebounceEffect } from "ahooks";
|
|
22
27
|
import ProFormField from "../../Field";
|
|
23
28
|
import "./index.less";
|
|
24
|
-
var ProFormSelect = function ProFormSelect(
|
|
25
|
-
var
|
|
26
|
-
|
|
29
|
+
var ProFormSelect = function ProFormSelect(_ref) {
|
|
30
|
+
var children = _ref.children,
|
|
31
|
+
optionType = _ref.optionType,
|
|
32
|
+
request = _ref.request,
|
|
33
|
+
disabled = _ref.disabled,
|
|
34
|
+
multiple = _ref.multiple,
|
|
35
|
+
_onChange = _ref.onChange,
|
|
36
|
+
_ref$fieldNames = _ref.fieldNames,
|
|
37
|
+
fieldNames = _ref$fieldNames === void 0 ? {
|
|
27
38
|
value: "value",
|
|
28
39
|
label: "label"
|
|
29
|
-
} :
|
|
30
|
-
|
|
31
|
-
placeholder =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
source = props.source,
|
|
45
|
-
disabled = props.disabled,
|
|
46
|
-
popupExtra = props.popupExtra;
|
|
47
|
-
var _useState = useState([]),
|
|
40
|
+
} : _ref$fieldNames,
|
|
41
|
+
_ref$placeholder = _ref.placeholder,
|
|
42
|
+
placeholder = _ref$placeholder === void 0 ? "请选择" : _ref$placeholder,
|
|
43
|
+
companyId = _ref.companyId,
|
|
44
|
+
projectId = _ref.projectId,
|
|
45
|
+
source = _ref.source,
|
|
46
|
+
popupExtra = _ref.popupExtra,
|
|
47
|
+
filter = _ref.filter,
|
|
48
|
+
location = _ref.location,
|
|
49
|
+
renderOptions = _ref.renderOptions,
|
|
50
|
+
dependencies = _ref.dependencies,
|
|
51
|
+
getFieldValue = _ref.getFieldValue,
|
|
52
|
+
params = _ref.params,
|
|
53
|
+
fieldProps = _objectWithoutProperties(_ref, _excluded);
|
|
54
|
+
var _useState = useState(false),
|
|
48
55
|
_useState2 = _slicedToArray(_useState, 2),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var _useState3 = useState(
|
|
56
|
+
open = _useState2[0],
|
|
57
|
+
setOpen = _useState2[1];
|
|
58
|
+
var _useState3 = useState(),
|
|
52
59
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
60
|
value = _useState4[0],
|
|
54
61
|
setValue = _useState4[1];
|
|
55
|
-
var _useState5 = useState(
|
|
62
|
+
var _useState5 = useState([]),
|
|
56
63
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
options = _useState6[0],
|
|
65
|
+
setOptions = _useState6[1];
|
|
66
|
+
useDebounceEffect(function () {
|
|
67
|
+
if ((["string", "boolean", "number"].includes(_typeof(fieldProps.value)) || fieldProps.value === null) && fieldProps.value !== value) setValue(fieldProps.value);
|
|
68
|
+
if (!isEqual(fieldProps.value, value)) setValue(fieldProps.value);
|
|
69
|
+
if (!fieldProps.value && multiple) setValue([]);
|
|
70
|
+
}, [fieldProps.value], {
|
|
71
|
+
wait: 200
|
|
72
|
+
});
|
|
73
|
+
useDebounceEffect(function () {
|
|
74
|
+
if (!isEqual(fieldProps.options, options)) setOptions(fieldProps.options || []);
|
|
75
|
+
}, [fieldProps.options], {
|
|
76
|
+
wait: 200
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/* 监听依赖值变化 */
|
|
80
|
+
useDebounceEffect(function () {
|
|
69
81
|
if (dependencies) {
|
|
70
82
|
/* 监听Form其他字段值 */
|
|
71
|
-
if (request &&
|
|
83
|
+
if (request && getFieldValue !== null && getFieldValue !== void 0 && getFieldValue(dependencies)) {
|
|
72
84
|
var requestParams = _objectSpread({}, params);
|
|
73
|
-
requestParams
|
|
85
|
+
set(requestParams, dependencies, getFieldValue === null || getFieldValue === void 0 ? void 0 : getFieldValue(dependencies));
|
|
74
86
|
request(requestParams).then(function (result) {
|
|
75
87
|
setOptions(result);
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
if (fieldProps.value) {
|
|
89
|
+
if (!(fieldProps.value instanceof Array)) {
|
|
90
|
+
if (!result.some(function (item) {
|
|
91
|
+
return item.value === fieldProps.value;
|
|
92
|
+
})) {
|
|
93
|
+
_onChange === null || _onChange === void 0 || _onChange(null);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
_onChange === null || _onChange === void 0 || _onChange(fieldProps.value.filter(function (v) {
|
|
97
|
+
return result.some(function (r) {
|
|
98
|
+
return r.value === v;
|
|
99
|
+
});
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
82
102
|
}
|
|
83
103
|
});
|
|
84
104
|
}
|
|
85
105
|
}
|
|
86
|
-
}, [dependencies ?
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
}, [dependencies ? getFieldValue === null || getFieldValue === void 0 ? void 0 : getFieldValue(dependencies) : null]);
|
|
107
|
+
var _onTap = useCallback(function (e) {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
if (disabled) return false;
|
|
110
|
+
if (companyId || projectId) {
|
|
111
|
+
var url = "";
|
|
112
|
+
var eventName = "getSelectParams";
|
|
113
|
+
var _params = {
|
|
114
|
+
companyId: companyId,
|
|
115
|
+
projectId: projectId,
|
|
116
|
+
multiple: multiple,
|
|
117
|
+
value: value,
|
|
118
|
+
source: source,
|
|
119
|
+
filter: filter,
|
|
120
|
+
onChange: function onChange(result) {
|
|
121
|
+
setValue(result);
|
|
122
|
+
_onChange === null || _onChange === void 0 || _onChange(result);
|
|
102
123
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
124
|
+
};
|
|
125
|
+
if (!(source !== null && source !== void 0 && source.organization) && !(source !== null && source !== void 0 && source.unit)) {
|
|
126
|
+
url = "/screens/common/select/user/index";
|
|
127
|
+
_params.source = source === null || source === void 0 ? void 0 : source.user;
|
|
128
|
+
} else {
|
|
129
|
+
url = "/screens/common/select/".concat(companyId ? 'company' : "project", "/index");
|
|
130
|
+
var recent = false;
|
|
131
|
+
for (var _key in source) {
|
|
132
|
+
if (["ALL", "USER"].includes(source[_key])) recent = true;
|
|
133
|
+
}
|
|
134
|
+
if (recent) {
|
|
135
|
+
url = "/screens/common/select/recent/index";
|
|
136
|
+
eventName = "getRecentParams";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
105
139
|
navigateTo({
|
|
106
|
-
url:
|
|
140
|
+
url: url,
|
|
107
141
|
success: function success(result) {
|
|
108
|
-
result.eventChannel.emit(
|
|
109
|
-
value: value ? _toConsumableArray(value) : [],
|
|
110
|
-
onChange: function onChange(result) {
|
|
111
|
-
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(result);
|
|
112
|
-
}
|
|
113
|
-
}));
|
|
142
|
+
return result.eventChannel.emit(eventName, _params);
|
|
114
143
|
}
|
|
115
144
|
});
|
|
145
|
+
} else {
|
|
146
|
+
setOpen(true);
|
|
116
147
|
}
|
|
117
|
-
}, [value]);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return getListAssignField(v, options, fieldNames);
|
|
124
|
-
}).join("、");
|
|
125
|
-
return value.map(function (v) {
|
|
126
|
-
return v[fieldNames.label];
|
|
127
|
-
}).join("、");
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, [value, options]);
|
|
131
|
-
var renderPopupSelectIcon = useCallback(function (option) {
|
|
132
|
-
if (["string", "boolean"].includes(_typeof(value)) && value === option) return /*#__PURE__*/React.createElement(View, {
|
|
133
|
-
className: "iconfont icon-icon-radio"
|
|
148
|
+
}, [value, disabled]);
|
|
149
|
+
|
|
150
|
+
/* 渲染选择图标 */
|
|
151
|
+
var renderIcon = useCallback(function (v) {
|
|
152
|
+
if (value === v || value instanceof Array && value.includes(v)) return /*#__PURE__*/React.createElement(View, {
|
|
153
|
+
className: "iconfont ".concat(multiple ? 'icon-icon-checkbox' : 'icon-icon-radio')
|
|
134
154
|
});
|
|
135
|
-
if (value instanceof Array) {
|
|
136
|
-
if (typeof value[0] === "string" && value.some(function (v) {
|
|
137
|
-
return v === option;
|
|
138
|
-
})) return /*#__PURE__*/React.createElement(View, {
|
|
139
|
-
className: "iconfont icon-icon-checkbox"
|
|
140
|
-
});
|
|
141
|
-
if (value.some(function (v) {
|
|
142
|
-
return v[fieldNames.value] === option;
|
|
143
|
-
})) return /*#__PURE__*/React.createElement(View, {
|
|
144
|
-
className: "iconfont icon-icon-checkbox"
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
155
|
return /*#__PURE__*/React.createElement(View, {
|
|
148
156
|
className: "iconfont icon-icon-circle"
|
|
149
157
|
});
|
|
150
158
|
}, [value]);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
|
|
160
|
+
/* 渲染文字 */
|
|
161
|
+
var renderText = useCallback(function () {
|
|
162
|
+
if (["string", "boolean", "number"].includes(_typeof(value)) || value === null) return getListAssignField(value, options, fieldNames);
|
|
163
|
+
if (isArray(value)) return value.map(function (v) {
|
|
164
|
+
return ["string", "boolean", "number"].includes(_typeof(v)) || v === null ? getListAssignField(v, options, fieldNames) : v[fieldNames.label];
|
|
165
|
+
}).join("、");
|
|
166
|
+
}, [value, options]);
|
|
167
|
+
var renderContent = useCallback(function () {
|
|
168
|
+
/* 地址选择 */
|
|
169
|
+
if (location) return /*#__PURE__*/React.createElement(ProFormField, _extends({
|
|
170
|
+
layout: "vertical"
|
|
171
|
+
}, fieldProps), /*#__PURE__*/React.createElement(View, {
|
|
172
|
+
className: "p-pro-form-select-location-container"
|
|
173
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
174
|
+
className: "p-pro-form-select-location-button",
|
|
159
175
|
onTap: function onTap() {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
} else {
|
|
174
|
-
_onChange === null || _onChange === void 0 || _onChange(item[fieldNames.value]);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}, renderPopupSelectIcon(item[fieldNames.value]), /*#__PURE__*/React.createElement(Text, {
|
|
178
|
-
className: "p-pro-form-item-select-option-text"
|
|
179
|
-
}, item[fieldNames.label]));
|
|
180
|
-
})) : /*#__PURE__*/React.createElement(View, {
|
|
181
|
-
className: "error-view"
|
|
182
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
183
|
-
className: "text"
|
|
184
|
-
}, "\u6682\u65E0\u6570\u636E"))));
|
|
185
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(ProFormField, _extends({}, props, {
|
|
186
|
-
layout: "horizontal"
|
|
187
|
-
}), /*#__PURE__*/React.createElement(View, {
|
|
188
|
-
className: "p-pro-form-item-select",
|
|
189
|
-
onTap: function onTap() {
|
|
190
|
-
if (disabled) return false;
|
|
191
|
-
if (companyId || projectId) {
|
|
192
|
-
onSelect();
|
|
193
|
-
} else {
|
|
194
|
-
setOpen(true);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}, disabled ? /*#__PURE__*/React.createElement(Text, {
|
|
198
|
-
className: "p-pro-form-item-control-disabled"
|
|
199
|
-
}, renderValueText() || "-") : value ? /*#__PURE__*/React.createElement(Text, {
|
|
200
|
-
className: "p-pro-form-item-value"
|
|
201
|
-
}, renderValueText()) : /*#__PURE__*/React.createElement(Text, {
|
|
202
|
-
className: "p-pro-form-item-placeholder"
|
|
203
|
-
}, placeholder))), !companyId && !projectId && /*#__PURE__*/React.createElement(Popup, {
|
|
204
|
-
open: open,
|
|
205
|
-
onOpenChange: function onOpenChange(open) {
|
|
206
|
-
return setOpen(open);
|
|
207
|
-
},
|
|
208
|
-
rootClassName: "p-pro-form-item-select-popup-container",
|
|
209
|
-
header: {
|
|
210
|
-
title: label,
|
|
211
|
-
extra: {
|
|
212
|
-
right: multiple && /*#__PURE__*/React.createElement(Text, {
|
|
213
|
-
className: "text",
|
|
214
|
-
onClick: function onClick() {
|
|
215
|
-
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(value);
|
|
176
|
+
return chooseLocation({
|
|
177
|
+
success: function success(result) {
|
|
178
|
+
var _location$onChange;
|
|
179
|
+
var v = [];
|
|
180
|
+
if (multiple) v = _toConsumableArray(value || []);
|
|
181
|
+
var l = {
|
|
182
|
+
longitude: result.longitude,
|
|
183
|
+
latitude: result.latitude,
|
|
184
|
+
address: result.address
|
|
185
|
+
};
|
|
186
|
+
var r = (_location$onChange = location.onChange) === null || _location$onChange === void 0 ? void 0 : _location$onChange.call(location, l);
|
|
187
|
+
v.push(r || l);
|
|
188
|
+
_onChange === null || _onChange === void 0 || _onChange(v);
|
|
216
189
|
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}, function (_ref) {
|
|
221
|
-
var onOpenChange = _ref.onOpenChange;
|
|
222
|
-
return /*#__PURE__*/React.createElement(Fragment, null, popupExtra === null || popupExtra === void 0 ? void 0 : popupExtra.top, /*#__PURE__*/React.createElement(SearchInput, {
|
|
223
|
-
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",
|
|
224
|
-
onSearch: function onSearch(value) {
|
|
225
|
-
var _props$options2;
|
|
226
|
-
return setOptions(((_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.filter(function (item) {
|
|
227
|
-
return item[fieldNames.label].indexOf(value) >= 0;
|
|
228
|
-
})) || []);
|
|
190
|
+
});
|
|
229
191
|
}
|
|
230
|
-
}
|
|
231
|
-
className: "
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}, options.length ? /*#__PURE__*/React.createElement(Fragment, null, options.map(function (item) {
|
|
192
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
193
|
+
className: "iconfont icon-icon-xianmudizhi"
|
|
194
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
195
|
+
className: "text"
|
|
196
|
+
}, location.text)), value && value !== null && value !== void 0 && value.length ? value.map(function (v, i) {
|
|
197
|
+
var _location$renderLocat;
|
|
237
198
|
return /*#__PURE__*/React.createElement(View, {
|
|
238
|
-
|
|
239
|
-
|
|
199
|
+
key: 'p-pro-form-location-' + i,
|
|
200
|
+
className: "p-pro-form-select-location-view",
|
|
240
201
|
onTap: function onTap() {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
202
|
+
return navigateTo({
|
|
203
|
+
url: "/screens/common/map/index",
|
|
204
|
+
success: function success(result) {
|
|
205
|
+
return result.eventChannel.emit("getLocationParams", {
|
|
206
|
+
latitude: v === null || v === void 0 ? void 0 : v.latitude,
|
|
207
|
+
longitude: v === null || v === void 0 ? void 0 : v.longitude
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}, (_location$renderLocat = location.renderLocation) === null || _location$renderLocat === void 0 ? void 0 : _location$renderLocat.call(location, v, i, {
|
|
213
|
+
onDelete: function onDelete(i) {
|
|
214
|
+
var v = _toConsumableArray(value);
|
|
215
|
+
v.splice(i, 1);
|
|
216
|
+
_onChange === null || _onChange === void 0 || _onChange(v);
|
|
217
|
+
},
|
|
218
|
+
onEdit: function onEdit(i, l) {
|
|
219
|
+
var v = _toConsumableArray(value);
|
|
220
|
+
v.splice(i, 1, l);
|
|
221
|
+
_onChange === null || _onChange === void 0 || _onChange(v);
|
|
222
|
+
}
|
|
223
|
+
}));
|
|
224
|
+
}) : null));
|
|
225
|
+
if (optionType) {
|
|
226
|
+
/* 选项平铺,做Checkbox/Radio展示 */
|
|
227
|
+
var ol = options || [];
|
|
228
|
+
if (!request && !ol.length) ol = [{
|
|
229
|
+
value: true
|
|
230
|
+
}];
|
|
231
|
+
return /*#__PURE__*/React.createElement(ProFormField, _extends({
|
|
232
|
+
layout: "vertical"
|
|
233
|
+
}, fieldProps), /*#__PURE__*/React.createElement(View, {
|
|
234
|
+
className: "p-pro-form-item-select"
|
|
235
|
+
}, ol.map(function (o, oi) {
|
|
236
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
237
|
+
key: 'p-pro-form-item-select-option-' + oi,
|
|
238
|
+
className: "p-pro-form-item-select-option ".concat(disabled ? 'disabled' : ''),
|
|
239
|
+
onTap: function onTap() {
|
|
240
|
+
if (disabled) return false;
|
|
241
|
+
if (value instanceof Array) {
|
|
242
|
+
if (value.some(function (v) {
|
|
243
|
+
return v === o[fieldNames.value];
|
|
244
|
+
})) {
|
|
245
|
+
value.splice(value.findIndex(function (v) {
|
|
246
|
+
return v === o[fieldNames.value];
|
|
247
|
+
}), 1);
|
|
248
|
+
} else {
|
|
249
|
+
value.push(o[fieldNames.value]);
|
|
250
|
+
}
|
|
251
|
+
_onChange === null || _onChange === void 0 || _onChange(value);
|
|
249
252
|
} else {
|
|
250
|
-
|
|
253
|
+
_onChange === null || _onChange === void 0 || _onChange(o[fieldNames.value]);
|
|
251
254
|
}
|
|
252
|
-
setValue(_toConsumableArray(v));
|
|
253
|
-
} else {
|
|
254
|
-
onOpenChange();
|
|
255
|
-
_onChange === null || _onChange === void 0 || _onChange(item[fieldNames.value]);
|
|
256
255
|
}
|
|
256
|
+
}, renderIcon(o[fieldNames.value]), o[fieldNames.label] && /*#__PURE__*/React.createElement(Text, {
|
|
257
|
+
className: "p-pro-form-item-select-option-text"
|
|
258
|
+
}, o[fieldNames.label]));
|
|
259
|
+
})));
|
|
260
|
+
}
|
|
261
|
+
/* 默认选择组件 */
|
|
262
|
+
return /*#__PURE__*/React.createElement(Fragment, null, children ? /*#__PURE__*/React.createElement(View, {
|
|
263
|
+
className: "p-select-container",
|
|
264
|
+
onTap: function onTap(e) {
|
|
265
|
+
return _onTap(e);
|
|
266
|
+
}
|
|
267
|
+
}, children) : /*#__PURE__*/React.createElement(ProFormField, _extends({
|
|
268
|
+
layout: "horizontal"
|
|
269
|
+
}, fieldProps), /*#__PURE__*/React.createElement(View, {
|
|
270
|
+
className: "p-pro-form-item-select",
|
|
271
|
+
onTap: function onTap(e) {
|
|
272
|
+
return _onTap(e);
|
|
273
|
+
}
|
|
274
|
+
}, disabled ? /*#__PURE__*/React.createElement(Text, {
|
|
275
|
+
className: "p-pro-form-item-control-disabled"
|
|
276
|
+
}, renderText() || "-") : value instanceof Array && value.length || !(value instanceof Array) && value ? /*#__PURE__*/React.createElement(Text, {
|
|
277
|
+
className: "p-pro-form-item-value"
|
|
278
|
+
}, renderText()) : /*#__PURE__*/React.createElement(Text, {
|
|
279
|
+
className: "p-pro-form-item-placeholder"
|
|
280
|
+
}, placeholder))), /*#__PURE__*/React.createElement(Popup, {
|
|
281
|
+
open: open,
|
|
282
|
+
onOpenChange: function onOpenChange(open) {
|
|
283
|
+
return setOpen(open);
|
|
284
|
+
},
|
|
285
|
+
rootClassName: "p-pro-form-item-select-popup-container",
|
|
286
|
+
header: {
|
|
287
|
+
title: fieldProps.label,
|
|
288
|
+
extra: {
|
|
289
|
+
right: multiple && /*#__PURE__*/React.createElement(Text, {
|
|
290
|
+
className: "text",
|
|
291
|
+
onClick: function onClick() {
|
|
292
|
+
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(value);
|
|
293
|
+
}
|
|
294
|
+
}, "\u786E\u5B9A")
|
|
257
295
|
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
296
|
+
}
|
|
297
|
+
}, function (_ref2) {
|
|
298
|
+
var onOpenChange = _ref2.onOpenChange;
|
|
299
|
+
return /*#__PURE__*/React.createElement(Fragment, null, popupExtra === null || popupExtra === void 0 ? void 0 : popupExtra.top, /*#__PURE__*/React.createElement(SearchInput, {
|
|
300
|
+
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",
|
|
301
|
+
onSearch: function onSearch(v) {
|
|
302
|
+
return setOptions((options === null || options === void 0 ? void 0 : options.filter(function (o) {
|
|
303
|
+
return o[fieldNames.label].indexOf(v) >= 0;
|
|
304
|
+
})) || []);
|
|
305
|
+
}
|
|
306
|
+
}), options.length ? /*#__PURE__*/React.createElement(ScrollView, {
|
|
307
|
+
className: "p-pro-form-item-select-popup-content",
|
|
308
|
+
showScrollbar: false,
|
|
309
|
+
scrollY: true,
|
|
310
|
+
enableFlex: true,
|
|
311
|
+
enhanced: true
|
|
312
|
+
}, options.map(function (o) {
|
|
313
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
314
|
+
className: "p-pro-form-item-select-option",
|
|
315
|
+
key: 'option-' + o[fieldNames.value],
|
|
316
|
+
onTap: function onTap() {
|
|
317
|
+
if (value instanceof Array) {
|
|
318
|
+
if (value.some(function (v) {
|
|
319
|
+
return v === o[fieldNames.value];
|
|
320
|
+
})) {
|
|
321
|
+
value.splice(value.findIndex(function (v) {
|
|
322
|
+
return v === o[fieldNames.value];
|
|
323
|
+
}), 1);
|
|
324
|
+
} else {
|
|
325
|
+
value.push(o[fieldNames.value]);
|
|
326
|
+
}
|
|
327
|
+
setValue(_toConsumableArray(value));
|
|
328
|
+
} else {
|
|
329
|
+
onOpenChange();
|
|
330
|
+
setValue(o[fieldNames.value]);
|
|
331
|
+
_onChange === null || _onChange === void 0 || _onChange(o[fieldNames.value]);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}, renderIcon(o[fieldNames.value]), renderOptions ? renderOptions(o) : /*#__PURE__*/React.createElement(Text, {
|
|
335
|
+
className: "p-pro-form-item-select-option-text"
|
|
336
|
+
}, o[fieldNames.label]));
|
|
337
|
+
})) : /*#__PURE__*/React.createElement(Empty, {
|
|
338
|
+
description: "\u6682\u65E0\u6570\u636E"
|
|
339
|
+
}), popupExtra === null || popupExtra === void 0 ? void 0 : popupExtra.bottom);
|
|
340
|
+
}));
|
|
341
|
+
}, [value, options, open, disabled]);
|
|
342
|
+
return useMemo(function () {
|
|
343
|
+
return renderContent();
|
|
344
|
+
}, [value, options, open, disabled]);
|
|
267
345
|
};
|
|
268
346
|
export default ProFormSelect;
|