jobsys-explore 1.0.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/.eslintignore +4 -0
- package/.eslintrc.cjs +38 -0
- package/.prettierrc.cjs +38 -0
- package/README.md +42 -0
- package/components/button/ExButton.jsx +119 -0
- package/components/button/index.js +4 -0
- package/components/button/index.less +8 -0
- package/components/form/ExAddress.jsx +125 -0
- package/components/form/ExCascader.jsx +98 -0
- package/components/form/ExCheckbox.jsx +59 -0
- package/components/form/ExDate.jsx +130 -0
- package/components/form/ExDatetime.jsx +152 -0
- package/components/form/ExField.jsx +123 -0
- package/components/form/ExFieldUploader.jsx +44 -0
- package/components/form/ExForm.jsx +395 -0
- package/components/form/ExNumber.jsx +49 -0
- package/components/form/ExRadio.jsx +58 -0
- package/components/form/ExRate.jsx +47 -0
- package/components/form/ExSelect.jsx +151 -0
- package/components/form/ExSlider.jsx +53 -0
- package/components/form/ExSwitch.jsx +49 -0
- package/components/form/ExTime.jsx +104 -0
- package/components/form/FormItem.jsx +229 -0
- package/components/form/PickerWrapper.jsx +111 -0
- package/components/form/addressData.json +1 -0
- package/components/form/index.js +37 -0
- package/components/form/index.less +108 -0
- package/components/form/utils.js +47 -0
- package/components/grid/ExGrid.jsx +53 -0
- package/components/grid/index.js +4 -0
- package/components/grid/index.less +3 -0
- package/components/index.js +9 -0
- package/components/pagination/ExPagination.jsx +148 -0
- package/components/pagination/index.js +5 -0
- package/components/pagination/index.less +15 -0
- package/components/provider/ExProvider.jsx +91 -0
- package/components/provider/index.js +4 -0
- package/components/qrcode/ExQrcode.jsx +86 -0
- package/components/qrcode/index.js +5 -0
- package/components/qrcode/index.less +8 -0
- package/components/result/ExResult.jsx +122 -0
- package/components/result/index.js +5 -0
- package/components/result/index.less +60 -0
- package/components/search/ExSearch.jsx +252 -0
- package/components/search/components/Expand.jsx +77 -0
- package/components/search/components/Field.jsx +27 -0
- package/components/search/components/Quick.jsx +53 -0
- package/components/search/components/index.js +5 -0
- package/components/search/index.js +5 -0
- package/components/search/index.less +119 -0
- package/components/search/utils.js +30 -0
- package/components/theme/ExTheme.jsx +10 -0
- package/components/theme/index.js +4 -0
- package/components/theme/index.less +97 -0
- package/components/uploader/ExUploader.jsx +248 -0
- package/components/uploader/index.js +5 -0
- package/components/utils.js +150 -0
- package/dist/__vite-browser-external-2447137e.mjs +5 -0
- package/dist/__vite-browser-external-2447137e.mjs.map +1 -0
- package/dist/__vite-browser-external-b3701507.js +2 -0
- package/dist/__vite-browser-external-b3701507.js.map +1 -0
- package/dist/hooks.cjs +2 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.js +35 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index-82d74e5f.mjs +2120 -0
- package/dist/index-82d74e5f.mjs.map +1 -0
- package/dist/index-b8729555.js +2 -0
- package/dist/index-b8729555.js.map +1 -0
- package/dist/jobsys-explore.cjs +9 -0
- package/dist/jobsys-explore.cjs.map +1 -0
- package/dist/jobsys-explore.js +18673 -0
- package/dist/jobsys-explore.js.map +1 -0
- package/dist/style.css +1 -0
- package/docgen.config.cjs +9 -0
- package/docs/.vitepress/cache/deps/_metadata.json +19 -0
- package/docs/.vitepress/cache/deps/package.json +3 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +162 -0
- package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/docs/.vitepress/cache/deps/vue.js +10795 -0
- package/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/docs/.vitepress/config.mjs +43 -0
- package/docs/.vitepress/dist/404.html +19 -0
- package/docs/.vitepress/dist/assets/app.e0eb4814.js +1 -0
- package/docs/.vitepress/dist/assets/chunks/framework.7a64ad8e.js +2 -0
- package/docs/.vitepress/dist/assets/chunks/theme.ffc5f35c.js +7 -0
- package/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.33bd5a8e.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-cyrillic.ea42a392.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-greek-ext.4fbe9427.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-greek.8f4463c4.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-latin-ext.bd8920cc.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-latin.bd3b6f56.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-vietnamese.6ce511fb.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.e75737ce.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-cyrillic.5f2c6c8c.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-greek-ext.ab0619bc.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-greek.d5a6d92a.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-latin-ext.0030eebd.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-latin.2ed14f66.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-vietnamese.14ce25a6.woff2 +0 -0
- package/docs/.vitepress/dist/assets/style.6747f984.css +1 -0
- package/docs/.vitepress/dist/hashmap.json +1 -0
- package/docs/.vitepress/theme/index.css +0 -0
- package/docs/.vitepress/theme/index.js +12 -0
- package/hooks/cipher.js +40 -0
- package/hooks/form.js +176 -0
- package/hooks/index.js +4 -0
- package/hooks/network.js +153 -0
- package/hooks/utils.js +61 -0
- package/index.html +17 -0
- package/index.js +10 -0
- package/package.json +75 -0
- package/playground/App.vue +45 -0
- package/playground/TestButton.vue +15 -0
- package/playground/TestForm.vue +271 -0
- package/playground/TestFormItem.vue +110 -0
- package/playground/TestGrid.vue +22 -0
- package/playground/TestPagination.vue +89 -0
- package/playground/TestQrcode.vue +7 -0
- package/playground/TestResult.vue +12 -0
- package/playground/TestSearch.vue +84 -0
- package/playground/http.js +23 -0
- package/playground/main.js +12 -0
- package/postcss.config.cjs +8 -0
- package/utils/style.js +13 -0
- package/utils/withInstall.js +7 -0
- package/vite.config.js +52 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
.ex-search {
|
|
2
|
+
background: var(--ex-white);
|
|
3
|
+
|
|
4
|
+
.ex-search__quick-bar {
|
|
5
|
+
padding: var(--van-padding-sm) var(--van-padding-md);
|
|
6
|
+
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
|
|
11
|
+
.ex-search__quick-container {
|
|
12
|
+
flex-grow: 1;
|
|
13
|
+
display: flex;
|
|
14
|
+
|
|
15
|
+
.ex-search__quick-item {
|
|
16
|
+
margin-right: var(--van-padding-md);
|
|
17
|
+
|
|
18
|
+
.ex-search__quick-trigger {
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
font-weight: 400;
|
|
21
|
+
color: var(--ex-gray-7);
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
|
|
25
|
+
&.active {
|
|
26
|
+
color: var(--van-primary-color);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ex-search__quick-label {
|
|
30
|
+
max-width: 130px;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
text-overflow: ellipsis;
|
|
34
|
+
display: inline-block;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ex-search__quick-icon {
|
|
38
|
+
margin-left: 2px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ex-search__filter {
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
font-weight: 400;
|
|
49
|
+
color: var(--ex-gray-7);
|
|
50
|
+
width: 50px;
|
|
51
|
+
text-align: right;
|
|
52
|
+
flex-shrink: 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ex-search-popup {
|
|
58
|
+
height: 80%;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
|
|
61
|
+
.ex-search-popup__header {
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
padding: var(--van-padding-md);
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: space-between;
|
|
67
|
+
height: 48px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.ex-search-popup__content {
|
|
71
|
+
height: calc(100% - 114px);
|
|
72
|
+
overflow: auto;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
.ex-search-popup__footer {
|
|
77
|
+
padding: var(--van-padding-md);
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
height: 66px;
|
|
80
|
+
line-height: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
.ex-search__popup-item {
|
|
85
|
+
margin-bottom: var(--van-padding-md);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.ex-search__field-item {
|
|
89
|
+
.ex-field {
|
|
90
|
+
.van-field__label {
|
|
91
|
+
font-weight: bold;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.ex-search__expand-item {
|
|
97
|
+
|
|
98
|
+
.van-collapse-item {
|
|
99
|
+
.van-cell {
|
|
100
|
+
&:after {
|
|
101
|
+
border-bottom: none
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ex-search__expand-title {
|
|
107
|
+
font-weight: bold;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.ex-search__expand-trigger {
|
|
111
|
+
font-size: 12px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.ex-search__expand-options {
|
|
115
|
+
.ex-search__expand-option {
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isArray, isDate, isFunction, isUndefined } from "lodash-es"
|
|
2
|
+
import { useAddressFullCode } from "../form/ExAddress.jsx"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 初始化搜索表单项默认值
|
|
6
|
+
* @param {FormItemConfig} item
|
|
7
|
+
*/
|
|
8
|
+
const initSearchItemDefaultValue = (item) => {
|
|
9
|
+
let value = ""
|
|
10
|
+
|
|
11
|
+
if (!isUndefined(item.defaultValue)) {
|
|
12
|
+
value = isFunction(item.defaultValue) ? item.defaultValue() : item.defaultValue
|
|
13
|
+
}
|
|
14
|
+
if (item.type === "number") {
|
|
15
|
+
value = value ? Number(value) : 0
|
|
16
|
+
} else if (item.type === "date" || item.type === "datetime") {
|
|
17
|
+
value = isDate(value) ? value : null
|
|
18
|
+
} else if (item.type === "checkbox" || item.type === "cascade") {
|
|
19
|
+
value = value || []
|
|
20
|
+
} else if (item.type === "address") {
|
|
21
|
+
value = value || []
|
|
22
|
+
if (!isArray(value)) {
|
|
23
|
+
value = useAddressFullCode(value)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return value
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { initSearchItemDefaultValue }
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
:root:root {
|
|
2
|
+
// Color Palette
|
|
3
|
+
--van-black: #000;
|
|
4
|
+
--van-white: #fff;
|
|
5
|
+
--van-gray-1: #f7f8fa;
|
|
6
|
+
--van-gray-2: #f2f3f5;
|
|
7
|
+
--van-gray-3: #ebedf0;
|
|
8
|
+
--van-gray-4: #dcdee0;
|
|
9
|
+
--van-gray-5: #c8c9cc;
|
|
10
|
+
--van-gray-6: #969799;
|
|
11
|
+
--van-gray-7: #646566;
|
|
12
|
+
--van-gray-8: #323233;
|
|
13
|
+
--van-red: #ee0a24;
|
|
14
|
+
--van-blue: #1989fa;
|
|
15
|
+
--van-orange: #ff976a;
|
|
16
|
+
--van-orange-dark: #ed6a0c;
|
|
17
|
+
--van-orange-light: #fffbe8;
|
|
18
|
+
--van-green: #07c160;
|
|
19
|
+
|
|
20
|
+
--ex-green: #1ea69a;
|
|
21
|
+
--ex-green-light: #f3f9f8;
|
|
22
|
+
--ex-orange: #fe862f;
|
|
23
|
+
--ex-black: rgba(0, 0, 0, 0.85);
|
|
24
|
+
--ex-white: #FFFFFF;
|
|
25
|
+
--ex-gray-1: #f7f8fa;
|
|
26
|
+
--ex-gray-2: #f2f3f5;
|
|
27
|
+
--ex-gray-3: #ebedf0;
|
|
28
|
+
--ex-gray-4: #dcdee0;
|
|
29
|
+
--ex-gray-5: #c8c9cc;
|
|
30
|
+
--ex-gray-6: #969799;
|
|
31
|
+
--ex-gray-7: #6D6D6D;
|
|
32
|
+
--ex-gray-8: rgba(0, 0, 0, 0.25);
|
|
33
|
+
--ex-gray-9: rgba(0, 0, 0, 0.45);
|
|
34
|
+
--ex-gray-10: rgba(0, 0, 0, 0.65);
|
|
35
|
+
|
|
36
|
+
--ex-primary-background: #f3f9f8;
|
|
37
|
+
|
|
38
|
+
// Gradient Colors
|
|
39
|
+
--van-gradient-red: linear-gradient(to right, #ff6034, #ee0a24);
|
|
40
|
+
--van-gradient-orange: linear-gradient(to right, #ffd01e, #ff8917);
|
|
41
|
+
|
|
42
|
+
// Component Colors
|
|
43
|
+
--van-primary-color: var(--ex-green);
|
|
44
|
+
--van-success-color: var(--ex-green);
|
|
45
|
+
--van-danger-color: var(--van-red);
|
|
46
|
+
--van-warning-color: var(--ex-orange);
|
|
47
|
+
--van-text-color: var(--ex-black);
|
|
48
|
+
--van-text-color-2: var(--van-gray-6);
|
|
49
|
+
--van-text-color-3: var(--van-gray-5);
|
|
50
|
+
--van-active-color: var(--van-gray-2);
|
|
51
|
+
--van-active-opacity: 0.6;
|
|
52
|
+
--van-disabled-opacity: 0.5;
|
|
53
|
+
--van-background: var(--van-gray-1);
|
|
54
|
+
--van-background-2: var(--van-white);
|
|
55
|
+
|
|
56
|
+
// Padding
|
|
57
|
+
--van-padding-base: 4px;
|
|
58
|
+
--van-padding-xs: 8px;
|
|
59
|
+
--van-padding-sm: 12px;
|
|
60
|
+
--van-padding-md: 16px;
|
|
61
|
+
--van-padding-lg: 24px;
|
|
62
|
+
--van-padding-xl: 32px;
|
|
63
|
+
|
|
64
|
+
// Font
|
|
65
|
+
--van-font-size-xs: 10px;
|
|
66
|
+
--van-font-size-sm: 12px;
|
|
67
|
+
--van-font-size-md: 14px;
|
|
68
|
+
--van-font-size-lg: 16px;
|
|
69
|
+
--van-font-bold: 600;
|
|
70
|
+
--van-line-height-xs: 14px;
|
|
71
|
+
--van-line-height-sm: 18px;
|
|
72
|
+
--van-line-height-md: 20px;
|
|
73
|
+
--van-line-height-lg: 22px;
|
|
74
|
+
--van-base-font: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica,
|
|
75
|
+
Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei',
|
|
76
|
+
sans-serif;
|
|
77
|
+
--van-price-font: Avenir-Heavy, PingFang SC, Helvetica Neue, Arial, sans-serif;
|
|
78
|
+
|
|
79
|
+
// Animation
|
|
80
|
+
--van-duration-base: 0.3s;
|
|
81
|
+
--van-duration-fast: 0.2s;
|
|
82
|
+
--van-ease-out: ease-out;
|
|
83
|
+
--van-ease-in: ease-in;
|
|
84
|
+
|
|
85
|
+
// Border
|
|
86
|
+
--van-border-color: var(--van-gray-3);
|
|
87
|
+
--van-border-width: 1px;
|
|
88
|
+
--van-radius-sm: 2px;
|
|
89
|
+
--van-radius-md: 4px;
|
|
90
|
+
--van-radius-lg: 8px;
|
|
91
|
+
--van-radius-max: 999px;
|
|
92
|
+
|
|
93
|
+
//Search
|
|
94
|
+
--van-search-content-background: var(--ex-primary-background);
|
|
95
|
+
--van-search-left-icon-color: var(--van-primary-color);
|
|
96
|
+
|
|
97
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { computed, defineComponent, inject, onMounted, reactive, watch } from "vue"
|
|
2
|
+
import { Button, showToast, Uploader } from "vant"
|
|
3
|
+
import { findIndex, isArray, isFunction, pick, random } from "lodash-es"
|
|
4
|
+
import { STATUS, useFetch } from "../../hooks"
|
|
5
|
+
import { EX_UPLOADER } from "../provider/ExProvider.jsx"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ExUploader 文件上传
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: "ExUploader",
|
|
13
|
+
props: {
|
|
14
|
+
modelValue: { type: [Object, Array], default: () => ({}) },
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 上传文件字段名
|
|
18
|
+
*/
|
|
19
|
+
name: { type: String, default: "file" },
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 接受上传的文件类型, 详见 [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept)
|
|
23
|
+
*/
|
|
24
|
+
accept: { type: String, default: "" },
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 设置上传的请求头部,IE10 以上有效
|
|
28
|
+
*/
|
|
29
|
+
headers: { type: Object, default: () => ({}) },
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 上传列表的基本样式 text, picture
|
|
33
|
+
*
|
|
34
|
+
* @values text, picture
|
|
35
|
+
*/
|
|
36
|
+
type: { type: String, default: "picture" },
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 是否禁用
|
|
40
|
+
*/
|
|
41
|
+
disabled: { type: Boolean, default: false },
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 单个文件大小上限,单位为 MB
|
|
45
|
+
*/
|
|
46
|
+
maxSize: { type: Number, default: 10 },
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 上传文件个数上限
|
|
50
|
+
*/
|
|
51
|
+
maxNum: { type: Number, default: 1 },
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 是否支持多选文件
|
|
55
|
+
*/
|
|
56
|
+
multiple: { type: Boolean, default: false },
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 上传文件的服务器地址
|
|
60
|
+
*/
|
|
61
|
+
action: { type: String, default: "" },
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 上传后的数据处理回调
|
|
65
|
+
*/
|
|
66
|
+
afterUpload: { type: Function, default: null },
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 上传时的附加参数
|
|
70
|
+
*/
|
|
71
|
+
extraData: { type: Object, default: () => ({}) },
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 上传按钮文本
|
|
75
|
+
*/
|
|
76
|
+
uploadText: { type: String, default: "上传" },
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 上传区域图标名称或图片链接,等同于 Icon 组件的 name 属性
|
|
80
|
+
*/
|
|
81
|
+
uploadIcon: { type: String, default: "photograph" },
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* [原生配置](https://vant-contrib.gitee.io/vant/#/zh-CN/uploader)
|
|
85
|
+
*/
|
|
86
|
+
uploaderProps: {
|
|
87
|
+
type: Object,
|
|
88
|
+
default: () => ({}),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
emits: ["update:modelValue", "success", "change"],
|
|
92
|
+
setup(props, { emit, slots }) {
|
|
93
|
+
const uploaderProvider = inject(EX_UPLOADER, () => ({}))
|
|
94
|
+
const defaultUploadUrl = uploaderProvider.uploadUrl || ""
|
|
95
|
+
const defaultFileItem = uploaderProvider.defaultFileItem || {}
|
|
96
|
+
|
|
97
|
+
const { url: urlKey, path: pathKey } = defaultFileItem
|
|
98
|
+
|
|
99
|
+
const state = reactive({
|
|
100
|
+
fileList: [],
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
const maxSize = computed(() => props.maxSize * 1024 * 1024)
|
|
104
|
+
|
|
105
|
+
const isImage = computed(() => props.type === "picture")
|
|
106
|
+
|
|
107
|
+
const isSingle = computed(() => props.maxNum === 1)
|
|
108
|
+
|
|
109
|
+
const prepareFileList = (fileList) => {
|
|
110
|
+
if (!fileList) {
|
|
111
|
+
return []
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
fileList = isArray(fileList) ? fileList : [fileList]
|
|
115
|
+
|
|
116
|
+
fileList = fileList
|
|
117
|
+
.filter((item) => item[urlKey] || item[pathKey])
|
|
118
|
+
.map((item) => ({
|
|
119
|
+
uid: random(1, 10000000),
|
|
120
|
+
url: item[urlKey],
|
|
121
|
+
status: "done",
|
|
122
|
+
isImage: isImage.value,
|
|
123
|
+
...item,
|
|
124
|
+
}))
|
|
125
|
+
|
|
126
|
+
return fileList
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
onMounted(() => {
|
|
130
|
+
state.fileList = prepareFileList(props.modelValue)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
watch(
|
|
134
|
+
() => props.modelValue,
|
|
135
|
+
(fileList) => {
|
|
136
|
+
state.fileList = prepareFileList(fileList)
|
|
137
|
+
},
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
const onOversize = () => {
|
|
141
|
+
showToast(`文件大小不能超过 ${props.maxSize}mb`)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const getModelValue = () => {
|
|
145
|
+
const fileList = state.fileList.filter((item) => item.status === "done")
|
|
146
|
+
if (isSingle.value) {
|
|
147
|
+
return fileList[0] || {}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return fileList || []
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const onSuccess = (file, result) => {
|
|
154
|
+
file.status = "done"
|
|
155
|
+
file.message = "上传成功"
|
|
156
|
+
file = { ...file, ...pick(result, Object.keys(defaultFileItem)) }
|
|
157
|
+
|
|
158
|
+
const fileIndex = findIndex(state.fileList, { uid: file.uid })
|
|
159
|
+
|
|
160
|
+
state.fileList[fileIndex] = file
|
|
161
|
+
|
|
162
|
+
emit("update:modelValue", getModelValue())
|
|
163
|
+
emit("change", getModelValue())
|
|
164
|
+
|
|
165
|
+
emit("success", { file, response: result })
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const onError = (file, result) => {
|
|
169
|
+
file.status = "failed"
|
|
170
|
+
file.message = result || "上传失败"
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const onDelete = (file) => {
|
|
174
|
+
const fileIndex = findIndex(state.fileList, { uid: file.uid })
|
|
175
|
+
|
|
176
|
+
if (fileIndex > -1) {
|
|
177
|
+
state.fileList.splice(fileIndex, 1)
|
|
178
|
+
|
|
179
|
+
emit("update:modelValue", getModelValue())
|
|
180
|
+
emit("change", getModelValue())
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const onSubmit = async (file) => {
|
|
185
|
+
file.uid = random(1, 10000000)
|
|
186
|
+
file.status = "uploading"
|
|
187
|
+
file.message = "上传中..."
|
|
188
|
+
|
|
189
|
+
const formData = new FormData()
|
|
190
|
+
Object.keys(props.extraData).forEach((key) => {
|
|
191
|
+
formData.append(key, props.extraData[key])
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
formData.append(props.name, file)
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
let res = await useFetch().post(props.action || defaultUploadUrl, formData, {
|
|
198
|
+
withCredentials: true,
|
|
199
|
+
headers: props.headers,
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
let result = res.result
|
|
203
|
+
|
|
204
|
+
if (res.status !== STATUS.STATE_CODE_SUCCESS) {
|
|
205
|
+
onError(file, result)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (props.afterUpload && isFunction(props.afterUpload)) {
|
|
209
|
+
result = props.afterUpload(res)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
onSuccess(file, result)
|
|
213
|
+
} catch (e) {
|
|
214
|
+
onError(file)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const customSlot = () => {
|
|
219
|
+
if (!isImage.value) {
|
|
220
|
+
slots.default = () => (
|
|
221
|
+
<Button icon="plus" type="primary" size={"small"}>
|
|
222
|
+
{props.uploadText}
|
|
223
|
+
</Button>
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
return slots
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return () => (
|
|
230
|
+
<div class={"ex-uploader"}>
|
|
231
|
+
<Uploader
|
|
232
|
+
v-model={state.fileList}
|
|
233
|
+
maxCount={props.maxNum}
|
|
234
|
+
maxSize={maxSize.value}
|
|
235
|
+
accetp={props.accept}
|
|
236
|
+
uploadText={props.uploadText}
|
|
237
|
+
uploadIcon={props.uploadIcon}
|
|
238
|
+
afterRead={onSubmit}
|
|
239
|
+
onOversize={onOversize}
|
|
240
|
+
onDelete={onDelete}
|
|
241
|
+
{...props.uploaderProps}
|
|
242
|
+
>
|
|
243
|
+
{customSlot()}
|
|
244
|
+
</Uploader>
|
|
245
|
+
</div>
|
|
246
|
+
)
|
|
247
|
+
},
|
|
248
|
+
})
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { isFunction, isString } from "lodash-es"
|
|
2
|
+
import { watch } from "vue"
|
|
3
|
+
import { useFetch } from "../hooks"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 通用 field props
|
|
7
|
+
*/
|
|
8
|
+
export const defaultFieldProps = {
|
|
9
|
+
/**
|
|
10
|
+
* 输入框左侧文本
|
|
11
|
+
*/
|
|
12
|
+
label: { type: String, default: "" },
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 名称,作为提交表单时的标识符
|
|
16
|
+
*/
|
|
17
|
+
name: { type: String, default: "" },
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 输入框占位提示文字
|
|
21
|
+
*/
|
|
22
|
+
placeholder: { type: String, default: "请填写" },
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 提示文案
|
|
26
|
+
*/
|
|
27
|
+
help: { type: String, default: "" },
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 是否禁用输入框
|
|
31
|
+
*/
|
|
32
|
+
disabled: { type: Boolean, default: false },
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 是否显示表单必填星号
|
|
36
|
+
*/
|
|
37
|
+
required: { type: Boolean, default: false },
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 是否展示右侧箭头并开启点击反馈
|
|
41
|
+
*/
|
|
42
|
+
isLink: { type: Boolean, default: false },
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 是否为只读状态,只读状态下无法输入内容
|
|
46
|
+
*/
|
|
47
|
+
readonly: { type: Boolean, default: false },
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 表单校验规则
|
|
51
|
+
*/
|
|
52
|
+
rules: { type: Array, default: null },
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 原生 [Field 配置](https://vant-contrib.gitee.io/vant/#/zh-CN/field)
|
|
56
|
+
*/
|
|
57
|
+
fieldProps: { type: Object, default: () => ({}) },
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 原生 Field 的 slots
|
|
62
|
+
* 用于从组合组件中挑选
|
|
63
|
+
*/
|
|
64
|
+
export const defaultFieldSlots = {
|
|
65
|
+
label: () => null,
|
|
66
|
+
input: () => null,
|
|
67
|
+
leftIcon: () => null,
|
|
68
|
+
rightIcon: () => null,
|
|
69
|
+
button: () => null,
|
|
70
|
+
errorMessage: () => null,
|
|
71
|
+
extra: () => null,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 通用的 options props
|
|
76
|
+
*/
|
|
77
|
+
export const defaultOptionsProps = {
|
|
78
|
+
/**
|
|
79
|
+
* 选项
|
|
80
|
+
*/
|
|
81
|
+
options: { type: [Array, Function], default: () => [] },
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 选项 url
|
|
85
|
+
*/
|
|
86
|
+
url: { type: String, default: null },
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 选项获取后的回调
|
|
90
|
+
*/
|
|
91
|
+
afterFetched: { type: Function, default: null },
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Prepare options for select
|
|
96
|
+
*
|
|
97
|
+
* @param options
|
|
98
|
+
* @return {Array}
|
|
99
|
+
*/
|
|
100
|
+
export const prepareOptions = (options) => {
|
|
101
|
+
options = isFunction(options) ? options() : options
|
|
102
|
+
options = options.map((op) => {
|
|
103
|
+
if (op.children?.length) {
|
|
104
|
+
op.children = prepareOptions(op.children)
|
|
105
|
+
}
|
|
106
|
+
return isString(op) ? { value: op, label: op, text: op } : { text: op.label, ...op }
|
|
107
|
+
})
|
|
108
|
+
return options
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 初始化选项
|
|
113
|
+
* @param options
|
|
114
|
+
* @param props
|
|
115
|
+
* @param {Array|Function} [defaultOptions]
|
|
116
|
+
*
|
|
117
|
+
* @return void
|
|
118
|
+
*/
|
|
119
|
+
export const useOptionTrait = async (options, props, defaultOptions) => {
|
|
120
|
+
options.value = prepareOptions(props.options)
|
|
121
|
+
|
|
122
|
+
const fetchData = () =>
|
|
123
|
+
new Promise((resolve) => {
|
|
124
|
+
useFetch()
|
|
125
|
+
.get(props.url)
|
|
126
|
+
.then((items) => {
|
|
127
|
+
if (props.afterFetched) {
|
|
128
|
+
items = props.afterFetched(items)
|
|
129
|
+
}
|
|
130
|
+
resolve(items)
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
watch(
|
|
135
|
+
() => props.options,
|
|
136
|
+
() => {
|
|
137
|
+
options.value = prepareOptions(props.options)
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
if (!options.value.length) {
|
|
142
|
+
if (props.url) {
|
|
143
|
+
fetchData().then((items) => {
|
|
144
|
+
options.value = items
|
|
145
|
+
})
|
|
146
|
+
} else if (defaultOptions) {
|
|
147
|
+
options.value = defaultOptions
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__vite-browser-external-2447137e.mjs","sources":["../__vite-browser-external"],"sourcesContent":["export default {}"],"names":["__viteBrowserExternal"],"mappings":"AAAA,MAAeA,IAAA,CAAA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__vite-browser-external-b3701507.js","sources":["../__vite-browser-external"],"sourcesContent":["export default {}"],"names":["__viteBrowserExternal"],"mappings":"gFAAA,MAAeA,EAAA,CAAA"}
|
package/dist/hooks.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-b8729555.js");require("lodash-es");require("axios");require("vant");function t(){return e.sm2_exports}function o(s,u){return e.sm32(s,u)}function n(s,u,r){return e.sm4_exports.encrypt(s,u,r)}function m(s,u,r){return e.sm4_exports.encrypt(s,u,r)}exports.STATUS=e.STATUS;exports.useFetch=e.useFetch;exports.useFindLabelsFromPath=e.useFindLabelsFromPath;exports.useFindTextsFromPath=e.useFindTextsFromPath;exports.useFormFail=e.useFormFail;exports.useFormFormat=e.useFormFormat;exports.useHiddenForm=e.useHiddenForm;exports.usePage=e.usePage;exports.useProcessStatus=e.useProcessStatus;exports.useProcessStatusSuccess=e.useProcessStatusSuccess;exports.useTextFromOptionsValue=e.useTextFromOptionsValue;exports.useSm2=t;exports.useSm3=o;exports.useSm4Decrypt=m;exports.useSm4Encrypt=n;
|
|
2
|
+
//# sourceMappingURL=hooks.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.cjs","sources":["../hooks/cipher.js"],"sourcesContent":["import { sm2, sm3, sm4 } from \"sm-crypto-v2\"\n\n/**\n * 国密 sm2\n */\nexport function useSm2() {\n\treturn sm2\n}\n\n/**\n * 国密 sm3 加密\n * @param msg\n * @param {Object} [options]\n * @return {*}\n */\nexport function useSm3(msg, options) {\n\treturn sm3(msg, options) // 杂凑\n}\n\n/**\n * 国密 sm4 加密\n * @param msg\n * @param key\n * @param {Object} [options]\n * @return {Uint8Array}\n */\nexport function useSm4Encrypt(msg, key, options) {\n\treturn sm4.encrypt(msg, key, options)\n}\n\n/**\n * 国密 sm4 解密\n * @param encryptData\n * @param key\n * @param {Object} [options]\n * @return {Uint8Array}\n */\nexport function useSm4Decrypt(encryptData, key, options) {\n\treturn sm4.encrypt(encryptData, key, options)\n}\n"],"names":["useSm2","sm2","useSm3","msg","options","sm3","useSm4Encrypt","key","sm4","useSm4Decrypt","encryptData"],"mappings":"6KAKO,SAASA,GAAS,CACxB,OAAOC,EAAG,WACX,CAQO,SAASC,EAAOC,EAAKC,EAAS,CACpC,OAAOC,EAAG,KAACF,EAAKC,CAAO,CACxB,CASO,SAASE,EAAcH,EAAKI,EAAKH,EAAS,CAChD,OAAOI,EAAG,YAAC,QAAQL,EAAKI,EAAKH,CAAO,CACrC,CASO,SAASK,EAAcC,EAAaH,EAAKH,EAAS,CACxD,OAAOI,EAAG,YAAC,QAAQE,EAAaH,EAAKH,CAAO,CAC7C"}
|