设备保养
This commit is contained in:
@@ -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>
|
||||
@@ -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>
|
||||
112
src/views/equipment/base/maintain/items/components/basic-add.js
Normal file
112
src/views/equipment/base/maintain/items/components/basic-add.js
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
172
src/views/equipment/base/maintain/items/components/basic-page.js
Normal file
172
src/views/equipment/base/maintain/items/components/basic-page.js
Normal 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(() => { });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user