| | |
| | | <template> |
| | | <div class="alarm-handle-knowledge"> |
| | | <el-card shadow="never" class="search-card"> |
| | | <el-form :inline="true" :model="searchForm" class="demo-form-inline"> |
| | | <el-form-item label="知识库标题"> |
| | | <el-input v-model="searchForm.title" placeholder="请输入知识库标题" /> |
| | | </el-form-item> |
| | | <el-form-item label="报警类型"> |
| | | <el-select v-model="searchForm.alarmType" placeholder="请选择报警类型" clearable> |
| | | <el-option label="温度报警" value="温度报警" /> |
| | | <el-option label="压力报警" value="压力报警" /> |
| | | <el-option label="振动报警" value="振动报警" /> |
| | | <el-option label="液位报警" value="液位报警" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button> |
| | | <el-button icon="el-icon-plus" @click="handleAdd">新增</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-card> |
| | | |
| | | <el-card shadow="never" class="table-card" > |
| | | <el-table :data="knowledgeList" style="width: 100%" :header-cell-style="{textAlign: 'center'}" :cell-style="{textAlign: 'center'}"> |
| | | <el-table-column type="index" label="序号" width="80" /> |
| | | <el-table-column prop="title" label="知识库标题" min-width="200" /> |
| | | <el-table-column prop="alarmType" label="报警类型" width="120" /> |
| | | <el-table-column prop="alarmLevel" label="报警级别" width="100"> |
| | | <template #default="scope"> |
| | | <el-tag :type="getAlarmLevelType(scope.row.alarmLevel)"> |
| | | {{ scope.row.alarmLevel }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="createTime" label="创建时间" width="180" /> |
| | | <el-table-column prop="creator" label="创建人" width="100" /> |
| | | <el-table-column prop="status" label="状态" width="100"> |
| | | <template #default="scope"> |
| | | <el-tag :type="scope.row.status === '启用' ? 'success' : 'info'"> |
| | | {{ scope.row.status }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="250" fixed="right"> |
| | | <template #default="scope"> |
| | | <el-button size="small" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button> |
| | | <el-button size="small" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button> |
| | | <el-button size="small" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <div class="pagination"> |
| | | <el-pagination |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="knowledgeList.length" |
| | | :page-size="10" |
| | | :page-sizes="[10, 20, 30, 50]" |
| | | <div class="app-container"> |
| | | <div class="search_form"> |
| | | <div> |
| | | <span class="search_title">知识库标题:</span> |
| | | <el-input |
| | | v-model="searchForm.customerName" |
| | | style="width: 240px" |
| | | placeholder="请输入" |
| | | @change="handleQuery" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | /> |
| | | <el-button type="primary" @click="handleQuery" style="margin-left: 10px" |
| | | >搜索</el-button |
| | | > |
| | | </div> |
| | | </el-card> |
| | | <div> |
| | | <el-button type="primary" @click="openForm('add')">新增知识库</el-button> |
| | | <el-button type="danger" plain @click="handleDelete">删除</el-button> |
| | | </div> |
| | | </div> |
| | | <div class="table_list"> |
| | | <PIMTable |
| | | rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :page="page" |
| | | :isSelection="true" |
| | | @selection-change="handleSelectionChange" |
| | | :tableLoading="tableLoading" |
| | | @pagination="pagination" |
| | | ></PIMTable> |
| | | </div> |
| | | <el-dialog |
| | | v-model="dialogFormVisible" |
| | | :title="operationType === 'add' ? '新增知识库' : '编辑知识库'" |
| | | width="70%" |
| | | @close="closeDia" |
| | | > |
| | | <el-form |
| | | :model="form" |
| | | label-width="140px" |
| | | label-position="top" |
| | | :rules="rules" |
| | | ref="formRef" |
| | | > |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="知识库标题:" prop="customerName"> |
| | | <el-input |
| | | v-model="form.customerName" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item |
| | | label="报警类型:" |
| | | prop="taxpayerIdentificationNumber" |
| | | > |
| | | <el-input |
| | | v-model="form.taxpayerIdentificationNumber" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="报警级别:" prop="companyAddress"> |
| | | <el-select |
| | | v-model="form.companyAddress" |
| | | placeholder="请选择报警级别" |
| | | clearable |
| | | style="width: 100%" |
| | | > |
| | | <el-option label="一般" value="一般" /> |
| | | <el-option label="轻微" value="轻微" /> |
| | | <el-option label="严重" value="严重" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系人:" prop="companyPhone"> |
| | | <el-input v-model="form.companyPhone" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确认</el-button> |
| | | <el-button @click="closeDia">取消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <!-- 用户导入对话框 --> |
| | | <el-dialog |
| | | :title="upload.title" |
| | | v-model="upload.open" |
| | | width="400px" |
| | | append-to-body |
| | | > |
| | | <el-upload |
| | | ref="uploadRef" |
| | | :limit="1" |
| | | accept=".xlsx, .xls" |
| | | :headers="upload.headers" |
| | | :action="upload.url + '?updateSupport=' + upload.updateSupport" |
| | | :disabled="upload.isUploading" |
| | | :before-upload="upload.beforeUpload" |
| | | :on-progress="upload.onProgress" |
| | | :on-success="upload.onSuccess" |
| | | :on-error="upload.onError" |
| | | :on-change="upload.onChange" |
| | | :auto-upload="false" |
| | | drag |
| | | > |
| | | <el-icon class="el-icon--upload"><upload-filled /></el-icon> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | | <template #tip> |
| | | <div class="el-upload__tip text-center"> |
| | | <span>仅允许导入xls、xlsx格式文件。</span> |
| | | <el-link |
| | | type="primary" |
| | | :underline="false" |
| | | style="font-size: 12px; vertical-align: baseline" |
| | | @click="importTemplate" |
| | | >下载模板</el-link |
| | | > |
| | | </div> |
| | | </template> |
| | | </el-upload> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitFileForm">确 定</el-button> |
| | | <el-button @click="upload.open = false">取 消</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: 'AlarmHandleKnowledge', |
| | | data() { |
| | | return { |
| | | searchForm: { |
| | | title: '', |
| | | alarmType: '' |
| | | }, |
| | | knowledgeList: [ |
| | | { |
| | | id: 1, |
| | | title: '反应釜温度过高报警处理流程', |
| | | alarmType: '温度报警', |
| | | alarmLevel: '严重', |
| | | createTime: '2025-12-01 14:30:00', |
| | | creator: '管理员', |
| | | status: '启用' |
| | | }, |
| | | { |
| | | id: 2, |
| | | title: '离心泵振动异常报警处理指南', |
| | | alarmType: '振动报警', |
| | | alarmLevel: '中等', |
| | | createTime: '2025-12-02 09:15:00', |
| | | creator: '设备工程师', |
| | | status: '启用' |
| | | }, |
| | | { |
| | | id: 3, |
| | | title: '储罐液位过低报警处理方法', |
| | | alarmType: '液位报警', |
| | | alarmLevel: '轻微', |
| | | createTime: '2025-12-03 16:45:00', |
| | | creator: '工艺工程师', |
| | | status: '启用' |
| | | }, |
| | | { |
| | | id: 4, |
| | | title: '压缩机压力过高报警应急预案', |
| | | alarmType: '压力报警', |
| | | alarmLevel: '严重', |
| | | createTime: '2025-12-04 11:20:00', |
| | | creator: '安全主管', |
| | | status: '启用' |
| | | }, |
| | | { |
| | | id: 5, |
| | | title: '干燥机湿度异常报警处理流程', |
| | | alarmType: '湿度报警', |
| | | alarmLevel: '中等', |
| | | createTime: '2025-12-05 15:10:00', |
| | | creator: '工艺工程师', |
| | | status: '禁用' |
| | | } |
| | | ] |
| | | <script setup> |
| | | import {onMounted, ref} from "vue"; |
| | | import { Search } from "@element-plus/icons-vue"; |
| | | import { |
| | | addCustomer, |
| | | delCustomer, |
| | | getCustomer, |
| | | listCustomer, |
| | | updateCustomer, |
| | | } from "@/api/basicData/customerFile.js"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import { userListNoPage } from "@/api/system/user.js"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import { getToken } from "@/utils/auth.js"; |
| | | const { proxy } = getCurrentInstance(); |
| | | const userStore = useUserStore(); |
| | | |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "知识库标题", |
| | | prop: "customerName", |
| | | width: 220, |
| | | }, |
| | | { |
| | | label: "报警类型", |
| | | prop: "taxpayerIdentificationNumber", |
| | | width: 220, |
| | | }, |
| | | { |
| | | label: "报警级别", |
| | | prop: "companyAddress", |
| | | width: 250, |
| | | formatter: (row, column, cellValue) => { |
| | | const levelMap = { |
| | | '一般': '一般', |
| | | '轻微': '轻微', |
| | | '严重': '严重' |
| | | }; |
| | | return levelMap[cellValue] || cellValue; |
| | | } |
| | | }, |
| | | methods: { |
| | | getAlarmLevelType(level) { |
| | | switch (level) { |
| | | case '严重': |
| | | return 'danger' |
| | | case '中等': |
| | | return 'warning' |
| | | case '轻微': |
| | | return 'info' |
| | | default: |
| | | return 'info' |
| | | } |
| | | }, |
| | | handleSearch() { |
| | | console.log('搜索知识库', this.searchForm) |
| | | }, |
| | | handleAdd() { |
| | | console.log('新增知识库') |
| | | }, |
| | | handleView(row) { |
| | | console.log('查看知识库详情', row) |
| | | }, |
| | | handleEdit(row) { |
| | | console.log('编辑知识库', row) |
| | | }, |
| | | handleDelete(row) { |
| | | console.log('删除知识库', row) |
| | | { |
| | | label: "联系人", |
| | | prop: "companyPhone", |
| | | }, |
| | | { |
| | | label: "创建时间", |
| | | prop: "maintenanceTime", |
| | | width: 100, |
| | | }, |
| | | { |
| | | dataType: "action", |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: 'right', |
| | | operation: [ |
| | | { |
| | | name: "编辑", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | openForm("edit", row); |
| | | } |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | const tableData = ref([]); |
| | | const selectedRows = ref([]); |
| | | const userList = ref([]); |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 100, |
| | | total: 0, |
| | | }); |
| | | const total = ref(0); |
| | | |
| | | // 用户信息表单弹框数据 |
| | | const operationType = ref(""); |
| | | const dialogFormVisible = ref(false); |
| | | const formYYs = ref({ // 其他字段... |
| | | contactList: [ |
| | | { |
| | | contactPerson: "", |
| | | contactPhone: "" |
| | | } |
| | | ] |
| | | }); |
| | | const data = reactive({ |
| | | searchForm: { |
| | | customerName: "", |
| | | }, |
| | | form: { |
| | | customerName: "", |
| | | taxpayerIdentificationNumber: "", |
| | | companyAddress: "", |
| | | addressPhone: "", |
| | | contactPerson: "", |
| | | contactPhone: "", |
| | | maintainer: "", |
| | | maintenanceTime: "", |
| | | basicBankAccount: "", |
| | | bankAccount: "", |
| | | bankCode: "", |
| | | }, |
| | | rules: { |
| | | customerName: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | taxpayerIdentificationNumber: [ |
| | | { required: true, message: "请输入", trigger: "blur" }, |
| | | ], |
| | | companyAddress: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | companyPhone: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | // contactPerson: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | // contactPhone: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | maintainer: [{ required: false, message: "请选择", trigger: "change" }], |
| | | maintenanceTime: [ |
| | | { required: false, message: "请选择", trigger: "change" }, |
| | | ], |
| | | basicBankAccount: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | bankAccount: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | bankCode: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | const upload = reactive({ |
| | | // 是否显示弹出层(客户导入) |
| | | open: false, |
| | | // 弹出层标题(客户导入) |
| | | title: "", |
| | | // 是否禁用上传 |
| | | isUploading: false, |
| | | // 设置上传的请求头部 |
| | | headers: { Authorization: "Bearer " + getToken() }, |
| | | // 上传的地址 |
| | | url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData", |
| | | // 文件上传前的回调 |
| | | beforeUpload: (file) => { |
| | | console.log('文件即将上传', file); |
| | | // 可以在此处做文件类型或大小校验 |
| | | const isValid = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.name.endsWith('.xlsx') || file.name.endsWith('.xls'); |
| | | if (!isValid) { |
| | | proxy.$modal.msgError("只能上传 Excel 文件"); |
| | | } |
| | | return isValid; |
| | | }, |
| | | // 文件状态改变时的回调 |
| | | onChange: (file, fileList) => { |
| | | console.log('文件状态改变', file, fileList); |
| | | }, |
| | | // 文件上传成功时的回调 |
| | | onSuccess: (response, file, fileList) => { |
| | | console.log('上传成功', response, file, fileList); |
| | | upload.isUploading = false; |
| | | if(response.code === 200){ |
| | | proxy.$modal.msgSuccess("文件上传成功"); |
| | | upload.open = false; |
| | | proxy.$refs["uploadRef"].clearFiles(); |
| | | getList(); |
| | | }else if(response.code === 500){ |
| | | proxy.$modal.msgError(response.msg); |
| | | }else{ |
| | | proxy.$modal.msgWarning(response.msg); |
| | | } |
| | | }, |
| | | // 文件上传失败时的回调 |
| | | onError: (error, file, fileList) => { |
| | | console.error('上传失败', error, file, fileList); |
| | | upload.isUploading = false; |
| | | proxy.$modal.msgError("文件上传失败"); |
| | | }, |
| | | // 文件上传进度回调 |
| | | onProgress: (event, file, fileList) => { |
| | | console.log('上传中...', event.percent); |
| | | } |
| | | }); |
| | | const { searchForm, form, rules } = toRefs(data); |
| | | const addNewContact = () => { |
| | | formYYs.value.contactList.push({ |
| | | contactPerson: "", |
| | | contactPhone: "" |
| | | }); |
| | | }; |
| | | |
| | | const removeContact = (index) => { |
| | | if (formYYs.value.contactList.length > 1) { |
| | | formYYs.value.contactList.splice(index, 1); |
| | | } |
| | | }; |
| | | // 查询列表 |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | page.current = 1; |
| | | getList(); |
| | | }; |
| | | const pagination = (obj) => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getList(); |
| | | }; |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | listCustomer({ ...searchForm.value, ...page }).then((res) => { |
| | | tableLoading.value = false; |
| | | tableData.value = res.records; |
| | | page.total = res.total; |
| | | }); |
| | | }; |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | /** 提交上传文件 */ |
| | | function submitFileForm() { |
| | | upload.isUploading = true; |
| | | proxy.$refs["uploadRef"].submit(); |
| | | } |
| | | /** 导入按钮操作 */ |
| | | function handleImport() { |
| | | upload.title = "客户导入"; |
| | | upload.open = true; |
| | | } |
| | | /** 下载模板 */ |
| | | function importTemplate() { |
| | | proxy.download("/basic/customer/downloadTemplate", {}, "客户导入模板.xlsx"); |
| | | } |
| | | // 打开弹框 |
| | | const openForm = (type, row) => { |
| | | operationType.value = type; |
| | | form.value = {}; |
| | | form.value.maintainer = userStore.nickName; |
| | | formYYs.value.contactList = [ |
| | | { |
| | | contactPerson: "", |
| | | contactPhone: "" |
| | | } |
| | | ]; |
| | | form.value.maintenanceTime = getCurrentDate(); |
| | | userListNoPage().then((res) => { |
| | | userList.value = res.data; |
| | | }); |
| | | if (type === "edit") { |
| | | getCustomer(row.id).then((res) => { |
| | | form.value = { ...res.data }; |
| | | formYYs.value.contactList = res.data.contactPerson.split(",").map((item, index) => { |
| | | return { |
| | | contactPerson: item, |
| | | contactPhone: res.data.contactPhone.split(",")[index] |
| | | } |
| | | }); |
| | | |
| | | }); |
| | | } |
| | | dialogFormVisible.value = true; |
| | | }; |
| | | // 提交表单 |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (operationType.value === "edit") { |
| | | submitEdit(); |
| | | } else { |
| | | submitAdd(); |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | | // 提交新增 |
| | | const submitAdd = () => { |
| | | if(formYYs.value.contactList.length < 1){ |
| | | return proxy.$modal.msgWarning("请至少添加一个联系人"); |
| | | } |
| | | form.value.contactPerson = formYYs.value.contactList.map(item => item.contactPerson).join(","); |
| | | form.value.contactPhone = formYYs.value.contactList.map(item => item.contactPhone).join(","); |
| | | addCustomer(form.value).then((res) => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | | getList(); |
| | | }); |
| | | }; |
| | | // 提交修改 |
| | | const submitEdit = () => { |
| | | form.value.contactPerson = formYYs.value.contactList.map(item => item.contactPerson).join(","); |
| | | form.value.contactPhone = formYYs.value.contactList.map(item => item.contactPhone).join(","); |
| | | updateCustomer(form.value).then((res) => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | | getList(); |
| | | }); |
| | | }; |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | | dialogFormVisible.value = false; |
| | | }; |
| | | // 导出 |
| | | const handleOut = () => { |
| | | ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | proxy.download("/basic/customer/export", {}, "客户档案.xlsx"); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | }; |
| | | // 删除 |
| | | const handleDelete = () => { |
| | | let ids = []; |
| | | if (selectedRows.value.length > 0) { |
| | | ids = selectedRows.value.map((item) => item.id); |
| | | } else { |
| | | proxy.$modal.msgWarning("请选择数据"); |
| | | return; |
| | | } |
| | | ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除提示", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | tableLoading.value = true; |
| | | delCustomer(ids) |
| | | .then((res) => { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | getList(); |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | }; |
| | | |
| | | // 获取当前日期并格式化为 YYYY-MM-DD |
| | | function getCurrentDate() { |
| | | const today = new Date(); |
| | | const year = today.getFullYear(); |
| | | const month = String(today.getMonth() + 1).padStart(2, "0"); // 月份从0开始 |
| | | const day = String(today.getDate()).padStart(2, "0"); |
| | | return `${year}-${month}-${day}`; |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .alarm-handle-knowledge { |
| | | padding: 16px; |
| | | background-color: #f0f2f5; |
| | | min-height: 100vh; |
| | | } |
| | | |
| | | .search-card { |
| | | margin-bottom: 16px; |
| | | border-radius: 8px; |
| | | box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); |
| | | } |
| | | |
| | | .table-card { |
| | | margin-top: 16px; |
| | | border-radius: 8px; |
| | | box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); |
| | | } |
| | | |
| | | .pagination { |
| | | margin-top: 16px; |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | padding-right: 20px; |
| | | } |
| | | |
| | | </style> |
| | | <style scoped lang="scss"></style> |