<template>
|
<view class="container">
|
<cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="productionTask">
|
<block slot="backText">返回</block>
|
<block slot="content">{{title}}</block>
|
</cu-custom>
|
<view class="container">
|
|
|
<uni-forms ref="form" :modelValue="formData" validate-trigger="bind" err-show-type="undertext">
|
<uni-group top="1">
|
<view class="divider"><text>报修基本信息</text></view>
|
<!-- <view class="text-gray margin-bottom-lg">—————————报修基本信息—————————</view> -->
|
<uni-forms-item :label-width="100" name="num" label="工单号:">
|
<uni-easyinput v-model="formData.repairCode" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="100" required name="num" label="设备编号:">
|
<uni-data-select v-model="formData.num" :localdata="equipmentList" @change="changeEquipmentList"
|
placeholder="请选择" :disabled="true" />
|
</uni-forms-item>
|
|
<uni-forms-item :label-width="100" name="remark" label="故障开始时间:">
|
<uni-easyinput v-model="formData.faultStartTime" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="100" name="outNum" label="维修负责人:">
|
<uni-easyinput v-model="formData.repairer" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="100" name="remark" label="备注:">
|
<uni-easyinput v-model="formData.remark" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="100" name="outNum" label="报修图片:">
|
|
<uni-file-picker limit="9" :value="fileList" :image-styles="imageStyles" @select="select"
|
:sourceType="sourceType" @progress="progress" @success="success" @fail="fail" @delete="deletea"
|
:readonly="readonly" />
|
</uni-forms-item>
|
|
<view class="divider"><text>是否需要领用备件</text></view>
|
<uni-forms-item :label-width="140" required name="num" label="是否需要领用备件:">
|
<uni-data-select v-model="formData.isSpare" :localdata="SpareList" @change="changeisSpareList"
|
placeholder="请选择" :disabled="isUNDERREPAIR" />
|
</uni-forms-item>
|
|
<uni-forms-item v-show="isShow" :label-width="140" required name="faultReason" label="故障原因:">
|
<uni-easyinput v-model="formData.faultReason" placeholder="请输入故障原因" :disabled="isUNDERREPAIR" />
|
</uni-forms-item>
|
<uni-forms-item v-show="isShow" required :label-width="140" name="repairDescription"
|
label="维修结果描述:">
|
<uni-easyinput v-model="formData.repairDescription" placeholder="请输入维修结果描述"
|
:disabled="isUNDERREPAIR" />
|
</uni-forms-item>
|
<uni-forms-item v-show="isShow" :label-width="100" name="outNum" label="维修图片:">
|
<uni-file-picker limit="9" :value="fileLists" :image-styles="imageStyles" @select="select"
|
:sourceType="sourceType" @progress="progress" @success="success" @fail="fail" @delete="deletea"
|
:readonly="readonlyRepaier" />
|
</uni-forms-item>
|
</uni-group>
|
</uni-forms>
|
<uni-forms v-show="isShowUNDEREPAIR" ref="form" :modelValue="ScanData" validate-trigger="bind"
|
err-show-type="undertext">
|
<uni-group top="1">
|
<view class="divider"><text>管理员领用备件</text></view>
|
<!-- <view class="text-gray margin-bottom-lg">—————————管理员领用备件——————————</view> -->
|
<uni-forms-item :label-width="100" required name="sparePartDescription" label="备件描述:">
|
<uni-easyinput type="textarea" v-model="ScanData.sparePartDescription" placeholder="请输入备件描述"
|
:disabled="isRuning" />
|
</uni-forms-item>
|
|
</uni-group>
|
</uni-forms>
|
<uni-forms v-show="isShowRepari" ref="form" :modelValue="formData" validate-trigger="bind"
|
err-show-type="undertext">
|
<uni-group top="1">
|
<view class="divider"><text>维修结果上报</text></view>
|
<!-- <view class="text-gray margin-bottom-lg">—————————维修结果上报——————————</view> -->
|
<uni-forms-item :label-width="140" required name="faultReason" label="故障原因:">
|
<uni-easyinput v-model="formData.faultReason" placeholder="请输入故障原因" :disabled="isRepari" />
|
</uni-forms-item>
|
<uni-forms-item required :label-width="140" name="repairDescription" label="维修结果描述:">
|
<uni-easyinput v-model="formData.repairDescription" placeholder="请输入维修结果描述"
|
:disabled="isRepari" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="100" name="outNum" label="维修图片:">
|
<uni-file-picker limit="9" :value="fileLists" :image-styles="imageStyles" @select="select"
|
:sourceType="sourceType" @progress="progress" @success="success" @fail="fail" @delete="deletea"
|
:readonly="readonlyRepaier" />
|
</uni-forms-item>
|
</uni-group>
|
</uni-forms>
|
<view v-show="isSHowBtn" class="padding flex flex-direction">
|
<view class="flex-sub bg-blue padding-sm margin-xl radius text-sm text-center text-white"
|
@click.stop="ProductionTask()" hover-class="is-hover">确定</view>
|
</view>
|
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
title
|
} from "process";
|
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
|
import configService from "@/common/service/config.service";
|
export default {
|
mixins: [MescrollMixin], // 使用mixin
|
data() {
|
return {
|
readonly: false,
|
readonlyRepaier: false,
|
// 图片回显
|
fileLists: [],
|
fileList: [],
|
// 上传图片的样式
|
imageStyles: {
|
width: 90,
|
height: 90,
|
},
|
sourceType: ['album', 'camera'],
|
isSHowBtn: true,
|
isShowRepari: false,
|
title: '',
|
isRepari: false,
|
isRuning: false,
|
isShowUNDEREPAIR: false,
|
isUNDERREPAIR: false,
|
SpareList: [{
|
text: "是",
|
value: 1
|
|
},
|
{
|
text: "否",
|
value: 0
|
}
|
],
|
ipAndPort: configService.staticURL,
|
imgTwoList: [],
|
imgThreeList: [],
|
scrollLeft: 0,
|
searchValue: '',
|
imgList: [],
|
imageAvatarTwo: [],
|
imageFilesList: [],
|
equipmentList: [],
|
uploadUrl: "/sys/common/upload",
|
ScanData: {
|
sparePartDescription: ''
|
},
|
formData: {
|
reportStatus: '',
|
avatarTwo: [],
|
isSpare: 0,
|
num: '',
|
avatar: [],
|
repairer: '',
|
faultStartTime: '',
|
repairCode: ''
|
},
|
istrue: true,
|
partTakeAdviceDetailList: [],
|
NavBarColor: this.NavBarColor,
|
url: {
|
upload: "/eam/sysFiles/batch_upload",
|
stallList: "/eam/eamRepairOrder/queryById",
|
getEquipmentList: 'eam/equipment/list',
|
approval: '/eam/eamRepairOrder/perform'
|
},
|
id: '',
|
taskId: '',
|
upOption: {
|
page: {
|
num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
|
size: 10 // 每页数据的数量
|
},
|
noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
|
empty: {
|
tip: '~ 暂无数据 ~', // 提示
|
},
|
loading: '',
|
text: '全部',
|
isShowNoMore: false,
|
textNoMore: '我是有底线的 >_<'
|
},
|
styles: {
|
color: '#2979FF',
|
borderColor: '#2979FF'
|
},
|
msg1Count: 0,
|
msg2Count: 0,
|
msg1Title: "",
|
procInstId: '',
|
values: '',
|
isShow: true,
|
flag: ''
|
|
}
|
},
|
computed: {
|
top() {
|
return this.CustomBar * 2 + 160
|
},
|
style() {
|
var StatusBar = this.StatusBar;
|
var CustomBar = this.CustomBar;
|
var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
|
return style
|
},
|
},
|
onLoad(options) {
|
const annItem = JSON.parse(decodeURIComponent(options.item));
|
this.flag = options.flag
|
console.log(this.flag)
|
this.id = annItem.dataId,
|
this.taskId = annItem.id,
|
this.procInstId = annItem.procInstId,
|
this.values = annItem.values,
|
this.assignee = annItem.assignee
|
},
|
created() {
|
this.getEquipment();
|
this.upCallback();
|
},
|
|
methods: {
|
changeisSpareList(e) {
|
this.formData.isSpare = e;
|
if (e == 0) {
|
this.isShow = true;
|
} else if (e == 1) {
|
this.isShow = false;
|
}
|
},
|
|
select(e) {
|
const tempFilePaths = e.tempFilePaths;
|
uni.showLoading({
|
title: '上传中...'
|
});
|
const uploadPromises = tempFilePaths.map((filePath, index) => {
|
return new Promise((resolve, reject) => {
|
this.$http.upload(this.url.upload, {
|
filePath: filePath,
|
name: 'file'
|
})
|
.then(uploadRes => {
|
// 假设服务器返回的结果中包含文件路径
|
const serverFilePath = uploadRes.data.result[0];
|
this.formData.avatar.push(serverFilePath);
|
resolve(uploadRes); // 返回结果给 Promise.all
|
})
|
.catch(err => {
|
console.error(`图片 ${index + 1} 上传失败:`, err);
|
reject(err);
|
});
|
});
|
});
|
|
Promise.all(uploadPromises)
|
.then(() => {
|
uni.hideLoading();
|
uni.showToast({
|
title: '全部上传成功'
|
});
|
})
|
.catch(err => {
|
uni.hideLoading();
|
uni.showToast({
|
title: '部分上传失败',
|
icon: 'none'
|
});
|
console.error('上传异常:', err);
|
});
|
},
|
// 删除
|
deletea(e) {
|
console.log('删除图片', e);
|
},
|
ProductionTask() {
|
console.log(this.formData.isSpare)
|
if (this.formData.reportStatus == 'WAIT_SPARES' && this.formData.isSpare == 1 && this.flag !== 'task') {
|
if (this.ScanData.sparePartDescription == undefined || this.ScanData.sparePartDescription == null ||
|
this
|
.ScanData.sparePartDescription ==
|
'') {
|
|
uni.showToast({
|
icon: 'none',
|
title: '备件描述不能为空'
|
});
|
return false;
|
}
|
}
|
|
|
// if (this.formData.reportStatus == 'UNDER_REPAIR' && this.formData.isSpare == 0 && this.flag !== 'task') {
|
// if (this.formData.faultReason == undefined || this.formData.faultReason == null ||
|
// this
|
// .formData.faultReason ==
|
// '') {
|
|
// uni.showToast({
|
// icon: 'none',
|
// title: '故障原因不能为空'
|
// });
|
// return false;
|
// }
|
// if (this.formData.repairDescription == undefined || this.formData.repairDescription == null ||
|
// this
|
// .formData.repairDescription ==
|
// '') {
|
|
// uni.showToast({
|
// icon: 'none',
|
// title: '维修结果不能为空'
|
// });
|
// return false;
|
// }
|
|
// }
|
// if (this.formData.reportStatus == 'UNDER_REPAIR' && this.formData.isSpare == 1 && this.flag !== 'task') {
|
// if (this.formData.faultReason == undefined || this.formData.faultReason == null ||
|
// this
|
// .formData.faultReason ==
|
// '') {
|
|
// uni.showToast({
|
// icon: 'none',
|
// title: '故障原因不能为空'
|
// });
|
// return false;
|
// }
|
// if (this.formData.repairDescription == undefined || this.formData.repairDescription == null ||
|
// this
|
// .formData.repairDescription ==
|
// '') {
|
|
// uni.showToast({
|
// icon: 'none',
|
// title: '维修结果不能为空'
|
// });
|
// return false;
|
// }
|
|
// }
|
if (this.formData.reportStatus == 'UNDER_REPAIR' && this.flag !== 'task') {
|
if (this.formData.faultReason == undefined || this.formData.faultReason == null || this.formData.faultReason == '') {
|
uni.showToast({
|
icon: 'none',
|
title: '故障原因不能为空'
|
});
|
return false;
|
}
|
if (this.formData.repairDescription == undefined || this.formData.repairDescription == null || this.formData.repairDescription == '') {
|
uni.showToast({
|
icon: 'none',
|
title: '维修结果不能为空'
|
});
|
return false;
|
}
|
}
|
|
if (this.formData.reportStatus == 'UNDER_REPAIR' && this.formData.isSpare == 1) {
|
|
if (this.formData.isSpare == undefined || this.formData.isSpare == null ||
|
this
|
.formData.isSpare ==
|
'') {
|
|
uni.showToast({
|
icon: 'none',
|
title: '是否需要领用备件不能为空'
|
});
|
return false;
|
}
|
}
|
uni.showLoading({
|
mask: true,
|
title: "加载中....",
|
})
|
this.$http.post(this.url.approval, {
|
sparePartDescription: this.ScanData.sparePartDescription,
|
dataId: this.id,
|
equipmentId: this.formData.num,
|
faultReason: this.formData.faultReason,
|
id: this.id,
|
imageFilesResult: this.formData.avatar,
|
instanceId: this.procInstId,
|
isUseSpare: this.formData.isSpare,
|
repairDescription: this.formData.repairDescription,
|
taskId: this.taskId
|
}).then(res => {
|
uni.hideLoading()
|
if (res.data.success) {
|
uni.showToast({
|
icon: "success",
|
title: '提交成功',
|
duration: 2000
|
});
|
this.$Router.replaceAll({
|
name: 'ToDoList'
|
})
|
}
|
}).catch(() => {
|
this.$tip.loaded();
|
uni.showToast({
|
icon: "error",
|
title: res.data.message,
|
duration: 2000
|
});
|
});
|
},
|
|
changeEquipmentList(e) {
|
this.formData.num = e;
|
},
|
handleCode(e, index) {
|
console.log(index);
|
// 根据 e 的值来判断是否需要更新 isTrue 的状态
|
if (e === 2) {
|
this.partTakeAdviceDetailList[index].istrue = false;
|
|
} else {
|
this.partTakeAdviceDetailList[index].istrue = true;
|
}
|
},
|
|
getEquipment() {
|
this.$http.get(this.url.getEquipmentList, {
|
params: {
|
pageNo: 1,
|
pageSize: 9999,
|
order: 'desc',
|
column: 'createTime'
|
},
|
|
}).then(res => {
|
//设置列表数据
|
if (res.data.success) {
|
this.equipmentList = res.data.result.records
|
} else {
|
uni.showToast({
|
icon: "error",
|
title: res.data.message,
|
duration: 2000
|
});
|
|
}
|
}).catch(() => {
|
this.$tip.error("联网失败")
|
})
|
},
|
|
|
|
upCallback() {
|
this.$http.get(this.url.stallList, {
|
params: {
|
id: this.id
|
},
|
|
}).then(res => {
|
this.announcement1 = res.data.result
|
console.log("url", res.data.result.reportStatus)
|
//设置列表数据
|
if (res.data.success) {
|
this.formData.reportStatus = this.announcement1.reportStatus
|
|
if (this.announcement1.reportStatus === 'WAIT_CONFIRM') {
|
if (this.flag == 'task') {
|
this.title = '维修执行';
|
this.isUNDERREPAIR = true
|
this.readonly = true
|
this.isRuning = true
|
this.isSHowBtn=false
|
this.readonlyRepaier=true
|
this.isShowRepari = false
|
} else if (this.flag !== 'task') {
|
this.title = '操作工确认';
|
this.isUNDERREPAIR = true
|
this.readonly = true
|
this.isRuning = true
|
this.isSHowBtn=true
|
this.readonlyRepaier=true
|
this.isShowRepari = false
|
}
|
|
} else if (this.announcement1.reportStatus === 'WAIT_SPARES') {
|
if (this.flag == 'task' && this.announcement1.isUseSpare == 1) {
|
this.title = '是否需要领用备件';
|
this.isShowUNDEREPAIR = false;
|
this.isUNDERREPAIR = true;
|
this.readonly = true
|
|
this.isSHowBtn = false;
|
} else {
|
this.title = '管理员领用备件';
|
this.readonly = true
|
this.isUNDERREPAIR = true;
|
this.isShowUNDEREPAIR = true;
|
}
|
|
|
} else if (this.announcement1.reportStatus === 'UNDER_REPAIR') {
|
if (this.announcement1.isUseSpare == 1 && this.flag == 'task') {
|
this.title = '管理员领用备件';
|
this.isShowRepari = true;
|
this.readonlyRepaier = true
|
this.isShowUNDEREPAIR = true;
|
this.isUNDERREPAIR = true;
|
this.isRuning = true;
|
this.isRepari = true;
|
this.readonly = true
|
this.isSHowBtn = false;
|
|
} else if (this.announcement1.isUseSpare == 1 && this.flag !== 'task') {
|
this.title = '维修执行'
|
this.isUNDERREPAIR = true
|
this.readonly = true
|
this.isShowUNDEREPAIR = true
|
this.isRuning = true
|
this.isShowRepari = true
|
|
} else {
|
this.title = '是否需要领用备件'
|
this.isSHowBtn = true
|
this.readonly = true
|
}
|
} else if (this.announcement1.reportStatus === 'COMPLETE') {
|
if (this.flag == 'task' && this.announcement1.isUseSpare == 0) {
|
this.title = '操作工确认'
|
this.isUNDERREPAIR = true
|
this.isShowUNDEREPAIR = false
|
this.readonly = true
|
this.readonlyRepaier = true
|
this.isRuning = true
|
this.isShowRepari = false
|
this.isRepari = false
|
this.isSHowBtn = false
|
} else if (this.flag == 'task' && this.announcement1.isUseSpare == 1) {
|
this.title = '操作工确认'
|
this.isUNDERREPAIR = true
|
this.isShowUNDEREPAIR = true
|
this.isRuning = true
|
this.readonlyRepaier=true
|
this.isShowRepari = true
|
this.isRepari = true
|
this.readonly = true
|
this.isSHowBtn = false;
|
}else if (this.flag !== 'task' && this.announcement1.isUseSpare == 0){
|
this.title = '维修执行'
|
this.isUNDERREPAIR = true
|
this.readonlyRepaier=true
|
this.readonly = true
|
this.isRuning = true
|
|
}
|
|
}
|
console.log(this.announcement1.reportImageFiles)
|
if (this.announcement1.reportImageFiles) {
|
try {
|
const parsedData = JSON.parse(this.announcement1.reportImageFiles);
|
this.imageFilesList = parsedData;
|
this.imgList = parsedData.map(imageObj => {
|
return `${this.ipAndPort}${imageObj.filePath}`;
|
});
|
|
this.fileList = this.imgList.map(url => ({
|
url: url,
|
extname: 'png',
|
name: 'eam'
|
}));
|
} catch (error) {
|
console.error('JSON 解析失败:', error);
|
this.imageFilesList = [];
|
this.imgList = [];
|
this.fileList = [];
|
}
|
}
|
console.log(this.fileLists)
|
this.formData.num = this.announcement1.equipmentId
|
this.formData.repairCode = this.announcement1.repairCode
|
this.formData.repairer = this.announcement1.repairer
|
this.formData.faultStartTime = this.announcement1.faultStartTime
|
this.formData.remark = this.announcement1.remark
|
this.formData.repairDescription = this.announcement1.repairDescription
|
this.formData.faultReason = this.announcement1.faultReason
|
this.formData.isSpare = this.announcement1.isUseSpare
|
if (this.formData.isSpare == 1) {
|
this.isShow = false;
|
} else if (this.formData.isSpare == 0) {
|
this.isShow = true;
|
}
|
this.ScanData.sparePartDescription = this.announcement1.sparePartDescription
|
if (this.announcement1.imageFiles) {
|
try {
|
const parsedDataIn = JSON.parse(this.announcement1.imageFiles);
|
this.imageAvatarTwo = parsedDataIn;
|
this.imgTwoList = parsedDataIn.map(imageObj => {
|
return `${this.ipAndPort}${imageObj.filePath}`;
|
});
|
|
this.fileLists = this.imgTwoList.map(url => ({
|
url: url,
|
extname: 'png',
|
name: 'eam'
|
}));
|
} catch (error) {
|
console.error('JSON 解析失败:', error);
|
this.imageAvatarTwo = [];
|
this.imgTwoList = [];
|
this.fileLists = [];
|
}
|
}
|
}
|
}).catch(() => {
|
//联网失败, 结束加载
|
})
|
},
|
|
|
|
/* 检索 */
|
getSera(res) {
|
this.msgList = [];
|
if (keyword == 0) {
|
this.$http.get(this.url.stallList, {
|
params: {
|
pageNo: 1,
|
pageSize: 999,
|
order: "desc",
|
column: "createTime",
|
equipmentCode: res
|
}
|
}).then(res => {
|
//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
|
|
this.announcement1 = res.data.result.records
|
this.mescroll.endSuccess(this.announcement1.length);
|
console.log("url", res)
|
//设置列表数据
|
if (res.data.success) {
|
console.log("res", res.data)
|
this.msg1Count = res.data.result.total
|
this.msg1Title = "通知(" + res.data.result.total + ")";
|
for (let annItem of this.announcement1) {
|
this.msgList.push(annItem)
|
}
|
}
|
if (page.num == 1) {
|
this.msgList = []; //如果是第一页需手动制空列表
|
this.msgList = this.msgList.concat(this.announcement1); //追加新数据
|
}
|
|
}).catch(() => {
|
//联网失败, 结束加载
|
this.mescroll.endErr();
|
})
|
}
|
},
|
|
mescrollInit(mescroll) {
|
console.log('mescrollInit')
|
this.mescroll = mescroll;
|
},
|
},
|
|
}
|
</script>
|
|
<style>
|
.is-hover {
|
color: rgba(255, 255, 255, 0.6);
|
background-color: #55aaff;
|
border-color: #55aaff;
|
}
|
|
.divider {
|
display: flex;
|
align-items: center;
|
text-align: center;
|
color: gray;
|
/* 文字颜色 */
|
margin: 20px 0;
|
/* 上下间距 */
|
}
|
|
.divider::before,
|
.divider::after {
|
content: '';
|
flex: 1;
|
border-bottom: 1px solid gray;
|
/* 横线颜色 */
|
margin: 0 16px;
|
/* 横线与文字之间的间距 */
|
}
|
|
.divider text {
|
white-space: nowrap;
|
/* 防止文字换行 */
|
}
|
|
.content {
|
margin-top: 5px;
|
}
|
|
.content scroll-view {
|
scrollIndicator: "none"
|
}
|
|
.popupView {
|
margin-top: 85px;
|
height: auto;
|
}
|
</style>
|