@jetlinks-web/components 1.0.5 → 2.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/index.ts +54 -15
- package/package.json +11 -8
- package/src/AMap/Map.vue +110 -107
- package/src/BadgeStatus/Badge.vue +41 -40
- package/src/BadgeStatus/color.ts +25 -23
- package/src/CardSelect/CardSelect.vue +136 -0
- package/src/CardSelect/index.ts +3 -0
- package/src/CheckButton/CheckButton.vue +146 -0
- package/src/CheckButton/index.md +27 -0
- package/src/CheckButton/index.ts +3 -0
- package/src/ConfigProvider/context.ts +17 -0
- package/src/ConfigProvider/index.tsx +42 -0
- package/src/Echarts/Echarts.vue +43 -43
- package/src/Ellipsis/Ellipsis.vue +182 -0
- package/src/Ellipsis/index.ts +3 -0
- package/src/Empty/Empty.vue +43 -0
- package/src/Empty/image.ts +3 -0
- package/src/Empty/index.ts +2 -0
- package/src/FullPage/{index.vue → FullPage.vue} +30 -27
- package/src/FullPage/index.ts +3 -0
- package/src/Icon/icon.tsx +40 -0
- package/src/Icon/index.ts +3 -0
- package/src/MonacoEditor/Monaco.vue +242 -0
- package/src/MonacoEditor/index.md +26 -0
- package/src/MonacoEditor/index.ts +2 -0
- package/src/PermissionButton/index.tsx +95 -92
- package/src/ProLayout/Basic/BasicLayout.less +66 -0
- package/src/ProLayout/Basic/BasicLayout.tsx +392 -0
- package/src/ProLayout/Basic/Header.less +8 -0
- package/src/ProLayout/Basic/Header.tsx +115 -0
- package/src/ProLayout/PageContainer/index.less +103 -0
- package/src/ProLayout/PageContainer/index.tsx +441 -0
- package/src/ProLayout/PageContainer/typings.ts +56 -0
- package/src/ProLayout/RouteContext.ts +87 -0
- package/src/ProLayout/SiderMenu/BaseMenu.tsx +296 -0
- package/src/ProLayout/SiderMenu/SiderMenu.tsx +320 -0
- package/src/ProLayout/SiderMenu/index.less +212 -0
- package/src/ProLayout/SiderMenu/index.ts +2 -0
- package/src/ProLayout/SiderMenu/typings.ts +49 -0
- package/src/ProLayout/TopHeader/index.less +174 -0
- package/src/ProLayout/TopHeader/index.tsx +210 -0
- package/src/ProLayout/defaultSettings.ts +106 -0
- package/src/ProLayout/index.ts +6 -0
- package/src/ProLayout/style/default.less +4 -0
- package/src/ProLayout/style/index.ts +1 -0
- package/src/ProLayout/style/style.less +7 -0
- package/src/ProLayout/typings.ts +87 -0
- package/src/ProLayout/util.ts +64 -0
- package/src/ProTable/index.md +53 -0
- package/src/ProTable/index.tsx +551 -0
- package/src/ProTable/proTableTypes.ts +70 -0
- package/src/ProTable/style/index.less +92 -0
- package/src/ProTable/style/index.ts +1 -0
- package/src/Scrollbar/Bar.vue +75 -0
- package/src/Scrollbar/Scrollbar.vue +260 -0
- package/src/Scrollbar/Thumb.vue +163 -0
- package/src/Scrollbar/constants.ts +10 -0
- package/src/Scrollbar/index.ts +4 -0
- package/src/Scrollbar/scrollbar.ts +108 -0
- package/src/Scrollbar/thumb.ts +16 -0
- package/src/Scrollbar/util.ts +38 -0
- package/src/Search/Advanced/History.vue +140 -0
- package/src/Search/Advanced/SaveHistory.vue +108 -0
- package/src/Search/Advanced/index.vue +435 -0
- package/src/Search/Item.vue +525 -0
- package/src/Search/Search.vue +398 -0
- package/src/Search/hooks/index.ts +1 -0
- package/src/Search/hooks/useSearchItems.ts +68 -0
- package/src/Search/index.md +57 -0
- package/src/Search/index.ts +5 -0
- package/src/Search/setting.ts +55 -0
- package/src/Search/typing.ts +76 -0
- package/src/Search/util.ts +263 -0
- package/src/ValueItem/ValueItem.vue +50 -35
- package/src/ValueItem/util.ts +2 -1
- package/src/style/index.ts +3 -0
- package/src/style/variable.less +4 -0
- package/src/GeoComponent/GeoComponent.vue +0 -139
- package/src/GeoComponent/index.ts +0 -3
- package/src/PermissionButton/hooks.ts +0 -20
package/index.ts
CHANGED
|
@@ -1,25 +1,64 @@
|
|
|
1
1
|
import type { App } from 'vue'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import PermissionButton from './src/PermissionButton/index'
|
|
3
|
+
import { InitAMap } from './src/AMap'
|
|
5
4
|
import BadgeStatus from './src/BadgeStatus'
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import CardSelect from './src/CardSelect'
|
|
6
|
+
import CheckButton from './src/CheckButton'
|
|
7
|
+
import ConfigProvider from './src/ConfigProvider'
|
|
8
8
|
import Echarts from './src/Echarts'
|
|
9
|
+
import Ellipsis from './src/Ellipsis'
|
|
10
|
+
import Empty from './src/Empty'
|
|
11
|
+
import FullPage from './src/FullPage'
|
|
12
|
+
import AIcon from './src/Icon'
|
|
13
|
+
import MonacoEditor from './src/MonacoEditor'
|
|
14
|
+
import PermissionButton from './src/PermissionButton'
|
|
15
|
+
import ProLayout, { PageContainer } from './src/ProLayout'
|
|
16
|
+
import ProTable from './src/ProTable'
|
|
17
|
+
import Scrollbar from './src/Scrollbar'
|
|
18
|
+
import Search, { AdvancedSearch } from './src/Search'
|
|
19
|
+
import ValueItem from './src/ValueItem'
|
|
9
20
|
|
|
10
|
-
|
|
11
|
-
import { InitAMap } from './src/AMap'
|
|
21
|
+
export * from './src/style'
|
|
12
22
|
|
|
23
|
+
export {
|
|
24
|
+
BadgeStatus,
|
|
25
|
+
CardSelect,
|
|
26
|
+
CheckButton,
|
|
27
|
+
Echarts,
|
|
28
|
+
Ellipsis,
|
|
29
|
+
Empty,
|
|
30
|
+
FullPage,
|
|
31
|
+
AIcon,
|
|
32
|
+
MonacoEditor,
|
|
33
|
+
PermissionButton,
|
|
34
|
+
ValueItem,
|
|
35
|
+
ProTable,
|
|
36
|
+
Scrollbar,
|
|
37
|
+
Search,
|
|
38
|
+
AdvancedSearch,
|
|
39
|
+
ConfigProvider,
|
|
40
|
+
}
|
|
13
41
|
export default {
|
|
14
42
|
install(app: App) {
|
|
15
|
-
app
|
|
43
|
+
app
|
|
44
|
+
.component('JAMap', InitAMap)
|
|
45
|
+
.component('JBadgeStatus', BadgeStatus)
|
|
46
|
+
.component('JCardSelect', CardSelect)
|
|
47
|
+
.component('JCheckButton', CheckButton)
|
|
48
|
+
.component('JConfigProvider', ConfigProvider)
|
|
49
|
+
.component('JEcharts', Echarts)
|
|
50
|
+
.component('JEllipsis', Ellipsis)
|
|
51
|
+
.component('JEmpty', Empty)
|
|
52
|
+
.component('JFullPage', FullPage)
|
|
16
53
|
.component('AIcon', AIcon)
|
|
17
|
-
.component('
|
|
18
|
-
.component('
|
|
19
|
-
.component('
|
|
20
|
-
.component('
|
|
21
|
-
.component('
|
|
22
|
-
.component('
|
|
23
|
-
.component('
|
|
24
|
-
|
|
54
|
+
.component('JMonacoEditor', MonacoEditor)
|
|
55
|
+
.component('JPermissionButton', PermissionButton)
|
|
56
|
+
.component('JProLayout', ProLayout)
|
|
57
|
+
.component('JPageContainer', PageContainer)
|
|
58
|
+
.component('JProTable', ProTable)
|
|
59
|
+
.component('JScrollbar', Scrollbar)
|
|
60
|
+
.component('JSearch', Search)
|
|
61
|
+
.component('JAdvancedSearch', AdvancedSearch)
|
|
62
|
+
.component('JValueItem', ValueItem)
|
|
63
|
+
},
|
|
25
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetlinks-web/components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"module": "index.ts",
|
|
@@ -13,15 +13,18 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
16
|
+
"@ant-design/icons-vue": "^7.0.1",
|
|
17
|
+
"@vueuse/core": "^10.2.1",
|
|
18
|
+
"@vueuse/router": "^10.9.0",
|
|
19
|
+
"@vuemap/vue-amap": "^2.0.17",
|
|
20
|
+
"sortablejs": "^1.15.2",
|
|
21
|
+
"echarts": "^5.4.3",
|
|
22
|
+
"monaco-editor": "^0.40.0",
|
|
23
|
+
"@jetlinks-web/constants": "^1.0.2",
|
|
24
|
+
"@jetlinks-web/utils": "^1.0.6",
|
|
25
|
+
"@jetlinks-web/hooks": "^1.0.10"
|
|
19
26
|
},
|
|
20
27
|
"devDependencies": {
|
|
21
|
-
"@vuemap/vue-amap": "^2.0.17",
|
|
22
|
-
"@vueuse/core": "^10.2.1",
|
|
23
|
-
"ant-design-vue": "^3.2.20",
|
|
24
|
-
"jetlinks-ui-components": "^1.0.34-16",
|
|
25
28
|
"lodash-es": "^4.17.21",
|
|
26
29
|
"pinia": "^2.1.6",
|
|
27
30
|
"vue": "^3.3.4",
|
package/src/AMap/Map.vue
CHANGED
|
@@ -1,107 +1,110 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
:style="props.style || { width: '100%', height: '100%' }"
|
|
4
|
-
:class="props.class"
|
|
5
|
-
>
|
|
6
|
-
<el-amap
|
|
7
|
-
v-if="
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@init="initMap"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
import
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:style="props.style || { width: '100%', height: '100%' }"
|
|
4
|
+
:class="props.class"
|
|
5
|
+
>
|
|
6
|
+
<el-amap
|
|
7
|
+
v-if="hasAMapKey"
|
|
8
|
+
:map-style="_mapStyle"
|
|
9
|
+
v-bind="{
|
|
10
|
+
...props,
|
|
11
|
+
...$attrs
|
|
12
|
+
}"
|
|
13
|
+
@init="initMap"
|
|
14
|
+
>
|
|
15
|
+
<template v-if="uiLoading">
|
|
16
|
+
<slot></slot>
|
|
17
|
+
</template>
|
|
18
|
+
<template v-else><slot></slot></template>
|
|
19
|
+
</el-amap>
|
|
20
|
+
<Empty v-else description="请配置高德地图key" style="padding: 20%" />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup name="InitAMap" lang="ts">
|
|
25
|
+
import type { CSSProperties, PropType } from 'vue';
|
|
26
|
+
import { ref, computed } from 'vue'
|
|
27
|
+
import { initAMapApiLoader, ElAmap } from '@vuemap/vue-amap';
|
|
28
|
+
import { getAMapUiPromise } from '@jetlinks-web/utils'
|
|
29
|
+
import { MapProps } from './util'
|
|
30
|
+
import { MAPConfig } from "@jetlinks-web/constants";
|
|
31
|
+
import Empty from '../Empty'
|
|
32
|
+
import '@vuemap/vue-amap/dist/style.css';
|
|
33
|
+
|
|
34
|
+
interface AMapProps {
|
|
35
|
+
style?: CSSProperties;
|
|
36
|
+
class?: string;
|
|
37
|
+
AMapUI?: string | boolean;
|
|
38
|
+
plugins?: string[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits([
|
|
42
|
+
'initMap',
|
|
43
|
+
])
|
|
44
|
+
|
|
45
|
+
const props = defineProps({
|
|
46
|
+
...MapProps(),
|
|
47
|
+
style: Object as PropType<AMapProps['style']>,
|
|
48
|
+
class: String as PropType<AMapProps['class']>,
|
|
49
|
+
AMapUI: [String, Boolean],
|
|
50
|
+
center: Array,
|
|
51
|
+
plugins: Array as PropType<string[]>,
|
|
52
|
+
zooms: {
|
|
53
|
+
type: Array,
|
|
54
|
+
default: [3, 20]
|
|
55
|
+
},
|
|
56
|
+
JSKey: String,
|
|
57
|
+
WebKey: String,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const config = inject<{ mapStyle: any, JSKey: string, WebKey: string }>(MAPConfig)
|
|
61
|
+
|
|
62
|
+
const _mapStyle = computed(() => {
|
|
63
|
+
if (props.mapStyle) {
|
|
64
|
+
return `amap://styles/${props.mapStyle}`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (config.mapStyle) {
|
|
68
|
+
return config.mapStyle
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const hasAMapKey = computed(() => {
|
|
75
|
+
return !!(props.JSKey || config.JSKey)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
initAMapApiLoader({
|
|
79
|
+
key: props.JSKey || config.JSKey || '',
|
|
80
|
+
securityJsCode: props.WebKey || config.WebKey,
|
|
81
|
+
plugins: props.plugins
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const uiLoading = ref<boolean>(false);
|
|
85
|
+
|
|
86
|
+
const map = ref<any>(null);
|
|
87
|
+
|
|
88
|
+
const isOpenUi = computed(() => {
|
|
89
|
+
return 'AMapUI' in props || props.AMapUI;
|
|
90
|
+
});
|
|
91
|
+
const getAMapUI = () => {
|
|
92
|
+
const version = typeof props.AMapUI === 'string' ? props.AMapUI : '1.1';
|
|
93
|
+
getAMapUiPromise(version).then(() => {
|
|
94
|
+
uiLoading.value = true;
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const initMap = (e: any) => {
|
|
99
|
+
map.value = e;
|
|
100
|
+
emit('initMap', e)
|
|
101
|
+
if (isOpenUi.value) {
|
|
102
|
+
getAMapUI();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<style scoped>
|
|
109
|
+
|
|
110
|
+
</style>
|
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<
|
|
3
|
-
:color="_color"
|
|
4
|
-
:text="text"
|
|
5
|
-
></
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script setup lang="ts" name="BadgeStatus">
|
|
9
|
-
import {
|
|
10
|
-
import { getHexColor } from './color'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<a-badge
|
|
3
|
+
:color="_color"
|
|
4
|
+
:text="text"
|
|
5
|
+
></a-badge>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts" name="BadgeStatus">
|
|
9
|
+
import { computed } from 'vue'
|
|
10
|
+
import { getHexColor } from './color'
|
|
11
|
+
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
text: {
|
|
14
|
+
type: String,
|
|
15
|
+
},
|
|
16
|
+
status: {
|
|
17
|
+
type: [String, Number],
|
|
18
|
+
default: 'default',
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* 自定义status值颜色
|
|
22
|
+
* @example {
|
|
23
|
+
* 1: 'success',
|
|
24
|
+
* 0: 'error'
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
statusNames: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: () => ({
|
|
30
|
+
'success': 'success',
|
|
31
|
+
'warning': 'warning',
|
|
32
|
+
'error': 'error',
|
|
33
|
+
'default': 'default',
|
|
34
|
+
})
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const _color = computed(() => {
|
|
39
|
+
return getHexColor(props.status, props.statusNames, 1)
|
|
40
|
+
})
|
|
41
|
+
</script>
|
package/src/BadgeStatus/color.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
'
|
|
4
|
-
'error': '229, 0, 18',
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
const colorMap = {
|
|
2
|
+
'success': '36, 178, 118',
|
|
3
|
+
'warning': '255, 144, 0',
|
|
4
|
+
'error': '229, 0, 18',
|
|
5
|
+
'processing': '9, 46, 231',
|
|
6
|
+
'default': '102, 102, 102',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const getHexColor = (code: string | number, statusNames: Record<string | number, any>, pe: number = 0.1) => {
|
|
10
|
+
if (!code) {
|
|
11
|
+
return `rgba(102, 102, 102, ${pe})`
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (colorMap[code]) {
|
|
15
|
+
return `rgba(${colorMap[code]}, ${pe})`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (Object.keys(statusNames).length) {
|
|
19
|
+
return statusNames[code]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default colorMap
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="j-card-select" :style="CardSelectStyle">
|
|
3
|
+
<div
|
|
4
|
+
v-for="item in options"
|
|
5
|
+
:class="{
|
|
6
|
+
'j-card-select-item': true,
|
|
7
|
+
'disabled': disabled || item.disabled,
|
|
8
|
+
'active': selectKeys.includes(item.value)
|
|
9
|
+
}"
|
|
10
|
+
@click="() => handleSelect(item.value, item)"
|
|
11
|
+
>
|
|
12
|
+
<slot name="itemRender" :node="item" >
|
|
13
|
+
<div class="j-card-select-item-content">
|
|
14
|
+
<div class="j-card-select-title">
|
|
15
|
+
{{ item.label }}
|
|
16
|
+
</div>
|
|
17
|
+
<div class="j-card-select-describe">
|
|
18
|
+
{{ item.describe }}
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</slot>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup name="CardSelect">
|
|
27
|
+
import { has } from 'lodash-es'
|
|
28
|
+
const props = defineProps({
|
|
29
|
+
layout: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: 'horizontal'
|
|
32
|
+
},
|
|
33
|
+
options: {
|
|
34
|
+
type: Array,
|
|
35
|
+
default: () => [],
|
|
36
|
+
},
|
|
37
|
+
disabled: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
multiple: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
column: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 3,
|
|
48
|
+
},
|
|
49
|
+
value: {
|
|
50
|
+
type: [String, Array],
|
|
51
|
+
default: undefined,
|
|
52
|
+
},
|
|
53
|
+
itemLayout: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: 'horizontal'
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const emit = defineEmits(['select', 'change', 'update:value'])
|
|
60
|
+
|
|
61
|
+
const selectKeys = ref([])
|
|
62
|
+
|
|
63
|
+
const CardSelectStyle = computed(() => {
|
|
64
|
+
const _column = props.column > 0 && props.layout === 'horizontal' ? props.column : 1
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
'grid-template-columns': `repeat(${_column}, 1fr)`
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const isMultiple = computed(() => {
|
|
72
|
+
return has(props, 'multiple') && props.multiple !== false
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const handleSelect = (key, node) => {
|
|
76
|
+
if (props.disabled || node.disabled) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const selectKeysSet = new Set(selectKeys.value)
|
|
81
|
+
const isActive = selectKeysSet.has(key)
|
|
82
|
+
|
|
83
|
+
if (isMultiple.value) {
|
|
84
|
+
if (isActive) {
|
|
85
|
+
selectKeysSet.delete(key)
|
|
86
|
+
} else {
|
|
87
|
+
selectKeysSet.add(key)
|
|
88
|
+
}
|
|
89
|
+
selectKeys.value = [...selectKeysSet.values()]
|
|
90
|
+
const nodes = props.options.filter(item => selectKeys.value.includes(item.value))
|
|
91
|
+
emit('select', selectKeys.value, nodes)
|
|
92
|
+
emit('change', selectKeys.value, nodes)
|
|
93
|
+
emit('update:value', selectKeys.value)
|
|
94
|
+
} else {
|
|
95
|
+
selectKeys.value = [key]
|
|
96
|
+
|
|
97
|
+
emit('select', key, node)
|
|
98
|
+
emit('change', key, node)
|
|
99
|
+
emit('update:value', key)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
watch(() => props.value, () => {
|
|
104
|
+
selectKeys.value = isMultiple.value ? props.value : [props.value]
|
|
105
|
+
}, { immediate: true })
|
|
106
|
+
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<style lang="less">
|
|
110
|
+
@import '../style/variable.less';
|
|
111
|
+
|
|
112
|
+
.j-card-select {
|
|
113
|
+
display: grid;
|
|
114
|
+
gap: 12px;
|
|
115
|
+
|
|
116
|
+
.j-card-select-item {
|
|
117
|
+
padding: 12px;
|
|
118
|
+
border: 1px solid #e6e6e6;
|
|
119
|
+
border-radius: @border-radius-base;
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
|
|
122
|
+
&.active {
|
|
123
|
+
border-color: @primary-color;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&.disabled {
|
|
127
|
+
cursor: not-allowed;
|
|
128
|
+
opacity: 0.75;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.j-card-select-describe {
|
|
132
|
+
color: @text-color-subtitle;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
</style>
|