This commit is contained in:
parent
a47e763254
commit
69e9f881da
40
dict/Dict.js
40
dict/Dict.js
|
@ -40,7 +40,7 @@ export default class Dict {
|
|||
r();
|
||||
throw new Error('need dict types')
|
||||
}
|
||||
getRequest(params,this.apiurl).then((res)=>{
|
||||
this.getRequest(params).then((res)=>{
|
||||
if(res&&res.datas){
|
||||
const response=res.datas;
|
||||
sessionStorage.setItem("dictdata",JSON.stringify(response));
|
||||
|
@ -95,7 +95,7 @@ export default class Dict {
|
|||
throw new Error('need dict types')
|
||||
}
|
||||
|
||||
getRequest(params,this.apiurl).then((res)=>{
|
||||
this.getRequest(params).then((res)=>{
|
||||
if(res&&res.datas){
|
||||
const response=res.datas;
|
||||
Object.keys(response).map((k,i)=>{
|
||||
|
@ -173,32 +173,23 @@ export default class Dict {
|
|||
if (dictMeta === undefined) {
|
||||
return Promise.reject(`the dict meta of ${type} was not found`)
|
||||
}
|
||||
return loadDict(this, dictMeta)
|
||||
return this.loadDict(this, dictMeta,this.apiurl)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getRequest(options,apiurl) {
|
||||
getRequest(options) {
|
||||
return request({
|
||||
url: apiurl||"/api/sysdict/get_dict",
|
||||
url: this.apiurl||"/api/sysdict/get_dict",
|
||||
method: 'post',
|
||||
data: {dict_code:Array.isArray(options)?options:[options]}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载字典
|
||||
* @param {Dict} dict 字典
|
||||
* @param {DictMeta} dictMeta 字典元数据
|
||||
* @returns {Promise}
|
||||
*/
|
||||
function loadDict(dict, dictMeta) {
|
||||
return dictMeta.request(dictMeta)
|
||||
.then(response => {
|
||||
loadDict(dict, dictMeta,apiurl) {
|
||||
return request({
|
||||
url: apiurl||"/api/sysdict/get_dict",
|
||||
method: 'post',
|
||||
data: {dict_code:Array.isArray(dictMeta)?options:[dictMeta]}
|
||||
}).then(response => {
|
||||
const type = dictMeta.type
|
||||
|
||||
|
||||
let dicts = dictMeta.responseConverter(response, dictMeta)
|
||||
if (!(dicts instanceof Array)) {
|
||||
console.error('the return of responseConverter must be Array.<DictData>')
|
||||
|
@ -212,5 +203,8 @@ function loadDict(dict, dictMeta) {
|
|||
Vue.set(dict.label[type], d.value, d.label)
|
||||
})
|
||||
return dicts
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ export default function (Vue, options) {
|
|||
return filters&&filters.label || '-'
|
||||
},
|
||||
getDict(name) {
|
||||
new Promise((r)=>{
|
||||
return new Promise((r)=>{
|
||||
this.dict = new Dict(this.apiurl);
|
||||
this.dict.owner = this;
|
||||
if(this.apiurl){
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "erp-element-ui",
|
||||
"version": "1.0.44",
|
||||
"version": "1.0.46",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -10,8 +10,9 @@ import axios from 'axios'
|
|||
import { MessageBox, Message } from 'element-ui';
|
||||
|
||||
// import cancelClass from './cancelToken'
|
||||
console.log(window.VUE_APP_BASE_API,"window.VUE_APP_BASE_API")
|
||||
const service = axios.create({
|
||||
baseURL: window.VUE_APP_BASE_API?window.VUE_APP_BASE_API:"http://dev-erp-api.xtkj99.com:7890", // api 的 base_url
|
||||
baseURL: window.VUE_APP_BASE_API||(process.env.VUE_APP_BASE_API)||"http://dev-erp-api.xtkj99.com:7890", // api 的 base_url
|
||||
timeout: 1000 * 60 * 2 // 接口超时
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue