Commit 9ba20148 authored by 王亚晖's avatar 王亚晖
parents 5c6148d3 14e0abfd
<template>
<div class="contentBlock">
<div class="contentBlockInn">
<div class="contentBlockInn" id="printBlock">
<el-card class="card-contianer">
<table
cellpadding="0"
......@@ -70,25 +70,26 @@
</table>
</td>
<th rowspan="3">
<div>
<div class="printHidden">
<div class="btngrounp">
<el-button type="primary" @click="postTransferAreaFun"
>查询</el-button
><el-button
type="primary"
@click="exportTableToExcel"
style="margin: 0 0 0 5px"
v-print="printObj"
style="margin: 0 0 0 10px"
>打印</el-button
><el-button
>
<!-- <el-button
type="primary"
@click="exportTableToExcel"
style="margin: 0 0 0 5px"
>打印预览</el-button
>
> -->
<el-button
type="primary"
@click="exportTableToExcel"
style="margin: 0 0 0 5px"
style="margin: 0 0 0 10px"
>导出</el-button
>
</div>
......@@ -135,6 +136,71 @@
</el-table>
</el-card>
</div>
<table
cellpadding="0"
cellspacing="1"
class="exlBlock"
id="exlBlock"
style="background-color: #99bbe8"
>
<tr>
<td colspan="3">年度:{{ enertyInfo.supplyYear }}</td>
<td colspan="2">
类型:{{ enertyInfo.nature == -1 ? "全部" : ""
}}{{ enertyInfo.nature == 0 ? "民用" : ""
}}{{ enertyInfo.nature == 1 ? "公建" : "" }}
</td>
<td colspan="3">
节能方式:{{ enertyInfo.energyType == -1 ? "全部" : ""
}}{{ enertyInfo.energyType == 1 ? "一步节能" : ""
}}{{ enertyInfo.energyType == 2 ? "二步节能" : ""
}}{{ enertyInfo.energyType == 3 ? "三步节能" : ""
}}{{ enertyInfo.energyType == 4 ? "四步节能" : "" }}
</td>
<td colspan="6">
供热站:<span v-for="item in areaName" :key="item"
>{{ item }}&nbsp;&nbsp;&nbsp;&nbsp;</span
>
</td>
</tr>
<tr>
<td rowspan="2">序号</td>
<td rowspan="2">区域名称</td>
<td rowspan="2">换热站名称</td>
<td rowspan="2">年度</td>
<td colspan="2">居民(应供收费面积)</td>
<td colspan="2">大公建(应供建筑面积)</td>
<td colspan="2">小公建(应供建筑面积)</td>
<td rowspan="2">应供建筑面积</td>
<td rowspan="2">实供建筑面积C</td>
<td rowspan="2">实供收费面积D</td>
<td rowspan="2">计算面积</td>
</tr>
<tr>
<td>收费面积</td>
<td>停暖面积</td>
<td>实供建筑面积</td>
<td>停暖建筑面积</td>
<td>实供建筑面积</td>
<td>停暖建筑面积</td>
</tr>
<tr v-for="(item, index) in tableData" :key="index">
<td>{{ index + 1 }}</td>
<td>{{ item.jurisdictionName }}</td>
<td>{{ item.stationName }}</td>
<td>{{ item.supplyYear }}</td>
<td>{{ item.realCostCiviled }}</td>
<td>{{ item.realCostSPB }}</td>
<td>{{ item.realBuildBPB }}</td>
<td>{{ item.stopBuildBPB }}</td>
<td>{{ item.realBuildSPB }}</td>
<td>{{ item.stopBuildSPB }}</td>
<td>{{ item.supplyArea }}</td>
<td>{{ item.realBuild }}</td>
<td>{{ item.realCost }}</td>
<td>{{ item.calculateArea }}</td>
</tr>
</table>
</div>
</template>
<script setup>
......@@ -146,11 +212,13 @@ import { ElMessage } from "element-plus";
import { saveAs } from "file-saver";
import XLSX from "xlsx-js-style";
import { postTransferArea } from "../../api/report";
import print from "vue3-print-nb";
const radioTitle = ref("供热站");
const options = reactive([]);
const enterpriseId = ref(null);
const checkboxList = ref([]);
const tableData = ref([]);
const areaName = ref([]);
const yearList = [
"2016-2017",
"2017-2018",
......@@ -178,7 +246,127 @@ const enertyInfo = reactive({
energyType: -1,
supplyYear: "2024-2025",
});
const vPrint = print;
const printObj = {
id: "printBlock",
popTitle: "明日预测报表",
extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
zIndex: 20002,
};
function exportTableToExcel() {
const workbook = XLSX.utils.book_new();
var ws = XLSX.utils.table_to_sheet(document.getElementById("exlBlock"));
const border = {
top: {
style: "thin",
},
bottom: {
style: "thin",
},
left: {
style: "thin",
},
right: {
style: "thin",
},
};
const range = XLSX.utils.decode_range(ws["!ref"]);
const cellList = Object.keys(ws).filter((item) => item.indexOf("!") < 0);
for (let row = range.s.r; row <= range.e.r; row++) {
for (let col = range.s.c; col <= range.e.c; col++) {
const cell = XLSX.utils.encode_cell({ r: row, c: col });
if (cellList.indexOf(cell) < 0) {
ws[cell] = { t: "", v: "", s: { border } };
} else {
ws[cell].s = { border };
}
}
}
for (const key in ws) {
if (
key === "A1" ||
key === "A2" ||
key === "B1" ||
key === "C1" ||
key === "D1" ||
key === "E1" ||
key === "F1" ||
key === "G1" ||
key === "H1" ||
key === "I1" ||
key === "J1" ||
key === "K1" ||
key === "L1" ||
key === "M1" ||
key === "N1" ||
ws[key].v === "序号" ||
ws[key].v === "区域名称" ||
ws[key].v === "换热站名称" ||
ws[key].v === "年度" ||
ws[key].v === "居民(应供收费面积)" ||
ws[key].v === "大公建(应供建筑面积)" ||
ws[key].v === "小公建(应供建筑面积)" ||
ws[key].v === "收费面积" ||
ws[key].v === "停暖面积" ||
ws[key].v === "实供建筑面积" ||
ws[key].v === "停暖建筑面积" ||
ws[key].v === "应供建筑面积" ||
ws[key].v === "实供建筑面积C" ||
ws[key].v === "实供收费面积D" ||
ws[key].v === "计算面积"
) {
ws[key].s = {
alignment: {
horizontal: "center",
vertical: "center",
},
border: {
bottom: {
color: "#000000",
style: "thin",
},
left: {
color: "#000000",
style: "thin",
},
right: {
color: "#000000",
style: "thin",
},
top: {
color: "#000000",
style: "thin",
},
},
fill: {
fgColor: { rgb: "0097d5fd" },
},
font: {
bold: true,
family: 2,
size: 12,
},
};
}
}
ws["!cols"] = [{ wch: 5 }];
XLSX.utils.sheet_add_aoa(ws, [], {
origin: "A1",
});
XLSX.utils.book_append_sheet(workbook, ws, "面积统计报表");
const excelBuffer = XLSX.write(workbook, { bookType: "xlsx", type: "array" });
const dataBlob = new Blob([excelBuffer], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",
});
const downloadUrl = URL.createObjectURL(dataBlob);
saveAs(dataBlob, "面积统计报表.xlsx");
ElMessage.success("导出成功!请稍后。。。");
}
//根据权限初始化单选列表
function initRadioList() {
var result = store.getters.getEnterprise();
......@@ -219,7 +407,15 @@ function initRadioList() {
}
function postTransferAreaFun() {
console.log(enertyInfo);
areaName.value.length = 0;
enertyInfo.jurisdictionIds.forEach((item) => {
options.forEach((item1) => {
if (item1.value == item) {
console.log(item1.lable);
areaName.value.push(item1.lable);
}
});
});
var date = new Date();
let supplyYearSend = ref();
if (date.getMonth() + 1 < 7) {
......@@ -310,4 +506,20 @@ table.botList td {
text-align: left;
font-weight: bolder;
}
.exlBlock {
display: none;
}
@media print {
.printHidden {
display: none;
}
@page {
size: auto;
margin: 3mm;
}
body,
html {
height: auto !important;
}
}
</style>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<template>
<div class="contentBlock">
<div class="contentBlockInn">
<div class="contentBlockInn" id="printBlock">
<el-card class="card-contianer">
<table
cellpadding="0"
......@@ -55,7 +55,7 @@
<template v-slot:header>
<div>
<div>港益</div>
<span>供水瞬时流量(m³/h)</span>
<span>供水瞬时热量(GJ/H)</span>
</div>
</template>
</el-table-column>
......@@ -155,15 +155,15 @@
<div class="btngrounp">
<el-button
type="primary"
@click="sendClick"
v-print="printObj"
style="margin: 15px 0 0 0"
>打印</el-button
><el-button
><!--<el-button
type="primary"
@click="exportTableToExcel"
style="margin: 15px 0 0 10px"
>打印预览</el-button
>
>-->
<el-button
type="primary"
@click="exportTableToExcel"
......@@ -179,6 +179,67 @@
</div>
</el-card>
</div>
<table
cellpadding="0"
cellspacing="3"
class="exlBlock"
id="exlBlock"
style="background-color: #ff0"
>
<tr>
<td colspan="17">港益热量汇总实时分析&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前时间:{{ enertyInfo.nowTime }}</td>
</tr>
<tr>
<td>地点</td>
<td>区域换热站计量反馈瞬时流量(m³/h)</td>
<td>区域换热站计量反馈瞬时热量(GJ/H)</td>
<td>港益供水温度(℃)</td>
<td>港益回水温度(℃)</td>
<td>港益供水瞬时流量(m³/h)</td>
<td>港益供水瞬时热量(GJ/H)</td>
<td>预测瞬时热量</td>
<td>当前预测热量累计</td>
<td>当前热量偏差量</td>
<td>滨海供热集团供水温度(℃)</td>
<td>滨海供热集团回水温度(℃)</td>
<td>滨海供热集团供水压力(MP)</td>
<td>滨海供热集团回水压力(MP)</td>
<td>滨海供热集团供水瞬时流量(m³/h)</td>
<td>滨海供热集团供水瞬时热量(GJ/H)</td>
<td>当前实际热量累计</td>
</tr>
<tr v-for="item in tableData" :key="item">
<td>{{ item.pipeName }}</td>
<td>{{ item.firstInstantaneousFlow }}</td>
<td>{{ item.firstInstantaneousHeat }}</td>
<td>{{ item.firstInTemp }}</td>
<td>{{ item.firstOutTemp }}</td>
<td>{{ item.supplyFlow }}</td>
<td>{{ item.supplyHeat }}</td>
<td>{{ item.predictionHeat }}</td>
<td>{{ item.currentPredictionHeat }}</td>
<td>{{ item.currentDifference }}</td>
<td>{{ item.groupFirstSupplyTemp }}</td>
<td>{{ item.groupFirstBackTemp }}</td>
<td>{{ item.groupFirstSupplyPress }}</td>
<td>{{ item.groupFirstBackPress }}</td>
<td>{{ item.groupSupplyFlow }}</td>
<td>{{ item.groupSupplyHeat }}</td>
<td>{{ item.currentRealHeat }}</td>
</tr>
<tr>
<td colspan="17">预测方案生成 瞬时热量(GJ/H)&nbsp;&nbsp;&nbsp;&nbsp;{{ tableDataList.prePlan }}</td>
</tr>
<tr>
<td colspan="17">滨海供热集团汇总 瞬时热量(GJ/H)&nbsp;&nbsp;&nbsp;&nbsp;{{ tableDataList.groupTotal }}</td>
</tr>
<tr>
<td colspan="17">预测瞬时热量与汇总 瞬时热量 差两(GJ/H)&nbsp;&nbsp;&nbsp;&nbsp;{{ tableDataList.prePlanDiff }}</td>
</tr>
<tr>
<td colspan="17">预测瞬时热量与汇总 瞬时热量 差量比(%)&nbsp;&nbsp;&nbsp;&nbsp;{{ tableDataList.diffPercent }}</td>
</tr>
</table>
</div>
</template>
<script setup>
......@@ -189,14 +250,145 @@ import { ElMessage } from "element-plus";
import { saveAs } from "file-saver";
import XLSX from "xlsx-js-style";
import { postRealAnalysis } from "../../api/report";
import print from "vue3-print-nb";
const enertyInfo = reactive({
nowTime: null,
queryTime: null
})
const tableDataList = ref([]);
const tableData = ref([]);
const vPrint = print;
const printObj = {
id: "printBlock",
popTitle: "明日预测报表",
extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
zIndex: 20002,
};
function exportTableToExcel() {
const workbook = XLSX.utils.book_new();
var ws = XLSX.utils.table_to_sheet(document.getElementById("exlBlock"));
const border = {
top: {
style: "thin",
},
bottom: {
style: "thin",
},
left: {
style: "thin",
},
right: {
style: "thin",
},
};
const range = XLSX.utils.decode_range(ws["!ref"]);
const cellList = Object.keys(ws).filter((item) => item.indexOf("!") < 0);
for (let row = range.s.r; row <= range.e.r; row++) {
for (let col = range.s.c; col <= range.e.c; col++) {
const cell = XLSX.utils.encode_cell({ r: row, c: col });
if (cellList.indexOf(cell) < 0) {
ws[cell] = { t: "", v: "", s: { border } };
} else {
ws[cell].s = { border };
}
}
}
for (const key in ws) {
if (
key === "A1" ||
key === "A2" ||
key === "A3" ||
key === "A4" ||
key === "A5" ||
key === "A6" ||
key === "A7" ||
key === "B1" ||
key === "C1" ||
key === "E1" ||
key === "D1" ||
key === "F1" ||
key === "G1" ||
key === "H1" ||
key === "I1" ||
key === "J1" ||
key === "K1" ||
key === "L1" ||
key === "M1" ||
key === "N1" ||
key === "O1" ||
key === "P1" ||
key === "Q1"
) {
ws[key].s = {
alignment: {
horizontal: "center",
vertical: "center",
},
border: {
bottom: {
color: "#000000",
style: "thin",
},
left: {
color: "#000000",
style: "thin",
},
right: {
color: "#000000",
style: "thin",
},
top: {
color: "#000000",
style: "thin",
},
},
fill: {
fgColor: { rgb: "0097d5fd" },
},
font: {
bold: true,
family: 2,
size: 12,
},
};
}
}
ws["!cols"] = [
{ wch: 20 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 10 },
{ wch: 20 },
];
XLSX.utils.sheet_add_aoa(ws, [], {
origin: "A1",
});
XLSX.utils.book_append_sheet(workbook, ws, "港益热量汇总实时分析");
const excelBuffer = XLSX.write(workbook, { bookType: "xlsx", type: "array" });
const dataBlob = new Blob([excelBuffer], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",
});
const downloadUrl = URL.createObjectURL(dataBlob);
saveAs(dataBlob, "港益热量汇总实时分析报表.xlsx");
ElMessage.success("导出成功!请稍后。。。");
}
function postRealAnalysisFun() {
var date = new Date();
var year = date.getFullYear();
......@@ -281,4 +473,20 @@ table.bottomTable td {
margin: 0 auto;
text-align: center;
}
.exlBlock {
display: none;
}
@media print {
.printHidden {
display: none;
}
@page {
size: auto;
margin: 3mm;
}
body,
html {
height: auto !important;
}
}
</style>
\ No newline at end of file
<template>
<div class="contentBlock">
<div class="contentBlockInn">
<div class="contentBlockInn" id="printBlock">
<el-card class="card-contianer">
<table
cellpadding="0"
......@@ -39,7 +39,7 @@
</table>
</td>
<th rowspan="3">
<div>
<div class="printHidden">
<div class="btngrounp">
<el-button
type="primary"
......@@ -48,15 +48,16 @@
>查询</el-button
><el-button
type="primary"
@click="exportTableToExcel"
v-print="printObj"
style="margin: 15px 0 0 10px"
>打印</el-button
><el-button
>
<!--<el-button
type="primary"
@click="exportTableToExcel"
style="margin: 15px 0 0 10px"
>打印预览</el-button
>
>-->
<el-button
type="primary"
@click="exportTableToExcel"
......@@ -110,6 +111,52 @@
</el-table>
</el-card>
</div>
<table
class="exlBlock"
id="exlBlock"
cellpadding="0"
cellspacing="1"
style="margin-top: 5px; background-color: #99bbe8"
>
<tr>
<td colspan="2">起始时间:{{ enertyInfo.startTime }}</td>
<td colspan="2">结束时间:{{ enertyInfo.endTime }}</td>
<td colspan="2">
面积:{{ enertyInfo.areaType == 0 ? "计算面积" : "实供建筑面积" }}
</td>
<td colspan="5">
片区:<span v-for="item in areaName" :key="item"
>{{ item }}&nbsp;&nbsp;&nbsp;&nbsp;</span
>
</td>
</tr>
<tr>
<td>序号</td>
<td>片区</td>
<td>换热站名称</td>
<td>面积</td>
<td>热量(GJ)</td>
<td>热耗(GJ/㎡)</td>
<td>热耗(W/㎡)</td>
<td>水量(T)</td>
<td>水耗(KG/㎡)</td>
<td>电量(KWH)</td>
<td>电量(KWH/㎡)</td>
</tr>
<tr v-for="item in tableData" :key="item.sn">
<td>{{item.sn}}</td>
<td>{{item.jurisdictionName}}</td>
<td>{{item.transferName}}</td>
<td>{{item.area}}</td>
<td>{{item.heat}}</td>
<td>{{item.heatG}}</td>
<td>{{item.heatW}}</td>
<td>{{item.water}}</td>
<td>{{item.waterUsed}}</td>
<td>{{item.electric}}</td>
<td>{{item.electricUsed}}</td>
</tr>
</table>
</div>
</template>
<script setup>
......@@ -121,6 +168,7 @@ import { ElMessage } from "element-plus";
import { saveAs } from "file-saver";
import XLSX from "xlsx-js-style";
import { postTransferEnergy } from "../../api/report";
import print from "vue3-print-nb";
const radioTitle = ref("供热站");
const options = reactive([]);
const enterpriseId = ref(null);
......@@ -132,6 +180,119 @@ const enertyInfo = reactive({
startTime: null,
endTime: null,
});
const areaName = ref([]);
const vPrint = print;
const printObj = {
id: "printBlock",
popTitle: "明日预测报表",
extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
zIndex: 20002,
};
function exportTableToExcel() {
const workbook = XLSX.utils.book_new();
var ws = XLSX.utils.table_to_sheet(document.getElementById("exlBlock"));
const border = {
top: {
style: "thin",
},
bottom: {
style: "thin",
},
left: {
style: "thin",
},
right: {
style: "thin",
},
};
const range = XLSX.utils.decode_range(ws["!ref"]);
const cellList = Object.keys(ws).filter((item) => item.indexOf("!") < 0);
for (let row = range.s.r; row <= range.e.r; row++) {
for (let col = range.s.c; col <= range.e.c; col++) {
const cell = XLSX.utils.encode_cell({ r: row, c: col });
if (cellList.indexOf(cell) < 0) {
ws[cell] = { t: "", v: "", s: { border } };
} else {
ws[cell].s = { border };
}
}
}
for (const key in ws) {
if (
key === "A1" ||
key === "A2" ||
key === "B1" ||
key === "C1" ||
key === "D1" ||
key === "E1" ||
key === "F1" ||
key === "G1" ||
ws[key].v === "序号" ||
ws[key].v === "片区" ||
ws[key].v === "换热站名称" ||
ws[key].v === "面积" ||
ws[key].v === "热量(GJ)" ||
ws[key].v === "热耗(GJ/㎡)" ||
ws[key].v === "热耗(W/㎡)" ||
ws[key].v === "水量(T)" ||
ws[key].v === "水耗(KG/㎡)" ||
ws[key].v === "电量(KWH)" ||
ws[key].v === "电量(KWH/㎡)"
) {
ws[key].s = {
alignment: {
horizontal: "center",
vertical: "center",
},
border: {
bottom: {
color: "#000000",
style: "thin",
},
left: {
color: "#000000",
style: "thin",
},
right: {
color: "#000000",
style: "thin",
},
top: {
color: "#000000",
style: "thin",
},
},
fill: {
fgColor: { rgb: "0097d5fd" },
},
font: {
bold: true,
family: 2,
size: 12,
},
};
}
}
ws["!cols"] = [
{ wch: 5 }
];
XLSX.utils.sheet_add_aoa(ws, [], {
origin: "A1",
});
XLSX.utils.book_append_sheet(workbook, ws, "换热站能耗报表");
const excelBuffer = XLSX.write(workbook, { bookType: "xlsx", type: "array" });
const dataBlob = new Blob([excelBuffer], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",
});
const downloadUrl = URL.createObjectURL(dataBlob);
saveAs(dataBlob, "换热站能耗报表.xlsx");
ElMessage.success("导出成功!请稍后。。。");
}
function timeFun() {
var date = new Date();
var year = date.getFullYear();
......@@ -195,6 +356,16 @@ function initRadioList() {
}
function postTransferEnergyFun() {
areaName.value.length = 0;
enertyInfo.jurisdictionIds.forEach((item) => {
options.forEach((item1) => {
if (item1.value == item) {
console.log(item1.lable);
areaName.value.push(item1.lable);
}
});
});
if (enertyInfo.startTime == null) {
ElMessage.error("请选择开始时间");
return false;
......@@ -231,7 +402,7 @@ function postPrintHeatForecastFun() {
onMounted(() => {
timeFun();
initRadioList();
postTransferEnergyFun()
postTransferEnergyFun();
//postHeatForecastFun();
});
onUnmounted(() => {});
......@@ -284,4 +455,20 @@ table.botList td {
text-align: left;
font-weight: bolder;
}
.exlBlock {
display: none;
}
@media print {
.printHidden {
display: none;
}
@page {
size: auto;
margin: 3mm;
}
body,
html {
height: auto !important;
}
}
</style>
\ No newline at end of file
......@@ -10,14 +10,16 @@
<div class="login-text1 text">用户登录</div>
<div class="login-text2 text">DATA MANAGEMENT BACKGROUND OF PACKET DIAGRAM</div>
<div class="div-input">
<el-input v-model="userInfo.userName" style="width: 380px ; height: 50px" placeholder="请输入账号"
:prefix-icon="User" input-style="color:black" />
<el-input v-model="userInfo.userName" style="width: 380px ; height: 50px"
placeholder="请输入账号" :prefix-icon="User" input-style="color:black" />
</div>
<el-row>
<el-col>
<div class="div-input">
<el-input v-model="userInfo.password" style=" color: white;width: 380px ; height: 50px" type="password"
placeholder="请输入密码" show-password :prefix-icon="Lock" input-style="color:black" />
<el-input v-model="userInfo.password"
style=" color: white;width: 380px ; height: 50px" type="password"
placeholder="请输入密码" show-password :prefix-icon="Lock"
input-style="color:black" />
</div>
</el-col>
</el-row>
......@@ -27,12 +29,13 @@
<el-col :span="15">
<div class="div-input input-contain">
<el-input v-model="code" style="width: 240px ; height: 50px"
placeholder="请输入验证码" input-style="color:black" @keyup.enter="login"/>
placeholder="请输入验证码" input-style="color:black" @keyup.enter="login" />
</div>
</el-col>
<el-col :span="9">
<div class="div-input img-contain">
<el-image @click="getPicture" style="width: 100%; height: 50px" :src="codeurl" :fit="'fill'" />
<el-image @click="getPicture" style="width: 100%; height: 50px" :src="codeurl"
:fit="'fill'" />
</div>
</el-col>
</el-row>
......@@ -40,7 +43,7 @@
<el-row justify="space-around">
<el-col :span="12">
<el-checkbox class="text" v-model="isRemember" label="记住密码" size="large" />
<el-checkbox class="text" v-model="isRemember" label="记住密码" size="large" @change="changeCheck"/>
</el-col>
<el-col :span="12">
<div class="text">忘记密码</div>
......@@ -197,7 +200,6 @@
color: red;
font-size: small;
}
</style>
<script lang="ts" setup>
......@@ -225,14 +227,14 @@ const isRemember = ref(false);
const loading = ref(false);
const errorMessage = ref('用户或密码错误,请重试')
var showMessage=ref(false);
var showMessage = ref(false);
const userInfo = reactive({
userName: '',
password: '',
verificationCode: '',
UUID: undefined
});
});
localStorage.setItem("SERVEICE", "");
......@@ -245,47 +247,48 @@ async function fetchClientIp() {
store.commit('setSERVEICE', data.ip);
//http.ipAddress = store.getters.getSERVEICE;
console.log("changeip:"+clientIp.value + " " );
console.log("changeip:" + clientIp.value + " ");
getPicture();
} catch (error) {
clientIp.value = '获取失败';
console.error('Error fetching client IP:', error);
}
}
}
async function getPicture() {
try{
try {
var serverIP = localStorage.getItem("SERVEICE");
console.log(clientIp.value + " " + serverIP);
if(!serverIP || serverIP == null || serverIP == ""){
if (!serverIP || serverIP == null || serverIP == "") {
await fetchClientIp();
}
await http.get('/api/User/getVierificationCode').then((x) => {
try{
var jobj=x.data;
try {
var jobj = x.data;
codeurl.value = 'data:image/jpg;base64,' + jobj.img;
userInfo.UUID = jobj.uuid;
}catch(error){
} catch (error) {
console.log(error.message);
}
});
}catch(error){
} catch (error) {
console.log(error.message);
await fetchClientIp();
}
}
getPicture();
getUserInfo();
let appContext = getCurrentInstance()!.appContext;
let $message = appContext.config.globalProperties.$message;
function login() {
if(code.value == ''){
showMessage.value=true;
errorMessage.value="请输入验证码";
if (code.value == '') {
showMessage.value = true;
errorMessage.value = "请输入验证码";
return $message.error(errorMessage.value);
}
loading.value = true;
......@@ -295,15 +298,67 @@ function login() {
if (!result.success) {
loading.value = false;
getPicture();
showMessage.value=true;
errorMessage.value=result.message;
showMessage.value = true;
errorMessage.value = result.message;
return $message.error(result.message);
}
$message.success('登录成功,正在跳转!');
store.commit('setUserInfo', result.data);
//保存
if(isRemember.value){
saveUserInfo(userInfo);
}
// router.push({ path: '/Home'});
router.push({ path: '/GisHome'});
router.push({ path: '/GisHome' });
});
}
function saveUserInfo(userInfo) {
var days = 30;//设置30天过期
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = "userName=" + userInfo.userName + "; expires=" + date.toUTCString();
document.cookie = "password=" + userInfo.password + "; expires=" + date.toUTCString();
}
function clearUserInfo() {
document.cookie = "userName=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
document.cookie = "password=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
}
function getUserInfo() {
var key_name ='userName' + "=";
var key_password='password'+"=";
var tuserInfo={
}
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(key_name) == 0){
tuserInfo.username=c.substring(key_name.length, c.length);
}else if(c.indexOf(key_password) == 0){
tuserInfo.password=c.substring(key_password.length, c.length);
}
}
//如果名称和密码都存在,返回用户信息,否则返回空
if(tuserInfo.username && tuserInfo.password){
isRemember.value=true;
userInfo.userName=tuserInfo.username;
userInfo.password=tuserInfo.passowrd;
return tuserInfo;
}
return null;
}
console.log('test remember')
//
function changeCheck(value){
console.log(isRemember);
if(!isRemember.value){
clearUserInfo();
}
}
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment