yudao-dev/src/views/equipment/base/inspection/Settings/add-or-updata.vue

301 lines
6.2 KiB
Vue
Raw Normal View History

2023-11-11 20:49:31 +08:00
<!--
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: DY
2024-07-30 08:36:49 +08:00
* @LastEditTime: 2024-02-26 08:40:22
2023-11-11 20:49:31 +08:00
* @Description:
-->
<template>
<el-drawer
:visible.sync="visible"
:show-close="false"
2024-07-30 08:36:49 +08:00
:wrapper-closable="true"
2023-11-11 20:49:31 +08:00
class="drawer"
size="50%">
<small-title slot="title" :no-padding="true">
2024-07-30 08:36:49 +08:00
<!-- {{ isdetail ? '详情' : '添加巡检' }} -->
{{ '添加内容' }}
2023-11-11 20:49:31 +08:00
</small-title>
<div class="content">
<div class="visual-part">
2024-07-30 08:36:49 +08:00
<el-row :gutter="20">
<el-col :span="8">
<div class="blodTip">巡检单名称</div>
<div class="lightTip">{{ dataForm.name }}</div>
</el-col>
<el-col :span="8">
<div class="blodTip">部门</div>
<div class="lightTip">{{ dataForm.department }}</div>
</el-col>
<el-col :span="8">
<div class="blodTip">巡检时间</div>
<div class="lightTip">{{ parseTime(dataForm.planCheckTime) }}</div>
</el-col>
</el-row>
2023-11-11 20:49:31 +08:00
</div>
2024-07-30 08:36:49 +08:00
<el-divider />
2023-11-11 20:49:31 +08:00
<div class="attr-list">
<small-title
style="margin: 16px 0; padding-left: 8px"
:no-padding="true">
2024-07-30 08:36:49 +08:00
巡检内容
2023-11-11 20:49:31 +08:00
</small-title>
<div v-if="!isdetail" class="action_btn">
<template>
2023-11-24 19:01:25 +08:00
<span style="display: inline-block;">
<el-button type="text" @click="addNew()" icon="el-icon-plus">添加</el-button>
</span>
</template>
2023-11-11 20:49:31 +08:00
</div>
<base-table
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:table-data="checkDetList">
<method-btn
v-if="!isdetail"
slot="handleBtn"
:width="120"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
v-show="listQuery.total > 0"
:total="listQuery.total"
:page.sync="listQuery.pageNo"
:limit.sync="listQuery.pageSize"
:page-sizes="[5, 10, 15]"
@pagination="getList" />
2024-07-30 08:36:49 +08:00
<!-- <div class="drawer-body__footer">
2023-11-11 20:49:31 +08:00
<el-button type="primary" @click="goback()">关闭</el-button>
2024-07-30 08:36:49 +08:00
</div> -->
2023-11-11 20:49:31 +08:00
</div>
</div>
<attr-add
v-if="addOrUpdateVisible"
ref="addOrUpdate"
2024-07-30 08:36:49 +08:00
:order-id="dataForm.id"
2023-11-11 20:49:31 +08:00
@refreshDataList="getList" />
</el-drawer>
</template>
<script>
2024-07-30 08:36:49 +08:00
import { getCheckOrder } from "@/api/equipment/base/inspection/settings";
import { deleteCheckOrderDet, getCheckOrderDetPage } from '@/api/equipment/base/inspection/record';
2023-11-11 20:49:31 +08:00
import SmallTitle from './SmallTitle';
import attrAdd from './attr-add';
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
2024-07-30 08:36:49 +08:00
import { parseTime } from '../../../../core/mixins/code-filter';
2023-11-11 20:49:31 +08:00
const tableBtn = [
{
type: 'edit',
btnName: '编辑',
},
{
type: 'delete',
btnName: '删除',
},
];
const tableProps = [
{
2024-07-30 08:36:49 +08:00
prop: 'equipmentName',
label: '设备名称',
2023-11-11 20:49:31 +08:00
},
{
2024-07-30 08:36:49 +08:00
prop: 'program',
label: '检查项目',
}
2023-11-11 20:49:31 +08:00
];
export default {
components: { SmallTitle, attrAdd },
data() {
return {
tableBtn,
tableProps,
addOrUpdateVisible: false,
urlOptions: {
2024-07-30 08:36:49 +08:00
infoURL: getCheckOrder,
2023-11-11 20:49:31 +08:00
},
listQuery: {
pageSize: 10,
pageNo: 1,
total: 0,
},
dataForm: {
id: undefined,
2024-07-30 08:36:49 +08:00
name: undefined,
department: undefined,
planCheckTime: undefined
2023-11-11 20:49:31 +08:00
},
checkDetList: [],
visible: false,
2024-07-30 08:36:49 +08:00
isdetail: false
2023-11-11 20:49:31 +08:00
};
},
mounted() {},
methods: {
initData() {
this.checkDetList.splice(0);
this.listQuery.total = 0;
},
handleClick(raw) {
if (raw.type === 'delete') {
this.$confirm(
2023-11-27 20:41:45 +08:00
`是否确认删除巡检项目名称为"${raw.data.program}"的数据项?`,
2023-11-11 20:49:31 +08:00
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
2024-07-30 08:36:49 +08:00
deleteCheckOrderDet(raw.data.id).then(({ data }) => {
2023-11-11 20:49:31 +08:00
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getList();
},
});
});
})
.catch(() => {});
} else {
this.addNew(raw.data.id);
}
},
getList() {
// 获取巡检项目分页
2024-07-30 08:36:49 +08:00
getCheckOrderDetPage({
2023-11-11 20:49:31 +08:00
...this.listQuery,
2024-07-30 08:36:49 +08:00
orderId: this.dataForm.id,
2023-11-11 20:49:31 +08:00
}).then((response) => {
this.checkDetList = response.data.list;
this.listQuery.total = response.data.total;
});
},
init(id, isdetail) {
this.initData();
this.isdetail = isdetail || false;
this.dataForm.id = id || undefined;
this.visible = true;
this.$nextTick(() => {
2024-07-30 08:36:49 +08:00
// this.$refs['dataForm'].resetFields();
2023-11-11 20:49:31 +08:00
if (this.dataForm.id) {
// 获取设备巡检详情
this.urlOptions.infoURL(id).then(response => {
this.dataForm = response.data
});
// 获取设备项目列表
this.getList();
} else {
if (this.urlOptions.isGetCode) {
this.getCode()
}
}
});
},
goback() {
this.$emit('refreshDataList');
this.visible = false;
// this.initData();
},
goEdit() {
this.isdetail = false;
},
// 新增 / 修改
addNew(id) {
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id);
});
}
}
};
</script>
<style scoped>
.drawer >>> .el-drawer {
border-radius: 8px 0 0 8px;
display: flex;
flex-direction: column;
}
.drawer >>> .el-form-item__label {
padding: 0;
}
.drawer >>> .el-drawer__header {
margin: 0;
padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6;
}
.drawer >>> .el-drawer__body {
flex: 1;
height: 1px;
display: flex;
flex-direction: column;
}
.drawer >>> .content {
padding: 30px 24px;
flex: 1;
display: flex;
flex-direction: column;
/* height: 100%; */
}
.drawer >>> .visual-part {
flex: 1 auto;
2024-07-30 08:36:49 +08:00
max-height: 10vh;
2023-11-11 20:49:31 +08:00
overflow: hidden;
overflow-y: scroll;
padding-right: 10px; /* 调整滚动条样式 */
}
.drawer >>> .el-form,
.drawer >>> .attr-list {
padding: 0 16px;
}
.drawer-body__footer {
display: flex;
justify-content: flex-end;
padding: 18px;
}
.action_btn {
float: right;
2023-11-24 19:01:25 +08:00
margin: -40px 15px;
2023-11-11 20:49:31 +08:00
font-size: 14px;
}
.add {
color: #0b58ff;
}
2024-07-30 08:36:49 +08:00
.blodTip {
height: 16px;
font-size: 14px;
font-weight: 600;
color: rgba(0,0,0,0.85);
margin-bottom: 8px;
}
.lightTip {
/* height: 16px; */
font-size: 14px;
font-weight: 400;
color: rgba(102,102,102,0.75);
margin-bottom: 12px;
}
2023-11-11 20:49:31 +08:00
</style>