设备保养

This commit is contained in:
‘937886381’ 2024-07-22 09:11:01 +08:00
parent 67200710c9
commit a6fe9e654e
10 changed files with 1057 additions and 182 deletions

View File

@ -1,8 +1,8 @@
###
# @Author: Do not edit
# @Date: 2023-08-29 09:40:39
# @LastEditTime: 2023-11-21 10:36:47
# @LastEditors: DY
# @LastEditTime: 2024-07-22 08:48:47
# @LastEditors: zhp
# @Description:
###
# 开发环境配置
@ -13,7 +13,7 @@ VUE_APP_TITLE = MES系统
# 芋道管理系统/开发环境
# VUE_APP_BASE_API = 'http://100.64.0.26:48082'
VUE_APP_BASE_API = 'http://192.168.0.33:48082'
# VUE_APP_BASE_API = 'http://192.168.0.33:48082'
# VUE_APP_BASE_API = 'http://192.168.4.173:48080'
# VUE_APP_BASE_API = 'http://192.168.2.173:48080'
# VUE_APP_BASE_API = 'http://192.168.1.49:48082'
@ -21,6 +21,8 @@ VUE_APP_BASE_API = 'http://192.168.0.33:48082'
# VUE_APP_BASE_API = 'http://192.168.4.159:48080'
# VUE_APP_BASE_API = 'http://192.168.1.56:48082'
# VUE_APP_BASE_API = 'http://192.168.4.159:48080'
VUE_APP_BASE_API = 'http://192.168.1.64:48082'
# 积木报表指向地址
VUE_APP_JIMU_API = 'http://192.168.0.33:48082'

View File

@ -0,0 +1,47 @@
/*
* @Author: zhp
* @Date: 2024-07-12 15:31:41
* @LastEditTime: 2024-07-19 14:18:59
* @LastEditors: zhp
* @Description:
*/
import request from '@/utils/request'
// 删除设备保养记录
export function deleteData(id) {
return request({
url: '/base/equipment-maintain-program/delete?id=' + id,
method: 'delete'
})
}
export function getItemPageData(data) {
return request({
url: '/base/equipment-maintain-program/page',
method: 'get',
data
})
}
export function getItemData(id) {
return request({
url: 'base/equipment-maintain-program/get?id=' + id,
method: 'get'
})
}
export function updateItemData(data) {
return request({
url: 'base/equipment-maintain-program/update',
method: 'put',
data
})
}
export function createItemData(data) {
return request({
url: 'base/equipment-maintain-program/create',
method: 'post',
data
})
}

View File

