refactor(l2): 统一请求工具引用并优化模板字段过滤逻辑
统一将多个文件中的请求工具引用从不同路径改为'@/utils/request' 优化模板字段过滤逻辑,支持多种enabled值类型 重构样式代码为多行格式提高可读性
This commit is contained in:
@@ -7,57 +7,26 @@
|
||||
</el-button>
|
||||
|
||||
<!-- 编辑模板开关 -->
|
||||
<el-switch
|
||||
v-model="editTemplate"
|
||||
active-text="编辑模板"
|
||||
inactive-text="查看模式"
|
||||
style="margin: 0 12px"
|
||||
/>
|
||||
<el-switch v-model="editTemplate" active-text="编辑模板" inactive-text="查看模式" style="margin: 0 12px" />
|
||||
|
||||
<el-button
|
||||
v-if="editTemplate"
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-check"
|
||||
size="small"
|
||||
:loading="savingTemplate"
|
||||
@click="saveTemplate"
|
||||
>
|
||||
<el-button v-if="editTemplate" type="success" plain icon="el-icon-check" size="small" :loading="savingTemplate"
|
||||
@click="saveTemplate">
|
||||
保存模板
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
v-if="lastSuccess && lastSuccess.lastSendTime"
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-magic-stick"
|
||||
size="small"
|
||||
@click="applyLastSuccessValues"
|
||||
>
|
||||
<el-button v-if="lastSuccess && lastSuccess.lastSendTime" type="primary" plain icon="el-icon-magic-stick"
|
||||
size="small" @click="applyLastSuccessValues">
|
||||
应用上次成功参数
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="el-icon-time"
|
||||
size="small"
|
||||
@click="openHistory"
|
||||
>
|
||||
<el-button type="info" plain icon="el-icon-time" size="small" @click="openHistory">
|
||||
历史记录
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 历史浮动面板 -->
|
||||
<FloatingPanel
|
||||
ref="historyPanel"
|
||||
title="炉火下发历史"
|
||||
storageKey="FURNACE_SEND_HISTORY_PANEL"
|
||||
:defaultW="980"
|
||||
:defaultH="520"
|
||||
:defaultX="30"
|
||||
:defaultY="60"
|
||||
>
|
||||
<FloatingPanel ref="historyPanel" title="炉火下发历史" storageKey="FURNACE_SEND_HISTORY_PANEL" :defaultW="980"
|
||||
:defaultH="520" :defaultX="30" :defaultY="60">
|
||||
<FurnaceHistoryPanel @apply="applyHistoryValues" />
|
||||
</FloatingPanel>
|
||||
|
||||
@@ -71,13 +40,7 @@
|
||||
<i class="el-icon-time"></i>
|
||||
上次下发:{{ formatTime(lastSuccess.lastSendTime) }}
|
||||
</span>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="mini"
|
||||
icon="el-icon-s-promotion"
|
||||
@click="handleSend"
|
||||
:loading="sending"
|
||||
>
|
||||
<el-button type="primary" size="mini" icon="el-icon-s-promotion" @click="handleSend" :loading="sending">
|
||||
下发
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -86,11 +49,7 @@
|
||||
<!-- 按模板渲染可编辑表单 -->
|
||||
<el-form :model="form" label-position="top" size="mini">
|
||||
<div class="group-list">
|
||||
<div
|
||||
v-for="group in groupedItems"
|
||||
:key="group.groupKey"
|
||||
class="group-section"
|
||||
>
|
||||
<div v-for="group in groupedItems" :key="group.groupKey" class="group-section">
|
||||
<div class="group-header">
|
||||
<span class="group-title">{{ group.groupTitle }}</span>
|
||||
<span class="group-count">({{ group.items.length }} 项)</span>
|
||||
@@ -98,17 +57,10 @@
|
||||
|
||||
<!-- 每行三个输入框 -->
|
||||
<el-row :gutter="20">
|
||||
<el-col
|
||||
:span="8"
|
||||
v-for="item in group.items"
|
||||
:key="item.templateItemId || item.paramCode"
|
||||
>
|
||||
<el-col :span="8" v-for="item in group.items" :key="item.templateItemId || item.paramCode">
|
||||
<el-form-item :label="item.labelEn">
|
||||
<el-input
|
||||
v-model="form[item.paramCode]"
|
||||
:placeholder="getPlaceholder(item)"
|
||||
:class="{ 'is-changed': isChangedFromLast(item) }"
|
||||
/>
|
||||
<el-input v-model="form[item.paramCode]" :placeholder="getPlaceholder(item)"
|
||||
:class="{ 'is-changed': isChangedFromLast(item) }" />
|
||||
|
||||
<!-- 辅助信息:上次/默认值(常驻,不会像 placeholder 一样消失) -->
|
||||
<div class="field-hint">
|
||||
@@ -176,8 +128,17 @@ export default {
|
||||
computed: {
|
||||
templateItems() {
|
||||
if (!this.template || !Array.isArray(this.template.items)) return []
|
||||
// 后端 enabled 可能是 1/0、"1"/"0"、true/false,避免被错误过滤导致页面无字段
|
||||
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))
|
||||
},
|
||||
|
||||
@@ -427,7 +388,7 @@ export default {
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.doSend()
|
||||
}).catch(() => {})
|
||||
}).catch(() => { })
|
||||
},
|
||||
|
||||
async doSend() {
|
||||
@@ -499,23 +460,88 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-title { margin-bottom: 20px; }
|
||||
.toolbar { margin-bottom: 20px; display:flex; flex-wrap:wrap; gap:8px; 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; }
|
||||
.page-title {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.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; }
|
||||
.toolbar {
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user