| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <div class="search_form"> |
| | | <div> |
| | | <span class="search_title">æ¥æï¼</span> |
| | | <!-- <el-time-picker |
| | | style="width: 240px;margin-right: 10px" |
| | | v-model="searchForm.startTime" |
| | | value-format="HH:mm:ss" |
| | | format="HH:mm:ss" |
| | | type="time" |
| | | placeholder="è¯·éæ©å¼å§æ¶é´" |
| | | clearable |
| | | /> --> |
| | | <el-date-picker |
| | | v-model="searchForm.date" |
| | | type="date" |
| | | placeholder="è¯·éæ©æ¥æ" |
| | | :size="size" |
| | | /> |
| | | <!-- <el-time-picker |
| | | v-model="searchForm.timeRange" |
| | | is-range |
| | | arrow-control |
| | | range-separator="To" |
| | | start-placeholder="éæ©ç»ææ¶é´" |
| | | end-placeholder="éæ©ç»ææ¶é´" |
| | | /> --> |
| | | <span class="search_title">çµä»·ï¼å
/度ï¼ï¼</span> |
| | | <el-input |
| | | v-model="searchForm.price" |
| | | style="width: 240px" |
| | | placeholder="请è¾å
¥çµä»·" |
| | | @change="handleQuery" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | /> |
| | | <el-button type="primary" @click="handleQuery" style="margin-left: 10px" |
| | | >æç´¢</el-button> |
| | | <el-button @click="resetFilters">éç½®</el-button> |
| | | </div> |
| | | <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="ç¨çµæ¶æ®µç®¡ç" |
| | | 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="date"> |
| | | <el-date-picker |
| | | style="width: 100%" |
| | | v-model="form.date" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="date" |
| | | placeholder="è¯·éæ©æ¥æ" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="çµä»·ï¼å
/度ï¼ï¼" prop="price"> |
| | | <el-input |
| | | v-model="form.price" |
| | | placeholder="请è¾å
¥çµä»·" |
| | | clearable |
| | | type="number" |
| | | step="0.01" |
| | | min="0" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="峰段ï¼" prop="peak"> |
| | | <el-input |
| | | v-model="form.peak" |
| | | placeholder="请è¾å
¥å³°æ®µ" |
| | | clearable |
| | | type="number" |
| | | step="0.01" |
| | | min="0" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="谷段ï¼" prop="valley"> |
| | | <el-input |
| | | v-model="form.valley" |
| | | placeholder="请è¾å
¥è°·æ®µ" |
| | | clearable |
| | | type="number" |
| | | step="0.01" |
| | | min="0" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="平段ï¼" prop="flat"> |
| | | <el-input |
| | | v-model="form.flat" |
| | | placeholder="请è¾å
¥å¹³æ®µ" |
| | | clearable |
| | | type="number" |
| | | step="0.01" |
| | | min="0" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="å°æ®µï¼" prop="sharp"> |
| | | <el-input |
| | | v-model="form.sharp" |
| | | placeholder="请è¾å
¥å°æ®µ" |
| | | clearable |
| | | type="number" |
| | | step="0.01" |
| | | min="0" |
| | | /> |
| | | </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> |
| | | </div> |
| | | </template> |
| | | <script setup> |
| | | import {Search} from "@element-plus/icons-vue"; |
| | | import {onMounted, ref} from "vue"; |
| | | import {ElMessageBox} from "element-plus"; |
| | | import {getToken} from "@/utils/auth.js"; |
| | | import {periodListPage,periodDelete,periodAdd,periodUpdate} from "@/api/energyManagement/index.js"; |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const data = reactive({ |
| | | searchForm: { |
| | | date: "", |
| | | price: "" |
| | | }, |
| | | form: { |
| | | date: "", |
| | | price: "", |
| | | peak: "", |
| | | valley: "", |
| | | flat: "", |
| | | sharp: "" |
| | | } |
| | | }); |
| | | const { searchForm,form } = toRefs(data); |
| | | const page = ref({ |
| | | current: 1, |
| | | size: 10, |
| | | total: 0 |
| | | }); |
| | | const dialogFormVisible = ref(false); |
| | | const selectedRows = ref([]); |
| | | const operationType = ref(''); |
| | | const tableData = ref([]); |
| | | const emit = defineEmits(['close']) |
| | | const tableLoading = ref(false); |
| | | const tableColumn = ref([ |
| | | // { |
| | | // label: "æ¶æ®µåç§°", |
| | | // prop: "timeName", |
| | | // width: 200, |
| | | // }, |
| | | { |
| | | label: "æ¥æ", |
| | | prop: "date", |
| | | width: 200, |
| | | }, |
| | | { |
| | | label: "çµä»·ï¼å
/度ï¼", |
| | | prop: "price", |
| | | width: 200, |
| | | }, |
| | | { |
| | | label: "峰段", |
| | | prop: "peak", |
| | | }, |
| | | { |
| | | label: "谷段", |
| | | prop: "valley", |
| | | }, |
| | | { |
| | | label: "平段", |
| | | prop: "flat", |
| | | }, |
| | | { |
| | | label: "å°æ®µ", |
| | | prop: "sharp", |
| | | }, |
| | | { |
| | | dataType: "action", |
| | | label: "æä½", |
| | | align: "center", |
| | | fixed: 'right', |
| | | operation: [ |
| | | { |
| | | name: "ç¼è¾", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | openForm("edit", row); |
| | | }, |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | |
| | | |
| | | // è¡¨æ ¼éæ©æ°æ® |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | const formDia = ref() |
| | | const upload = reactive({ |
| | | // æ¯å¦æ¾ç¤ºå¼¹åºå±ï¼å®¢æ·å¯¼å
¥ï¼ |
| | | open: false, |
| | | // å¼¹åºå±æ é¢ï¼å®¢æ·å¯¼å
¥ï¼ |
| | | title: "", |
| | | // æ¯å¦ç¦ç¨ä¸ä¼ |
| | | isUploading: false, |
| | | // 设置ä¸ä¼ ç请æ±å¤´é¨ |
| | | headers: { Authorization: "Bearer " + getToken() }, |
| | | // ä¸ä¼ çå°å |
| | | url: import.meta.env.VITE_APP_BASE_API + "/equipmentEnergyConsumption/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); |
| | | if(response.code === 200){ |
| | | proxy.$modal.msgSuccess("æä»¶ä¸ä¼ æå"); |
| | | }else if(response.code === 500){ |
| | | ElMessageBox.error(response.msg); |
| | | }else{ |
| | | ElMessageBox.warning(response.msg); |
| | | } |
| | | }, |
| | | // æä»¶ä¸ä¼ 失败æ¶çåè° |
| | | onError: (error, file, fileList) => { |
| | | console.error('ä¸ä¼ 失败', error, file, fileList); |
| | | ElMessageBox.error("æä»¶ä¸ä¼ 失败"); |
| | | }, |
| | | // æä»¶ä¸ä¼ è¿åº¦åè° |
| | | onProgress: (event, file, fileList) => { |
| | | console.log('ä¸ä¼ ä¸...', event.percent); |
| | | } |
| | | }); |
| | | |
| | | // æ¥è¯¢å表 |
| | | /** æç´¢æé®æä½ */ |
| | | const handleQuery = () => { |
| | | page.current = 1; |
| | | getList(); |
| | | }; |
| | | //éç½® |
| | | const resetFilters = () => { |
| | | searchForm.value = { |
| | | date: "", |
| | | price: "" |
| | | }; |
| | | getList(); |
| | | |
| | | }; |
| | | const pagination = (obj) => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getList(); |
| | | }; |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | periodListPage({ ...searchForm, ...page.value }).then((res) => { |
| | | tableLoading.value = false; |
| | | if (res && res.data) { |
| | | tableData.value = res.data.records || []; |
| | | page.total = res.data.total || 0; |
| | | } else { |
| | | tableData.value = []; |
| | | page.total = 0; |
| | | ElMessageBox.warning('æªè·åå°æ°æ®'); |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | tableLoading.value = false; |
| | | console.error('æ°æ®å 载失败:', err); |
| | | ElMessageBox.error('æ°æ®å 载失败ï¼è¯·éè¯'); |
| | | }); |
| | | }; |
| | | // æå¼å¼¹æ¡ |
| | | const openDialog = (type, row) => { |
| | | operationType.value = type; |
| | | dialogFormVisible.value = true; |
| | | // form.value.maintainer = userStore.nickName; |
| | | // form.value.maintenanceTime = getCurrentDate(); |
| | | form.value = {} |
| | | proxy.resetForm("formRef"); |
| | | periodListPage().then((res) => { |
| | | codeList.value = res.data; |
| | | }); |
| | | if (type === "edit") { |
| | | form.value = {...row} |
| | | } |
| | | } |
| | | // æå¼å¼¹æ¡ |
| | | const openForm = (type, row) => { |
| | | openDialog(type, row) |
| | | }; |
| | | // æäº¤è¡¨å |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | if (operationType.value === "add") { |
| | | periodAdd(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("æ°å¢æå") |
| | | closeDia() |
| | | getList() |
| | | }) |
| | | } else { |
| | | periodUpdate(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("ä¿®æ¹æå") |
| | | closeDia() |
| | | getList() |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | // å
³éå¼¹æ¡ |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | | dialogFormVisible.value = false; |
| | | emit('close') |
| | | }; |
| | | /** 导å
¥æé®æä½ */ |
| | | function handleImport() { |
| | | upload.title = "设å¤è½è"; |
| | | upload.open = true; |
| | | // æ¸
ç©ºä¸æ¬¡ä¸ä¼ çæä»¶å表 |
| | | nextTick(() => { |
| | | proxy.$refs["uploadRef"]?.clearFiles(); |
| | | }); |
| | | } |
| | | function importTemplate() { |
| | | proxy.download( |
| | | "/equipmentEnergyConsumption/export", |
| | | {}, |
| | | '设å¤è½è导å
¥æ¨¡ç.xlsx' |
| | | ); |
| | | } |
| | | /** æäº¤ä¸ä¼ æä»¶ */ |
| | | function submitFileForm() { |
| | | proxy.$refs["uploadRef"].submit(); |
| | | } |
| | | |
| | | /** å¼¹æ¡å
³éæ¶æ¸
空æä»¶å表 */ |
| | | function handleDialogClose() { |
| | | nextTick(() => { |
| | | proxy.$refs["uploadRef"]?.clearFiles(); |
| | | }); |
| | | } |
| | | |
| | | 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; |
| | | periodDelete(ids) |
| | | .then((res) => { |
| | | proxy.$modal.msgSuccess("å 餿å"); |
| | | getList(); |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已忶"); |
| | | }); |
| | | }; |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |