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,49 @@
|
|
|
1
|
+
import { defineComponent, ref, watch } from "vue"
|
|
2
|
+
import { defaultFieldProps } from "../utils"
|
|
3
|
+
import { Stepper } from "vant"
|
|
4
|
+
import ExField from "./ExField.jsx"
|
|
5
|
+
import { pick } from "lodash-es"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ExNumber 数字
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: "ExNumber",
|
|
13
|
+
props: {
|
|
14
|
+
...defaultFieldProps,
|
|
15
|
+
|
|
16
|
+
modelValue: { type: [Number, String], default: 1 },
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* [原生配置](https://vant-contrib.gitee.io/vant/#/zh-CN/stepper)
|
|
20
|
+
*/
|
|
21
|
+
numberProps: { type: Object, default: () => ({}) },
|
|
22
|
+
},
|
|
23
|
+
emits: ["update:modelValue"],
|
|
24
|
+
setup(props, { emit, slots }) {
|
|
25
|
+
const componentValue = ref(props.modelValue)
|
|
26
|
+
|
|
27
|
+
watch(
|
|
28
|
+
() => props.modelValue,
|
|
29
|
+
() => (componentValue.value = props.modelValue),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const onChange = (value) => {
|
|
33
|
+
emit("update:modelValue", Number(value))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const fieldProps = pick(props, Object.keys(defaultFieldProps))
|
|
37
|
+
|
|
38
|
+
return () => (
|
|
39
|
+
<ExField {...fieldProps}>
|
|
40
|
+
{{
|
|
41
|
+
...slots,
|
|
42
|
+
input: () => (
|
|
43
|
+
<Stepper v-model={componentValue.value} {...props.numberProps} theme={"round"} buttonSize={22} onChange={onChange}></Stepper>
|
|
44
|
+
),
|
|
45
|
+
}}
|
|
46
|
+
</ExField>
|
|
47
|
+
)
|
|
48
|
+
},
|
|
49
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineComponent, ref, watch } from "vue"
|
|
2
|
+
import { defaultFieldProps, defaultOptionsProps, useOptionTrait } from "../utils"
|
|
3
|
+
import { Radio, RadioGroup } from "vant"
|
|
4
|
+
import ExField from "./ExField.jsx"
|
|
5
|
+
import { pick } from "lodash-es"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ExRadio 单选
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: "ExRadio",
|
|
13
|
+
props: {
|
|
14
|
+
...defaultFieldProps,
|
|
15
|
+
...defaultOptionsProps,
|
|
16
|
+
|
|
17
|
+
modelValue: { type: [Number, String], default: "" },
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* [原生配置](https://vant-contrib.gitee.io/vant/#/zh-CN/raido)
|
|
21
|
+
*/
|
|
22
|
+
radioProps: { type: Object, default: () => ({}) },
|
|
23
|
+
},
|
|
24
|
+
emits: ["update:modelValue"],
|
|
25
|
+
setup(props, { emit, slots }) {
|
|
26
|
+
const componentValue = ref(props.modelValue)
|
|
27
|
+
|
|
28
|
+
watch(
|
|
29
|
+
() => props.modelValue,
|
|
30
|
+
() => (componentValue.value = props.modelValue),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
const options = ref([])
|
|
34
|
+
|
|
35
|
+
useOptionTrait(options, props)
|
|
36
|
+
|
|
37
|
+
const onChange = (value) => {
|
|
38
|
+
emit("update:modelValue", value)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const fieldProps = pick(props, Object.keys(defaultFieldProps))
|
|
42
|
+
|
|
43
|
+
return () => (
|
|
44
|
+
<ExField {...fieldProps}>
|
|
45
|
+
{{
|
|
46
|
+
...slots,
|
|
47
|
+
input: () => (
|
|
48
|
+
<RadioGroup v-model={componentValue.value} {...props.radioProps} onChange={onChange}>
|
|
49
|
+
{{
|
|
50
|
+
default: () => options.value.map((option) => <Radio name={option.value}>{{ default: () => option.text }}</Radio>),
|
|
51
|
+
}}
|
|
52
|
+
</RadioGroup>
|
|
53
|
+
),
|
|
54
|
+
}}
|
|
55
|
+
</ExField>
|
|
56
|
+
)
|
|
57
|
+
},
|
|
58
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { defineComponent, ref, watch } from "vue"
|
|
2
|
+
import { defaultFieldProps } from "../utils"
|
|
3
|
+
import { Rate } from "vant"
|
|
4
|
+
import ExField from "./ExField.jsx"
|
|
5
|
+
import { pick } from "lodash-es"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ExRate 评分
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: "ExRate",
|
|
13
|
+
props: {
|
|
14
|
+
...defaultFieldProps,
|
|
15
|
+
|
|
16
|
+
modelValue: { type: Number, default: 2 },
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* [原生配置](https://vant-contrib.gitee.io/vant/#/zh-CN/rate)
|
|
20
|
+
*/
|
|
21
|
+
rateProps: { type: Object, default: () => ({}) },
|
|
22
|
+
},
|
|
23
|
+
emits: ["update:modelValue"],
|
|
24
|
+
setup(props, { emit, slots }) {
|
|
25
|
+
const componentValue = ref(props.modelValue)
|
|
26
|
+
|
|
27
|
+
watch(
|
|
28
|
+
() => props.modelValue,
|
|
29
|
+
() => (componentValue.value = props.modelValue),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const onChange = (value) => {
|
|
33
|
+
emit("update:modelValue", Number(value))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const fieldProps = pick(props, Object.keys(defaultFieldProps))
|
|
37
|
+
|
|
38
|
+
return () => (
|
|
39
|
+
<ExField {...fieldProps}>
|
|
40
|
+
{{
|
|
41
|
+
...slots,
|
|
42
|
+
input: () => <Rate v-model={componentValue.value} clearable={true} {...props.rateProps} onChange={onChange}></Rate>,
|
|
43
|
+
}}
|
|
44
|
+
</ExField>
|
|
45
|
+
)
|
|
46
|
+
},
|
|
47
|
+
})
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { computed, defineComponent, ref, watch } from "vue"
|
|
2
|
+
import PickerWrapper, { pickerSlots } from "./PickerWrapper.jsx"
|
|
3
|
+
import { Button, Picker } from "vant"
|
|
4
|
+
import { defaultFieldProps, defaultOptionsProps } from "../utils"
|
|
5
|
+
import { useFetch } from "../../hooks"
|
|
6
|
+
import { find, isArray, isFunction, isString } from "lodash-es"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ExSelect 下拉选择
|
|
10
|
+
* @version 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
export default defineComponent({
|
|
13
|
+
name: "ExSelect",
|
|
14
|
+
props: {
|
|
15
|
+
...defaultOptionsProps,
|
|
16
|
+
...defaultFieldProps,
|
|
17
|
+
|
|
18
|
+
modelValue: { type: [Array, String, Number], default: "" },
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 标题
|
|
22
|
+
*/
|
|
23
|
+
title: { type: String, default: "" },
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 是否显示清除按钮
|
|
27
|
+
*/
|
|
28
|
+
clearable: { type: Boolean, default: false },
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* [默认配置](https://vant-contrib.gitee.io/vant/#/zh-CN/picker)
|
|
32
|
+
*/
|
|
33
|
+
pickerProps: { type: Object, default: () => ({}) },
|
|
34
|
+
},
|
|
35
|
+
emits: ["update:modelValue", "change"],
|
|
36
|
+
setup(props, { emit, slots, expose }) {
|
|
37
|
+
const defaultValue = isArray(props.modelValue) ? props.modelValue : [props.modelValue]
|
|
38
|
+
const componentValue = ref(defaultValue)
|
|
39
|
+
const options = ref([])
|
|
40
|
+
let columns = 1 //根据子项的数组数来确定 Picker 的列数,默认为1列
|
|
41
|
+
const pickerRef = ref()
|
|
42
|
+
|
|
43
|
+
watch(
|
|
44
|
+
() => props.modelValue,
|
|
45
|
+
() => {
|
|
46
|
+
componentValue.value = isArray(props.modelValue) ? props.modelValue : [props.modelValue]
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
const displayText = computed(() => {
|
|
51
|
+
let value = isArray(props.modelValue) ? props.modelValue : [props.modelValue]
|
|
52
|
+
return value
|
|
53
|
+
.map((value, index) => {
|
|
54
|
+
if (columns === 1) {
|
|
55
|
+
return find(options.value, { value })?.text
|
|
56
|
+
} else {
|
|
57
|
+
return find(options.value[index], { value })?.text
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
?.join("/")
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const fetchData = () =>
|
|
64
|
+
new Promise((resolve) => {
|
|
65
|
+
useFetch()
|
|
66
|
+
.get(props.url)
|
|
67
|
+
.then((items) => {
|
|
68
|
+
if (props.afterFetched) {
|
|
69
|
+
items = props.afterFetched(items)
|
|
70
|
+
}
|
|
71
|
+
resolve(items)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const prepareOptions = async (options) => {
|
|
76
|
+
options = isFunction(options) ? options() : options
|
|
77
|
+
if (options && options.length) {
|
|
78
|
+
columns = options.filter((option) => isArray(option)).length || 1
|
|
79
|
+
} else if (props.url) {
|
|
80
|
+
options = await fetchData()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
options = options.map((option) => {
|
|
84
|
+
if (isArray(option)) {
|
|
85
|
+
return option.map((op) => {
|
|
86
|
+
return isString(op) ? { value: op, label: op, text: op } : { text: op.label, ...op }
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return isString(option) ? { value: option, label: option, text: option } : { text: option.label, ...option }
|
|
91
|
+
})
|
|
92
|
+
return options
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
prepareOptions(props.options).then((opts) => (options.value = opts))
|
|
96
|
+
|
|
97
|
+
watch(
|
|
98
|
+
() => props.options,
|
|
99
|
+
() => prepareOptions(props.options).then((opts) => (options.value = opts)),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
// @hack
|
|
103
|
+
// 由于在 Picker 清除 model value 后再次打开 Picker 在不重新选择新选项的情况下无法选中之前的选项
|
|
104
|
+
// 所以这里手动重新赋一次值给 model value
|
|
105
|
+
const onOpenWrapper = () => {
|
|
106
|
+
if (columns === 1 && !componentValue.value?.[0]) {
|
|
107
|
+
componentValue.value = [options.value[0].value]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const onConfirm = ({ selectedValues }) => {
|
|
112
|
+
const value = columns === 1 ? selectedValues[0] : selectedValues
|
|
113
|
+
emit("change", value)
|
|
114
|
+
emit("update:modelValue", value)
|
|
115
|
+
pickerRef.value.close()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const onClear = () => {
|
|
119
|
+
const value = columns === 1 ? null : []
|
|
120
|
+
emit("change", value)
|
|
121
|
+
emit("update:modelValue", value)
|
|
122
|
+
pickerRef.value.close()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
expose({ displayText })
|
|
126
|
+
|
|
127
|
+
return () => (
|
|
128
|
+
<PickerWrapper ref={pickerRef} closeable={false} onOpen={onOpenWrapper}>
|
|
129
|
+
{{
|
|
130
|
+
...pickerSlots(slots, props),
|
|
131
|
+
default: () => [
|
|
132
|
+
<Picker
|
|
133
|
+
v-model={componentValue.value}
|
|
134
|
+
columns={options.value}
|
|
135
|
+
onConfirm={onConfirm}
|
|
136
|
+
onCancel={() => pickerRef.value.close()}
|
|
137
|
+
{...props.pickerProps}
|
|
138
|
+
/>,
|
|
139
|
+
props.clearable ? (
|
|
140
|
+
<div class={"ex-field-popup__clear-btn"}>
|
|
141
|
+
<Button block type={"primary"} plain={true} round={true} onClick={onClear}>
|
|
142
|
+
清除
|
|
143
|
+
</Button>
|
|
144
|
+
</div>
|
|
145
|
+
) : null,
|
|
146
|
+
],
|
|
147
|
+
}}
|
|
148
|
+
</PickerWrapper>
|
|
149
|
+
)
|
|
150
|
+
},
|
|
151
|
+
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineComponent, ref, watch } from "vue"
|
|
2
|
+
import { defaultFieldProps } from "../utils"
|
|
3
|
+
import { Slider } from "vant"
|
|
4
|
+
import ExField from "./ExField.jsx"
|
|
5
|
+
import { pick } from "lodash-es"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ExSlider 评分
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: "ExSlider",
|
|
13
|
+
props: {
|
|
14
|
+
...defaultFieldProps,
|
|
15
|
+
|
|
16
|
+
modelValue: { type: [Number, Array], default: 2 },
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* [原生配置](https://vant-contrib.gitee.io/vant/#/zh-CN/slider)
|
|
20
|
+
*/
|
|
21
|
+
sliderProps: { type: Object, default: () => ({}) },
|
|
22
|
+
},
|
|
23
|
+
emits: ["update:modelValue"],
|
|
24
|
+
setup(props, { emit, slots }) {
|
|
25
|
+
const componentValue = ref(props.modelValue)
|
|
26
|
+
|
|
27
|
+
watch(
|
|
28
|
+
() => props.modelValue,
|
|
29
|
+
() => (componentValue.value = props.modelValue),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const onChange = (value) => {
|
|
33
|
+
emit("update:modelValue", value)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const fieldProps = pick(props, Object.keys(defaultFieldProps))
|
|
37
|
+
|
|
38
|
+
return () => (
|
|
39
|
+
<ExField {...fieldProps}>
|
|
40
|
+
{{
|
|
41
|
+
...slots,
|
|
42
|
+
input: () => (
|
|
43
|
+
<Slider v-model={componentValue.value} clearable={true} {...props.sliderProps} onChange={onChange}>
|
|
44
|
+
{{
|
|
45
|
+
button: () => <div class="ex-slider-button">{componentValue.value}</div>,
|
|
46
|
+
}}
|
|
47
|
+
</Slider>
|
|
48
|
+
),
|
|
49
|
+
}}
|
|
50
|
+
</ExField>
|
|
51
|
+
)
|
|
52
|
+
},
|
|
53
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineComponent, ref, watch } from "vue"
|
|
2
|
+
import { defaultFieldProps } from "../utils"
|
|
3
|
+
import { Switch } from "vant"
|
|
4
|
+
import ExField from "./ExField.jsx"
|
|
5
|
+
import { pick } from "lodash-es"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ExSwitch 开关
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: "ExSwitch",
|
|
13
|
+
props: {
|
|
14
|
+
...defaultFieldProps,
|
|
15
|
+
|
|
16
|
+
modelValue: { type: Boolean, default: false },
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* [原生配置](https://vant-contrib.gitee.io/vant/#/zh-CN/switch)
|
|
20
|
+
*/
|
|
21
|
+
switchProps: { type: Object, default: () => ({}) },
|
|
22
|
+
},
|
|
23
|
+
emits: ["update:modelValue"],
|
|
24
|
+
setup(props, { emit, slots }) {
|
|
25
|
+
const componentValue = ref(props.modelValue)
|
|
26
|
+
|
|
27
|
+
watch(
|
|
28
|
+
() => props.modelValue,
|
|
29
|
+
() => (componentValue.value = props.modelValue),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const onChange = (value) => {
|
|
33
|
+
emit("update:modelValue", Boolean(value))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const fieldProps = pick(props, Object.keys(defaultFieldProps))
|
|
37
|
+
|
|
38
|
+
return () => (
|
|
39
|
+
<ExField {...fieldProps}>
|
|
40
|
+
{{
|
|
41
|
+
...slots,
|
|
42
|
+
input: () => (
|
|
43
|
+
<Switch v-model={componentValue.value} {...props.switchProps} theme={"round"} size={"22px"} onChange={onChange}></Switch>
|
|
44
|
+
),
|
|
45
|
+
}}
|
|
46
|
+
</ExField>
|
|
47
|
+
)
|
|
48
|
+
},
|
|
49
|
+
})
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { computed, defineComponent, ref, watch } from "vue"
|
|
2
|
+
import PickerWrapper, { pickerSlots } from "./PickerWrapper.jsx"
|
|
3
|
+
import { TimePicker } from "vant"
|
|
4
|
+
import { defaultFieldProps } from "../utils"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ExTime 日期选择
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
name: "ExDate",
|
|
12
|
+
props: {
|
|
13
|
+
...defaultFieldProps,
|
|
14
|
+
|
|
15
|
+
modelValue: { type: String, default: "" },
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 标题
|
|
19
|
+
*/
|
|
20
|
+
title: { type: String, default: "选择时间" },
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* [原生配置](https://vant-contrib.gitee.io/vant/#/zh-CN/time-picker)
|
|
24
|
+
*/
|
|
25
|
+
timeProps: { type: Object, default: () => ({}) },
|
|
26
|
+
},
|
|
27
|
+
emits: ["update:modelValue"],
|
|
28
|
+
setup(props, { emit, slots, expose }) {
|
|
29
|
+
const columnsType = props.timeProps?.columnsType || ["hour", "minute"]
|
|
30
|
+
const prepareDate = (time) => {
|
|
31
|
+
const value = []
|
|
32
|
+
|
|
33
|
+
if (time) {
|
|
34
|
+
time = time.split(":")
|
|
35
|
+
} else {
|
|
36
|
+
return value
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
columnsType.forEach((column, index) => {
|
|
40
|
+
value.push(time[index])
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return value
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const defaultValue = prepareDate(props.modelValue)
|
|
47
|
+
|
|
48
|
+
const componentValue = ref(defaultValue)
|
|
49
|
+
|
|
50
|
+
watch(
|
|
51
|
+
() => props.modelValue,
|
|
52
|
+
() => {
|
|
53
|
+
componentValue.value = prepareDate(props.modelValue)
|
|
54
|
+
},
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
const pickerRef = ref(null)
|
|
58
|
+
|
|
59
|
+
const displayText = computed(() => {
|
|
60
|
+
if (props.modelValue) {
|
|
61
|
+
let text = ""
|
|
62
|
+
columnsType.forEach((column, index) => {
|
|
63
|
+
let times = prepareDate(props.modelValue)
|
|
64
|
+
|
|
65
|
+
if (column === "hour") {
|
|
66
|
+
text += `${times[index]}时`
|
|
67
|
+
} else if (column === "minute") {
|
|
68
|
+
text += `${times[index]}分`
|
|
69
|
+
} else if (column === "second") {
|
|
70
|
+
text += `${times[index]}秒`
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
return text
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return ""
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
expose({ displayText })
|
|
81
|
+
|
|
82
|
+
const onConfirm = ({ selectedValues }) => {
|
|
83
|
+
pickerRef.value.close()
|
|
84
|
+
emit("update:modelValue", selectedValues.join(":"))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return () => (
|
|
88
|
+
<PickerWrapper ref={pickerRef} closeable={false}>
|
|
89
|
+
{{
|
|
90
|
+
...pickerSlots(slots, props),
|
|
91
|
+
default: () => (
|
|
92
|
+
<TimePicker
|
|
93
|
+
v-model={componentValue.value}
|
|
94
|
+
onConfirm={onConfirm}
|
|
95
|
+
onCancel={() => pickerRef.value.close()}
|
|
96
|
+
title={props.title}
|
|
97
|
+
{...props.timeProps}
|
|
98
|
+
/>
|
|
99
|
+
),
|
|
100
|
+
}}
|
|
101
|
+
</PickerWrapper>
|
|
102
|
+
)
|
|
103
|
+
},
|
|
104
|
+
})
|