From 88f57a962ec9f4cbe56530d3e7b1a280ae8a4f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=B8=85?= <3115919733@qq.com> Date: Mon, 12 May 2025 08:55:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E8=BE=93=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/uni-number-box/uni-number-box.vue | 151 ++++++++------ pages.json | 21 ++ pages/tms/features/VehicleInOut/index.vue | 160 +++++++++++++++ pages/tms/index.vue | 199 +++++++++++++++++++ 4 files changed, 471 insertions(+), 60 deletions(-) create mode 100644 pages/tms/features/VehicleInOut/index.vue create mode 100644 pages/tms/index.vue diff --git a/components/uni-number-box/uni-number-box.vue b/components/uni-number-box/uni-number-box.vue index edc90a8..5ad868e 100644 --- a/components/uni-number-box/uni-number-box.vue +++ b/components/uni-number-box/uni-number-box.vue @@ -1,11 +1,12 @@ @@ -18,17 +19,26 @@ * @property {Number} min 最小值 * @property {Number} max 最大值 * @property {Number} step 每次点击改变的间隔大小 + * @property {String} background 背景色 + * @property {String} color 字体颜色(前景色) * @property {Boolean} disabled = [true|false] 是否为禁用状态 * @event {Function} change 输入框值改变时触发的事件,参数为输入框当前的 value + * @event {Function} focus 输入框聚焦时触发的事件,参数为 event 对象 + * @event {Function} blur 输入框失焦时触发的事件,参数为 event 对象 */ export default { name: "UniNumberBox", + emits: ['change', 'input', 'update:modelValue', 'blur', 'focus'], props: { value: { type: [Number, String], default: 1 }, + modelValue: { + type: [Number, String], + default: 1 + }, min: { type: Number, default: 0 @@ -41,6 +51,14 @@ type: Number, default: 1 }, + background: { + type: String, + default: '#f5f5f5' + }, + color: { + type: String, + default: '#333' + }, disabled: { type: Boolean, default: false @@ -55,14 +73,17 @@ value(val) { this.inputValue = +val; }, - inputValue(newVal, oldVal) { - if (+newVal !== +oldVal) { - this.$emit("change", newVal); - } + modelValue(val) { + this.inputValue = +val; } }, created() { - this.inputValue = +this.value; + if (this.value === 1) { + this.inputValue = +this.modelValue; + } + if (this.modelValue === 1) { + this.inputValue = +this.value; + } }, methods: { _calcValue(type) { @@ -80,7 +101,9 @@ if (value > (this.max * scale)) { value = this.max * scale } - } else if (type === "plus") { + } + + if (type === "plus") { value += step; if (value > (this.max * scale)) { return; @@ -90,17 +113,24 @@ } } - this.inputValue = String(value / 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, (this.step + "").split(".")[1].length); + 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; @@ -112,14 +142,23 @@ } else if (value < this.min) { value = this.min; } - this.inputValue = value; + 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) } } }; - \ No newline at end of file + diff --git a/pages.json b/pages.json index 1274be0..08bee0b 100644 --- a/pages.json +++ b/pages.json @@ -42,6 +42,13 @@ "enablePullDownRefresh": false } }, + { + "path": "pages/tms/index", + "style": { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + }, { "path": "pages/account/index", "style": { @@ -639,6 +646,14 @@ "enablePullDownRefresh": false } + },{ + "path" : "pages/tms/features/VehicleInOut/index", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + } ], "globalStyle": { @@ -681,6 +696,12 @@ "text": "库内", "pagePath": "pages/checkplan/index" }, + { + "iconPath": "static/img/material.png", + "selectedIconPath": "static/img/material_selected.png", + "text": "运输", + "pagePath": "pages/tms/index" + }, { "iconPath": "static/img/account.png", "selectedIconPath": "static/img/account_selected.png", diff --git a/pages/tms/features/VehicleInOut/index.vue b/pages/tms/features/VehicleInOut/index.vue new file mode 100644 index 0000000..4b323ae --- /dev/null +++ b/pages/tms/features/VehicleInOut/index.vue @@ -0,0 +1,160 @@ + + + + + \ No newline at end of file diff --git a/pages/tms/index.vue b/pages/tms/index.vue new file mode 100644 index 0000000..8d25d05 --- /dev/null +++ b/pages/tms/index.vue @@ -0,0 +1,199 @@ + + + + + \ No newline at end of file