This commit is contained in:
qsh
2023-03-21 00:53:28 +08:00
parent 953377e655
commit 955687d473
171 changed files with 7149 additions and 7341 deletions

View File

@@ -1,20 +1,20 @@
import Vue from 'vue'
import store from '@/store'
import DataDict from '@/utils/dict'
import { getDicts as getDicts } from '@/api/system/dict/data'
import Vue from 'vue';
import store from '@/store';
import DataDict from '@/utils/dict';
import { getDicts as getDicts } from '@/api/system/dict/data';
function searchDictByKey(dict, key) {
if (key == null && key == "") {
return null
if (key == null && key == '') {
return null;
}
try {
for (let i = 0; i < dict.length; i++) {
if (dict[i].key == key) {
return dict[i].value
return dict[i].value;
}
}
} catch (e) {
return null
return null;
}
}
@@ -25,25 +25,29 @@ function install() {
labelField: 'dictLabel',
valueField: 'dictValue',
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) })
return new Promise((resolve) => {
resolve(storeDict);
});
} else {
return new Promise((resolve, reject) => {
getDicts(dictMeta.type).then(res => {
store.dispatch('dict/setDict', { key: dictMeta.type, value: res.data })
resolve(res.data)
}).catch(error => {
reject(error)
})
})
getDicts(dictMeta.type)
.then((res) => {
store.dispatch('dict/setDict', { key: dictMeta.type, value: res.data });
resolve(res.data);
})
.catch((error) => {
reject(error);
});
});
}
},
},
},
})
}
}
}
});
}
export default {
install,
}
install
};