@wp1001/ui 2.9.13

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.
Files changed (177) hide show
  1. package/.env +6 -0
  2. package/@vant-D4fmGxs6.js +3891 -0
  3. package/index.js +8419 -0
  4. package/package.json +59 -0
  5. package/packages/assets/devtools-detector.js +2 -0
  6. package/packages/components/xarray/index.js +64 -0
  7. package/packages/components/xarray/xarray.vue +57 -0
  8. package/packages/components/xautorows/index.js +35 -0
  9. package/packages/components/xautorows/xautorows.vue +29 -0
  10. package/packages/components/xbutton/mobile.js +3 -0
  11. package/packages/components/xbutton/mobile.vue +9 -0
  12. package/packages/components/xbutton/pc.js +3 -0
  13. package/packages/components/xbutton/pc.vue +9 -0
  14. package/packages/components/xbuttons/mobile.js +51 -0
  15. package/packages/components/xbuttons/mobile.vue +12 -0
  16. package/packages/components/xbuttons/pc.js +51 -0
  17. package/packages/components/xbuttons/pc.vue +16 -0
  18. package/packages/components/xchart/constants.js +58 -0
  19. package/packages/components/xchart/index.js +263 -0
  20. package/packages/components/xchart/utils.js +121 -0
  21. package/packages/components/xchart/xchart.vue +173 -0
  22. package/packages/components/xcheckboxs/mobile.js +58 -0
  23. package/packages/components/xcheckboxs/mobile.vue +38 -0
  24. package/packages/components/xcheckboxs/pc.js +49 -0
  25. package/packages/components/xcheckboxs/pc.vue +42 -0
  26. package/packages/components/xcol/mobile.js +10 -0
  27. package/packages/components/xcol/mobile.vue +9 -0
  28. package/packages/components/xcol/pc.js +10 -0
  29. package/packages/components/xcol/pc.vue +9 -0
  30. package/packages/components/xdatepicker/mobile.js +71 -0
  31. package/packages/components/xdatepicker/mobile.vue +44 -0
  32. package/packages/components/xdatepicker/pc.js +9 -0
  33. package/packages/components/xdatepicker/pc.vue +12 -0
  34. package/packages/components/xdialog/mobile.js +60 -0
  35. package/packages/components/xdialog/mobile.vue +43 -0
  36. package/packages/components/xdialog/pc.js +64 -0
  37. package/packages/components/xdialog/pc.vue +51 -0
  38. package/packages/components/xdict/index.js +47 -0
  39. package/packages/components/xdict/xdict.vue +9 -0
  40. package/packages/components/xdistrictselect/mobile.js +79 -0
  41. package/packages/components/xdistrictselect/mobile.vue +28 -0
  42. package/packages/components/xdistrictselect/pc.js +127 -0
  43. package/packages/components/xdistrictselect/pc.vue +32 -0
  44. package/packages/components/xform/mobile.js +29 -0
  45. package/packages/components/xform/mobile.vue +43 -0
  46. package/packages/components/xform/pc.js +42 -0
  47. package/packages/components/xform/pc.vue +76 -0
  48. package/packages/components/xform/utils.js +95 -0
  49. package/packages/components/xformitem/mobile.js +56 -0
  50. package/packages/components/xformitem/mobile.vue +3 -0
  51. package/packages/components/xformitem/pc.js +72 -0
  52. package/packages/components/xformitem/pc.vue +10 -0
  53. package/packages/components/xformitem/utils.jsx +181 -0
  54. package/packages/components/xicon/mobile.js +35 -0
  55. package/packages/components/xicon/mobile.vue +9 -0
  56. package/packages/components/xicon/pc.js +35 -0
  57. package/packages/components/xicon/pc.vue +11 -0
  58. package/packages/components/xinfo/index.js +100 -0
  59. package/packages/components/xinfo/xinfo.vue +140 -0
  60. package/packages/components/xlooper/index.js +7 -0
  61. package/packages/components/xlooper/xlooper.vue +20 -0
  62. package/packages/components/xpagination/mobile.js +21 -0
  63. package/packages/components/xpagination/mobile.vue +31 -0
  64. package/packages/components/xpagination/pc.js +21 -0
  65. package/packages/components/xpagination/pc.vue +16 -0
  66. package/packages/components/xpicker/index.js +38 -0
  67. package/packages/components/xpicker/xpicker.vue +29 -0
  68. package/packages/components/xradios/mobile.js +40 -0
  69. package/packages/components/xradios/mobile.vue +22 -0
  70. package/packages/components/xradios/pc.js +53 -0
  71. package/packages/components/xradios/pc.vue +43 -0
  72. package/packages/components/xrow/mobile.js +9 -0
  73. package/packages/components/xrow/mobile.vue +23 -0
  74. package/packages/components/xrow/pc.js +9 -0
  75. package/packages/components/xrow/pc.vue +22 -0
  76. package/packages/components/xscan/mobile.js +24 -0
  77. package/packages/components/xscan/mobile.vue +21 -0
  78. package/packages/components/xscan/pc.js +20 -0
  79. package/packages/components/xscan/pc.vue +18 -0
  80. package/packages/components/xsearcher/index.js +198 -0
  81. package/packages/components/xsearcher/xsearcher.vue +170 -0
  82. package/packages/components/xselect/mobile.js +86 -0
  83. package/packages/components/xselect/mobile.vue +24 -0
  84. package/packages/components/xselect/pc.js +114 -0
  85. package/packages/components/xselect/pc.vue +55 -0
  86. package/packages/components/xselect/util.js +66 -0
  87. package/packages/components/xselectv2/index.js +91 -0
  88. package/packages/components/xselectv2/xselectv2.vue +46 -0
  89. package/packages/components/xtable/mobile.js +108 -0
  90. package/packages/components/xtable/mobile.vue +246 -0
  91. package/packages/components/xtable/pc.js +143 -0
  92. package/packages/components/xtable/pc.vue +421 -0
  93. package/packages/components/xtable/searcher.js +477 -0
  94. package/packages/components/xtable/searcher.jsx +330 -0
  95. package/packages/components/xtable/searcher.vue +133 -0
  96. package/packages/components/xtable/settings.js +80 -0
  97. package/packages/components/xtable/settings.vue +77 -0
  98. package/packages/components/xtable/utils.js +692 -0
  99. package/packages/components/xtabletools/mobile.js +25 -0
  100. package/packages/components/xtabletools/mobile.vue +126 -0
  101. package/packages/components/xtabletools/pc.js +18 -0
  102. package/packages/components/xtabletools/pc.vue +135 -0
  103. package/packages/components/xtablev2/index.js +53 -0
  104. package/packages/components/xtablev2/utils.jsx +214 -0
  105. package/packages/components/xtablev2/xtablev2.vue +147 -0
  106. package/packages/components/xtags/mobile.js +17 -0
  107. package/packages/components/xtags/mobile.vue +21 -0
  108. package/packages/components/xtags/pc.js +17 -0
  109. package/packages/components/xtags/pc.vue +22 -0
  110. package/packages/components/xtinymce/index.js +71 -0
  111. package/packages/components/xtinymce/xtinymce.vue +9 -0
  112. package/packages/components/xuploader/xfileuploader.js +48 -0
  113. package/packages/components/xuploader/xfileuploader.vue +54 -0
  114. package/packages/components/xuploader/ximageuploader.js +53 -0
  115. package/packages/components/xuploader/ximageuploader.vue +52 -0
  116. package/packages/comps.js +108 -0
  117. package/packages/controllers/BaseController.js +125 -0
  118. package/packages/controllers/CrudController.js +907 -0
  119. package/packages/controllers/TempCrudController.js +32 -0
  120. package/packages/controllers/index.js +15 -0
  121. package/packages/directives/el-table-infinite-scroll.js +55 -0
  122. package/packages/directives/index.js +5 -0
  123. package/packages/index.js +81 -0
  124. package/packages/index.scss +4 -0
  125. package/packages/layout/breadcrumb/breadcrumb.vue +31 -0
  126. package/packages/layout/breadcrumb/index.js +41 -0
  127. package/packages/layout/header/header.vue +281 -0
  128. package/packages/layout/header/inner.js +11 -0
  129. package/packages/layout/header/inner.vue +3 -0
  130. package/packages/layout/mobile-menu.vue +83 -0
  131. package/packages/layout/mobile-tabs.vue +54 -0
  132. package/packages/layout/pc.vue +85 -0
  133. package/packages/layout/screenlock/index.js +129 -0
  134. package/packages/layout/screenlock/screenlock.vue +85 -0
  135. package/packages/layout/sidebar/item.js +16 -0
  136. package/packages/layout/sidebar/item.vue +16 -0
  137. package/packages/layout/sidebar/menu.js +72 -0
  138. package/packages/layout/sidebar/menu.vue +106 -0
  139. package/packages/layout/sidebar/sidebar.vue +147 -0
  140. package/packages/layout/tagsview/ScrollPane.js +65 -0
  141. package/packages/layout/tagsview/ScrollPane.vue +24 -0
  142. package/packages/layout/tagsview/index.js +169 -0
  143. package/packages/layout/tagsview/index.vue +124 -0
  144. package/packages/plop/actions/make-fill-admin-partials-action.js +95 -0
  145. package/packages/plop/generators/make-admin-page.js +39 -0
  146. package/packages/plop/generators/make-database-admin-pages.js +84 -0
  147. package/packages/plop/generators/make-page-generator.js +52 -0
  148. package/packages/plop/generators/make-simple-page.js +20 -0
  149. package/packages/plop/plopfile.js +24 -0
  150. package/packages/plop/templates/admin_page/controller.js +3 -0
  151. package/packages/plop/templates/admin_page/model.js +24 -0
  152. package/packages/plop/templates/admin_page/{{snakeCase pagename}}-scoped.scss +3 -0
  153. package/packages/plop/templates/admin_page/{{snakeCase pagename}}.vue +11 -0
  154. package/packages/plop/templates/simple_page/controller.js +3 -0
  155. package/packages/plop/templates/simple_page/model.js +6 -0
  156. package/packages/plop/templates/simple_page/{{snakeCase pagename}}-scoped.scss +3 -0
  157. package/packages/plop/templates/simple_page/{{snakeCase pagename}}.vue +7 -0
  158. package/packages/plop/utils/index.js +168 -0
  159. package/packages/plop/utils/plop-utils.js +86 -0
  160. package/packages/styles/common.scss +137 -0
  161. package/packages/styles/element-ui.scss +142 -0
  162. package/packages/styles/vant.scss +133 -0
  163. package/packages/styles/variables.scss +23 -0
  164. package/packages/utils/crypt.js +24 -0
  165. package/packages/utils/decorators.js +67 -0
  166. package/packages/utils/disallowDevtools.js +53 -0
  167. package/packages/utils/effects.js +173 -0
  168. package/packages/utils/funcs.js +78 -0
  169. package/packages/utils/index.js +95 -0
  170. package/packages/utils/message.js +110 -0
  171. package/packages/utils/middlewares.js +86 -0
  172. package/packages/utils/model.js +71 -0
  173. package/packages/utils/modelUtils.js +203 -0
  174. package/packages/utils/request.js +57 -0
  175. package/packages/utils/site.js +33 -0
  176. package/packages/vite-plugins.js +141 -0
  177. package/publish.sh +12 -0
