af-mobile-client-vue3 1.1.6 → 1.1.7
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 -6
- package/.env.development +4 -4
- package/.env.envoiceShow +6 -6
- package/.env.production +6 -6
- package/.husky/commit-msg +1 -1
- package/.husky/pre-commit +1 -1
- package/.vscode/settings.json +61 -61
- package/mock/modules/user.mock.ts +152 -152
- package/package.json +1 -1
- package/public/favicon.svg +4 -4
- package/public/safari-pinned-tab.svg +32 -32
- package/scripts/verifyCommit.js +19 -19
- package/src/App.vue +43 -43
- package/src/api/user/index.ts +40 -40
- package/src/bootstrap.ts +18 -18
- package/src/components/core/NavBar/index.vue +12 -12
- package/src/components/core/Tabbar/index.vue +38 -38
- package/src/components/core/XGridDropOption/index.vue +151 -151
- package/src/components/core/XMultiSelect/index.vue +183 -183
- package/src/components/data/XCellDetail/index.vue +106 -106
- package/src/components/data/XForm/index.vue +5 -0
- package/src/components/data/XFormItem/index.vue +3 -4
- package/src/components/data/XOlMap/README.md +0 -2
- package/src/components/data/XOlMap/XLocationPicker/index.vue +21 -9
- package/src/components/data/XOlMap/index.vue +81 -74
- package/src/components/data/XOlMap/types.ts +0 -4
- package/src/components/data/XOlMap/utils/wgs84ToGcj02.js +154 -154
- package/src/components/data/XReportForm/XReportFormJsonRender.vue +220 -220
- package/src/components/data/XReportForm/index.vue +1079 -1079
- package/src/components/data/XReportGrid/XAddReport/index.ts +1 -1
- package/src/components/data/XReportGrid/XReportDrawer/index.ts +1 -1
- package/src/components/data/XSignature/index.vue +285 -285
- package/src/components/data/XTag/index.vue +10 -10
- package/src/components/layout/NormalDataLayout/index.vue +70 -70
- package/src/components/layout/TabBarLayout/index.vue +40 -40
- package/src/components.d.ts +53 -53
- package/src/env.d.ts +16 -16
- package/src/font-style/font.css +3 -3
- package/src/hooks/useCommon.ts +9 -9
- package/src/locales/en-US.json +25 -25
- package/src/locales/zh-CN.json +25 -25
- package/src/plugins/AppData.ts +38 -38
- package/src/router/guards.ts +59 -59
- package/src/router/index.ts +61 -61
- package/src/router/invoiceRoutes.ts +33 -33
- package/src/services/api/common.ts +109 -109
- package/src/services/api/manage.ts +8 -8
- package/src/services/api/search.ts +16 -16
- package/src/services/restTools.ts +56 -56
- package/src/services/v3Api.ts +11 -11
- package/src/stores/modules/setting.ts +52 -52
- package/src/stores/mutation-type.ts +7 -7
- package/src/utils/authority-utils.ts +84 -84
- package/src/utils/crypto.ts +39 -39
- package/src/utils/i18n.ts +41 -41
- package/src/utils/indexedDB.ts +180 -180
- package/src/utils/mobileUtil.ts +26 -26
- package/src/utils/routerUtil.ts +271 -271
- package/src/utils/runEvalFunction.ts +13 -13
- package/src/utils/wechatUtil.ts +9 -9
- package/src/views/common/LoadError.vue +64 -64
- package/src/views/common/NotFound.vue +68 -68
- package/src/views/component/EvaluateRecordView/index.vue +40 -40
- package/src/views/component/XCellDetailView/index.vue +217 -217
- package/src/views/component/XOlMapView/XLocationPicker/index.vue +120 -120
- package/src/views/component/XOlMapView/index.vue +0 -1
- package/src/views/component/XReportFormIframeView/index.vue +47 -47
- package/src/views/component/XReportFormView/index.vue +13 -13
- package/src/views/component/XSignatureView/index.vue +50 -50
- package/src/views/component/menu.vue +117 -117
- package/src/views/component/notice.vue +46 -46
- package/src/views/component/topNav.vue +36 -36
- package/src/views/invoiceShow/index.vue +61 -61
- package/src/views/user/login/ForgetPasswordForm.vue +94 -94
- package/src/views/user/login/LoginTitle.vue +68 -68
- package/src/views/user/login/index.vue +22 -22
- package/src/views/user/my/index.vue +230 -230
- package/src/vue-router.d.ts +9 -9
- package/tsconfig.json +43 -43
package/src/App.vue
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { ConfigProviderThemeVars } from 'vant'
|
|
3
|
-
import { useHead } from '@unhead/vue'
|
|
4
|
-
import {
|
|
5
|
-
ConfigProvider as VanConfigProvider,
|
|
6
|
-
} from 'vant/es'
|
|
7
|
-
import { reactive } from 'vue'
|
|
8
|
-
|
|
9
|
-
useHead({
|
|
10
|
-
title: '智慧燃气',
|
|
11
|
-
meta: [
|
|
12
|
-
{
|
|
13
|
-
name: 'description',
|
|
14
|
-
content: '智慧燃气手机端',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
name: 'theme-color',
|
|
18
|
-
content: () => '#ffffff',
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
})
|
|
22
|
-
const themeVars: ConfigProviderThemeVars = reactive({
|
|
23
|
-
baseFont: 'PingFangSC-Regular-woff2, serif',
|
|
24
|
-
})
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<template>
|
|
28
|
-
<VanConfigProvider theme="light" :theme-vars="themeVars" theme-vars-scope="global">
|
|
29
|
-
<router-view v-slot="{ Component }">
|
|
30
|
-
<component :is="Component" />
|
|
31
|
-
</router-view>
|
|
32
|
-
</VanConfigProvider>
|
|
33
|
-
</template>
|
|
34
|
-
|
|
35
|
-
<style>
|
|
36
|
-
@import "./font-style/font.css";
|
|
37
|
-
input[type="password"]::-ms-reveal{
|
|
38
|
-
display: none;
|
|
39
|
-
}
|
|
40
|
-
input[type="password"]::-ms-clear{
|
|
41
|
-
display: none;
|
|
42
|
-
}
|
|
43
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ConfigProviderThemeVars } from 'vant'
|
|
3
|
+
import { useHead } from '@unhead/vue'
|
|
4
|
+
import {
|
|
5
|
+
ConfigProvider as VanConfigProvider,
|
|
6
|
+
} from 'vant/es'
|
|
7
|
+
import { reactive } from 'vue'
|
|
8
|
+
|
|
9
|
+
useHead({
|
|
10
|
+
title: '智慧燃气',
|
|
11
|
+
meta: [
|
|
12
|
+
{
|
|
13
|
+
name: 'description',
|
|
14
|
+
content: '智慧燃气手机端',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'theme-color',
|
|
18
|
+
content: () => '#ffffff',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
})
|
|
22
|
+
const themeVars: ConfigProviderThemeVars = reactive({
|
|
23
|
+
baseFont: 'PingFangSC-Regular-woff2, serif',
|
|
24
|
+
})
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<VanConfigProvider theme="light" :theme-vars="themeVars" theme-vars-scope="global">
|
|
29
|
+
<router-view v-slot="{ Component }">
|
|
30
|
+
<component :is="Component" />
|
|
31
|
+
</router-view>
|
|
32
|
+
</VanConfigProvider>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
@import "./font-style/font.css";
|
|
37
|
+
input[type="password"]::-ms-reveal{
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
input[type="password"]::-ms-clear{
|
|
41
|
+
display: none;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
package/src/api/user/index.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { loginApi } from '@af-mobile-client-vue3/services/api/Login'
|
|
2
|
-
|
|
3
|
-
import { get, post } from '@af-mobile-client-vue3/services/restTools'
|
|
4
|
-
import { http } from '@af-mobile-client-vue3/utils/http'
|
|
5
|
-
|
|
6
|
-
export interface BasicResponseModel<T = any> {
|
|
7
|
-
code: number
|
|
8
|
-
msg: string
|
|
9
|
-
data: T
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function login(data: any) {
|
|
13
|
-
return post(
|
|
14
|
-
loginApi.Login,
|
|
15
|
-
data,
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function OALogin(data: any) {
|
|
20
|
-
return get(`/af-system/user/${data.username}/${data.password}/智慧OA`)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @description: 获取用户信息
|
|
25
|
-
*/
|
|
26
|
-
export function getUserInfo() {
|
|
27
|
-
return get(
|
|
28
|
-
'/getUserInfo',
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @description: 用户登出
|
|
34
|
-
*/
|
|
35
|
-
export function doLogout() {
|
|
36
|
-
return http.request({
|
|
37
|
-
url: loginApi.Logout,
|
|
38
|
-
method: 'DELETE',
|
|
39
|
-
})
|
|
40
|
-
}
|
|
1
|
+
import { loginApi } from '@af-mobile-client-vue3/services/api/Login'
|
|
2
|
+
|
|
3
|
+
import { get, post } from '@af-mobile-client-vue3/services/restTools'
|
|
4
|
+
import { http } from '@af-mobile-client-vue3/utils/http'
|
|
5
|
+
|
|
6
|
+
export interface BasicResponseModel<T = any> {
|
|
7
|
+
code: number
|
|
8
|
+
msg: string
|
|
9
|
+
data: T
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function login(data: any) {
|
|
13
|
+
return post(
|
|
14
|
+
loginApi.Login,
|
|
15
|
+
data,
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function OALogin(data: any) {
|
|
20
|
+
return get(`/af-system/user/${data.username}/${data.password}/智慧OA`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @description: 获取用户信息
|
|
25
|
+
*/
|
|
26
|
+
export function getUserInfo() {
|
|
27
|
+
return get(
|
|
28
|
+
'/getUserInfo',
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @description: 用户登出
|
|
34
|
+
*/
|
|
35
|
+
export function doLogout() {
|
|
36
|
+
return http.request({
|
|
37
|
+
url: loginApi.Logout,
|
|
38
|
+
method: 'DELETE',
|
|
39
|
+
})
|
|
40
|
+
}
|
package/src/bootstrap.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { Router } from 'vue-router'
|
|
2
|
-
import guards from '@af-mobile-client-vue3/router/guards'
|
|
3
|
-
import { loadGuards, loadRoutes } from '@af-mobile-client-vue3/utils/routerUtil'
|
|
4
|
-
|
|
5
|
-
type GuardFunction = (to: any, from: any, next?: any) => void
|
|
6
|
-
interface Guards {
|
|
7
|
-
beforeEach?: GuardFunction[]
|
|
8
|
-
afterEach?: GuardFunction[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async function bootstrap(router: Router, customGuard: Guards = {}) {
|
|
12
|
-
// 加载路由
|
|
13
|
-
loadRoutes()
|
|
14
|
-
// 加载路由守卫
|
|
15
|
-
loadGuards({ ...guards, ...customGuard }, router)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default bootstrap
|
|
1
|
+
import type { Router } from 'vue-router'
|
|
2
|
+
import guards from '@af-mobile-client-vue3/router/guards'
|
|
3
|
+
import { loadGuards, loadRoutes } from '@af-mobile-client-vue3/utils/routerUtil'
|
|
4
|
+
|
|
5
|
+
type GuardFunction = (to: any, from: any, next?: any) => void
|
|
6
|
+
interface Guards {
|
|
7
|
+
beforeEach?: GuardFunction[]
|
|
8
|
+
afterEach?: GuardFunction[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function bootstrap(router: Router, customGuard: Guards = {}) {
|
|
12
|
+
// 加载路由
|
|
13
|
+
loadRoutes()
|
|
14
|
+
// 加载路由守卫
|
|
15
|
+
loadGuards({ ...guards, ...customGuard }, router)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default bootstrap
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { NavBar as VanNavBar } from 'vant/es'
|
|
3
|
-
|
|
4
|
-
// back
|
|
5
|
-
const onClickLeft = () => history.back()
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<template>
|
|
9
|
-
<VanNavBar left-arrow placeholder fixed @click-left="onClickLeft" />
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<style scoped></style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { NavBar as VanNavBar } from 'vant/es'
|
|
3
|
+
|
|
4
|
+
// back
|
|
5
|
+
const onClickLeft = () => history.back()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<VanNavBar left-arrow placeholder fixed @click-left="onClickLeft" />
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<style scoped></style>
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import SvgIcon from '@af-mobile-client-vue3/components/core/SvgIcon/index.vue'
|
|
3
|
-
import { Icon as VanIcon, Tabbar as VanTabbar, TabbarItem as VanTabbarItem } from 'vant'
|
|
4
|
-
import { ref } from 'vue'
|
|
5
|
-
import 'vant/lib/tabbar-item/index.css'
|
|
6
|
-
import 'vant/lib/tabbar/index.css'
|
|
7
|
-
|
|
8
|
-
const Props = defineProps<{
|
|
9
|
-
tabbarData: [
|
|
10
|
-
{
|
|
11
|
-
icon: string
|
|
12
|
-
title: string
|
|
13
|
-
to: {
|
|
14
|
-
name: string
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
]
|
|
18
|
-
}>()
|
|
19
|
-
const active = ref(0)
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<template>
|
|
23
|
-
<VanTabbar v-model="active" :placeholder="true" :route="true" fixed>
|
|
24
|
-
<VanTabbarItem
|
|
25
|
-
v-for="(item, index) in Props.tabbarData"
|
|
26
|
-
:key="index"
|
|
27
|
-
:to="item.to"
|
|
28
|
-
>
|
|
29
|
-
<template v-if="item.icon.startsWith('svg:')" #icon="props">
|
|
30
|
-
<SvgIcon :name="item.icon.split(':')[1]" :class-name="props.active ? 'svg-icon-active-blue' : ``" />
|
|
31
|
-
</template>
|
|
32
|
-
<template v-else #icon>
|
|
33
|
-
<VanIcon :name="item.icon" />
|
|
34
|
-
</template>
|
|
35
|
-
{{ item.title }}
|
|
36
|
-
</VanTabbarItem>
|
|
37
|
-
</VanTabbar>
|
|
38
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import SvgIcon from '@af-mobile-client-vue3/components/core/SvgIcon/index.vue'
|
|
3
|
+
import { Icon as VanIcon, Tabbar as VanTabbar, TabbarItem as VanTabbarItem } from 'vant'
|
|
4
|
+
import { ref } from 'vue'
|
|
5
|
+
import 'vant/lib/tabbar-item/index.css'
|
|
6
|
+
import 'vant/lib/tabbar/index.css'
|
|
7
|
+
|
|
8
|
+
const Props = defineProps<{
|
|
9
|
+
tabbarData: [
|
|
10
|
+
{
|
|
11
|
+
icon: string
|
|
12
|
+
title: string
|
|
13
|
+
to: {
|
|
14
|
+
name: string
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
]
|
|
18
|
+
}>()
|
|
19
|
+
const active = ref(0)
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<VanTabbar v-model="active" :placeholder="true" :route="true" fixed>
|
|
24
|
+
<VanTabbarItem
|
|
25
|
+
v-for="(item, index) in Props.tabbarData"
|
|
26
|
+
:key="index"
|
|
27
|
+
:to="item.to"
|
|
28
|
+
>
|
|
29
|
+
<template v-if="item.icon.startsWith('svg:')" #icon="props">
|
|
30
|
+
<SvgIcon :name="item.icon.split(':')[1]" :class-name="props.active ? 'svg-icon-active-blue' : ``" />
|
|
31
|
+
</template>
|
|
32
|
+
<template v-else #icon>
|
|
33
|
+
<VanIcon :name="item.icon" />
|
|
34
|
+
</template>
|
|
35
|
+
{{ item.title }}
|
|
36
|
+
</VanTabbarItem>
|
|
37
|
+
</VanTabbar>
|
|
38
|
+
</template>
|
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
Button as VanButton,
|
|
4
|
-
Checkbox as VanCheckbox,
|
|
5
|
-
CheckboxGroup as VanCheckboxGroup,
|
|
6
|
-
Grid as VanGrid,
|
|
7
|
-
GridItem as VanGridItem,
|
|
8
|
-
Radio as VanRadio,
|
|
9
|
-
RadioGroup as VanRadioGroup,
|
|
10
|
-
} from 'vant'
|
|
11
|
-
import { defineEmits, defineModel, defineProps } from 'vue'
|
|
12
|
-
|
|
13
|
-
interface ColumnItem {
|
|
14
|
-
[key: string]: string | number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ColumnsFieldNames {
|
|
18
|
-
text: string
|
|
19
|
-
value: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const props = defineProps({
|
|
23
|
-
columns: {
|
|
24
|
-
type: Array as () => ColumnItem[],
|
|
25
|
-
default: () => [] as ColumnItem[],
|
|
26
|
-
},
|
|
27
|
-
columnsFieldNames: {
|
|
28
|
-
type: Object as () => ColumnsFieldNames,
|
|
29
|
-
default: () => ({
|
|
30
|
-
text: 'label',
|
|
31
|
-
value: 'value',
|
|
32
|
-
}),
|
|
33
|
-
},
|
|
34
|
-
gutter: {
|
|
35
|
-
type: Number,
|
|
36
|
-
default: 8,
|
|
37
|
-
},
|
|
38
|
-
columnNum: {
|
|
39
|
-
type: Number,
|
|
40
|
-
default: 4,
|
|
41
|
-
},
|
|
42
|
-
multiple: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
default: false,
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const emit = defineEmits<{
|
|
49
|
-
change: [value: string | string[], list: ColumnItem[]]
|
|
50
|
-
}>()
|
|
51
|
-
|
|
52
|
-
const checked = defineModel<string | string[]>()
|
|
53
|
-
|
|
54
|
-
function classSel(colRow: ColumnItem): boolean {
|
|
55
|
-
if (typeof checked.value === 'string' || Array.isArray(checked.value))
|
|
56
|
-
return checked.value.includes(String(colRow[props.columnsFieldNames.value]))
|
|
57
|
-
else if (typeof checked.value === 'undefined')
|
|
58
|
-
return false
|
|
59
|
-
else
|
|
60
|
-
return checked.value === String(colRow[props.columnsFieldNames.value])
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function valueChange(value: string | string[]) {
|
|
64
|
-
const list = props.columns.filter((item) => {
|
|
65
|
-
if (props.multiple)
|
|
66
|
-
return value.includes(String(item[props.columnsFieldNames.value]))
|
|
67
|
-
|
|
68
|
-
else
|
|
69
|
-
return value === item[props.columnsFieldNames.value]
|
|
70
|
-
})
|
|
71
|
-
emit('change', value, list)
|
|
72
|
-
}
|
|
73
|
-
</script>
|
|
74
|
-
|
|
75
|
-
<template>
|
|
76
|
-
<div id="XGridDropOption">
|
|
77
|
-
<template v-if="props.multiple">
|
|
78
|
-
<VanCheckboxGroup v-model="checked as string[]" direction="horizontal" @change="valueChange">
|
|
79
|
-
<VanGrid :gutter="props.gutter" :border="false" :column-num="props.columnNum">
|
|
80
|
-
<VanGridItem v-for="colRow in props.columns" :key="colRow[props.columnsFieldNames.text]">
|
|
81
|
-
<template #default>
|
|
82
|
-
<VanCheckbox :name="colRow[props.columnsFieldNames.value]">
|
|
83
|
-
<VanButton type="default" size="small" :class="{ 'select-text-col': classSel(colRow) }">
|
|
84
|
-
{{ colRow[props.columnsFieldNames.text] }}
|
|
85
|
-
</VanButton>
|
|
86
|
-
</VanCheckbox>
|
|
87
|
-
</template>
|
|
88
|
-
</VanGridItem>
|
|
89
|
-
</VanGrid>
|
|
90
|
-
</VanCheckboxGroup>
|
|
91
|
-
</template>
|
|
92
|
-
<template v-else>
|
|
93
|
-
<VanRadioGroup v-model="checked" direction="horizontal" @change="valueChange">
|
|
94
|
-
<VanGrid :gutter="props.gutter" :border="false" :column-num="props.columnNum">
|
|
95
|
-
<VanGridItem v-for="colRow in props.columns" :key="colRow[props.columnsFieldNames.text]">
|
|
96
|
-
<template #default>
|
|
97
|
-
<VanRadio :name="colRow[props.columnsFieldNames.value]">
|
|
98
|
-
<VanButton type="default" size="small" :class="{ 'select-text-col': classSel(colRow) }">
|
|
99
|
-
{{ colRow[props.columnsFieldNames.text] }}
|
|
100
|
-
</VanButton>
|
|
101
|
-
</VanRadio>
|
|
102
|
-
</template>
|
|
103
|
-
</VanGridItem>
|
|
104
|
-
</VanGrid>
|
|
105
|
-
</VanRadioGroup>
|
|
106
|
-
</template>
|
|
107
|
-
</div>
|
|
108
|
-
</template>
|
|
109
|
-
|
|
110
|
-
<style scoped lang="less">
|
|
111
|
-
#XGridDropOption {
|
|
112
|
-
width: 100%;
|
|
113
|
-
--van-grid-item-content-padding: 2px;
|
|
114
|
-
--van-padding-sm: 0px;
|
|
115
|
-
--van-checkbox-label-margin: 0px;
|
|
116
|
-
--van-radio-label-margin: 0px;
|
|
117
|
-
--van-button-default-border-color: 'rgb(247,248,250)';
|
|
118
|
-
|
|
119
|
-
.van-grid {
|
|
120
|
-
width: 100%;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.select-text-col {
|
|
124
|
-
color: blue;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
:deep(.van-checkbox__icon) {
|
|
128
|
-
display: none;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
:deep(.van-checkbox) {
|
|
132
|
-
width: 100%;
|
|
133
|
-
}
|
|
134
|
-
:deep(.van-radio__icon) {
|
|
135
|
-
display: none;
|
|
136
|
-
}
|
|
137
|
-
:deep(.van-radio) {
|
|
138
|
-
width: 100%;
|
|
139
|
-
}
|
|
140
|
-
:deep(.van-button) {
|
|
141
|
-
width: 100%;
|
|
142
|
-
background-color: rgb(247,248,250);
|
|
143
|
-
}
|
|
144
|
-
:deep(.van-checkbox__label) {
|
|
145
|
-
width: 100%;
|
|
146
|
-
}
|
|
147
|
-
:deep(.van-radio__label) {
|
|
148
|
-
width: 100%;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Button as VanButton,
|
|
4
|
+
Checkbox as VanCheckbox,
|
|
5
|
+
CheckboxGroup as VanCheckboxGroup,
|
|
6
|
+
Grid as VanGrid,
|
|
7
|
+
GridItem as VanGridItem,
|
|
8
|
+
Radio as VanRadio,
|
|
9
|
+
RadioGroup as VanRadioGroup,
|
|
10
|
+
} from 'vant'
|
|
11
|
+
import { defineEmits, defineModel, defineProps } from 'vue'
|
|
12
|
+
|
|
13
|
+
interface ColumnItem {
|
|
14
|
+
[key: string]: string | number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ColumnsFieldNames {
|
|
18
|
+
text: string
|
|
19
|
+
value: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const props = defineProps({
|
|
23
|
+
columns: {
|
|
24
|
+
type: Array as () => ColumnItem[],
|
|
25
|
+
default: () => [] as ColumnItem[],
|
|
26
|
+
},
|
|
27
|
+
columnsFieldNames: {
|
|
28
|
+
type: Object as () => ColumnsFieldNames,
|
|
29
|
+
default: () => ({
|
|
30
|
+
text: 'label',
|
|
31
|
+
value: 'value',
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
gutter: {
|
|
35
|
+
type: Number,
|
|
36
|
+
default: 8,
|
|
37
|
+
},
|
|
38
|
+
columnNum: {
|
|
39
|
+
type: Number,
|
|
40
|
+
default: 4,
|
|
41
|
+
},
|
|
42
|
+
multiple: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const emit = defineEmits<{
|
|
49
|
+
change: [value: string | string[], list: ColumnItem[]]
|
|
50
|
+
}>()
|
|
51
|
+
|
|
52
|
+
const checked = defineModel<string | string[]>()
|
|
53
|
+
|
|
54
|
+
function classSel(colRow: ColumnItem): boolean {
|
|
55
|
+
if (typeof checked.value === 'string' || Array.isArray(checked.value))
|
|
56
|
+
return checked.value.includes(String(colRow[props.columnsFieldNames.value]))
|
|
57
|
+
else if (typeof checked.value === 'undefined')
|
|
58
|
+
return false
|
|
59
|
+
else
|
|
60
|
+
return checked.value === String(colRow[props.columnsFieldNames.value])
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function valueChange(value: string | string[]) {
|
|
64
|
+
const list = props.columns.filter((item) => {
|
|
65
|
+
if (props.multiple)
|
|
66
|
+
return value.includes(String(item[props.columnsFieldNames.value]))
|
|
67
|
+
|
|
68
|
+
else
|
|
69
|
+
return value === item[props.columnsFieldNames.value]
|
|
70
|
+
})
|
|
71
|
+
emit('change', value, list)
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<div id="XGridDropOption">
|
|
77
|
+
<template v-if="props.multiple">
|
|
78
|
+
<VanCheckboxGroup v-model="checked as string[]" direction="horizontal" @change="valueChange">
|
|
79
|
+
<VanGrid :gutter="props.gutter" :border="false" :column-num="props.columnNum">
|
|
80
|
+
<VanGridItem v-for="colRow in props.columns" :key="colRow[props.columnsFieldNames.text]">
|
|
81
|
+
<template #default>
|
|
82
|
+
<VanCheckbox :name="colRow[props.columnsFieldNames.value]">
|
|
83
|
+
<VanButton type="default" size="small" :class="{ 'select-text-col': classSel(colRow) }">
|
|
84
|
+
{{ colRow[props.columnsFieldNames.text] }}
|
|
85
|
+
</VanButton>
|
|
86
|
+
</VanCheckbox>
|
|
87
|
+
</template>
|
|
88
|
+
</VanGridItem>
|
|
89
|
+
</VanGrid>
|
|
90
|
+
</VanCheckboxGroup>
|
|
91
|
+
</template>
|
|
92
|
+
<template v-else>
|
|
93
|
+
<VanRadioGroup v-model="checked" direction="horizontal" @change="valueChange">
|
|
94
|
+
<VanGrid :gutter="props.gutter" :border="false" :column-num="props.columnNum">
|
|
95
|
+
<VanGridItem v-for="colRow in props.columns" :key="colRow[props.columnsFieldNames.text]">
|
|
96
|
+
<template #default>
|
|
97
|
+
<VanRadio :name="colRow[props.columnsFieldNames.value]">
|
|
98
|
+
<VanButton type="default" size="small" :class="{ 'select-text-col': classSel(colRow) }">
|
|
99
|
+
{{ colRow[props.columnsFieldNames.text] }}
|
|
100
|
+
</VanButton>
|
|
101
|
+
</VanRadio>
|
|
102
|
+
</template>
|
|
103
|
+
</VanGridItem>
|
|
104
|
+
</VanGrid>
|
|
105
|
+
</VanRadioGroup>
|
|
106
|
+
</template>
|
|
107
|
+
</div>
|
|
108
|
+
</template>
|
|
109
|
+
|
|
110
|
+
<style scoped lang="less">
|
|
111
|
+
#XGridDropOption {
|
|
112
|
+
width: 100%;
|
|
113
|
+
--van-grid-item-content-padding: 2px;
|
|
114
|
+
--van-padding-sm: 0px;
|
|
115
|
+
--van-checkbox-label-margin: 0px;
|
|
116
|
+
--van-radio-label-margin: 0px;
|
|
117
|
+
--van-button-default-border-color: 'rgb(247,248,250)';
|
|
118
|
+
|
|
119
|
+
.van-grid {
|
|
120
|
+
width: 100%;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.select-text-col {
|
|
124
|
+
color: blue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:deep(.van-checkbox__icon) {
|
|
128
|
+
display: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:deep(.van-checkbox) {
|
|
132
|
+
width: 100%;
|
|
133
|
+
}
|
|
134
|
+
:deep(.van-radio__icon) {
|
|
135
|
+
display: none;
|
|
136
|
+
}
|
|
137
|
+
:deep(.van-radio) {
|
|
138
|
+
width: 100%;
|
|
139
|
+
}
|
|
140
|
+
:deep(.van-button) {
|
|
141
|
+
width: 100%;
|
|
142
|
+
background-color: rgb(247,248,250);
|
|
143
|
+
}
|
|
144
|
+
:deep(.van-checkbox__label) {
|
|
145
|
+
width: 100%;
|
|
146
|
+
}
|
|
147
|
+
:deep(.van-radio__label) {
|
|
148
|
+
width: 100%;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
</style>
|