From 989d547833c94ffc4e7395b0023ec24ee09f5ab6 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期五, 14 十一月 2025 15:06:18 +0800
Subject: [PATCH] Merge branch 'dev_7004' into dev_tide_mom

---
 src/views/energyManagement/energyPeriodTime/index.vue |  444 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 444 insertions(+), 0 deletions(-)

diff --git a/src/views/energyManagement/energyPeriodTime/index.vue b/src/views/energyManagement/energyPeriodTime/index.vue
new file mode 100644
index 0000000..0c94322
--- /dev/null
+++ b/src/views/energyManagement/energyPeriodTime/index.vue
@@ -0,0 +1,444 @@
+<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>

--
Gitblit v1.9.3