418 lines
10 KiB
Vue
418 lines
10 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<!-- 搜索工作栏 -->
|
|
<SearchBar
|
|
:formConfigs="searchBarFormConfig"
|
|
ref="search-bar"
|
|
@headBtnClick="handleSearchBarBtnClick" />
|
|
|
|
<!-- 列表 -->
|
|
<base-table
|
|
:table-props="tableProps"
|
|
:page="queryParams.pageNo"
|
|
:limit="queryParams.pageSize"
|
|
:table-data="list"
|
|
@emitFun="handleEmitFun"
|
|
:max-height="tableH">
|
|
<method-btn
|
|
v-if="tableBtn.length"
|
|
slot="handleBtn"
|
|
label="操作"
|
|
:width="90"
|
|
:method-list="tableBtn"
|
|
@clickBtn="handleTableBtnClick" />
|
|
</base-table>
|
|
|
|
<!-- 分页组件 -->
|
|
<pagination
|
|
v-show="total > 0"
|
|
:total="total"
|
|
:page.sync="queryParams.pageNo"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getList" />
|
|
|
|
<!-- 对话框(添加 / 修改) -->
|
|
<base-dialog
|
|
:dialogTitle="title"
|
|
:dialogVisible="open"
|
|
@close="cancel"
|
|
@cancel="cancel"
|
|
@confirm="submitForm">
|
|
<DialogForm
|
|
v-if="open"
|
|
ref="form"
|
|
v-model="form"
|
|
:disabled="mode == 'detail'" />
|
|
</base-dialog>
|
|
<CustomDialogForm
|
|
v-if="addOrUpdateVisible"
|
|
ref="addOrUpdate"
|
|
@refreshDataList="getList" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
// import moment from 'moment';
|
|
import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
|
import CustomDialogForm from './CustomDialogForm.vue';
|
|
import { deleteRepair, exportRepairLogExcel } from '@/api/equipment/base/repair'
|
|
import { parseTime } from '@/utils/ruoyi'
|
|
import htmls from './htmls.vue'
|
|
import DialogForm from './Repair--add.vue';
|
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
|
// const timeFilter = (val) => moment(val).format('yyyy-MM-DD HH:mm:ss');
|
|
|
|
export default {
|
|
name: 'EquipmentRepair',
|
|
components: { CustomDialogForm, DialogForm },
|
|
mixins: [basicPageMixin, tableHeightMixin],
|
|
data() {
|
|
return {
|
|
addOrUpdateVisible: false,
|
|
searchBarKeys: ['maintenanceResult', 'createTime', 'equipmentId'],
|
|
tableBtn: [
|
|
this.$auth.hasPermi('equipment:repair:query')
|
|
? {
|
|
type: 'detail',
|
|
btnName: '详情',
|
|
}
|
|
: undefined,
|
|
// this.$auth.hasPermi('equipment:repair:finish')
|
|
// ? {
|
|
// type: 'finish',
|
|
// btnName: '完成',
|
|
// }
|
|
// : undefined,
|
|
// this.$auth.hasPermi('equipment:repair:update')
|
|
// ? {
|
|
// type: 'edit',
|
|
// btnName: '修改',
|
|
// }
|
|
// : undefined,
|
|
this.$auth.hasPermi('equipment:repair:delete')
|
|
? {
|
|
type: 'delete',
|
|
btnName: '删除',
|
|
}
|
|
: undefined,
|
|
].filter((v) => v),
|
|
tableProps: [
|
|
// {
|
|
// prop: 'createTime',
|
|
// label: '添加时间',
|
|
// fixed: true,
|
|
// width: 180,
|
|
// filter: parseTime,
|
|
// },
|
|
{ prop: 'repairOrderNumber', label: '维修单号', width: 180, showOverflowtooltip: true },
|
|
{ prop: 'lineName', label: '产线名', width: 120, showOverflowtooltip: true },
|
|
{ prop: 'sectionName', label: '工段名', width: 120, showOverflowtooltip: true },
|
|
{ prop: 'equipmentName', label: '设备名称', minWidth: 100, showOverflowtooltip: true },
|
|
{ prop: 'faultDetail', label: '故障明细', subcomponent: htmls, width: 180, showOverflowtooltip: true },
|
|
// { prop: 'maintenanceDetail', label: '维修明细', subcomponent: htmls, minWidth: 100, showOverflowtooltip: true },
|
|
{
|
|
prop: 'maintenanceStartTime',
|
|
label: '维修开始时间',
|
|
width: 150,
|
|
filter: parseTime,
|
|
},
|
|
{
|
|
prop: 'maintenanceFinishTime',
|
|
label: '维修结束时间',
|
|
width: 150,
|
|
filter: parseTime,
|
|
},
|
|
// { prop: 'maintenanceStartTime', label: '开始时间', filter: parseTime },
|
|
{
|
|
prop: 'maintenanceResult',
|
|
label: '维修结果',
|
|
filter: (v) => (v != null ? ['成功', '失败'][v] : ''),
|
|
},
|
|
// { prop: 'maintenanceDuration', label: '维修时长(h)' },
|
|
{ prop: 'maintenanceDetail', label: '维修描述', subcomponent: htmls }, // 没有参数
|
|
// { prop: 'repairman', label: '维修工', minWidth: 100, showOverflowtooltip: true },
|
|
// { prop: 'repairmanPhone', label: '联系方式', minWidth: 100, showOverflowtooltip: true },
|
|
{ prop: 'remark', label: '备注', minWidth: 90, showOverflowtooltip: true }
|
|
],
|
|
searchBarFormConfig: [
|
|
{
|
|
type: 'select',
|
|
label: '设备',
|
|
placeholder: '请选择设备',
|
|
param: 'equipmentId',
|
|
filterable: true,
|
|
},
|
|
{
|
|
type: 'select',
|
|
label: '维修结果',
|
|
placeholder: '请选择状态',
|
|
param: 'maintenanceResult',
|
|
selectOptions: [
|
|
{ name: '成功', id: '0' },
|
|
{ name: '失败', id: '1' }
|
|
],
|
|
},
|
|
// 时间段
|
|
{
|
|
type: 'datePicker',
|
|
label: '时间段',
|
|
dateType: 'daterange', // datetimerange
|
|
format: 'yyyy-MM-dd',
|
|
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
|
// valueFormat: 'timestamp',
|
|
rangeSeparator: '-',
|
|
startPlaceholder: '开始日期',
|
|
endPlaceholder: '结束日期',
|
|
defaultTime: ['00:00:00', '23:59:59'],
|
|
param: 'createTime'
|
|
},
|
|
{
|
|
type: 'button',
|
|
btnName: '查询',
|
|
name: 'search',
|
|
color: 'primary',
|
|
},
|
|
{
|
|
type: (this.$auth.hasPermi('equipment:repair:export') ||
|
|
this.$auth.hasPermiAnd([
|
|
'equipment:repair:create',
|
|
'base:core-worker:query',
|
|
'system:user:list'
|
|
])) ? 'separate' : '',
|
|
},
|
|
{
|
|
type: this.$auth.hasPermi('equipment:repair:export') ? 'button' : '',
|
|
btnName: '导出',
|
|
name: 'export',
|
|
plain: true,
|
|
color: 'primary',
|
|
},
|
|
{
|
|
type: this.$auth.hasPermiAnd([
|
|
'equipment:repair:create',
|
|
'base:core-worker:query',
|
|
'system:user:list'
|
|
]) ? 'button' : '',
|
|
btnName: '新增',
|
|
name: 'add',
|
|
plain: true,
|
|
color: 'success',
|
|
},
|
|
],
|
|
// 是否显示弹出层
|
|
open: false,
|
|
// 查询参数
|
|
queryParams: {
|
|
pageNo: 1,
|
|
pageSize: 20,
|
|
special: false,
|
|
maintenanceResult: null,
|
|
createTime: null,
|
|
equipmentId: null,
|
|
special: false
|
|
},
|
|
// 表单参数
|
|
form: {},
|
|
basePath: '/base/equipment-repair-log',
|
|
mode: null
|
|
};
|
|
},
|
|
created() {
|
|
this.initSearchBar();
|
|
this.getList();
|
|
},
|
|
methods: {
|
|
initSearchBar() {
|
|
this.http('/base/core-equipment/page', 'get', {
|
|
special: false,
|
|
pageNo: 1,
|
|
pageSize: 99,
|
|
}).then(({ data }) => {
|
|
this.$set(
|
|
this.searchBarFormConfig[0],
|
|
'selectOptions',
|
|
(data?.list || []).map((item) => ({
|
|
name: item.name,
|
|
id: item.id,
|
|
}))
|
|
);
|
|
});
|
|
},
|
|
/** 查询列表 */
|
|
getList() {
|
|
this.loading = true;
|
|
// 执行查询
|
|
this.recv(this.queryParams).then((response) => {
|
|
this.list = response.data.list;
|
|
this.total = response.data.total;
|
|
this.loading = false;
|
|
});
|
|
},
|
|
/** 取消按钮 */
|
|
cancel() {
|
|
this.open = false;
|
|
this.mode = null;
|
|
this.reset();
|
|
},
|
|
/** 表单重置 */
|
|
reset() {
|
|
this.form = {
|
|
id: null,
|
|
repairOrderNumber: null,
|
|
equipmentId: null,
|
|
repairman: null,
|
|
repairmanPhone: null,
|
|
faultTime: null,
|
|
faultLevel: null,
|
|
maintenanceStartTime: null,
|
|
maintenanceFinishTime: null,
|
|
faultType: null,
|
|
repairMode: null,
|
|
maintenanceStatus: null,
|
|
faultDetail: null,
|
|
maintenanceDetail: null,
|
|
remark: null,
|
|
files: [
|
|
// {
|
|
// fileName: '',
|
|
// fileType: '',
|
|
// fileUrl: '',
|
|
// },
|
|
],
|
|
};
|
|
this.resetForm('form');
|
|
},
|
|
/** 搜索按钮操作 */
|
|
handleQuery() {
|
|
this.queryParams.pageNo = 1;
|
|
this.getList();
|
|
},
|
|
/** 重置按钮操作 */
|
|
resetQuery() {
|
|
this.resetForm('queryForm');
|
|
this.handleQuery();
|
|
},
|
|
/** 新增按钮操作 */
|
|
handleAdd() {
|
|
this.reset();
|
|
this.open = true;
|
|
this.title = '添加维修记录';
|
|
},
|
|
/** 修改按钮操作 */
|
|
handleUpdate(row) {
|
|
// this.reset();
|
|
// const id = row.id;
|
|
// this.info({ id }).then((response) => {
|
|
// this.form = response.data;
|
|
// // this.form.repairman = this.form.repairman.split(',')
|
|
// this.open = true;
|
|
// this.title = '修改维修记录';
|
|
// });
|
|
this.addOrUpdateVisible = true
|
|
this.$nextTick(() => {
|
|
this.$refs.addOrUpdate.init({id: row.id});
|
|
});
|
|
},
|
|
/** 完成按钮操作 */
|
|
handlFinish(row) {
|
|
this.addOrUpdateVisible = true
|
|
const params = {
|
|
id: row.id,
|
|
maintenanceStatus: 1
|
|
}
|
|
this.$nextTick(() => {
|
|
this.$refs.addOrUpdate.init(params);
|
|
});
|
|
},
|
|
/** 提交按钮 */
|
|
submitForm() {
|
|
this.$refs['form'].validate((valid) => {
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
// if (this.form.repairman) {
|
|
// this.form.repairman = this.form.repairman.join(',')
|
|
// }
|
|
// 修改的提交
|
|
if (this.form.id != null) {
|
|
this.put({
|
|
...this.form,
|
|
repairman: this.form.repairman.join(',')
|
|
}).then((response) => {
|
|
this.$modal.msgSuccess('修改成功');
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
return;
|
|
}
|
|
// 添加的提交
|
|
this.post({
|
|
...this.form,
|
|
repairman: this.form.repairman.join(',')
|
|
}).then((response) => {
|
|
this.$modal.msgSuccess('新增成功');
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
});
|
|
},
|
|
/** 删除按钮操作 */
|
|
handleDelete(row) {
|
|
const id = row.id;
|
|
this.$modal
|
|
.confirm('是否确认删除维修单号为"' + row.repairOrderNumber + '"的数据?')
|
|
.then(() => {
|
|
return deleteRepair(id);
|
|
})
|
|
.then(() => {
|
|
this.getList();
|
|
this.$modal.msgSuccess('删除成功');
|
|
})
|
|
.catch(() => {});
|
|
},
|
|
handleDetail({ id }) {
|
|
this.addOrUpdateVisible = true
|
|
this.$nextTick(() => {
|
|
this.$refs.addOrUpdate.init({id: id}, true);
|
|
});
|
|
},
|
|
/** 导出按钮操作 */
|
|
handleExport() {
|
|
// 处理查询参数
|
|
let params = { ...this.queryParams };
|
|
params.pageNo = undefined;
|
|
params.pageSize = undefined;
|
|
this.$modal
|
|
.confirm('是否确认导出所有维修记录?')
|
|
.then(() => {
|
|
this.exportLoading = true;
|
|
return exportRepairLogExcel(params);
|
|
})
|
|
.then((response) => {
|
|
this.$download.excel(response, '设备维修.xls');
|
|
this.exportLoading = false;
|
|
})
|
|
.catch(() => {});
|
|
},
|
|
// 处理表格按钮
|
|
handleTableBtnClick({ data, type }) {
|
|
console.log('nihc', data, type)
|
|
switch (type) {
|
|
case 'edit':
|
|
this.handleUpdate(data);
|
|
break;
|
|
case 'delete':
|
|
this.handleDelete(data);
|
|
break;
|
|
case 'detail':
|
|
this.handleDetail(data);
|
|
break;
|
|
case 'finish':
|
|
this.handlFinish(data);
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
};
|
|
</script>
|