update 迁移table和modal-form组件,迁移app管理

This commit is contained in:
2021-06-11 22:09:33 +08:00
parent f5bd5e73c8
commit 16a94b7c5a
17 changed files with 1099 additions and 71 deletions

View File

@@ -0,0 +1,42 @@
import { api } from 'common/api'
import { mapKeys } from 'lodash'
import store from 'store'
import { toCamelCase } from 'util/format'
const { getState, dispatch } = store
const getDicData = async (...args) => {
const dicData = getState('dicData')
let result = {}
const code = []
for (let i = 0; i < args.length; i++) {
const codeName = toCamelCase(args[i])
if (!dicData.hasOwnProperty(codeName)) {
code.push(args[i])
} else {
result[codeName] = dicData[codeName]
}
}
if (code.length) {
try {
const value = mapKeys((await api.sysDictTypeDropDowns({ code })).data, (value, key) => {
return toCamelCase(key)
})
dispatch({
type: 'ADD_DIC_DATA',
value
})
result = { ...result, ...value }
return result
}
catch { }
}
return dicData
}
export default getDicData

View File

@@ -16,4 +16,29 @@ export const numberToChinese = (val) => {
const chinanum = overWan ? getWan(overWan) + '万' + getWan(noWan) : getWan(num)
return chinanum
}
/**
* 下划线转驼峰
* @param {String} str
*/
export const toCamelCase = (str) => {
if (typeof str === 'string') {
return str.toLowerCase().split('_').map((p, i) => {
if (i > 0) {
return p[0].toUpperCase() + p.slice(1)
} else {
return p
}
}).join('')
}
return str
}
/**
* 驼峰转下划线
* @param {String} str
*/
export const toUnderScoreCase = (str) => {
}