You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

365 lines
11 KiB

<template>
<div class="mod-config">
<!-- 查询表单 - rqrq -->
<el-form :inline="true" label-position="top" style="margin-top: 1px; margin-left: 0px;">
<el-form-item label="工厂编码">
<el-input v-model="queryData.site" style="width: 120px" placeholder="工厂编码" clearable @keyup.enter.native="getDataList()"></el-input>
</el-form-item>
<el-form-item label="白名单关键词">
<el-input v-model="queryData.searchErrorDesc" style="width: 200px" placeholder="白名单关键词" clearable @keyup.enter.native="getDataList()"></el-input>
</el-form-item>
<el-form-item label="是否启用">
<el-select v-model="queryData.active" style="width: 120px" placeholder="全部" clearable>
<el-option label="启用" value="Y"></el-option>
<el-option label="禁用" value="N"></el-option>
</el-select>
</el-form-item>
<el-form-item label=" ">
<el-button type="primary" @click="getDataList()">查询</el-button>
<el-button @click="resetQuery()">重置</el-button>
<el-button type="primary" class="yzzButtonAn" @click="addConfig()">新增白名单</el-button>
</el-form-item>
</el-form>
<!-- 数据表格 - rqrq -->
<el-table
:data="dataList"
:height="height"
border
highlight-current-row
v-loading="dataListLoading"
style="width: 100%;">
<el-table-column
prop="id"
header-align="center"
align="center"
label="ID"
width="80">
</el-table-column>
<el-table-column
prop="site"
header-align="center"
align="center"
label="工厂编码"
width="100">
</el-table-column>
<el-table-column
prop="errorDesc"
header-align="center"
align="left"
label="白名单关键词(可忽略的错误)"
min-width="200"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="active"
header-align="center"
align="center"
label="是否启用"
width="100">
<template slot-scope="scope">
<el-tag
:type="scope.row.active === 'Y' ? 'success' : 'danger'"
size="small">
{{ scope.row.active === 'Y' ? '启用' : '禁用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column
prop="remark"
header-align="center"
align="left"
label="备注"
min-width="200"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="createdBy"
header-align="center"
align="center"
label="创建人"
width="100">
</el-table-column>
<el-table-column
prop="createdTime"
header-align="center"
align="center"
label="创建时间"
width="160">
</el-table-column>
<!-- 操作列 - rqrq -->
<el-table-column
header-align="center"
align="center"
fixed="right"
width="150"
label="操作">
<template slot-scope="scope">
<a type="text" @click="editConfig(scope.row)">修改</a>
<a type="text" @click="deleteConfig(scope.row)" style="margin-left: 10px;">删除</a>
</template>
</el-table-column>
</el-table>
<!-- 分页 - rqrq -->
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 1000]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 新增/修改弹窗 - rqrq -->
<el-dialog
:title="dialogTitle"
:visible.sync="dialogVisible"
:close-on-click-modal="false"
v-drag
width="700px">
<el-form :model="formData" :rules="formRules" ref="configForm" label-position="top" style="margin-top: 1px; margin-left: 0px;">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="工厂编码" prop="site">
<el-input v-model="formData.site" placeholder="请输入工厂编码"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否启用" prop="active">
<el-select v-model="formData.active" placeholder="请选择" style="width: 100%">
<el-option label="启用" value="Y"></el-option>
<el-option label="禁用" value="N"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="白名单关键词(配置可忽略的普通错误)" prop="errorDesc">
<el-input v-model="formData.errorDesc" placeholder="请输入白名单关键词(如:用户输入错误、格式不正确)"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="备注说明">
<el-input v-model="formData.remark" type="textarea" :rows="3" resize='none' placeholder="请输入备注说明(如:该错误属于正常业务场景,可忽略)"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer" style="margin-top: 52px">
<el-button type="primary" @click="saveConfig" :disabled="saveLoading">
{{ saveLoading ? '保存中...' : '确定' }}
</el-button>
<el-button @click="dialogVisible = false" :disabled="saveLoading">取消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getImportantErrorConfigList,
addImportantErrorConfig,
updateImportantErrorConfig,
deleteImportantErrorConfig
} from '@/api/system/importantErrorConfig.js'
export default {
data() {
return {
// 查询条件 - rqrq
queryData: {
site: this.$store.state.user.site,
searchErrorDesc: '',
active: '',
page: 1,
limit: 20
},
// 表格高度 - rqrq
height: 450,
// 数据列表 - rqrq
dataList: [],
// 分页参数 - rqrq
pageIndex: 1,
pageSize: 20,
totalPage: 0,
dataListLoading: false,
// 弹窗相关 - rqrq
dialogVisible: false,
dialogTitle: '',
dialogType: '', // add 或 edit
formData: {},
formRules: {
site: [
{ required: true, message: '请输入工厂编码', trigger: 'blur' }
],
errorDesc: [
{ required: true, message: '请输入白名单关键词', trigger: 'blur' }
],
active: [
{ required: true, message: '请选择是否启用', trigger: 'change' }
]
},
saveLoading: false,
deleteLoading: false
}
},
mounted() {
this.$nextTick(() => {
// 计算表格高度 - rqrq
this.height = window.innerHeight - 220;
})
},
activated() {
this.getDataList()
},
methods: {
// 获取数据列表 - rqrq
getDataList() {
this.dataListLoading = true
this.queryData.page = this.pageIndex
this.queryData.limit = this.pageSize
getImportantErrorConfigList(this.queryData).then(({data}) => {
this.dataListLoading = false
if (data && data.code === 0) {
this.dataList = data.page.list || []
this.totalPage = data.page.totalCount || 0
} else {
this.dataList = []
this.totalPage = 0
this.$alert(data.msg || '查询失败', '错误', { confirmButtonText: '确定' })
}
}).catch(error => {
this.dataListLoading = false
console.error('查询错误白名单列表失败:', error)
this.$alert('查询失败', '错误', { confirmButtonText: '确定' })
})
},
// 重置查询条件 - rqrq
resetQuery() {
this.queryData = {
site: this.$store.state.user.site,
searchErrorDesc: '',
active: '',
page: 1,
limit: 20
}
this.pageIndex = 1
this.getDataList()
},
// 每页数量变化 - rqrq
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页变化 - rqrq
currentChangeHandle(val) {
this.pageIndex = val
this.getDataList()
},
// 新增配置 - rqrq
addConfig() {
this.dialogTitle = '新增错误白名单'
this.dialogType = 'add'
this.formData = {
site: this.$store.state.user.site ,
errorDesc: '',
active: 'Y',
remark: ''
}
this.dialogVisible = true
this.$nextTick(() => {
this.$refs.configForm.clearValidate()
})
},
// 修改配置 - rqrq
editConfig(row) {
this.dialogTitle = '修改错误白名单'
this.dialogType = 'edit'
this.formData = Object.assign({}, row)
this.dialogVisible = true
this.$nextTick(() => {
this.$refs.configForm.clearValidate()
})
},
// 保存配置 - rqrq
saveConfig() {
this.$refs.configForm.validate((valid) => {
if (!valid) {
return
}
this.saveLoading = true
const apiMethod = this.dialogType === 'add' ? addImportantErrorConfig : updateImportantErrorConfig
apiMethod(this.formData).then(({data}) => {
if (data && data.code === 0) {
this.$message.success(this.dialogType === 'add' ? '新增成功' : '修改成功')
this.dialogVisible = false
this.getDataList()
} else {
this.$alert(data.msg || '操作失败', '错误')
}
}).catch(error => {
console.error('保存错误白名单失败:', error)
this.$alert('保存失败', '错误', { confirmButtonText: '确定' })
}).finally(() => {
this.saveLoading = false
})
})
},
// 删除配置 - rqrq
deleteConfig(row) {
// 二次确认 - rqrq
this.$confirm(`确定要删除白名单 "${row.errorDesc}" 吗?删除后该类错误将被标记为重要错误`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.deleteLoading = true
deleteImportantErrorConfig({ id: row.id }).then(({data}) => {
if (data && data.code === 0) {
this.$message.success('删除成功')
this.getDataList()
} else {
this.$alert(data.msg || '删除失败', '错误')
}
}).catch(error => {
console.error('删除错误白名单失败:', error)
this.$message.error('删除失败')
}).finally(() => {
this.deleteLoading = false
})
}).catch(() => {
// 用户取消删除 - rqrq
})
}
}
}
</script>
<style scoped>
/* 表格样式优化 - rqrq */
.mod-config {
padding: 10px;
}
</style>