This commit is contained in:
parent
f510fc328a
commit
fc13e32cd7
20
dict/Dict.js
20
dict/Dict.js
|
@ -3,7 +3,7 @@ import { mergeRecursive } from "./../utils/ruoyi";
|
|||
import DictMeta from './DictMeta'
|
||||
import DictData from './DictData'
|
||||
import { getDicts as getDicts } from './../api/InventoryManagement';
|
||||
|
||||
import request from './../utils/request';
|
||||
|
||||
|
||||
const DEFAULT_DICT_OPTIONS = {
|
||||
|
@ -24,7 +24,7 @@ export default class Dict {
|
|||
this.raw={}
|
||||
}
|
||||
|
||||
init(options) {
|
||||
init(options,apiurl) {
|
||||
return new Promise((r)=>{
|
||||
let params=Object.assign([],options);
|
||||
if (options instanceof Array) {
|
||||
|
@ -36,7 +36,8 @@ export default class Dict {
|
|||
r();
|
||||
throw new Error('need dict types')
|
||||
}
|
||||
getRequest(params).then((res)=>{
|
||||
|
||||
getRequest(params,apiurl).then((res)=>{
|
||||
if(res&&res.datas){
|
||||
const response=res.datas;
|
||||
sessionStorage.setItem("dictdata",JSON.stringify(response));
|
||||
|
@ -174,8 +175,17 @@ export default class Dict {
|
|||
}
|
||||
|
||||
|
||||
function getRequest(options) {
|
||||
return getDicts(options);
|
||||
function getRequest(options,apiurl) {
|
||||
if(apiurl&&apiurl!=""){
|
||||
return request({
|
||||
url: apiurl,
|
||||
method: 'post',
|
||||
data: {dict_code:Array.isArray(dictType)?dictType:[dictType]}
|
||||
})
|
||||
}else{
|
||||
return getDicts(options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ export default function (Vue, options) {
|
|||
if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const dict = new Dict()
|
||||
dict.owner = this
|
||||
return {
|
||||
|
@ -25,7 +26,7 @@ export default function (Vue, options) {
|
|||
let dicttime=sessionStorage.getItem("dicttime");
|
||||
if(dicttime&&new Date().getTime()-Number(dicttime)>1000*60*720){
|
||||
options.onCreated && options.onCreated(this.dict)
|
||||
this.dict.init(this.$options.dicts).then(() => {
|
||||
this.dict.init(this.$options.dicts,this.$options.apiurl).then(() => {
|
||||
this.dictstatus = true;
|
||||
sessionStorage.setItem("dicttime",new Date().getTime());
|
||||
options.onReady && options.onReady(this.dict)
|
||||
|
@ -72,7 +73,7 @@ export default function (Vue, options) {
|
|||
}
|
||||
} else {
|
||||
options.onCreated && options.onCreated(this.dict)
|
||||
this.dict.init(this.$options.dicts).then(() => {
|
||||
this.dict.init(this.$options.dicts,this.$options.apiurl).then(() => {
|
||||
this.dictstatus = true;
|
||||
sessionStorage.setItem("dicttime",new Date().getTime());
|
||||
options.onReady && options.onReady(this.dict)
|
||||
|
|
8
index.js
8
index.js
|
@ -36,10 +36,6 @@ const componentarr = [
|
|||
Configuration
|
||||
];
|
||||
|
||||
let dictapi=DataDict;
|
||||
const setDicturl=(fn)=>{
|
||||
dictapi=fn
|
||||
}
|
||||
const install = function (Vue) {
|
||||
// 判断是否安装
|
||||
if (install.installed) return;
|
||||
|
@ -55,7 +51,7 @@ const install = function (Vue) {
|
|||
valueField: 'dictValue',
|
||||
//这个函数用来请求数据字典的数据,调用 getDicts() 函数,并使用传入的 dictMeta.type 来获取相应类型的数据字典
|
||||
request(dictMeta) {
|
||||
return dictapi(dictMeta.type).then(res => res.datas)
|
||||
return getDicts(dictMeta.type).then(res => res.datas)
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -69,9 +65,7 @@ if (typeof window !== "undefined" && window.Vue) {
|
|||
install(window.Vue);
|
||||
}
|
||||
export default {
|
||||
setDicturl:()=>{},
|
||||
install,
|
||||
...componentarr,
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "erp-element-ui",
|
||||
"version": "1.0.36",
|
||||
"version": "1.0.37",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue