refactor(l2): 统一请求工具引用并优化模板字段过滤逻辑
统一将多个文件中的请求工具引用从不同路径改为'@/utils/request' 优化模板字段过滤逻辑,支持多种enabled值类型 重构样式代码为多行格式提高可读性
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import request from '@/utils/L2Request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 创建发送任务
|
// 创建发送任务
|
||||||
export function createSendJob(data) {
|
export function createSendJob(data) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import request from '@/utils/L2Request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 获取发送模板(含明细)
|
// 获取发送模板(含明细)
|
||||||
export function getSendTemplate(templateCode) {
|
export function getSendTemplate(templateCode) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import request from '@/utils/L2Request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 获取 DRIVE 设定值(最新成功发送)
|
// 获取 DRIVE 设定值(最新成功发送)
|
||||||
export function getDriveSetupValue() {
|
export function getDriveSetupValue() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import request from '@/utils/l2-request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按模板编码查询发送模板(含明细)
|
* 按模板编码查询发送模板(含明细)
|
||||||
|
|||||||
@@ -7,57 +7,26 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
<!-- 编辑模板开关 -->
|
<!-- 编辑模板开关 -->
|
||||||
<el-switch
|
<el-switch v-model="editTemplate" active-text="编辑模板" inactive-text="查看模式" style="margin: 0 12px" />
|
||||||
v-model="editTemplate"
|
|
||||||
active-text="编辑模板"
|
|
||||||
inactive-text="查看模式"
|
|
||||||
style="margin: 0 12px"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<el-button
|
<el-button v-if="editTemplate" type="success" plain icon="el-icon-check" size="small" :loading="savingTemplate"
|
||||||
v-if="editTemplate"
|
@click="saveTemplate">
|
||||||
type="success"
|
|
||||||
plain
|
|
||||||
icon="el-icon-check"
|
|
||||||
size="small"
|
|
||||||
:loading="savingTemplate"
|
|
||||||
@click="saveTemplate"
|
|
||||||
>
|
|
||||||
保存模板
|
保存模板
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
<el-button
|
<el-button v-if="lastSuccess && lastSuccess.lastSendTime" type="primary" plain icon="el-icon-magic-stick"
|
||||||
v-if="lastSuccess && lastSuccess.lastSendTime"
|
size="small" @click="applyLastSuccessValues">
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
icon="el-icon-magic-stick"
|
|
||||||
size="small"
|
|
||||||
@click="applyLastSuccessValues"
|
|
||||||
>
|
|
||||||
应用上次成功参数
|
应用上次成功参数
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
<el-button
|
<el-button type="info" plain icon="el-icon-time" size="small" @click="openHistory">
|
||||||
type="info"
|
|
||||||
plain
|
|
||||||
icon="el-icon-time"
|
|
||||||
size="small"
|
|
||||||
@click="openHistory"
|
|
||||||
>
|
|
||||||
历史记录
|
历史记录
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 历史浮动面板 -->
|
<!-- 历史浮动面板 -->
|
||||||
<FloatingPanel
|
<FloatingPanel ref="historyPanel" title="炉火下发历史" storageKey="FURNACE_SEND_HISTORY_PANEL" :defaultW="980"
|
||||||
ref="historyPanel"
|
:defaultH="520" :defaultX="30" :defaultY="60">
|
||||||
title="炉火下发历史"
|
|
||||||
storageKey="FURNACE_SEND_HISTORY_PANEL"
|
|
||||||
:defaultW="980"
|
|
||||||
:defaultH="520"
|
|
||||||
:defaultX="30"
|
|
||||||
:defaultY="60"
|
|
||||||
>
|
|
||||||
<FurnaceHistoryPanel @apply="applyHistoryValues" />
|
<FurnaceHistoryPanel @apply="applyHistoryValues" />
|
||||||
</FloatingPanel>
|
</FloatingPanel>
|
||||||
|
|
||||||
@@ -71,13 +40,7 @@
|
|||||||
<i class="el-icon-time"></i>
|
<i class="el-icon-time"></i>
|
||||||
上次下发:{{ formatTime(lastSuccess.lastSendTime) }}
|
上次下发:{{ formatTime(lastSuccess.lastSendTime) }}
|
||||||
</span>
|
</span>
|
||||||
<el-button
|
<el-button type="primary" size="mini" icon="el-icon-s-promotion" @click="handleSend" :loading="sending">
|
||||||
type="primary"
|
|
||||||
size="mini"
|
|
||||||
icon="el-icon-s-promotion"
|
|
||||||
@click="handleSend"
|
|
||||||
:loading="sending"
|
|
||||||
>
|
|
||||||
下发
|
下发
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -86,11 +49,7 @@
|
|||||||
<!-- 按模板渲染可编辑表单 -->
|
<!-- 按模板渲染可编辑表单 -->
|
||||||
<el-form :model="form" label-position="top" size="mini">
|
<el-form :model="form" label-position="top" size="mini">
|
||||||
<div class="group-list">
|
<div class="group-list">
|
||||||
<div
|
<div v-for="group in groupedItems" :key="group.groupKey" class="group-section">
|
||||||
v-for="group in groupedItems"
|
|
||||||
:key="group.groupKey"
|
|
||||||
class="group-section"
|
|
||||||
>
|
|
||||||
<div class="group-header">
|
<div class="group-header">
|
||||||
<span class="group-title">{{ group.groupTitle }}</span>
|
<span class="group-title">{{ group.groupTitle }}</span>
|
||||||
<span class="group-count">({{ group.items.length }} 项)</span>
|
<span class="group-count">({{ group.items.length }} 项)</span>
|
||||||
@@ -98,17 +57,10 @@
|
|||||||
|
|
||||||
<!-- 每行三个输入框 -->
|
<!-- 每行三个输入框 -->
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col
|
<el-col :span="8" v-for="item in group.items" :key="item.templateItemId || item.paramCode">
|
||||||
:span="8"
|
|
||||||
v-for="item in group.items"
|
|
||||||
:key="item.templateItemId || item.paramCode"
|
|
||||||
>
|
|
||||||
<el-form-item :label="item.labelEn">
|
<el-form-item :label="item.labelEn">
|
||||||
<el-input
|
<el-input v-model="form[item.paramCode]" :placeholder="getPlaceholder(item)"
|
||||||
v-model="form[item.paramCode]"
|
:class="{ 'is-changed': isChangedFromLast(item) }" />
|
||||||
:placeholder="getPlaceholder(item)"
|
|
||||||
:class="{ 'is-changed': isChangedFromLast(item) }"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 辅助信息:上次/默认值(常驻,不会像 placeholder 一样消失) -->
|
<!-- 辅助信息:上次/默认值(常驻,不会像 placeholder 一样消失) -->
|
||||||
<div class="field-hint">
|
<div class="field-hint">
|
||||||
@@ -176,8 +128,17 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
templateItems() {
|
templateItems() {
|
||||||
if (!this.template || !Array.isArray(this.template.items)) return []
|
if (!this.template || !Array.isArray(this.template.items)) return []
|
||||||
|
// 后端 enabled 可能是 1/0、"1"/"0"、true/false,避免被错误过滤导致页面无字段
|
||||||
return [...this.template.items]
|
return [...this.template.items]
|
||||||
.filter(i => i.enabled === undefined || i.enabled === 1)
|
.filter(i => {
|
||||||
|
const en = i && i.enabled
|
||||||
|
// 未提供 enabled:默认展示
|
||||||
|
if (en === undefined || en === null || en === '') return true
|
||||||
|
// 明确禁用:0/"0"/false
|
||||||
|
if (en === 0 || en === false) return false
|
||||||
|
if (String(en) === '0') return false
|
||||||
|
return true
|
||||||
|
})
|
||||||
.sort((a, b) => (a.itemNo || 0) - (b.itemNo || 0))
|
.sort((a, b) => (a.itemNo || 0) - (b.itemNo || 0))
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -427,7 +388,7 @@ export default {
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.doSend()
|
this.doSend()
|
||||||
}).catch(() => {})
|
}).catch(() => { })
|
||||||
},
|
},
|
||||||
|
|
||||||
async doSend() {
|
async doSend() {
|
||||||
@@ -499,23 +460,88 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.page-title { margin-bottom: 20px; }
|
.page-title {
|
||||||
.toolbar { margin-bottom: 20px; display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
|
margin-bottom: 20px;
|
||||||
.card-grid-container { min-height: 300px; }
|
}
|
||||||
.parameter-card .card-header { display:flex; justify-content:space-between; align-items:center; }
|
|
||||||
.card-title { font-weight: 600; }
|
|
||||||
.header-right { display:flex; align-items:center; }
|
|
||||||
.last-send-time { font-size: 12px; color:#909399; margin-right:16px; }
|
|
||||||
.empty-data { margin-top: 20px; }
|
|
||||||
.addr-inline { margin-top: 6px; }
|
|
||||||
.addr-label { display:inline-block; margin-right:6px; color:#909399; font-size:12px; }
|
|
||||||
|
|
||||||
.group-list { margin-top: 8px; }
|
.toolbar {
|
||||||
.group-section { padding: 10px 0 6px; border-top: 1px solid #ebeef5; }
|
margin-bottom: 20px;
|
||||||
.group-section:first-child { border-top: none; padding-top: 0; }
|
display: flex;
|
||||||
.group-header { display:flex; align-items:baseline; gap:8px; margin: 4px 0 10px; }
|
flex-wrap: wrap;
|
||||||
.group-title { font-weight: 600; }
|
gap: 8px;
|
||||||
.group-count { color:#909399; font-size: 12px; margin-left: 6px; }
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-grid-container {
|
||||||
|
min-height: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.parameter-card .card-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-title {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-right {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.last-send-time {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
margin-right: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-data {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addr-inline {
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addr-label {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 6px;
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-list {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-section {
|
||||||
|
padding: 10px 0 6px;
|
||||||
|
border-top: 1px solid #ebeef5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-section:first-child {
|
||||||
|
border-top: none;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 8px;
|
||||||
|
margin: 4px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-title {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-count {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
/* 字段提示信息 */
|
/* 字段提示信息 */
|
||||||
.field-hint {
|
.field-hint {
|
||||||
|
|||||||
Reference in New Issue
Block a user