@ -1,4 +1,4 @@
<!--
<!--
filename: dialogForm.vue
author: liubin
date: 2023-08-15 10:32:36
@ -6,123 +6,58 @@
-->
<template>
<el-form
ref="form"
:model="form"
:label-width="`${labelWidth}px`"
:size="size"
:label-position="labelPosition"
v-loading="formLoading">
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
<el-input
v-if="col.input"
v-model="form[col.prop]"
@change="$emit('update', form)"
:placeholder="`请输入${col.label}`"
:disabled="disabled"
v-bind="col.bind" />
<el-input
v-if="col.textarea"
type="textarea"
v-model="form[col.prop]"
:disabled="disabled"
@change="$emit('update', form)"
:placeholder="`请输入${col.label}`"
v-bind="col.bind" />
<el-select
v-if="col.select"
v-model="form[col.prop]"
:placeholder="`请选择${col.label}`"
:disabled="disabled"
@change="$emit('update', form)"
v-bind="col.bind">
<el-option
v-for="opt in optionListOf[col.prop]"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
<el-date-picker
v-if="col.datetime"
v-model="form[col.prop]"
type="datetime"
:disabled="disabled"
:placeholder="`请选择${col.label}`"
value-format="timestamp"
@change="$emit('update', form)"
v-bind="col.bind"></el-date-picker>
<el-switch
v-if="col.switch"
v-model="form[col.prop]"
:disabled="disabled"
active-color="#0b58ff"
inactive-color="#e1e1e1"
@change="$emit('update', form)"
v-bind="col.bind"></el-switch>
<component
v-if="col.subcomponent"
:key="col.key"
:disabled="disabled"
:read-only="disabled"
:is="col.subcomponent"
v-model="form[col.prop]"
:inlineStyle="col.style"
@on-change="$emit('update', form)"
v-bind="col.bind"></component>
<el-form ref="form" :model="form" :label-width="`${labelWidth}px`" :size="size" :label-position="labelPosition"
v-loading="formLoading">
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
<el-input v-if="col.input" v-model="form[col.prop]" @change="$emit('update', form)"
:placeholder="`请输入${col.label}`" :disabled="disabled" v-bind="col.bind" />
<el-input v-if="col.textarea" type="textarea" v-model="form[col.prop]" :disabled="disabled"
@change="$emit('update', form)" :placeholder="`请输入${col.label}`" v-bind="col.bind" />
<el-select v-if="col.select" v-model="form[col.prop]" :placeholder="`请选择${col.label}`" :disabled="disabled"
@change="$emit('update', form)" v-bind="col.bind">
<el-option v-for="opt in optionListOf[col.prop]" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
<el-date-picker v-if="col.datetime" v-model="form[col.prop]" type="datetime"
:disabled="col.disabled ? col.disabled : disabled" :placeholder="`请选择${col.label}`" value-format="timestamp"
@change="$emit('update', form)" v-bind="col.bind">
</el-date-picker>
<el-switch v-if="col.switch" v-model="form[col.prop]" :disabled="disabled" active-color="#0b58ff"
inactive-color="#e1e1e1" @change="$emit('update', form)" v-bind="col.bind"></el-switch>
<component v-if="col.subcomponent" :key="col.key" :disabled="disabled" :read-only="disabled"
:is="col.subcomponent" v-model="form[col.prop]" :inlineStyle="col.style" @on-change="$emit('update', form)"
v-bind="col.bind"></component>
<div
class="upload-area"
:class="uploadOpen ? '' : 'height-48'"
ref="uploadArea"
:key="col.prop"
v-if="col.upload">
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
<el-button
type="text"
icon="el-icon-arrow-right"
@click="handleFilesOpen" />
</span>
<!-- :file-list="uploadedFileList" -->
<el-upload
class="upload-in-dialog"
v-if="col.upload"
:key="col.prop + '__el-upload'"
:action="uploadUrl"
:headers="uploadHeaders"
:show-file-list="false"
icon="el-icon-upload2"
:disabled="disabled"
:before-upload="beforeUpload"
:on-success="
(response, file, fileList) => {
handleUploadSuccess(response, file, col.prop);
}
"
v-bind="col.bind">
<el-button size="mini" :disabled="col.bind?.disabled || false">
<svg-icon
icon-class="icon-upload"
style="color: inherit"></svg-icon>
上传文件
</el-button>
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
</div>
</el-upload>
<div class="upload-area" :class="uploadOpen ? '' : 'height-48'" ref="uploadArea" :key="col.prop"
v-if="col.upload">
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
<el-button type="text" icon="el-icon-arrow-right" @click="handleFilesOpen" />
</span>
<!-- :file-list="uploadedFileList" -->
<el-upload class="upload-in-dialog" v-if="col.upload" :key="col.prop + '__el-upload'" :action="uploadUrl"
:headers="uploadHeaders" :show-file-list="false" icon="el-icon-upload2" :disabled="disabled"
:before-upload="beforeUpload" :on-success="
(response, file, fileList) => {
handleUploadSuccess(response, file, col.prop);
}
" v-bind="col.bind">
<el-button size="mini" :disabled="col.bind?.disabled || false">
<svg-icon icon-class="icon-upload" style="color: inherit"></svg-icon>
上传文件
</el-button>
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
{{ col.uploadTips || '只能上传jpg/png文件, 大小不超过2MB' }}
</div>
</el-upload>
<uploadedFile
class="file"
v-for="file in form[col.prop]"
:file="file"
:key="file.fileUrl"
@delete="!disabled && handleDeleteFile(file, col.prop)" />
</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
<uploadedFile class="file" v-for="file in form[col.prop]" :file="file" :key="file.fileUrl"
@delete="!disabled && handleDeleteFile(file, col.prop)" />
</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>

