diff --git a/pages/modules/package-instore.vue b/pages/modules/package-instore.vue
index e3dd0be..c79f5c2 100644
--- a/pages/modules/package-instore.vue
+++ b/pages/modules/package-instore.vue
@@ -6,7 +6,43 @@
钢托盘1编码
-
+
+
+
+
+ 物料数量
+
+
+
+
+
+ 钢托盘2编码
+
+
+
+
+
+ 物料数量
+
+
+
+
+
+ 钢托盘3编码
+
+
+
+
+
+ 物料数量
+
+
+
+
+
+ 木托盘编码
+
+
@@ -15,42 +51,6 @@
-
- 钢托盘2编码
-
-
-
-
-
- 物料数量
-
-
-
-
-
- 钢托盘3编码
-
-
-
-
-
- 物料数量
-
-
-
-
-
- 木托盘编码
-
-
-
-
-
- 物料数量
-
-
-
-
@@ -78,8 +78,9 @@
-
-
+
+
+
@@ -95,22 +96,40 @@
},
data() {
return {
- code1: '',
- num1: '',
- code2: '',
- num2: '',
- code3: '',
- num3: '',
- code4: '',
- num4: '',
+ code: this.$store.getters.codeArr || ['', '', '', ''],
+ num: this.$store.getters.numArr || ['', '', ''],
+ num1: this.$store.getters.num || '',
dataList: [],
disabled: false
};
},
+ watch: {
+ num () {
+ let num1 = this.num[0] !== '' ? parseFloat(this.num[0]) : ''
+ let num2 = this.num[1] !== '' ? parseFloat(this.num[1]) : ''
+ let num3 = this.num[2] !== '' ? parseFloat(this.num[2]) : ''
+ this.num1 = num1 + num2 + num3
+ }
+ },
created () {
- this._manualSortingPackingTaskShow()
+ // this._manualSortingPackingTaskShow()
+ if (this.num1 === '') {
+ let num1 = this.num[0] !== '' ? parseFloat(this.num[0]) : ''
+ let num2 = this.num[1] !== '' ? parseFloat(this.num[1]) : ''
+ let num3 = this.num[2] !== '' ? parseFloat(this.num[2]) : ''
+ this.num1 = num1 + num2 + num3
+ }
+ },
+ beforeDestroy () {
+ this.$store.dispatch('setCodeArr', this.code)
+ this.$store.dispatch('setNumArr', this.num)
+ this.$store.dispatch('setNum', this.num1)
},
methods: {
+ clearUp () {
+ this.code = ['', '', '', '']
+ this.num = ['', '', '', '']
+ },
/** grid查询 */
async _manualSortingPackingTaskShow () {
let res = await manualSortingPackingTaskShow()
@@ -119,21 +138,13 @@
/** 确认 */
async toSure () {
this.disabled = true
- if (!(((this.code1 !== '' && this.num1 !== '') || (this.code2 !== '' && this.num2 !== '') || (this.code3 !== '' && this.num3 !== '')) && (this.code4 !== '' && this.num4 !== ''))) {
+ if (!(((this.code[0] !== '' && this.num[0] !== '') || (this.code[1] !== '' && this.num[1] !== '') || (this.code[2] !== '' && this.num[2] !== '')) && (this.code[3] !== '' && this.num1 !== ''))) {
this.disabled = false
return
}
try {
- let res = await manualSortingPackingTask(this.code1, this.num1, this.code2, this.num2, this.code3, this.num3, this.code4, this.num4)
+ let res = await manualSortingPackingTask(this.code[0], this.num[0], this.code[1], this.num[1], this.code[2], this.num[2], this.code[3], this.num1)
this.disabled = false
- this.code1 = ''
- this.num2 = ''
- this.code2 = ''
- this.num2 = ''
- this.code3 = ''
- this.num3 = ''
- this.code4 = ''
- this.num4 = ''
this._manualSortingPackingTaskShow()
uni.showToast({
title: res.message,
diff --git a/utils/utils.js b/utils/utils.js
index 6f94817..6eb933e 100644
--- a/utils/utils.js
+++ b/utils/utils.js
@@ -36,4 +36,81 @@ export const dateFtt = date => {
}
return new Date(Date.parse(date))
}
-
\ No newline at end of file
+
+ /**
+ * 小数加法
+ */
+ export const accAdd = (arg1, arg2) => {
+ var r1, r2, m, c
+ try {
+ r1 = arg1.toString().split('.')[1].length
+ } catch (e) {
+ r1 = 0
+ }
+ try {
+ r2 = arg2.toString().split('.')[1].length
+ } catch (e) {
+ r2 = 0
+ }
+ c = Math.abs(r1 - r2)
+ m = Math.pow(10, Math.max(r1, r2))
+ if (c > 0) {
+ var cm = Math.pow(10, c)
+ if (r1 > r2) {
+ arg1 = Number(arg1.toString().replace('.', ''))
+ arg2 = Number(arg2.toString().replace('.', '')) * cm
+ } else {
+ arg1 = Number(arg1.toString().replace('.', '')) * cm
+ arg2 = Number(arg2.toString().replace('.', ''))
+ }
+ } else {
+ arg1 = Number(arg1.toString().replace('.', ''))
+ arg2 = Number(arg2.toString().replace('.', ''))
+ }
+ return (arg1 + arg2) / m
+ }
+
+ /**
+ * 小数减法
+ */
+ export const accSubtract = (arg1, arg2) => {
+ var r1, r2, m, c
+ try {
+ r1 = arg1.toString().split('.')[1].length
+ } catch (e) {
+ r1 = 0
+ }
+ try {
+ r2 = arg2.toString().split('.')[1].length
+ } catch (e) {
+ r2 = 0
+ }
+ c = Math.abs(r1 - r2)
+ m = Math.pow(10, Math.max(r1, r2))
+ if (c > 0) {
+ var cm = Math.pow(10, c)
+ if (r1 > r2) {
+ arg1 = Number(arg1.toString().replace('.', ''))
+ arg2 = Number(arg2.toString().replace('.', '')) * cm
+ } else {
+ arg1 = Number(arg1.toString().replace('.', '')) * cm
+ arg2 = Number(arg2.toString().replace('.', ''))
+ }
+ } else {
+ arg1 = Number(arg1.toString().replace('.', ''))
+ arg2 = Number(arg2.toString().replace('.', ''))
+ }
+ return (arg1 - arg2) / m
+ }
+
+ /**
+ * 小数乘法
+ */
+ export const accMul = (arg1, arg2) => {
+ var m = 0
+ var s1 = arg1.toString()
+ var s2 = arg2.toString()
+ try { m += s1.split('.')[1].length } catch (e) {}
+ try { m += s2.split('.')[1].length } catch (e) {}
+ return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
+ }
\ No newline at end of file
diff --git a/vuex/modules/data.js b/vuex/modules/data.js
new file mode 100644
index 0000000..bef9176
--- /dev/null
+++ b/vuex/modules/data.js
@@ -0,0 +1,42 @@
+import * as types from '../types'
+const state = {
+ codeArr: uni.getStorageSync('codeArr') || ['', '', '', ''],
+ numArr: uni.getStorageSync('numArr') || ['', '', '', ''],
+ num: uni.getStorageSync('num') || ''
+}
+const getters = {
+ codeArr: state => state.codeArr,
+ numArr: state => state.numArr,
+ num: state => state.num
+}
+const actions = {
+ setCodeArr ({commit}, res) {
+ uni.setStorageSync('codeArr', res)
+ commit(types.CODE_ARR, res)
+ },
+ setNumArr ({commit}, res) {
+ uni.setStorageSync('numArr', res)
+ commit(types.NUM_ARR, res)
+ },
+ setNum ({commit}, res) {
+ uni.setStorageSync('num', res)
+ commit(types.N_U_M, res)
+ }
+}
+const mutations = {
+ [types.CODE_ARR] (state, res) {
+ state.codeArr = res
+ },
+ [types.NUM_ARR] (state, res) {
+ state.numArr = res
+ },
+ [types.N_U_M] (state, res) {
+ state.num = res
+ }
+}
+export default {
+ state,
+ getters,
+ actions,
+ mutations
+}
\ No newline at end of file
diff --git a/vuex/store.js b/vuex/store.js
index 095161f..f8cd813 100644
--- a/vuex/store.js
+++ b/vuex/store.js
@@ -2,11 +2,13 @@ import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
+import data from './modules/data'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
- user
+ user,
+ data
}
})
diff --git a/vuex/types.js b/vuex/types.js
index 4668940..d50166b 100644
--- a/vuex/types.js
+++ b/vuex/types.js
@@ -6,4 +6,7 @@ export const DEL_LOGIN_NAME = 'DEL_LOGIN_NAME'
export const COM_CONFIG = 'COM_CONFIG'
export const SAVE_USER_INFO = 'SAVE_USER_INFO'
export const DEL_USER_INFO = 'DEL_USER_INFO'
-export const SAVE_TOKEN = 'SAVE_TOKEN'
\ No newline at end of file
+export const SAVE_TOKEN = 'SAVE_TOKEN'
+export const CODE_ARR = 'CODE_ARR'
+export const NUM_ARR = 'NUM_ARR'
+export const N_U_M = 'N_U_M'
\ No newline at end of file