12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184 |
- <template>
- <view>
- <view class="sticky-box">
- <view class="button-group">
- <button type="default" @click="reset">取消</button>
- <button type="default" @click="navigateToSummary">统计</button>
- <button type="default" @click="navigateToSearch">查仓</button>
- <button type="default" @click="navigateToStage">暂存</button>
- </view>
- <uni-easyinput prefixIcon="search" :focus="isFocus" v-model="searchValue" @blur="isFocus = false"
- @confirm="scan" @clear="clear" placeholder="请扫描拼件单号">
- </uni-easyinput>
- </view>
- <view class="table-container" style="height: 100vh;">
- <scroll-view class="table-content" :style="{'height': clientHeight + 'px'}" scroll-x scroll-y
- :scroll-into-view="scrollItem">
- <view class="table-header">
- <!-- <view class="table-cell">操作</view> -->
- <view class="table-cell">扫描状态</view>
- <view class="table-cell1">装箱单号</view>
- <view class="table-cell">仓位</view>
- <view class="table-cell">收货仓库</view>
- <view class="table-cellwl">物料编码</view>
- <view class="table-cellph">批号</view>
- <view class="table-cell1">实际作业数量</view>
- <view class="table-cell1">计量单位</view>
- <view class="table-cell">日期</view>
- <view class="table-cell3">单据编号</view>
- </view>
- <view class="table-row" v-for="(item, index) in indexList" :key="index" :id="'scrollItem-' + index"
- :style="getStyle(item.smzt)">
- <!-- <view class="table-cell"><button type="default" size="mini" @click="edit(item,index)">编辑</button>
- </view> -->
- <view class="table-cell">{{ item.smzt? '已扫描' : '未扫描' }}</view>
- <view class="table-cell1" :style="getStyle(item.smzt)">{{ item["FENCHASENUM.LT"] }}</view>
- <view class="table-cell">{{ item["FStockLocId.FF102029.FNumber"] }}</view>
- <view class="table-cell" :style="getStyle(item.smzt)">{{ item["FSTOCKID.FName"] }}</view>
- <view class="table-cellwl" :style="getStyle(item.smzt)">{{ item["FMATERIALID.FNumber"] }}</view>
- <view class="table-cellph" :style="getStyle(item.smzt)">{{ item["FLOT.FNumber"] }}</view>
- <view class="table-cell1" :style="getStyle(item.smzt)">
- {{ getActualWorkQuantity(item) }}
- </view>
- <view class="table-cell1" :style="getStyle(item.smzt)">{{ item["FUnitID.FName"] }}</view>
- <view class="table-cell" :style="getStyle(item.smzt)">{{ item["FDate"].substring(0, 10) }}</view>
- <view class="table-cell3" :style="getStyle(item.smzt)">{{ item["FBillNo"] }}</view>
- </view>
- </scroll-view>
- </view>
- <view style="height: 200px;touch-action: none;"></view>
- <view class="card-bottom" style="">
- <view style="margin: 0 auto;">
- <view
- style="display: flex;flex-direction: row;margin-top: 8px;font-size: 12px;margin-right: 15px;margin-bottom: 8px;">
- <view style="margin-right: 15px;">源单明细:{{ indexList.length }}</view>
- <view style="margin-right: 15px;">已扫描:{{ indexListLength }}</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- audit,
- getBillList,
- getInventoryList,
- save,
- submit
- } from '../../api/production_replenishment';
- import modal from '../../plugins/modal';
- // import {
- // audioUrls,
- // playVoice
- // } from '../../utils/audio';
- import {
- playVoice,
- audioUrls,
- playSequentially
- } from '../../utils/audio2';
- import submitHelper from '@/utils/storageSubmitHelper.js'; // 确保路径正确
- import {
- executeSql
- } from '../../utils/database';
- import {
- createInventoryQueryRequest,
- getSearchParam,
- getStorageByBillNoParam,
- getStorageSearchParam
- } from '@/utils/storageParams.js';
- export default {
- onShow() {
- const res = uni.getSystemInfo({
- success: (res => {
- console.log(res.windowHeight)
- if (res.windowHeight < 600) {
- this.clientHeight = 580
- } else {
- this.clientHeight = res.windowHeight - 150;
- }
- console.log(res.windowHeight)
- console.log(this.clientHeight)
- // console.log(getApp().globalData.navHeight)
- })
- });
- this.$nextTick(() => {
- this.searchValue = ''
- this.isFocus = true;
- })
- },
- computed: {
- //已扫描数量
- indexListLength() {
- console.log("执行了计算属性")
- console.log(this.indexList.filter(obj => obj.smzt === 1).length)
- return this.indexList.filter(obj => obj.smzt === 1).length
- },
- //剩余数量
- indexList2Length() {
- let arr1 = this.indexList.filter((item, index, self) => {
- return item.smzt == 0
- })
- console.log(arr1)
- return arr1.length
- },
- //正操作仓位未扫描数量
- indexList3Length() {
- return this.indexList.filter(item =>
- item["FStockLocId.FF102029.fname"] == this.Location && item['smzt'] != 1
- ).length
- },
- showWorkCenter() {
- return this.formId !== 'PUR_MRB';
- },
- showRemark() {
- return this.formId !== 'PUR_MRB';
- },
- showApplicant() {
- return this.formId !== 'PUR_MRB';
- }
- },
- mounted() {
- // 页面加载完成后滚动到目标数据位置
- uni.$on('scrollIntoView', (target) => {
- this.$nextTick(() => {
- // 使用id属性定位
- uni.createSelectorQuery().select('#' + target).boundingClientRect().exec((rect) => {
- console.log(rect)
- uni.pageScrollTo({
- scrollTop: rect[0].top - 95,
- duration: 0
- });
- });
- });
- })
- this.$nextTick(() => {
- this.searchValue = ''
- this.isFocus = true;
- })
- },
- //监听
- watch: {
- Location(newValue, oldValue) {
- console.log(`Location changed from ${oldValue} to ${newValue}`)
- this.Location = newValue
- // 可以在这里执行相应的操作
- },
- },
- data() {
- return {
- formId: '',
- fbillType: '',
- isFocus: true,
- indexList: [],
- clientHeight: '',
- searchValue: '',
- scrollItem: '', // 滚动到的指定元素
- color: '',
- stockNum: '', //正操作仓库
- uniqueFStockLocId: [],
- balance: 0,
- isStage: false,
- stageIds: [],
- stageLists: [],
- tableName: "common_bill",
- };
- },
- //获取上一页传过来的参数
- onLoad(option) {
- this.formId = uni.getStorageSync("formId")
- // this.fbillType = option.FBillType;
- // console.log(this.formId)
- // console.log(this.fbillType)
- uni.setNavigationBarTitle({
- title: uni.getStorageSync("moudleName")
- });
- uni.$on('item', (data) => {
- console.log(data)
- let index = data["index"]
- if ("NewFENCHASENUM.LT" in data) {
- this.indexList[index]["FENCHASENUM.LT"] = data["NewFENCHASENUM.LT"]
- }
- if (this.indexList[index]["FStockLocId.FF102029.fname"] != data["FStockLocId.FF102029.fname"]) {
- const requestData = createInventoryQueryRequest(data["FStockLocId.FF102029.fname"])
- getInventoryList(JSON.stringify(requestData)).then(res => {
- this.indexList[index]["quantity"] = res.length
- console.log("修改了原仓位条数", res.length)
- this.indexList[index]['FStockLocId.FF102029.fname'] = data[
- "FStockLocId.FF102029.fname"]
- // 用于记录每个组合的计数
- let countMap = {};
- // 统计每个组合的行数
- this.indexList.forEach(obj => {
- // 获取当前对象的组合键
- let key = obj.FBillNo + '|' + obj['FStockLocId.FF102029.fname'];
- // 如果该组合已经存在于 countMap 中,则增加计数,否则初始化为 1
- if (countMap[key]) {
- countMap[key]++;
- } else {
- countMap[key] = 1;
- }
- });
- // 将计数值添加到每个对象中
- this.indexList.forEach(obj => {
- let key = obj.FBillNo + '|' + obj['FStockLocId.FF102029.fname'];
- obj.rowCount = countMap[key];
- });
- })
- }
- this.indexList[index]['FInventoryQty'] = data["FInventoryQty"]
- // 定义一个映射对象
- const formIdMap = {
- 'LT_PRD_PMCWorkBench': 'FActualQty',
- 'SP_PickMtrl': 'FActualQty',
- 'STK_MisDelivery': 'FQty',
- 'PUR_MRB': 'FRMREALQTY'
- };
- // 获取对应的字段名称
- const field = formIdMap[this.formId];
- // 如果存在匹配的字段,则更新 indexList
- if (field) {
- this.indexList[index][field] = data[field];
- }
- // this.indexList[index]['FActualQty'] = data["FActualQty"]
- this.indexList[index]['Flot.FNumber'] = data["Flot.FNumber"]
- this.indexList[index]['FAuxPropId.FF101501.FDATAVALUE'] = data["FAuxPropId.FF101501.FDATAVALUE"]
- this.indexList[index]['smzt'] = data["smzt"]
- console.log(this.indexList[index])
- this.$nextTick(() => {
- this.searchValue = ''
- this.isFocus = true
- })
- })
- uni.$on('search', (data) => {
- console.log(data)
- console.log(this.indexList)
- // 遍历 indexList 数组
- this.indexList.forEach(item => {
- // 检查 smzt 是否为 1
- if (item.smzt === 1 && item['FStockLocId.FF102029.FNumber'] == null) {
- // 修改 FStockLocId.FF102029.FNumber 为 'a'
- item['FStockLocId.FF102029.FNumber'] = data;
- }
- });
- // this.indexList = data
- // this.indexList.forEach(item => {
- // // item.smzt = 0; // 增加属性 smzt,并设置初始值为0
- // this.$set(item, 'smzt', 0);
- // })
- // // 用于记录每个组合的计数
- // let countMap = {};
- // // 统计每个组合的行数
- // this.indexList.forEach(obj => {
- // // 获取当前对象的组合键
- // let key = obj.FBillNo + '|' + obj['FStockLocId.FF102029.fname'];
- // // 如果该组合已经存在于 countMap 中,则增加计数,否则初始化为 1
- // if (countMap[key]) {
- // countMap[key]++;
- // } else {
- // countMap[key] = 1;
- // }
- // });
- // // 将计数值添加到每个对象中
- // this.indexList.forEach(obj => {
- // let key = obj.FBillNo + '|' + obj['FStockLocId.FF102029.fname'];
- // // obj.rowCount = countMap[key];
- // this.$set(obj, 'rowCount', countMap[key])
- // });
- // // 1. 提取不同的仓位
- // this.uniqueFStockLocId = [...new Set(this.indexList.map(obj => obj[
- // 'FStockLocId.FF102029.fname']))];
- // console.log(this.uniqueFStockLocId)
- // // this.processQuantity(this.uniqueFStockLocId[0])
- // this.updateIndexList(this.indexList)
- // this.$nextTick(() => {
- // this.searchValue = ''
- // this.isFocus = true;
- // })
- })
- uni.$on('summary', (data) => {
- console.log(data)
- this.indexList = data
- this.searchValue = ''
- this.isFocus = true;
- })
- uni.$on('stage', (data) => {
- console.log(data)
- // 处理每个对象
- this.stageLists = data.map(item => {
- // 解析 data 字段
- const parsedData = JSON.parse(item.data);
- // 返回处理后的对象
- return {
- ...item,
- data: parsedData
- };
- });
- this.stageIds = data.map(item => item.id)
- // this.stageLists = data.map(item => item.data)
- console.log(this.stageIds)
- console.log(this.stageLists)
- // 解析字符串为数组并合并
- const combinedArray = this.stageLists
- .map(item => item.data) // 解析每个字符串
- .flat(); // 合并所有数组
- console.log(combinedArray);
- this.indexList = combinedArray
- this.searchValue = ''
- this.isFocus = true;
- this.isStage = true
- })
- this.$nextTick(() => {
- console.log('dddd')
- this.searchValue = ''
- this.isFocus = true;
- })
- // this.$forceUpdate()
- },
- methods: {
- getActualWorkQuantity(item) {
- switch (this.formId) {
- case 'STK_InStock':
- return item["FRealQty"];
- default:
- return item["FQty"];
- }
- },
- getFabricOrderNo(item) {
- switch (this.formId) {
- case 'PUR_MRB':
- return item["FFabricOrderNo"];
- default:
- return item["FFabricOrderNo.LT"];
- }
- },
- getWorkCenterName(item) {
- switch (this.formId) {
- case 'LT_PRD_PMCWorkBench':
- return item["FEWorkCenterId.LT.fname"];
- case 'STK_MisDelivery':
- case 'SP_PickMtrl':
- return item["FWorkCenterId.fname"];
- default:
- return '';
- }
- },
- getApplicantName(item) {
- switch (this.formId) {
- case 'LT_PRD_PMCWorkBench':
- return item["FApplicantId.fname"];
- case 'STK_MisDelivery':
- return item["FPickingPeople.LT.fname"];
- case 'SP_PickMtrl':
- return item["FPickerId.fname"];
- default:
- return ''; // 默认返回值,可以根据需求调整
- }
- },
- async updateIndexList(data1) {
- try {
- // 存储所有的异步操作 promise
- let promises = [];
- // 遍历 uniqueFStockLocId 数组
- for (let fname of this.uniqueFStockLocId) {
- const requestData = createInventoryQueryRequest(fname)
- // 发起异步请求,并将 promise 存储在数组中
- let promise = getInventoryList(JSON.stringify(requestData)).then(res => {
- let objs = data1.filter(item => item['FStockLocId.FF102029.fname'] === fname);
- objs.forEach(obj => {
- this.$set(obj, 'quantity', res.length);
- });
- });
- promises.push(promise);
- }
- // 等待所有异步操作完成
- await Promise.all(promises)
- console.log(data1)
- this.indexList = data1
- console.log('indexList updated:', this.indexList);
- } catch (error) {
- console.error('Error updating indexList:', error);
- }
- },
- scrollToItem(itemId) {
- // 设置滚动到的指定元素的 ID
- this.scrollItem = itemId;
- console.log(this.scrollItem)
- },
- //取消
- reset() {
- const self = this
- modal.confirm("是否重置?").then(res => {
- if (res) {
- self.indexList = []
- self.searchValue = ""
- self.balance = 0
- this.isFocus = true
- playVoice(audioUrls.warningSuccessUrl)
- } else {
- // 用户点击取消,不执行任何操作
- }
- })
- },
- edit(item, index) {
- uni.navigateTo({
- url: '/pages/storage/show?item=' + encodeURIComponent(JSON.stringify(
- item)) +
- '&&index=' + encodeURIComponent(JSON.stringify(index))
- });
- },
- // scrollToItem(id) {
- // // 使用id属性定位
- // this.$nextTick(() => {
- // uni.$emit('scrollIntoView', id);
- // })
- // },
- showDetail(index) {
- console.log(index);
- let item = this.indexList[index.name]
- console.log(item)
- uni.navigateTo({
- url: '/pages/automatedwarehouse/listshow?Info=' + encodeURIComponent(JSON.stringify(
- item))
- });
- },
- focusPoint() {
- this.isFocus = false;
- this.$nextTick(() => {
- this.isFocus = true;
- });
- },
- clear() {
- this.focusPoint()
- },
- //跳转到查询页面
- navigateToSearch() {
- if (this.indexList.length == 0) {
- // this.isRangeSelected = false; // 显示错误提示
- playVoice(audioUrls.failVoiceUrl)
- uni.showToast({
- title: '请先扫描',
- duration: 2000,
- icon: "error"
- });
- return;
- }
- console.log(this.stockNum)
- uni.navigateTo({
- // url: '/pages/production-replenishment/search', //这是你的当前页面地址
- url: `/pages/storage/search?stockNum=${this.stockNum}`
- });
- },
- navigateToSummary() {
- uni.navigateTo({
- url: '/pages/storage/summary?Info=' + encodeURIComponent(JSON
- .stringify(this.indexList)) + '&&stageInfo=' + encodeURIComponent(JSON
- .stringify(this.stageLists)), //这是你的当前页面地址
- });
- },
- navigateToStage() {
- uni.navigateTo({
- url: '/pages/storage/stage?Info=' + encodeURIComponent(JSON
- .stringify(this.indexList)), //这是你的当前页面地址
- });
- },
- searchValueIsEmpty(data) {
- console.log(data)
- if (data == "" || data == undefined) {
- return true
- } else {
- return false
- }
- },
- checkBarcodeInArray(barcode, arrayOfObjects, propertyName) {
- if (arrayOfObjects.findIndex(item => item[propertyName] === barcode) < 0) { //不存在
- return true
- }
- return false
- },
- areAllDetailsScanned(nowindex) {
- if (this.indexList.filter(item =>
- item["FBillNo"] == this.indexList[nowindex].FBillNo && item[
- 'smzt'] == 0
- ).length == 0) {
- return true
- }
- return false
- },
- isAllPositionsComplete(nowindex) {
- console.log(this.indexList[nowindex].FBillNo)
- console.log(this.indexList[nowindex]["FStockLocId.FF102029.FNumber"])
- if (this.indexList.filter(item =>
- item["FBillNo"] == this.indexList[nowindex].FBillNo && item["FStockLocId.FF102029.FNumber"] ==
- null
- ).length == 0) {
- console.log(this.indexList.filter(item =>
- item["FBillNo"] == this.indexList[nowindex].FBillNo && item[
- "FStockLocId.FF102029.FNumber"] ==
- null
- ).length)
- return true
- }
- return false
- },
- showToast() {
- uni.showToast({
- title: '请扫描条码',
- icon: 'none',
- duration: 3000
- })
- },
- handlePositionScanCompletion() { //根据仓位扫描的完成情况来处理不同的逻辑
- if (this.indexList.filter(item =>
- item["FStockLocId.FF102029.fname"] == this.Location && item[
- 'smzt'] != 1
- ).length == 0) { //该仓位扫描完
- playVoice(audioUrls.allSuccessVoiceUrl)
- uni.showToast({
- title: '该仓位扫描完成',
- icon: 'none',
- duration: 3000
- })
- } else { //如果改仓位未扫描完,提示音
- playVoice(audioUrls.successVoiceUrl)
- uni.showToast({
- title: '扫描成功',
- icon: 'none',
- duration: 3000
- })
- }
- },
- handleError(error) {
- playVoice(audioUrls.failVoiceUrl)
- console.error('操作失败:', error);
- modal.confirm(error.message || '操作失败').then(res => {
- if (res) {
- } else {
- // 用户点击取消,不执行任何操作
- }
- })
- // uni.showToast({
- // title: error.message || '操作失败',
- // duration: 3000,
- // icon: "none"
- // });
- },
- async handleSubmit(FID) {
- const FormId = uni.getStorageSync('formId')
- try {
- await submitHelper.submit(FormId, FID, this.indexList);
- this.indexList = this.indexList.filter(item => item.FID !== FID);
- console.log(this.indexList)
- if (this.isStage == true) {
- // 处理每个对象
- this.stageLists.forEach(item => {
- // 过滤掉 FID 匹配的对象
- item.data = item.data.filter(obj => obj.FID !== FID);
- // 检查 data 数组是否为空
- if (item.data.length === 0) {
- console.log("data 数组为空"); //删除暂存
- this.deleteStages(item.id)
- } else {
- console.log("data 数组不为空");
- }
- })
- console.log(this.stageLists)
- }
- this.balance = 0
- } catch (error) {
- this.handleError(error)
- }
- },
- async deleteStages(id) {
- let condition = `id = (${id})`
- let sql = `delete from ${this.tableName} where ${condition}`
- executeSql(sql).then(result => {
- console.log('结果:', result);
- // this.handleDeleteSuccess()
- })
- .catch(error => {
- console.error('捕获错误:', error); // 输出: 捕获错误: 失败的结果
- // this.handleDeleteFail(error)
- })
- },
- showModalAndHandleSubmit(nowindex) {
- let vm = this
- console.log(nowindex)
- console.log(this.indexList[nowindex])
- let bBillNo = this.indexList[nowindex]["FBillNo"]
- let FID = this.indexList[nowindex]["FID"]
- this.$nextTick(() => {
- this.searchValue = ''
- this.isFocus = true;
- })
- playVoice(audioUrls.allSuccessVoiceUrl)
- uni.showModal({
- title: "提示",
- content: "单号(" + bBillNo + ")已扫描完毕,是否提交",
- showCancel: true,
- success: function(res) {
- if (res.confirm) {
- // this.submit(FID)
- this.handleSubmit(FID)
- } else {
- // 执行取消后的操作
- }
- }.bind(this)
- })
- },
- showModalAndHandlePosition(nowindex) {
- let vm = this
- // console.log(nowindex)
- let bBillNo = this.indexList[nowindex]["FBillNo"]
- // let FID = this.indexList[nowindex]["FID"]
- // this.$nextTick(() => {
- // this.searchValue = ''
- // this.isFocus = true;
- // })
- // playVoice(audioUrls.allSuccessVoiceUrl)
- uni.showModal({
- title: "提示",
- content: "单号(" + bBillNo + ")已扫描完毕,请选择仓位",
- showCancel: true,
- success: function(res) {
- if (res.confirm) {
- // this.submit(FID)
- this.navigateToSearch()
- } else {
- // 执行取消后的操作
- }
- }.bind(this)
- })
- },
- handleScanSuccess() {
- // this.Location = this.indexList[nowindex]["FStockLocId.FF102029.fname"]
- // this.indexList[nowindex].smzt = 1 //修改数据状态
- this.indexList = this.indexList.map(item => {
- if (item["FENCHASENUM.LT"] == this.searchValue) {
- item.smzt = 1
- }
- return item
- })
- console.log(this.indexList)
- let nowindex = null; //该条码的索引
- for (let i = 0; i < this.indexList.length; i++) { //获取查询装箱单号对应仓位,并切换当前仓位
- console.log(this.indexList[i]["FENCHASENUM.LT"])
- console.log(this.searchValue)
- if (this.indexList[i]["FENCHASENUM.LT"] === this.searchValue) {
- // nowlocation = this.indexList[i]["FStockLocId.FF102029.fname"] //当前仓位
- nowindex = i //当前索引
- this.stockNum = this.indexList[nowindex]["FSTOCKID.FNumber"]
- console.log(this.indexList[nowindex]["FSTOCKID.FNumber"])
- // this.balance = this.indexList[i]["quantity"] - this.indexList[i]["rowCount"]
- break;
- }
- }
- console.log(this.stockNum)
- console.log(this.indexList.filter(obj => obj.smzt === 1).length)
- const audioUrlsArr = [];
- audioUrlsArr.push(audioUrls.success2VoiceUrl);
- // console.log(this.getActualWorkQuantity(this.indexList[nowindex]))
- //是否全发
- // if (this.getActualWorkQuantity(this.indexList[nowindex]) == this.indexList[nowindex][
- // "FInventoryQty"
- // ]) { //全发播放声音
- // console.log("播放声音")
- // audioUrlsArr.push(audioUrls.successVoiceUrl);
- // } else { //不全发播放声音
- // audioUrlsArr.push(audioUrls.success2VoiceUrl);
- // }
- // audioUrlsArr.push(audioUrls.success2VoiceUrl);
- // playSequentially(audioUrlsArr);
- // if (this.indexList.filter(item =>
- // item["FStockLocId.FF102029.fname"] == this.Location && item[
- // 'smzt'] != 1
- // ).length == 0) { //该仓位扫描完
- // // playVoice(audioUrls.allSuccessVoiceUrl)
- // audioUrlsArr.push(audioUrls.storeSuccessUrl);
- // }
- if (this.areAllDetailsScanned(nowindex)) { //校验单号是否全扫完
- //校验仓位是否全填
- audioUrlsArr.push(audioUrls.allSuccessVoiceUrl)
- if (this.isAllPositionsComplete(nowindex)) {
- this.showModalAndHandleSubmit(nowindex)
- } else {
- this.showModalAndHandlePosition(nowindex)
- }
- // playVoice(audioUrls.allSuccessVoiceUrl)
- } else { //单号未全扫完
- // this.handlePositionScanCompletion()
- this.$nextTick(() => {
- this.searchValue = ''
- this.isFocus = true;
- this.scrollToItem("scrollItem-" + nowindex)
- })
- }
- playSequentially(audioUrlsArr);
- },
- createSearchCondition(data) {
- return {
- "FormId": uni.getStorageSync('formId'),
- "FStockOrgId": uni.getStorageSync('FStockOrgId'),
- "FEnchaseNum_LT": data,
- };
- },
- createSearchConditionByBillNo(data) {
- return {
- "FormId": uni.getStorageSync('formId'),
- "FBillNo": data,
- };
- },
- async scan() {
- let vm = this
- //校验是否输入条码
- if (this.searchValueIsEmpty(this.searchValue)) {
- playVoice(audioUrls.failVoiceUrl)
- this.showToast()
- this.focusPoint()
- return
- }
- // 列表中是否存在该条码
- if (this.checkBarcodeInArray(this.searchValue, this.indexList, "FENCHASENUM.LT")) { //不存在
- //查询源单列表
- const condition = this.createSearchCondition(this.searchValue);
- const searchParam = getStorageSearchParam(condition)
- modal.loading('获取数据中,请耐心等待...')
- // const submitRes = await this.submitData(submitParam);
- try {
- const BillNo = await getBillList(JSON.stringify(searchParam))
- console.log(BillNo)
- if (BillNo.length !== 0) { //获取到入库单
- const condition = this.createSearchConditionByBillNo(BillNo[0].FBillNo);
- const searchByBillNoParam = getStorageByBillNoParam(condition)
- const BillList = await getBillList(JSON.stringify(searchByBillNoParam))
- console.log(BillList)
- BillList.forEach(item => {
- // item.smzt = 0; // 增加属性 smzt,并设置初始值为0
- this.$set(item, 'smzt', 0);
- this.$set(item, 'FStockLocId.FF102029.FNumber', null);
- })
- // this.indexList = BillList
- this.indexList = this.indexList.concat(BillList)
-
- this.handleScanSuccess()
- // this.indexList = this.indexList.map(item => {
- // if (item["FEnchaseNum.LT"] == this.searchValue) {
- // item.smzt = 1
- // }
- // return item
- // })
- } else { //不存在查询的入库单
- modal.msg("请确认输入条件有效!");
- playVoice(audioUrls.failVoiceUrl);
- }
- modal.closeLoading();
- } catch (error) {
- console.log(error)
- // this.handleError(error);
- throw new Error(error);
- } finally {
- modal.closeLoading();
- }
- this.$nextTick(() => {
- this.searchValue = ''
- this.isFocus = true;
- // this.scrollToItem("scrollItem-" + nowindex)
- })
- // uni.showModal({
- // title: '提示',
- // content: "条码:" + vm.searchValue + '不存在',
- // showCancel: false,
- // success: function(res) {
- // if (res.confirm) {
- // this.focusPoint()
- // vm.searchValue = ''
- // return
- // } else {
- // // 执行取消后的操作
- // }
- // }.bind(this)
- // })
- // playVoice(audioUrls.failVoiceUrl)
- return
- }
- //校验条码已扫描
- // if (this.indexList.findIndex(item => item["FENCHASENUM.LT"] === this.searchValue && item.smzt ==
- // 1) >= 0) {
- // uni.showModal({
- // // title: '提示',
- // content: "条码:" + vm.searchValue + '已扫描',
- // showCancel: false,
- // success: function(res) {
- // if (res.confirm) {
- // vm.focusPoint()
- // vm.searchValue = ''
- // return
- // } else {
- // // 执行取消后的操作
- // }
- // }
- // })
- // playVoice(audioUrls.failVoiceUrl)
- // return
- // }
- //条码存在未扫描
- // let nowlocation = null; //该条码的仓位
- // let nowindex = null; //该条码的索引
- // for (let i = 0; i < this.indexList.length; i++) { //获取查询装箱单号对应仓位,并切换当前仓位
- // if (this.indexList[i]["FEnchaseNum.LT"] === this.searchValue) {
- // // nowlocation = this.indexList[i]["FStockLocId.FF102029.fname"] //当前仓位
- // nowindex = i //当前索引
- // // this.balance = this.indexList[i]["quantity"] - this.indexList[i]["rowCount"]
- // break;
- // }
- // }
- //不是首次扫描
- // if (this.indexListLength != 0) { //已有操作,计算上次操作的仓位未扫描数
- // let UnscannedNumber = this.indexList.filter(item =>
- // item["FStockLocId.FF102029.fname"] == this.Location && item['smzt'] != 1
- // ).length
- // if (nowlocation != this.Location && UnscannedNumber != 0) { //仓位不一致
- // playVoice(audioUrls.warningSuccessUrl)
- // uni.showModal({
- // title: "提示",
- // content: "是否切换仓位",
- // showCancel: true,
- // success: function(res) {
- // if (res.confirm) {
- // vm.handleScanSuccess(nowindex)
- // } else {
- // // 执行取消后的操作
- // vm.$nextTick(() => {
- // vm.searchValue = ''
- // vm.isFocus = true;
- // })
- // }
- // }
- // })
- // return
- // } else { //仓位一致或原仓位已扫完,正常扫描,无切换
- // this.handleScanSuccess(nowindex)
- // }
- // } else { //首次扫描
- // this.handleScanSuccess(nowindex)
- // }
- this.handleScanSuccess()
- },
- handleResponse(res) {
- // 关闭加载提示
- modal.closeLoading();
- // 检查响应是否为空
- if (res.length === 0) {
- modal.msg("请确认装箱单号有效!");
- playVoice(audioUrls.failVoiceUrl);
- return;
- }
- console.log(res)
- // 处理数据去重并更新状态
- // this.updateBillList(res);
- },
- getHeightStyle() {
- return 'height:' + this.listHeight + 'px';
- },
- getStyle(smzt) {
- return smzt ? 'background-color: Navy;color:white' : '';
- // return 'scrollItem-' + index === this.scrollItem ? 'background-color: blue;color:white' : '';
- },
- }
- };
- </script>
- <style lang="scss">
- .button-group {
- display: flex;
- justify-content: flex-start;
- /* 主轴上左对齐 */
- align-items: center;
- /* 垂直居中对齐 */
- }
- .button-group button {
- white-space: nowrap;
- /* 禁止换行 */
- // margin-right: 10px;
- }
- .button-item {
- flex: 1;
- text-align: center;
- padding: 10px;
- font-size: 16px;
- background-color: #eee;
- }
- /* 容器样式 */
- .table-container {
- width: 100%;
- // overflow: hidden;
- /* 添加滚动条 */
- }
- /* 表头样式 */
- .table-header {
- // background-color: #f0f0f0;
- font-weight: bold;
- display: flex;
- }
- /* 表行样式 */
- .table-row {
- display: flex;
- flex-direction: row;
- /* 水平布局 */
- // border-top: 1px solid #ccc;
- }
- /* 表内容样式 */
- .table-content {
- width: 100%;
- overflow: auto;
- }
- /* 单元格样式 */
- .table-cell1 {
- min-width: 85px;
- /* 设置最小宽度 */
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 5px;
- border: 0.5px solid #ccc;
- // text-align: center;
- }
- /* 单元格样式 */
- .table-cell2 {
- min-width: 90px;
- /* 设置最小宽度 */
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 5px;
- border: 0.5px solid #ccc;
- // text-align: center;
- }
- /* 单元格样式 */
- .table-cell3 {
- min-width: 100px;
- /* 设置最小宽度 */
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 5px;
- border: 0.5px solid #ccc;
- // text-align: center;
- }
- /* 单元格样式 */
- .table-cell4 {
- min-width: 85px;
- /* 设置最小宽度 */
- flex: 1;
- padding: 8px;
- border: 0.5px solid #ccc;
- text-align: center;
- }
- /* 单元格样式 */
- .table-cell {
- min-width: 80px;
- padding: 5px;
- display: flex;
- justify-content: center;
- align-items: center;
- border: 0.5px solid #ccc;
- // text-align: center;
- }
- /* 单元格样式 */
- .table-cellph {
- min-width: 310px;
- display: flex;
- justify-content: center;
- align-items: center;
- border: 0.5px solid #ccc;
- }
- /* 单元格样式 */
- .table-cellwl {
- min-width: 150px;
- /* 设置最小宽度 */
- display: flex;
- justify-content: center;
- align-items: center;
- border: 0.5px solid #ccc;
- // text-align: center;
- }
- /* 最后一个单元格去掉右边框 */
- .table-cell:last-child {
- // border-right: none;
- }
- .example {
- padding: 15px;
- background-color: #fff;
- }
- .form-item {
- display: flex;
- align-items: center;
- }
- .sticky-box {
- /* #ifndef APP-PLUS-NVUE */
- // display: flex;
- position: -webkit-sticky;
- /* #endif */
- position: sticky;
- top: var(--window-top);
- z-index: 99;
- flex-direction: row;
- margin: 0px;
- // padding: 15px 0 15px 0;
- background-color: #F4F5F6;
- // border-bottom-style: solid;
- // border-bottom-color: #E2E2E2;
- }
- .button {
- border-color: #e5e5e5;
- border-style: solid;
- border-width: 1px;
- padding: 4px 8px;
- border-radius: 4px;
- }
- .card-bottom {
- touch-action: none;
- // height: 60px;
- position: fixed;
- bottom: 0;
- width: 100%;
- z-index: 999;
- background-color: white;
- border-top: 1px;
- display: flex;
- flex-direction: column;
- }
- .text {
- font-size: 12px;
- color: #666;
- margin-top: 5px;
- }
- .button {
- margin-bottom: 10px;
- }
- .segmented-control {
- margin-bottom: 15px;
- }
- // .button-group {
- // margin-top: 15px;
- // display: flex;
- // justify-content: space-around;
- // }
- .form-item {
- display: flex;
- align-items: center;
- }
- .button {
- display: flex;
- align-items: center;
- height: 35px;
- margin-left: 10px;
- }
- </style>
- <style lang="scss">
- .u-page {
- padding: 0;
- }
- .u-demo-block__title {
- padding: 10px 0 2px 15px;
- }
- .swipe-action {
- &__content {
- padding: 25rpx 0;
- display: flex;
- flex-direction: column; //设置布局方向为竖直
- &__text {
- font-size: 15px;
- color: $u-main-color;
- padding-left: 30rpx;
- }
- }
- }
- .u-swipe-action-item {
- touch-action: none;
- }
- .red {
- color: red;
- }
- .label-picker-container {
- display: flex;
- align-items: center;
- /* 垂直居中对齐 */
- font-size: 12px;
- /* 设置标签的字体大小 */
- }
- </style>
|