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