Commit a567f555 authored by 刘怀志's avatar 刘怀志

67882 药品库存,剂量、销售单位值更新问题(后期优化)

parent f2188ab4
...@@ -3,20 +3,20 @@ import store from '@/store' ...@@ -3,20 +3,20 @@ import store from '@/store'
import DataDict from '@/utils/dict' import DataDict from '@/utils/dict'
import { getDicts as getDicts } from '@/api/system/dict/data' import { getDicts as getDicts } from '@/api/system/dict/data'
function searchDictByKey(dict, key) { // function searchDictByKey(dict, key) {
if (key == null && key === '') { // if (key == null && key === '') {
return null // return null
} // }
try { // try {
for (let i = 0; i < dict.length; i++) { // for (let i = 0; i < dict.length; i++) {
if (dict[i].key === key) { // if (dict[i].key === key) {
return dict[i].value // return dict[i].value
} // }
} // }
} catch (e) { // } catch (e) {
return null // return null
} // }
} // }
function install() { function install() {
Vue.use(DataDict, { Vue.use(DataDict, {
...@@ -25,10 +25,7 @@ function install() { ...@@ -25,10 +25,7 @@ function install() {
labelField: 'dictLabel', labelField: 'dictLabel',
valueField: 'dictValue', valueField: 'dictValue',
request(dictMeta) { request(dictMeta) {
const storeDict = searchDictByKey(store.getters.dict, dictMeta.type) // const storeDict = searchDictByKey(store.getters.dict, dictMeta.type)
if (storeDict) {
return new Promise(resolve => { resolve(storeDict) })
} else {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getDicts(dictMeta.type).then(res => { getDicts(dictMeta.type).then(res => {
store.dispatch('dict/setDict', { key: dictMeta.type, value: res.data }) store.dispatch('dict/setDict', { key: dictMeta.type, value: res.data })
...@@ -37,7 +34,11 @@ function install() { ...@@ -37,7 +34,11 @@ function install() {
reject(error) reject(error)
}) })
}) })
} // if (storeDict) {
// return new Promise(resolve => { resolve(storeDict) })
// } else {
//
// }
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment