From d57f812513fc311b7952f244e578ac84991b2a51 Mon Sep 17 00:00:00 2001 From: Admin Date: Wed, 28 Jan 2026 17:52:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=20UI=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 脚本编辑:增加全屏编辑按钮,打开大弹窗编辑 2. 执行时间:改为时间选择器 + 标签方式,支持可视化添加多个时间点 3. 任务参数:改为 Key-Value 表格形式,支持添加/删除,更直观 --- frontend/src/views/scheduled-tasks/index.vue | 218 ++++++++++++++++--- 1 file changed, 188 insertions(+), 30 deletions(-) diff --git a/frontend/src/views/scheduled-tasks/index.vue b/frontend/src/views/scheduled-tasks/index.vue index a0074d9..c5af34b 100644 --- a/frontend/src/views/scheduled-tasks/index.vue +++ b/frontend/src/views/scheduled-tasks/index.vue @@ -97,9 +97,17 @@ const testLoading = ref(false) const testResult = ref(null) const testParams = ref('{}') -// 参数编辑 +// 参数编辑(key-value-remark 列表) const paramsDialogVisible = ref(false) const paramsJson = ref('{}') +const paramsList = ref([]) // [{key: '', value: '', remark: ''}] + +// 脚本全屏编辑 +const scriptDialogVisible = ref(false) +const scriptContent = ref('') + +// 时间点选择 +const newTimePoint = ref('09:00') // 计算属性 const timePointsStr = computed({ @@ -382,18 +390,63 @@ function showTestDialog() { } function showParamsDialog() { - paramsJson.value = JSON.stringify(form.input_params || {}, null, 2) + // 将 input_params 转换为列表格式 + const params = form.input_params || {} + paramsList.value = Object.entries(params).map(([key, val]) => { + if (typeof val === 'object' && val !== null && 'value' in val) { + return { key, value: val.value, remark: val.remark || '' } + } + return { key, value: val, remark: '' } + }) + if (paramsList.value.length === 0) { + paramsList.value.push({ key: '', value: '', remark: '' }) + } paramsDialogVisible.value = true } +function addParam() { + paramsList.value.push({ key: '', value: '', remark: '' }) +} + +function removeParam(index) { + paramsList.value.splice(index, 1) +} + function saveParams() { - try { - form.input_params = JSON.parse(paramsJson.value) - paramsDialogVisible.value = false - ElMessage.success('参数已保存') - } catch (e) { - ElMessage.error('JSON 格式错误') + // 将列表转换为对象 + const params = {} + for (const item of paramsList.value) { + if (item.key) { + params[item.key] = item.value + } } + form.input_params = params + paramsDialogVisible.value = false + ElMessage.success('参数已保存') +} + +// 脚本全屏编辑 +function showScriptDialog() { + scriptContent.value = form.script_content + scriptDialogVisible.value = true +} + +function saveScript() { + form.script_content = scriptContent.value + scriptDialogVisible.value = false + ElMessage.success('脚本已保存') +} + +// 时间点管理 +function addTimePoint() { + if (newTimePoint.value && !form.time_points.includes(newTimePoint.value)) { + form.time_points.push(newTimePoint.value) + form.time_points.sort() + } +} + +function removeTimePoint(index) { + form.time_points.splice(index, 1) } function getTenantName(tenantId) { @@ -547,8 +600,31 @@ onMounted(() => { - -
多个时间点用逗号分隔,格式: HH:MM
+
+
+ + {{ tp }} + +
+
+ + 添加 +
+
+
点击添加按钮增加执行时间点
@@ -574,28 +650,35 @@ onMounted(() => {
SDK 文档 + + + 全屏编辑 + 测试运行
- - - -
- {{ JSON.stringify(form.input_params) }} - 编辑参数 +
+ 暂无参数 +
+
+ + {{ key }}: {{ String(val).substring(0, 20) }}{{ String(val).length > 20 ? '...' : '' }} + +
+ 编辑参数
脚本中使用 get_param('key') 获取
@@ -800,16 +883,66 @@ onMounted(() => { - - -
- JSON 格式,脚本中使用 get_param('key') 获取 + +
+ + + + + + + + + + + + + + +
+ + + 添加参数 + +
+
+
+ 脚本中使用 get_param('key')get_param('key', '默认值') 获取参数
+ + + +
+ SDK 文档 + + 提示: 内置模块无需 import,直接使用 datetime.now()、json.dumps() 等 + +
+ + +
@@ -866,24 +999,49 @@ onMounted(() => { line-height: 1.5; } +.script-textarea-fullscreen :deep(textarea) { + font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; + font-size: 14px; + line-height: 1.6; +} + +.script-fullscreen-toolbar { + display: flex; + align-items: center; + margin-bottom: 12px; +} + +.time-points-container { + width: 100%; +} + +.time-points-list { + min-height: 32px; + margin-bottom: 8px; +} + +.time-points-add { + display: flex; + gap: 8px; + align-items: center; +} + .params-preview { display: flex; align-items: center; gap: 12px; + flex-wrap: wrap; } -.params-preview code { +.params-tags { flex: 1; - padding: 8px 12px; - background: #f5f7fa; - border-radius: 4px; - font-size: 12px; - max-width: 400px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; } +.params-table { + min-height: 200px; +} + + .output-preview, .error-preview { cursor: pointer; font-size: 12px;