View File

@ -17,7 +17,7 @@
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
:width="120"
:width="150"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" />
</base-table>
@ -64,8 +64,8 @@ export default {
searchBarKeys: ['equipmentName', 'createTime'],
tableBtn: [
{
type: 'detail',
btnName: '保养记录',
type: 'content',
btnName: '添加内容',
},
this.$auth.hasPermi('equipment:plan-config:update')
? {
@ -89,21 +89,24 @@ export default {
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
{ prop: 'name', label: '计划名称' },
{ prop: 'code', label: '计划编号' },
{ prop: 'enabled', label: '启用状态', filter: (val) => ['停用', '启用'][val] },
{ prop: 'lineName', label: '产线' },
{ prop: 'sectionName', label: '工段' },
{ prop: 'equipmentName', label: '设备名称' },
{ prop: 'maintainDuration', label: '计划保养用时(h)' },
{ prop: 'maintenancePeriod', label: '保养频率(天/次)' },
{ prop: 'maintainType', label: '保养类型', filter: publicFormatter('maintain_type') },
{ prop: 'departmentName', label: '部门' },
{ prop: 'maintenancePeriod', label: '保养频率(天/次)'},
// { prop: 'lineName', label: '线' },
{
prop: 'firstMaintenanceTime', label: '首次保养时间',
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
{ prop: 'maintainDuration', label: '保养时长(时)' },
{ prop: 'confirmTimeLimit', label: '确认时限' },
// { prop: 'maintenancePeriod', label: '(/)' },
// { prop: 'maintainType', label: '', filter: publicFormatter('maintain_type') },
{ prop: 'remark', label: '备注' },
],
searchBarFormConfig: [
{
type: 'input',
label: '设备名',
placeholder: '请输入设备名称',
label: '保养计划名称',
placeholder: '请输入保养计划名称',
param: 'equipmentName',
},
//
@ -184,19 +187,46 @@ export default {
[
{
select: true,
label: '设备名称',
prop: 'equipmentId',
url: '/base/core-equipment/listAll',
rules: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
},
{
select: true,
label: '保养类型',
prop: 'maintainType',
options: this.getDictDatas(this.DICT_TYPE.MAINTAIN_TYPE),
},
label: '部门',
prop: 'departmentId',
url: '/system/dept/list-all-simple',
rules: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
},
{
input: true,
label: '保养频率(天/次)',
prop: 'maintenancePeriod',
rules: [
{
type: 'number',
trigger: 'blur',
message: '请输入正确的数字',
transform: (val) => Number(val),
},
],
rules: [{ required: true, message: '保养频率不能为空', trigger: 'blur' }],
},
// {
// select: true,
// label: '',
// prop: 'maintainType',
// options: this.getDictDatas(this.DICT_TYPE.MAINTAIN_TYPE),
// },
],
[
[
{
input: true,
label: '确认时限(h)',
prop: 'confirmTimeLimit',
rules: [
{
type: 'number',
trigger: 'blur',
message: '请输入正确的数字',
transform: (val) => Number(val),
},
],
},
{
input: true,
label: '保养时长(h)',
@ -210,31 +240,22 @@ export default {
},
],
},
{
input: true,
label: '保养频率(天/次)',
prop: 'maintenancePeriod',
rules: [
{
type: 'number',
trigger: 'blur',
message: '请输入正确的数字',
transform: (val) => Number(val),
},
],
rules: [{ required: true, message: '保养频率不能为空', trigger: 'blur' }],
},
],
[
{
switch: true,
label: '启用状态',
prop: 'enabled',
bind: {
'active-value': 1,
'inactive-value': 0,
},
}
[
{
datetime: true,
label: '首次保养时间',
disabled: false,
prop: 'firstMaintenanceTime',
rules: [{ required: true, message: '首次保养时间不能为空', trigger: 'blur' }],
bind: {
format: 'yyyy-MM-dd HH:mm:ss',
'value-format': 'timestamp',
// 'value-format': 'yyyy-MM-dd HH:mm:ss',
clearable: true,
},
},
],
[{ input: true, label: '备注', prop: 'remark' }],
],
@ -246,17 +267,17 @@ export default {
pageSize: 10,
equipmentName: null,
createTime: null,
},
},
//
form: {},
basePath: '/base/equipment-maintain-plan',
};
},
created() {
if (this.$route.query) {
this.queryParams.equipmentId = this.$route.query?.equipmentId ?? undefined
this.searchBarFormConfig[0].defaultSelect = this.$route.query.equipmentName ?? undefined
}
// if (this.$route.query) {
// this.queryParams.equipmentId = this.$route.query?.equipmentId ?? undefined
// this.searchBarFormConfig[0].defaultSelect = this.$route.query.equipmentName ?? undefined
// }
this.getList();
},
methods: {
@ -280,13 +301,15 @@ export default {
this.form = {
code: null,
name: null,
equipmentId: null,
departmentId: null,
enabled: null,
maintenancePeriod: null,
maintainDuration: null,
maintainType: null,
maintainDuration: null,
confirmTimeLimit: null,
firstMaintenanceTime:null,
// maintainType: null,
remark: null,
enabled: 1
// enabled: 1
};
this.resetForm('form');
},
@ -303,7 +326,8 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.open = true;
this.rows[3][0].disabled = false
this.title = '添加保养计划';
},
handleDetail(row){
@ -326,10 +350,15 @@ export default {
handleUpdate(row) {
this.reset();
const id = row.id;
this.info({ id }).then((response) => {
this.form = response.data;
this.open = true;
this.title = '修改保养计划';
this.info({ id }).then((response) => {
this.$nextTick(() => {
this.form = response.data;
this.open = true
this.rows[3][0].disabled = true
console.log(this.rows[3].disabled)
this.title = '修改保养计划';
this.$forceUpdate()
})
});
},
/** 提交按钮 */

View File

@ -0,0 +1,46 @@
<!--
* @Author: zhp
* @Date: 2024-07-12 13:41:41
* @LastEditTime: 2024-07-12 13:41:41
* @LastEditors: zhp
* @Description:
-->
<template>
<div class="tableInner">
<el-input-number v-model="list[itemProp]" @blur="changeInput" :min="0" :max="100000000" style="width: 100%"
:controls='false'></el-input-number>
</div>
</template>
<script>
export default {
name: 'InputArea',
props: {
injectData: {
type: Object,
default: () => ({})
},
itemProp: {
type: String
}
},
data() {
return {
list: this.injectData
}
},
methods: {
changeInput() {
console.log(this.list)
this.$emit('emitData', this.list)
}
}
}
</script>
<style lang="scss">
.tableInner .el-input__inner {
border: none;
padding: 0;
height: 33px;
}
</style>

View File

@ -0,0 +1,141 @@
<!--
* @Author: zhp
* @Date: 2024-07-18 14:56:21
* @LastEditTime: 2024-07-19 14:57:43
* @LastEditors: zhp
* @Description:
-->
<template>
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="auto">
<el-row :gutter="24">
<el-col :span="24">
<el-form-item label="保养项目" prop="program">
<el-input v-model="dataForm.program" placeholder="请输入保养项目" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="24">
<el-form-item label="默认保养结果" prop="resultType">
<el-select v-model="dataForm.resultType" placeholder="请选择默认保养结果">
<el-option v-for="dict in resultList" :key="dict.id" :label="dict.name" :value="dict.id" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="dataForm.resultType === 0" :gutter="24">
<el-col :span="24">
<el-form-item prop="maintainResult">
<el-input v-model="dataForm.maintainResult" placeholder="请输入文本内容" />
</el-form-item>
</el-col>
</el-row>
<el-row v-else-if="dataForm.resultType === 1" :gutter="24">
<el-col :span="24">
<el-form-item prop="maintainResult">
<el-input oninput="value=value.replace(/[^\-\d.]/g, '')" v-model="dataForm.maintainResult"
placeholder="请输入数值" />
</el-form-item>
</el-col>
</el-row>
<el-row v-else-if="dataForm.resultType === 2" :gutter="24">
<el-col :span="12">
<el-form-item prop="minValue">
<el-input oninput="value=value.replace(/[^\-\d.]/g, '')" v-model="dataForm.minValue" placeholder="请输入最小值" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="maxValue">
<el-input @change="handleChange" oninput="value=value.replace(/[^\-\d.]/g, '')" v-model="dataForm.maxValue"
placeholder="请输入最大值" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
import basicAdd from './basic-add';
import {
createItemData,
getItemData,
updateItemData
} from '@/api/equipment/base/maintain/items';
import { getList,} from "@/api/base/qualityScrapType";
// import { getMaterialList } from "@/api/base/material";
export default {
mixins: [basicAdd],
data() {
return {
urlOptions: {
createURL: createItemData,
updateURL: updateItemData,
infoURL: getItemData,
},
typeList: [],
resultList: [
{
id: 0,
name:'文本'
},
{
id: 1,
name: '单一数值'
},
{
id: 2,
name: '数值范围'
}
],
dataForm: {
id: undefined,
program: undefined,
resultType: undefined,
equipmentTypeId: undefined,
minValue: undefined,
maxValue: undefined,
maintainResult:undefined,
},
// materialList: [],
dataRule: {
// materialId: [{ required: true, message: "", trigger: "blur" }],
program: [{ required: true, message: "保养项目不能为空", trigger: "blur" }],
maintainResult: [{ required: true, message: "默认保养结果不能为空", trigger: "blur" }],
minValue: [{ required: true, message: "最小值不能为空", trigger: "blur" }],
maxValue: [{ required: true, message: "最大值不能为空", trigger: "blur" }],
// typeId: [{ required: true, message: "", trigger: "change" }],
}
};
},
mounted() {
this.getDict()
console.log('我看看', this.dataForm)
},
methods: {
async getDict() {
//
const res = await getList();
this.typeList = res.data;
},
handleChange(val) {
if (val && this.dataForm.maxValue) {
if (parseFloat(this.dataForm.minValue) >= parseFloat(val)) {
return this.$message({
message: '最小值不能大于最大值',
type: 'warning'
});
}
}
}
// setMaterialCode() {
// const chooseM = this.materialList.filter(item => {
// return item.id === this.dataForm.materialId
// })
// this.dataForm.materialCode = chooseM[0].code
// }
},
};
</script>

View File

@ -0,0 +1,112 @@
/*
* @Author: zwq
* @Date: 2022-08-24 11:19:43
* @LastEditors: zhp
* @LastEditTime: 2024-07-19 14:47:02
* @Description:
*/
export default {
data() {
/* eslint-disable */
return {
urlOptions: {
createURL: '',
updateURL: '',
infoURL: '',
codeURL: '',
getOption: false,
isGetCode: false,
optionArrUrl: [],
optionArr: {}
},
visible: false,
setData: false
}
},
created() {
},
activated() {
},
methods: {
init(obj) {
console.log(obj);
this.dataForm.id = obj.id || "";
this.dataForm.equipmentTypeId = obj.equipmentTypeId || "";
this.visible = true;
if (this.urlOptions.getOption) {
this.getArr()
}
this.$nextTick(() => {
this.$refs["dataForm"].resetFields();
if (this.dataForm.id) {
this.urlOptions.infoURL(this.dataForm.id).then(res => {
this.dataForm.id = res.data.id
this.dataForm.program = res.data.program
this.dataForm.resultType = res.data.resultType
// console.log(this.dataForm.maintainResult.search('~'))
if (res.data.resultType === 2 || res.data.maintainResult.search('~') != -1) {
this.dataForm.minValue = res.data.maintainResult.substring(0, res.data.maintainResult.search('~'))
this.dataForm.maxValue = res.data.maintainResult.substring(res.data.maintainResult.search('~') + 1, res.data.maintainResult.length)
this.dataForm.maintainResult = undefined
// = this.dataForm.minValue + '-' + this.dataForm.maxValue
} else {
this.dataForm.minValue = undefined
this.dataForm.maxValue = undefined
this.dataForm.maintainResult = res.data.maintainResult
}
console.log(this.dataForm);
});
}
});
},
getCode() {
this.urlOptions.codeURL()
.then(({ data: res }) => {
this.dataForm.code = res;
})
.catch(() => {});
},
getArr() {
const params = {
pageSize: 100,
pageNo: 1,
}
this.urlOptions.optionArrUrl.forEach((item, index) => {
item(params).then(({ data: res }) => {
this.$set(this.urlOptions.optionArr, `arr${index}`, res.list)
})
.catch(() => {
});
});
},
// 表单提交
dataFormSubmit() {
this.$refs["dataForm"].validate((valid) => {
if (this.dataForm.resultType === 2) {
this.dataForm.maintainResult = this.dataForm.minValue + '~' + this.dataForm.maxValue
}
if (!valid) {
return false;
}
// 修改的提交
if (this.dataForm.id) {
this.urlOptions.updateURL(this.dataForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.visible = false;
this.$emit("refreshDataList");
});
return;
}
// 添加的提交
this.urlOptions.createURL(this.dataForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
},
formClear() {
this.$refs.dataForm.resetFields()
}
}
}

View File

@ -0,0 +1,172 @@
/*
* @Author: zhp
* @Date: 2024-07-19 09:49:22
* @LastEditTime: 2024-07-19 14:17:27
* @LastEditors: zhp
* @Description:
*/
export default {
data() {
/* eslint-disable */
return {
urlOptions: {
getDataListURL: '',
deleteURL: '',
statusUrl: '',
exportURL: ''
},
tableData: [],
listQuery: {
pageSize: 10,
pageNo: 1,
total: 1,
},
exportLoading: false,
dataListLoading: false,
addOrEditTitle: '',
addOrUpdateVisible: false,
}
},
created() {
},
mounted() {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList() {
this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery).then(response => {
this.tableData = response.data.list;
this.listQuery.total = response.data.total;
this.dataListLoading = false;
});
},
// 每页数
sizeChangeHandle(val) {
this.listQuery.pageSize = val;
this.listQuery.pageNo = 1;
this.getDataList();
},
// 当前页
currentChangeHandle(val) {
this.listQuery.pageNo = val;
this.getDataList();
},
// 新增 / 修改
addOrUpdateHandle(id) {
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id);
});
},
cancel(id) {
this.$refs["popover-" + id].showPopper = false;
},
//改变状态
changeStatus(id) {
this.$http
.post(this.urlOptions.statusUrl, { id })
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
}
this.$refs["popover-" + id].showPopper = false;
this.$message({
message: this.$t("prompt.success"),
type: "success",
duration: 500,
onClose: () => {
this.getDataList();
},
});
})
.catch(() => { });
},
//tableBtn点击
handleClick(val) {
if (val.type === "edit") {
this.addOrUpdateVisible = true;
this.addOrEditTitle = "编辑"
let obj = {
id: val.data.id,
equipmentTypeId:val.data.equipmentTypeId
}
this.$nextTick(() => {
this.$refs.addOrUpdate.init(obj);
});
} else if (val.type === "delete") {
this.deleteHandle(val.data.id, val.data.program, val.data._pageIndex)
} else if (val.type === "change") {
this.changeStatus(val.data.id)
} else {
this.otherMethods(val)
}
},
// 删除
deleteHandle(id, name, index) {
this.$confirm(`确定要删除${name}?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.urlOptions.deleteURL(id).then(({ data }) => {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.getDataList();
},
});
});
})
.catch(() => { });
},
//search-bar点击
buttonClick(val) {
switch (val.btnName) {
case "search":
this.listQuery.xm1 = val.xm1;
this.listQuery.xm2 = val.xm2;
this.listQuery.pageNo = 1;
this.getDataList();
break;
case "add":
this.addOrEditTitle = '新增'
this.addOrUpdateVisible = true;
this.addOrUpdateHandle()
break;
default:
console.log(val)
}
},
handleCancel() {
this.$refs.addOrUpdate.formClear()
this.addOrUpdateVisible = false
this.addOrEditTitle = ''
},
handleConfirm() {
this.$refs.addOrUpdate.dataFormSubmit()
},
successSubmit() {
this.handleCancel()
this.getDataList()
},
/** 导出按钮操作 */
handleExport() {
// 处理查询参数
let params = { ...this.queryParams };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出所有数据项?').then(() => {
this.exportLoading = true;
return this.urlOptions.exportURL(params);
}).then(response => {
this.$download.excel(response, '工厂.xls');
this.exportLoading = false;
}).catch(() => { });
}
}
}

View File

@ -0,0 +1,257 @@
<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">
<method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :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" width="20%"
@confirm="submitForm">
<DialogForm v-if="open" ref="form" v-model="form" :has-files="false" :rows="rows" />
</base-dialog>
<show-detail v-if="showDetailVisible" ref="showDetail"></show-detail>
</div>
</template>
<script>
import moment from 'moment';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
import { deleteData } from '@/api/equipment/base/maintain/items'
import showDetail from './showDetail.vue'
import { publicFormatter } from '@/utils/dict';
export default {
name: 'PlanConfig',
mixins: [basicPageMixin],
components: {
showDetail
},
data() {
const t = new Date();
const [y, m, d] = [t.getFullYear(), t.getMonth(), t.getDate()];
return {
searchBarKeys: ['equipmentName', 'createTime'],
equipmentTypeList:[],
tableBtn: [
{
type: 'detail',
btnName: '详情',
},
// this.$auth.hasPermi('equipment:plan-config:update')
// ? {
// type: 'edit',
// btnName: '',
// }
// : undefined,
this.$auth.hasPermi('equipment:plan-config:delete')
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
tableProps: [
{ prop: 'equipmentType', label: '设备类型' },
{ prop: 'creator', label: '创建人' },
{
prop: 'createTime',
label: '创建时间',
// fixed: true,
width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
],
searchBarFormConfig: [
{
type: 'select',
label: '设备类型',
placeholder: '请输入设备类型',
param: 'equipmentTypeId',
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: 'separate',
},
{
type: this.$auth.hasPermi('equipment:plan-config:create')
? 'button'
: '',
btnName: '新增',
name: 'add',
plain: true,
color: 'success',
},
],
rows: [
[
{
select: true,
label: '设备类型',
prop: 'equipmentTypeId',
url: '/base/core-equipment-type/listAll',
rules: [{ required: true, message: '设备类型不能为空', trigger: 'blur' }],
},
],
],
//
open: false,
//
queryParams: {
pageNo: 1,
pageSize: 10,
equipmentTypeId: null,
},
showDetailVisible:false,
//
form: {},
basePath: 'base/equipment-maintain-program-type',
};
},
created() {
this.initSearchBar()
this.getList();
},
methods: {
/** 查询列表 */
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.reset();
},
/** 表单重置 */
reset() {
this.form = {
equipmentTypeId: null,
id: null,
equipmentType:null,
};
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
this.handleQuery();
},
initSearchBar() {
this.http('/base/core-equipment-type/listAll', 'get').then(({ data }) => {
this.$set(
this.searchBarFormConfig[0],
'selectOptions',
data.map((item) => ({
name: item.name,
id: item.id,
}))
);
this.equipmentTypeList = data
});
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = '保养项目设置新增';
},
handleDetail(row) {
this.showDetailVisible = true
this.$nextTick(() => {
this.$refs.showDetail.init(row.equipmentTypeId)
})
// alert(' ')
// console.log(row)
// const queryData = {
// equipmentId: row.equipmentId,
// maintainPlanId: row.id,
// isAdd: 1
// // relatePlan: row.enabled
// }
// if (this.queryParams.createTime) {
// queryData.createTime = this.queryParams.createTime
// }
// console.log('', queryData)
// this.$router.push({ path: '/equipment/base/maintain/record',query: queryData })
// this.$router.push({ path: '/equipment/base/maintain/record', query: { orderNo: row.orderNo }})
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id;
this.info({ id }).then((response) => {
this.form = response.data;
this.open = true;
this.title = '修改保养计划';
});
},
/** 提交按钮 */
submitForm() {
this.equipmentTypeList.forEach(ele => {
if (this.form.equipmentTypeId === ele.id) {
this.form.equipmentType = ele.name
}
});
this.$refs['form'].validate((valid) => {
if (!valid) {
return;
}
//
if (this.form.id != null) {
this.put(this.form).then((response) => {
this.$modal.msgSuccess('修改成功');
this.open = false;
this.getList();
});
return;
}
//
this.post(this.form).then((response) => {
this.$modal.msgSuccess('新增成功');
this.open = false;
this.getList();
});
});
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$modal
.confirm('是否确认删除设备类型名称' + row.equipmentType + '?')
.then(function () {
return deleteData(id);
})
.then(() => {
this.getList();
this.$modal.msgSuccess('删除成功');
})
.catch(() => {});
},
},
};
</script>

View File

@ -0,0 +1,134 @@
<!--
* @Author: zhp
* @Date: 2024-07-12 13:28:21
* @LastEditTime: 2024-07-19 14:59:05
* @LastEditors: zhp
* @Description:
-->
<template>
<div>
<el-drawer title="配置保养项目" :visible.sync="drawer" :direction="direction" size="50%">
<div style="padding: 0px 16px;">
<el-form :inline="true" class="">
<el-form-item>
<el-button :plain='true' type="success" @click="handleAdd">新增</el-button>
</el-form-item>
</el-form>
<base-table v-loading="dataListLoading" :table-props="tableProps" :table-data="tableData">
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="80" label="操作" :method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
</div>
</el-drawer>
<base-dialog :dialogTitle="addOrEditTitle" :dialogVisible="addOrUpdateVisible" @cancel="handleCancel"
@confirm="handleConfirm" :before-close="handleCancel" width="30%">
<add-or-update ref="addOrUpdate" @refreshDataList="successSubmit"></add-or-update>
</base-dialog>
</div>
</template>
<script>
const tableProps = [
{
prop: 'program',
label: '保养项目',
subcomponent: inputArea,
align:'center',
},
{
prop: 'maintainResult',
label: '默认保养结果',
subcomponent: inputArea,
align: 'center',
},
]
const topBtnConfig = [
{
type: 'add',
btnName: 'btn.add'
}
]
// import basicPageMixin from '@/mixins/lb/basicPageMixin';
import AddOrUpdate from './components/add-or-updata';
import {
getItemPageData,
deleteData
} from '@/api/equipment/base/maintain/items';
import basicPage from './components/basic-page';
import inputArea from './components/InputArea.vue'
export default {
mixins: [basicPage],
components: {
AddOrUpdate,
},
data() {
return {
drawer: false,
urlOptions: {
getDataListURL: getItemPageData,
deleteURL: deleteData,
// exportURL: exportFactoryExcel,
},
direction: 'rtl',
dataListLoading:false,
addOrUpdateVisible: false,
addOrEditTitle: '',
queryParams: {
pageNo:1,
pageSize:10,
equipmentTypeId:null,
},
tableProps,
basePath: 'base/equipment-maintain-program',
tableData: [],
tableBtn: [
{
type: 'edit',
name: '编辑'
},
{
type: 'delete',
name: '删除'
}
],
addButtonShow: '新增'
}
},
methods: {
inputChange(val) {
// console.log('=======')
console.log(val)
this.tableData[val._pageIndex - 1][val.prop] = val[val.prop]
// console.log(this.tableData)
},
getDataList(id) {
this.dataListLoading = true;
this.queryParams.equipmentTypeId = id
this.urlOptions.getDataListURL(this.listQuery).then(response => {
this.tableData = response.data.list;
this.listQuery.total = response.data.total;
this.dataListLoading = false
});
},
handleAdd() {
this.addOrUpdateVisible = true
this.addOrEditTitle = '新增'
let obj = {
equipmentTypeId: this.queryParams.equipmentTypeId
}
this.$nextTick(() => {
this.$refs.addOrUpdate.init(obj)
});
},
init(id) {
this.drawer = true
this.getDataList(id)
}
},
}
</script>
<style lang="scss" scoped>
</style>