<template>
|
<view>
|
<view>
|
<u-table font-size="25">
|
<u-tr>
|
<u-td>
|
<xfl-select :list="UserArray" :initValue="this.$UserTool.UserInfo.userName" :clearable="false"
|
:disabled="true">
|
</xfl-select>
|
</u-td>
|
<u-td width="25%">现在时间:</u-td>
|
<u-td width="25%">{{date}}</u-td>
|
</u-tr>
|
</u-table>
|
</view>
|
|
<view style="padding: 20rpx 0rpx">
|
<u-table>
|
<u-tr>
|
<u-td width="30%">托盘条码</u-td>
|
<u-td>
|
<u-input v-model="value_rfid" :border="true" :focus="rfidFocus" placeholder="请输入托盘条码"
|
@input="value_rfidChange" />
|
</u-td>
|
</u-tr>
|
<u-tr>
|
<u-td width="30%">轴承条码</u-td>
|
<u-td>
|
<u-input v-model="value_qrcode" :border="true" :focus="qrcodeFocus"
|
placeholder="请输入轴承条码" />
|
</u-td>
|
</u-tr>
|
<u-tr>
|
<u-td width="30%">车型</u-td>
|
<!-- <u-td>
|
<u-input v-model="materielId" :border="true" placeholder="" />
|
</u-td> -->
|
<xfl-select :list="CxTypes" :initValue="'请选择'" :clearable="false" @change="Get_VehicleType_Alls"
|
ref="Get_VehicleType_All">
|
</xfl-select>
|
</u-tr>
|
<u-tr>
|
<u-td width="30%">轴承型号</u-td>
|
<u-td>
|
<!-- 关键:v-if 条件渲染 -->
|
<xfl-select
|
v-if="showBearingSelect"
|
:list="BearingModels"
|
:initValue="'请选择'"
|
:clearable="false"
|
@change="BearingModelss"
|
ref="BearingModelsss"
|
:key="bearingSelectKey">
|
</xfl-select>
|
</u-td>
|
</u-tr>
|
<u-tr>
|
<u-td width="30%">厂家</u-td>
|
<u-td>
|
<u-input v-model="madeUnit" :border="true" :disabled="true" placeholder="自动获取厂家" />
|
</u-td>
|
</u-tr>
|
|
<u-tr>
|
<u-td width="30%">轴承类别</u-td>
|
<!-- <u-td>
|
<u-input v-model="NewOrOld" :border="true" placeholder="" />
|
</u-td> -->
|
<u-td>
|
<xfl-select :list="StateArray" :initValue="'请选择'" :clearable="false" @change="StateChange"
|
ref="StateSelect">
|
</xfl-select>
|
</u-td>
|
|
</u-tr>
|
<u-tr>
|
<u-td width="30%">轴承单号</u-td>
|
<u-td>
|
<u-input v-model="LotNumber" :border="true" placeholder="轴承单号" />
|
</u-td>
|
</u-tr>
|
<u-tr>
|
<u-td width="30%">生产日期</u-td>
|
<u-td>
|
<u-input v-model="ProductDate" :border="true" :focus="prdateFocus" placeholder="生产日期" />
|
</u-td>
|
</u-tr>
|
</u-table>
|
</view>
|
<view style="padding: 0rpx 0rpx;">
|
<u-table>
|
<u-tr>
|
<u-td>
|
<u-button style="width:100px" type="primary" @click="SaveInfomation">组盘</u-button>
|
</u-td>
|
</u-tr>
|
</u-table>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
var _this;
|
var _user;
|
export default {
|
data() {
|
return {
|
bearingSelectKey: 0, // 保留key作为双保险
|
showBearingSelect: true, // 新增:控制组件销毁/创建
|
date: '',
|
CurrentUser: '', //当前用户
|
value_rfid: '',
|
value_qrcode: '',
|
//厂家
|
madeUnit: '',
|
//车型
|
materielId: '',
|
//轴承型号
|
selectedBearingModel: '', // 新增:当前选中的轴承型号值
|
materielType: '',
|
//检修类型
|
NewOrOld: '',
|
//批次 --2024.6.20新增
|
LotNumber: '',
|
//生产日期 --2024.6.20新增
|
ProductDate: '',
|
rfidFocus: false,
|
qrcodeFocus: false,
|
prdateFocus: false,
|
CxTypes:[], //所有车型
|
BearingModels:[], // 对应车型下面的所有轴承型号
|
templists:[], // 临时保存 轴承型号 和 厂家
|
StateArray: [{
|
label: 'RO',
|
value: '新造'
|
},{
|
label: 'R1',
|
value: '检修'
|
}]
|
}
|
},
|
methods: {
|
UserChange(value) {
|
|
},
|
VehicleType(){
|
let data = {};
|
_this.$AjaxRequest.Params('post', 'Dt_materielinfo/Get_VehicleType_All',
|
data, _user.token);
|
_this.$AjaxRequest.Request().then(function(result) {
|
if (result.data.status) {
|
_this.CxTypes = result.data.data
|
} else {
|
uni.showToast({
|
icon: 'none',
|
title: "请求错误:" + result.data.message,
|
duration: 2000
|
});
|
}
|
console.log("车型的所有数据",result)
|
}).catch(function(err) {
|
uni.showToast({
|
icon: 'none',
|
title: "请求后台异常,错误信息." + err.errMsg,
|
duration: 2000
|
});
|
});
|
},
|
Get_VehicleType_Alls(value){
|
_this.materielId = value.orignItem; // 给车型赋值
|
|
console.log(_this.materielId);
|
|
// ==================== 核心:完全销毁并重建轴承型号下拉框 ====================
|
|
// 1. 立即销毁组件(清除所有内部状态)
|
_this.showBearingSelect = false;
|
|
// 2. 清空所有相关数据
|
_this.BearingModels = [];
|
_this.selectedBearingModel = '';
|
_this.madeUnit = '';
|
_this.materielType = '';
|
|
// 3. 延迟重建组件(确保销毁完成)
|
setTimeout(() => {
|
_this.showBearingSelect = true;
|
_this.bearingSelectKey += 1; // 同时改变key,双保险
|
|
// 确保渲染完成后再请求数据
|
_this.$nextTick(() => {
|
// 请求新数据
|
let data = { MainData: { "materielId": _this.materielId } };
|
_this.$AjaxRequest.Params('post', 'Dt_materiel_zc_info/GetBearingModel', data, _user.token);
|
|
_this.$AjaxRequest.Request().then(function(result) {
|
const backendList = result.data.data || [];
|
_this.templists = backendList;
|
|
if (backendList.length === 0) {
|
_this.BearingModels = [];
|
return;
|
}
|
|
_this.BearingModels = backendList.map(item => item.materiel_zc_id_list);
|
|
console.log("车型对应的轴承数据", result);
|
console.log("轴承型号的数据", _this.BearingModels);
|
console.log("轴承型号和厂家的数据", _this.templists);
|
}).catch(function(err) {
|
uni.showToast({
|
icon: 'none',
|
title: "请求后台异常,错误信息." + err.errMsg,
|
duration: 2000
|
});
|
});
|
});
|
}, 150); // 150ms延迟确保销毁完成
|
},
|
BearingModelss(value){
|
console.log("选择的轴承型号是",value.orignItem)
|
// 这里赋值厂家
|
_this.templists.forEach(x => { // 关键:forEach 小写e
|
if(value.orignItem == x.materiel_zc_id_list){
|
_this.madeUnit = x.materiel_zc_name_list
|
_this.materielType = value.orignItem
|
}
|
});
|
},
|
StateChange(value) { // 选择轴承类别
|
_this.NewOrOld = value.orignItem.label;
|
},
|
setTimer() {
|
if (this.timer == null) {
|
this.timer = setInterval(() => {
|
this.date = this.$DateTool.getDate();
|
}, 1000)
|
}
|
|
},
|
value_rfidChange() {
|
if (_this.value_rfid.length == 6) {
|
_this.qrcodeFocus = true;
|
}
|
},
|
initInfo() {
|
_this.madeUnit = '';
|
_this.materielId = '';
|
_this.materielType = '';
|
_this.NewOrOld = '';
|
_this.LotNumber = '';
|
_this.ProductDate = '';
|
},
|
SaveInfomation() {
|
//_this.LotNumber == '' ||
|
if (_this.value_rfid.length == 0 || _this.value_qrcode.length == 0 ||
|
_this.madeUnit == '' || _this.materielId == '' ||
|
_this.materielType == '' || _this.NewOrOld == '' ||
|
_this.ProductDate == '') {
|
|
uni.showToast({
|
title: "组盘信息不能为空",
|
duration: 2000,
|
icon: 'none',
|
});
|
return;
|
}
|
if (_this.value_rfid.length > 6) {
|
uni.showToast({
|
title: "托盘长度不能大于6位数。",
|
duration: 2000,
|
icon: 'none',
|
});
|
return;
|
}
|
|
uni.showModal({
|
title: '提示',
|
content: '是否确认组盘?',
|
success: function(res) {
|
if (res.confirm) {
|
let data = {
|
MainData: {
|
rfid: _this.value_rfid,
|
qrcode: _this.value_qrcode,
|
madeUnit: _this.madeUnit,
|
materielId: _this.materielId,
|
materielType: _this.materielType,
|
NewOrOld: _this.NewOrOld,
|
LotNumber: _this.LotNumber,
|
ProductDate: _this.ProductDate
|
},
|
};
|
console.log("最后提交的组盘信息",data)
|
_this.$AjaxRequest.Params('post', 'ToAPP/InboundBoxingAction',
|
data, _user.token);
|
_this.$AjaxRequest.Request().then(function(result) {
|
if (result.data.status) {
|
uni.showToast({
|
title: "组盘成功!",
|
duration: 2000
|
});
|
_this.value_rfid = "";
|
_this.value_qrcode = "";
|
_this.initInfo();
|
_this.rfidFocus = true;
|
} else {
|
uni.showToast({
|
icon: 'none',
|
title: "请求错误:" + result.data.message,
|
duration: 2000
|
});
|
}
|
}).catch(function(err) {
|
uni.showToast({
|
icon: 'none',
|
title: "请求后台异常,错误信息." + err.errMsg,
|
duration: 2000
|
});
|
});
|
} else if (res.cancel) {}
|
}
|
});
|
},
|
},
|
created: function() {
|
// 每次进入界面时,先清除之前的所有定时器,然后启动新的定时器
|
clearInterval(this.timer)
|
this.timer = null;
|
this.setTimer();
|
_user = this.$UserTool.UserInfo;
|
this.CurrentUser = _user.userName;
|
this.UserArray = [this.$UserTool.AllUserInfo];
|
|
},
|
destroyed: function() {
|
// 每次离开当前界面时,清除定时器
|
clearInterval(this.timer);
|
this.timer = null;
|
},
|
mounted() {
|
_this = this;
|
_this.rfidFocus = true;
|
this.VehicleType();
|
},
|
|
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.tdHeight {
|
height: 80rpx;
|
}
|
|
.loopView {
|
height: 160px;
|
background-color: #f0f0f0;
|
margin-top: 10px;
|
}
|
|
.loopItem {
|
margin-top: 5px;
|
margin-left: 15px;
|
|
}
|
|
.deleteBtn {
|
margin-top: 25px;
|
margin-left: 10px;
|
width: 120px;
|
background-color: orangered;
|
}
|
</style>
|