123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179 |
- <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">
- <!-- <scroll-view scroll-x="true" class="scroll-view-header"> -->
- <view class="table-header">
- <view class="table-cell">操作</view>
- <view class="table-cell">扫描状态</view>
- <view class="table-cell">仓位名称</view>
- <view class="table-cellwl">物料编码</view>
- <view class="table-cell1">箱号</view>
- <view class="table-cell1">实际作业数量</view>
- <view class="table-cell1">即时库存数量</view>
- <view class="table-cell1">装箱单号</view>
- <view class="table-cell">面料订单号</view>
- <view class="table-cell">等级</view>
- <view class="table-cellph">批号</view>
- <view class="table-cell2" v-if="showWorkCenter">工作中心</view>
- <view class="table-cell" v-if="showRemark">备注</view>
- <view class="table-cell3">单据编号</view>
- <view class="table-cell">仓位原件数</view>
- <view class="table-cell">发货件数</view>
- <view class="table-cell">剩余件数</view>
- <view class="table-cell">日期</view>
- <view class="table-cell" v-if="showApplicant">作业申请人</view>
- <view class="table-cell">仓管员</view>
- </view>
- <!-- </scroll-view> -->
- <!-- <scroll-view class="table-content" :style="{'height': clientHeight + 'px'}" scroll-x scroll-y
- :scroll-into-view="scrollItem"> -->
- <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-cell">{{ item["FStockLocId.FF102029.fname"] }}</view>
- <view class="table-cellwl" :style="getStyle(item.smzt)">{{ item["FMaterialId.fnumber"] }}</view>
- <view class="table-cell1" :style="getStyle(item.smzt)">{{ item["FBOXNO.LT"] }}</view>
- <!-- <view class="table-cell1" :style="getStyle(item.smzt)"
- v-if="formId === 'LT_PRD_PMCWorkBench'||formId === 'SP_PickMtrl'">{{ item["FActualQty"] }}
- </view>
- <view class="table-cell1" :style="getStyle(item.smzt)" v-else-if="formId === 'STK_MisDelivery'">
- {{ item["FQty"] }}
- </view>
- <view class="table-cell1" :style="getStyle(item.smzt)" v-else-if="formId === 'PUR_MRB'">
- {{ item["FRMREALQTY"] }}
- </view>
- <view class="table-cell1" :style="getStyle(item.smzt)" v-else>{{ item["FQty"] }}</view> -->
- <view class="table-cell1" :style="getStyle(item.smzt)">
- {{ getActualWorkQuantity(item) }}
- </view>
- <view class="table-cell1" :style="getStyle(item.smzt)">{{ item["FInventoryQty"] }}</view>
- <view class="table-cell1" :style="getStyle(item.smzt)">{{ item["FENCHASENUM.LT"] }}</view>
- <view class="table-cell" :style="getStyle(item.smzt)">
- {{ getFabricOrderNo(item) }}
- </view>
- <view class="table-cell" :style="getStyle(item.smzt)">{{ item["FAuxPropId.FF101501.FDATAVALUE"] }}
- </view>
- <view class="table-cellph" :style="getStyle(item.smzt)">{{ item["Flot.FNumber"] }}</view>
- <view class="table-cell2" :style="getStyle(item.smzt)" v-if="showWorkCenter">
- {{ getWorkCenterName(item) }}
- </view>
- <!-- <view class="table-cell2" :style="getStyle(item.smzt)" v-if="formId === 'LT_PRD_PMCWorkBench'">
- {{ item["FEWorkCenterId.LT.fname"] }}
- </view>
- <view class="table-cell2" :style="getStyle(item.smzt)" v-else-if="formId === 'STK_MisDelivery'">
- {{ item["FWorkCenterId.fname"] }}
- </view>
- <view class="table-cell2" :style="getStyle(item.smzt)" v-else-if="formId === 'SP_PickMtrl'">
- {{ item["FWorkCenterId.fname"] }}
- </view> -->
- <view class="table-cell" :style="getStyle(item.smzt)" v-if="showRemark">
- {{ item["FEntrtyMemo"] }}
- </view>
- <view class="table-cell3" :style="getStyle(item.smzt)">{{ item["FBillNo"] }}</view>
- <view class="table-cell" :style="getStyle(item.smzt)">{{ item["quantity"] }}</view>
- <view class="table-cell" :style="getStyle(item.smzt)">{{ item["rowCount"] }}</view>
- <view class="table-cell" :style="getStyle(item.smzt)">{{ item["quantity"]-item["rowCount"] }}
- </view>
- <view class="table-cell" :style="getStyle(item.smzt)">{{ item["FDate"].substring(0, 10) }}</view>
- <view class="table-cell" :style="getStyle(item.smzt)" v-if="showApplicant">
- {{ getApplicantName(item) }}
- </view>
- <!-- <view class="table-cell" :style="getStyle(item.smzt)" v-if="formId === 'LT_PRD_PMCWorkBench'">
- {{ item["FApplicantId.fname"] }}
- </view>
- <view class="table-cell" :style="getStyle(item.smzt)" v-else-if="formId === 'STK_MisDelivery'">
- {{ item["FPickingPeople.LT.fname"] }}
- </view>
- <view class="table-cell" :style="getStyle(item.smzt)" v-else-if="formId === 'SP_PickMtrl'">
- {{ item["FPickerId.fname"] }}
- </view> -->
- <view class="table-cell" :style="getStyle(item.smzt)">{{ item["FSTOCKERID.fname"] }}</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>剩余件数:{{ balance }}</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- audit,
- 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 {
- getAuditParam,
- getSaveParam,
- getSubmitParam
- } from '../../utils/params';
- import submitHelper from '@/utils/commonSubmitHelper.js'; // 确保路径正确
- import {
- executeSql
- } from '../../utils/database';
- import {
- createInventoryQueryRequest
- } from '@/utils/newparams.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: '',
- Location: '', //正操作仓位
- 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 data1 = {
- // "parameters": [{
- // "FormId": "STK_Inventory",
- // "FieldKeys": "fID",
- // "FilterString": [{
- // "Left": "",
- // "FieldName": "FStockLocId.FF102029.FName",
- // "Compare": "67",
- // "Value": data["FStockLocId.FF102029.fname"],
- // "Right": "",
- // "Logic": 0
- // },
- // {
- // "Left": "",
- // "FieldName": "FBaseQty",
- // "Compare": "21",
- // "Value": "0",
- // "Right": "",
- // "Logic": 0
- // }
- // ],
- // }]
- // }
- 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"]
- // if (this.formId === 'LT_PRD_PMCWorkBench' || this.formId === 'SP_PickMtrl') {
- // this.indexList[index]['FActualQty'] = data["FActualQty"]
- // }
- // if (this.formId === 'STK_MisDelivery') {
- // this.indexList[index]['FQty'] = data["FQty"]
- // }
- // if (this.formId === 'PUR_MRB') {
- // this.indexList[index]['FRMREALQTY'] = data["FRMREALQTY"]
- // }
- // 定义一个映射对象
- 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)
- 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 'LT_PRD_PMCWorkBench':
- case 'SP_PickMtrl':
- return item["FActualQty"];
- case 'STK_MisDelivery':
- return item["FQty"];
- case 'PUR_MRB':
- return item["FRMREALQTY"];
- 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 data = {
- // "parameters": [{
- // "FormId": "STK_Inventory",
- // "FieldKeys": "fID",
- // "FilterString": [{
- // "Left": "",
- // "FieldName": "FStockLocId.FF102029.FName",
- // "Compare": "67",
- // "Value": fname,
- // "Right": "",
- // "Logic": 0
- // },
- // {
- // "Left": "",
- // "FieldName": "FBaseQty",
- // "Compare": "21",
- // "Value": "0",
- // "Right": "",
- // "Logic": 0
- // }
- // ],
- // }]
- // };
- 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);
- }
- },
- // // 定义一个函数来创建请求数据
- // createInventoryQueryRequest(value) {
- // return {
- // parameters: [{
- // FormId: "STK_Inventory",
- // FieldKeys: "fID",
- // FilterString: [
- // {
- // Left: "",
- // FieldName: "FStockLocId.FF102029.FName",
- // Compare: "67",
- // Value: value,
- // Right: "",
- // Logic: 0
- // },
- // {
- // Left: "",
- // FieldName: "FBaseQty",
- // Compare: "21",
- // Value: "0",
- // Right: "",
- // Logic: 0
- // }
- // ]
- // }]
- // }
- // },
- 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/stock-dispatch/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;
- }
- uni.navigateTo({
- // url: '/pages/production-replenishment/search', //这是你的当前页面地址
- url: `/pages/stock-dispatch/search?FormId=${this.formId}&FBillType=${this.fbillType}`
- });
- },
- navigateToSummary() {
- uni.navigateTo({
- url: '/pages/stock-dispatch/summary?Info=' + encodeURIComponent(JSON
- .stringify(this.indexList)) + '&&stageInfo=' + encodeURIComponent(JSON
- .stringify(this.stageLists)), //这是你的当前页面地址
- });
- },
- navigateToStage() {
- uni.navigateTo({
- url: '/pages/stock-dispatch/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
- },
- 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)
- 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)
- })
- },
- handleScanSuccess(nowindex) {
- this.Location = this.indexList[nowindex]["FStockLocId.FF102029.fname"]
- this.indexList[nowindex].smzt = 1 //修改数据状态
- console.log(this.indexList.filter(obj => obj.smzt === 1).length)
- this.$forceUpdate()
- const audioUrlsArr = [];
- 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)
- // playVoice(audioUrls.allSuccessVoiceUrl)
- this.showModalAndHandleSubmit(nowindex)
- } else { //单号未全扫完
- // this.handlePositionScanCompletion()
- this.$nextTick(() => {
- this.searchValue = ''
- this.isFocus = true;
- this.scrollToItem("scrollItem-" + nowindex)
- })
- }
- playSequentially(audioUrlsArr);
- },
- 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")) {
- 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)
- }
- },
- 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>
|