This commit is contained in:
hayu 2025-09-08 18:19:01 +08:00
parent 05be348f58
commit 8145feb1dc
2 changed files with 139 additions and 9 deletions

View File

@ -70,6 +70,14 @@ export function addDevice(data) {
})
}
export function editDeviceBatch(data) {
return request({
url: '/material/ma_machine/updateDate',
method: 'post',
data: data,
})
}
// 工程项目-列表
export function getProjectList(query) {
return request({

View File

@ -71,12 +71,25 @@
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button
type="success"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
:disabled="selectList.length === 0"
>
批量更改检验时间
<span v-if="selectList.length > 0" style="margin-left: 5px">({{ selectList.length }})</span>
</el-button>
<span v-if="selectList.length > 0" style="margin-left: 10px; color: #67c23a">
已选择 {{ selectList.length }} 条需更改数据
</span>
<el-button icon="el-icon-upload2" size="mini" @click="handleSynch">检验报告同步</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="deviceList" ref="multipleTable" row-key="maId" :max-height="650">
<!-- <el-table-column type="selection" width="55" align="center" :reserve-selection="true" /> -->
<el-table v-loading="loading" :data="deviceList" ref="multipleTable" @selection-change="handleSelectionChange" row-key="maId" :max-height="650">
<el-table-column type="selection" align="center" />
<el-table-column label="序号" align="center" width="80" type="index">
<template slot-scope="scope">
<span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
@ -432,6 +445,45 @@
</div>
</el-dialog>
<el-dialog :title="dialogTitle" :visible.sync="authDialogVisible" width="25%" append-to-body>
<el-form :model="authForm" ref="authFormRef" label-width="120px" class="auth-dialog-form">
<!-- 本次检验时间 -->
<el-form-item label="本次检验时间:" prop="currentCheckDate">
<el-date-picker
v-model="authForm.currentCheckDate"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
:picker-options="{
disabledDate(time) {
return time.getTime() > Date.now();
}
}"
@change="handleCurrentCheckDateChange"
/>
</el-form-item>
<!-- 下次检验时间 -->
<el-form-item label="下次检验时间:" prop="nextCheckDate">
<el-date-picker
v-model="authForm.nextCheckDate"
type="date"
placeholder="自动生成"
value-format="yyyy-MM-dd"
disabled
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="authDialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitForms">保存</el-button>
</div>
</el-dialog>
</div>
</template>
@ -442,6 +494,7 @@ import {
editDevice,
editMachineStatus,
addDevice,
editDeviceBatch,
delDevice,
getDeviceType,
getZichanType,
@ -502,6 +555,8 @@ export default {
title: '',
//
open: false,
selectList: [], //
selectedItems: [], //
//
queryParams: {
pageNum: 1,
@ -563,7 +618,12 @@ export default {
sortedKeeperOptions: [],
repairerOptions: [],
sortedRepairerOptions: [],
authDialogVisible: false,
dialogTitle: "检验时间设置",
authForm: {
currentCheckDate: null,
nextCheckDate: null,
},
titleSynch: '', //
openSynch: false, //
synchLoading: false, //loading
@ -723,6 +783,10 @@ export default {
this.deviceList = response.rows
this.total = response.total
this.loading = false
this.$nextTick(() => {
this.selectList = []
})
})
},
@ -1104,14 +1168,72 @@ export default {
// 5.
this.getList();
});
}
},
//
handleSelectionChange(validSelection) {
this.selectList = validSelection;
},
formatDate(date) {
if (!date) return null;
const y = date.getFullYear();
const m = String(date.getMonth() + 1).padStart(2, "0");
const d = String(date.getDate()).padStart(2, "0");
return `${y}-${m}-${d}`;
},
//
handleAdd() {
if (this.selectList.length === 0) {
this.$message.warning("请先选择要修改的数据");
return;
}
const today = new Date();
this.authForm.currentCheckDate = this.formatDate(today);
this.calculateNextCheckDate(today);
this.authDialogVisible = true;
},
//
handleCurrentCheckDateChange(val) {
if (val) {
this.calculateNextCheckDate(new Date(val));
} else {
this.authForm.nextCheckDate = null;
}
},
// handleExport() {
// this.download('/material/ma_machine/export', {
// ...this.queryParams
// }, `_${new Date().getTime()}.xlsx`)
// },
//
calculateNextCheckDate(date) {
let nextDate = new Date(date);
nextDate.setFullYear(nextDate.getFullYear() + 1);
nextDate.setDate(nextDate.getDate() - 1);
this.authForm.nextCheckDate = this.formatDate(nextDate);
},
//
async submitForms() {
if (!this.authForm.currentCheckDate) {
this.$message.error("请选择本次检验时间");
return;
}
if (this.selectList.length === 0) {
this.$message.warning("没有选择任何设备");
return;
}
//
const params = {
maIds: this.selectList.map(item => item.maId),
thisCheckTime: this.authForm.currentCheckDate,
nextCheckTime: this.authForm.nextCheckDate
};
console.log(params)
try {
await editDeviceBatch(params);
this.$message.success("批量更新成功");
this.authDialogVisible = false;
this.getList();
} catch (e) {
this.$message.error("批量更新失败");
}
},
}
}
</script>