中航光电热表web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

397 lines
11 KiB

<template>
6 months ago
<basic-container>
<avue-crud
:option="option"
v-model:search="search"
6 months ago
:table-loading="loading"
:data="data"
v-model="form"
v-model:page="page"
ref="crud"
@row-del="rowDel"
@row-save="rowSave"
@row-update="rowUpdate"
6 months ago
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete"
>删除
</el-button>
</template>
<template #menu-right>
<el-button type="primary" icon="el-icon-upload" @click="handleImport"
>导入
</el-button>
</template>
<template #menu> </template>
6 months ago
</avue-crud>
6 months ago
<!-- 导入 -->
<basic-import v-if="isShowImport" title="导入" :isShow="isShowImport"
templateUrl="/blade-desk/QA/CycleTestItem/download-excel-template"
templateName="试验项目模板.xlsx"
6 months ago
importUrl="/blade-desk/QA/CycleTestItem/import-excel"
@closeDialog="closeDialog"></basic-import>
6 months ago
</basic-container>
</template>
<script>
6 months ago
import basicImport from '@/components/basic-import/main.vue'
import { pageList, removeItem, saveItem, exportData } from '@/api/energyManagement/bsEnergyMonitor';
export default {
6 months ago
components: {
basicImport,
},
6 months ago
data() {
return {
6 months ago
isShowImport:false,
6 months ago
selectionList: [],
query: {},
search: {},
6 months ago
option: {
height: "auto",
calcHeight: 32,
tip: false,
simplePage: true,
searchShow: true,
searchMenuSpan: 6,
searchIcon: true,
searchIndex: 3,
tree: false,
border: true,
index: true,
selection: true,
viewBtn: false,
delBtn: false,
addBtn: true,
editBtnText: "修改",
viewBtnIcon: " ",
delBtnIcon: " ",
editBtnIcon: " ",
viewBtnText: "详情",
labelWidth: 160,
6 months ago
menuWidth: 180,
dialogWidth: 1040,
dialogClickModal: false,
searchEnter: true,
excelBtn: false,
filterBtn: true,
searchShowBtn: false,
columnSort: true,
excelBtn: true,
columnSort: true,
index: false,
showOverflowTooltip: true,
searchLabelPosition: "left",
searchLabelPosition: "left",
searchGutter: 24,
searchSpan: 6,
menuAlign: "left",
gridBtn: false,
searchMenuPosition: "right",
addBtnIcon: " ",
viewBtnIcon: " ",
delBtnIcon: " ",
editBtnIcon: " ",
align: "center",
column: [
{
label: '月份',
prop: 'month',
type: "month",
sortable: true,
filter: true,
format:'YYYY-MM',
valueFormat:'YYYY-MM',
span: 24,
search: true,
width: 120,
searchLabelWidth: 50,
},
6 months ago
{
label: "上年度月用水",
prop: "lastWater",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 140,
},
{
label: "上年度月用电",
prop: "lastElectric",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 140,
},
{
label: "上年度月产值",
prop: "lastOutput",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 140,
},
{
label: "本年度月用水",
prop: "currentWater",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 140,
},
{
label: "本年度月用电",
prop: "currentElectric",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 140,
},
{
label: "本年度月产值",
prop: "currentOutput",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 140,
},
{
label: "上年度月用水目标",
prop: "lastWaterTarget",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 170,
},
{
label: "上年度月用电目标",
prop: "lastElectricTarget",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 170,
},
{
label: "本年度月用水目标",
prop: "currentWaterTarget",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 170,
6 months ago
},
{
label: "本年度月用电目标",
prop: "currentElectricTarget",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 170,
6 months ago
},
{
label: "上年度月用水实际完成",
prop: "lastWaterRate",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 200,
},
{
label: "上年度月用电实际完成",
prop: "lastElectricRate",
search: false,
sortable: true,
filter: true,
span: 12,
width: 200,
},
{
label: "本年度月用电实际完成",
prop: "currentElectricRate",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 200,
},
{
label: "本年度月用水实际完成",
prop: "currentWaterRate",
6 months ago
search: false,
sortable: true,
filter: true,
span: 12,
width: 200,
},
// {
// label: "创建人",
// prop: "userName",
// search: false,
// sortable: true,
// filter: true,
// span: 12,
// width: 140,
// },
// {
// label: "创建时间",
// prop: "uploadTime",
// search: false,
// sortable: true,
// filter: true,
// span: 12,
// width: 140,
// },
6 months ago
],
},
form: {},
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
};
},
methods: {
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
6 months ago
// 点击导入按钮
handleImport() {
this.isShowImport = true
},
6 months ago
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning("请选择至少一条数据");
return;
}
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
const ids = this.selectionList.map(item => item.emId).join(',');
removeItem(ids).then(() => {
this.$message.success("删除成功");
this.onLoad(this.page);
this.selectionClear();
});
});
},
rowDel(row) {
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
removeItem(row.emId).then(() => {
this.$message.success("删除成功");
this.onLoad(this.page);
});
});
},
rowSave(row, done, loading) {
const submitData = { ...row };
// 处理日期字段,确保为字符串格式
if (submitData.emMonth) {
if (typeof submitData.emMonth === 'object' && submitData.emMonth instanceof Date) {
const year = submitData.emMonth.getFullYear();
const month = String(submitData.emMonth.getMonth() + 1).padStart(2, '0');
const day = String(submitData.emMonth.getDate()).padStart(2, '0');
submitData.emMonth = `${year}-${month}-${day}`;
} else if (typeof submitData.emMonth === 'string') {
submitData.emMonth = submitData.emMonth.substring(0, 10);
}
}
saveItem(submitData).then(() => {
this.$message.success("新增成功");
this.onLoad(this.page);
done();
}).catch(() => {
loading();
});
},
rowUpdate(row, index, done, loading) {
const submitData = { ...row };
// 处理日期字段,确保为字符串格式
if (submitData.emMonth) {
if (typeof submitData.emMonth === 'object' && submitData.emMonth instanceof Date) {
const year = submitData.emMonth.getFullYear();
const month = String(submitData.emMonth.getMonth() + 1).padStart(2, '0');
const day = String(submitData.emMonth.getDate()).padStart(2, '0');
submitData.emMonth = `${year}-${month}-${day}`;
} else if (typeof submitData.emMonth === 'string') {
submitData.emMonth = submitData.emMonth.substring(0, 10);
}
}
saveItem(submitData).then(() => {
this.$message.success("修改成功");
this.onLoad(this.page);
done();
}).catch(() => {
loading();
});
6 months ago
},
// 多选
selectionChange(list) {
this.selectionList = list;
},
6 months ago
onLoad() {
this.loading = true;
pageList(
this.page.currentPage,
this.page.pageSize,
{}
).then(res => {
this.data = res.data.data.records;
this.page.total = res.data.data.total;
this.loading = false;
setTimeout(() => {
this.selectionClear();
}, 500);
}).catch(() => {
this.loading = false;
});
6 months ago
},
},
};
</script>
6 months ago
<style lang="scss" scoped></style>