<template>
|
<view class="container">
|
<cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="productionTask">
|
<block slot="backText">返回</block>
|
<block slot="content">执行</block>
|
</cu-custom>
|
<view class="container">
|
<template>
|
<!-- 浮窗遮罩层 -->
|
<view v-if="showPreview" class="overlay" @tap.stop="closePreview">
|
<view class="modal">
|
<!-- 关闭按钮 -->
|
<text class="close-btn" @tap.stop="showPreview = false">×</text>
|
<!-- 图片展示 -->
|
<image :src="previewImageSrc" mode="aspectFit" class="preview-image" />
|
</view>
|
</view>
|
|
</template>
|
<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="80" name="orderNum" label="工单号:">
|
<uni-easyinput v-model="formData.orderNum" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="80" 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="80" name="remark" label="点检日期:">
|
<uni-easyinput v-model="formData.inspectionDate" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="80" name="outNum" label="点检人:">
|
<uni-easyinput v-model="formData.operator" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="80" name="remark" label="备注:">
|
<uni-easyinput type="textarea" v-model="formData.remark" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item :label-width="80" name="outNum" label="点检图片:">
|
<uni-file-picker limit="9" :value="fileLists" :image-styles="imageStyles"
|
:sourceType="sourceType" @select="select" @progress="progress" @success="success"
|
@fail="fail" @delete="deletea" />
|
</uni-forms-item>
|
<uni-forms-item name="outNum" :label-width="80" label="作业指导:">
|
<button class="cu-btn bg-blue" @tap="showPreview = true">查看</button>
|
</uni-forms-item>
|
</uni-group>
|
</uni-forms>
|
|
<view class="divider"><text>保养项信息</text></view>
|
<view class="padding flex flex-direction">
|
<button :disabled="isClick" class="mini-btn" type="primary" @click.stop="batchnsIpection()"
|
size="mini">批量点检正常</button>
|
</view>
|
<uni-collapse>
|
<uni-collapse-item :show-animation="true" :accordion="true" title="保养项" :border="false"
|
title-border="none">
|
<uni-card margin="10px" spacing="1px" v-for="(item,index) in partTakeAdviceDetailList" :key="index">
|
|
|
<view class="flex">
|
<view class="flex-sub text-light bg-white padding-xs margin-xs radius">行号:</view>
|
<view class="flex-sub bg-white padding-xs margin-xs radius text-right">{{index+1}}
|
</view>
|
</view>
|
<view class="flex">
|
<view class="flex-sub text-light bg-white padding-xs margin-xs radius">保养项:</view>
|
<view class="flex-sub bg-white padding-xs margin-xs text-bold radius text-right">
|
{{item.itemName}}
|
</view>
|
</view>
|
|
<view class="flex">
|
<view class="flex-sub text-light bg-white padding-xs margin-xs radius">保养要求:</view>
|
<!-- <view class="flex-sub bg-white padding-xs margin-xs radius text-right"
|
v-if="item.itemDemand!=null && item.itemDemand.length>10">
|
{{(item.itemDemand).toString().substr(0,10)+'...'}}
|
</view>
|
|
<view class="flex-sub bg-white padding-xs margin-xs radius text-right" v-else>
|
{{item.itemDemand}}
|
</view> -->
|
<view class="flex-sub bg-white padding-xs margin-xs radius text-right">
|
{{item.itemDemand}}
|
</view>
|
</view>
|
<view class="flex">
|
<view class="flex-sub text-light bg-white padding-xs margin-xs radius">点检结果:</view>
|
<view class="flex-sub bg-white padding-xs text-right margin-xs radius">
|
<uni-data-select :localdata="item.restle" v-model="item.inspectionResult"
|
@change="handleCode($event, index)" />
|
</view>
|
</view>
|
|
<view class="flex">
|
<view class="flex-sub text-light bg-white padding-xs margin-xs radius">异常是否报修:</view>
|
<view class="flex-sub bg-white padding-xs text-right margin-xs radius">
|
<uni-data-select :localdata="item.type" @change="handleType($event, index)"
|
v-model="item.reportFlag" :disabled="item.istrue" />
|
</view>
|
</view>
|
|
<view class="flex">
|
<view class="flex-sub text-light bg-white padding-xs margin-xs radius">异常描述:</view>
|
<view class="flex-sub bg-white padding-xs text-right margin-xs radius">
|
<uni-easyinput v-model="item.exceptionDescription" :disabled="item.istrue" />
|
</view>
|
</view>
|
</uni-card>
|
</uni-collapse-item>
|
</uni-collapse>
|
|
|
|
<view 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 index from "../../../../store";
|
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
|
import configService from "@/common/service/config.service.js";
|
export default {
|
mixins: [MescrollMixin], // 使用mixin
|
data() {
|
return {
|
showPreview: false,
|
// 图片回显
|
fileLists: [],
|
// 上传图片的样式
|
imageStyles: {
|
width: 90,
|
height: 90,
|
},
|
sourceType: ['album', 'camera'],
|
isClick: false,
|
scrollLeft: 0,
|
ipAndPort: configService.staticURL,
|
searchValue: '',
|
imgList: [],
|
equipmentList: [],
|
uploadUrl: "/sys/common/upload",
|
formData: {
|
num: '',
|
avatar: []
|
},
|
istrue: true,
|
partTakeAdviceDetailList: [],
|
NavBarColor: this.NavBarColor,
|
url: {
|
upload: "/eam/sysFiles/batch_upload",
|
stallList: "/eam/eamInspectionOrder/queryById",
|
getEquipmentList: 'eam/equipment/list',
|
getStandardFile: "eam/maintenanceStandard/queryById",
|
BaoList: 'eam/eamInspectionOrderDetail/queryList',
|
approval: 'eam/eamInspectionOrder/approval'
|
},
|
previewImageSrc: '',
|
standardId: '',
|
id: '',
|
taskId: '',
|
inspectionResult: '',
|
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: ''
|
|
}
|
},
|
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.id = annItem.dataId,
|
this.taskId = annItem.id,
|
this.procInstId = annItem.procInstId,
|
this.values = annItem.values,
|
this.assignee = annItem.assignee
|
},
|
created() {
|
this.getEquipment();
|
this.getList();
|
this.upCallback();
|
},
|
|
methods: {
|
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);
|
},
|
batchnsIpection() {
|
uni.showModal({
|
title: '提示',
|
content: '确定批量点检正常?',
|
cancelText: '再看看',
|
confirmText: '确定',
|
success: res => {
|
if (res.confirm) {
|
for (let i = 0; i < this.partTakeAdviceDetailList.length; i++) {
|
this.partTakeAdviceDetailList[i].inspectionResult = '1';
|
}
|
this.isClick = true;
|
}
|
}
|
})
|
|
|
},
|
ProductionTask() {
|
if (this.hasInspectionDateArrived()) {
|
for (let i = 0; i < this.partTakeAdviceDetailList.length; i++) {
|
if (this.partTakeAdviceDetailList[i].inspectionResult == undefined || this
|
.partTakeAdviceDetailList[i]
|
.inspectionResult == null || this
|
.partTakeAdviceDetailList[i].inspectionResult == '') {
|
uni.showToast({
|
icon: 'none',
|
title: '点检结果不能为空'
|
});
|
return false;
|
}
|
}
|
|
for (let i = 0; i < this.partTakeAdviceDetailList.length; i++) {
|
if (this.partTakeAdviceDetailList[i].inspectionResult === "2") {
|
if (this.partTakeAdviceDetailList[i].reportFlag === undefined || this
|
.partTakeAdviceDetailList[i].reportFlag === null || this.partTakeAdviceDetailList[i]
|
.reportFlag === '') {
|
const index = i + 1
|
uni.showModal({
|
title: "提示",
|
content: '第' + index + '行号异常报修必选',
|
confirmText: '确定',
|
showCancel: false,
|
})
|
|
return false;
|
|
}
|
if (this.partTakeAdviceDetailList[i].exceptionDescription == undefined || this
|
.partTakeAdviceDetailList[i].exceptionDescription == null || this
|
.partTakeAdviceDetailList[i].exceptionDescription == '') {
|
const index = i + 1
|
uni.showModal({
|
title: "提示",
|
content: '第' + index + '行号异常描述需填写',
|
confirmText: '确定',
|
showCancel: false,
|
})
|
return false;
|
|
}
|
|
|
}
|
}
|
|
|
uni.showLoading({
|
mask: true,
|
title: "加载中....",
|
})
|
this.$http.post(this.url.approval, {
|
/**
|
* 确认意见
|
*/
|
confirmComment: '',
|
/**
|
* 确认类型 1 通过 2 驳回
|
*/
|
confirmDealType: '',
|
dataId: this.id,
|
fileList: this.formData.avatar, // 包含上传后的图片路径,,
|
instanceId: this.procInstId,
|
tableDetailList: this.partTakeAdviceDetailList,
|
taskId: this.taskId,
|
userId: this.assignee,
|
values: this.values
|
}).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
|
});
|
});
|
|
} else {
|
uni.showToast({
|
icon: "error",
|
title: '未到点检日期不能提前点检',
|
duration: 2000
|
});
|
}
|
|
},
|
closePreview() {
|
this.showPreview = false;
|
},
|
changeEquipmentList(e) {
|
this.formData.num = e;
|
},
|
handleCode(e, index) {
|
console.log(index);
|
// 根据 e 的值来判断是否需要更新 isTrue 的状态
|
if (e == '2') {
|
this.partTakeAdviceDetailList[index].istrue = false;
|
|
} else if (e == '1') {
|
this.partTakeAdviceDetailList[index].istrue = true;
|
}
|
},
|
|
|
handleType(e, index) {
|
console.log(e)
|
},
|
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("联网失败")
|
})
|
},
|
getList() {
|
this.$http.get(this.url.BaoList, {
|
params: {
|
orderId: this.id
|
},
|
|
}).then(res => {
|
this.partTakeAdviceDetailList = res.data.result;
|
const restle = [];
|
this.partTakeAdviceDetailList.forEach(item => {
|
item.restle = [{
|
text: "正常",
|
value: '1'
|
},
|
{
|
text: "异常",
|
value: '2'
|
}
|
]; // 新字段,值为一个空数组
|
item.type = [{
|
text: "否",
|
value: 0
|
},
|
{
|
text: "是",
|
value: 1
|
}
|
]; // 新字段,值为一个空数组
|
item.istrue = true;
|
});
|
console.log("url", res)
|
//设置列表数据
|
if (res.data.success) {
|
console.log("res", res.data.result)
|
|
}
|
}).catch(() => {
|
//联网失败, 结束加载
|
})
|
},
|
|
getStandardFile() {
|
this.$http.get(this.url.getStandardFile, {
|
params: {
|
id: this.standardId
|
}
|
}).then(res => {
|
if (res.data.success) {
|
console.log("res", res.data.result);
|
const referenceFileStr = res.data.result.referenceFile;
|
|
// 判断是否存在 referenceFile 并进行解析
|
if (referenceFileStr) {
|
try {
|
const referenceFileObj = JSON.parse(referenceFileStr);
|
const filePath = `${this.ipAndPort}${referenceFileObj.filePath}`;
|
this.previewImageSrc = filePath;
|
console.log('previewImageSrc:', this.previewImageSrc);
|
} catch (e) {
|
console.error("referenceFile 解析失败", e);
|
this.previewImageSrc = '';
|
}
|
} else {
|
console.warn("referenceFile 不存在");
|
this.previewImageSrc = '';
|
}
|
}
|
}).catch(err => {
|
console.error("网络请求失败", err);
|
// 联网失败, 结束加载
|
});
|
},
|
upCallback() {
|
this.$http.get(this.url.stallList, {
|
params: {
|
id: this.id
|
},
|
|
}).then(res => {
|
this.announcement1 = res.data.result
|
console.log("url", res)
|
//设置列表数据
|
if (res.data.success) {
|
console.log("res", res.data.result.equipmentCode)
|
if (this.announcement1.standardId !== null) {
|
this.standardId = this.announcement1.standardId
|
this.getStandardFile()
|
}
|
this.formData.num = this.announcement1.equipmentId
|
this.formData.remark = this.announcement1.remark
|
this.formData.orderNum = this.announcement1.orderNum
|
this.formData.operator = this.announcement1.operator
|
this.formData.inspectionDate = this.announcement1.inspectionDate
|
this.hasInspectionDateArrived();
|
|
|
}
|
}).catch(() => {
|
//联网失败, 结束加载
|
})
|
},
|
hasInspectionDateArrived() {
|
// 获取当前时间
|
const now = new Date();
|
// 获取点检日期
|
const inspectionDate = new Date(this.formData.inspectionDate);
|
// 计算当前时间与点检日期之间的小时差
|
const diffInHours = (inspectionDate - now) / (1000 * 60 * 60);
|
// 如果小时差小于等于0,表示当前时间已到达或超过点检日期
|
return diffInHours <= 0;
|
},
|
|
|
|
/* 检索 */
|
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: #179b16;
|
border-color: #179b16;
|
}
|
|
.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;
|
}
|
|
.overlay {
|
position: fixed;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
background-color: rgba(0, 0, 0, 0.7);
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
z-index: 999;
|
}
|
|
.modal {
|
position: relative;
|
width: 90%;
|
max-width: 600px;
|
background: #fff;
|
border-radius: 12rpx;
|
padding: 20rpx;
|
box-sizing: border-box;
|
}
|
|
.preview-image {
|
width: 100%;
|
max-height: 80vh;
|
object-fit: contain;
|
}
|
|
.close-btn {
|
position: absolute;
|
top: 10rpx;
|
right: 20rpx;
|
font-size: 40rpx;
|
color: #333;
|
}
|
</style>
|