@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.
- package/.env +6 -0
- package/@vant-D4fmGxs6.js +3891 -0
- package/index.js +8419 -0
- package/package.json +59 -0
- package/packages/assets/devtools-detector.js +2 -0
- package/packages/components/xarray/index.js +64 -0
- package/packages/components/xarray/xarray.vue +57 -0
- package/packages/components/xautorows/index.js +35 -0
- package/packages/components/xautorows/xautorows.vue +29 -0
- package/packages/components/xbutton/mobile.js +3 -0
- package/packages/components/xbutton/mobile.vue +9 -0
- package/packages/components/xbutton/pc.js +3 -0
- package/packages/components/xbutton/pc.vue +9 -0
- package/packages/components/xbuttons/mobile.js +51 -0
- package/packages/components/xbuttons/mobile.vue +12 -0
- package/packages/components/xbuttons/pc.js +51 -0
- package/packages/components/xbuttons/pc.vue +16 -0
- package/packages/components/xchart/constants.js +58 -0
- package/packages/components/xchart/index.js +263 -0
- package/packages/components/xchart/utils.js +121 -0
- package/packages/components/xchart/xchart.vue +173 -0
- package/packages/components/xcheckboxs/mobile.js +58 -0
- package/packages/components/xcheckboxs/mobile.vue +38 -0
- package/packages/components/xcheckboxs/pc.js +49 -0
- package/packages/components/xcheckboxs/pc.vue +42 -0
- package/packages/components/xcol/mobile.js +10 -0
- package/packages/components/xcol/mobile.vue +9 -0
- package/packages/components/xcol/pc.js +10 -0
- package/packages/components/xcol/pc.vue +9 -0
- package/packages/components/xdatepicker/mobile.js +71 -0
- package/packages/components/xdatepicker/mobile.vue +44 -0
- package/packages/components/xdatepicker/pc.js +9 -0
- package/packages/components/xdatepicker/pc.vue +12 -0
- package/packages/components/xdialog/mobile.js +60 -0
- package/packages/components/xdialog/mobile.vue +43 -0
- package/packages/components/xdialog/pc.js +64 -0
- package/packages/components/xdialog/pc.vue +51 -0
- package/packages/components/xdict/index.js +47 -0
- package/packages/components/xdict/xdict.vue +9 -0
- package/packages/components/xdistrictselect/mobile.js +79 -0
- package/packages/components/xdistrictselect/mobile.vue +28 -0
- package/packages/components/xdistrictselect/pc.js +127 -0
- package/packages/components/xdistrictselect/pc.vue +32 -0
- package/packages/components/xform/mobile.js +29 -0
- package/packages/components/xform/mobile.vue +43 -0
- package/packages/components/xform/pc.js +42 -0
- package/packages/components/xform/pc.vue +76 -0
- package/packages/components/xform/utils.js +95 -0
- package/packages/components/xformitem/mobile.js +56 -0
- package/packages/components/xformitem/mobile.vue +3 -0
- package/packages/components/xformitem/pc.js +72 -0
- package/packages/components/xformitem/pc.vue +10 -0
- package/packages/components/xformitem/utils.jsx +181 -0
- package/packages/components/xicon/mobile.js +35 -0
- package/packages/components/xicon/mobile.vue +9 -0
- package/packages/components/xicon/pc.js +35 -0
- package/packages/components/xicon/pc.vue +11 -0
- package/packages/components/xinfo/index.js +100 -0
- package/packages/components/xinfo/xinfo.vue +140 -0
- package/packages/components/xlooper/index.js +7 -0
- package/packages/components/xlooper/xlooper.vue +20 -0
- package/packages/components/xpagination/mobile.js +21 -0
- package/packages/components/xpagination/mobile.vue +31 -0
- package/packages/components/xpagination/pc.js +21 -0
- package/packages/components/xpagination/pc.vue +16 -0
- package/packages/components/xpicker/index.js +38 -0
- package/packages/components/xpicker/xpicker.vue +29 -0
- package/packages/components/xradios/mobile.js +40 -0
- package/packages/components/xradios/mobile.vue +22 -0
- package/packages/components/xradios/pc.js +53 -0
- package/packages/components/xradios/pc.vue +43 -0
- package/packages/components/xrow/mobile.js +9 -0
- package/packages/components/xrow/mobile.vue +23 -0
- package/packages/components/xrow/pc.js +9 -0
- package/packages/components/xrow/pc.vue +22 -0
- package/packages/components/xscan/mobile.js +24 -0
- package/packages/components/xscan/mobile.vue +21 -0
- package/packages/components/xscan/pc.js +20 -0
- package/packages/components/xscan/pc.vue +18 -0
- package/packages/components/xsearcher/index.js +198 -0
- package/packages/components/xsearcher/xsearcher.vue +170 -0
- package/packages/components/xselect/mobile.js +86 -0
- package/packages/components/xselect/mobile.vue +24 -0
- package/packages/components/xselect/pc.js +114 -0
- package/packages/components/xselect/pc.vue +55 -0
- package/packages/components/xselect/util.js +66 -0
- package/packages/components/xselectv2/index.js +91 -0
- package/packages/components/xselectv2/xselectv2.vue +46 -0
- package/packages/components/xtable/mobile.js +108 -0
- package/packages/components/xtable/mobile.vue +246 -0
- package/packages/components/xtable/pc.js +143 -0
- package/packages/components/xtable/pc.vue +421 -0
- package/packages/components/xtable/searcher.js +477 -0
- package/packages/components/xtable/searcher.jsx +330 -0
- package/packages/components/xtable/searcher.vue +133 -0
- package/packages/components/xtable/settings.js +80 -0
- package/packages/components/xtable/settings.vue +77 -0
- package/packages/components/xtable/utils.js +692 -0
- package/packages/components/xtabletools/mobile.js +25 -0
- package/packages/components/xtabletools/mobile.vue +126 -0
- package/packages/components/xtabletools/pc.js +18 -0
- package/packages/components/xtabletools/pc.vue +135 -0
- package/packages/components/xtablev2/index.js +53 -0
- package/packages/components/xtablev2/utils.jsx +214 -0
- package/packages/components/xtablev2/xtablev2.vue +147 -0
- package/packages/components/xtags/mobile.js +17 -0
- package/packages/components/xtags/mobile.vue +21 -0
- package/packages/components/xtags/pc.js +17 -0
- package/packages/components/xtags/pc.vue +22 -0
- package/packages/components/xtinymce/index.js +71 -0
- package/packages/components/xtinymce/xtinymce.vue +9 -0
- package/packages/components/xuploader/xfileuploader.js +48 -0
- package/packages/components/xuploader/xfileuploader.vue +54 -0
- package/packages/components/xuploader/ximageuploader.js +53 -0
- package/packages/components/xuploader/ximageuploader.vue +52 -0
- package/packages/comps.js +108 -0
- package/packages/controllers/BaseController.js +125 -0
- package/packages/controllers/CrudController.js +907 -0
- package/packages/controllers/TempCrudController.js +32 -0
- package/packages/controllers/index.js +15 -0
- package/packages/directives/el-table-infinite-scroll.js +55 -0
- package/packages/directives/index.js +5 -0
- package/packages/index.js +81 -0
- package/packages/index.scss +4 -0
- package/packages/layout/breadcrumb/breadcrumb.vue +31 -0
- package/packages/layout/breadcrumb/index.js +41 -0
- package/packages/layout/header/header.vue +281 -0
- package/packages/layout/header/inner.js +11 -0
- package/packages/layout/header/inner.vue +3 -0
- package/packages/layout/mobile-menu.vue +83 -0
- package/packages/layout/mobile-tabs.vue +54 -0
- package/packages/layout/pc.vue +85 -0
- package/packages/layout/screenlock/index.js +129 -0
- package/packages/layout/screenlock/screenlock.vue +85 -0
- package/packages/layout/sidebar/item.js +16 -0
- package/packages/layout/sidebar/item.vue +16 -0
- package/packages/layout/sidebar/menu.js +72 -0
- package/packages/layout/sidebar/menu.vue +106 -0
- package/packages/layout/sidebar/sidebar.vue +147 -0
- package/packages/layout/tagsview/ScrollPane.js +65 -0
- package/packages/layout/tagsview/ScrollPane.vue +24 -0
- package/packages/layout/tagsview/index.js +169 -0
- package/packages/layout/tagsview/index.vue +124 -0
- package/packages/plop/actions/make-fill-admin-partials-action.js +95 -0
- package/packages/plop/generators/make-admin-page.js +39 -0
- package/packages/plop/generators/make-database-admin-pages.js +84 -0
- package/packages/plop/generators/make-page-generator.js +52 -0
- package/packages/plop/generators/make-simple-page.js +20 -0
- package/packages/plop/plopfile.js +24 -0
- package/packages/plop/templates/admin_page/controller.js +3 -0
- package/packages/plop/templates/admin_page/model.js +24 -0
- package/packages/plop/templates/admin_page/{{snakeCase pagename}}-scoped.scss +3 -0
- package/packages/plop/templates/admin_page/{{snakeCase pagename}}.vue +11 -0
- package/packages/plop/templates/simple_page/controller.js +3 -0
- package/packages/plop/templates/simple_page/model.js +6 -0
- package/packages/plop/templates/simple_page/{{snakeCase pagename}}-scoped.scss +3 -0
- package/packages/plop/templates/simple_page/{{snakeCase pagename}}.vue +7 -0
- package/packages/plop/utils/index.js +168 -0
- package/packages/plop/utils/plop-utils.js +86 -0
- package/packages/styles/common.scss +137 -0
- package/packages/styles/element-ui.scss +142 -0
- package/packages/styles/vant.scss +133 -0
- package/packages/styles/variables.scss +23 -0
- package/packages/utils/crypt.js +24 -0
- package/packages/utils/decorators.js +67 -0
- package/packages/utils/disallowDevtools.js +53 -0
- package/packages/utils/effects.js +173 -0
- package/packages/utils/funcs.js +78 -0
- package/packages/utils/index.js +95 -0
- package/packages/utils/message.js +110 -0
- package/packages/utils/middlewares.js +86 -0
- package/packages/utils/model.js +71 -0
- package/packages/utils/modelUtils.js +203 -0
- package/packages/utils/request.js +57 -0
- package/packages/utils/site.js +33 -0
- package/packages/vite-plugins.js +141 -0
- package/publish.sh +12 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './index.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div
|
|
7
|
+
@click="$emit('show')"
|
|
8
|
+
:class="`x-picker__${modelValue ? 'value' : 'placeholder'}`"
|
|
9
|
+
>
|
|
10
|
+
{{ text }}
|
|
11
|
+
</div>
|
|
12
|
+
<van-popup
|
|
13
|
+
class="x-picker"
|
|
14
|
+
:class="isMobile ? 'mobile-x-picker' : 'pc-x-picker'"
|
|
15
|
+
round
|
|
16
|
+
position="bottom"
|
|
17
|
+
teleport="body"
|
|
18
|
+
v-bind="$attrs"
|
|
19
|
+
v-model:show="visible"
|
|
20
|
+
>
|
|
21
|
+
<van-picker
|
|
22
|
+
:modelValue="value"
|
|
23
|
+
:title="$attrs.title"
|
|
24
|
+
:columns
|
|
25
|
+
@cancel="$emit('cancel')"
|
|
26
|
+
@confirm="onConfirm"
|
|
27
|
+
/>
|
|
28
|
+
</van-popup>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { formatOptions } from '../../utils/index.js'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
name: 'MobileXRadios',
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
text: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: 'text'
|
|
10
|
+
},
|
|
11
|
+
plain: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
15
|
+
value: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'value'
|
|
18
|
+
},
|
|
19
|
+
direction: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: 'horizontal'
|
|
22
|
+
},
|
|
23
|
+
sort: Boolean | String,
|
|
24
|
+
options: Array | Object
|
|
25
|
+
},
|
|
26
|
+
data () {
|
|
27
|
+
return {
|
|
28
|
+
_options: []
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
watch: {
|
|
32
|
+
options: {
|
|
33
|
+
immediate: true,
|
|
34
|
+
deep: true,
|
|
35
|
+
handler () {
|
|
36
|
+
this._options = formatOptions(this.options, this)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './mobile.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<van-radio-group
|
|
7
|
+
class="x-radios mobile-x-radios"
|
|
8
|
+
:class="plain ? 'mobile-x-radios--plain' : ''"
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
:direction
|
|
11
|
+
>
|
|
12
|
+
<van-radio
|
|
13
|
+
v-for="option in _options"
|
|
14
|
+
v-bind="$attrs"
|
|
15
|
+
:disabled="option.raw?.disabled"
|
|
16
|
+
:key="option.text"
|
|
17
|
+
:name="option.value"
|
|
18
|
+
>
|
|
19
|
+
{{ option.text }}
|
|
20
|
+
</van-radio>
|
|
21
|
+
</van-radio-group>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { formatOptions } from '../../utils/index.js'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
name: 'PcXRadios',
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: Number | String,
|
|
8
|
+
plain: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: false
|
|
11
|
+
},
|
|
12
|
+
text: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'text'
|
|
15
|
+
},
|
|
16
|
+
value: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'value'
|
|
19
|
+
},
|
|
20
|
+
button: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false
|
|
23
|
+
},
|
|
24
|
+
sort: Boolean | String,
|
|
25
|
+
options: Array | Object,
|
|
26
|
+
},
|
|
27
|
+
emits: ['update:modelValue', 'change'],
|
|
28
|
+
data () {
|
|
29
|
+
return {
|
|
30
|
+
_options: []
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
computed: {
|
|
34
|
+
attrs () {
|
|
35
|
+
const {
|
|
36
|
+
clearable,
|
|
37
|
+
platform,
|
|
38
|
+
placeholder,
|
|
39
|
+
...others
|
|
40
|
+
} = this.$attrs
|
|
41
|
+
return others
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
watch: {
|
|
45
|
+
options: {
|
|
46
|
+
immediate: true,
|
|
47
|
+
deep: true,
|
|
48
|
+
handler () {
|
|
49
|
+
this._options = formatOptions(this.options, this)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './pc.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<el-radio-group
|
|
7
|
+
class="x-radios pc-x-radios"
|
|
8
|
+
:class="plain ? 'pc-x-radios--plain' : ''"
|
|
9
|
+
v-bind="attrs"
|
|
10
|
+
:modelValue
|
|
11
|
+
@update:modelValue="value => $emit('update:modelValue', value)"
|
|
12
|
+
@change="$emit('change', $event)"
|
|
13
|
+
>
|
|
14
|
+
<component
|
|
15
|
+
:is="button ? 'el-radio-button' : 'el-radio'"
|
|
16
|
+
v-for="option in _options"
|
|
17
|
+
v-bind="attrs"
|
|
18
|
+
:disabled="option.raw?.disabled"
|
|
19
|
+
:key="option.text"
|
|
20
|
+
:value="option.value"
|
|
21
|
+
>
|
|
22
|
+
<slot
|
|
23
|
+
v-if="$slots.custom"
|
|
24
|
+
name="custom"
|
|
25
|
+
:option
|
|
26
|
+
:raw="option.raw"
|
|
27
|
+
/>
|
|
28
|
+
<span v-else>{{ option.text }}</span>
|
|
29
|
+
</component>
|
|
30
|
+
</el-radio-group>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<style lang="scss" scoped>
|
|
34
|
+
.pc-x-radios--plain {
|
|
35
|
+
:deep(.el-radio) {
|
|
36
|
+
margin-right: 20px;
|
|
37
|
+
font-weight: normal;
|
|
38
|
+
.el-radio__input {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './mobile.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<van-row class="x-row mobile-x-row">
|
|
7
|
+
<mobile-x-col
|
|
8
|
+
v-for="(col, index) in cols"
|
|
9
|
+
v-bind="col"
|
|
10
|
+
:span="col.xs ?? col.span"
|
|
11
|
+
:key="index"
|
|
12
|
+
>
|
|
13
|
+
<slot
|
|
14
|
+
v-if="col.slot || $attrs.slot"
|
|
15
|
+
:name="col.slot || $attrs.slot"
|
|
16
|
+
:col
|
|
17
|
+
/>
|
|
18
|
+
<span v-else>{{ col.text }}</span>
|
|
19
|
+
</mobile-x-col>
|
|
20
|
+
|
|
21
|
+
<slot v-if="cols.length === 0" />
|
|
22
|
+
</van-row>
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './pc.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<el-row class="x-row pc-x-row">
|
|
7
|
+
<pc-x-col
|
|
8
|
+
v-for="(col, index) in cols"
|
|
9
|
+
v-bind="col"
|
|
10
|
+
:key="index"
|
|
11
|
+
>
|
|
12
|
+
<slot
|
|
13
|
+
v-if="col.slot || $attrs.slot"
|
|
14
|
+
:name="col.slot || $attrs.slot"
|
|
15
|
+
:col
|
|
16
|
+
/>
|
|
17
|
+
<span v-else>{{ col.text }}</span>
|
|
18
|
+
</pc-x-col>
|
|
19
|
+
|
|
20
|
+
<slot v-if="cols.length === 0" />
|
|
21
|
+
</el-row>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
name: 'MobileXScan',
|
|
3
|
+
props: {
|
|
4
|
+
modelValue: String,
|
|
5
|
+
_label: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: '扫码'
|
|
8
|
+
},
|
|
9
|
+
readonly: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
emits: ['update:modelValue'],
|
|
15
|
+
methods: {
|
|
16
|
+
handleClick () {
|
|
17
|
+
this.readonly && this.handleScan()
|
|
18
|
+
},
|
|
19
|
+
async handleScan () {
|
|
20
|
+
const code = await StardustBrowser.funcs.scanCode()
|
|
21
|
+
this.$emit('update:modelValue', code)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './mobile.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<van-field
|
|
7
|
+
placeholder="点此扫码"
|
|
8
|
+
class="x-scan mobile-x-scan"
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
:label="_label"
|
|
11
|
+
:modelValue
|
|
12
|
+
:readonly
|
|
13
|
+
style="padding: 0;"
|
|
14
|
+
@update:modelValue="v => $emit('update:modelValue', v)"
|
|
15
|
+
@click.native="handleClick"
|
|
16
|
+
>
|
|
17
|
+
<template #right-icon>
|
|
18
|
+
<van-icon name="scan" @click.native="handleScan" />
|
|
19
|
+
</template>
|
|
20
|
+
</van-field>
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
name: 'PcXScan',
|
|
3
|
+
props: {
|
|
4
|
+
modelValue: String,
|
|
5
|
+
readonly: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
emits: ['update:modelValue'],
|
|
11
|
+
methods: {
|
|
12
|
+
handleClick () {
|
|
13
|
+
this.readonly && this.handleScan()
|
|
14
|
+
},
|
|
15
|
+
async handleScan () {
|
|
16
|
+
const code = await StardustBrowser.funcs.scanCode()
|
|
17
|
+
this.$emit('update:modelValue', code)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { default } from './pc.js'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<el-input
|
|
7
|
+
class="x-scan pc-x-scan"
|
|
8
|
+
v-bind="$attrs"
|
|
9
|
+
:modelValue
|
|
10
|
+
:readonly
|
|
11
|
+
@update:modelValue="v => $emit('update:modelValue', v)"
|
|
12
|
+
@click.native="handleClick"
|
|
13
|
+
>
|
|
14
|
+
<template #append>
|
|
15
|
+
<el-button icon="CameraFilled" @click="handleScan" />
|
|
16
|
+
</template>
|
|
17
|
+
</el-input>
|
|
18
|
+
</template>
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { injectVanFieldProvide } from '../../utils/funcs.js'
|
|
2
|
+
|
|
3
|
+
const { highdict } = StardustJs
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
name: 'XSearcher',
|
|
7
|
+
props: {
|
|
8
|
+
modelName: String,
|
|
9
|
+
params: Object,
|
|
10
|
+
titles: String | Array,
|
|
11
|
+
subTitles: String | Array,
|
|
12
|
+
header: Array,
|
|
13
|
+
operatesWidth: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default: 80
|
|
16
|
+
},
|
|
17
|
+
modelValue: Boolean | Number | String | Array,
|
|
18
|
+
multiple: Boolean,
|
|
19
|
+
clearable: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: true
|
|
22
|
+
},
|
|
23
|
+
value: String,
|
|
24
|
+
title: String,
|
|
25
|
+
width: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: '660px'
|
|
28
|
+
},
|
|
29
|
+
fullscreen: Boolean,
|
|
30
|
+
hideSearcher: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
readonly: Boolean,
|
|
35
|
+
disabled: Boolean,
|
|
36
|
+
placeholder: String,
|
|
37
|
+
searcherPlaceholder: String,
|
|
38
|
+
emptyText: String,
|
|
39
|
+
formatTitle: Function,
|
|
40
|
+
formatSubTitle: Function
|
|
41
|
+
},
|
|
42
|
+
emits: ['update:modelValue', 'change', 'select'],
|
|
43
|
+
computed: {
|
|
44
|
+
_placeholder () {
|
|
45
|
+
return this.placeholder?.replace('输入', '选择') || '请选择'
|
|
46
|
+
},
|
|
47
|
+
_titles () {
|
|
48
|
+
return [this.titles].flat().filter(k => k)
|
|
49
|
+
},
|
|
50
|
+
_subTitles () {
|
|
51
|
+
return [this.subTitles].flat().filter(k => k)
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
data () {
|
|
55
|
+
return {
|
|
56
|
+
visible: false,
|
|
57
|
+
loading: false,
|
|
58
|
+
keywords: '',
|
|
59
|
+
list: []
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
watch: {
|
|
63
|
+
modelValue: {
|
|
64
|
+
immediate: true,
|
|
65
|
+
handler (value) {
|
|
66
|
+
value && this.provide?.resetValidation()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
created () {
|
|
71
|
+
if (window.isMobile) {
|
|
72
|
+
injectVanFieldProvide(this)
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
methods: {
|
|
76
|
+
handleFocus (e) {
|
|
77
|
+
e.target.blur()
|
|
78
|
+
},
|
|
79
|
+
handleClear () {
|
|
80
|
+
if (this.readonly) return
|
|
81
|
+
const value = this.multiple ? [] : null
|
|
82
|
+
this.$emit('update:modelValue', value)
|
|
83
|
+
this.$emit('change', value)
|
|
84
|
+
this.$emit('select', value, value)
|
|
85
|
+
},
|
|
86
|
+
handleShow () {
|
|
87
|
+
if (this.readonly) return
|
|
88
|
+
this.visible = true
|
|
89
|
+
this.handleSearch()
|
|
90
|
+
},
|
|
91
|
+
async handleSearch () {
|
|
92
|
+
if (this.loading) return
|
|
93
|
+
this.loading = true
|
|
94
|
+
this.list = await (this.$attrs.search || this.search)(this.modelValue, this.keywords, this.list)
|
|
95
|
+
this.loading = false
|
|
96
|
+
},
|
|
97
|
+
handleSelect (item, index) {
|
|
98
|
+
if (this.multiple) {
|
|
99
|
+
const values = Array.isArray(this.modelValue) ? this.modelValue : (this.modelValue ? [this.modelValue] : [])
|
|
100
|
+
const value = item[this.value]
|
|
101
|
+
const index = values.indexOf(value)
|
|
102
|
+
if (index >= 0) {
|
|
103
|
+
values.splice(index, 1)
|
|
104
|
+
} else {
|
|
105
|
+
values.push(value)
|
|
106
|
+
}
|
|
107
|
+
this.$emit('update:modelValue', values)
|
|
108
|
+
this.$emit('change', values)
|
|
109
|
+
this.$emit('select', values, values.map(v => this.list.find(e => e[this.value] === v)))
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
if (this.modelValue === item[this.value]) {
|
|
113
|
+
this.handleClear()
|
|
114
|
+
} else {
|
|
115
|
+
this.$emit('update:modelValue', item[this.value])
|
|
116
|
+
this.$emit('change', item[this.value])
|
|
117
|
+
this.$emit('select', item[this.value], item)
|
|
118
|
+
}
|
|
119
|
+
this.visible = false
|
|
120
|
+
},
|
|
121
|
+
async search (modelValue, keywords) {
|
|
122
|
+
const attributes = this._titles.concat(this._subTitles)
|
|
123
|
+
const params = { ...this.params }
|
|
124
|
+
params.page ||= 1
|
|
125
|
+
params.limit ||= 20
|
|
126
|
+
params.attributes ||= attributes.includes(this.value) ? attributes : [...attributes, this.value]
|
|
127
|
+
params.where ||= {}
|
|
128
|
+
const ors = []
|
|
129
|
+
if (this.multiple && !Array.isArray(modelValue)) {
|
|
130
|
+
modelValue = modelValue ? [modelValue] : []
|
|
131
|
+
}
|
|
132
|
+
if (
|
|
133
|
+
modelValue != undefined && modelValue !== ''
|
|
134
|
+
&& !(this.multiple && !modelValue.length)
|
|
135
|
+
) {
|
|
136
|
+
if (this.multiple) {
|
|
137
|
+
ors.push({ [this.value]: { '[Op.in]': modelValue } })
|
|
138
|
+
} else {
|
|
139
|
+
ors.push({ [this.value]: modelValue })
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
keywords = keywords.split(' ').filter(k => k)
|
|
143
|
+
if (keywords.length) {
|
|
144
|
+
attributes.forEach(t => {
|
|
145
|
+
keywords.forEach(k => {
|
|
146
|
+
ors.push({ [t]: { '[Op.like]': `%${k}%` } })
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
delete params.where['[Op.or]']
|
|
151
|
+
if (ors.length) params.where['[Op.or]'] = ors
|
|
152
|
+
const list = await this.service.restful.search(this.modelName, params, 'data')
|
|
153
|
+
if (this.multiple) {
|
|
154
|
+
list.sort((a, b) => modelValue.indexOf(b[this.value]) - modelValue.indexOf(a[this.value]))
|
|
155
|
+
const values = list.map(ele => ele[this.value])
|
|
156
|
+
const leftValues = modelValue.filter(v => !values.includes(v))
|
|
157
|
+
if (leftValues.length) {
|
|
158
|
+
params.where = { [this.value]: { '[Op.in]': leftValues } }
|
|
159
|
+
const items = await this.service.restful.search(this.modelName, params, 'data')
|
|
160
|
+
list.push(...items)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return list
|
|
164
|
+
},
|
|
165
|
+
calcTitles (item) {
|
|
166
|
+
if (this.formatTitle) return this.formatTitle(item)
|
|
167
|
+
return this._titles.map(key => highdict.get(item, key)).join(' | ')
|
|
168
|
+
},
|
|
169
|
+
calcSubTitles (item) {
|
|
170
|
+
if (this.formatSubTitle) return this.formatSubTitle(item)
|
|
171
|
+
return this._subTitles.map(key => highdict.get(item, key)).join(' | ')
|
|
172
|
+
},
|
|
173
|
+
calcColumns () {
|
|
174
|
+
const props = this.params?.attributes || [...this.titles, ...this.subTitles]
|
|
175
|
+
const columns = this.header.map((label, index) => {
|
|
176
|
+
const column = { prop: props[index], sortable: false }
|
|
177
|
+
if (typeof label === 'object') {
|
|
178
|
+
const { label: _label, ...others } = label
|
|
179
|
+
Object.assign(column, { label: _label, tableAttrs: others })
|
|
180
|
+
} else {
|
|
181
|
+
column.label = label
|
|
182
|
+
}
|
|
183
|
+
if (this.$slots.cell) {
|
|
184
|
+
column.tableAttrs ??= {}
|
|
185
|
+
column.tableAttrs.slot = 'cell'
|
|
186
|
+
}
|
|
187
|
+
return column
|
|
188
|
+
})
|
|
189
|
+
if (this.$slots.right) {
|
|
190
|
+
columns.push({
|
|
191
|
+
label: '操作', prop: 'operates', fixed: 'right', sortable: false,
|
|
192
|
+
tableAttrs: { slot: 'operates', width: this.operatesWidth * 1 }
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
return columns
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|