@@ -0,0 +1,42 @@
1
+ <script>
2
+ export { default } from './pc.js'
3
+ </script>
4
+
5
+ <template>
6
+ <el-checkbox-group
7
+ class="x-checkboxs pc-x-checkboxs"
8
+ :class="plain ? 'pc-x-checkboxs--plain' : ''"
9
+ v-bind="attrs"
10
+ :modelValue
11
+ @update:modelValue="value => $emit('update:modelValue', value)"
12
+ @change="$emit('change', $event)"
13
+ >
14
+ <el-checkbox
15
+ v-for="option in _options"
16
+ v-bind="attrs"
17
+ :disabled="option.raw?.disabled"
18
+ :key="option.text"
19
+ :value="option.value"
20
+ >
21
+ <slot
22
+ v-if="$slots.custom"
23
+ name="custom"
24
+ :option
25
+ :raw="option.raw"
26
+ />
27
+ <span v-else>{{ option.text }}</span>
28
+ </el-checkbox>
29
+ </el-checkbox-group>
30
+ </template>
31
+
32
+ <style lang="scss" scoped>
33
+ .pc-x-checkboxs--plain {
34
+ :deep(.el-checkbox) {
35
+ margin-right: 20px;
36
+ font-weight: normal;
37
+ .el-checkbox__input {
38
+ display: none;
39
+ }
40
+ }
41
+ }
42
+ </style>
@@ -0,0 +1,10 @@
1
+ export default {
2
+ name: 'MobileXCol',
3
+ inheritAttrs: false,
4
+ computed: {
5
+ attrs () {
6
+ const { text, slot, ...others } = this.$attrs
7
+ return others
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,9 @@
1
+ <script>
2
+ export { default } from './mobile.js'
3
+ </script>
4
+
5
+ <template>
6
+ <van-col v-bind="attrs" class="x-col mobile-x-col">
7
+ <slot />
8
+ </van-col>
9
+ </template>
@@ -0,0 +1,10 @@
1
+ export default {
2
+ name: 'PcXCol',
3
+ inheritAttrs: false,
4
+ computed: {
5
+ attrs () {
6
+ const { text, slot, ...others } = this.$attrs
7
+ return others
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,9 @@
1
+ <script>
2
+ export { default } from './pc.js'
3
+ </script>
4
+
5
+ <template>
6
+ <el-col v-bind="attrs" class="x-col pc-x-col">
7
+ <slot />
8
+ </el-col>
9
+ </template>
@@ -0,0 +1,71 @@
1
+ import { injectVanFieldProvide } from '../../utils/funcs.js'
2
+
3
+ const { $Date, format } = StardustJs.dates
4
+
5
+ export default {
6
+ name: 'MobileXDatePicker',
7
+ props: {
8
+ modelValue: String | Date,
9
+ valueFormat: String,
10
+ type: {
11
+ type: String,
12
+ default: 'date'
13
+ }
14
+ },
15
+ emits: ['update:modelValue', 'change'],
16
+ computed: {
17
+ value () {
18
+ if (!this.modelValue) return ''
19
+ let format = 'YYYY-MM-DD'
20
+ if (this.type === 'datetime') {
21
+ format = 'YYYY-MM-DD HH:mm'
22
+ } else if (this.type === 'time') {
23
+ format = 'HH:mm'
24
+ }
25
+ return new $Date(this.modelValue).to(format)
26
+ },
27
+ tabs () {
28
+ if (this.type === 'datetime') return ['选择日期', '选择时间']
29
+ else if (this.type === 'time') return ['选择时间']
30
+ return ['选择日期']
31
+ }
32
+ },
33
+ data () {
34
+ return {
35
+ visible: false,
36
+ date: [],
37
+ time: []
38
+ }
39
+ },
40
+ watch: {
41
+ modelValue: {
42
+ immediate: true,
43
+ handler (value) {
44
+ const d = new $Date(value)
45
+ this.date = d.to('YYYY-MM-DD').split('-')
46
+ this.time = d.to('HH:mm').split(':')
47
+ }
48
+ }
49
+ },
50
+ created () {
51
+ injectVanFieldProvide(this)
52
+ },
53
+ methods: {
54
+ onConfirm (params) {
55
+ let [date, time] = params
56
+ if (this.type === 'date') {
57
+ time = {}
58
+ } else if (this.type === 'time') {
59
+ time = date
60
+ date = {}
61
+ }
62
+ const [year = '1970', month = '01', day = '01'] = date?.selectedValues || []
63
+ const [hour = '00', minute = '00'] = time?.selectedValues || []
64
+ const value = new $Date(`${year}/${month}/${day} ${hour}:${minute}:00`).to(this.valueFormat || '')
65
+ this.$emit('update:modelValue', value)
66
+ this.$emit('change', value)
67
+ this.provide?.resetValidation()
68
+ this.visible = false
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,44 @@
1
+ <script>
2
+ export { default } from './mobile.js'
3
+ </script>
4
+
5
+ <template>
6
+ <div class="x-date-picker mobile-x-date-picker">
7
+ <input
8
+ v-model="value"
9
+ readonly
10
+ class="van-field__control"
11
+ :placeholder="$attrs.placeholder ?? '请选择日期'"
12
+ @click="visible = true"
13
+ />
14
+ <mobile-x-dialog v-model="visible" title class="x-date-picker__dialog">
15
+ <van-picker-group
16
+ :title="$attrs.title"
17
+ :tabs
18
+ @confirm="onConfirm"
19
+ @cancel="visible = false"
20
+ >
21
+ <van-date-picker
22
+ v-model="date"
23
+ v-bind="$attrs"
24
+ v-if="type === 'datetime' || type === 'date'"
25
+ />
26
+ <van-time-picker
27
+ v-model="time"
28
+ v-bind="$attrs"
29
+ v-if="type === 'datetime' || type === 'time'"
30
+ />
31
+ </van-picker-group>
32
+ </mobile-x-dialog>
33
+ </div>
34
+ </template>
35
+
36
+ <style lang="scss">
37
+ .x-date-picker {
38
+ &__dialog {
39
+ .van-action-sheet__content {
40
+ padding: 0 !important;
41
+ }
42
+ }
43
+ }
44
+ </style>
@@ -0,0 +1,9 @@
1
+ export default {
2
+ name: 'PcXDatePicker',
3
+ emits: ['update:modelValue'],
4
+ methods: {
5
+ onChange (value) {
6
+ this.$emit('update:modelValue', value)
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,12 @@
1
+ <script>
2
+ export { default } from './pc.js'
3
+ </script>
4
+
5
+ <template>
6
+ <el-date-picker
7
+ v-bind="$attrs"
8
+ class="x-date-picker pc-x-date-picker"
9
+ placeholder="请选择日期时间"
10
+ @update:modelValue="onChange"
11
+ />
12
+ </template>
@@ -0,0 +1,60 @@
1
+ export default {
2
+ name: 'MobileXDialog',
3
+ props: {
4
+ actionsheet: {
5
+ type: Boolean,
6
+ default: true
7
+ },
8
+ modelValue: {
9
+ type: Boolean,
10
+ default: false
11
+ },
12
+ title: {
13
+ type: String,
14
+ default: '详情'
15
+ },
16
+ submitText: {
17
+ type: String,
18
+ default: '提交'
19
+ },
20
+ cancelText: {
21
+ type: String,
22
+ default: '取消'
23
+ },
24
+ },
25
+ emits: [
26
+ 'update:modelValue',
27
+ 'submit',
28
+ 'cancel'
29
+ ],
30
+ computed: {
31
+ visible: {
32
+ get () {
33
+ return this.modelValue
34
+ },
35
+ set (value) {
36
+ this.$emit('update:modelValue', value)
37
+ }
38
+ },
39
+ canCancel () {
40
+ return !!this.$attrs.onCancel || !!this.$parent.$attrs.onCancel
41
+ },
42
+ canConfirm () {
43
+ return !!this.$attrs.onSubmit || !!this.$parent.$attrs.onSubmit
44
+ }
45
+ },
46
+ methods: {
47
+ async handleCancel () {
48
+ await this.$nextTick()
49
+ this.visible = true
50
+ await this.$nextTick()
51
+ this.$emit('cancel')
52
+ },
53
+ async handleConfirm () {
54
+ await this.$nextTick()
55
+ this.visible = true
56
+ await this.$nextTick()
57
+ this.$emit('submit')
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,43 @@
1
+ <script>
2
+ export { default } from './mobile.js'
3
+ </script>
4
+
5
+ <template>
6
+ <component
7
+ :is="actionsheet ? 'van-action-sheet' : 'van-dialog'"
8
+ width="92%"
9
+ teleport="body"
10
+ v-bind="$attrs"
11
+ v-model:show="visible"
12
+ class="x-dialog mobile-x-dialog"
13
+ :show-confirm-button="canConfirm"
14
+ :show-cancel-button="canCancel"
15
+ @confirm="handleConfirm"
16
+ @cancel="handleCancel"
17
+ >
18
+ <template v-if="$slots.header || title" #title>
19
+ <slot name="header" v-if="$slots.header" />
20
+ <span v-else>{{ title }}</span>
21
+ </template>
22
+
23
+ <template v-if="$slots.default" #default>
24
+ <slot name="default" />
25
+ </template>
26
+
27
+ <template v-if="$slots.header || title" #description>
28
+ <slot name="header" v-if="$slots.header" />
29
+ <span v-else>{{ title }}</span>
30
+ </template>
31
+
32
+ <template v-if="canConfirm || canCancel" #cancel>
33
+ <van-row>
34
+ <van-col v-if="canCancel" :span="12">
35
+ <van-button block @click.stop="handleCancel">{{ cancelText }}</van-button>
36
+ </van-col>
37
+ <van-col v-if="canConfirm" :span="12">
38
+ <van-button block style="color: var(--van-blue);" @click.stop="handleConfirm">{{ submitText }}</van-button>
39
+ </van-col>
40
+ </van-row>
41
+ </template>
42
+ </component>
43
+ </template>
@@ -0,0 +1,64 @@
1
+ export default {
2
+ name: 'PcXDialog',
3
+ props: {
4
+ platform: String,
5
+ drawer: {
6
+ type: Boolean,
7
+ default: false
8
+ },
9
+ modelValue: {
10
+ type: Boolean,
11
+ default: false
12
+ },
13
+ title: {
14
+ type: String,
15
+ default: '详情'
16
+ },
17
+ submitText: {
18
+ type: String,
19
+ default: '提交'
20
+ },
21
+ cancelText: {
22
+ type: String,
23
+ default: '取消'
24
+ },
25
+ draggable: {
26
+ type: Boolean,
27
+ default: true
28
+ },
29
+ onSubmit: Function,
30
+ onCancel: Function
31
+ },
32
+ emits: [
33
+ 'update:modelValue',
34
+ 'submit',
35
+ 'cancel',
36
+ 'fullscreenchange'
37
+ ],
38
+ data () {
39
+ return {
40
+ fullscreen: this.$attrs.fullscreen || false
41
+ }
42
+ },
43
+ computed: {
44
+ visible: {
45
+ get () {
46
+ return this.modelValue
47
+ },
48
+ set (value) {
49
+ this.$emit('update:modelValue', value)
50
+ }
51
+ },
52
+ hasFooter () {
53
+ return this.onSubmit || this.$parent.$attrs.onSubmit
54
+ || this.onCancel || this.$parent.$attrs.onCancel
55
+ || this.$slots.footer
56
+ }
57
+ },
58
+ methods: {
59
+ handleToggleFullscreen () {
60
+ this.fullscreen = !this.fullscreen
61
+ this.$emit('fullscreenchange', this.fullscreen)
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,51 @@
1
+ <script>
2
+ export { default } from './pc.js'
3
+ </script>
4
+
5
+ <template>
6
+ <component
7
+ :is="drawer ? 'ElDrawer' : 'ElDialog'"
8
+ :draggable
9
+ append-to-body
10
+ v-bind="$attrs"
11
+ v-model="visible"
12
+ :fullscreen
13
+ :size="$attrs.width"
14
+ class="x-dialog pc-x-dialog"
15
+ :class="{ 'pc-x-drawer': drawer, 'no-footer': !hasFooter }"
16
+ >
17
+ <template #header>
18
+ <slot v-if="$slots.header" name="header" />
19
+ <span v-else class="el-dialog__title">{{ title || '\u3000' }}</span>
20
+ <x-icon
21
+ v-if="!drawer"
22
+ name="FullScreen"
23
+ class="full el-dialog__headerbtn"
24
+ style="right: 50px;"
25
+ @click="handleToggleFullscreen"
26
+ />
27
+ </template>
28
+
29
+ <slot v-if="$slots.default" name="default" />
30
+
31
+ <template #footer>
32
+ <slot v-if="$slots.footer" name="footer" />
33
+
34
+ <el-button
35
+ v-if="!!onSubmit || !!$parent.$attrs.onSubmit"
36
+ type="primary"
37
+ :disabled="$attrs['submit-disabled']"
38
+ @click="$emit('submit')"
39
+ >
40
+ {{ submitText }}
41
+ </el-button>
42
+ <el-button
43
+ v-if="!!onCancel || !!$parent.$attrs.onCancel"
44
+ :disabled="$attrs['cancel-disabled']"
45
+ @click="$emit('cancel')"
46
+ >
47
+ {{ cancelText }}
48
+ </el-button>
49
+ </template>
50
+ </component>
51
+ </template>
@@ -0,0 +1,47 @@
1
+ import { injectVanFieldProvide } from '../../utils/funcs.js'
2
+ import { baseForm } from '../../utils/model.js'
3
+ import { initForm } from '../../utils/modelUtils.js'
4
+
5
+ export default {
6
+ name: 'XDict',
7
+ props: {
8
+ modelValue: Object | String | undefined,
9
+ items: Array
10
+ },
11
+ emits: ['update:modelValue'],
12
+ data () {
13
+ return {
14
+ form: baseForm()
15
+ }
16
+ },
17
+ watch: {
18
+ items: {
19
+ immediate: true,
20
+ deep: true,
21
+ handler () {
22
+ this.form = this.makeForm()
23
+ }
24
+ },
25
+ 'form.form': {
26
+ deep: true,
27
+ handler () {
28
+ this.$emit('update:modelValue', this.form.form)
29
+ this.provide?.resetValidation()
30
+ }
31
+ }
32
+ },
33
+ created () {
34
+ if (window.isMobile) {
35
+ injectVanFieldProvide(this)
36
+ }
37
+ },
38
+ methods: {
39
+ makeForm () {
40
+ const form = baseForm()
41
+ const span = Math.floor(24 / this.items.length)
42
+ const fields = this.items.map(it => ({ span: it.span || span, ...it }))
43
+ initForm(form, fields)
44
+ return form
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,9 @@
1
+ <script>
2
+ export { default } from './index.js'
3
+ </script>
4
+
5
+ <template>
6
+ <div class="x-dict" :class="isMobile ? 'mobile-x-dict' : 'pc-x-dict'">
7
+ <x-form :form hide-labels :gutter="10" v-bind="$attrs" />
8
+ </div>
9
+ </template>
@@ -0,0 +1,79 @@
1
+ import { areaList } from '@vant/area-data'
2
+
3
+ const areas = {
4
+ provinces: [],
5
+ cities: [],
6
+ counties: []
7
+ }
8
+
9
+ areas.provinces = Object.entries(areaList.province_list).map(ele => ({ value: ele[0], text: ele[1] }))
10
+ areas.cities = Object.entries(areaList.city_list).map(ele => ({ value: ele[0], text: ele[1] }))
11
+ areas.counties = Object.entries(areaList.county_list).map(ele => ({ value: ele[0], text: ele[1] }))
12
+
13
+ export default {
14
+ name: 'MobileXDistrictSelect',
15
+ props: {
16
+ modelValue: String | Array,
17
+ seperator: {
18
+ type: String,
19
+ default: '/'
20
+ },
21
+ level: {
22
+ type: String,
23
+ default: 'county'
24
+ },
25
+ placeholder: {
26
+ type: String,
27
+ default: '请选择地区'
28
+ }
29
+ },
30
+ emits: ['update:modelValue', 'change'],
31
+ data () {
32
+ return {
33
+ areaList,
34
+ visible: false,
35
+ value: '',
36
+ area: ''
37
+ }
38
+ },
39
+ computed: {
40
+ number () {
41
+ return ({ province: 1, city: 2, county: 3 })[this.level]
42
+ },
43
+ text () {
44
+ return this.modelValue || this.placeholder
45
+ }
46
+ },
47
+ watch: {
48
+ modelValue: {
49
+ handler: 'init',
50
+ immediate: true
51
+ }
52
+ },
53
+ methods: {
54
+ async init () {
55
+ if (this.modelValue === this.value) return
56
+ const parts = Array.isArray(this.modelValue) ? this.modelValue : (this.modelValue || '').split(this.seperator)
57
+ const [province, city, county] = parts
58
+ const pCode = areas.provinces.find(p => p.text === province)?.value
59
+ const pCode2 = pCode?.slice(0, 2)
60
+ const ciCode = areas.cities.find(c => c.value.startsWith(pCode2) && c.text === city)?.value
61
+ const cCode4 = ciCode?.slice(0, 4)
62
+ const coCode = areas.counties.find(c => c.value.startsWith(cCode4) && c.text === county)?.value
63
+ this.area = coCode
64
+ if (Array.isArray(this.modelValue)) {
65
+ this.value = this.modelValue.join(this.seperator)
66
+ this.$emit('update:modelValue', this.value)
67
+ this.$emit('change', this.value)
68
+ }
69
+ },
70
+ onConfirm ({ selectedOptions }) {
71
+ this.visible = false
72
+ const value = selectedOptions.map(ele => ele.text).join(this.seperator)
73
+ this.area = selectedOptions[selectedOptions.length - 1].value
74
+ this.value = value
75
+ this.$emit('update:modelValue', value)
76
+ this.$emit('change', value)
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,28 @@
1
+ <script>
2
+ export { default } from './mobile.js'
3
+ </script>
4
+
5
+ <template>
6
+ <div class="x-district-select mobile-x-district-select">
7
+ <div
8
+ :class="`x-district-select__${modelValue ? 'value' : 'placeholder'}`"
9
+ @click="visible = true"
10
+ >
11
+ {{ text }}
12
+ </div>
13
+ <van-popup
14
+ v-model:show="visible"
15
+ position="bottom"
16
+ :style="{ height: '50%' }"
17
+ >
18
+ <van-area
19
+ v-model="area"
20
+ :area-list="areaList"
21
+ :columns-num="number"
22
+ @click.stop
23
+ @cancel="visible = false"
24
+ @confirm="onConfirm"
25
+ />
26
+ </van-popup>
27
+ </div>
28
+ </template>