From 3919ce012caf8ab9243cee7db8c6605d0aec788f Mon Sep 17 00:00:00 2001 From: ln1778 <465410291@qq.com> Date: Thu, 20 Jun 2024 15:20:05 +0800 Subject: [PATCH] 211 --- dict/Dict.js | 14 +++++++++----- dict/index.js | 14 +++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/dict/Dict.js b/dict/Dict.js index 3c5d756..49aceda 100644 --- a/dict/Dict.js +++ b/dict/Dict.js @@ -22,9 +22,10 @@ export default class Dict { this.label = {} this.type = {} this.raw={} + this.apiurl="/api/sysdict/get_dict"; } - init(options,apiurl) { + init(options,url) { return new Promise((r)=>{ let params=Object.assign([],options); if (options instanceof Array) { @@ -36,8 +37,11 @@ export default class Dict { r(); throw new Error('need dict types') } - - getRequest(params,apiurl).then((res)=>{ + + if(url){ + this.apiurl=url; + } + getRequest(params).then((res)=>{ if(res&&res.datas){ const response=res.datas; sessionStorage.setItem("dictdata",JSON.stringify(response)); @@ -175,9 +179,9 @@ export default class Dict { } -function getRequest(options,apiurl) { +function 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)?dictType:[options]} }); diff --git a/dict/index.js b/dict/index.js index 00de011..f661ae1 100644 --- a/dict/index.js +++ b/dict/index.js @@ -5,13 +5,20 @@ export default function (Vue, options) { mergeOptions(options) Vue.mixin({ data() { + let apiurl="/api/sysdict/get_dict"; if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) { return {} } - const dict = new Dict() - dict.owner = this + const dict = new Dict(); + if(this.$options.dictapiurl){ + apiurl=this.$options.dictapiurl; + dict.apiurl=this.$options.dictapiurl; + } + dict.owner = this; + return { + apiurl, dict, dictstatus: false, requesttime:0, @@ -112,8 +119,9 @@ export default function (Vue, options) { }, getDict(name) { new Promise((r)=>{ - this.dict = new Dict(); + this.dict = new Dict(); this.dict.owner = this; + this.dict.apiurl=this.apiurl; this.dict.getDict(name).then(() => { r(this.dict); })