@agentprismform/render-vue 0.0.0-stage → 1.2.0
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/dist/index.cjs +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.mjs +2632 -0
- package/dist/style.css +1 -0
- package/package.json +38 -4
- package/src/components/FormGroup.vue +50 -0
- package/src/components/FormItem.vue +171 -0
- package/src/components/FormRender.vue +127 -0
- package/src/components/controls/AddressControl.vue +255 -0
- package/src/components/controls/AgreementControl.vue +49 -0
- package/src/components/controls/CascaderControl.vue +159 -0
- package/src/components/controls/DateControl.vue +96 -0
- package/src/components/controls/ImageUploadControl.vue +135 -0
- package/src/components/controls/InputControl.vue +80 -0
- package/src/components/controls/ListControl.vue +149 -0
- package/src/components/controls/SearchControl.vue +193 -0
- package/src/components/controls/SelectControl.vue +206 -0
- package/src/components/controls/SliderControl.vue +61 -0
- package/src/components/controls/TaskControl.vue +39 -0
- package/src/components/controls/VerifyCodeControl.vue +135 -0
- package/src/components/controls/task/ApiTask.vue +99 -0
- package/src/components/controls/task/CustomerTask.vue +91 -0
- package/src/components/controls/task/H5JumpTask.vue +125 -0
- package/src/components/controls/task/InlineTask.vue +116 -0
- package/src/components/controls/task/NativeTask.vue +299 -0
- package/src/components/controls/task/SubFormTask.vue +156 -0
- package/src/composables/useFormRender.ts +63 -0
- package/src/composables/useTaskHandler.ts +11 -0
- package/src/helpers.ts +143 -0
- package/src/index.ts +5 -0
- package/src/taskHandlers.ts +4 -0
- package/README.md +0 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Task 控件路由 — 根据 taskCategory / taskType 分发到差异化子组件
|
|
4
|
+
*/
|
|
5
|
+
import { computed } from 'vue'
|
|
6
|
+
import type { FormItem } from '@agentprismform/core'
|
|
7
|
+
import { classifyTask } from '@agentprismform/render-task'
|
|
8
|
+
import SubFormTask from './task/SubFormTask.vue'
|
|
9
|
+
import H5JumpTask from './task/H5JumpTask.vue'
|
|
10
|
+
import NativeTask from './task/NativeTask.vue'
|
|
11
|
+
import ApiTask from './task/ApiTask.vue'
|
|
12
|
+
import CustomerTask from './task/CustomerTask.vue'
|
|
13
|
+
import InlineTask from './task/InlineTask.vue'
|
|
14
|
+
|
|
15
|
+
const props = defineProps<{
|
|
16
|
+
item: FormItem
|
|
17
|
+
field: any
|
|
18
|
+
formCore: any
|
|
19
|
+
}>()
|
|
20
|
+
|
|
21
|
+
const taskComponent = computed(() => {
|
|
22
|
+
const kind = classifyTask(props.item.props)
|
|
23
|
+
const map: Record<string, any> = {
|
|
24
|
+
subForm: SubFormTask,
|
|
25
|
+
h5: H5JumpTask,
|
|
26
|
+
signature: NativeTask,
|
|
27
|
+
map: NativeTask,
|
|
28
|
+
native: NativeTask,
|
|
29
|
+
api: ApiTask,
|
|
30
|
+
customer: CustomerTask,
|
|
31
|
+
inline: InlineTask,
|
|
32
|
+
}
|
|
33
|
+
return map[kind] || SubFormTask
|
|
34
|
+
})
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<component :is="taskComponent" :item="item" :field="field" :formCore="formCore" />
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, inject, onBeforeUnmount, ref, unref, watch } from 'vue'
|
|
3
|
+
import type { FormItem } from '@agentprismform/core'
|
|
4
|
+
import {
|
|
5
|
+
FORM_UI_HOST_HANDLERS_KEY,
|
|
6
|
+
type FormUiHostHandlers,
|
|
7
|
+
} from '@agentprismform/render-ui'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{ item: FormItem; field: any; formCore: any }>()
|
|
10
|
+
const emit = defineEmits(['change'])
|
|
11
|
+
|
|
12
|
+
const hostHandlersInjected = inject<
|
|
13
|
+
FormUiHostHandlers | null | { value: FormUiHostHandlers | null }
|
|
14
|
+
>(FORM_UI_HOST_HANDLERS_KEY, null)
|
|
15
|
+
|
|
16
|
+
const localValue = ref(String(props.field?.value || ''))
|
|
17
|
+
const remain = ref(0)
|
|
18
|
+
const sending = ref(false)
|
|
19
|
+
const hostError = ref('')
|
|
20
|
+
let timer: ReturnType<typeof setInterval> | null = null
|
|
21
|
+
|
|
22
|
+
watch(
|
|
23
|
+
() => props.field?.value,
|
|
24
|
+
(v) => {
|
|
25
|
+
localValue.value = v == null ? '' : String(v)
|
|
26
|
+
},
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const countTime = computed(() => Number(props.item.props?.countTime) || 60)
|
|
30
|
+
const verifyText = computed(
|
|
31
|
+
() => props.item.props?.verifyText || props.item.props?.reVerifyText || '获取验证码',
|
|
32
|
+
)
|
|
33
|
+
const counting = computed(() => remain.value > 0)
|
|
34
|
+
const btnLabel = computed(() => {
|
|
35
|
+
if (remain.value > 0) return `${remain.value}s`
|
|
36
|
+
if (sending.value) return '发送中'
|
|
37
|
+
return verifyText.value
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
function onInput(e: Event) {
|
|
41
|
+
localValue.value = (e.target as HTMLInputElement).value
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function onBlur() {
|
|
45
|
+
const val = localValue.value.trim()
|
|
46
|
+
localValue.value = val
|
|
47
|
+
emit('change', { value: val, eventType: 'inputBlur' })
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function clearTimer() {
|
|
51
|
+
if (timer) {
|
|
52
|
+
clearInterval(timer)
|
|
53
|
+
timer = null
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function startCountdownOnly() {
|
|
58
|
+
remain.value = countTime.value
|
|
59
|
+
clearTimer()
|
|
60
|
+
timer = setInterval(() => {
|
|
61
|
+
remain.value -= 1
|
|
62
|
+
if (remain.value <= 0) clearTimer()
|
|
63
|
+
}, 1000)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function onSend() {
|
|
67
|
+
if (counting.value || sending.value || props.field?.disabled) return
|
|
68
|
+
hostError.value = ''
|
|
69
|
+
sending.value = true
|
|
70
|
+
try {
|
|
71
|
+
const host = unref(hostHandlersInjected)
|
|
72
|
+
if (host?.sendVerifyCode) {
|
|
73
|
+
const mobileKey =
|
|
74
|
+
(props.item.props as any)?.mobileKey || (props.item.props as any)?.bindMobileKey
|
|
75
|
+
const mobile =
|
|
76
|
+
mobileKey && props.formCore?.fields?.[mobileKey]?.value != null
|
|
77
|
+
? String(props.formCore.fields[mobileKey].value)
|
|
78
|
+
: undefined
|
|
79
|
+
await host.sendVerifyCode({ item: props.item, mobile })
|
|
80
|
+
}
|
|
81
|
+
// 未注入宿主:只倒计时,不伪造成功发码
|
|
82
|
+
startCountdownOnly()
|
|
83
|
+
} catch (e: any) {
|
|
84
|
+
hostError.value = e?.message || '发送失败'
|
|
85
|
+
} finally {
|
|
86
|
+
sending.value = false
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onBeforeUnmount(clearTimer)
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<template>
|
|
94
|
+
<div class="ctrl-verify-wrap">
|
|
95
|
+
<div class="ctrl-verify">
|
|
96
|
+
<input
|
|
97
|
+
class="ctrl-verify-input"
|
|
98
|
+
type="text"
|
|
99
|
+
inputmode="numeric"
|
|
100
|
+
:value="localValue"
|
|
101
|
+
:placeholder="item.placeholder || '请输入验证码'"
|
|
102
|
+
:disabled="field?.disabled"
|
|
103
|
+
:maxlength="item.props?.maxlength || 6"
|
|
104
|
+
@input="onInput"
|
|
105
|
+
@blur="onBlur"
|
|
106
|
+
/>
|
|
107
|
+
<button
|
|
108
|
+
type="button"
|
|
109
|
+
class="ctrl-verify-btn"
|
|
110
|
+
:disabled="field?.disabled || counting || sending"
|
|
111
|
+
@click="onSend"
|
|
112
|
+
>
|
|
113
|
+
{{ btnLabel }}
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
<div v-if="hostError" class="ctrl-verify-error">{{ hostError }}</div>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
119
|
+
|
|
120
|
+
<style scoped>
|
|
121
|
+
.ctrl-verify-wrap { width: 100%; }
|
|
122
|
+
.ctrl-verify { display: flex; align-items: center; gap: 8px; width: 100%; }
|
|
123
|
+
.ctrl-verify-input {
|
|
124
|
+
flex: 1; min-width: 0; border: none; outline: none; background: transparent;
|
|
125
|
+
font-size: 13px; color: #333; line-height: 20px;
|
|
126
|
+
}
|
|
127
|
+
.ctrl-verify-input::placeholder { color: #bfbfbf; }
|
|
128
|
+
.ctrl-verify-input:disabled { color: #999; }
|
|
129
|
+
.ctrl-verify-btn {
|
|
130
|
+
flex-shrink: 0; border: none; background: transparent; color: #1989fa;
|
|
131
|
+
font-size: 13px; line-height: 20px; cursor: pointer; padding: 0;
|
|
132
|
+
}
|
|
133
|
+
.ctrl-verify-btn:disabled { color: #bfbfbf; cursor: not-allowed; }
|
|
134
|
+
.ctrl-verify-error { font-size: 11px; color: #e74c3c; margin-top: 4px; }
|
|
135
|
+
</style>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* API 内联 Task — 调用真实 API(优先)或 fallback 模拟
|
|
4
|
+
*/
|
|
5
|
+
import { ref, computed } from 'vue'
|
|
6
|
+
import type { FormItem } from '@agentprismform/core'
|
|
7
|
+
import { completeTask } from '@agentprismform/render-task'
|
|
8
|
+
import { getTaskHandlers } from '../../../taskHandlers'
|
|
9
|
+
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
item: FormItem
|
|
12
|
+
field: any
|
|
13
|
+
formCore: any
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const loading = ref(false)
|
|
17
|
+
const errorMsg = ref('')
|
|
18
|
+
|
|
19
|
+
const taskType = computed(() => (props.item.props as any)?.taskType as string || '')
|
|
20
|
+
const handler = computed(() => getTaskHandlers()[taskType.value])
|
|
21
|
+
|
|
22
|
+
async function open() {
|
|
23
|
+
if (loading.value) return
|
|
24
|
+
loading.value = true
|
|
25
|
+
errorMsg.value = ''
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
if (handler.value) {
|
|
29
|
+
// 真实 API 调用
|
|
30
|
+
const result = await handler.value(props.formCore, props.item.key)
|
|
31
|
+
loading.value = false
|
|
32
|
+
completeTask(props.formCore, props.item.key, {
|
|
33
|
+
...result,
|
|
34
|
+
_completed: true,
|
|
35
|
+
_completedAt: new Date().toISOString(),
|
|
36
|
+
})
|
|
37
|
+
} else {
|
|
38
|
+
// Fallback 模拟(未接入真实逻辑的 task)
|
|
39
|
+
await new Promise(r => setTimeout(r, 800))
|
|
40
|
+
loading.value = false
|
|
41
|
+
completeTask(props.formCore, props.item.key, {
|
|
42
|
+
code: '00',
|
|
43
|
+
data: { id: `mock_${Date.now()}`, name: `模拟${props.item.label}结果` },
|
|
44
|
+
_completed: true,
|
|
45
|
+
_completedAt: new Date().toISOString(),
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
} catch (e: any) {
|
|
49
|
+
loading.value = false
|
|
50
|
+
errorMsg.value = e?.message || '请求失败'
|
|
51
|
+
// 3 秒后清除错误
|
|
52
|
+
setTimeout(() => { errorMsg.value = '' }, 3000)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const hasValue = computed(() => {
|
|
57
|
+
const v = props.field?.value
|
|
58
|
+
return v && typeof v === 'object' && v._completed
|
|
59
|
+
})
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<div class="task-api" @click="open">
|
|
64
|
+
<div class="task-trigger" :class="{ completed: hasValue, loading: loading, error: !!errorMsg }">
|
|
65
|
+
<span class="task-icon">{{ loading ? '⏳' : errorMsg ? '⚠️' : '🔌' }}</span>
|
|
66
|
+
<span class="task-label">
|
|
67
|
+
<template v-if="loading">请求中...</template>
|
|
68
|
+
<template v-else-if="errorMsg">{{ errorMsg }}</template>
|
|
69
|
+
<template v-else-if="hasValue">✅ 已完成</template>
|
|
70
|
+
<template v-else>{{ item.placeholder || `点击获取${item.label}` }}</template>
|
|
71
|
+
</span>
|
|
72
|
+
<span v-if="loading" class="spinner" />
|
|
73
|
+
<span v-else class="task-arrow">▸</span>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<style scoped>
|
|
79
|
+
.task-api { user-select: none; }
|
|
80
|
+
.task-trigger {
|
|
81
|
+
display: flex; align-items: center; gap: 8px;
|
|
82
|
+
padding: 10px 12px; border: 1px solid #1890ff;
|
|
83
|
+
border-radius: 8px; background: #e6f7ff; cursor: pointer;
|
|
84
|
+
}
|
|
85
|
+
.task-trigger:active { background: #bae7ff; }
|
|
86
|
+
.task-trigger.completed { border-color: #52c41a; background: #f6ffed; }
|
|
87
|
+
.task-trigger.loading { opacity: 0.8; cursor: wait; }
|
|
88
|
+
.task-trigger.error { border-color: #e74c3c; background: #fff2f0; }
|
|
89
|
+
.task-icon { font-size: 18px; }
|
|
90
|
+
.task-label { flex: 1; font-size: 14px; color: #333; }
|
|
91
|
+
.task-arrow { color: #1890ff; font-size: 16px; font-weight: bold; }
|
|
92
|
+
|
|
93
|
+
.spinner {
|
|
94
|
+
width: 16px; height: 16px;
|
|
95
|
+
border: 2px solid #e6f7ff; border-top-color: #1890ff;
|
|
96
|
+
border-radius: 50%; animation: spin 0.8s linear infinite;
|
|
97
|
+
}
|
|
98
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
99
|
+
</style>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* SDK/本地 Task — 模拟调用设备能力(活体检测、人脸验证)
|
|
4
|
+
*/
|
|
5
|
+
import { ref, computed } from 'vue'
|
|
6
|
+
import type { FormItem } from '@agentprismform/core'
|
|
7
|
+
import { completeTask } from '@agentprismform/render-task'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
item: FormItem
|
|
11
|
+
field: any
|
|
12
|
+
formCore: any
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const loading = ref(false)
|
|
16
|
+
const progress = ref(0)
|
|
17
|
+
|
|
18
|
+
const taskType = computed(() => (props.item.props as any)?.taskType as string || '')
|
|
19
|
+
|
|
20
|
+
function open() {
|
|
21
|
+
if (loading.value) return
|
|
22
|
+
loading.value = true
|
|
23
|
+
progress.value = 0
|
|
24
|
+
|
|
25
|
+
// 模拟 SDK 检测过程
|
|
26
|
+
const timer = setInterval(() => {
|
|
27
|
+
progress.value += 20
|
|
28
|
+
if (progress.value >= 100) {
|
|
29
|
+
clearInterval(timer)
|
|
30
|
+
loading.value = false
|
|
31
|
+
completeTask(props.formCore, props.item.key, {
|
|
32
|
+
score: Math.floor(Math.random() * 30) + 70,
|
|
33
|
+
passed: true,
|
|
34
|
+
_completed: true,
|
|
35
|
+
_completedAt: new Date().toISOString(),
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
}, 400)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const hasValue = computed(() => {
|
|
42
|
+
const v = props.field?.value
|
|
43
|
+
return v && typeof v === 'object' && v._completed
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const icon = computed(() => taskType.value === 'face_verify_sign' ? '👤' : '📷')
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<div class="task-customer" @click="open">
|
|
51
|
+
<div class="task-trigger" :class="{ completed: hasValue, loading: loading }">
|
|
52
|
+
<span class="task-icon">{{ icon }}</span>
|
|
53
|
+
<span class="task-label">
|
|
54
|
+
{{ loading ? '检测中...' : (hasValue ? '✅ 已完成' : (item.placeholder || `点击启动${item.label}`)) }}
|
|
55
|
+
</span>
|
|
56
|
+
<span class="task-badge">SDK</span>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<!-- Progress overlay -->
|
|
60
|
+
<div v-if="loading" class="progress-bar">
|
|
61
|
+
<div class="progress-fill" :style="{ width: progress + '%' }" />
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<style scoped>
|
|
67
|
+
.task-customer { user-select: none; }
|
|
68
|
+
.task-trigger {
|
|
69
|
+
display: flex; align-items: center; gap: 8px;
|
|
70
|
+
padding: 10px 12px; border: 1px solid #52c41a;
|
|
71
|
+
border-radius: 8px; background: #f6ffed; cursor: pointer;
|
|
72
|
+
}
|
|
73
|
+
.task-trigger:active { background: #d9f7be; }
|
|
74
|
+
.task-trigger.completed { border-color: #52c41a; background: #f6ffed; }
|
|
75
|
+
.task-trigger.loading { opacity: 0.8; cursor: wait; }
|
|
76
|
+
.task-icon { font-size: 18px; }
|
|
77
|
+
.task-label { flex: 1; font-size: 14px; color: #333; }
|
|
78
|
+
.task-badge {
|
|
79
|
+
font-size: 10px; color: #fff; background: #52c41a;
|
|
80
|
+
padding: 2px 6px; border-radius: 8px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.progress-bar {
|
|
84
|
+
margin-top: 6px; height: 4px; background: #e8e8e8;
|
|
85
|
+
border-radius: 2px; overflow: hidden;
|
|
86
|
+
}
|
|
87
|
+
.progress-fill {
|
|
88
|
+
height: 100%; background: #52c41a;
|
|
89
|
+
border-radius: 2px; transition: width 0.3s ease;
|
|
90
|
+
}
|
|
91
|
+
</style>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* H5 跳转 Task — 模拟跳转到外部 H5 页面,模拟返回后回写
|
|
4
|
+
*/
|
|
5
|
+
import { ref, computed } from 'vue'
|
|
6
|
+
import type { FormItem } from '@agentprismform/core'
|
|
7
|
+
import { completeTask } from '@agentprismform/render-task'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
item: FormItem
|
|
11
|
+
field: any
|
|
12
|
+
formCore: any
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const showConfirm = ref(false)
|
|
16
|
+
|
|
17
|
+
const h5Url = computed(() => {
|
|
18
|
+
return (props.item.props as any)?.h5link
|
|
19
|
+
|| (props.item.props as any)?.taxLink
|
|
20
|
+
|| 'https://example.com/task'
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
function open() {
|
|
24
|
+
showConfirm.value = true
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function confirm() {
|
|
28
|
+
showConfirm.value = false
|
|
29
|
+
// 模拟:实际场景中 window.open / location.href 跳转,回来后回写
|
|
30
|
+
// Demo 里直接模拟一个返回结果
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
completeTask(props.formCore, props.item.key, {
|
|
33
|
+
url: h5Url.value,
|
|
34
|
+
_completed: true,
|
|
35
|
+
_completedAt: new Date().toISOString(),
|
|
36
|
+
_mock: '模拟 H5 跳转已返回',
|
|
37
|
+
})
|
|
38
|
+
}, 500)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function cancel() {
|
|
42
|
+
showConfirm.value = false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function onOverlayClick(e: MouseEvent, close: () => void) {
|
|
46
|
+
e.stopPropagation()
|
|
47
|
+
if (e.target === e.currentTarget) close()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const hasValue = computed(() => {
|
|
51
|
+
const v = props.field?.value
|
|
52
|
+
return v && typeof v === 'object' && v._completed
|
|
53
|
+
})
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<div class="task-h5" @click="open">
|
|
58
|
+
<div class="task-trigger" :class="{ completed: hasValue }">
|
|
59
|
+
<span class="task-icon">🌐</span>
|
|
60
|
+
<span class="task-label">{{ hasValue ? '✅ 已完成' : (item.placeholder || '点击跳转 H5 页面') }}</span>
|
|
61
|
+
<span class="task-badge">H5</span>
|
|
62
|
+
<span class="task-arrow">▸</span>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<!-- 确认弹窗 -->
|
|
66
|
+
<div v-if="showConfirm" class="modal-overlay" @click="onOverlayClick($event, cancel)">
|
|
67
|
+
<div class="confirm-card">
|
|
68
|
+
<div class="confirm-icon">🌐</div>
|
|
69
|
+
<div class="confirm-title">即将跳转到外部页面</div>
|
|
70
|
+
<div class="confirm-url">{{ h5Url }}</div>
|
|
71
|
+
<div class="confirm-hint">(Demo 模拟:实际将打开外部链接)</div>
|
|
72
|
+
<div class="confirm-actions">
|
|
73
|
+
<button class="btn-cancel" @click="cancel">取消</button>
|
|
74
|
+
<button class="btn-confirm" @click="confirm">确认跳转</button>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</template>
|
|
80
|
+
|
|
81
|
+
<style scoped>
|
|
82
|
+
.task-h5 { user-select: none; }
|
|
83
|
+
.task-trigger {
|
|
84
|
+
display: flex; align-items: center; gap: 8px;
|
|
85
|
+
padding: 10px 12px; border: 1px solid #13c2c2;
|
|
86
|
+
border-radius: 8px; background: #e6fffb; cursor: pointer;
|
|
87
|
+
}
|
|
88
|
+
.task-trigger:active { background: #b5f5ec; }
|
|
89
|
+
.task-trigger.completed { border-color: #52c41a; background: #f6ffed; }
|
|
90
|
+
.task-icon { font-size: 18px; }
|
|
91
|
+
.task-label { flex: 1; font-size: 14px; color: #333; }
|
|
92
|
+
.task-badge {
|
|
93
|
+
font-size: 10px; color: #fff; background: #13c2c2;
|
|
94
|
+
padding: 2px 6px; border-radius: 8px;
|
|
95
|
+
}
|
|
96
|
+
.task-arrow { color: #13c2c2; font-size: 16px; font-weight: bold; }
|
|
97
|
+
|
|
98
|
+
/* Confirm modal */
|
|
99
|
+
.modal-overlay {
|
|
100
|
+
position: fixed; inset: 0; background: rgba(0,0,0,0.45);
|
|
101
|
+
display: flex; align-items: center; justify-content: center;
|
|
102
|
+
z-index: 1000;
|
|
103
|
+
}
|
|
104
|
+
.confirm-card {
|
|
105
|
+
width: 300px; background: #fff; border-radius: 12px;
|
|
106
|
+
padding: 24px; text-align: center;
|
|
107
|
+
}
|
|
108
|
+
.confirm-icon { font-size: 40px; margin-bottom: 12px; }
|
|
109
|
+
.confirm-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
|
|
110
|
+
.confirm-url {
|
|
111
|
+
font-size: 12px; color: #999; word-break: break-all;
|
|
112
|
+
margin-bottom: 8px; background: #f5f5f5; padding: 6px 10px;
|
|
113
|
+
border-radius: 4px;
|
|
114
|
+
}
|
|
115
|
+
.confirm-hint { font-size: 11px; color: #faad14; margin-bottom: 20px; }
|
|
116
|
+
.confirm-actions { display: flex; gap: 12px; }
|
|
117
|
+
.btn-cancel {
|
|
118
|
+
flex: 1; padding: 10px; border: 1px solid #d9d9d9;
|
|
119
|
+
border-radius: 8px; background: #fff; font-size: 14px; cursor: pointer;
|
|
120
|
+
}
|
|
121
|
+
.btn-confirm {
|
|
122
|
+
flex: 1; padding: 10px; border: none; border-radius: 8px;
|
|
123
|
+
background: #13c2c2; color: #fff; font-size: 14px; cursor: pointer;
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* inline 内联 Task — 特殊内联操作(如复制链接)
|
|
4
|
+
*/
|
|
5
|
+
import { ref, computed } from 'vue'
|
|
6
|
+
import type { FormItem } from '@agentprismform/core'
|
|
7
|
+
import { completeTask } from '@agentprismform/render-task'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{
|
|
10
|
+
item: FormItem
|
|
11
|
+
field: any
|
|
12
|
+
formCore: any
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const showConfirm = ref(false)
|
|
16
|
+
const link = computed(() => (props.item.props as any)?.taxLink || `https://tax.example.com/copy?id=${Date.now()}`)
|
|
17
|
+
|
|
18
|
+
function open() {
|
|
19
|
+
showConfirm.value = true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function confirm() {
|
|
23
|
+
showConfirm.value = false
|
|
24
|
+
// 模拟复制链接
|
|
25
|
+
navigator.clipboard?.writeText(link.value).catch(() => {})
|
|
26
|
+
completeTask(props.formCore, props.item.key, {
|
|
27
|
+
copied: true,
|
|
28
|
+
url: link.value,
|
|
29
|
+
_completed: true,
|
|
30
|
+
_completedAt: new Date().toISOString(),
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function cancel() {
|
|
35
|
+
showConfirm.value = false
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function onOverlayClick(e: MouseEvent, close: () => void) {
|
|
39
|
+
e.stopPropagation()
|
|
40
|
+
if (e.target === e.currentTarget) close()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const hasValue = computed(() => {
|
|
44
|
+
const v = props.field?.value
|
|
45
|
+
return v && typeof v === 'object' && v._completed
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<div class="task-inline" @click="open">
|
|
51
|
+
<div class="task-trigger" :class="{ completed: hasValue }">
|
|
52
|
+
<span class="task-icon">🔗</span>
|
|
53
|
+
<span class="task-label">{{ hasValue ? '✅ 已复制' : (item.placeholder || '复制链接') }}</span>
|
|
54
|
+
<span class="task-badge">inline</span>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<!-- Confirm -->
|
|
58
|
+
<div v-if="showConfirm" class="modal-overlay" @click="onOverlayClick($event, cancel)">
|
|
59
|
+
<div class="inline-card">
|
|
60
|
+
<div class="inline-icon">🔗</div>
|
|
61
|
+
<div class="inline-title">复制链接</div>
|
|
62
|
+
<div class="inline-link">{{ link }}</div>
|
|
63
|
+
<div class="inline-hint">(Demo 模拟:实际将复制并跳转)</div>
|
|
64
|
+
<div class="inline-actions">
|
|
65
|
+
<button class="btn-cancel" @click="cancel">取消</button>
|
|
66
|
+
<button class="btn-confirm" @click="confirm">复制并完成</button>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
<style scoped>
|
|
74
|
+
.task-inline { user-select: none; }
|
|
75
|
+
.task-trigger {
|
|
76
|
+
display: flex; align-items: center; gap: 8px;
|
|
77
|
+
padding: 10px 12px; border: 1px solid #595959;
|
|
78
|
+
border-radius: 8px; background: #fafafa; cursor: pointer;
|
|
79
|
+
}
|
|
80
|
+
.task-trigger:active { background: #f0f0f0; }
|
|
81
|
+
.task-trigger.completed { border-color: #52c41a; background: #f6ffed; }
|
|
82
|
+
.task-icon { font-size: 18px; }
|
|
83
|
+
.task-label { flex: 1; font-size: 14px; color: #333; }
|
|
84
|
+
.task-badge {
|
|
85
|
+
font-size: 10px; color: #fff; background: #595959;
|
|
86
|
+
padding: 2px 6px; border-radius: 8px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Modal */
|
|
90
|
+
.modal-overlay {
|
|
91
|
+
position: fixed; inset: 0; background: rgba(0,0,0,0.45);
|
|
92
|
+
display: flex; align-items: center; justify-content: center;
|
|
93
|
+
z-index: 1000;
|
|
94
|
+
}
|
|
95
|
+
.inline-card {
|
|
96
|
+
width: 280px; background: #fff; border-radius: 12px;
|
|
97
|
+
padding: 24px; text-align: center;
|
|
98
|
+
}
|
|
99
|
+
.inline-icon { font-size: 40px; margin-bottom: 12px; }
|
|
100
|
+
.inline-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
|
|
101
|
+
.inline-link {
|
|
102
|
+
font-size: 12px; color: #999; word-break: break-all;
|
|
103
|
+
margin-bottom: 8px; background: #f5f5f5; padding: 6px 10px;
|
|
104
|
+
border-radius: 4px;
|
|
105
|
+
}
|
|
106
|
+
.inline-hint { font-size: 11px; color: #faad14; margin-bottom: 20px; }
|
|
107
|
+
.inline-actions { display: flex; gap: 12px; }
|
|
108
|
+
.btn-cancel {
|
|
109
|
+
flex: 1; padding: 10px; border: 1px solid #d9d9d9;
|
|
110
|
+
border-radius: 8px; background: #fff; font-size: 14px; cursor: pointer;
|
|
111
|
+
}
|
|
112
|
+
.btn-confirm {
|
|
113
|
+
flex: 1; padding: 10px; border: none; border-radius: 8px;
|
|
114
|
+
background: #595959; color: #fff; font-size: 14px; cursor: pointer;
|
|
115
|
+
}
|
|
116
|
+
</style>
|