From 559cffc5f005767c95f99d75865c3ec9d7c5b080 Mon Sep 17 00:00:00 2001 From: g7hoo Date: Wed, 10 Aug 2022 09:43:17 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E7=BC=93=E5=AD=98&add=20momentjs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 5 +++++ package.json | 3 ++- src/components/base-dialog/addOrUpdate/index.vue | 14 ++++++++------ src/views/modules/monitoring/product.vue | 11 ++++++++--- .../modules/sys/dict-data-add-or-update.vue | 16 +++++++++++++++- .../modules/sys/dict-type-add-or-update.vue | 2 +- src/views/pages/login.vue | 16 +++++++++++++++- 7 files changed, 54 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 91aad73..1ebd4cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10942,6 +10942,11 @@ "minimist": "^1.2.5" } }, + "moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" + }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npm.taobao.org/move-concurrently/download/move-concurrently-1.0.1.tgz", diff --git a/package.json b/package.json index 73b5dab..9010c37 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,10 @@ "element-ui": "^2.15.7", "js-cookie": "^2.2.1", "lodash": "^4.17.19", - "sass": "^1.26.5", + "moment": "^2.29.4", "qs": "^6.9.4", "quill": "^1.3.7", + "sass": "^1.26.5", "sass-loader": "^9.0.2", "screenfull": "^4.2.1", "svg-sprite-loader": "^5.0.0", diff --git a/src/components/base-dialog/addOrUpdate/index.vue b/src/components/base-dialog/addOrUpdate/index.vue index ff1df4b..aa5cd65 100644 --- a/src/components/base-dialog/addOrUpdate/index.vue +++ b/src/components/base-dialog/addOrUpdate/index.vue @@ -1,6 +1,6 @@ @@ -87,7 +89,7 @@ export default { * type: 'dialog' | 'drawer' | 'page' * fields: Array * - fields.object: { name, type: 'number'|'textarea'|'select'|'date'|.., required: boolean, validator: boolean(是否需要验证), [options]: any[], api: string(自动获取数据的接口,一般为getcode接口)} - * operations: Array[object], 操作名和对应的接口地址 + * operations: Array[object], 操作名和对应的接口地址,还有permission(如,sys:dict:update) */ type: Object, default: () => ({}) // 此处省去类型检查,使用者自行注意就好 @@ -265,7 +267,7 @@ export default { method: btn.name === 'save' ? 'POST' : 'PUT', data: this.dataForm }).then(({ data: res }) => { - if (data && data.code === 0) { + if (res && res.code === 0) { this.$message({ message: btn.name === 'save' ? '添加成功!' : '更新成功!', type: 'success', diff --git a/src/views/modules/monitoring/product.vue b/src/views/modules/monitoring/product.vue index 5e7fb39..b6d3b86 100644 --- a/src/views/modules/monitoring/product.vue +++ b/src/views/modules/monitoring/product.vue @@ -64,9 +64,14 @@ import BaseTable from '@/components/base-table' import TableOperateComponent from '@/components/base-table/components/operationComponent' import TableTextComponent from '@/components/base-table/components/detailComponent' import BaseDialog from '@/components/base-dialog/addOrUpdate' +import moment from 'moment' + +const UnitDictTypeId = '1557173812109242370' +const ProductTypeDictTypeId = ' ' + const tableConfigs = [ { type: 'index', name: '序号' }, - { prop: 'updateTime', name: '添加时间' }, + { prop: 'updateTime', name: '添加时间', filter: val => val ? moment(val).format('YYYY-MM-DD hh:mm:ss') : '-' }, { prop: 'name', name: '产品名称' }, { prop: 'code', name: '产品编码' }, { prop: 'specifications', name: '规格' }, @@ -146,8 +151,8 @@ const addOrUpdateConfigs = { ], operations: [ { name: 'reset', url: true }, - { name: 'save', url: 'api/product/add' }, - { name: 'update', url: 'api/product/update' } + { name: 'save', url: '/monitoring/product', permission: "" }, + { name: 'update', url: '/monitoring/product', permission: "" } ] // extraComponents: [ // { diff --git a/src/views/modules/sys/dict-data-add-or-update.vue b/src/views/modules/sys/dict-data-add-or-update.vue index a5ff947..15ed332 100644 --- a/src/views/modules/sys/dict-data-add-or-update.vue +++ b/src/views/modules/sys/dict-data-add-or-update.vue @@ -78,7 +78,7 @@ export default { if (!valid) { return false } - this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/dict/data', this.dataForm) + this.$http[!this.dataForm.id ? 'post' : 'put'](this.$http.adornUrl('/sys/dict/data'), this.dataForm) .then(({ data: res }) => { if (res.code !== 0) { return this.$message.error(res.msg) @@ -92,6 +92,20 @@ export default { this.$emit('refreshDataList') } }) + + /** 刷新dictlist */ + this.$http.get(this.$http.adornUrl('/sys/dict/data/getAll')).then(({ data: res }) => { + if (res && res.code === 0) { + localStorage.setItem('dictList', JSON.stringify(res.data)) + } else { + this.$message({ + message: '数据字典拉取失败,请检查!', + type: 'error', + duration: 2000 + }) + } + }) + }) .catch(() => {}) }) diff --git a/src/views/modules/sys/dict-type-add-or-update.vue b/src/views/modules/sys/dict-type-add-or-update.vue index 44e9a18..4872106 100644 --- a/src/views/modules/sys/dict-type-add-or-update.vue +++ b/src/views/modules/sys/dict-type-add-or-update.vue @@ -77,7 +77,7 @@ export default { if (!valid) { return false } - this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/dict/type', this.dataForm) + this.$http[!this.dataForm.id ? 'post' : 'put'](this.$http.adornUrl('/sys/dict/type'), this.dataForm) .then(({ data: res }) => { if (res.code !== 0) { return this.$message.error(res.msg) diff --git a/src/views/pages/login.vue b/src/views/pages/login.vue index 165d007..bf9b823 100644 --- a/src/views/pages/login.vue +++ b/src/views/pages/login.vue @@ -106,9 +106,23 @@ export default { return this.$message.error(res.msg) } Cookies.set('token', res.data.token) + + /** 保存dictlist */ + this.$http.get(this.$http.adornUrl('/sys/dict/data/getAll')).then(({ data: res }) => { + if (res && res.code === 0) { + localStorage.setItem('dictList', JSON.stringify(res.data)) + } else { + this.$message({ + message: '数据字典拉取失败,请检查!', + type: 'error', + duration: 2000 + }) + } + }) + this.$router.replace({ name: 'home' }) }) - .catch((err) => { + .catch(err => { this.$message({ message: err.message, type: 'error',