Commit af5200d1 authored by jiaxu.yan's avatar jiaxu.yan

feat: 调度模块修改

parent 00f525ab
...@@ -75,6 +75,7 @@ const rules = reactive({ ...@@ -75,6 +75,7 @@ const rules = reactive({
const energyTypeList = ref(['一步节能', '二步节能', '三步节能', '四步节能', '非节能']) // 节能等级列表 const energyTypeList = ref(['一步节能', '二步节能', '三步节能', '四步节能', '非节能']) // 节能等级列表
const currentMonth = ref(0) const currentMonth = ref(0)
const currentYear = ref(0) const currentYear = ref(0)
const addSaveBtnLoading = ref(false)
const selectYearValue = computed(() => { const selectYearValue = computed(() => {
if (currentMonth.value >= 7) { if (currentMonth.value >= 7) {
return currentYear.value + "年-" + (currentYear.value + 1) + "年" return currentYear.value + "年-" + (currentYear.value + 1) + "年"
...@@ -132,6 +133,7 @@ function handleAdd() { ...@@ -132,6 +133,7 @@ function handleAdd() {
resetInput() resetInput()
addWindowOpen.value = true addWindowOpen.value = true
formRef.value.resetFields() formRef.value.resetFields()
addSaveBtnLoading.value = false
} // 处理新增 } // 处理新增
function handleSearch() { function handleSearch() {
if (!searchKey.value) { if (!searchKey.value) {
...@@ -191,6 +193,7 @@ function onReviseSubmit() { ...@@ -191,6 +193,7 @@ function onReviseSubmit() {
}) })
} // 提交修改 } // 提交修改
function onAddSubmit() { // 提交新增 function onAddSubmit() { // 提交新增
addSaveBtnLoading.value = true
formRef.value.validate(valid => { formRef.value.validate(valid => {
if (valid) { if (valid) {
if (addForm.value.year.trim().length > 4) { if (addForm.value.year.trim().length > 4) {
...@@ -200,6 +203,7 @@ function onAddSubmit() { // 提交新增 ...@@ -200,6 +203,7 @@ function onAddSubmit() { // 提交新增
if (String(item.year).trim() === String(addForm.value.year).trim()) { if (String(item.year).trim() === String(addForm.value.year).trim()) {
if (String(item.energyType).trim() === String(addForm.value.energyType).trim()) { if (String(item.energyType).trim() === String(addForm.value.energyType).trim()) {
ElMessage.error('该年该类型已存在.') ElMessage.error('该年该类型已存在.')
addSaveBtnLoading.value = false
return return
} }
} }
...@@ -217,14 +221,19 @@ function onAddSubmit() { // 提交新增 ...@@ -217,14 +221,19 @@ function onAddSubmit() { // 提交新增
message: res.success, message: res.success,
type: 'error', type: 'error',
}) })
addSaveBtnLoading.value = false
} }
}).catch(err => { }).catch(err => {
ElMessage({ ElMessage({
message: '接口异常,新增失败.', message: '接口异常,新增失败.',
type: 'error', type: 'error',
}) })
addSaveBtnLoading.value = false
}) })
} }
else {
addSaveBtnLoading.value = false
}
}) })
} // 提交新增 } // 提交新增
function handleClose() { function handleClose() {
...@@ -507,7 +516,7 @@ function getOrganizationStructure() { ...@@ -507,7 +516,7 @@ function getOrganizationStructure() {
</template> </template>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="onAddSubmit">保存</el-button> <el-button type="primary" :loading="addSaveBtnLoading" @click="onAddSubmit">保存</el-button>
<el-button type="primary" @click="handleClose">关闭</el-button> <el-button type="primary" @click="handleClose">关闭</el-button>
</div> </div>
</template> </template>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="openingOfElectricValve"> <el-form-item prop="openingOfElectricValve" style="padding: 0;margin: 0;">
<el-input v-float-number style="width: 80%; text-align: left" <el-input v-float-number style="width: 80%; text-align: left"
v-model="formDatas.openingOfElectricValve"> v-model="formDatas.openingOfElectricValve">
<template #append> <template #append>
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="boilerOutletWaterTemperature"> <el-form-item prop="boilerOutletWaterTemperature" style="padding: 0;margin: 0;">
<el-input style="width: 80%" v-model="formDatas.boilerOutletWaterTemperature"> <el-input style="width: 80%" v-model="formDatas.boilerOutletWaterTemperature">
<template #append> <template #append>
<div style="width: 40px"></div> <div style="width: 40px"></div>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="holdingTime"> <el-form-item prop="holdingTime" style="padding: 0;margin: 0;">
<el-input v-float-number style="width: 80%" v-model="formDatas.holdingTime"> <el-input v-float-number style="width: 80%" v-model="formDatas.holdingTime">
<template #append> <template #append>
<div style="width: 40px">分钟</div> <div style="width: 40px">分钟</div>
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="upperLlimitMainFlow"> <el-form-item prop="upperLlimitMainFlow" style="padding: 0;margin: 0;">
<el-input v-float-number style="width: 80%" v-model="formDatas.upperLlimitMainFlow"> <el-input v-float-number style="width: 80%" v-model="formDatas.upperLlimitMainFlow">
<template #append> <template #append>
<div style="width: 40px">m3/h</div> <div style="width: 40px">m3/h</div>
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="lowerLlimitMainFlow"> <el-form-item prop="lowerLlimitMainFlow" style="padding: 0;margin: 0;">
<el-input v-float-number style="width: 80%" v-model="formDatas.lowerLlimitMainFlow"> <el-input v-float-number style="width: 80%" v-model="formDatas.lowerLlimitMainFlow">
<template #append> <template #append>
<div style="width: 40px">m3/h</div> <div style="width: 40px">m3/h</div>
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="maxTargetTemperature"> <el-form-item prop="maxTargetTemperature" style="padding: 0;margin: 0;">
<el-input style="width: 80%" v-model="formDatas.maxTargetTemperature"> <el-input style="width: 80%" v-model="formDatas.maxTargetTemperature">
<template #append> <template #append>
<div style="width: 40px"></div> <div style="width: 40px"></div>
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="bestHoldingTime"> <el-form-item prop="bestHoldingTime" style="padding: 0;margin: 0;">
<el-input v-float-number style="width: 80%" v-model="formDatas.bestHoldingTime"> <el-input v-float-number style="width: 80%" v-model="formDatas.bestHoldingTime">
<template #append> <template #append>
<div style="width: 40px">分钟</div> <div style="width: 40px">分钟</div>
......
...@@ -31,6 +31,7 @@ const reset = () => { ...@@ -31,6 +31,7 @@ const reset = () => {
"energyName": '' "energyName": ''
} }
} }
const addSaveBtnLoading = ref(false)
const loading = ref(false) const loading = ref(false)
const energyForm = ref() const energyForm = ref()
const dialogVisible = ref(false) const dialogVisible = ref(false)
...@@ -122,6 +123,9 @@ const rules = reactive({ ...@@ -122,6 +123,9 @@ const rules = reactive({
recordDate: [{ required: true, message: "日期是必选项" }], recordDate: [{ required: true, message: "日期是必选项" }],
}); });
// 放重复点击操作
const clicked = ref(false)
// 删除 // 删除
const handleDelete = (row) => { const handleDelete = (row) => {
console.log(row.energyId); console.log(row.energyId);
...@@ -159,6 +163,7 @@ const handleCancel = () => { ...@@ -159,6 +163,7 @@ const handleCancel = () => {
const handleAdd = () => { const handleAdd = () => {
action.value = "add", action.value = "add",
dialogVisible.value = true; dialogVisible.value = true;
addSaveBtnLoading.value = false
reset() reset()
} }
// 编辑 // 编辑
...@@ -180,6 +185,7 @@ const handleEdit = (val) => { ...@@ -180,6 +185,7 @@ const handleEdit = (val) => {
}; };
const onSubmit = () => { const onSubmit = () => {
addSaveBtnLoading.value = true
loading.value = true loading.value = true
energyForm.value.validate((valid) => { energyForm.value.validate((valid) => {
if (valid) { if (valid) {
...@@ -189,13 +195,14 @@ const onSubmit = () => { ...@@ -189,13 +195,14 @@ const onSubmit = () => {
: timeFormat(formEnergy.recordDate); : timeFormat(formEnergy.recordDate);
if (action.value === "add") { if (action.value === "add") {
http.post("api/energy/Save", { ...formEnergy.value }, false).then(res => { http.post("api/energy/Save", { ...formEnergy.value }, false).then(res => {
loading.value = true
if (res.success) { if (res.success) {
dialogVisible.value = false dialogVisible.value = false
ElMessage.success(res.message) ElMessage.success(res.message)
getEnergyData(); getEnergyData();
loading.value = false
} }
}) })
loading.value = false
} else { } else {
delete formEnergy.value.supplyName; delete formEnergy.value.supplyName;
formEnergy.value.updateNullFields = ""; formEnergy.value.updateNullFields = "";
...@@ -214,6 +221,7 @@ const onSubmit = () => { ...@@ -214,6 +221,7 @@ const onSubmit = () => {
message: "请输入正确的内容", message: "请输入正确的内容",
type: "error", type: "error",
}); });
addSaveBtnLoading.value = false
} }
}); });
}; };
...@@ -339,12 +347,12 @@ onMounted(() => { ...@@ -339,12 +347,12 @@ onMounted(() => {
</div> </div>
<el-dialog v-model="dialogVisible" :title="action == 'add' ? '数据新增' : '数据修改'" width="50%" :before-close="handleClose"> <el-dialog v-model="dialogVisible" :title="action == 'add' ? '数据新增' : '数据修改'" width="50%" :before-close="handleClose">
<el-form :inline="true" :model="formEnergy" :rules="rules" ref="energyForm" :hide-required-asterisk="true"> <el-form :inline="true" :model="formEnergy" :rules="rules" ref="energyForm" :hide-required-asterisk="true">
<table cellpadding="0" cellspacing="1" style="background-color: #99bbe8"> <table cellpadding="0" cellspacing="1" style="background-color: #99bbe8 ; height: 50px;">
<tr> <tr>
<th style="width: 25%">供热站</th> <th style="width: 25%">供热站</th>
<td style="width: 60%; margin: 0; padding: 0"> <td style="width: 60%; margin: 0; padding: 0">
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr height="50px">
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="supplyName" style="margin: 0; padding: 0; width: 100%;"> <el-form-item prop="supplyName" style="margin: 0; padding: 0; width: 100%;">
<el-select v-model="formEnergy.supplyId" placeholder="请选择"> <el-select v-model="formEnergy.supplyId" placeholder="请选择">
...@@ -361,7 +369,7 @@ onMounted(() => { ...@@ -361,7 +369,7 @@ onMounted(() => {
<th style="width: 25%">能源类型</th> <th style="width: 25%">能源类型</th>
<td style="width: 60%; margin: 0; padding: 0"> <td style="width: 60%; margin: 0; padding: 0">
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr height="66px">
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="energyType" style="margin: 0; padding: 0; width: 100%"> <el-form-item prop="energyType" style="margin: 0; padding: 0; width: 100%">
<el-select v-model="formEnergy.energyType" placeholder="请选择"> <el-select v-model="formEnergy.energyType" placeholder="请选择">
...@@ -381,7 +389,7 @@ onMounted(() => { ...@@ -381,7 +389,7 @@ onMounted(() => {
<th style="width: 25%">能源用度</th> <th style="width: 25%">能源用度</th>
<td style="width: 60%; margin: 0; padding: 0"> <td style="width: 60%; margin: 0; padding: 0">
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr height="66px">
<td style="text-align: left"> <td style="text-align: left">
<el-form-item prop="record" style="margin: 0; padding: 0; width: 100%"> <el-form-item prop="record" style="margin: 0; padding: 0; width: 100%">
<el-input v-float-number v-model="formEnergy.record" placeholder="请输入能源用度" /> <el-input v-float-number v-model="formEnergy.record" placeholder="请输入能源用度" />
...@@ -395,7 +403,7 @@ onMounted(() => { ...@@ -395,7 +403,7 @@ onMounted(() => {
<th style="width: 25%">日期</th> <th style="width: 25%">日期</th>
<td style="width: 60%; margin: 0; padding: 0"> <td style="width: 60%; margin: 0; padding: 0">
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr height="66px">
<td> <td>
<el-form-item prop="recordDate" style="margin: 0; padding: 0; width: 100%"> <el-form-item prop="recordDate" style="margin: 0; padding: 0; width: 100%">
<el-date-picker value-format="YYYY-MM-DD HH:mm:ss" v-model="formEnergy.recordDate" type="datetime" <el-date-picker value-format="YYYY-MM-DD HH:mm:ss" v-model="formEnergy.recordDate" type="datetime"
...@@ -409,7 +417,7 @@ onMounted(() => { ...@@ -409,7 +417,7 @@ onMounted(() => {
</table> </table>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="handleCancel(energyForm)">关闭</el-button> <el-button type="primary" @click="handleCancel(energyForm)">关闭</el-button>
<el-button type="primary" @click="onSubmit()">保存</el-button> <el-button type="primary" :loading="addSaveBtnLoading" @click="onSubmit()">保存</el-button>
</div> </div>
</el-form> </el-form>
</el-dialog> </el-dialog>
......
<script setup> <script setup>
import {onMounted, ref, reactive} from "vue"; import {onMounted, ref, reactive, onBeforeMount} from "vue";
import {ElMessage, ElMessageBox} from "element-plus"; import {ElMessage, ElMessageBox} from "element-plus";
import {getPhenomenon, addPhenomenon, alterPhenomenon, deletePhenomenon} from "@/api/scheduling.js" import {getPhenomenon, addPhenomenon, alterPhenomenon, deletePhenomenon} from "@/api/scheduling.js"
import {vFloatNumber} from "@/utils/directives.js"; import {vFloatNumber} from "@/utils/directives.js";
...@@ -11,6 +11,7 @@ const reviseWindowOpen = ref(false) ...@@ -11,6 +11,7 @@ const reviseWindowOpen = ref(false)
const addWindowOpen = ref(false) const addWindowOpen = ref(false)
const reviseForm = ref({}) // 修改表单 const reviseForm = ref({}) // 修改表单
const addForm = ref({}) // 新增表单 const addForm = ref({}) // 新增表单
const addSaveBtnLoading = ref(false)
const formRef = ref() const formRef = ref()
...@@ -32,6 +33,7 @@ const tableBodyClass = data => { // 表体样式 ...@@ -32,6 +33,7 @@ const tableBodyClass = data => { // 表体样式
function add() { function add() {
addWindowOpen.value = true addWindowOpen.value = true
formRef.value.resetFields() formRef.value.resetFields()
addSaveBtnLoading.value = false
} // 新增按钮单击事件 } // 新增按钮单击事件
function revise(val) { function revise(val) {
reviseForm.value = {...val} reviseForm.value = {...val}
...@@ -88,6 +90,13 @@ function handleClose() { ...@@ -88,6 +90,13 @@ function handleClose() {
function onReviseSubmit() { function onReviseSubmit() {
formRef.value.validate((valid) => { formRef.value.validate((valid) => {
if (valid) { if (valid) {
if(Math.abs(Number(reviseForm.value.phenomenonTemp)) > 30){
ElMessage({
message: '对应温度不能大于30度或小于-30度',
type: 'error',
})
return
}
if (reviseForm.value.phenomenonName === '晴天') { if (reviseForm.value.phenomenonName === '晴天') {
reviseForm.value.phenomenonType = 1 reviseForm.value.phenomenonType = 1
} else if (reviseForm.value.phenomenonName === '多云') { } else if (reviseForm.value.phenomenonName === '多云') {
...@@ -121,7 +130,16 @@ function onReviseSubmit() { ...@@ -121,7 +130,16 @@ function onReviseSubmit() {
}) })
} // 修改表单提交 } // 修改表单提交
function onAddSubmit() { function onAddSubmit() {
addSaveBtnLoading.value = true
formRef.value.validate(valid => { formRef.value.validate(valid => {
if(Math.abs(Number(addForm.value.phenomenonTemp)) > 30){
ElMessage({
message: '对应温度不能大于30度或小于-30度',
type: 'error',
})
addSaveBtnLoading.value = false
return
}
if (valid) { if (valid) {
if (addForm.value.phenomenonName === '晴天') { if (addForm.value.phenomenonName === '晴天') {
addForm.value.phenomenonType = 1 addForm.value.phenomenonType = 1
...@@ -143,14 +161,19 @@ function onAddSubmit() { ...@@ -143,14 +161,19 @@ function onAddSubmit() {
message: res.message, message: res.message,
type: 'error', type: 'error',
}) })
addSaveBtnLoading.value = false
} }
}).catch(err => { }).catch(err => {
ElMessage({ ElMessage({
message: '新增失败.', message: '新增失败.',
type: 'error', type: 'error',
}) })
addSaveBtnLoading.value = false
}) })
} }
else {
addSaveBtnLoading.value = false
}
}) })
} // 新增表单提交 } // 新增表单提交
function resetInput() { function resetInput() {
...@@ -165,7 +188,6 @@ function resetSearch() { ...@@ -165,7 +188,6 @@ function resetSearch() {
searchKey.value = '' searchKey.value = ''
getData() getData()
} }
onMounted(() => { onMounted(() => {
getData() getData()
}) })
...@@ -282,7 +304,7 @@ function customSort(a, b) { ...@@ -282,7 +304,7 @@ function customSort(a, b) {
</template> </template>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="onAddSubmit">保存</el-button> <el-button type="primary" :loading="addSaveBtnLoading" @click="onAddSubmit">保存</el-button>
<el-button type="primary" @click="handleClose">关闭</el-button> <el-button type="primary" @click="handleClose">关闭</el-button>
</div> </div>
......
...@@ -10,6 +10,8 @@ const dataBackup = ref([]); ...@@ -10,6 +10,8 @@ const dataBackup = ref([]);
const searchKey = ref(""); // 查询参数 const searchKey = ref(""); // 查询参数
const reviseWindowOpen = ref(false); const reviseWindowOpen = ref(false);
const addWindowOpen = ref(false); const addWindowOpen = ref(false);
const addSaveBtnLoading = ref(false);
const reviseSaveBtnLoading = ref(false);
// const reviseForm = ref({}); // 修改表单 // const reviseForm = ref({}); // 修改表单
const addForm = ref({ const addForm = ref({
windLevel: "", windLevel: "",
...@@ -51,12 +53,14 @@ const rules = reactive({ ...@@ -51,12 +53,14 @@ const rules = reactive({
function add() { function add() {
addWindowOpen.value = true; addWindowOpen.value = true;
addSaveBtnLoading.value = false
formRef.value.resetFields() formRef.value.resetFields()
} // 新增按钮单击事件 } // 新增按钮单击事件
function revise(val) { function revise(val) {
reviseForm.value = { ...val }; reviseForm.value = { ...val };
reviseForm.value.windLevel = Number(reviseForm.value.windLevel); reviseForm.value.windLevel = Number(reviseForm.value.windLevel);
reviseWindowOpen.value = true; reviseWindowOpen.value = true;
reviseSaveBtnLoading.value = false
formRef.value.resetFields() formRef.value.resetFields()
} // 修改按钮单击事件 } // 修改按钮单击事件
function omit(val) { function omit(val) {
...@@ -106,8 +110,17 @@ function handleClose() { ...@@ -106,8 +110,17 @@ function handleClose() {
resetInput(); resetInput();
} // 关闭弹窗 } // 关闭弹窗
function onReviseSubmit() { function onReviseSubmit() {
reviseSaveBtnLoading.value = true
formRef.value.validate(valid=>{ formRef.value.validate(valid=>{
if(valid){ if(valid){
if(Math.abs(Number(reviseForm.value.windTemp)) > 30){
ElMessage({
message: '对应温度不能大于30度或小于-30度',
type: 'error',
})
reviseSaveBtnLoading.value = false
return
}
alterWind(reviseForm.value) alterWind(reviseForm.value)
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
...@@ -122,6 +135,7 @@ function onReviseSubmit() { ...@@ -122,6 +135,7 @@ function onReviseSubmit() {
message: res.message, message: res.message,
type: "error", type: "error",
}); });
reviseSaveBtnLoading.value = false
} }
}) })
.catch((err) => { .catch((err) => {
...@@ -129,13 +143,24 @@ function onReviseSubmit() { ...@@ -129,13 +143,24 @@ function onReviseSubmit() {
message: "修改失败.", message: "修改失败.",
type: "error", type: "error",
}); });
reviseSaveBtnLoading.value = false
}); });
} }
reviseSaveBtnLoading.value = false
}) })
} // 修改表单提交 } // 修改表单提交
function onAddSubmit() { function onAddSubmit() {
addSaveBtnLoading.value = true;
formRef.value.validate(valid=>{ formRef.value.validate(valid=>{
if(valid){ if(valid){
if(Math.abs(Number(addForm.value.windTemp)) > 30){
ElMessage({
message: '对应温度不能大于30度或小于-30度',
type: 'error',
})
addSaveBtnLoading.value = false
return
}
addWind(addForm.value) addWind(addForm.value)
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
...@@ -150,16 +175,19 @@ function onAddSubmit() { ...@@ -150,16 +175,19 @@ function onAddSubmit() {
message: res.message, message: res.message,
type: "error", type: "error",
}); });
addSaveBtnLoading.value = false
} }
}) })
.catch((err) => [ .catch((err) => {
ElMessage({ ElMessage({
message: "新增失败.", message: "新增失败.",
type: "error", type: "error",
}), })
]); addSaveBtnLoading.value = false
});
} }
addSaveBtnLoading.value = false
}) })
} // 新增表单提交 } // 新增表单提交
...@@ -253,7 +281,7 @@ function customSort(a, b) { ...@@ -253,7 +281,7 @@ function customSort(a, b) {
</template> </template>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="onReviseSubmit">保存</el-button> <el-button type="primary" :loading="reviseSaveBtnLoading" @click="onReviseSubmit">保存</el-button>
<el-button type="primary" @click="handleClose">关闭</el-button> <el-button type="primary" @click="handleClose">关闭</el-button>
</div> </div>
</template> </template>
...@@ -290,7 +318,7 @@ function customSort(a, b) { ...@@ -290,7 +318,7 @@ function customSort(a, b) {
</template> </template>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="onAddSubmit">保存</el-button> <el-button type="primary" :loading="addSaveBtnLoading" @click="onAddSubmit">保存</el-button>
<el-button type="primary" @click="handleClose">关闭</el-button> <el-button type="primary" @click="handleClose">关闭</el-button>
</div> </div>
</template> </template>
......
...@@ -36,14 +36,18 @@ function handleClose() { ...@@ -36,14 +36,18 @@ function handleClose() {
emit('onCancel') emit('onCancel')
} }
function handleConfirm() { function handleConfirm() {
addSaveBtnLoading.value = true
formRef.value.validate(valid=>{ formRef.value.validate(valid=>{
if(valid){ if(valid){
addData.value.operateTime = getCurrentDateTime() addData.value.operateTime = getCurrentDateTime()
emit('onConfirm', addData.value) emit('onConfirm', addData.value)
resetInput() resetInput()
}else {
addSaveBtnLoading.value = false
} }
}) })
} }
const addSaveBtnLoading = ref(false)
function getCurrentDateTime() { function getCurrentDateTime() {
const now = new Date(); const now = new Date();
const year = now.getFullYear(); const year = now.getFullYear();
...@@ -58,6 +62,7 @@ function getCurrentDateTime() { ...@@ -58,6 +62,7 @@ function getCurrentDateTime() {
function onOpen() { function onOpen() {
resetInput() resetInput()
formRef.value.resetFields() formRef.value.resetFields()
addSaveBtnLoading.value = false
} }
function resetInput() { function resetInput() {
addData.value = { addData.value = {
...@@ -201,7 +206,7 @@ const rules = reactive({ ...@@ -201,7 +206,7 @@ const rules = reactive({
</template> </template>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="handleConfirm">保存</el-button> <el-button type="primary" :loading="addSaveBtnLoading" @click="handleConfirm">保存</el-button>
<el-button type="primary" @click="handleClose">关闭</el-button> <el-button type="primary" @click="handleClose">关闭</el-button>
</div> </div>
</template> </template>
......
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