From b573cd8198e37487612c7d8a4190c7d4aabc1b97 Mon Sep 17 00:00:00 2001 From: hou <1601990943@qq.com> Date: Sun, 12 Dec 2021 01:06:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E9=80=80=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 14 +- src/i18n/lang/cn.ts | 3 + src/i18n/lang/en.ts | 3 + src/pages.json | 16 + .../warehouse/wholeLnventory/index.vue | 122 ++-- .../product/warehouse/wholeLnventory/model.ts | 15 +- .../ingoods/dnReturnGoods/Local-details.vue | 136 ++++ .../raw/ingoods/dnReturnGoods/Location.vue | 169 ++--- src/pages/raw/ingoods/dnReturnGoods/config.ts | 30 +- src/pages/raw/ingoods/dnReturnGoods/index.vue | 45 +- src/pages/raw/ingoods/dnReturnGoods/model.ts | 44 +- src/plugins/app-update/index.ts | 684 +++++++++++------- src/utils/page.ts | 1 + src/utils/url.ts | 1 + 14 files changed, 765 insertions(+), 518 deletions(-) create mode 100644 src/pages/raw/ingoods/dnReturnGoods/Local-details.vue diff --git a/src/App.vue b/src/App.vue index b50f78a..c997206 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,28 +1,28 @@ diff --git a/src/pages/product/warehouse/wholeLnventory/model.ts b/src/pages/product/warehouse/wholeLnventory/model.ts index 6b861ea..a03b4fc 100644 --- a/src/pages/product/warehouse/wholeLnventory/model.ts +++ b/src/pages/product/warehouse/wholeLnventory/model.ts @@ -30,6 +30,8 @@ export class wholeLnventory extends VuexModule { */ WlList = []; WlListaa = []; + productCode: any = ""; + productDescZh: any = ""; /** * 物料型号类型 */ @@ -97,9 +99,14 @@ export class wholeLnventory extends VuexModule { loginName: session.loginName, }); const WlListaa = res.data; - const WlList = res.data.map((_: any) => ({ - label: _.productCode + "-" + _.locCode, - value: _.locCode, + let arr: any = []; + res.data.forEach((item: any) => { + arr.push(item.locCode); + }); + let newArr = Array.from(new Set(arr)); + const WlList = newArr.map((item: any) => ({ + label: item, + value: item, })); console.log("WlList", WlList); return { WlList, WlListaa }; @@ -133,6 +140,8 @@ export class wholeLnventory extends VuexModule { icon: "none", title: vm.$t("message.Warehouse_Tip9") as any, }); + this.productCode = records.data.productCode; + this.productDescZh = records.data.productDescZh; return { records }; } // if (records.code == 0) { diff --git a/src/pages/raw/ingoods/dnReturnGoods/Local-details.vue b/src/pages/raw/ingoods/dnReturnGoods/Local-details.vue new file mode 100644 index 0000000..0a604a7 --- /dev/null +++ b/src/pages/raw/ingoods/dnReturnGoods/Local-details.vue @@ -0,0 +1,136 @@ + + + diff --git a/src/pages/raw/ingoods/dnReturnGoods/Location.vue b/src/pages/raw/ingoods/dnReturnGoods/Location.vue index 21d0658..3122079 100644 --- a/src/pages/raw/ingoods/dnReturnGoods/Location.vue +++ b/src/pages/raw/ingoods/dnReturnGoods/Location.vue @@ -15,7 +15,7 @@ enable-check="single" show-left-and-right-border :headers="headers" - :contents="model.orderInInfoList" + :contents="model.dnReturnList" :show-vert-border="false" @onCheck="handleRow" > @@ -24,15 +24,15 @@ {{ $t("message.Pi_Station") }}:{{ $t("message.return_Type") }}: - {{ some.sendSpot }} + {{ some.poType }} {{ $t("message.po_ReturnGoodsQuantity") }}: - {{ some.totalMoAmount }} + {{ some.poAmount }} @@ -144,7 +144,6 @@ export default class RawReceiptDetail extends BasePage { LocationList: any = []; //库位 Location: any = []; - someIndex: number = 0; some: any = {}; qty: any = ""; /** @@ -177,14 +176,35 @@ export default class RawReceiptDetail extends BasePage { * 表头 */ headers = headers; + //页面初始化 + async onReady() { + let means: any = JSON.parse( + localStorage.getItem("__GWMS_APP_STATE_DATA__") as any + ); + let user: any = session.user; + let content = { + loginName: means.session.user.loginName, + factoryCode: means.session.user.factoryCode, + workArea: user.list[0].workareaCode, + }; + let res: any = await this.model.queryByFactory(content); + res.forEach((item: any) => { + let pickerName: any = {}; + pickerName.label = item.locationCode; + pickerName.value = item.locationCode + "(" + item.sendSpot + ")"; + pickerName.sendSpot = item.sendSpot; + this.Location.push(pickerName); + }); + } + //选择库位触发事件 LocationChoice(e: any) { - console.log("e>>>>>>>>>>>>>>>>>>>>>>>>", e); this.wlCode = e.pickerName; } + //表格单选触发事件 handleRow({ data }: any) { - this.someIndex = data[0].index; this.some = data[0].lineData; } + //添加触发事件 Add() { if (this.qty == "" || this.wlCode == "") { uni.showToast({ @@ -200,38 +220,12 @@ export default class RawReceiptDetail extends BasePage { }); return; } - // if ( - // parseFloat(this.qty) > model.orderInInfoList[this.someIndex].receiptAmount - // ) { - // uni.showToast({ - // icon: "none", - // title: "不能大于需求数量,请重新输入" as any, - // }); - // return; - // } - let num = parseFloat(this.qty); - this.LocationList.forEach((item: any) => { - num += parseFloat(item.qty); - }); - console.log(num); - // if (num > this.model.orderInInfoList[this.someIndex].receiptAmount) { - // uni.showToast({ - // icon: "none", - // title: "不能大于需求数量,请重新输入" as any, - // }); - // return; - // } - let isTrue: boolean = true; - if (this.LocationList.length != 0) { - this.LocationList.forEach((item: any) => { - if (this.wlCode.sendSpot != item.Code) { - uni.showToast({ - icon: "none", - title: this.$t("message.Commission_tips7") as any, - }); - return (isTrue = false); - } + if (parseFloat(this.qty) > parseFloat(this.some.poAmount)) { + uni.showToast({ + icon: "none", + title: this.$t("message.quantitys") as any, }); + return; } if (this.some == {}) { uni.showToast({ @@ -240,79 +234,50 @@ export default class RawReceiptDetail extends BasePage { }); return; } - if ((isTrue = true)) { - let arr = { - wlCode: this.wlCode.label, - qty: this.qty, - Code: this.wlCode.sendSpot, - }; - this.LocationList.push(arr); - let objString = JSON.stringify(this.some); - let TEM = JSON.parse(objString); - TEM.wlList = null; - TEM.wlCode = this.wlCode.label; - TEM.requestAmount = this.qty; - // this.model.orderInInfoList[this.someIndex].wlQTyList.push(TEM); - // this.model.orderInInfoList[this.someIndex].receiptAmount += parseFloat( - // this.qty - // ); - console.log( - "this.model.orderInInfoList", - this.model.orderInInfoList[this.someIndex] - ); - this.qty = ""; - } - } - deleteItem(index: any) { - this.LocationList.splice(index, 1); - // this.model.orderInInfoList[this.someIndex].wlQTyList.splice(index, 1); - this.business(); - } - business() { - let num: number = 0; + let num: number = parseFloat(this.qty); this.LocationList.forEach((item: any) => { num += parseFloat(item.qty); }); - // this.model.orderInInfoList[this.someIndex].receiptAmount = num; - console.log( - "this.model.orderInInfoList", - this.model.orderInInfoList[this.someIndex] - ); - } - async onShow() { - //页面初始化 获取可选库位 - let means: any = JSON.parse( - localStorage.getItem("__GWMS_APP_STATE_DATA__") as any - ); - let user: any = session.user; - let sendSpot = JSON.parse(localStorage.getItem("sendSpot") as any); - let content = { - loginName: means.session.user.loginName, - sendSpot: sendSpot, - factoryCode: means.session.user.factoryCode, - workArea: user.list[0].workareaCode, + if (num > parseFloat(this.some.poAmount)) { + uni.showToast({ + icon: "none", + title: this.$t("message.dn_Tip2") as any, + }); + return; + } + let arr = { + wlCode: this.wlCode.label, + qty: this.qty, + Code: this.wlCode.sendSpot, }; - let res: any = await this.model.queryByFactoryCodeAndWorkAreaCode(content); - res.forEach((item: any) => { - let pickerName: any = {}; - pickerName.label = item.locationCode; - pickerName.value = item.locationCode + "(" + item.sendSpot + ")"; - pickerName.sendSpot = item.sendSpot; - this.Location.push(pickerName); - }); - this.model.orderInInfoList.forEach((item: any) => { - item.receiptAmount = 0; - item.wlQTyList = []; - }); - console.log("this.model.orderInInfoList", this.model.orderInInfoList); + this.LocationList.push(arr); + let TEM = { + wlCode: this.wlCode.label, + nowAmount: this.qty, + }; + this.some.list.push(TEM); + this.qty = ""; + } + //删除某一项 触发事件 + deleteItem(index: any) { + this.LocationList.splice(index, 1); + this.some.list.splice(index, 1); + } + appoint() { + this.redirectTo(this.page.raw.ingoods.dnReturnGoods.Local); } - appoint() {} - /** * 提交 */ async onSubmit() { - await this.model.submitOrderInEnter(); + await this.model.submit({ + poNo: this.some.poNo, + loginName: session.loginName, + factoryCode: session.factoryCode, + materialCode: this.some.materialCode, + poLine: this.some.poLine, + list: this.some.list, + }); } } diff --git a/src/pages/raw/ingoods/dnReturnGoods/config.ts b/src/pages/raw/ingoods/dnReturnGoods/config.ts index b607f13..73f890c 100644 --- a/src/pages/raw/ingoods/dnReturnGoods/config.ts +++ b/src/pages/raw/ingoods/dnReturnGoods/config.ts @@ -1,31 +1,35 @@ /** * 看单明细表格列 */ -import vm from '@/main'; +import vm from "@/main"; export const headers = [ { - label: vm.$t('message.po_MaterielNo'), - key: 'materialCode', + label: vm.$t("message.po_MaterielNo"), + key: "materialCode", }, { - label: vm.$t('message.po_MaterielDes'), - key: 'materialDesc', + label: vm.$t("message.po_MaterielDes"), + key: "materialDesc", width: 350, }, { - label: vm.$t('message.po_DemandQuantity'), - key: 'receiptAmount', + label: vm.$t("message.returned"), + key: "poAmount", }, { - label: vm.$t('message.po_ReturnGoodsQuantity'), - key: 'returnAmount', + label: vm.$t("message.quantity"), + key: "receiptAmount", }, { - label: vm.$t('message.po_RemainingQuantity'), - key: 'splitAmount', + label: vm.$t("message.po_Supplier"), + key: "supplyCode", }, { - label: vm.$t('message.po_Location'), - key: 'location', + label: vm.$t("message.po_OrderType"), + key: "poType", + }, + { + label: vm.$t("message.po_Location"), + key: "wlCode", }, ]; diff --git a/src/pages/raw/ingoods/dnReturnGoods/index.vue b/src/pages/raw/ingoods/dnReturnGoods/index.vue index f18ddc0..4d2beec 100644 --- a/src/pages/raw/ingoods/dnReturnGoods/index.vue +++ b/src/pages/raw/ingoods/dnReturnGoods/index.vue @@ -19,57 +19,29 @@ - - - + - - - - + - + - - - - - - - - - - - - - @@ -150,7 +122,8 @@ export default class dnReturnGoodsDom extends BasePage { onSubmit() { this.$form.validate((valid: boolean) => { if (!valid) return; - if (!this.model.hasDnInfo) { + console.log(1); + if (this.model.orderInInfo == []) { uni.showToast({ icon: "none", title: this.$t("message.dn_PleaseScan") as string, diff --git a/src/pages/raw/ingoods/dnReturnGoods/model.ts b/src/pages/raw/ingoods/dnReturnGoods/model.ts index 804c463..489b9ce 100644 --- a/src/pages/raw/ingoods/dnReturnGoods/model.ts +++ b/src/pages/raw/ingoods/dnReturnGoods/model.ts @@ -39,10 +39,12 @@ export class ReceiptModule extends VuexModule { * 隐藏看单号 */ dnNo = ""; + dnReturnList = []; /** * 看单号查询结果 */ orderInInfo: OrderInInfo = new OrderInInfo(); + detailedList = []; /** * 看单明细 */ @@ -152,7 +154,24 @@ export class ReceiptModule extends VuexModule { console.log("1111111", orderInInfoList); return { dnNo, orderInInfo, orderInInfoList, orderInInfoListEx }; } - + @MutationAction + async queryOrder(poNo: string) { + const res: any = await http.post(url.material.DNorderin.queryOrder, { + poNo, + factoryCode: session.factoryCode, + loginName: session.loginName, + }); + const orderInInfoListEx = res.data.filter( + (_: OrderInInfo) => _.userDefined10 === "0" + ); + let dnReturnList = res.data; + dnReturnList.forEach((item: any) => { + item.list = []; + }); + const orderInInfo: any = res.data[0] || {}; + console.log("orderInInfo", orderInInfo); + return { orderInInfo, orderInInfoListEx, dnReturnList }; + } /** * 提交看单明细 */ @@ -203,6 +222,29 @@ export class ReceiptModule extends VuexModule { ); return res; } + @Action({ commit: "updateCheckedOrderInInfoListKw" }) + async queryByFactory(content: any) { + let res = await http.post( + "/wmspda/fg/queryByFactoryCodeAndWorkAreaCode", + content + ); + return res; + } + @Action({ commit: "updateCheckedOrderInInfoListKw" }) + async submit(content: any) { + let res = await http.post( + "/material/outsourcing/into/materialComplete", + content + ); + return res; + } + @Action({ commit: "updateCheckedOrderInInfoListKw" }) + async querydetaildlist(content: any) { + let res = await http.post("/material/outsourcing/into/info", content); + let detailedList = res.data; + console.log(res); + return { detailedList }; + } } export default getModule(ReceiptModule); diff --git a/src/plugins/app-update/index.ts b/src/plugins/app-update/index.ts index ea1ce04..15fa1c5 100644 --- a/src/plugins/app-update/index.ts +++ b/src/plugins/app-update/index.ts @@ -2,14 +2,17 @@ /**** 此文件说明请看注释 *****/ // 可以用自己项目的请求方法 // 请求配置说明:https://ext.dcloud.net.cn/plugin?id=822 -import $http from '@/utils/request'; +import $http from "@/utils/request"; +import { any } from "lodash/fp"; +import http from "@/utils/request"; +import { url } from "@/utils/url"; /**** 结束 *****/ const platform = uni.getSystemInfoSync().platform; // 主颜色 -const $mainColor = 'FF5B78'; +const $mainColor = "FF5B78"; // 弹窗图标url -const $iconUrl = '/static/icon/ic_ar.png'; +const $iconUrl = "/static/icon/ic_ar.png"; const PlusNativeObjView = plus.nativeObj.View as any; @@ -25,12 +28,16 @@ export const getCurrentNo = function (callback: (params: any) => void): void { }); }; // 发起ajax请求获取服务端版本号 -const getServerNo = function (version: any, isPrompt = false, callback: (params: any) => void) { +const getServerNo = function ( + version: any, + isPrompt = false, + callback: (params: any) => void +) { const httpData: any = { version: version.versionCode, versionName: version.versionName, }; - if (platform == 'android') { + if (platform == "android") { httpData.type = 1101; } else { httpData.type = 1102; @@ -92,65 +99,71 @@ const getDownload = function (data: any) { const dtask = plus.downloader.createDownload( data.downloadUrl, { - filename: '_downloads/', + filename: "_downloads/", }, function (download, status) { if (status == 200) { popupObj.change({ progressValue: 100, - progressTip: '正在安装文件...', + progressTip: "正在安装文件...", progress: true, buttonNum: 0, }); plus.runtime.install( - download.filename as '_www/' | '_doc/' | '_documents/' | '_downloads/', + download.filename as + | "_www/" + | "_doc/" + | "_documents/" + | "_downloads/", {}, function () { popupObj.change({ - contentText: '应用资源更新完成!', + contentText: "应用资源更新完成!", buttonNum: 1, progress: false, }); }, function (e) { popupObj.cancel(); - plus.nativeUI.alert('安装文件失败[' + e.code + ']:' + e.message); - }, + plus.nativeUI.alert("安装文件失败[" + e.code + "]:" + e.message); + } ); } else { popupObj.change({ - contentText: '文件下载失败...', + contentText: "文件下载失败...", buttonNum: 1, progress: false, }); } - }, + } ); dtask.start(); - dtask.addEventListener('statechanged', function (task, status) { + dtask.addEventListener("statechanged", function (task, status) { switch (task.state) { case 1: // 开始 popupObj.change({ progressValue: 0, - progressTip: '准备下载...', + progressTip: "准备下载...", progress: true, }); break; case 2: // 已连接到服务器 popupObj.change({ progressValue: 0, - progressTip: '开始下载...', + progressTip: "开始下载...", progress: true, }); break; case 3: // eslint-disable-next-line - const progress = parseInt(String(((task.downloadedSize || 0) / (task.totalSize || 1)) * 100)); + const progress = parseInt( + String(((task.downloadedSize || 0) / (task.totalSize || 1)) * 100) + ); if (progress - lastProgressValue >= 2) { lastProgressValue = progress; popupObj.change({ progressValue: progress, - progressTip: '已下载' + progress + '%', + progressTip: "已下载" + progress + "%", progress: true, }); } @@ -161,8 +174,8 @@ const getDownload = function (data: any) { popupObj.cancelDownload = function () { dtask && dtask.abort(); uni.showToast({ - title: '已取消下载', - icon: 'none', + title: "已取消下载", + icon: "none", }); }; // 重启APP @@ -172,7 +185,7 @@ const getDownload = function (data: any) { }; // 文字换行 function drawtext(text: string, maxWidth: number) { - const textArr = text.split(''); + const textArr = text.split(""); const len = textArr.length; // 上个节点 let previousNode = 0; @@ -191,7 +204,7 @@ function drawtext(text: string, maxWidth: number) { if (letterWidth > 0) { if (nodeWidth + chineseWidth + letterWidth * otherWidth > maxWidth) { rowText.push({ - type: 'text', + type: "text", content: text.substring(previousNode, i), }); previousNode = i; @@ -204,7 +217,7 @@ function drawtext(text: string, maxWidth: number) { } else { if (nodeWidth + chineseWidth > maxWidth) { rowText.push({ - type: 'text', + type: "text", content: text.substring(previousNode, i), }); previousNode = i; @@ -216,15 +229,15 @@ function drawtext(text: string, maxWidth: number) { } else { if (/\n/g.test(textArr[i])) { rowText.push({ - type: 'break', + type: "break", content: text.substring(previousNode, i), }); previousNode = i + 1; nodeWidth = 0; letterWidth = 0; - } else if (textArr[i] == '\\' && textArr[i + 1] == 'n') { + } else if (textArr[i] == "\\" && textArr[i + 1] == "n") { rowText.push({ - type: 'break', + type: "break", content: text.substring(previousNode, i), }); previousNode = i + 2; @@ -234,7 +247,7 @@ function drawtext(text: string, maxWidth: number) { letterWidth += 1; if (nodeWidth + letterWidth * otherWidth > maxWidth) { rowText.push({ - type: 'text', + type: "text", content: text.substring(previousNode, i + 1 - letterWidth), }); previousNode = i + 1 - letterWidth; @@ -244,7 +257,7 @@ function drawtext(text: string, maxWidth: number) { } else { if (nodeWidth + otherWidth > maxWidth) { rowText.push({ - type: 'text', + type: "text", content: text.substring(previousNode, i), }); previousNode = i; @@ -257,7 +270,7 @@ function drawtext(text: string, maxWidth: number) { } if (previousNode < len) { rowText.push({ - type: 'text', + type: "text", content: text.substring(previousNode, len), }); } @@ -266,13 +279,13 @@ function drawtext(text: string, maxWidth: number) { // 是否更新弹窗 function updatePopup(data: any, callback: () => any) { // 弹窗遮罩层 - const maskLayer = new PlusNativeObjView('maskLayer', { + const maskLayer = new PlusNativeObjView("maskLayer", { //先创建遮罩层 - top: '0px', - left: '0px', - height: '100%', - width: '100%', - backgroundColor: 'rgba(0,0,0,0.5)', + top: "0px", + left: "0px", + height: "100%", + width: "100%", + backgroundColor: "rgba(0,0,0,0.5)", }); // 以下为计算菜单的nview绘制布局,为固定算法,使用者无关关心 @@ -291,30 +304,30 @@ function updatePopup(data: any, callback: () => any) { const popupViewContentList: any[] = [ { src: $iconUrl, - id: 'logo', - tag: 'img', + id: "logo", + tag: "img", position: { - top: '0px', - left: (popupViewWidth - 124) / 2 + 'px', - width: '124px', - height: '80px', + top: "0px", + left: (popupViewWidth - 124) / 2 + "px", + width: "124px", + height: "80px", }, }, { - tag: 'font', - id: 'title', - text: '发现新版本' + data.versionName, + tag: "font", + id: "title", + text: "发现新版本" + data.versionName, textStyles: { - size: '18px', - color: '#333', - weight: 'bold', - whiteSpace: 'normal', + size: "18px", + color: "#333", + weight: "bold", + whiteSpace: "normal", }, position: { - top: '90px', - left: viewContentPadding + 'px', - width: viewContentWidth + 'px', - height: '30px', + top: "90px", + left: viewContentPadding + "px", + width: viewContentWidth + "px", + height: "30px", }, }, ]; @@ -326,110 +339,116 @@ function updatePopup(data: any, callback: () => any) { contentTop += textHeight; } popupViewContentList.push({ - tag: 'font', - id: 'content' + index + 1, + tag: "font", + id: "content" + index + 1, text: item.content, textStyles: { - size: '14px', - color: '#666', - lineSpacing: '50%', - align: 'left', + size: "14px", + color: "#666", + lineSpacing: "50%", + align: "left", }, position: { - top: contentTop + 'px', - left: viewContentPadding + 'px', - width: viewContentWidth + 'px', - height: textHeight + 'px', + top: contentTop + "px", + left: viewContentPadding + "px", + width: viewContentWidth + "px", + height: textHeight + "px", }, }); - if (item.type == 'break') { + if (item.type == "break") { contentTop += 10; popupViewHeight += 10; } }); // 弹窗内容 - const popupView = new PlusNativeObjView('popupView', { + const popupView = new PlusNativeObjView("popupView", { //创建底部图标菜单 - tag: 'rect', - top: (screenHeight - popupViewHeight) / 2 + 'px', - left: '15%', - height: popupViewHeight + 'px', - width: '70%', + tag: "rect", + top: (screenHeight - popupViewHeight) / 2 + "px", + left: "15%", + height: popupViewHeight + "px", + width: "70%", }); // 绘制白色背景 popupView.drawRect( { - color: '#FFFFFF', - radius: '8px', + color: "#FFFFFF", + radius: "8px", }, { - top: '40px', - height: popupViewHeight - 40 + 'px', - }, + top: "40px", + height: popupViewHeight - 40 + "px", + } ); // 绘制底边按钮 popupView.drawRect( { - radius: '3px', - borderColor: '#f1f1f1', - borderWidth: '1px', + radius: "3px", + borderColor: "#f1f1f1", + borderWidth: "1px", }, { - bottom: viewContentPadding + 'px', - left: viewContentPadding + 'px', - width: (viewContentWidth - viewContentPadding) / 2 + 'px', - height: '30px', - }, + bottom: viewContentPadding + "px", + left: viewContentPadding + "px", + width: (viewContentWidth - viewContentPadding) / 2 + "px", + height: "30px", + } ); // 绘制底边按钮 popupView.drawRect( { - radius: '3px', + radius: "3px", color: $mainColor, }, { - bottom: viewContentPadding + 'px', - left: (viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2 + 'px', - width: (viewContentWidth - viewContentPadding) / 2 + 'px', - height: '30px', - }, + bottom: viewContentPadding + "px", + left: + (viewContentWidth - viewContentPadding) / 2 + + viewContentPadding * 2 + + "px", + width: (viewContentWidth - viewContentPadding) / 2 + "px", + height: "30px", + } ); popupViewContentList.push({ - tag: 'font', - id: 'cancelText', - text: '暂不升级', + tag: "font", + id: "cancelText", + text: "暂不升级", textStyles: { - size: '14px', - color: '#666', - lineSpacing: '0%', - whiteSpace: 'normal', + size: "14px", + color: "#666", + lineSpacing: "0%", + whiteSpace: "normal", }, position: { - bottom: viewContentPadding + 'px', - left: viewContentPadding + 'px', - width: (viewContentWidth - viewContentPadding) / 2 + 'px', - height: '30px', + bottom: viewContentPadding + "px", + left: viewContentPadding + "px", + width: (viewContentWidth - viewContentPadding) / 2 + "px", + height: "30px", }, }); popupViewContentList.push({ - tag: 'font', - id: 'confirmText', - text: '立即升级', + tag: "font", + id: "confirmText", + text: "立即升级", textStyles: { - size: '14px', - color: '#FFF', - lineSpacing: '0%', - whiteSpace: 'normal', + size: "14px", + color: "#FFF", + lineSpacing: "0%", + whiteSpace: "normal", }, position: { - bottom: viewContentPadding + 'px', - left: (viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2 + 'px', - width: (viewContentWidth - viewContentPadding) / 2 + 'px', - height: '30px', + bottom: viewContentPadding + "px", + left: + (viewContentWidth - viewContentPadding) / 2 + + viewContentPadding * 2 + + "px", + width: (viewContentWidth - viewContentPadding) / 2 + "px", + height: "30px", }, }); popupView.draw(popupViewContentList); - popupView.addEventListener('click', function (e: MouseEvent) { + popupView.addEventListener("click", function (e: MouseEvent) { const maxTop = popupViewHeight - viewContentPadding; const maxLeft = popupViewWidth - viewContentPadding; const buttonWidth = (viewContentWidth - viewContentPadding) / 2; @@ -450,7 +469,7 @@ function updatePopup(data: any, callback: () => any) { } }); // 点击遮罩层 - maskLayer.addEventListener('click', function () { + maskLayer.addEventListener("click", function () { //处理遮罩层点击 maskLayer.hide(); popupView.hide(); @@ -472,45 +491,45 @@ function downloadPopupDrawing(data: any): any { const viewContentWidth = popupViewWidth - viewContentPadding * 2; // 弹窗容器高度 let popupViewHeight = viewContentPadding * 3 + 60; - const progressTip = data.progressTip || '准备下载...'; - const contentText = data.contentText || '正在为您更新,请耐心等待'; + const progressTip = data.progressTip || "准备下载..."; + const contentText = data.contentText || "正在为您更新,请耐心等待"; let elementList: any[] = [ { - tag: 'rect', //背景色 - color: '#FFFFFF', + tag: "rect", //背景色 + color: "#FFFFFF", rectStyles: { - radius: '8px', + radius: "8px", }, }, { - tag: 'font', - id: 'title', - text: '升级APP', + tag: "font", + id: "title", + text: "升级APP", textStyles: { - size: '16px', - color: '#333', - weight: 'bold', - verticalAlign: 'middle', - whiteSpace: 'normal', + size: "16px", + color: "#333", + weight: "bold", + verticalAlign: "middle", + whiteSpace: "normal", }, position: { - top: viewContentPadding + 'px', - height: '30px', + top: viewContentPadding + "px", + height: "30px", }, }, { - tag: 'font', - id: 'content', + tag: "font", + id: "content", text: contentText, textStyles: { - size: '14px', - color: '#333', - verticalAlign: 'middle', - whiteSpace: 'normal', + size: "14px", + color: "#333", + verticalAlign: "middle", + whiteSpace: "normal", }, position: { - top: viewContentPadding * 2 + 30 + 'px', - height: '20px', + top: viewContentPadding * 2 + 30 + "px", + height: "20px", }, }, ]; @@ -519,32 +538,32 @@ function downloadPopupDrawing(data: any): any { popupViewHeight += viewContentPadding + 40; elementList = elementList.concat([ { - tag: 'font', - id: 'progressValue', + tag: "font", + id: "progressValue", text: progressTip, textStyles: { - size: '14px', + size: "14px", color: $mainColor, - whiteSpace: 'normal', + whiteSpace: "normal", }, position: { - top: viewContentPadding * 4 + 20 + 'px', - height: '30px', + top: viewContentPadding * 4 + 20 + "px", + height: "30px", }, }, { - tag: 'rect', //绘制进度条背景 - id: 'progressBg', + tag: "rect", //绘制进度条背景 + id: "progressBg", rectStyles: { - radius: '4px', - borderColor: '#f1f1f1', - borderWidth: '1px', + radius: "4px", + borderColor: "#f1f1f1", + borderWidth: "1px", }, position: { - top: viewContentPadding * 4 + 60 + 'px', - left: viewContentPadding + 'px', - width: viewContentWidth + 'px', - height: '8px', + top: viewContentPadding * 4 + 60 + "px", + left: viewContentPadding + "px", + width: viewContentWidth + "px", + height: "8px", }, }, ]); @@ -553,64 +572,70 @@ function downloadPopupDrawing(data: any): any { popupViewHeight += viewContentPadding + 30; elementList = elementList.concat([ { - tag: 'rect', //绘制底边按钮 + tag: "rect", //绘制底边按钮 rectStyles: { - radius: '3px', - borderColor: '#f1f1f1', - borderWidth: '1px', + radius: "3px", + borderColor: "#f1f1f1", + borderWidth: "1px", }, position: { - bottom: viewContentPadding + 'px', - left: viewContentPadding + 'px', - width: (viewContentWidth - viewContentPadding) / 2 + 'px', - height: '30px', + bottom: viewContentPadding + "px", + left: viewContentPadding + "px", + width: (viewContentWidth - viewContentPadding) / 2 + "px", + height: "30px", }, }, { - tag: 'rect', //绘制底边按钮 + tag: "rect", //绘制底边按钮 rectStyles: { - radius: '3px', + radius: "3px", color: $mainColor, }, position: { - bottom: viewContentPadding + 'px', - left: (viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2 + 'px', - width: (viewContentWidth - viewContentPadding) / 2 + 'px', - height: '30px', + bottom: viewContentPadding + "px", + left: + (viewContentWidth - viewContentPadding) / 2 + + viewContentPadding * 2 + + "px", + width: (viewContentWidth - viewContentPadding) / 2 + "px", + height: "30px", }, }, { - tag: 'font', - id: 'cancelText', - text: '取消下载', + tag: "font", + id: "cancelText", + text: "取消下载", textStyles: { - size: '14px', - color: '#666', - lineSpacing: '0%', - whiteSpace: 'normal', + size: "14px", + color: "#666", + lineSpacing: "0%", + whiteSpace: "normal", }, position: { - bottom: viewContentPadding + 'px', - left: viewContentPadding + 'px', - width: (viewContentWidth - viewContentPadding) / 2 + 'px', - height: '30px', + bottom: viewContentPadding + "px", + left: viewContentPadding + "px", + width: (viewContentWidth - viewContentPadding) / 2 + "px", + height: "30px", }, }, { - tag: 'font', - id: 'confirmText', - text: '后台下载', + tag: "font", + id: "confirmText", + text: "后台下载", textStyles: { - size: '14px', - color: '#FFF', - lineSpacing: '0%', - whiteSpace: 'normal', + size: "14px", + color: "#FFF", + lineSpacing: "0%", + whiteSpace: "normal", }, position: { - bottom: viewContentPadding + 'px', - left: (viewContentWidth - viewContentPadding) / 2 + viewContentPadding * 2 + 'px', - width: (viewContentWidth - viewContentPadding) / 2 + 'px', - height: '30px', + bottom: viewContentPadding + "px", + left: + (viewContentWidth - viewContentPadding) / 2 + + viewContentPadding * 2 + + "px", + width: (viewContentWidth - viewContentPadding) / 2 + "px", + height: "30px", }, }, ]); @@ -619,32 +644,32 @@ function downloadPopupDrawing(data: any): any { popupViewHeight += viewContentPadding + 40; elementList = elementList.concat([ { - tag: 'rect', //绘制底边按钮 + tag: "rect", //绘制底边按钮 rectStyles: { - radius: '6px', + radius: "6px", color: $mainColor, }, position: { - bottom: viewContentPadding + 'px', - left: viewContentPadding + 'px', - width: viewContentWidth + 'px', - height: '40px', + bottom: viewContentPadding + "px", + left: viewContentPadding + "px", + width: viewContentWidth + "px", + height: "40px", }, }, { - tag: 'font', - id: 'confirmText', - text: '关闭', + tag: "font", + id: "confirmText", + text: "关闭", textStyles: { - size: '14px', - color: '#FFF', - lineSpacing: '0%', + size: "14px", + color: "#FFF", + lineSpacing: "0%", }, position: { - bottom: viewContentPadding + 'px', - left: viewContentPadding + 'px', - width: viewContentWidth + 'px', - height: '40px', + bottom: viewContentPadding + "px", + left: viewContentPadding + "px", + width: viewContentWidth + "px", + height: "40px", }, }, ]); @@ -661,23 +686,24 @@ function downloadPopupDrawing(data: any): any { // 文件下载的弹窗 function downloadPopup(data: any) { // 弹窗遮罩层 - const maskLayer = new PlusNativeObjView('maskLayer', { + const maskLayer = new PlusNativeObjView("maskLayer", { //先创建遮罩层 - top: '0px', - left: '0px', - height: '100%', - width: '100%', - backgroundColor: 'rgba(0,0,0,0.5)', + top: "0px", + left: "0px", + height: "100%", + width: "100%", + backgroundColor: "rgba(0,0,0,0.5)", }); let popupViewData = downloadPopupDrawing(data); // 弹窗内容 - const popupView = new PlusNativeObjView('popupView', { + const popupView = new PlusNativeObjView("popupView", { //创建底部图标菜单 - tag: 'rect', - top: (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + 'px', - left: '15%', - height: popupViewData.popupViewHeight + 'px', - width: '70%', + tag: "rect", + top: + (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + "px", + left: "15%", + height: popupViewData.popupViewHeight + "px", + width: "70%", }); let progressValue = 0; let progressTip = 0; @@ -694,51 +720,52 @@ function downloadPopup(data: any) { progressValue = res.progressValue; // 绘制进度条 progressElement.push({ - tag: 'rect', //绘制进度条背景 - id: 'progressValueBg', + tag: "rect", //绘制进度条背景 + id: "progressValueBg", rectStyles: { - radius: '4px', + radius: "4px", color: $mainColor, }, position: { - top: popupViewData.viewContentPadding * 4 + 60 + 'px', - left: popupViewData.viewContentPadding + 'px', - width: popupViewData.viewContentWidth * (res.progressValue / 100) + 'px', - height: '8px', + top: popupViewData.viewContentPadding * 4 + 60 + "px", + left: popupViewData.viewContentPadding + "px", + width: + popupViewData.viewContentWidth * (res.progressValue / 100) + "px", + height: "8px", }, }); } if (res.progressTip) { progressTip = res.progressTip; progressElement.push({ - tag: 'font', - id: 'progressValue', + tag: "font", + id: "progressValue", text: res.progressTip, textStyles: { - size: '14px', + size: "14px", color: $mainColor, - whiteSpace: 'normal', + whiteSpace: "normal", }, position: { - top: popupViewData.viewContentPadding * 4 + 20 + 'px', - height: '30px', + top: popupViewData.viewContentPadding * 4 + 20 + "px", + height: "30px", }, }); } if (res.contentText) { contentText = res.contentText; progressElement.push({ - tag: 'font', - id: 'content', + tag: "font", + id: "content", text: res.contentText, textStyles: { - size: '16px', - color: '#333', - whiteSpace: 'normal', + size: "16px", + color: "#333", + whiteSpace: "normal", }, position: { - top: popupViewData.viewContentPadding * 2 + 30 + 'px', - height: '30px', + top: popupViewData.viewContentPadding * 2 + 30 + "px", + height: "30px", }, }); } @@ -752,8 +779,8 @@ function downloadPopup(data: any) { progressTip: progressTip, contentText: contentText, }, - res, - ), + res + ) ); const newElement: any[] = []; popupViewData.elementList.map((item: any, index: number) => { @@ -769,11 +796,13 @@ function downloadPopup(data: any) { }); progressElement = newElement.concat(progressElement); popupView.setStyle({ - tag: 'rect', - top: (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + 'px', - left: '15%', - height: popupViewData.popupViewHeight + 'px', - width: '70%', + tag: "rect", + top: + (popupViewData.screenHeight - popupViewData.popupViewHeight) / 2 + + "px", + left: "15%", + height: popupViewData.popupViewHeight + "px", + width: "70%", }); popupView.draw(progressElement); } else { @@ -785,20 +814,27 @@ function downloadPopup(data: any) { popupView.hide(); }, }; - popupView.addEventListener('click', function (e: MouseEvent) { - const maxTop = popupViewData.popupViewHeight - popupViewData.viewContentPadding; - const maxLeft = popupViewData.popupViewWidth - popupViewData.viewContentPadding; + popupView.addEventListener("click", function (e: MouseEvent) { + const maxTop = + popupViewData.popupViewHeight - popupViewData.viewContentPadding; + const maxLeft = + popupViewData.popupViewWidth - popupViewData.viewContentPadding; if (e.clientY > maxTop - 40 && e.clientY < maxTop) { if (buttonNum == 1) { // 单按钮 - if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft) { + if ( + e.clientX > popupViewData.viewContentPadding && + e.clientX < maxLeft + ) { maskLayer.hide(); popupView.hide(); callbackData.reboot(); } } else if (buttonNum == 2) { // 双按钮 - const buttonWidth = (popupViewData.viewContentWidth - popupViewData.viewContentPadding) / 2; + const buttonWidth = + (popupViewData.viewContentWidth - popupViewData.viewContentPadding) / + 2; if ( e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft - buttonWidth - popupViewData.viewContentPadding @@ -819,37 +855,131 @@ function downloadPopup(data: any) { // 改变进度条 return callbackData; } -export default function (isPrompt = false) { - getCurrentNo((versionInfo: any) => { - getServerNo(versionInfo, isPrompt, (res: any) => { - if (res.forceUpdate) { - if (/\.wgt$/i.test(res.downloadUrl)) { - getDownload(res); - } else if (/\.html$/i.test(res.downloadUrl)) { - plus.runtime.openURL(res.downloadUrl); - } else { - if (platform == 'android') { - getDownload(res); - } else { - plus.runtime.openURL(res.downloadUrl); - } - } - } else { - updatePopup(res, function () { - if (/\.wgt$/i.test(res.downloadUrl)) { - getDownload(res); - } else if (/\.html$/i.test(res.downloadUrl)) { - plus.runtime.openURL(res.downloadUrl); - } else { - if (platform == 'android') { - getDownload(res); - } else { - plus.runtime.openURL(res.downloadUrl); - } - } - }); - } +// export default function (isPrompt = false) { +// console.log(1); +// getCurrentNo((versionInfo: any) => { +// getServerNo(versionInfo, isPrompt, (res: any) => { +// if (res.forceUpdate) { +// if (/\.wgt$/i.test(res.downloadUrl)) { +// getDownload(res); +// } else if (/\.html$/i.test(res.downloadUrl)) { +// plus.runtime.openURL(res.downloadUrl); +// } else { +// if (platform == "android") { +// getDownload(res); +// } else { +// plus.runtime.openURL(res.downloadUrl); +// } +// } +// } else { +// updatePopup(res, function () { +// if (/\.wgt$/i.test(res.downloadUrl)) { +// getDownload(res); +// } else if (/\.html$/i.test(res.downloadUrl)) { +// plus.runtime.openURL(res.downloadUrl); +// } else { +// if (platform == "android") { +// getDownload(res); +// } else { +// plus.runtime.openURL(res.downloadUrl); +// } +// } +// }); +// } +// }); +// }); +// } +export default async function checkUpdateVersion() { + //锁定屏幕方向 + console.log(1); + plus.screen.lockOrientation("portrait-primary"); //锁定屏幕方向 竖屏正方向 + try { + //发送ajax 获取版本更新 + let { + data: { data, code, flag, message }, + } = await http.post(url.menu, { + data: { + versionCode: uni.getStorageSync("versionCode"), //从本地缓存中同步获取指定 key 对应的内容 + }, }); - }); + if (code === 20000) { + uni.showModal({ + title: "温馨提示", + content: `有新的版本可下载${data.versionCode}是否下载?`, + success: (res) => { + if (res.confirm) { + console.log(res.confirm); + //判断手机类型 + // 也可以用5+app的方法:plus.os.name.toLowerCase() == 'ios' + if (uni.getSystemInfoSync().platform === "ios") { + plus.runtime.openURL(data.updateUrl); + } else { + //新建下载任务 + var downloadTask = plus.downloader.createDownload( + data.updateUrl, + {}, + (download, status) => { + if (status === 200) { + //安装APK文件 + plus.runtime.install( + download.filename as any, + {}, + function (error) { + uni.showModal({ + content: "安装失败", + }); + } + ); + } else { + uni.showModal({ + title: "更新失败!!!", + }); + } + } + ); + try { + // 开始下载 + downloadTask.start(); + //监听下载 + // var that = this; + var showLoading = plus.nativeUI.showWaiting("正在下载"); + downloadTask.addEventListener( + "statechanged", + function (download, status) { + switch (download.state) { + case 1: + uni.showToast({ + title: "下载中", + }); + break; + case 2: + break; + case 3: + plus.nativeUI.closeWaiting(); + } + } + ); + } catch (err) { + plus.nativeUI.closeWaiting(); + uni.showModal({ + content: "下载失败,请稍后重试", + }); + } + } + //检验过一次版本就加入缓存,不再检测 + uni.setStorageSync("isCheckVersion", true); + } + }, + }); + } else { + uni.showModal({ + content: message, + }); + } + } catch (e) { + uni.showModal({ + content: "获取数据失败", + }); + } } // #endif diff --git a/src/utils/page.ts b/src/utils/page.ts index 2b63705..f453cd9 100644 --- a/src/utils/page.ts +++ b/src/utils/page.ts @@ -129,6 +129,7 @@ export const page = { index: "/pages/raw/ingoods/dnReturnGoods/index", detail: "/pages/raw/ingoods/dnReturnGoods/detail", location: "/pages/raw/ingoods/dnReturnGoods/Location", + Local: "/pages/raw/ingoods/dnReturnGoods/Local-details", detailEx: "/pages/raw/ingoods/dnReturnGoods/detail-ex", idetailed: "/pages/raw/ingoods/dnReturnGoods/idetailed", }, diff --git a/src/utils/url.ts b/src/utils/url.ts index 80e1723..ae837a9 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -63,6 +63,7 @@ export const url = { info: "/wmspda/material/orderin/dnInfo", ImportInfo: "/wmspda/material/orderin/overseasDnInfo", dnReturnInfo: "/wmspda/material/orderin/dnReturnInfo", + queryOrder: "/wmspda/material/poReturn/queryOrder", //dn退货 单号查询 enter: "/wmspda/material/orderin/enter", ImportEnter: "/wmspda/material/orderin/overseasDnEnter", out: "/wmspda/material/orderin/out",