<template>
|
<view class="container">
|
<cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="productionTask">
|
<block slot="backText">返回</block>
|
<block slot="content">新增-报修</block>
|
</cu-custom>
|
|
<uni-forms ref="form" :modelValue="formData" validate-trigger="bind" err-show-type="undertext">
|
<uni-group top="1">
|
<!-- <uni-forms-item required name="num" label="设备编号:">
|
<uni-data-select v-model="formData.num" :localdata="equipmentList" @change="changeEquipmentList"
|
placeholder="请选择" />
|
</uni-forms-item> -->
|
<uni-forms-item required :label-width="100" name="num" label="设备编号:">
|
<uni-easyinput v-model=" formData.numSear" placeholder="请选择" :disabled="true" suffixIcon="search"
|
@iconClick="OnenterpriseId()" />
|
</uni-forms-item>
|
<uni-forms-item required :label-width="100" name="name" label="故障简称:">
|
<uni-data-select v-model="formData.faultName" :localdata="formData.faultNameList"
|
@change="changefaultNameList" placeholder="请选择" />
|
</uni-forms-item>
|
<uni-forms-item required :label-width="100" name="faultType" label="故障分类:">
|
<uni-easyinput v-model="formData.faultType" :disabled='true' />
|
</uni-forms-item>
|
<uni-forms-item required :label-width="100" name="faultDescription" label="故障描述:">
|
<uni-easyinput v-model="formData.faultDescription" :disabled='true' />
|
</uni-forms-item>
|
<uni-forms-item required name="name" :label-width="100" label="是否停机:">
|
<uni-data-select v-model="formData.breakdownFlag" :localdata="isTrueList" @change="changeisTrueList"
|
placeholder="请选择" />
|
</uni-forms-item>
|
<uni-forms-item required :label-width="110" name="desc" label="故障开始时间:">
|
<uni-datetime-picker type="datetime" v-model="formData.loadTime" />
|
</uni-forms-item>
|
|
<uni-forms-item 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="faultDescription" label="备注:">
|
<uni-easyinput type="textarea" v-model="formData.remark" />
|
</uni-forms-item>
|
</uni-group>
|
</uni-forms>
|
|
<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>
|
</template>
|
|
<script>
|
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
|
export default {
|
mixins: [MescrollMixin], // 使用mixin
|
data() {
|
return {
|
// 图片回显
|
fileLists: [],
|
// 上传图片的样式
|
imageStyles: {
|
width: 90,
|
height: 90,
|
},
|
// uni.chooseImage值,从相册选择,拍摄
|
sourceType: ['album', 'camera'],
|
id: '',
|
equipmentList: [],
|
isTrueList: [{
|
text: "是",
|
value: "0"
|
},
|
{
|
text: "否",
|
value: "1"
|
}
|
],
|
type: 'top',
|
scrollLeft: 0,
|
imgList: [],
|
formData: {
|
avatar: [],
|
numSear: '',
|
remark: '',
|
num: '',
|
faultNameList: [],
|
faultName: '',
|
faultType: '',
|
breakdownFlag: '',
|
loadTime: Date.now(),
|
faultDescription: ''
|
},
|
NavBarColor: this.NavBarColor,
|
activeColor: '#5277A6',
|
url: {
|
part: 'eam/equipment/list',
|
upload: "/eam/sysFiles/batch_upload",
|
add: "/eam/eamReportRepair/add",
|
getEquipmentList: "eam/equipment/asyncLoadEquipment",
|
faultReasonList: 'eam/equipmentFaultReason/list'
|
},
|
|
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'
|
},
|
msgList: [], //列表数据
|
announcement1: [],
|
msg1Count: 0,
|
msg2Count: 0,
|
msg1Title: ""
|
}
|
},
|
computed: {
|
top() {
|
return this.CustomBar * 2 + 130
|
},
|
style() {
|
var StatusBar = this.StatusBar;
|
var CustomBar = this.CustomBar;
|
var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
|
return style
|
},
|
},
|
|
|
onShow() {
|
if (this.mescroll) {
|
this.mescroll.resetUpScroll()
|
}
|
let that = this
|
uni.$off('selectPart');
|
uni.$on('selectPart', function(e) {
|
console.log('监听到事件来自 selectMould ,携带参数 msg 为:', e.msg)
|
const annItem = JSON.parse(e.msg);
|
that.formData.numSear = annItem.equipmentCode + '[' + annItem.equipmentName + ']'
|
that.formData.num = annItem.id
|
|
});
|
},
|
|
|
onLoad(options) {
|
const decodedEquipmentId = decodeURIComponent(options.equipmentId);
|
this.formData.num = decodedEquipmentId;
|
this.getSera()
|
},
|
created() {
|
// this.getEquipment();
|
this.getfaultReasonList();
|
},
|
methods: {
|
getSera() {
|
//联网加载数据
|
this.$http.get(this.url.part, {
|
params: {
|
pageNo: 1,
|
pageSize: 10,
|
order: "desc",
|
column: "createTime",
|
id: this.formData.num
|
}
|
}).then(res => {
|
//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
|
this.announcement1 = res.data.result.records[0]
|
console.log(this.announcement1);
|
//设置列表数据
|
if (res.data.success) {
|
this.formData.numSear = this.announcement1.equipmentCode + '[' + this.announcement1
|
.equipmentName +
|
']'
|
}
|
|
|
}).catch(() => {
|
//联网失败, 结束加载
|
})
|
|
},
|
/**
|
* 设备信息
|
*/
|
OnenterpriseId() {
|
uni.navigateTo({
|
url: "/pages/selectEquipment/selectEquipment"
|
})
|
},
|
changefaultNameList(e) {
|
this.formData.faultName = e;
|
|
this.setFaultReason(this.formData.faultName)
|
|
},
|
setFaultReason(value) {
|
for (let i = 0; i < this.formData.faultNameList.length; i++) {
|
if (this.formData.faultNameList[i].id === value) {
|
this.formData.faultType = this.formData.faultNameList[i].faultCategory_dictText
|
this.formData.faultDescription = this.formData.faultNameList[i].faultDescription
|
}
|
|
}
|
},
|
|
|
getfaultReasonList() {
|
this.$http.get(this.url.faultReasonList).then(res => {
|
//设置列表数据
|
if (res.data.success) {
|
this.formData.faultNameList = res.data.result.records
|
} else {
|
uni.showToast({
|
icon: "error",
|
title: res.data.message,
|
duration: 2000
|
});
|
|
}
|
}).catch(() => {
|
this.$tip.error("联网失败")
|
})
|
},
|
|
changeisTrueList(e) {
|
this.formData.breakdownFlag = e;
|
},
|
select(e) {
|
const tempFilePaths = e.tempFilePaths;
|
|
// if (!Array.isArray(tempFilePaths) || tempFilePaths.length === 0) {
|
// uni.showToast({
|
// title: '请选择文件',
|
// icon: 'none'
|
// });
|
// return;
|
// }
|
|
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() {
|
if (this.formData.num == 0 || this.formData.num == undefined) {
|
uni.showToast({
|
icon: "none",
|
title: '设备编号为空!',
|
duration: 2000
|
});
|
return false
|
}
|
if (this.formData.faultName == 0 || this.formData.faultName == undefined) {
|
uni.showToast({
|
icon: "none",
|
title: '故障简称为空!',
|
duration: 2000
|
});
|
return false
|
}
|
// 请求开始 增加遮罩层
|
uni.showLoading({
|
mask: true,
|
title: "加载中....",
|
})
|
this.$http.post(this.url.add, {
|
breakdownFlag: this.formData.breakdownFlag,
|
equipmentId: this.formData.num,
|
faultDescription: this.formData.faultDescription,
|
faultName: this.formData.faultName,
|
faultStartTime: this.formData.loadTime,
|
faultType: this.formData.faultType,
|
faultType_dictText: this.formData.faultType,
|
imageFilesResult: this.formData.avatar, // 包含上传后的图片路径,
|
remark: this.formData.remark
|
}).then(res => {
|
uni.hideLoading();
|
if (res.data.success) {
|
uni.showToast({
|
icon: "success",
|
title: '提交成功',
|
duration: 2000
|
});
|
this.$Router.replaceAll({
|
name: 'index'
|
})
|
|
}
|
}).catch(() => {
|
this.$tip.loaded();
|
uni.showToast({
|
icon: "error",
|
title: '提交失败',
|
duration: 2000
|
});
|
});
|
},
|
|
|
|
},
|
|
}
|
</script>
|
|
<style>
|
.is-hover {
|
color: rgba(255, 255, 255, 0.6);
|
background-color: #55aaff;
|
border-color: #55aaff;
|
}
|
|
|
|
.content {
|
margin-top: 5px;
|
}
|
|
.content scroll-view {
|
scrollIndicator: "none"
|
}
|
|
.popupView {
|
margin-top: 85px;
|
height: auto;
|
}
|
</style>
|