| | |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="title">物料编码</view> |
| | | <input placeholder="请扫描物料编码" v-model="matnrCode"></input> |
| | | <input placeholder="请扫描物料编码" v-model="matnrCode" @input="onMatnrCodeInput" @confirm="search"></input> |
| | | <text class='cuIcon-search text-blue' @click="search"></text> |
| | | </view> |
| | | <view class="cu-form-group"> |
| | | <view class="title">票号</view> |
| | | <input placeholder="请扫描现品票号" v-model="fieldsIndex" @input="search()" focus></input> |
| | | <text class='cuIcon-close text-gray margin-right-xs' v-show="fieldsIndex!==''" |
| | | @click="clearCode"></text> |
| | | <!-- <text class='cuIcon-search text-blue' @click="search"></text> --> |
| | | </view> |
| | | <!-- <view class="cu-form-group">--> |
| | | <!-- <view class="title">票号</view>--> |
| | | <!-- <input placeholder="请扫描现品票号" v-model="fieldsIndex" @input="search()" focus></input>--> |
| | | <!-- <text class='cuIcon-close text-gray margin-right-xs' v-show="fieldsIndex!==''"--> |
| | | <!-- @click="clearCode"></text>--> |
| | | <!-- <!– <text class='cuIcon-search text-blue' @click="search"></text> –>--> |
| | | <!-- </view>--> |
| | | <view class="cu-form-group"> |
| | | <view class="title">ASN单号</view> |
| | | <input placeholder="请输入ASN单号" v-model="asnCode"></input> |
| | |
| | | <text class="text-grey ">{{item.splrBatch}}</text> |
| | | </view> |
| | | </view> |
| | | <view class="cu-item"> |
| | | <view class="content"> |
| | | <text class="text-black">票号:<text class="text-grey ">{{item.crushNo}}</text></text> |
| | | </view> |
| | | </view> |
| | | <!-- <view class="cu-item">--> |
| | | <!-- <view class="content">--> |
| | | <!-- <text class="text-black">票号:<text class="text-grey ">{{item.crushNo}}</text></text>--> |
| | | <!-- </view>--> |
| | | <!-- </view>--> |
| | | <view class="cu-item"> |
| | | <view class="content"> |
| | | <text class="text-black">库存单位: <text class="text-grey ">{{item.stockUnit}}</text></text> |
| | |
| | | </view> |
| | | </view> |
| | | <view class="cu-item"> |
| | | <view class="content"> |
| | | <view class="content" v-if="item.asnCode"> |
| | | <text class="text-black">可组盘数量:<text |
| | | class="text-grey ">{{item.anfme - item.workQty - item.qty}}</text></text> |
| | | </view> |
| | |
| | | <view class="title text-blue"><text |
| | | class="text-red text-xl vertical-middle">*</text>组盘数量: |
| | | </view> |
| | | <uni-number-box style="width: 70%;" :min="0" :max="max" :decimal="2" :step="0.000001" |
| | | <uni-number-box style="width: 70%;" :min="0" :max="max" :decimal="6" :step="1" |
| | | v-model="item.receiptQty"></uni-number-box> |
| | | </view> |
| | | </view> |
| | |
| | | range: [], |
| | | asnCode: '', |
| | | repeatClick: false, |
| | | fieldsIndex: null, |
| | | isconfirm: false, |
| | | matnrCode: '', |
| | | max: 99999999, |
| | | searchTimer: null, |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | }, |
| | | mounted() {}, |
| | | methods: { |
| | | onMatnrCodeInput(e) { |
| | | // 扫码输入时自动触发查询 |
| | | if (e.detail && e.detail.value && e.detail.value.trim() !== '') { |
| | | this.matnrCode = e.detail.value; |
| | | // 如果物料编码为"0",不请求接口 |
| | | if (this.matnrCode.trim() === '0') { |
| | | return; |
| | | } |
| | | // 延迟一下再查询,避免频繁请求 |
| | | if (this.searchTimer) { |
| | | clearTimeout(this.searchTimer); |
| | | } |
| | | this.searchTimer = setTimeout(() => { |
| | | this.getDet(); |
| | | }, 500); |
| | | } |
| | | }, |
| | | async search() { |
| | | // if (this.fieldsIndex.length < 25) { |
| | | // return; |
| | | // } |
| | | const find = this.list.find(el => el.trackCode === this.barcode); |
| | | find ? this.scrollTo() : this.getDet(); |
| | | // 如果物料编码为空,不执行查询 |
| | | if (!this.matnrCode || this.matnrCode.trim() === '') { |
| | | return; |
| | | } |
| | | // 如果物料编码为"0",不请求接口 |
| | | if (this.matnrCode.trim() === '0') { |
| | | return; |
| | | } |
| | | // 直接调用查询方法 |
| | | this.getDet(); |
| | | }, |
| | | getDet() { |
| | | let that = this; |
| | | // 如果物料编码为"0",不请求接口 |
| | | if (that.matnrCode && that.matnrCode.trim() === '0') { |
| | | return; |
| | | } |
| | | // 检查是否有查询条件 |
| | | if ((!that.matnrCode || that.matnrCode.trim() === '') && |
| | | (!that.asnCode || that.asnCode.trim() === '')) { |
| | | uni.showToast({ |
| | | title: "请输入物料编码或ASN单号", |
| | | icon: "none", |
| | | position: 'top' |
| | | }) |
| | | return; |
| | | } |
| | | let param = { |
| | | matnrCode: that.matnrCode.trim(), |
| | | asnCode: that.asnCode.trim(), |
| | | fieldsIndex: that.fieldsIndex.trim() |
| | | matnrCode: that.matnrCode ? that.matnrCode.trim() : '', |
| | | asnCode: that.asnCode ? that.asnCode.trim() : '' |
| | | } |
| | | that.getDetl(param); |
| | | }, |
| | | clearCode() { |
| | | this.fieldsIndex = '' |
| | | }, |
| | | async getDetl(req) { |
| | | let that = this; |
| | |
| | | title: "加载中...", |
| | | mask: true |
| | | }) |
| | | // 构建请求参数,只传递非空值 |
| | | let requestParams = {}; |
| | | if (that.matnrCode && that.matnrCode.trim() !== '') { |
| | | requestParams.matnrCode = that.matnrCode.trim(); |
| | | } |
| | | if (that.asnCode && that.asnCode.trim() !== '') { |
| | | requestParams.asnCode = that.asnCode.trim(); |
| | | requestParams.code = that.asnCode.trim(); |
| | | } |
| | | if (req && req.batch) { |
| | | requestParams.batch = req.batch; |
| | | } |
| | | |
| | | const { |
| | | code, |
| | | data, |
| | | msg |
| | | } = await request('/asnOrderItem/trackCode', { |
| | | matnrCode: that.matnrCode, |
| | | asnCode: that.asnCode, |
| | | code: that.asnCode, |
| | | fieldsIndex: that.fieldsIndex, |
| | | batch: req.batch |
| | | }, "post") |
| | | } = await request('/asnOrderItem/trackCode', requestParams, "post") |
| | | console.log('查询参数:', requestParams); |
| | | console.log('查询结果:', code, data); |
| | | if (code === 200) { |
| | | if (!data || data.length === 0) { |
| | | console.warn('未找到可组托的物料,请检查:1.物料编码是否正确 2.物料是否已收货至收货区 3.是否还有可组托数量'); |
| | | uni.showToast({ |
| | | title: "未找到可组托的物料", |
| | | icon: "none", |
| | | position: 'top' |
| | | }) |
| | | uni.hideLoading(); |
| | | return; |
| | | } |
| | | for (var i = 0; i < data.length; i++) { |
| | | data[i].receiptQty = data[i].anfme - data[i].workQty; |
| | | data[i].crushNo = that.fieldsIndex; |
| | | // 计算可组盘数量 = 总数量 - 已执行数量 - 已收货数量 |
| | | let anfme = data[i].anfme || 0; |
| | | let workQty = data[i].workQty || 0; |
| | | let qty = data[i].qty || 0; |
| | | data[i].receiptQty = anfme - workQty - qty; |
| | | // 确保可组盘数量不为负数 |
| | | if (data[i].receiptQty < 0) { |
| | | data[i].receiptQty = 0; |
| | | } |
| | | data[i].selected = true; |
| | | } |
| | | that.fieldsIndex = null; |
| | | that.showBackData(data) |
| | | // 加载物料成功后,清空物料编码输入框 |
| | | that.matnrCode = ''; |
| | | } else { |
| | | uni.showToast({ |
| | | title: msg, |
| | | title: msg || "查询失败", |
| | | icon: "none", |
| | | position: 'top' |
| | | }) |
| | |
| | | } |
| | | }, |
| | | showBackData(data) { |
| | | let status; |
| | | data.map(item => { |
| | | this.list.push(item) |
| | | }) |
| | | let oldLength = this.list.length |
| | | this.list = this.list.filter((item, index, self) => |
| | | self.findIndex(i => ( |
| | | i.id === item.id // 根据id去重 |
| | | )) === index && item.isptResult === self[0].isptResult |
| | | ); |
| | | let newLength = this.list.length |
| | | |
| | | if (oldLength > newLength) { |
| | | this.showMsg("新明细被过滤,请检查状态") |
| | | } |
| | | // 追加新物料到列表,只根据id去重,不限制质检结果 |
| | | data.forEach(item => { |
| | | // 检查是否已存在相同id的物料,如果不存在则追加 |
| | | const exists = this.list.some(existingItem => existingItem.id === item.id); |
| | | if (!exists) { |
| | | this.list.push(item); |
| | | } |
| | | }); |
| | | }, |
| | | showMsg(msg) { |
| | | setTimeout(function() { |
| | |
| | | }) |
| | | return; |
| | | } |
| | | // 校验所有物料的组盘数量不能为空、不能为0 |
| | | for (let i = 0; i < this.list.length; i++) { |
| | | const item = this.list[i]; |
| | | if (item.receiptQty === null || item.receiptQty === undefined || item.receiptQty === '' || item.receiptQty === 0) { |
| | | uni.showToast({ |
| | | title: `第${i + 1}个物料(${item.matnrCode || item.maktx || '未知'})的组盘数量不能为空或0`, |
| | | icon: "none", |
| | | position: 'top', |
| | | duration: 3000 |
| | | }) |
| | | return; |
| | | } |
| | | } |
| | | this.repeatClick = true |
| | | const newArr = this.list.map(item => { |
| | | return { |