From a4e5f22b95b4f4e65cea7e4917f8fe9150430041 Mon Sep 17 00:00:00 2001 From: Vergil <974548713@qq.com> Date: Mon, 24 Feb 2020 15:20:42 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=85=A8=E5=B1=80=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AmountInputBox/AmountInputBox.js | 81 +++++ src/components/AmountInputBox/index.js | 11 + src/main.js | 4 + .../GroupMatching/index.vue | 8 +- .../machiningHoursStatistics/index.vue | 325 ++++++++---------- .../OutFactoryMaintenance/index.vue | 22 +- .../TechnologyCenter/QueryParts/index.vue | 16 +- 7 files changed, 256 insertions(+), 211 deletions(-) create mode 100644 src/components/AmountInputBox/AmountInputBox.js create mode 100644 src/components/AmountInputBox/index.js diff --git a/src/components/AmountInputBox/AmountInputBox.js b/src/components/AmountInputBox/AmountInputBox.js new file mode 100644 index 00000000..2514ead5 --- /dev/null +++ b/src/components/AmountInputBox/AmountInputBox.js @@ -0,0 +1,81 @@ +/** + * @desc 验证整数类型数字方法 + * @param {Object} e + * @param {regular} reg 正则 + * @param {Number} charcode 键盘code + * */ +const checkNumber = (e, reg, charcode) => { + if (!reg.test(String.fromCharCode(charcode)) && charcode > 9 && !e.ctrlKey) { + if (e.preventDefault) { + e.preventDefault() + } else { + e.returnValue = false + } + } +} + +/** + * @desc 验证浮点类型小数方法(建议用text类型的表单) + * @param {Object} e + * @param {regular} reg 正则 + * @param {Number} charcode 键盘code + * @param {Object} el dom对象 + * */ +const checkFloat = (e, reg, charcode, el) => { + if (charcode === 46) { + if (el.children[0].value.includes('.')) { + e.preventDefault() + } + return + } else if ( + !reg.test(String.fromCharCode(charcode)) && + charcode > 9 && + !e.ctrlKey + ) { + if (e.preventDefault) { + e.preventDefault() + } else { + e.returnValue = false + } + } +} + +/** + * @author LeeYunxiang + * @description 限制数字输入格式 int => 正整数 , num => 自然数(正整数包括0) , float => 正数包括小数(建议用text类型的input表单) + * */ +export default { + key: 'positive', + func: { + inserted(el, bind) { + el.addEventListener('keypress', e => { + e = e || window.event + const charcode = typeof e.charCode === 'number' ? e.charCode : e.keyCode + let reg = null + switch (bind.value) { + case 'num': + reg = /\d/ + checkNumber(e, reg, charcode) + break + case 'int': + if (el.children[0].value.length === 0) { + reg = /^[1-9]$/ + } else { + reg = /\d/ + } + checkNumber(e, reg, charcode) + break + case 'float': + reg = /\d/ + checkFloat(e, reg, charcode, el) + break + case 'notZero': + // reg = (/^([1-9]\d*(\.\d*[1-9])?)|(0\.\d*[1-9])$/) + reg = (/^(?!(0[0-9]{0,}$))[0-9]{1,}[.]{0,}[0-9]{0,}$/) + checkFloat(e, reg, charcode, el) + break + } + }) + } + } +} diff --git a/src/components/AmountInputBox/index.js b/src/components/AmountInputBox/index.js new file mode 100644 index 00000000..75190d55 --- /dev/null +++ b/src/components/AmountInputBox/index.js @@ -0,0 +1,11 @@ +import AmountInputBox from './AmountInputBox.js' +const directives = [AmountInputBox] +export default { + install: Vue => { + if (directives.length && directives.length > 0) { + directives.map(item => { + Vue.directive(item.key, item.func) + }) + } + } +} diff --git a/src/main.js b/src/main.js index 729e3d4d..42e86a8b 100644 --- a/src/main.js +++ b/src/main.js @@ -22,6 +22,10 @@ import 'viewerjs/dist/viewer.css' import VueBarcode from '@xkeshi/vue-barcode' import Direction from 'vue-direction-key' import elDragDialog from '@/directive/el-dragDialog' +// 全局数字、金额输入框组件 +import directive from './components/AmountInputBox/index.js' +Vue.use(directive) + Vue.use(elDragDialog) Vue.component('barcode', VueBarcode) Vue.use(Direction) diff --git a/src/views/ManufacturingCenter/GroupMatching/index.vue b/src/views/ManufacturingCenter/GroupMatching/index.vue index 28f36a16..d469982e 100644 --- a/src/views/ManufacturingCenter/GroupMatching/index.vue +++ b/src/views/ManufacturingCenter/GroupMatching/index.vue @@ -1,7 +1,7 @@ -
+
- - + ~ @@ -16,188 +15,159 @@ v-model="endTime" value-format="yyyy-MM-dd" size="small" - style="width: 170px;margin:0px 10px" + style="width: 150px" type="date" placeholder="选择加工完成日期"/> - 查询 + 查询 导出 + + + + + + + + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
- - - - - - - - - - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
-
- - - - -
{{ item.label }}
-
{{ item.name }}
-
-
- - 机床导出 - - - 组件导出 - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +
{{ item.label }}
+
{{ item.name }}
+
+
+ + 机床导出 + + + 组件导出 + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -207,6 +177,7 @@ import { searchtable, searchtable2, searchtable4, searchtable5, initProject, sea export default { data() { return { + AmountInputBox: 231, workerName: '', startTime: '', endTime: '', diff --git a/src/views/Outsourcing/OutFactoryMaintenance/index.vue b/src/views/Outsourcing/OutFactoryMaintenance/index.vue index 5142aa31..9b2e1617 100644 --- a/src/views/Outsourcing/OutFactoryMaintenance/index.vue +++ b/src/views/Outsourcing/OutFactoryMaintenance/index.vue @@ -1,13 +1,11 @@ - + diff --git a/src/views/TechnologyCenter/QueryParts/index.vue b/src/views/TechnologyCenter/QueryParts/index.vue index 0d6daf08..99153845 100644 --- a/src/views/TechnologyCenter/QueryParts/index.vue +++ b/src/views/TechnologyCenter/QueryParts/index.vue @@ -1,24 +1,14 @@ - From e284656a1ede9f21f0a119903b3f703ef46c1358 Mon Sep 17 00:00:00 2001 From: Vergil <974548713@qq.com> Date: Tue, 25 Feb 2020 11:25:17 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=B7=A5=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ManufacturingCenter/Enter0therData/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/ManufacturingCenter/Enter0therData/index.vue b/src/views/ManufacturingCenter/Enter0therData/index.vue index 3e5a55df..715b97c6 100644 --- a/src/views/ManufacturingCenter/Enter0therData/index.vue +++ b/src/views/ManufacturingCenter/Enter0therData/index.vue @@ -25,7 +25,7 @@ type="month" size="small" value-format="yyyy-MM" - style="margin-left: 400px; width: 140px" + style="margin-left: 280px; width: 140px" placeholder="选择月"/> 查询