dpzvc3-ui 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +175 -0
- package/build-style.js +58 -0
- package/dist/dpzvc3.esm.js +17676 -0
- package/dist/dpzvc3.esm.js.map +1 -0
- package/dist/dpzvc3.esm.min.js +2 -0
- package/dist/dpzvc3.esm.min.js.map +1 -0
- package/dist/dpzvc3.js +15200 -0
- package/dist/dpzvc3.js.map +1 -0
- package/dist/dpzvc3.min.js +2 -0
- package/dist/dpzvc3.min.js.map +1 -0
- package/dist/styles/base/font.css +1 -0
- package/dist/styles/base/reset.css +1 -0
- package/dist/styles/base/variable.css +0 -0
- package/dist/styles/components/actionSheet.css +1 -0
- package/dist/styles/components/badge.css +1 -0
- package/dist/styles/components/button.css +1 -0
- package/dist/styles/components/card.css +1 -0
- package/dist/styles/components/cell-swipe.css +1 -0
- package/dist/styles/components/cell.css +1 -0
- package/dist/styles/components/checkBox.css +1 -0
- package/dist/styles/components/editor.css +1 -0
- package/dist/styles/components/header.css +1 -0
- package/dist/styles/components/indicator.css +1 -0
- package/dist/styles/components/loadmore.css +1 -0
- package/dist/styles/components/message.css +1 -0
- package/dist/styles/components/modal.css +1 -0
- package/dist/styles/components/number.css +1 -0
- package/dist/styles/components/picker.css +1 -0
- package/dist/styles/components/popup.css +1 -0
- package/dist/styles/components/progress.css +1 -0
- package/dist/styles/components/prompt.css +1 -0
- package/dist/styles/components/radioBox.css +1 -0
- package/dist/styles/components/slide-Bar.css +1 -0
- package/dist/styles/components/spinner.css +1 -0
- package/dist/styles/components/swipe.css +1 -0
- package/dist/styles/components/switchBar.css +1 -0
- package/dist/styles/components/tab.css +1 -0
- package/dist/styles/components/text.css +1 -0
- package/dist/styles/components/toTop.css +1 -0
- package/dist/styles/components/upload.css +1 -0
- package/dist/styles/dpzvc3.css +1 -0
- package/dist/styles/utils/1px.css +1 -0
- package/dist/styles/utils/animation.css +1 -0
- package/dist/styles/utils/nowrap.css +1 -0
- package/dist-prod/91.9d79b442ec3131707419.js +3 -0
- package/dist-prod/91.9d79b442ec3131707419.js.LICENSE.txt +25 -0
- package/dist-prod/91.9d79b442ec3131707419.js.map +1 -0
- package/dist-prod/actionsheet.e2f7c32d0120f5147a4f.chunk.js +2 -0
- package/dist-prod/actionsheet.e2f7c32d0120f5147a4f.chunk.js.map +1 -0
- package/dist-prod/badge.6038c4ccc54ffb56a645.chunk.js +2 -0
- package/dist-prod/badge.6038c4ccc54ffb56a645.chunk.js.map +1 -0
- package/dist-prod/button.28b491339fbba29c3f16.chunk.js +2 -0
- package/dist-prod/button.28b491339fbba29c3f16.chunk.js.map +1 -0
- package/dist-prod/card.3ad847f07bebc1391125.chunk.js +2 -0
- package/dist-prod/card.3ad847f07bebc1391125.chunk.js.map +1 -0
- package/dist-prod/cell.8920796a9ebd2d84bbd3.chunk.js +2 -0
- package/dist-prod/cell.8920796a9ebd2d84bbd3.chunk.js.map +1 -0
- package/dist-prod/cellswipe.53b0178e4638c201dcf1.chunk.js +2 -0
- package/dist-prod/cellswipe.53b0178e4638c201dcf1.chunk.js.map +1 -0
- package/dist-prod/checkbox.87403976981ee0f64f4a.chunk.js +2 -0
- package/dist-prod/checkbox.87403976981ee0f64f4a.chunk.js.map +1 -0
- package/dist-prod/guide.5195c74796a7a0e37f7b.chunk.js +2 -0
- package/dist-prod/guide.5195c74796a7a0e37f7b.chunk.js.map +1 -0
- package/dist-prod/header.e3cecc6d60f801c1c105.chunk.js +2 -0
- package/dist-prod/header.e3cecc6d60f801c1c105.chunk.js.map +1 -0
- package/dist-prod/index.html +19 -0
- package/dist-prod/indicator.6b0c7a91ca254c3586e8.chunk.js +2 -0
- package/dist-prod/indicator.6b0c7a91ca254c3586e8.chunk.js.map +1 -0
- package/dist-prod/loadmore.ba86c35311fc68ee215b.chunk.js +2 -0
- package/dist-prod/loadmore.ba86c35311fc68ee215b.chunk.js.map +1 -0
- package/dist-prod/main.2e9aaa9095e329ea2d7b.js +2 -0
- package/dist-prod/main.2e9aaa9095e329ea2d7b.js.map +1 -0
- package/dist-prod/message.e57fa263a214006f7191.chunk.js +2 -0
- package/dist-prod/message.e57fa263a214006f7191.chunk.js.map +1 -0
- package/dist-prod/modal.1172c8ba7d90503fc8e8.chunk.js +2 -0
- package/dist-prod/modal.1172c8ba7d90503fc8e8.chunk.js.map +1 -0
- package/dist-prod/picker.4ff114161c5c3f8df57a.chunk.js +2 -0
- package/dist-prod/picker.4ff114161c5c3f8df57a.chunk.js.map +1 -0
- package/dist-prod/popup.8f92c027932e4d47fa59.chunk.js +2 -0
- package/dist-prod/popup.8f92c027932e4d47fa59.chunk.js.map +1 -0
- package/dist-prod/progress.1e0d785044aecadc5615.chunk.js +2 -0
- package/dist-prod/progress.1e0d785044aecadc5615.chunk.js.map +1 -0
- package/dist-prod/prompt.c2b442c3dd0e6d8319bc.chunk.js +2 -0
- package/dist-prod/prompt.c2b442c3dd0e6d8319bc.chunk.js.map +1 -0
- package/dist-prod/radiobox.479703c69b75d473e85d.chunk.js +2 -0
- package/dist-prod/radiobox.479703c69b75d473e85d.chunk.js.map +1 -0
- package/dist-prod/rater.939e0e7e770728f684c3.chunk.js +2 -0
- package/dist-prod/rater.939e0e7e770728f684c3.chunk.js.map +1 -0
- package/dist-prod/slidebar.3d3f48a631f03a2210c9.chunk.js +2 -0
- package/dist-prod/slidebar.3d3f48a631f03a2210c9.chunk.js.map +1 -0
- package/dist-prod/spinner.f20e3bd8cec27d26afe0.chunk.js +2 -0
- package/dist-prod/spinner.f20e3bd8cec27d26afe0.chunk.js.map +1 -0
- package/dist-prod/swipe.2e5b0acc3bbb2bf49dd5.chunk.js +2 -0
- package/dist-prod/swipe.2e5b0acc3bbb2bf49dd5.chunk.js.map +1 -0
- package/dist-prod/switchbar.56d03d96c275ff4c65a1.chunk.js +2 -0
- package/dist-prod/switchbar.56d03d96c275ff4c65a1.chunk.js.map +1 -0
- package/dist-prod/tab.4c391211c41b7d12b585.chunk.js +2 -0
- package/dist-prod/tab.4c391211c41b7d12b585.chunk.js.map +1 -0
- package/dist-prod/text.ee2804ba87e6a460aa7d.chunk.js +2 -0
- package/dist-prod/text.ee2804ba87e6a460aa7d.chunk.js.map +1 -0
- package/dist-prod/totop.c6f9dce152bb6abe5cb2.chunk.js +2 -0
- package/dist-prod/totop.c6f9dce152bb6abe5cb2.chunk.js.map +1 -0
- package/dist-prod/upload.ec7a954970889869d93e.chunk.js +2 -0
- package/dist-prod/upload.ec7a954970889869d93e.chunk.js.map +1 -0
- package/images/IMG_2614 2 2.JPG +0 -0
- package/images/IMG_2614.JPG +0 -0
- package/images/IMG_2615 2.JPG +0 -0
- package/images/IMG_2615.JPG +0 -0
- package/package.json +113 -0
- package/postcss.config.js +5 -0
- package/src/components/Indicator/Indicator.vue +82 -0
- package/src/components/Indicator/index.js +86 -0
- package/src/components/Text/Number.vue +167 -0
- package/src/components/Text/index.js +7 -0
- package/src/components/Text/textBar.vue +122 -0
- package/src/components/action-sheet/actionSheet.vue +93 -0
- package/src/components/action-sheet/index.js +5 -0
- package/src/components/app.vue +61 -0
- package/src/components/badge/badge.vue +80 -0
- package/src/components/badge/index.js +5 -0
- package/src/components/button/button.vue +111 -0
- package/src/components/button/index.js +5 -0
- package/src/components/card/card.vue +49 -0
- package/src/components/card/index.js +5 -0
- package/src/components/cell/cell.vue +93 -0
- package/src/components/cell/index.js +5 -0
- package/src/components/cell-swipe/cell-swipe.vue +169 -0
- package/src/components/cell-swipe/index.js +5 -0
- package/src/components/checkBox/checkbox-group.vue +74 -0
- package/src/components/checkBox/checkbox.vue +117 -0
- package/src/components/checkBox/index.js +8 -0
- package/src/components/header/header.vue +130 -0
- package/src/components/header/index.js +5 -0
- package/src/components/loadMore/index.js +5 -0
- package/src/components/loadMore/loadmore.vue +258 -0
- package/src/components/message/confirm.js +60 -0
- package/src/components/message/index.js +111 -0
- package/src/components/message/message.vue +137 -0
- package/src/components/message/messageGroup.vue +82 -0
- package/src/components/modal/confirm.js +122 -0
- package/src/components/modal/index.js +52 -0
- package/src/components/modal/modal.vue +138 -0
- package/src/components/picker/area-picker/area-picker.vue +230 -0
- package/src/components/picker/area-picker/props.js +17 -0
- package/src/components/picker/date-picker/date-picker.vue +191 -0
- package/src/components/picker/date-picker/props.js +24 -0
- package/src/components/picker/index.js +5 -0
- package/src/components/picker/normal-picker/normal-picker.vue +120 -0
- package/src/components/picker/normal-picker/props.js +20 -0
- package/src/components/picker/picker-slot.vue +217 -0
- package/src/components/picker/picker.vue +111 -0
- package/src/components/popup/index.js +5 -0
- package/src/components/popup/popup.vue +91 -0
- package/src/components/progress/index.js +5 -0
- package/src/components/progress/progress.vue +86 -0
- package/src/components/prompt/confirm.js +91 -0
- package/src/components/prompt/index.js +53 -0
- package/src/components/prompt/prompt.vue +125 -0
- package/src/components/radioBox/index.js +8 -0
- package/src/components/radioBox/radiobox-group.vue +66 -0
- package/src/components/radioBox/radiobox.vue +88 -0
- package/src/components/rater/index.js +5 -0
- package/src/components/rater/rater.vue +118 -0
- package/src/components/slideBar/index.js +6 -0
- package/src/components/slideBar/slideBar.vue +207 -0
- package/src/components/spinner/behavior/blade.vue +42 -0
- package/src/components/spinner/behavior/double-bounce.vue +38 -0
- package/src/components/spinner/behavior/fading-circle.vue +55 -0
- package/src/components/spinner/behavior/snake.vue +41 -0
- package/src/components/spinner/behavior/triple-bounce.vue +52 -0
- package/src/components/spinner/index.js +5 -0
- package/src/components/spinner/props.js +28 -0
- package/src/components/spinner/spinner.vue +78 -0
- package/src/components/swipe/index.js +5 -0
- package/src/components/swipe/swipe.vue +281 -0
- package/src/components/switchbar/index.js +5 -0
- package/src/components/switchbar/switchbar.vue +79 -0
- package/src/components/tab/index.js +6 -0
- package/src/components/tab/tab.vue +89 -0
- package/src/components/toTop/index.js +5 -0
- package/src/components/toTop/topTop.vue +78 -0
- package/src/components/upload/index.js +5 -0
- package/src/components/upload/upload.vue +166 -0
- package/src/config/config.js +16 -0
- package/src/directives/clickoutside.js +42 -0
- package/src/directives/tranferDom.js +66 -0
- package/src/index.js +149 -0
- package/src/lib/MegaPixImage.js +163 -0
- package/src/lib/MegaPixImageOld.js +153 -0
- package/src/lib/exif-js.js +235 -0
- package/src/lib/exif.js +789 -0
- package/src/main.js +31 -0
- package/src/mixin/emitter.js +72 -0
- package/src/mixin/input.js +41 -0
- package/src/router.js +36 -0
- package/src/styles/base/font.less +99 -0
- package/src/styles/base/reset.less +135 -0
- package/src/styles/base/variable.less +108 -0
- package/src/styles/components/actionSheet.less +43 -0
- package/src/styles/components/badge.less +81 -0
- package/src/styles/components/button.less +124 -0
- package/src/styles/components/card.less +31 -0
- package/src/styles/components/cell-swipe.less +20 -0
- package/src/styles/components/cell.less +75 -0
- package/src/styles/components/checkBox.less +113 -0
- package/src/styles/components/editor.less +3 -0
- package/src/styles/components/header.less +72 -0
- package/src/styles/components/indicator.less +39 -0
- package/src/styles/components/loadmore.less +48 -0
- package/src/styles/components/message.less +57 -0
- package/src/styles/components/modal.less +84 -0
- package/src/styles/components/number.less +60 -0
- package/src/styles/components/picker.less +152 -0
- package/src/styles/components/popup.less +46 -0
- package/src/styles/components/progress.less +52 -0
- package/src/styles/components/prompt.less +37 -0
- package/src/styles/components/radioBox.less +138 -0
- package/src/styles/components/slide-Bar.less +149 -0
- package/src/styles/components/spinner.less +329 -0
- package/src/styles/components/swipe.less +125 -0
- package/src/styles/components/switchBar.less +88 -0
- package/src/styles/components/tab.less +71 -0
- package/src/styles/components/text.less +82 -0
- package/src/styles/components/toTop.less +28 -0
- package/src/styles/components/upload.less +23 -0
- package/src/styles/index.less +38 -0
- package/src/styles/utils/1px.less +206 -0
- package/src/styles/utils/animation.less +165 -0
- package/src/styles/utils/nowrap.less +19 -0
- package/src/template/index.ejs +40 -0
- package/src/utils/util.js +202 -0
- package/src/vconsole-resources.min.js +6 -0
- package/src/vconsole-sources.min.js +6 -0
- package/src/vconsole.min.js +7 -0
- package/src/views/ActionSheet.vue +46 -0
- package/src/views/Badge.vue +51 -0
- package/src/views/Button.vue +69 -0
- package/src/views/Card.vue +88 -0
- package/src/views/Cell.vue +30 -0
- package/src/views/CellSwipe.vue +68 -0
- package/src/views/CheckBox.vue +77 -0
- package/src/views/Header.vue +70 -0
- package/src/views/Indicator.vue +82 -0
- package/src/views/LoadMore.vue +73 -0
- package/src/views/Message.vue +61 -0
- package/src/views/Modal.vue +69 -0
- package/src/views/Picker.vue +140 -0
- package/src/views/Popup.vue +97 -0
- package/src/views/Progress.vue +47 -0
- package/src/views/Prompt.vue +43 -0
- package/src/views/RadioBox.vue +68 -0
- package/src/views/Rater.vue +49 -0
- package/src/views/SlideBar.vue +55 -0
- package/src/views/Spinner.vue +15 -0
- package/src/views/Swipe.vue +59 -0
- package/src/views/SwitchBar.vue +47 -0
- package/src/views/Tab.vue +53 -0
- package/src/views/Text.vue +93 -0
- package/src/views/ToTop.vue +17 -0
- package/src/views/Upload.vue +61 -0
- package/src/views/guide.vue +164 -0
- package/src/views/index.vue +554 -0
- package/webpack.base.config.js +65 -0
- package/webpack.dev.config.js +42 -0
- package/webpack.dist.dev.config.js +75 -0
- package/webpack.dist.prod.config.js +89 -0
- package/webpack.prod.config.js +51 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes">
|
|
3
|
+
<div class="header">
|
|
4
|
+
<div
|
|
5
|
+
class="left"
|
|
6
|
+
@click="cancle"
|
|
7
|
+
>
|
|
8
|
+
取消
|
|
9
|
+
</div>
|
|
10
|
+
<div class="title">
|
|
11
|
+
请选择区域
|
|
12
|
+
</div>
|
|
13
|
+
<div
|
|
14
|
+
class="right"
|
|
15
|
+
@click="sure"
|
|
16
|
+
>
|
|
17
|
+
确定
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div class="main">
|
|
22
|
+
<PickerSlot
|
|
23
|
+
:list="provinces"
|
|
24
|
+
:init-item="province.code"
|
|
25
|
+
target="province"
|
|
26
|
+
@change="change"
|
|
27
|
+
/>
|
|
28
|
+
<PickerSlot
|
|
29
|
+
:list="citys"
|
|
30
|
+
:init-item="city.code"
|
|
31
|
+
target="city"
|
|
32
|
+
@change="change"
|
|
33
|
+
/>
|
|
34
|
+
<PickerSlot
|
|
35
|
+
:list="districts"
|
|
36
|
+
:init-item="district.code"
|
|
37
|
+
target="district"
|
|
38
|
+
@change="change"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import { defineComponent, ref, computed, watch, inject } from 'vue'
|
|
46
|
+
import CHINA_AREA from 'china-area-data'
|
|
47
|
+
import PickerSlot from '../picker-slot'
|
|
48
|
+
import props from './props'
|
|
49
|
+
|
|
50
|
+
const prefixCls = 'dpzvc3-picker'
|
|
51
|
+
const rootCode = '86'
|
|
52
|
+
|
|
53
|
+
export default defineComponent({
|
|
54
|
+
name: 'AreaPicker',
|
|
55
|
+
components: { PickerSlot },
|
|
56
|
+
props: {
|
|
57
|
+
...props,
|
|
58
|
+
addressValue: String,
|
|
59
|
+
valueSeparator: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: '-'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
setup (props, { emit }) {
|
|
65
|
+
const { pickerOnOk, pickeronFail } = inject('DpzVc3Picker')
|
|
66
|
+
const currentValue = ref(props.addressValue || '')
|
|
67
|
+
|
|
68
|
+
const province = ref({
|
|
69
|
+
value: '北京市',
|
|
70
|
+
code: '110000',
|
|
71
|
+
target: 'province',
|
|
72
|
+
index: 0
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const city = ref({
|
|
76
|
+
value: '市辖区',
|
|
77
|
+
code: '110100',
|
|
78
|
+
target: 'city',
|
|
79
|
+
index: 0
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const district = ref({
|
|
83
|
+
value: '东城区',
|
|
84
|
+
code: '110101',
|
|
85
|
+
target: 'district',
|
|
86
|
+
index: 0
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const classes = computed(() => [prefixCls])
|
|
90
|
+
|
|
91
|
+
// 计算省、市、区列表
|
|
92
|
+
const provinces = computed(() => filter('province'))
|
|
93
|
+
const citys = computed(() => filter('city', province.value))
|
|
94
|
+
const districts = computed(() => filter('district', city.value))
|
|
95
|
+
|
|
96
|
+
watch(
|
|
97
|
+
() => props.addressValue,
|
|
98
|
+
(val) => {
|
|
99
|
+
currentValue.value = val
|
|
100
|
+
initVal()
|
|
101
|
+
},
|
|
102
|
+
{ immediate: true }
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
function initVal () {
|
|
106
|
+
if (!currentValue.value) return
|
|
107
|
+
const [provinceName, cityName, districtName] = currentValue.value.split(
|
|
108
|
+
props.valueSeparator
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
// 省份
|
|
112
|
+
const provincesData = CHINA_AREA[rootCode]
|
|
113
|
+
if (provincesData) {
|
|
114
|
+
Object.keys(provincesData).forEach((item) => {
|
|
115
|
+
if (provinceName === item || provinceName === provincesData[item]) {
|
|
116
|
+
province.value.value = provincesData[item]
|
|
117
|
+
province.value.code = item
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 城市
|
|
123
|
+
const cityData = CHINA_AREA[province.value.code]
|
|
124
|
+
if (cityData) {
|
|
125
|
+
Object.keys(cityData).forEach((item) => {
|
|
126
|
+
if (cityName === item || cityName === cityData[item]) {
|
|
127
|
+
city.value.value = cityData[item]
|
|
128
|
+
city.value.code = item
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 区县
|
|
134
|
+
const districtData = CHINA_AREA[city.value.code]
|
|
135
|
+
if (districtData) {
|
|
136
|
+
Object.keys(districtData).forEach((item) => {
|
|
137
|
+
if (districtName === item || districtName === districtData[item]) {
|
|
138
|
+
district.value.value = districtData[item]
|
|
139
|
+
district.value.code = item
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function filter (target, val = {}) {
|
|
146
|
+
switch (target) {
|
|
147
|
+
case 'province': {
|
|
148
|
+
const data = CHINA_AREA[rootCode]
|
|
149
|
+
if (!data) return []
|
|
150
|
+
return Object.keys(data).map((item, index) => ({
|
|
151
|
+
code: item,
|
|
152
|
+
value: data[item],
|
|
153
|
+
target,
|
|
154
|
+
index
|
|
155
|
+
}))
|
|
156
|
+
}
|
|
157
|
+
case 'city':
|
|
158
|
+
case 'district': {
|
|
159
|
+
const listData = CHINA_AREA[val.code]
|
|
160
|
+
if (!listData) {
|
|
161
|
+
if (target) {
|
|
162
|
+
if (target === 'city') city.value = { value: '', code: '', target, index: 0 }
|
|
163
|
+
if (target === 'district') district.value = { value: '', code: '', target, index: 0 }
|
|
164
|
+
}
|
|
165
|
+
return []
|
|
166
|
+
}
|
|
167
|
+
return Object.keys(listData).map((item, index) => ({
|
|
168
|
+
code: item,
|
|
169
|
+
value: listData[item],
|
|
170
|
+
target,
|
|
171
|
+
index
|
|
172
|
+
}))
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function change (target, current) {
|
|
178
|
+
if (target === 'province') province.value = { ...province.value, ...current }
|
|
179
|
+
if (target === 'city') city.value = { ...city.value, ...current }
|
|
180
|
+
if (target === 'district') district.value = { ...district.value, ...current }
|
|
181
|
+
|
|
182
|
+
emit('update:addressValue', [
|
|
183
|
+
province.value.value,
|
|
184
|
+
city.value.value,
|
|
185
|
+
district.value.value
|
|
186
|
+
].filter(Boolean).join(props.valueSeparator))
|
|
187
|
+
|
|
188
|
+
emit('change', {
|
|
189
|
+
province: { code: province.value.code, name: province.value.value },
|
|
190
|
+
city: { code: city.value.code, name: city.value.value },
|
|
191
|
+
district: { code: district.value.code, name: district.value.value }
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function sure () {
|
|
196
|
+
// emit('sure', {
|
|
197
|
+
// province: { code: province.value.code, name: province.value.value },
|
|
198
|
+
// city: { code: city.value.code, name: city.value.value },
|
|
199
|
+
// district: { code: district.value.code, name: district.value.value },
|
|
200
|
+
// formArea: [province.value.value, city.value.value, district.value.value].filter(Boolean).join(props.valueSeparator)
|
|
201
|
+
// })
|
|
202
|
+
pickerOnOk({
|
|
203
|
+
province: { code: province.value.code, name: province.value.value },
|
|
204
|
+
city: { code: city.value.code, name: city.value.value },
|
|
205
|
+
district: { code: district.value.code, name: district.value.value },
|
|
206
|
+
formArea: [province.value.value, city.value.value, district.value.value].filter(Boolean).join(props.valueSeparator)
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function cancle () {
|
|
211
|
+
// emit('cancle')
|
|
212
|
+
pickeronFail()
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
classes,
|
|
217
|
+
province,
|
|
218
|
+
city,
|
|
219
|
+
district,
|
|
220
|
+
provinces,
|
|
221
|
+
citys,
|
|
222
|
+
districts,
|
|
223
|
+
currentValue,
|
|
224
|
+
change,
|
|
225
|
+
sure,
|
|
226
|
+
cancle
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
</script>
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes">
|
|
3
|
+
<div class="header">
|
|
4
|
+
<div
|
|
5
|
+
class="left"
|
|
6
|
+
@click="cancle"
|
|
7
|
+
>
|
|
8
|
+
取消
|
|
9
|
+
</div>
|
|
10
|
+
<div
|
|
11
|
+
class="right"
|
|
12
|
+
@click="sure"
|
|
13
|
+
>
|
|
14
|
+
确定
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class="main">
|
|
19
|
+
<PickerSlot
|
|
20
|
+
v-if="year"
|
|
21
|
+
:list="yearList"
|
|
22
|
+
:init-item="date.year.code"
|
|
23
|
+
target="year"
|
|
24
|
+
@change="change"
|
|
25
|
+
/>
|
|
26
|
+
<PickerSlot
|
|
27
|
+
v-if="month"
|
|
28
|
+
:list="monthList"
|
|
29
|
+
:init-item="date.month.code"
|
|
30
|
+
target="month"
|
|
31
|
+
@change="change"
|
|
32
|
+
/>
|
|
33
|
+
<PickerSlot
|
|
34
|
+
v-if="day"
|
|
35
|
+
:list="dayList"
|
|
36
|
+
:init-item="date.day.code"
|
|
37
|
+
target="day"
|
|
38
|
+
@change="change"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import { defineComponent, ref, computed, watch, inject } from 'vue'
|
|
46
|
+
import PickerSlot from '../picker-slot.vue'
|
|
47
|
+
import props from './props'
|
|
48
|
+
|
|
49
|
+
const DAYS = {
|
|
50
|
+
30: [4, 6, 9, 11],
|
|
51
|
+
31: [1, 3, 5, 7, 8, 10, 12]
|
|
52
|
+
}
|
|
53
|
+
const prefixCls = 'dpzvc3-date-picker'
|
|
54
|
+
|
|
55
|
+
export default defineComponent({
|
|
56
|
+
name: 'DatePicker',
|
|
57
|
+
components: { PickerSlot },
|
|
58
|
+
props: {
|
|
59
|
+
...props,
|
|
60
|
+
dateValue: String,
|
|
61
|
+
year: [Boolean, Array],
|
|
62
|
+
month: [Boolean, Array],
|
|
63
|
+
day: [Boolean, Array],
|
|
64
|
+
valueSeparator: { type: String, default: '-' }
|
|
65
|
+
},
|
|
66
|
+
setup (props, { emit }) {
|
|
67
|
+
const { pickerOnOk, pickeronFail } = inject('DpzVc3Picker')
|
|
68
|
+
const currentValue = ref(props.dateValue || '')
|
|
69
|
+
|
|
70
|
+
const date = ref({
|
|
71
|
+
year: { code: new Date().getFullYear(), value: String(new Date().getFullYear()), target: 'year', index: 0 },
|
|
72
|
+
month: { code: new Date().getMonth() + 1, value: String(new Date().getMonth() + 1), target: 'month', index: 0 },
|
|
73
|
+
day: { code: new Date().getDate(), value: String(new Date().getDate()), target: 'day', index: 0 },
|
|
74
|
+
formatDate: ''
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const classes = computed(() => [prefixCls])
|
|
78
|
+
|
|
79
|
+
const yearList = computed(() => {
|
|
80
|
+
if (!props.year) return []
|
|
81
|
+
let from = 1900
|
|
82
|
+
let to = new Date().getFullYear()
|
|
83
|
+
if (Array.isArray(props.year)) {
|
|
84
|
+
from = props.year[0] ?? from
|
|
85
|
+
to = props.year[1] ?? to
|
|
86
|
+
}
|
|
87
|
+
const list = []
|
|
88
|
+
for (let i = from, index = 0; i <= to; i++, index++) {
|
|
89
|
+
list.push({ code: i, value: String(i), target: 'year', index })
|
|
90
|
+
}
|
|
91
|
+
return list
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const monthList = computed(() => {
|
|
95
|
+
if (!props.month) return []
|
|
96
|
+
let from = 1
|
|
97
|
+
let to = 12
|
|
98
|
+
if (Array.isArray(props.month)) {
|
|
99
|
+
from = props.month[0] ?? from
|
|
100
|
+
to = props.month[1] ?? to
|
|
101
|
+
}
|
|
102
|
+
const list = []
|
|
103
|
+
for (let i = from, index = 0; i <= to; i++, index++) {
|
|
104
|
+
list.push({ code: i, value: String(i), target: 'month', index })
|
|
105
|
+
}
|
|
106
|
+
return list
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
const dayList = computed(() => {
|
|
110
|
+
if (!props.day) return []
|
|
111
|
+
let from = 1
|
|
112
|
+
let to = 31
|
|
113
|
+
|
|
114
|
+
const month = Number(date.value.month.value)
|
|
115
|
+
const year = Number(date.value.year.code)
|
|
116
|
+
|
|
117
|
+
if (DAYS[30].includes(month)) to = 30
|
|
118
|
+
else if (DAYS[31].includes(month)) to = 31
|
|
119
|
+
else {
|
|
120
|
+
// 二月
|
|
121
|
+
if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) to = 29
|
|
122
|
+
else to = 28
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (Array.isArray(props.day)) {
|
|
126
|
+
from = props.day[0] ?? from
|
|
127
|
+
to = props.day[1] ?? to
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const list = []
|
|
131
|
+
for (let i = from, index = 0; i <= to; i++, index++) {
|
|
132
|
+
list.push({ code: i, value: String(i), target: 'day', index })
|
|
133
|
+
}
|
|
134
|
+
return list
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
watch(() => props.dateValue, (val) => {
|
|
138
|
+
currentValue.value = val
|
|
139
|
+
initVal()
|
|
140
|
+
}, { immediate: true })
|
|
141
|
+
|
|
142
|
+
function initVal () {
|
|
143
|
+
if (!currentValue.value) return
|
|
144
|
+
const [y = '', m = '', d = ''] = currentValue.value.split(props.valueSeparator)
|
|
145
|
+
if (props.year) date.value.year = { ...date.value.year, code: Number(y), value: y }
|
|
146
|
+
if (props.month) date.value.month = { ...date.value.month, code: Number(m), value: m }
|
|
147
|
+
if (props.day) date.value.day = { ...date.value.day, code: Number(d), value: d }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function cancle () {
|
|
151
|
+
// emit('cancle')
|
|
152
|
+
pickeronFail()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function sure () {
|
|
156
|
+
date.value.formatDate = [date.value.year.value, date.value.month.value, date.value.day.value]
|
|
157
|
+
.filter(Boolean)
|
|
158
|
+
.join(props.valueSeparator)
|
|
159
|
+
// emit('sure', date.value)
|
|
160
|
+
pickerOnOk(date.value)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function change (target, current) {
|
|
164
|
+
if (target === 'year') date.value.year = { ...date.value.year, ...current }
|
|
165
|
+
if (target === 'month') date.value.month = { ...date.value.month, ...current }
|
|
166
|
+
if (target === 'day') date.value.day = { ...date.value.day, ...current }
|
|
167
|
+
|
|
168
|
+
date.value.formatDate = [date.value.year.value, date.value.month.value, date.value.day.value]
|
|
169
|
+
.filter(Boolean)
|
|
170
|
+
.join(props.valueSeparator)
|
|
171
|
+
|
|
172
|
+
emit('change', target, current)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
classes,
|
|
177
|
+
date,
|
|
178
|
+
yearList,
|
|
179
|
+
monthList,
|
|
180
|
+
dayList,
|
|
181
|
+
cancle,
|
|
182
|
+
sure,
|
|
183
|
+
change
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<style lang="less">
|
|
190
|
+
|
|
191
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by yishide on 2025/9/13.
|
|
3
|
+
*/
|
|
4
|
+
export default {
|
|
5
|
+
props: {
|
|
6
|
+
dateValue: String,
|
|
7
|
+
year: {
|
|
8
|
+
type: [Boolean, Array],
|
|
9
|
+
default: true
|
|
10
|
+
},
|
|
11
|
+
month: {
|
|
12
|
+
type: [Boolean, Array],
|
|
13
|
+
default: true
|
|
14
|
+
},
|
|
15
|
+
day: {
|
|
16
|
+
type: [Boolean, Array],
|
|
17
|
+
default: true
|
|
18
|
+
},
|
|
19
|
+
valueSeparator: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: '/'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes">
|
|
3
|
+
<div class="header">
|
|
4
|
+
<div
|
|
5
|
+
class="left"
|
|
6
|
+
@click="cancle"
|
|
7
|
+
>
|
|
8
|
+
取消
|
|
9
|
+
</div>
|
|
10
|
+
<div
|
|
11
|
+
class="right"
|
|
12
|
+
@click="sure"
|
|
13
|
+
>
|
|
14
|
+
确定
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="main">
|
|
18
|
+
<PickerSlot
|
|
19
|
+
v-for="(item, key) in shadowList"
|
|
20
|
+
:key="item.target"
|
|
21
|
+
:target="item.target"
|
|
22
|
+
:init-item="initItems[key]"
|
|
23
|
+
:list="item.list"
|
|
24
|
+
@change="change"
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import { defineComponent, ref, computed, watch, inject } from 'vue'
|
|
32
|
+
import PickerSlot from '../picker-slot.vue'
|
|
33
|
+
|
|
34
|
+
const prefixCls = 'dpzvc3-normal-picker'
|
|
35
|
+
|
|
36
|
+
export default defineComponent({
|
|
37
|
+
name: 'NormalPicker',
|
|
38
|
+
components: { PickerSlot },
|
|
39
|
+
props: {
|
|
40
|
+
list: { type: Array, default: () => [] },
|
|
41
|
+
initArr: { type: Array, default: () => [] }
|
|
42
|
+
},
|
|
43
|
+
setup (props, { emit }) {
|
|
44
|
+
const { pickerOnOk, pickeronFail } = inject('DpzVc3Picker')
|
|
45
|
+
|
|
46
|
+
/** 初始化选中项 */
|
|
47
|
+
const initItems = ref(
|
|
48
|
+
props.initArr.length
|
|
49
|
+
? [...props.initArr]
|
|
50
|
+
: props.list.map(item => item.list?.[0]?.code ?? '')
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
const normal = ref({})
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* ⚠️ 关键修复点:
|
|
57
|
+
* - 不修改 props.list
|
|
58
|
+
* - 返回全新对象
|
|
59
|
+
*/
|
|
60
|
+
const shadowList = computed(() => {
|
|
61
|
+
return props.list.map(item => {
|
|
62
|
+
const list = (item.list || []).map((child, index) => ({
|
|
63
|
+
code: child.code ?? child.value,
|
|
64
|
+
value: child.value,
|
|
65
|
+
target: child.target ?? item.target,
|
|
66
|
+
index
|
|
67
|
+
}))
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
...item,
|
|
71
|
+
list
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const classes = computed(() => [prefixCls])
|
|
77
|
+
|
|
78
|
+
watch(
|
|
79
|
+
() => props.initArr,
|
|
80
|
+
val => {
|
|
81
|
+
initItems.value =
|
|
82
|
+
val.length > 0
|
|
83
|
+
? [...val]
|
|
84
|
+
: props.list.map(item => item.list?.[0]?.code ?? '')
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
function cancle () {
|
|
89
|
+
pickeronFail()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function sure () {
|
|
93
|
+
pickerOnOk(normal.value)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function change (target, current) {
|
|
97
|
+
const index = shadowList.value.findIndex(i => i.target === target)
|
|
98
|
+
if (index !== -1) {
|
|
99
|
+
initItems.value[index] = current.code
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
normal.value = {
|
|
103
|
+
...normal.value,
|
|
104
|
+
[target]: current
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
emit('scroll', current)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
classes,
|
|
112
|
+
shadowList,
|
|
113
|
+
initItems,
|
|
114
|
+
cancle,
|
|
115
|
+
sure,
|
|
116
|
+
change
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
</script>
|