af-mobile-client-vue3 1.2.14 → 1.2.16
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/package.json +1 -1
- package/src/components/data/XCellList/index.vue +12 -2
- package/src/components/data/XCellListFilter/index.vue +14 -1
- package/src/components/data/XForm/index.vue +2 -2
- package/src/components/data/XFormItem/index.vue +17 -1
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/views/component/XCellListView/index.vue +56 -21
- package/src/views/component/XFormGroupView/index.vue +7 -4
package/package.json
CHANGED
|
@@ -141,6 +141,9 @@ const buttonState = ref(undefined)
|
|
|
141
141
|
const groupFormItems = ref({})
|
|
142
142
|
const title = ref('')
|
|
143
143
|
|
|
144
|
+
// 按钮权限
|
|
145
|
+
const buttonPermissions = ref([])
|
|
146
|
+
|
|
144
147
|
const slots = useSlots()
|
|
145
148
|
|
|
146
149
|
// 当前组件实例(不推荐使用,可能会在后续的版本更迭中调整,暂时用来绑定函数的上下文)
|
|
@@ -202,9 +205,10 @@ function initComponent() {
|
|
|
202
205
|
|
|
203
206
|
if (result.buttonState) {
|
|
204
207
|
buttonState.value = result.buttonState
|
|
205
|
-
|
|
208
|
+
buttonPermissions.value = result.buttonPermissions
|
|
209
|
+
if (buttonState.value.edit && buttonState.value.edit === true && (filterButtonPermissions('edit').state === false || ((filterButtonPermissions('edit').state === true && userState.f.resources.f_role_name.includes((filterButtonPermissions('edit').roleStr))))))
|
|
206
210
|
allActions.value.push({ text: '修改', func: 'updateRow' })
|
|
207
|
-
if (buttonState.value.delete && buttonState.value.delete === true)
|
|
211
|
+
if (buttonState.value.delete && buttonState.value.delete === true && (filterButtonPermissions('delete').state === false || ((filterButtonPermissions('delete').state === true && userState.f.resources.f_role_name.includes((filterButtonPermissions('delete').roleStr))))))
|
|
208
212
|
allActions.value.push({ text: '删除', func: 'deleteRow' })
|
|
209
213
|
}
|
|
210
214
|
splitArrayAt(allActions.value, 3)
|
|
@@ -452,6 +456,11 @@ function addOption() {
|
|
|
452
456
|
}
|
|
453
457
|
}
|
|
454
458
|
|
|
459
|
+
// 按钮权限信息筛选
|
|
460
|
+
function filterButtonPermissions(btn) {
|
|
461
|
+
return buttonPermissions.value.find(item => item.btnName === btn)
|
|
462
|
+
}
|
|
463
|
+
|
|
455
464
|
// 处理按钮点击
|
|
456
465
|
function handleButtonClick(btn, item) {
|
|
457
466
|
emit(`${btn.btnIcon}`, item)
|
|
@@ -546,6 +555,7 @@ defineExpose({
|
|
|
546
555
|
:order-list="orderList"
|
|
547
556
|
:form-query="formQueryList"
|
|
548
557
|
:button-state="buttonState"
|
|
558
|
+
:button-permissions="buttonPermissions"
|
|
549
559
|
:scan-options="scanOptions"
|
|
550
560
|
@on-refresh="onRefresh"
|
|
551
561
|
@add-option="addOption"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOption/index.vue'
|
|
3
3
|
import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
|
|
4
|
+
import useUserStore from '@af-mobile-client-vue3/stores/modules/user'
|
|
4
5
|
import { Icon } from '@iconify/vue'
|
|
5
6
|
import {
|
|
6
7
|
showFailToast,
|
|
@@ -23,6 +24,7 @@ const props = defineProps<{
|
|
|
23
24
|
orderList?: any[]
|
|
24
25
|
formQuery?: any[]
|
|
25
26
|
buttonState?: any
|
|
27
|
+
buttonPermissions?: any[]
|
|
26
28
|
scanOptions?: {
|
|
27
29
|
show?: boolean // 是否显示扫码按钮
|
|
28
30
|
type?: string | string[] // 显示类型:可以是单个类型,也可以是类型数组
|
|
@@ -41,6 +43,8 @@ const emit = defineEmits([
|
|
|
41
43
|
'onNFC',
|
|
42
44
|
])
|
|
43
45
|
|
|
46
|
+
const userState = useUserStore().getLogin()
|
|
47
|
+
|
|
44
48
|
// 定义扫描模式枚举,便于扩展
|
|
45
49
|
const SCAN_MODES = {
|
|
46
50
|
SCAN: 'scan', // 扫码模式
|
|
@@ -276,6 +280,11 @@ function handleFilterMenuChange(value: boolean) {
|
|
|
276
280
|
function handleCloseScanButton() {
|
|
277
281
|
listFilterMenu.value.close(false)
|
|
278
282
|
}
|
|
283
|
+
|
|
284
|
+
// 按钮权限信息筛选
|
|
285
|
+
function filterButtonPermissions(btn) {
|
|
286
|
+
return props.buttonPermissions.find(item => item.btnName === btn)
|
|
287
|
+
}
|
|
279
288
|
</script>
|
|
280
289
|
|
|
281
290
|
<template>
|
|
@@ -385,7 +394,11 @@ function handleCloseScanButton() {
|
|
|
385
394
|
<VanButton type="default" @click="resetOption">
|
|
386
395
|
重置
|
|
387
396
|
</VanButton>
|
|
388
|
-
<VanButton
|
|
397
|
+
<VanButton
|
|
398
|
+
v-if="props.buttonState.add && props.buttonState.add === true && (filterButtonPermissions('add').state === false || ((filterButtonPermissions('add').state === true && userState.f.resources.f_role_name.includes((filterButtonPermissions('add').roleStr)))))"
|
|
399
|
+
type="primary"
|
|
400
|
+
@click="addOption"
|
|
401
|
+
>
|
|
389
402
|
新增
|
|
390
403
|
</VanButton>
|
|
391
404
|
<VanButton type="primary" @click="confirmOption">
|
|
@@ -382,11 +382,11 @@ async function onSubmit() {
|
|
|
382
382
|
const realForm = handleFormKeys(requestForm)
|
|
383
383
|
try {
|
|
384
384
|
addOrModifyEntity(realForm, tableName.value, props.serviceName || import.meta.env.VITE_APP_SYSTEM_NAME).then(() => {
|
|
385
|
-
showSuccessToast('
|
|
385
|
+
showSuccessToast('提交成功!!')
|
|
386
386
|
})
|
|
387
387
|
}
|
|
388
388
|
catch (error) {
|
|
389
|
-
showFailToast('
|
|
389
|
+
showFailToast('提交失败!!')
|
|
390
390
|
}
|
|
391
391
|
finally {
|
|
392
392
|
setTimeout(() => {
|
|
@@ -7,7 +7,8 @@ import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOpt
|
|
|
7
7
|
import XMultiSelect from '@af-mobile-client-vue3/components/core/XMultiSelect/index.vue'
|
|
8
8
|
import XSelect from '@af-mobile-client-vue3/components/core/XSelect/index.vue'
|
|
9
9
|
import XLocationPicker from '@af-mobile-client-vue3/components/data/XOlMap/XLocationPicker/index.vue'
|
|
10
|
-
import { runLogic } from '@af-mobile-client-vue3/services/api/common'
|
|
10
|
+
import { getConfigByNameAsync, runLogic } from '@af-mobile-client-vue3/services/api/common'
|
|
11
|
+
import { post } from '@af-mobile-client-vue3/services/restTools'
|
|
11
12
|
import { searchToListOption, searchToOption } from '@af-mobile-client-vue3/services/v3Api'
|
|
12
13
|
import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
|
|
13
14
|
import { getDict } from '@af-mobile-client-vue3/utils/dictUtil'
|
|
@@ -94,6 +95,7 @@ const emits = defineEmits(['update:modelValue', 'set-form'])
|
|
|
94
95
|
// 判断并初始化防抖函数
|
|
95
96
|
let debouncedUserLinkFunc: (() => void) | null = null
|
|
96
97
|
let debouncedDepLinkFunc: (() => void) | null = null
|
|
98
|
+
let debouncedUpdateOptions: (() => void) | null = null
|
|
97
99
|
|
|
98
100
|
const { attr, form, mode, serviceName, getDataParams, columnsField } = props
|
|
99
101
|
const calendarShow = ref(false)
|
|
@@ -445,6 +447,10 @@ onBeforeMount(() => {
|
|
|
445
447
|
|
|
446
448
|
if (attr?.keyName?.toString()?.startsWith('search@根据表单项[') && attr?.keyName?.toString().endsWith(']联动部门'))
|
|
447
449
|
debouncedDepLinkFunc = debounce(() => updateResOptions('部门'), 200)
|
|
450
|
+
|
|
451
|
+
if (attr.keyName && (attr?.keyName?.toString().indexOf('async ') !== -1 || attr?.keyName?.toString()?.indexOf('function') !== -1)) {
|
|
452
|
+
debouncedUpdateOptions = debounce(updateOptions, 200)
|
|
453
|
+
}
|
|
448
454
|
})
|
|
449
455
|
// 是否展示表单左侧label文字
|
|
450
456
|
const labelData = computed(() => {
|
|
@@ -474,6 +480,13 @@ function onCalendarConfirm(values) {
|
|
|
474
480
|
calendarShow.value = false
|
|
475
481
|
}
|
|
476
482
|
|
|
483
|
+
// js 函数作为数据源
|
|
484
|
+
async function updateOptions() {
|
|
485
|
+
if (attr.keyName && (attr.keyName.toString().includes('async ') || attr.keyName.toString().includes('function '))) {
|
|
486
|
+
option.value = await executeStrFunctionByContext(this, attr.keyName, [form, runLogic, mode, getConfigByNameAsync, post])
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
477
490
|
function init() {
|
|
478
491
|
if (attr.keyName && typeof attr.keyName === 'string') {
|
|
479
492
|
if (attr.keyName && attr.keyName.includes('logic@')) {
|
|
@@ -509,6 +522,9 @@ function init() {
|
|
|
509
522
|
else
|
|
510
523
|
searchToOption(searchData, res => getDataCallback(res))
|
|
511
524
|
}
|
|
525
|
+
else if (attr.keyName.toString().includes('async ') || attr.keyName.toString().includes('function ')) {
|
|
526
|
+
updateOptions()
|
|
527
|
+
}
|
|
512
528
|
else {
|
|
513
529
|
initRadioValue()
|
|
514
530
|
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 根据类型获取日期区间字符串
|
|
3
|
-
* @param type '当年' | 'curMonth' | '当日'
|
|
4
|
-
* @param show 区分实际值还是显示值, true为实际值, false为显示值
|
|
5
|
-
* @returns [start, end] 例:['2024-01-01 00:00:00', '2024-12-31 23:59:59']
|
|
6
|
-
*/
|
|
7
|
-
export function getRangeByType(type: string, show: boolean): [string, string] {
|
|
8
|
-
const now = new Date()
|
|
9
|
-
const year = now.getFullYear()
|
|
10
|
-
const month = (now.getMonth() + 1).toString().padStart(2, '0')
|
|
11
|
-
const day = now.getDate().toString().padStart(2, '0')
|
|
12
|
-
|
|
13
|
-
if (!show) {
|
|
14
|
-
if (type === 'curYear') {
|
|
15
|
-
return [
|
|
16
|
-
`${year}-01-01 00:00:00`,
|
|
17
|
-
`${year}-12-31 23:59:59`,
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
if (type === 'curMonth') {
|
|
21
|
-
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
22
|
-
return [
|
|
23
|
-
`${year}-${month}-01 00:00:00`,
|
|
24
|
-
`${year}-${month}-${lastDay.toString().padStart(2, '0')} 23:59:59`,
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
if (type === 'curDay') {
|
|
28
|
-
return [
|
|
29
|
-
`${year}-${month}-${day} 00:00:00`,
|
|
30
|
-
`${year}-${month}-${day} 23:59:59`,
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (show) {
|
|
35
|
-
if (type === 'curYear') {
|
|
36
|
-
return [
|
|
37
|
-
`${year}-01-01`,
|
|
38
|
-
`${year}-12-31`,
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
if (type === 'curMonth') {
|
|
42
|
-
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
43
|
-
return [
|
|
44
|
-
`${year}-${month}-01`,
|
|
45
|
-
`${year}-${month}-${lastDay.toString().padStart(2, '0')}`,
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
if (type === 'curDay') {
|
|
49
|
-
return [
|
|
50
|
-
`${year}-${month}-${day}`,
|
|
51
|
-
`${year}-${month}-${day}`,
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// 兜底返回空字符串数组
|
|
56
|
-
return ['', '']
|
|
57
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 根据类型获取日期区间字符串
|
|
3
|
+
* @param type '当年' | 'curMonth' | '当日'
|
|
4
|
+
* @param show 区分实际值还是显示值, true为实际值, false为显示值
|
|
5
|
+
* @returns [start, end] 例:['2024-01-01 00:00:00', '2024-12-31 23:59:59']
|
|
6
|
+
*/
|
|
7
|
+
export function getRangeByType(type: string, show: boolean): [string, string] {
|
|
8
|
+
const now = new Date()
|
|
9
|
+
const year = now.getFullYear()
|
|
10
|
+
const month = (now.getMonth() + 1).toString().padStart(2, '0')
|
|
11
|
+
const day = now.getDate().toString().padStart(2, '0')
|
|
12
|
+
|
|
13
|
+
if (!show) {
|
|
14
|
+
if (type === 'curYear') {
|
|
15
|
+
return [
|
|
16
|
+
`${year}-01-01 00:00:00`,
|
|
17
|
+
`${year}-12-31 23:59:59`,
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
if (type === 'curMonth') {
|
|
21
|
+
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
22
|
+
return [
|
|
23
|
+
`${year}-${month}-01 00:00:00`,
|
|
24
|
+
`${year}-${month}-${lastDay.toString().padStart(2, '0')} 23:59:59`,
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
if (type === 'curDay') {
|
|
28
|
+
return [
|
|
29
|
+
`${year}-${month}-${day} 00:00:00`,
|
|
30
|
+
`${year}-${month}-${day} 23:59:59`,
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (show) {
|
|
35
|
+
if (type === 'curYear') {
|
|
36
|
+
return [
|
|
37
|
+
`${year}-01-01`,
|
|
38
|
+
`${year}-12-31`,
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
if (type === 'curMonth') {
|
|
42
|
+
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
43
|
+
return [
|
|
44
|
+
`${year}-${month}-01`,
|
|
45
|
+
`${year}-${month}-${lastDay.toString().padStart(2, '0')}`,
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
if (type === 'curDay') {
|
|
49
|
+
return [
|
|
50
|
+
`${year}-${month}-${day}`,
|
|
51
|
+
`${year}-${month}-${day}`,
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// 兜底返回空字符串数组
|
|
56
|
+
return ['', '']
|
|
57
|
+
}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import XCellList from '@af-mobile-client-vue3/components/data/XCellList/index.vue'
|
|
3
3
|
import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
|
|
4
|
+
import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
|
|
4
5
|
import { defineEmits, ref } from 'vue'
|
|
5
6
|
import { useRouter } from 'vue-router'
|
|
6
7
|
|
|
7
8
|
// 定义事件
|
|
8
9
|
const emit = defineEmits(['deleteRow'])
|
|
10
|
+
const userInfo = useUserStore().getUserInfo()
|
|
9
11
|
// 访问路由
|
|
10
12
|
const router = useRouter()
|
|
11
13
|
// 获取默认值
|
|
12
14
|
const idKey = ref('o_id')
|
|
13
15
|
|
|
14
16
|
// 简易crud表单测试
|
|
15
|
-
const configName = ref('
|
|
17
|
+
// const configName = ref('orderCarInMobileCRUD')
|
|
18
|
+
// const serviceName = ref('af-gaslink')
|
|
19
|
+
// const configName = ref('lngPriceManageMobileCRUD')
|
|
20
|
+
const configName = ref('测试2')
|
|
16
21
|
const serviceName = ref('af-gaslink')
|
|
22
|
+
// const configName = ref('mobile_liushuiQueryCRUD')
|
|
23
|
+
// const serviceName = ref('af-revenue')
|
|
17
24
|
|
|
18
25
|
// 资源权限测试
|
|
19
26
|
// const configName = ref('crud_sources_test')
|
|
@@ -49,11 +56,11 @@ const serviceName = ref('af-gaslink')
|
|
|
49
56
|
function toDetail(item) {
|
|
50
57
|
router.push({
|
|
51
58
|
name: 'XFormGroupView',
|
|
52
|
-
query: {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
59
|
+
// query: {
|
|
60
|
+
// id: item[idKey.value],
|
|
61
|
+
// id: item.rr_id,
|
|
62
|
+
// o_id: item.o_id,
|
|
63
|
+
// },
|
|
57
64
|
})
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -69,19 +76,35 @@ function toDetail(item) {
|
|
|
69
76
|
// },
|
|
70
77
|
// })
|
|
71
78
|
// }
|
|
79
|
+
function addOption() {
|
|
80
|
+
router.push({
|
|
81
|
+
name: 'XFormGroupView',
|
|
82
|
+
// params: { id: totalCount.value },
|
|
83
|
+
// query: {
|
|
84
|
+
// configName: configName.value,
|
|
85
|
+
// serviceName: serviceName.value,
|
|
86
|
+
// mode: '新增',
|
|
87
|
+
// },
|
|
88
|
+
})
|
|
89
|
+
// 如果存在回调函数,调用它并传递true表示已处理
|
|
90
|
+
// if (typeof callback === 'function') {
|
|
91
|
+
// callback(true)
|
|
92
|
+
// }
|
|
93
|
+
}
|
|
72
94
|
|
|
73
95
|
// 修改功能
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
|
|
96
|
+
function updateRow(result) {
|
|
97
|
+
console.log('用户----', userInfo)
|
|
98
|
+
router.push({
|
|
99
|
+
name: 'XFormGroupView',
|
|
100
|
+
// params: { id: result.o_id, openid: result.o_id },
|
|
101
|
+
// query: {
|
|
102
|
+
// configName: configName.value,
|
|
103
|
+
// serviceName: serviceName.value,
|
|
104
|
+
// mode: '修改',
|
|
105
|
+
// },
|
|
106
|
+
})
|
|
107
|
+
}
|
|
85
108
|
|
|
86
109
|
// 删除功能
|
|
87
110
|
function deleteRow(result) {
|
|
@@ -92,11 +115,23 @@ function deleteRow(result) {
|
|
|
92
115
|
<template>
|
|
93
116
|
<NormalDataLayout id="XCellListView" title="工作计划">
|
|
94
117
|
<template #layout_content>
|
|
118
|
+
<!-- <XCellList -->
|
|
119
|
+
<!-- :config-name="configName" -->
|
|
120
|
+
<!-- :service-name="serviceName" -->
|
|
121
|
+
<!-- :custom-add="true" -->
|
|
122
|
+
<!-- :custom-edit="true" -->
|
|
123
|
+
<!-- :id-key="idKey" -->
|
|
124
|
+
<!-- @to-detail="toDetail" -->
|
|
125
|
+
<!-- @delete-row="deleteRow" -->
|
|
126
|
+
<!-- @update="updateRow" -->
|
|
127
|
+
<!-- @add="addOption" -->
|
|
128
|
+
<!-- /> -->
|
|
129
|
+
|
|
130
|
+
<!-- :fix-query-form="{ u_f_price_state: ['生效', '待生效'] }" -->
|
|
131
|
+
|
|
95
132
|
<XCellList
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
:fix-query-form="{ o_f_oper_name: 'edu_test' }"
|
|
99
|
-
:id-key="idKey"
|
|
133
|
+
config-name="小小测试CRUD"
|
|
134
|
+
service-name="af-apply"
|
|
100
135
|
@to-detail="toDetail"
|
|
101
136
|
@delete-row="deleteRow"
|
|
102
137
|
/>
|
|
@@ -5,16 +5,19 @@ import { showDialog } from 'vant'
|
|
|
5
5
|
import { ref } from 'vue'
|
|
6
6
|
import { useRoute } from 'vue-router'
|
|
7
7
|
|
|
8
|
+
// const configName = ref('reviewFormGroup')
|
|
9
|
+
// const serviceName = ref('af-revenue')
|
|
10
|
+
|
|
8
11
|
// 纯表单
|
|
9
|
-
const configName = ref('form_check_test')
|
|
10
|
-
const serviceName = ref('af-system')
|
|
12
|
+
// const configName = ref('form_check_test')
|
|
13
|
+
// const serviceName = ref('af-system')
|
|
11
14
|
|
|
12
15
|
// const configName = ref("计划下发Form")
|
|
13
16
|
// const serviceName = ref("af-linepatrol")
|
|
14
17
|
|
|
15
18
|
// 表单组
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const configName = ref('lngChargeAuditMobileFormGroup')
|
|
20
|
+
const serviceName = ref('af-gaslink')
|
|
18
21
|
|
|
19
22
|
const formData = ref({})
|
|
20
23
|
const formGroup = ref(null)
|