From 311712d06356714169281a2bbc20c171f1c2e661 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期五, 12 九月 2025 17:35:55 +0800 Subject: [PATCH] 部署修改 --- src/views/inventoryManagement/stockWarning/index.vue | 582 +++++++++++++++++++-------------------------------------- 1 files changed, 194 insertions(+), 388 deletions(-) diff --git a/src/views/inventoryManagement/stockWarning/index.vue b/src/views/inventoryManagement/stockWarning/index.vue index bd0ccaf..89d396e 100644 --- a/src/views/inventoryManagement/stockWarning/index.vue +++ b/src/views/inventoryManagement/stockWarning/index.vue @@ -41,27 +41,27 @@ <!-- 鎿嶄綔鎸夐挳 --> <div class="table-operations"> <el-button type="primary" @click="handleAdd">鏂板棰勮瑙勫垯</el-button> - <el-button type="success" @click="handleBatchProcess">鎵归噺澶勭悊</el-button> + <!-- <el-button type="success" @click="handleBatchProcess">鎵归噺澶勭悊@</el-button> --> <el-button @click="handleExport">瀵煎嚭</el-button> </div> - <el-table - :data="tableData" - border - v-loading="tableLoading" + <el-table + :data="tableData" + border + v-loading="tableLoading" @selection-change="handleSelectionChange" style="width: 100%" height="calc(100vh - 280px)" > <el-table-column align="center" type="selection" width="55" /> <el-table-column align="center" label="搴忓彿" type="index" width="60" /> - + <!-- 鍩虹淇℃伅瀛楁 --> <el-table-column label="鍌ㄦ皵缃愮紪鐮�" prop="tankCode" width="120" show-overflow-tooltip /> <el-table-column label="鍌ㄦ皵缃愬悕绉�" prop="tankName" width="200" show-overflow-tooltip /> <el-table-column label="鍌ㄦ皵缃愮被鍨�" prop="tankType" width="120" show-overflow-tooltip /> <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" width="150" show-overflow-tooltip /> <el-table-column label="瀹圭Н(m鲁)" prop="volume" width="100" show-overflow-tooltip /> - + <!-- 搴撳瓨鐩稿叧瀛楁 --> <el-table-column label="褰撳墠姘斾綋閲�" prop="currentGasLevel" width="120" show-overflow-tooltip> <template #default="scope"> @@ -72,7 +72,7 @@ <el-table-column label="鏈�浣庢皵浣撻噺" prop="minGasLevel" width="120" show-overflow-tooltip /> <el-table-column label="鏈�楂樻皵浣撻噺" prop="maxGasLevel" width="120" show-overflow-tooltip /> <el-table-column label="褰撳墠鍘嬪姏(MPa)" prop="currentPressure" width="140" show-overflow-tooltip /> - + <!-- 棰勮瑙勫垯瀛楁 --> <el-table-column label="棰勮绫诲瀷" prop="warningType" width="100" show-overflow-tooltip> <template #default="scope"> @@ -94,7 +94,7 @@ <el-switch v-model="scope.row.isEnabled" @change="handleEnableChange(scope.row)" /> </template> </el-table-column> - + <!-- 鏃堕棿鐩稿叧瀛楁 --> <el-table-column label="棰勮鏃堕棿" prop="warningTime" width="150" show-overflow-tooltip /> <el-table-column label="棰勮鎸佺画澶╂暟" prop="warningDuration" width="120" show-overflow-tooltip /> @@ -115,32 +115,32 @@ <span v-else>-</span> </template> </el-table-column> - + <!-- 鎿嶄綔鍒� --> <el-table-column fixed="right" label="鎿嶄綔" width="200" align="center"> <template #default="scope"> <el-button link type="primary" size="small" @click="handleEdit(scope.row)">缂栬緫</el-button> - <el-button link type="success" size="small" @click="handleProcess(scope.row)">澶勭悊</el-button> + <el-button link type="success" size="small" @click="handleProcess(scope.row)">澶勭悊@</el-button> <el-button link type="danger" size="small" @click="handleDelete(scope.row)">鍒犻櫎</el-button> </template> </el-table-column> </el-table> - + <!-- 鍒嗛〉 --> - <pagination - v-show="total > 0" - :total="total" + <pagination + v-show="total > 0" + :total="total" layout="total, sizes, prev, pager, next, jumper" - :page="page.current" - :limit="page.size" - @pagination="paginationChange" + :page="page.current" + :limit="page.size" + @pagination="paginationChange" /> </div> <!-- 鏂板/缂栬緫棰勮瑙勫垯寮圭獥 --> - <el-dialog - v-model="dialogFormVisible" - :title="operationType === 'add' ? '鏂板棰勮瑙勫垯' : '缂栬緫棰勮瑙勫垯'" + <el-dialog + v-model="dialogFormVisible" + :title="operationType === 'add' ? '鏂板棰勮瑙勫垯' : '缂栬緫棰勮瑙勫垯'" width="50%" @close="closeDialog" > @@ -158,7 +158,7 @@ </el-form-item> </el-col> </el-row> - + <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="鍌ㄦ皵缃愮被鍨嬶細" prop="tankType"> @@ -176,7 +176,7 @@ </el-form-item> </el-col> </el-row> - + <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="瀹圭Н(m鲁)锛�" prop="volume"> @@ -189,7 +189,7 @@ </el-form-item> </el-col> </el-row> - + <!-- 搴撳瓨鐩稿叧 --> <el-row :gutter="20"> <el-col :span="12"> @@ -203,7 +203,7 @@ </el-form-item> </el-col> </el-row> - + <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="鏈�楂樻皵浣撻噺(%)锛�" prop="maxGasLevel"> @@ -216,7 +216,7 @@ </el-form-item> </el-col> </el-row> - + <!-- 棰勮瑙勫垯 --> <el-row :gutter="20"> <el-col :span="12"> @@ -239,7 +239,7 @@ </el-form-item> </el-col> </el-row> - + <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="棰勮闃堝�硷細" prop="warningThreshold"> @@ -252,15 +252,15 @@ </el-form-item> </el-col> </el-row> - + <!-- 鏃堕棿鐩稿叧 --> <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="棰勮鏃堕棿锛�" prop="warningTime"> - <el-date-picker - v-model="form.warningTime" - type="datetime" - placeholder="璇烽�夋嫨棰勮鏃堕棿" + <el-date-picker + v-model="form.warningTime" + type="datetime" + placeholder="璇烽�夋嫨棰勮鏃堕棿" style="width: 100%" value-format="YYYY-MM-DD HH:mm:ss" /> @@ -268,24 +268,24 @@ </el-col> <el-col :span="12"> <el-form-item label="棰勮鍏呰鏃堕棿锛�" prop="expectedRefillTime"> - <el-date-picker - v-model="form.expectedRefillTime" - type="datetime" - placeholder="璇烽�夋嫨棰勮鍏呰鏃堕棿" + <el-date-picker + v-model="form.expectedRefillTime" + type="datetime" + placeholder="璇烽�夋嫨棰勮鍏呰鏃堕棿" style="width: 100%" value-format="YYYY-MM-DD HH:mm:ss" /> </el-form-item> </el-col> </el-row> - + <el-row :gutter="20"> <el-col :span="12"> <el-form-item label="棰勮缂烘皵鏃堕棿锛�" prop="expectedShortageTime"> - <el-date-picker - v-model="form.expectedShortageTime" - type="datetime" - placeholder="璇烽�夋嫨棰勮缂烘皵鏃堕棿" + <el-date-picker + v-model="form.expectedShortageTime" + type="datetime" + placeholder="璇烽�夋嫨棰勮缂烘皵鏃堕棿" style="width: 100%" value-format="YYYY-MM-DD HH:mm:ss" /> @@ -293,17 +293,17 @@ </el-col> <el-col :span="12"> <el-form-item label="棰勮瑙勫垯鎻忚堪锛�" prop="warningRule"> - <el-input - v-model="form.warningRule" - type="textarea" - :rows="3" + <el-input + v-model="form.warningRule" + type="textarea" + :rows="3" placeholder="璇疯緭鍏ラ璀﹁鍒欐弿杩�" /> </el-form-item> </el-col> </el-row> </el-form> - + <template #footer> <div class="dialog-footer"> <el-button @click="closeDialog">鍙栨秷</el-button> @@ -382,15 +382,15 @@ import { WarningFilled } from '@element-plus/icons-vue' import pagination from '@/components/PIMTable/Pagination.vue' // 娉ㄩ噴鎺堿PI瀵煎叆锛屼娇鐢ㄥ亣鏁版嵁 -// import { -// getStockWarningPage, -// addStockWarning, -// updateStockWarning, -// deleteStockWarning, -// batchProcessStockWarning, -// exportStockWarning, -// toggleStockWarningStatus -// } from '@/api/inventoryManagement/stockWarning.js' +import { + getStockWarningPage, + addStockWarning, + updateStockWarning, + deleteStockWarning, + batchProcessStockWarning, + exportStockWarning, + toggleStockWarningStatus +} from '@/api/inventoryManagement/stockWarning.js' const { proxy } = getCurrentInstance() @@ -410,7 +410,8 @@ // 鍒嗛〉鍙傛暟 const page = reactive({ current: 1, - size: 10 + size: 10, + total: 0 }) // 鎼滅储琛ㄥ崟 @@ -459,19 +460,19 @@ // 鑾峰彇鍊掕鏃朵俊鎭� const getCountdown = (expectedTime) => { if (!expectedTime) return { text: '-', isExpired: false } - + const now = new Date().getTime() const expected = new Date(expectedTime).getTime() const diff = expected - now - + if (diff <= 0) { return { text: '宸茬己姘�', isExpired: true } } - + const days = Math.floor(diff / (1000 * 60 * 60 * 24)) const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)) - + if (days > 0) { return { text: `${days}澶�${hours}灏忔椂`, isExpired: false } } else if (hours > 0) { @@ -484,11 +485,11 @@ // 鑾峰彇鍊掕鏃舵牱寮忕被 const getCountdownClass = (expectedTime) => { if (!expectedTime) return '' - + const now = new Date().getTime() const expected = new Date(expectedTime).getTime() const diff = expected - now - + if (diff <= 0) { return 'countdown-expired' } else if (diff <= 24 * 60 * 60 * 1000) { // 24灏忔椂鍐� @@ -518,7 +519,7 @@ const showShortageWarning = (tank) => { currentWarningTank.value = tank shortageWarningVisible.value = true - + // 鎾斁鎻愮ず闊筹紙鍙�夛級 // const audio = new Audio('/path/to/warning-sound.mp3') // audio.play() @@ -537,236 +538,20 @@ // 杩欓噷鍙互璋冪敤澶勭悊API } - - -// 鐢熸垚鍋囨暟鎹� -const generateMockData = () => { - const mockData = [ - { - id: 1, - tankCode: 'TANK001', - tankName: '娑插寲姘斿偍缃怉', - tankType: '娑插寲姘斿偍缃�', - specificationModel: 'LPG-5000L', - volume: 5000, - currentGasLevel: 15, - safetyGasLevel: 30, - minGasLevel: 10, - maxGasLevel: 95, - currentPressure: 2.5, - warningType: '姘斾綋涓嶈冻', - warningLevel: '绱ф��', - warningThreshold: 20, - isEnabled: true, - warningTime: '2025-01-15 08:30:00', - warningDuration: 3, - lastUpdateTime: '2025-01-15 10:00:00', - expectedRefillTime: '2025-01-16 14:00:00', - expectedShortageTime: '2025-01-15 18:30:00', // 浠婂ぉ涓嬪崍6:30缂烘皵 - warningRule: '褰撴皵浣撻噺浣庝簬20%鏃惰Е鍙戦璀�' - }, - { - id: 2, - tankCode: 'TANK002', - tankName: '鍘嬬缉姘斿偍缃怋', - tankType: '鍘嬬缉姘斿偍缃�', - specificationModel: 'COMP-3000L', - volume: 3000, - currentGasLevel: 45, - safetyGasLevel: 25, - minGasLevel: 15, - maxGasLevel: 90, - currentPressure: 8.2, - warningType: '鍘嬪姏寮傚父', - warningLevel: '閲嶈', - warningThreshold: 10, - isEnabled: true, - warningTime: '2025-01-14 16:20:00', - warningDuration: 2, - lastUpdateTime: '2025-01-15 09:15:00', - expectedRefillTime: '2025-01-17 09:00:00', - expectedShortageTime: '2025-01-18 12:00:00', // 3澶╁悗缂烘皵 - warningRule: '褰撳帇鍔涜秴杩�8MPa鏃惰Е鍙戦璀�' - }, - { - id: 3, - tankCode: 'TANK003', - tankName: '澶╃劧姘斿偍缃怌', - tankType: '澶╃劧姘斿偍缃�', - specificationModel: 'NG-8000L', - volume: 8000, - currentGasLevel: 75, - safetyGasLevel: 20, - minGasLevel: 10, - maxGasLevel: 95, - currentPressure: 4.8, - warningType: '娓╁害寮傚父', - warningLevel: '涓�鑸�', - warningThreshold: 5, - isEnabled: true, - warningTime: '2025-01-13 11:45:00', - warningDuration: 1, - lastUpdateTime: '2025-01-15 08:45:00', - expectedRefillTime: '2025-01-20 10:00:00', - expectedShortageTime: '2025-01-22 15:30:00', // 7澶╁悗缂烘皵 - warningRule: '褰撴俯搴﹁秴杩�60掳C鏃惰Е鍙戦璀�' - }, - { - id: 4, - tankCode: 'TANK004', - tankName: '姘ф皵鍌ㄧ綈D', - tankType: '姘ф皵鍌ㄧ綈', - specificationModel: 'O2-2000L', - volume: 2000, - currentGasLevel: 8, - safetyGasLevel: 25, - minGasLevel: 5, - maxGasLevel: 90, - currentPressure: 6.5, - warningType: '娉勬紡棰勮', - warningLevel: '绱ф��', - warningThreshold: 15, - isEnabled: true, - warningTime: '2025-01-15 07:15:00', - warningDuration: 4, - lastUpdateTime: '2025-01-15 11:30:00', - expectedRefillTime: '2025-01-15 16:00:00', - expectedShortageTime: '2025-01-15 14:00:00', // 浠婂ぉ涓嬪崍2鐐圭己姘� - warningRule: '褰撴娴嬪埌姘斾綋娉勬紡鏃惰Е鍙戦璀�' - }, - { - id: 5, - tankCode: 'TANK005', - tankName: '娑插寲姘斿偍缃怑', - tankType: '娑插寲姘斿偍缃�', - specificationModel: 'LPG-6000L', - volume: 6000, - currentGasLevel: 35, - safetyGasLevel: 30, - minGasLevel: 15, - maxGasLevel: 95, - currentPressure: 3.2, - warningType: '姘斾綋涓嶈冻', - warningLevel: '閲嶈', - warningThreshold: 20, - isEnabled: false, - warningTime: '2025-01-14 14:30:00', - warningDuration: 2, - lastUpdateTime: '2025-01-15 09:00:00', - expectedRefillTime: '2025-01-19 08:00:00', - expectedShortageTime: '2025-01-21 10:00:00', // 6澶╁悗缂烘皵 - warningRule: '褰撴皵浣撻噺浣庝簬20%鏃惰Е鍙戦璀�' - }, - { - id: 6, - tankCode: 'TANK006', - tankName: '鍘嬬缉姘斿偍缃怓', - tankType: '鍘嬬缉姘斿偍缃�', - specificationModel: 'COMP-4000L', - volume: 4000, - currentGasLevel: 85, - safetyGasLevel: 20, - minGasLevel: 10, - maxGasLevel: 90, - currentPressure: 7.8, - warningType: '鍘嬪姏寮傚父', - warningLevel: '涓�鑸�', - warningThreshold: 8, - isEnabled: true, - warningTime: '2025-01-12 09:20:00', - warningDuration: 1, - lastUpdateTime: '2025-01-15 08:30:00', - expectedRefillTime: '2025-01-25 14:00:00', - expectedShortageTime: '2025-01-28 16:00:00', // 13澶╁悗缂烘皵 - warningRule: '褰撳帇鍔涜秴杩�8MPa鏃惰Е鍙戦璀�' - }, - { - id: 7, - tankCode: 'TANK007', - tankName: '澶╃劧姘斿偍缃怗', - tankType: '澶╃劧姘斿偍缃�', - specificationModel: 'NG-10000L', - volume: 10000, - currentGasLevel: 92, - safetyGasLevel: 15, - minGasLevel: 8, - maxGasLevel: 95, - currentPressure: 5.2, - warningType: '娓╁害寮傚父', - warningLevel: '閲嶈', - warningThreshold: 6, - isEnabled: true, - warningTime: '2025-01-11 16:45:00', - warningDuration: 1, - lastUpdateTime: '2025-01-15 07:45:00', - expectedRefillTime: '2025-01-30 09:00:00', - expectedShortageTime: '2025-02-05 12:00:00', // 21澶╁悗缂烘皵 - warningRule: '褰撴俯搴﹁秴杩�60掳C鏃惰Е鍙戦璀�' - }, - { - id: 8, - tankCode: 'TANK008', - tankName: '姘ф皵鍌ㄧ綈H', - tankType: '姘ф皵鍌ㄧ綈', - specificationModel: 'O2-1500L', - volume: 1500, - currentGasLevel: 12, - safetyGasLevel: 30, - minGasLevel: 8, - maxGasLevel: 90, - currentPressure: 4.5, - warningType: '娉勬紡棰勮', - warningLevel: '绱ф��', - warningThreshold: 12, - isEnabled: true, - warningTime: '2025-01-15 06:30:00', - warningDuration: 5, - lastUpdateTime: '2025-01-15 12:15:00', - expectedRefillTime: '2025-01-15 20:00:00', - expectedShortageTime: '2025-01-15 17:30:00', // 浠婂ぉ涓嬪崍5:30缂烘皵 - warningRule: '褰撴娴嬪埌姘斾綋娉勬紡鏃惰Е鍙戦璀�' - } - ] - - // 鏍规嵁鎼滅储鏉′欢杩囨护鏁版嵁 - let filteredData = mockData.filter(item => { - if (searchForm.tankName && !item.tankName.includes(searchForm.tankName)) return false - if (searchForm.tankType && item.tankType !== searchForm.tankType) return false - if (searchForm.warningType && item.warningType !== searchForm.warningType) return false - if (searchForm.warningLevel && item.warningLevel !== searchForm.warningLevel) return false - return true - }) - - // 鍒嗛〉澶勭悊 - const start = (page.current - 1) * page.size - const end = start + page.size - const paginatedData = filteredData.slice(start, end) - - return { - records: paginatedData, - total: filteredData.length - } -} - // 鑾峰彇鍒楄〃鏁版嵁 const getList = async () => { tableLoading.value = true - try { - // 妯℃嫙缃戠粶寤惰繜 - await new Promise(resolve => setTimeout(resolve, 500)) - - const result = generateMockData() - tableData.value = result.records - total.value = result.total - - // 妫�鏌ョ己姘旈璀� + getStockWarningPage(page, searchForm) + .then(res => { + + tableData.value = res.data.records + page.value.total = res.data.total; + tableLoading.value = false; + // 妫�鏌ョ己姘旈璀� checkShortageWarnings() - } catch (error) { - console.error('鑾峰彇鍒楄〃澶辫触:', error) - ElMessage.error('鑾峰彇鍒楄〃澶辫触') - } finally { - tableLoading.value = false - } + }).catch(err => { + tableLoading.value = false; + }) } // 鎼滅储 @@ -798,7 +583,7 @@ // 鏂板 const handleAdd = () => { operationType.value = 'add' - resetForm() + // resetForm() dialogFormVisible.value = true } @@ -815,7 +600,7 @@ // 妯℃嫙API璋冪敤寤惰繜 await new Promise(resolve => setTimeout(resolve, 300)) ElMessage.success(`姝e湪澶勭悊棰勮锛�${row.tankName}`) - getList() + // getList() } catch (error) { ElMessage.error('澶勭悊棰勮澶辫触') } @@ -829,11 +614,21 @@ cancelButtonText: '鍙栨秷', type: 'warning' }) - - // 妯℃嫙API璋冪敤寤惰繜 - await new Promise(resolve => setTimeout(resolve, 300)) - ElMessage.success('鍒犻櫎鎴愬姛') - getList() + let ids = []; + ids.push(row.id); + deleteStockWarning(ids).then(res => { + if(res.code == 200){ + ElMessage.success("鍒犻櫎鎴愬姛"); + ids.value = []; + getList(); + } + }).catch(err => { + ElMessage.error(err.msg); + }) + // // 妯℃嫙API璋冪敤寤惰繜 + // await new Promise(resolve => setTimeout(resolve, 300)) + // ElMessage.success('鍒犻櫎鎴愬姛') + // getList() } catch (error) { if (error !== 'cancel') { ElMessage.error('鍒犻櫎澶辫触') @@ -847,7 +642,7 @@ ElMessage.warning('璇烽�夋嫨瑕佸鐞嗙殑棰勮') return } - + try { // 妯℃嫙API璋冪敤寤惰繜 await new Promise(resolve => setTimeout(resolve, 500)) @@ -860,75 +655,65 @@ // 瀵煎嚭 const handleExport = async () => { - try { - // 妯℃嫙API璋冪敤寤惰繜 - await new Promise(resolve => setTimeout(resolve, 800)) - - // 鐢熸垚瀵煎嚭鏁版嵁 - const exportData = generateMockData().records - const csvContent = generateCSV(exportData) - - // 鍒涘缓涓嬭浇閾炬帴 - const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }) - const url = window.URL.createObjectURL(blob) - const link = document.createElement('a') - link.href = url - link.download = `鍌ㄦ皵缃愰璀︽暟鎹甠${new Date().getTime()}.csv` - link.click() - window.URL.revokeObjectURL(url) - - ElMessage.success('瀵煎嚭鎴愬姛') - } catch (error) { - ElMessage.error('瀵煎嚭澶辫触') - } + // if (selectedRows.value.length === 0) { + // exportStockWarning().then(res => { + // // // 鍒涘缓涓嬭浇閾炬帴 + // // const blob = new Blob([res.data], { type: 'text/csv;charset=utf-8;' }) + // // const url = window.URL.createObjectURL(blob) + // // const link = document.createElement('a') + // // link.href = url + // // link.download = `鍌ㄦ皵缃愰璀︽暟鎹甠${new Date().getTime()}.csv` + // // link.click() + // // window.URL.revokeObjectURL(url) + // }).catch(err => { + // ElMessage.error(err.msg); + // }) + // }else{ + // let ids = []; + // selectedRows.value.forEach(item => { + // ids.push(item.id); + // }) + // exportStockWarning(ids).then(res => { + // // // 鍒涘缓涓嬭浇閾炬帴 + // // const blob = new Blob([res.data], { type: 'text/csv;charset=utf-8;' }) + // // const url = window.URL.createObjectURL(blob) + // // const link = document.createElement('a') + // // link.href = url + // // link.download = `鍌ㄦ皵缃愰璀︽暟鎹甠${new Date().getTime()}.csv` + // // link.click() + // // window.URL.revokeObjectURL(url) + // }).catch(err => { + // ElMessage.error(err.msg); + // }) + // } + + ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", { + confirmButtonText: "纭", + cancelButtonText: "鍙栨秷", + type: "warning", + }) + .then(() => { + proxy.download("/gasTankWarning/export", {ids: selectedRows.value.map(item => item.id)}, "鍌ㄦ皵缃愰璀�.xlsx"); + }) + .catch(() => { + proxy.$modal.msg("宸插彇娑�"); + }); } -// 鐢熸垚CSV鍐呭 -const generateCSV = (data) => { - const headers = [ - '鍌ㄦ皵缃愮紪鐮�', '鍌ㄦ皵缃愬悕绉�', '鍌ㄦ皵缃愮被鍨�', '瑙勬牸鍨嬪彿', '瀹圭Н(m鲁)', - '褰撳墠姘斾綋閲�(%)', '瀹夊叏姘斾綋閲�(%)', '鏈�浣庢皵浣撻噺(%)', '鏈�楂樻皵浣撻噺(%)', - '褰撳墠鍘嬪姏(MPa)', '棰勮绫诲瀷', '棰勮绾у埆', '棰勮闃堝��', '鏄惁鍚敤', - '棰勮鏃堕棿', '棰勮鎸佺画澶╂暟', '鏈�鍚庢洿鏂版椂闂�', '棰勮鍏呰鏃堕棿', '棰勮缂烘皵鏃堕棿', '棰勮瑙勫垯鎻忚堪' - ] - - const csvRows = [headers.join(',')] - - data.forEach(item => { - const row = [ - item.tankCode, - item.tankName, - item.tankType, - item.specificationModel, - item.volume, - item.currentGasLevel, - item.safetyGasLevel, - item.minGasLevel, - item.maxGasLevel, - item.currentPressure, - item.warningType, - item.warningLevel, - item.warningThreshold, - item.isEnabled ? '鏄�' : '鍚�', - item.warningTime, - item.warningDuration, - item.lastUpdateTime, - item.expectedRefillTime, - item.expectedShortageTime, - item.warningRule - ] - csvRows.push(row.join(',')) - }) - - return csvRows.join('\n') -} -// 鍚敤鐘舵�佸彉鍖� + +// // 鍚敤鐘舵�佸彉鍖� const handleEnableChange = async (row) => { + try { - // 妯℃嫙API璋冪敤寤惰繜 - await new Promise(resolve => setTimeout(resolve, 200)) - ElMessage.success(`${row.tankName} 鐨勫惎鐢ㄧ姸鎬佸凡鏇存柊`) + updateStockWarning(row).then(res => { + if(res.code == 200){ + ElMessage.success(`${row.tankName} 鐨勫惎鐢ㄧ姸鎬佸凡鏇存柊`); + getList(); + } + }).catch(err => { + ElMessage.error(err.msg); + }) } catch (error) { ElMessage.error('鐘舵�佹洿鏂板け璐�') // 鎭㈠鍘熺姸鎬� @@ -940,18 +725,39 @@ const submitForm = async () => { try { await proxy.$refs.formRef.validate() - + // 妯℃嫙API璋冪敤寤惰繜 - await new Promise(resolve => setTimeout(resolve, 500)) - + // await new Promise(resolve => setTimeout(resolve, 500)) + if (operationType.value === 'add') { - ElMessage.success('鏂板鎴愬姛') + addStockWarning(form).then(res => { + if(res.code == 200){ + ElMessage.success("娣诲姞鎴愬姛"); + dialogFormVisible.value = false + getList() + resetForm() + } + }).catch(err => { + ElMessage.error(err.msg); + }) + + // ElMessage.success('鏂板鎴愬姛') } else { - ElMessage.success('缂栬緫鎴愬姛') + updateStockWarning(form).then(res => { + if(res.code == 200){ + ElMessage.success("鏇存柊鎴愬姛"); + dialogFormVisible.value = false + getList() + resetForm() + } + }).catch(err => { + ElMessage.error(err.msg); + }) + // ElMessage.success('缂栬緫鎴愬姛') } - - closeDialog() - getList() + + // closeDialog() + // getList() } catch (error) { if (!error.errors) { ElMessage.error(operationType.value === 'add' ? '鏂板澶辫触' : '缂栬緫澶辫触') @@ -962,7 +768,7 @@ // 鍏抽棴寮圭獥 const closeDialog = () => { dialogFormVisible.value = false - resetForm() + // resetForm() } // 閲嶇疆琛ㄥ崟 @@ -1040,89 +846,89 @@ <style scoped lang="scss"> .app-container { padding: 20px; - + .table-operations { text-align: right; margin-bottom: 20px; - + .el-button { margin-right: 10px; } } - + .table_list { background: #fff; border-radius: 4px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } - + .text-danger { color: #f56c6c; font-weight: bold; } - + .text-warning { color: #e6a23c; font-weight: bold; } - + .text-success { color: #67c23a; font-weight: bold; } - + .dialog-footer { text-align: right; } - + // 鍊掕鏃舵牱寮� .countdown-timer { font-weight: bold; } - + .countdown-normal { color: #67c23a; } - + .countdown-warning { color: #e6a23c; } - + .countdown-urgent { color: #f56c6c; animation: blink 1s infinite; } - + .countdown-expired { color: #f56c6c; font-weight: bold; } - + @keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0.5; } } - + // 缂烘皵棰勮寮规鏍峰紡 .shortage-warning-content { text-align: center; padding: 20px 0; - + .warning-icon { margin-bottom: 20px; } - + .warning-message { h3 { color: #f56c6c; margin-bottom: 10px; } - + p { margin-bottom: 10px; color: #606266; } - + .warning-details { background: #f5f7fa; padding: 15px; -- Gitblit v1.9.3