update 数据字典缓存&add momentjs
This commit is contained in:
父節點
cfec6ff3f5
當前提交
559cffc5f0
5
package-lock.json
generated
5
package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-dialog class="super-flexible-dialog" :title="isDetail ? title.detail : !dataForm.id ? title.add : title.edit" :visible.sync="visible" @close="handleClose">
|
||||
<el-form :model="dataForm" :rules="dataFormRules">
|
||||
<el-form ref="dataForm" :model="dataForm" :rules="dataFormRules">
|
||||
<!-- 如果需要更精细一点的布局,可以根据配置项实现地再复杂一点,但此处暂时全部采用一行两列布局 -->
|
||||
<el-row v-for="n in rows" :key="n" :gutter="20">
|
||||
<el-col v-for="c in COLUMN_PER_ROW" :key="`${n}+'col'+${c}`" :span="24 / COLUMN_PER_ROW">
|
||||
@ -44,10 +44,12 @@
|
||||
</el-form>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button v-for="(operate, index) in configs.operations" :key="`operate-${index}`" :type="btnType[operate.name]" @click="handleClick(operate)">
|
||||
<template v-for="(operate, index) in configs.operations">
|
||||
<!-- {{ operate.name | btnNameFilter }} -->
|
||||
{{ btnName[operate.name] }}
|
||||
</el-button>
|
||||
<el-button v-if="operate.permission ? $hasPermission(operate.permission) : true" :key="`operate-${index}`" :type="btnType[operate.name]" @click="handleClick(operate)">{{
|
||||
btnName[operate.name]
|
||||
}}</el-button>
|
||||
</template>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@ -87,7 +89,7 @@ export default {
|
||||
* type: 'dialog' | 'drawer' | 'page'
|
||||
* fields: Array<string|object>
|
||||
* - 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',
|
||||
|
@ -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: [
|
||||
// {
|
||||
|
@ -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(() => {})
|
||||
})
|
||||
|
@ -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)
|
||||
|
@ -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',
|
||||
|
載入中…
新增問題並參考
Block a user