<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" :rules="rules" validate-trigger="submit" err-show-type="undertext">
|
<uni-group top="10">
|
<uni-forms-item name="factoryId" label="产线:" :label-width="100" :required="true">
|
<uni-data-select :localdata="formData.msListCategory" popup-title="请选择" @change="changeLine"
|
:disabled="true" :clear="false" v-model="formData.factoryId">
|
</uni-data-select>
|
</uni-forms-item>
|
|
<uni-forms-item name="buttonId" label="安灯类型:" :label-width="100">
|
<uni-data-select :localdata="formData.handleList" popup-title="请选择" :disabled="true"
|
@change="changehnadle" :clear="false" v-model="formData.buttonId">
|
</uni-data-select>
|
</uni-forms-item>
|
|
<uni-forms-item name="andonTime" :label-width="100" label="安灯时间:">
|
<uni-datetime-picker type="datetime" :disabled="true" v-model="formData.andonTime" />
|
</uni-forms-item>
|
|
<uni-forms-item name="andonLevel" :label-width="100" label="安灯等级:">
|
<uni-data-select :localdata="formData.andonLevel" popup-title="请选择" @change="changeLevel"
|
:clear="false" :disabled="true" v-model="formData.andonLevelValue">
|
</uni-data-select>
|
</uni-forms-item>
|
|
<uni-forms-item name="orderStatus" :label-width="100" label="安灯状态:">
|
<uni-data-select :localdata="formData.andonStatus" popup-title="请选择" @change="changeStatus"
|
:disabled="true" :clear="false" v-model="formData.orderStatus">
|
</uni-data-select>
|
</uni-forms-item>
|
<uni-forms-item name="num" :label-width="100" label="安灯发起人:">
|
<uni-easyinput v-model="formData.operator" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item name="num" :label-width="100" label="处理人:">
|
<uni-easyinput v-model="formData.realname" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item name="num" :label-width="100" label="响应人:">
|
<uni-easyinput v-model="formData.realname" :disabled="true" />
|
</uni-forms-item>
|
<uni-forms-item name="problemDescreption" :label-width="100" label="问题描述:">
|
<uni-easyinput type="textarea" placeholder="请输入问题描述" v-model="formData.problemDescreption"
|
:maxlength="500" />
|
</uni-forms-item>
|
|
<uni-forms-item name="resolutionDescreption" :label-width="100" label="处理结果描述:">
|
<uni-easyinput type="textarea" placeholder="请输入处理结果描述" v-model="formData.resolutionDescreption"
|
:maxlength="500" />
|
</uni-forms-item>
|
</uni-group>
|
</uni-forms>
|
|
<button class="margin-bottom" type="primary" @click="submitForm">确定</button>
|
</view>
|
</template>
|
|
<script>
|
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
|
|
export default {
|
mixins: [MescrollMixin],
|
data() {
|
return {
|
NavBarColor: this.NavBarColor,
|
url: {
|
add: "andonorder/andonOrder/AndonHandel",
|
andonLevel: "sys/dict/getDictItems/andon_level",
|
andonStatus: "sys/dict/getDictItems/order_status",
|
andonType: 'sys/dict/getDictItems/andon_button_config,button_name,id',
|
andonCategory: "base/factory/queryUserProductionLineList"
|
},
|
|
formData: {
|
operator:'',
|
orderIds: '',
|
handleList: [],
|
msListCategory: [],
|
andonLevel: [],
|
andonStatus: [],
|
problemDescreption: '',
|
resolutionDescreption: '',
|
andonTime: Date.now(),
|
factoryId: '',
|
buttonId: '',
|
andonLevelValue: '',
|
orderStatus: '',
|
realname: '',
|
userId: ''
|
},
|
|
receivedItem: {},
|
currentLineId: '',
|
// 表单验证规则
|
rules: {
|
factoryId: {
|
rules: [{
|
required: true,
|
errorMessage: '请选择产线'
|
}]
|
},
|
buttonId: {
|
rules: [{
|
required: true,
|
errorMessage: '请选择安灯类型'
|
}]
|
},
|
andonTime: {
|
rules: [{
|
required: true,
|
errorMessage: '请选择安灯时间'
|
}]
|
},
|
andonLevelValue: {
|
rules: [{
|
required: true,
|
errorMessage: '请选择安灯等级'
|
}]
|
},
|
orderStatus: {
|
rules: [{
|
required: true,
|
errorMessage: '请选择安灯状态'
|
}]
|
}
|
}
|
}
|
},
|
onLoad(options) {
|
// 接收 item 参数(需要解码并转换回对象)
|
if (options.item) {
|
// 先解码再转成对象
|
this.receivedItem = JSON.parse(decodeURIComponent(options.item));
|
|
}
|
|
this.formData.orderIds = this.receivedItem.id;
|
this.formData.factoryId = options.currentLineId;
|
this.formData.orderStatus = this.receivedItem.orderStatus;
|
this.formData.operator=this.receivedItem.operatorName;
|
this.formData.andonLevelValue = this.receivedItem.andonLevel;
|
this.formData.realname = this.receivedItem.responder;
|
this.formData.buttonId = this.receivedItem.buttonId;
|
console.log('接收的item参数:', this.receivedItem);
|
|
},
|
created() {
|
this.loadData();
|
},
|
|
methods: {
|
serialNumScan() {
|
uni.navigateTo({
|
url: "/pages/selectUsers/selectUsers"
|
})
|
},
|
// 加载所有下拉列表数据
|
loadData() {
|
// 并行加载多个接口,优化性能
|
Promise.all([
|
this.andonCategory(),
|
this.andonType(),
|
this.andonLevel(),
|
this.andonStatus()
|
]).then(() => {
|
console.log('所有数据加载完成');
|
}).catch(() => {
|
uni.showToast({
|
title: '数据加载失败',
|
icon: 'none'
|
});
|
});
|
},
|
|
|
// 产线变更
|
changeLine(e) {
|
this.formData.factoryId = e;
|
},
|
|
// 安灯类型变更
|
changehnadle(e) {
|
this.formData.buttonId = e;
|
},
|
|
// 安灯等级变更
|
changeLevel(e) {
|
this.formData.andonLevelValue = e;
|
},
|
|
// 安灯状态变更
|
changeStatus(e) {
|
this.formData.orderStatus = e;
|
},
|
|
// 获取产线列表
|
andonCategory() {
|
return new Promise((resolve, reject) => {
|
this.$http.get(this.url.andonCategory).then(res => {
|
if (res.data.success) {
|
this.formData.msListCategory = res.data.result;
|
resolve();
|
} else {
|
reject();
|
}
|
}).catch(() => {
|
uni.showToast({
|
title: '产线数据加载失败',
|
icon: 'none'
|
});
|
reject();
|
});
|
});
|
},
|
|
// 获取安灯类型列表
|
andonType() {
|
return new Promise((resolve, reject) => {
|
this.$http.get(this.url.andonType).then(res => {
|
if (res.data.success) {
|
this.formData.handleList = res.data.result;
|
resolve();
|
} else {
|
reject();
|
}
|
}).catch(() => {
|
uni.showToast({
|
title: '安灯类型加载失败',
|
icon: 'none'
|
});
|
reject();
|
});
|
});
|
},
|
|
// 获取安灯等级列表
|
andonLevel() {
|
return new Promise((resolve, reject) => {
|
this.$http.get(this.url.andonLevel).then(res => {
|
if (res.data.success) {
|
this.formData.andonLevel = res.data.result;
|
resolve();
|
} else {
|
reject();
|
}
|
}).catch(() => {
|
uni.showToast({
|
title: '安灯等级加载失败',
|
icon: 'none'
|
});
|
reject();
|
});
|
});
|
},
|
|
// 获取安灯状态列表
|
andonStatus() {
|
return new Promise((resolve, reject) => {
|
this.$http.get(this.url.andonStatus).then(res => {
|
if (res.data.success) {
|
this.formData.andonStatus = res.data.result;
|
resolve();
|
} else {
|
reject();
|
}
|
}).catch(() => {
|
uni.showToast({
|
title: '安灯状态加载失败',
|
icon: 'none'
|
});
|
reject();
|
});
|
});
|
},
|
|
// 表单提交
|
submitForm() {
|
this.AddLoadMaterial();
|
|
},
|
|
// 提交安灯工单
|
AddLoadMaterial() {
|
/**
|
* 安灯人- 发起人
|
*/
|
// 显示加载中
|
uni.showLoading({
|
title: '提交中...'
|
});
|
this.$http.post(this.url.add, {
|
andonLevel: this.formData.andonLevelValue,
|
buttonId: this.formData.buttonId,
|
factoryId: this.formData.factoryId,
|
id: this.formData.orderIds,
|
operateTime: this.formData.andonTime,
|
operator:this.formData.operator,
|
responder: this.formData.realname,
|
processor: this.formData.realname,
|
orderStatus: this.formData.orderStatus,
|
problemDescreption: this.formData.problemDescreption,
|
resolutionDescreption: this.formData.resolutionDescreption
|
}).then(res => {
|
uni.hideLoading();
|
|
if (res.data.success) {
|
uni.showModal({
|
title: '成功',
|
content: res.data.message || '处理成功',
|
showCancel: false,
|
success: () => {
|
uni.reLaunch({
|
url:'/pages/eam/andon/andonCall/andonCall'
|
})
|
}
|
});
|
} else {
|
uni.showModal({
|
title: '提示',
|
content: res.data.message || '提交失败,请重试',
|
showCancel: false
|
});
|
}
|
}).catch(() => {
|
uni.hideLoading();
|
uni.showToast({
|
title: '网络异常,请稍后再试',
|
icon: 'none'
|
});
|
});
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.container {
|
background-color: #f5f5f5;
|
min-height: 100vh;
|
}
|
|
.margin-bottom {
|
margin: 30px 30px 50px;
|
width: calc(100% - 60px);
|
}
|
|
uni-easyinput[type="textarea"] {
|
min-height: 100px;
|
}
|
|
/* 优化表单项间距 */
|
uni-forms-item {
|
margin-bottom: 10px;
|
}
|
</style>
|