From d548a171da70b18a58caaf208e0e17a29b0ad55b Mon Sep 17 00:00:00 2001 From: lijuncheng Date: Fri, 12 Jan 2024 10:05:52 +0800 Subject: [PATCH 01/80] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8E=9F=E6=96=99?= =?UTF-8?q?=E4=B8=8A=E6=9E=B6=E7=94=B3=E8=AF=B7=E4=BF=AE=E6=94=B9=E6=95=B0?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/record.js | 1 + pages/purchaseReturn/request/returnRequestCreate.vue | 4 ++-- pages/putaway/request/putawayRequestCreate.vue | 9 ++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/record.js b/common/record.js index 8980df6c..2e457395 100644 --- a/common/record.js +++ b/common/record.js @@ -28,6 +28,7 @@ export function createDetailInfo(data, pack) { let detail = {}; Object.assign(detail, data) detail.balanceQty = Number(detail.qty) + detail.qty = Number(detail.qty); detail.stdPackQty = Number(pack.stdPackQty) detail.stdPackUnit = pack.stdPackUnit detail.handleQty =0; diff --git a/pages/purchaseReturn/request/returnRequestCreate.vue b/pages/purchaseReturn/request/returnRequestCreate.vue index dbc33c07..11f8fde1 100644 --- a/pages/purchaseReturn/request/returnRequestCreate.vue +++ b/pages/purchaseReturn/request/returnRequestCreate.vue @@ -219,9 +219,9 @@ purchaseReturnRequestCreate(params).then(res => { uni.hideLoading() if (res.data) { - this.showCommitSuccessMessage("提交成功
生成采购退货申请" + res.data, ) + this.showCommitSuccessMessage("提交成功
生成采购退货申请
" + res.data) } else { - this.showErrorMessage("提交失败"+res.msg) + this.showErrorMessage("提交失败["+res.msg+"]") } }).catch(error => { uni.hideLoading() diff --git a/pages/putaway/request/putawayRequestCreate.vue b/pages/putaway/request/putawayRequestCreate.vue index 18a8cc44..b57bb414 100644 --- a/pages/putaway/request/putawayRequestCreate.vue +++ b/pages/putaway/request/putawayRequestCreate.vue @@ -52,7 +52,6 @@ diff --git a/pages/issue/record/issueRecord.vue b/pages/issue/record/issueRecord.vue index 1b95de9d..fec2efc8 100644 --- a/pages/issue/record/issueRecord.vue +++ b/pages/issue/record/issueRecord.vue @@ -8,10 +8,12 @@ - - + @@ -61,7 +63,7 @@ import { calc } from '@/common/calc.js'; - + import { getManagementPrecisions } from '@/common/balance.js'; @@ -76,7 +78,7 @@ import winScanButton from '@/mycomponents/scan/winScanButton.vue' import comScanIssuePack from '@/pages/issue/coms/comScanIssuePack.vue' import workStation from '@/mycomponents/workStation/workStation.vue' - + export default { name: '', components: { @@ -101,8 +103,8 @@ fromInventoryStatuses: "", toInventoryStatuses: "", requestList: [], - dataContent:{}, - managementList:[] + dataContent: {}, + managementList: [] } }, mounted() { @@ -212,7 +214,7 @@ caclcQty() { var totalQty = 0; this.detailSource.subList.forEach(res => { - totalQty = calc.add(totalQty,res.qty); + totalQty = calc.add(totalQty, res.qty); }) this.detailSource.totalQty = totalQty; }, @@ -244,10 +246,10 @@ let handleQty = 0; if (batch != undefined) { batch.Records.forEach(res => { - handleQty = calc.add(handleQty,res.qty); + handleQty = calc.add(handleQty, res.qty); }) batch.handleQty = handleQty; - itemHandleQty = calc.add(itemHandleQty,handleQty) + itemHandleQty = calc.add(itemHandleQty, handleQty) } }) } @@ -270,31 +272,39 @@ batch.Records.forEach(r => { let record = {}; record.handleQty = r.qty; - + record.fromPackingNumber = r .packingNumber; record.fromBatch = r.batch; record.fromContainerNumber = r .ContainerNumber; - + record.toContainerNumber = r .ContainerNumber; record.toInventoryStatus = r .inventoryStatus; record.toLocationCode = subItem .toLocationCode; - record.fromLocationCode = fromLocation.fromLocationCode + record.fromLocationCode = fromLocation + .fromLocationCode record.supplierCode = r.supplierCode; - + + let single_price = r.singlePrice == null ? + 0 : r.singlePrice; + + record.singlePrice = single_price; + record.amount = single_price * r.qty; + + //使用在途库不改变管理模式 - var info = getPackingNumberAndBatch( - this.managementList, r - .itemCode, - r.packingNumber, r - .batch); - record.toPackingNumber = info - .packingNumber; - record.toBatch = info.batch; + var info = getPackingNumberAndBatch( + this.managementList, r + .itemCode, + r.packingNumber, r + .batch); + record.toPackingNumber = info + .packingNumber; + record.toBatch = info.batch; subItem.recordList.push(record); }) subList.push(subItem); @@ -303,7 +313,7 @@ }) }) }) - + this.dataContent.subList = subList this.dataContent.createTime = createTime; this.dataContent.creator = creator; @@ -314,7 +324,7 @@ title: "提交中....", mask: true }); - + //目前任务只到一个库位 var itemCodes = [] let locationCode = this.detailSource[0].toLocationCode @@ -323,7 +333,7 @@ itemCodes.push(item.itemCode) }) }) - + //获取管理模式,封装参数 getManagementPrecisions(itemCodes, locationCode, res => { if (res.success) { @@ -336,11 +346,11 @@ }); }, - + submitJob() { var params = this.setParams() console.log("提交参数", JSON.stringify(params)); - + issueRecordSubmit(params).then(res => { uni.hideLoading() if (res.data) { @@ -353,20 +363,20 @@ this.showErrorMessage(error) }) }, - + showCommitSuccessMessage(hint) { this.$refs.comMessage.showSuccessMessage(hint, res => { this.clearData(); }) }, - clearData(){ - this.detailSource =[]; - this.requestList=[]; - this.dataContent ={} - this.managementList=[] + clearData() { + this.detailSource = []; + this.requestList = []; + this.dataContent = {} + this.managementList = [] }, - + showMessage(message) { this.$refs.comMessage.showMessage(message, res => { if (res) { diff --git a/static/config.json b/static/config.json index 7b990381..61fe3fd0 100644 --- a/static/config.json +++ b/static/config.json @@ -18,7 +18,7 @@ "request_url": { "name": "request_url", - "value": "http://192.168.0.179:12080/admin-api", + "value": "http://192.168.0.106:12080/admin-api", "dev2": "http://192.168.0.157:12080/admin-api", "chefang": "http://192.168.0.176:12080/admin-api", "chenxinming": "http://192.168.0.230:12080/admin-api", From 7bd3a71a364d022bdac1e142a2c8bc7c0fb39f0b Mon Sep 17 00:00:00 2001 From: lijuncheng Date: Tue, 16 Jan 2024 16:26:52 +0800 Subject: [PATCH 14/80] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=20=E9=9B=B6?= =?UTF-8?q?=E4=BB=B6=E5=8F=B7=E5=8F=98=E6=88=90=E7=89=A9=E6=96=99=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.js | 16 ++++++++-------- api/request2.js | 4 ++-- common/basic.js | 6 +++--- common/classify.data.js | 2 +- common/scan.js | 8 ++++---- common/style/new_style.css | 2 +- common/style/pdabasic.css | 8 ++++---- mycomponents/item/itemDetailInfo.vue | 4 ++-- mycomponents/item/itemSelect.vue | 6 +++--- mycomponents/partCode/partCodeSelect.vue | 6 +++--- mycomponents/popup/selectList.vue | 8 ++++---- mycomponents/record/recordComDetailCard.vue | 2 +- mycomponents/scan/winScanPackAndLocation.vue | 8 ++++---- pages.json | 2 +- pages/container/coms/comContainerBindCard.vue | 2 +- pages/container/coms/comPalletRecord.vue | 2 +- pages/count/coms/comCountDetailCard.vue | 2 +- pages/count/job/countDetail.vue | 6 +++--- pages/count/record/countRecord.vue | 6 +++--- pages/customerReturn/coms/comReturnRecord.vue | 2 +- pages/deliver/coms/comDeliverRequestPopup.vue | 10 +++++----- pages/deliver/coms/comScanDeliverPack.vue | 2 +- pages/deliver/job/deliverDetail.vue | 2 +- pages/demo/demo.vue | 12 ++++++------ pages/inspect/job/inspectResult.vue | 2 +- .../coms/comIssueJobCard.vue | 2 +- .../coms/comScanIssuePack.vue | 2 +- pages/issue-按批次推荐/job/issueDetail.vue | 12 ++++++------ pages/issue/coms/comScanIssuePack.vue | 2 +- pages/issue/job/issueDetail.vue | 2 +- pages/issue/js/issue.js | 4 ++-- pages/issue/record/issueRecord.vue | 4 ++-- pages/package/coms/comOverRecord.vue | 2 +- pages/package/coms/comPackageRecord.vue | 2 +- pages/package/record/mergePackageRecord.vue | 8 ++++---- .../productDismantle/coms/comProductJobCard.vue | 2 +- pages/productDismantle/coms/comProductRecord.vue | 2 +- pages/productPutaway/coms/comProductRecord.vue | 2 +- pages/productReceipt/coms/comProductRecord.vue | 2 +- .../coms/comProductionRecord.vue | 2 +- pages/productionReturn/coms/comReturnRecord.vue | 2 +- .../productionReturn/coms/comScanReturnPack.vue | 2 +- pages/query/container.vue | 2 +- pages/query/item.vue | 14 +++++++------- pages/query/item_copy.vue | 16 ++++++++-------- pages/repleinsh/coms/comScanReplishPack.vue | 2 +- pages/repleinsh/job/repleinshDetail.vue | 2 +- pages/repleinsh/record/repleinshRecord.vue | 2 +- pages/unPlanned/coms/comReceiptRecord.vue | 2 +- 49 files changed, 112 insertions(+), 112 deletions(-) diff --git a/api/index.js b/api/index.js index ab6423f7..e2f0294e 100644 --- a/api/index.js +++ b/api/index.js @@ -140,14 +140,14 @@ export const getBalancesAsync = (params) => promise( }); -//根据零件、箱码、托码、批次、库位类型、库存状态查询库存 +//根据物料、箱码、托码、批次、库位类型、库存状态查询库存 export const getBalancesByFilter = (params) => request( devUrl + "/api/pda/inventory/balances/by-balances-request-many-parameter", { method: 'post', data: params }); -//根据零件、箱码、托码、批次、库位类型、库存状态查询库存 +//根据物料、箱码、托码、批次、库位类型、库存状态查询库存 export const getBalancesByFilterAsync = (params) => promise( devUrl + "/api/pda/inventory/balances/by-balances-request-many-parameter", { method: 'post', @@ -170,7 +170,7 @@ export const getBalancesByStatus = (params) => request( data: params }); -//根据库位和零件号查询库存 +//根据库位和物料号查询库存 export const getBalancesByLocationAndItem = (params) => request( devUrl + "/api/pda/inventory/balances/get-by-location-and-item?locationCode=" + params.locationCode + "&itemCode=" + params.itemCode, { @@ -179,7 +179,7 @@ export const getBalancesByLocationAndItem = (params) => request( }); -//根据库位和零件号查询库存 +//根据库位和物料号查询库存 export const getBalancesByLocationAndItemAsync = (params) => promise( devUrl + "/api/pda/inventory/balances/get-by-location-and-item?locationCode=" + params.locationCode + "&itemCode=" + params.itemCode, { @@ -203,15 +203,15 @@ export const summary = (params) => request( data: params }); -//零件 -//查询零件信息 +//物料 +//查询物料信息 export const getitems = (code) => request( devUrl + "/api/pda/item/" + code, { method: 'get', data: code }); -//根据库位查询零件 +//根据库位查询物料 export const getItemsByLocation = (params) => promise( devUrl + "/api/pda/inventory/balances/get-item-by-location", { method: 'get', @@ -427,7 +427,7 @@ export const locationByType = (type) => request( data: type }); -//根据库位查询零件 +//根据库位查询物料 export const getLocationByItem = (params) => promise( devUrl + "/api/pda/inventory/balances/get-location-by-item", { method: 'get', diff --git a/api/request2.js b/api/request2.js index e3886e99..d1791264 100644 --- a/api/request2.js +++ b/api/request2.js @@ -375,7 +375,7 @@ export function getBasicLocationByCode(code) { /** - * 校验库位零件关系 + * 校验库位物料关系 * @param {*} * */ @@ -3509,7 +3509,7 @@ export function getBalanceByFilter(param) { } /** - * 查询管理精度,多个零件,多个库位 + * 查询管理精度,多个物料,多个库位 * @param {*} * */ diff --git a/common/basic.js b/common/basic.js index 4df664c5..b725be39 100644 --- a/common/basic.js +++ b/common/basic.js @@ -476,7 +476,7 @@ export function getInspectReasonList(value) { // else return '其他' // } -// //零件状态 +// //物料状态 // export function getItemStatusStyle(val) { // if (val == "wpztUNK") return 'item_unk' // else if (val == "wpztENABLE") return 'item_active' @@ -498,7 +498,7 @@ export function getInspectReasonList(value) { // } -// //零件状态描述 +// //物料状态描述 // export function getItemStatusDesc(val) { // if (val == "wpztUNK") return '未知' // else if (val == "wpztENABLE") return '可用' @@ -541,7 +541,7 @@ export function getInspectReasonList(value) { // if (val == 0) return '未知' // else if (val == 1) return '库位盘点' // else if (val == 2) return '物品盘点' -// else if (val == 3) return '库位零件盘点' +// else if (val == 3) return '库位物料盘点' // else return '其他' // } diff --git a/common/classify.data.js b/common/classify.data.js index 4870927a..ea61158a 100644 --- a/common/classify.data.js +++ b/common/classify.data.js @@ -1,7 +1,7 @@ export default [{ "name": "库存查询", "children": [{ - "name": "按零件查询库存", + "name": "按物料查询库存", "icon": "/static/menus/menu_search_lj.svg", "url": "pages/query/item", "index": 1, diff --git a/common/scan.js b/common/scan.js index 73fe2759..f8635d6f 100644 --- a/common/scan.js +++ b/common/scan.js @@ -125,7 +125,7 @@ export function analyseScanInfo(scanMsg) { //解析完工收货标签 //P2250229RAA;L220408;Q100;N62840610;SB0000107;UEA;DU571LS;FA;E2022-4-8 -//P零件号,L批次,Q数量,N生产计划号,S箱码,U计量单位,D生产线,F班次,E日期,M零件名称(待添加) +//P物料号,L批次,Q数量,N生产计划号,S箱码,U计量单位,D生产线,F班次,E日期,M物料名称(待添加) //解析规则 //P:itemCode 物料号 //L:lot批次 @@ -240,7 +240,7 @@ export function analyseProductLabelInfo(scanMsg) { //解析天津mes标签 //1#2546319FL#254FL003#202207110009: -//1.序号1,2.生产号2546311FL,3.零件号254FL004,4.批序号202207110009 +//1.序号1,2.生产号2546311FL,3.物料号254FL004,4.批序号202207110009 export function analyseTJMesQRCode(scanMsg) { let scanResult = { success: false, @@ -269,7 +269,7 @@ export function analyseTJMesQRCode(scanMsg) { seq: datas[0], //序号 produceNo: datas[1], //生产号 // projectNo: datas[2], //项目号 - itemCode: itemCode, //配置码(零件号) + itemCode: itemCode, //配置码(物料号) lot: datas[3], //批次 position: location //上层、下层 } @@ -282,7 +282,7 @@ export function analyseTJMesQRCode(scanMsg) { seq: seq, //序号 produceNo: 'N', //生产号 projectNo: 'N', //项目号 - itemCode: 'N', //配置码(零件号) + itemCode: 'N', //配置码(物料号) lot: 'N', //批次 position: '' } diff --git a/common/style/new_style.css b/common/style/new_style.css index 6d4c4bc7..f7f1c40c 100644 --- a/common/style/new_style.css +++ b/common/style/new_style.css @@ -115,7 +115,7 @@ uni-page-head .uni-page-head__title { } /* -零件状态 +物料状态 未知,可用,隔离,新增,规划,禁用 */ diff --git a/common/style/pdabasic.css b/common/style/pdabasic.css index d52e32ec..7b7f368a 100644 --- a/common/style/pdabasic.css +++ b/common/style/pdabasic.css @@ -417,7 +417,7 @@ -/* //零件状态 +/* //物料状态 export function getItemTypeStyle(val) { if (val == 0) return 'active' else if (val == 1) return 'hold' @@ -428,7 +428,7 @@ export function getItemTypeStyle(val) { } */ -/* 零件状态 */ +/* 物料状态 */ .active { background-color: #5FCB94; color: #FFFFFF; @@ -460,7 +460,7 @@ export function getItemTypeStyle(val) { font-weight: bolder; } -/* 零件编号字体 */ +/* 物料编号字体 */ .text-itemcode { /* font-size: 26rpx; */ color: #000; @@ -472,7 +472,7 @@ export function getItemTypeStyle(val) { /* font-size: 22rpx; */ } -/* 零件编号字体 */ +/* 物料编号字体 */ .text-bolder { color: #000; font-weight: bolder; diff --git a/mycomponents/item/itemDetailInfo.vue b/mycomponents/item/itemDetailInfo.vue index 14c757a1..6649a075 100644 --- a/mycomponents/item/itemDetailInfo.vue +++ b/mycomponents/item/itemDetailInfo.vue @@ -2,11 +2,11 @@ - 零件号 + 物料号 {{dataContent.code}} - 零件名称 + 物料名称 {{dataContent.name}} diff --git a/mycomponents/item/itemSelect.vue b/mycomponents/item/itemSelect.vue index 631cf749..6a059ffc 100644 --- a/mycomponents/item/itemSelect.vue +++ b/mycomponents/item/itemSelect.vue @@ -1,9 +1,9 @@ @@ -55,7 +55,7 @@ import { unPlannedReceiptRecordbSubmit } from '@/api/request2.js'; - + import { getDirectoryItemArray, getUnPlannedReceiptReasonList @@ -64,17 +64,17 @@ import { getBusinessType, } from '@/common/record.js'; - + import { - calc - } from '@/common/calc.js'; + calc + } from '@/common/calc.js'; import { goHome, updateTitle, deepCopyData, getPackingNumberAndBatchByList } from '@/common/basic.js'; - + import { getPrecisionStrategyList } from '@/common/balance.js'; @@ -102,10 +102,10 @@ detailSource: [], //绑定在页面上的数据源 businessTypeCode: "UnplannedReceipt", reasonText: "", - reasonCode:"", + reasonCode: "", reasonList: [], - dataContent:{}, - managementList:[] + dataContent: {}, + managementList: [] } }, @@ -123,8 +123,7 @@ }); }, - onLoad(option) { - }, + onLoad(option) {}, methods: { openScanPopup() { @@ -188,7 +187,7 @@ // Object.assign(detail, label) detail.qty = Number(label.qty) detail.handleQty = 0, - detail.inventoryStatus = "OK" + detail.inventoryStatus = "OK" detail.stdPackQty = pack.stdPackQty; detail.stdPackUnit = pack.stdPackUnit; label.inventoryStatus = "OK"; @@ -203,7 +202,7 @@ item.qty = 0; for (let detail of item.subList) { if (detail != undefined) { - item.qty = calc.add(item.qty,detail.qty) + item.qty = calc.add(item.qty, detail.label.qty) } } } @@ -242,44 +241,44 @@ this.showErrorMessage("请选择入库原因") return; } - - + + if (this.detailSource.length > 0 && this.detailSource[0].subList.length > 0) { - //查询管理模式 - uni.showLoading({ - title: "提交中....", - mask: true - }); - this.managementList = []; - var precisionStrategParams = this.setPrecisionStrategParams() - getPrecisionStrategyList(precisionStrategParams, res => { - if (res.success) { - this.managementList = res.list; - var params = this.setParams() - console.log("提交" + JSON.stringify(params)) - unPlannedReceiptRecordbSubmit(params).then(res => { - uni.hideLoading() - if (res.data) { - this.showCommitSuccessMessage("提交成功
生成计划外入库记录
" + res.data) - } else { - this.showErrorMessage("提交失败[" + res.msg + "]") - } - }).catch(error => { - uni.hideLoading() - this.showErrorMessage(error) - }) - - } else { - uni.hideLoading(); - this.showErrorMessage(res.message); - } - - }) - }else { + //查询管理模式 + uni.showLoading({ + title: "提交中....", + mask: true + }); + this.managementList = []; + var precisionStrategParams = this.setPrecisionStrategParams() + getPrecisionStrategyList(precisionStrategParams, res => { + if (res.success) { + this.managementList = res.list; + var params = this.setParams() + console.log("提交" + JSON.stringify(params)) + unPlannedReceiptRecordbSubmit(params).then(res => { + uni.hideLoading() + if (res.data) { + this.showCommitSuccessMessage("提交成功
生成计划外入库记录
" + res.data) + } else { + this.showErrorMessage("提交失败[" + res.msg + "]") + } + }).catch(error => { + uni.hideLoading() + this.showErrorMessage(error) + }) + + } else { + uni.hideLoading(); + this.showErrorMessage(res.message); + } + + }) + } else { this.showErrorMessage("没有要提交的数据,请先扫描") } - - + + }, setPrecisionStrategParams() { var itemList = [] @@ -301,47 +300,48 @@ } itemList.push(result) } - + } }) }) return itemList; }, setParams() { - + var subList = [] var creator = this.$store.state.user.id this.detailSource.forEach(item => { item.subList.forEach(detail => { if (detail.scaned) { var submitItem = deepCopyData(detail) - var info = getPackingNumberAndBatchByList(this.managementList, detail.label.itemCode, + var info = getPackingNumberAndBatchByList(this.managementList, detail.label + .itemCode, detail.label.packingNumber, detail.toLocationCode, detail.label.batch); - + submitItem.itemCode = detail.package.itemCode; submitItem.itemName = detail.package.itemName; submitItem.itemDesc1 = detail.package.itemDesc1; submitItem.itemDesc2 = detail.package.itemDesc2; - + submitItem.inventoryStatus = detail.inventoryStatus; - + submitItem.fromPackingNumber = info.packingNumber; submitItem.toPackingNumber = info.packingNumber; - + // detail.fromContainerNumber = detail.containerNumber; // detail.toContainerNumber = detail.containerNumber - + submitItem.fromBatch = info.batch; submitItem.toBatch = info.batch; - + submitItem.fromLocationCode = ""; submitItem.toLocationCode = detail.toLocationCode; - + submitItem.reason = this.reasonCode; - - submitItem.qty = detail.handleQty!=0?detail.handleQty:detail.qty; - submitItem.package =""; - + + submitItem.qty = detail.label.qty; + submitItem.package = ""; + subList.push(submitItem) } }) @@ -364,16 +364,16 @@ this.clearData(); }) }, - clearData(){ + clearData() { this.reasonCode = "" this.reasonText = ""; this.detailSource = []; - this.managementList=[]; - this.dataContent ={} - this.toLocationCode ="" + this.managementList = []; + this.dataContent = {} + this.toLocationCode = "" } - - + + } } diff --git a/uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue b/uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue index 39bb86a9..6f8393a8 100644 --- a/uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue +++ b/uni_modules/uni-number-box/components/uni-number-box/uni-number-box.vue @@ -1,13 +1,14 @@ @@ -27,7 +28,9 @@ * @event {Function} focus 输入框聚焦时触发的事件,参数为 event 对象 * @event {Function} blur 输入框失焦时触发的事件,参数为 event 对象 */ - + import { + Decimal + } from 'decimal.js'; //引入 export default { name: "UniNumberBox", emits: ['change', 'input', 'update:modelValue', 'blur', 'focus'], @@ -71,26 +74,55 @@ }, data() { return { - inputValue: 0 + inputValue: 0, + maxlength: 10 }; }, watch: { value(val) { - this.inputValue = +val; + this.inputValue = this.add(this.inputValue, val) }, modelValue(val) { - this.inputValue = +val; + this.inputValue = this.add(this.inputValue, val) } }, created() { if (this.value === 1) { - this.inputValue = +this.modelValue; + this.inputValue = this.add(this.inputValue, this.modelValue) } if (this.modelValue === 1) { - this.inputValue = +this.value; + this.inputValue = this.add(this.inputValue, this.value) } }, methods: { + add(num1, num2) { + return new Decimal(num1).add(new Decimal(num2)) + }, + + sub(num1, num2) { + return new Decimal(num1).sub(new Decimal(num2)) + }, + + mul(num1,num2) { + return new Decimal(num1).mul(new Decimal(num2)) + }, + div(num1,num2) { + return new Decimal(num1).div(new Decimal(num2)) + }, + checkNum(e) { + let value = e.detail.value; + let dot = value.indexOf('.'); //鍖呭惈灏忔暟鐐 + let reg = /^[0-9]+$/; //姝f暣鏁 + if (dot > -1) { + this.maxlength = dot + 7; //闀垮害鏄¯灏忔暟鐐瑰悗涓や綅 + if (value.length > dot + 7) { + + } + } + if (reg.test(value)) { //濡傛灉鏄¯姝f暣鏁颁笉鍖呭惈灏忔暟鐐 + this.maxlength = 10; + } + }, _calcValue(type) { if (this.disabled) { return; @@ -99,7 +131,7 @@ let value = this.inputValue * scale; let step = this.step * scale; if (type === "minus") { - value -= step; + value = this.sub(value - step) if (value < (this.min * scale)) { return; } @@ -109,53 +141,54 @@ } if (type === "plus") { - value += step; - if (value > (this.max * scale)) { - return; - } - if (value < (this.min * scale)) { - value = this.min * scale - } - } - - this.inputValue = (value / scale).toFixed(String(scale).length - 1); - this.$emit("change", +this.inputValue); - // TODO vue2 兼容 - this.$emit("input", +this.inputValue); - // TODO vue3 兼容 - this.$emit("update:modelValue", +this.inputValue); - }, - _getDecimalScale() { - - let scale = 1; - // 浮点型 - if (~~this.step !== this.step) { - scale = Math.pow(10, String(this.step).split(".")[1].length); - } - return scale; - }, - _onBlur(event) { - this.$emit('blur', event) - let value = event.detail.value; - if (!value) { - // this.inputValue = 0; + value = this.add(value, step) + + if (value > (this.max * scale)) { return; } - value = +value; - if (value > this.max) { - value = this.max; - } else if (value < this.min) { - value = this.min; + if (value < (this.min * scale)) { + value = this.min * scale } - const scale = this._getDecimalScale(); - this.inputValue = value.toFixed(String(scale).length - 1); - this.$emit("change", +this.inputValue); - this.$emit("input", +this.inputValue); - }, - _onFocus(event) { - this.$emit('focus', event) } + + this.inputValue = (value / scale).toFixed(String(scale).length - 1); + this.$emit("change", +this.inputValue); + // TODO vue2 兼容 + this.$emit("input", +this.inputValue); + // TODO vue3 兼容 + this.$emit("update:modelValue", +this.inputValue); + }, + _getDecimalScale() { + + let scale = 1; + // 浮点型 + if (~~this.step !== this.step) { + scale = Math.pow(10, String(this.step).split(".")[1].length); + } + return scale; + }, + _onBlur(event) { + this.$emit('blur', event) + let value = event.detail.value; + if (!value) { + // this.inputValue = 0; + return; + } + value = +value; + if (value > this.max) { + value = this.max; + } else if (value < this.min) { + value = this.min; + } + const scale = this._getDecimalScale(); + this.inputValue = value.toFixed(String(scale).length - 1); + this.$emit("change", +this.inputValue); + this.$emit("input", +this.inputValue); + }, + _onFocus(event) { + this.$emit('focus', event) } + } };