提交 71d7ca90 编写于 作者: ibizdev's avatar ibizdev

ibiz4j 发布系统代码

上级 1d820a20
...@@ -12,6 +12,7 @@ import { authServiceRegister } from '@/authservice/auth-service-register'; ...@@ -12,6 +12,7 @@ import { authServiceRegister } from '@/authservice/auth-service-register';
import { utilServiceRegister } from '@/utilservice/util-service-register'; import { utilServiceRegister } from '@/utilservice/util-service-register';
import { entityServiceRegister } from '@/service/entity-service-register'; import { entityServiceRegister } from '@/service/entity-service-register';
import { counterServiceRegister } from '@/counter/counter-service-register'; import { counterServiceRegister } from '@/counter/counter-service-register';
import { codeListRegister } from '@codelist/codelist-register';
import InputBox from './components/input-box/input-box.vue' import InputBox from './components/input-box/input-box.vue'
import AppKeepAlive from './components/app-keep-alive/app-keep-alive.vue' import AppKeepAlive from './components/app-keep-alive/app-keep-alive.vue'
...@@ -38,6 +39,7 @@ import AppFormGroup from './components/app-form-group/app-form-group.vue' ...@@ -38,6 +39,7 @@ import AppFormGroup from './components/app-form-group/app-form-group.vue'
import AppFormItem from './components/app-form-item/app-form-item.vue' import AppFormItem from './components/app-form-item/app-form-item.vue'
import AppPicker from './components/app-picker/app-picker.vue' import AppPicker from './components/app-picker/app-picker.vue'
import AppMpicker from './components/app-mpicker/app-mpicker.vue' import AppMpicker from './components/app-mpicker/app-mpicker.vue'
import AppUpicker from './components/app-upicker/app-upicker.vue'
import AppFormGroup2 from './components/app-form-group2/app-form-group2.vue' import AppFormGroup2 from './components/app-form-group2/app-form-group2.vue'
import AppFormItem2 from './components/app-form-item2/app-form-item2.vue' import AppFormItem2 from './components/app-form-item2/app-form-item2.vue'
import CodeList from './components/codelist/codelist.vue' import CodeList from './components/codelist/codelist.vue'
...@@ -89,6 +91,8 @@ window['utilServiceRegister'] = utilServiceRegister; ...@@ -89,6 +91,8 @@ window['utilServiceRegister'] = utilServiceRegister;
window['entityServiceRegister'] = entityServiceRegister; window['entityServiceRegister'] = entityServiceRegister;
// 全局挂载计数器服务注册中心 // 全局挂载计数器服务注册中心
window['counterServiceRegister'] = counterServiceRegister; window['counterServiceRegister'] = counterServiceRegister;
// 全局挂载代码表服务注册中心
window['codeListRegister'] = codeListRegister;
export const AppComponents = { export const AppComponents = {
install(v: any, opt: any) { install(v: any, opt: any) {
...@@ -127,6 +131,7 @@ export const AppComponents = { ...@@ -127,6 +131,7 @@ export const AppComponents = {
v.component('app-form-item',AppFormItem); v.component('app-form-item',AppFormItem);
v.component('app-picker', AppPicker); v.component('app-picker', AppPicker);
v.component('app-mpicker', AppMpicker); v.component('app-mpicker', AppMpicker);
v.component('app-upicker', AppUpicker);
v.component('app-form-group2', AppFormGroup2); v.component('app-form-group2', AppFormGroup2);
v.component('app-form-item2', AppFormItem2); v.component('app-form-item2', AppFormItem2);
v.component('codelist', CodeList); v.component('codelist', CodeList);
......
/**
* 代码表服务注册中心
*
* @export
* @class CodeListRegister
*/
export class CodeListRegister {
/**
* 所有实体数据服务Map
*
* @protected
* @type {*}
* @memberof CodeListRegister
*/
protected allCodeList: Map<string, () => Promise<any>> = new Map();
/**
* 已加载实体数据服务Map缓存
*
* @protected
* @type {Map<string, any>}
* @memberof CodeListRegister
*/
protected serviceCache: Map<string, any> = new Map();
/**
* Creates an instance of CodeListRegister.
* @memberof CodeListRegister
*/
constructor() {
this.init();
}
/**
* 初始化
*
* @protected
* @memberof CodeListRegister
*/
protected init(): void {
this.allCodeList.set('SysOperator', () => import('@/codelist/sys-operator'));
}
/**
* 加载实体数据服务
*
* @protected
* @param {string} serviceName
* @returns {Promise<any>}
* @memberof CodeListRegister
*/
protected async loadService(serviceName: string): Promise<any> {
const service = this.allCodeList.get(serviceName);
if (service) {
return service();
}
}
/**
* 获取应用实体数据服务
*
* @param {string} name
* @returns {Promise<any>}
* @memberof CodeListRegister
*/
public async getService(name: string): Promise<any> {
if (this.serviceCache.has(name)) {
return this.serviceCache.get(name);
}
const CodeList: any = await this.loadService(name);
if (CodeList && CodeList.default) {
const instance: any = new CodeList.default();
this.serviceCache.set(name, instance);
return instance;
}
}
}
export const codeListRegister: CodeListRegister = new CodeListRegister();
\ No newline at end of file
...@@ -22,6 +22,14 @@ export default class SysOperator { ...@@ -22,6 +22,14 @@ export default class SysOperator {
*/ */
public expirationTime:any; public expirationTime:any;
/**
* 预定义类型
*
* @type string
* @memberof SysOperator
*/
public predefinedType:string ='OPERATOR';
/** /**
* 缓存超长时长 * 缓存超长时长
* *
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<script lang="ts"> <script lang="ts">
import { Vue, Component, Watch, Prop, Model } from 'vue-property-decorator'; import { Vue, Component, Watch, Prop, Model } from 'vue-property-decorator';
import CodeListService from '@/service/app/codelist-service';
@Component({ @Component({
}) })
export default class AppDepartmentSelect extends Vue { export default class AppDepartmentSelect extends Vue {
...@@ -18,6 +19,20 @@ export default class AppDepartmentSelect extends Vue { ...@@ -18,6 +19,20 @@ export default class AppDepartmentSelect extends Vue {
*/ */
@Prop() public url?: any; @Prop() public url?: any;
/**
* 代码表标识
*
* @memberof AppDepartmentSelect
*/
@Prop() public tag?:string;
/**
* 代码表类型
*
* @memberof AppDepartmentSelect
*/
@Prop() public codelistType?:string;
/** /**
* 过滤项 * 过滤项
* *
...@@ -121,14 +136,14 @@ export default class AppDepartmentSelect extends Vue { ...@@ -121,14 +136,14 @@ export default class AppDepartmentSelect extends Vue {
} }
this.oldurl = _url; this.oldurl = _url;
// 缓存机制 // 缓存机制
const result:any = this.$store.getters.getCopyData(_url); const result:any = this.$store.getters.getDepData(this.filter);
if(result){ if(result){
this.Nodesdata = result; this.Nodesdata = result;
return; return;
} }
this.$http.get(_url).then((response: any) => { this.$http.get(_url).then((response: any) => {
this.Nodesdata = response.data; this.Nodesdata = response.data;
this.$store.commit('addDepData', { srfkey: this.filter, orgData: response.data }); this.$store.commit('addDepData', { srfkey: this.filter, depData: response.data });
}).catch((response: any) => { }).catch((response: any) => {
if (!response || !response.status || !response.data) { if (!response || !response.status || !response.data) {
this.$Notice.error({ title: (this.$t('app.commonWords.error') as string), desc: (this.$t('app.commonWords.sysException') as string) }); this.$Notice.error({ title: (this.$t('app.commonWords.error') as string), desc: (this.$t('app.commonWords.sysException') as string) });
...@@ -163,14 +178,20 @@ export default class AppDepartmentSelect extends Vue { ...@@ -163,14 +178,20 @@ export default class AppDepartmentSelect extends Vue {
// 单选 // 单选
if(!this.multiple){ if(!this.multiple){
if(this.fillMap && Object.keys(this.fillMap).length >0){ if(this.fillMap && Object.keys(this.fillMap).length >0){
let templateValue = {}; let templateValue:any = {};
Object.keys(this.fillMap).forEach((item:any) =>{ Object.keys(this.fillMap).forEach((item:any) =>{
if(this.data && this.data[this.fillMap[item]]){ if(this.data && this.data[this.fillMap[item]]){
Object.assign(templateValue,{[item]:this.data[this.fillMap[item]]}); Object.assign(templateValue,{[item]:this.data[this.fillMap[item]]});
} }
}) })
if(!templateValue.label && templateValue.id && this.tag && this.codelistType && Object.is(this.codelistType,"DYNAMIC")){
this.fillLabel(templateValue,templateValue.id,(templateValue:any) =>{
this.selectTreeValue = JSON.stringify([templateValue]);
});
}else{
this.selectTreeValue = JSON.stringify([templateValue]); this.selectTreeValue = JSON.stringify([templateValue]);
} }
}
}else{ }else{
// 多选 // 多选
if(this.fillMap && Object.keys(this.fillMap).length >0){ if(this.fillMap && Object.keys(this.fillMap).length >0){
...@@ -188,10 +209,32 @@ export default class AppDepartmentSelect extends Vue { ...@@ -188,10 +209,32 @@ export default class AppDepartmentSelect extends Vue {
}) })
} }
}) })
let tempflag:boolean = false;
if(tempArray.length >0 && tempArray.length >0){
tempArray.forEach((item:any) =>{
if(!item.label) tempflag = true;
})
}
if(tempflag && this.tag && this.codelistType && Object.is(this.codelistType,"DYNAMIC")){
let tempStatus:number = 0;
tempArray.forEach((item:any) =>{
if(!item.label){
tempStatus += 1;
this.fillLabel(item,item.id,(result:any) =>{
item = result;
tempStatus -= 1;
if(tempStatus === 0){
this.selectTreeValue = JSON.stringify(tempArray);
}
})
}
})
}else{
this.selectTreeValue = JSON.stringify(tempArray); this.selectTreeValue = JSON.stringify(tempArray);
} }
} }
} }
}
/** /**
* select事件处理 * select事件处理
...@@ -208,10 +251,35 @@ export default class AppDepartmentSelect extends Vue { ...@@ -208,10 +251,35 @@ export default class AppDepartmentSelect extends Vue {
let _name = this.fillMap[attribute]; let _name = this.fillMap[attribute];
let values = selectArr.map((item:any) => item[attribute]); let values = selectArr.map((item:any) => item[attribute]);
let _value = $event === "[]" ? null : values.join(","); let _value = $event === "[]" ? null : values.join(",");
this.$emit('select-change',{name: this.fillMap[attribute], value: _value}) setTimeout(() => {
this.$emit('select-change',{name: this.fillMap[attribute], value: _value});
},0);
}); });
} }
} }
/**
* 填充label
*
* @memberof AppOrgSelect
*/
public fillLabel(tempObject:any,valueItem:any,callback:any){
if(!tempObject.label && tempObject.id && this.tag && this.codelistType && Object.is(this.codelistType,"DYNAMIC")){
let codeListService:CodeListService = new CodeListService();
codeListService.getItems(this.tag).then((items:any) =>{
if(items && items.length >0){
let result:any = items.find((item:any) =>{
return item.id === valueItem;
})
Object.assign(tempObject,{label:result.label});
}
callback(tempObject);
}).catch((error:any) =>{
console.log(error);
})
}
}
} }
</script> </script>
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
<script lang = 'ts'> <script lang = 'ts'>
import { Vue, Component, Prop, Watch } from "vue-property-decorator"; import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import { Http } from '@/utils'; import { Http } from '@/utils';
import CodeListService from "@service/app/codelist-service";
import { observable } from 'rxjs';
@Component({}) @Component({})
export default class AppOrgSelect extends Vue { export default class AppOrgSelect extends Vue {
...@@ -37,6 +39,20 @@ export default class AppOrgSelect extends Vue { ...@@ -37,6 +39,20 @@ export default class AppOrgSelect extends Vue {
*/ */
@Prop() public filter?:string; @Prop() public filter?:string;
/**
* 代码表标识
*
* @memberof AppOrgSelect
*/
@Prop() public tag?:string;
/**
* 代码表类型
*
* @memberof AppOrgSelect
*/
@Prop() public codelistType?:string;
/** /**
* 是否多选 * 是否多选
* *
...@@ -138,14 +154,20 @@ export default class AppOrgSelect extends Vue { ...@@ -138,14 +154,20 @@ export default class AppOrgSelect extends Vue {
// 单选 // 单选
if(!this.multiple){ if(!this.multiple){
if(this.fillMap && Object.keys(this.fillMap).length >0){ if(this.fillMap && Object.keys(this.fillMap).length >0){
let templateValue = {}; let templateValue:any = {};
Object.keys(this.fillMap).forEach((item:any) =>{ Object.keys(this.fillMap).forEach((item:any) =>{
if(this.data && this.data[this.fillMap[item]]){ if(this.data && this.data[this.fillMap[item]]){
Object.assign(templateValue,{[item]:this.data[this.fillMap[item]]}); Object.assign(templateValue,{[item]:this.data[this.fillMap[item]]});
} }
}) })
if(!templateValue.label && templateValue.id && this.tag && this.codelistType && Object.is(this.codelistType,"DYNAMIC")){
this.fillLabel(templateValue,templateValue.id,(templateValue:any) =>{
this.selectTreeValue = JSON.stringify([templateValue]);
});
}else{
this.selectTreeValue = JSON.stringify([templateValue]); this.selectTreeValue = JSON.stringify([templateValue]);
} }
}
}else{ }else{
// 多选 // 多选
if(this.fillMap && Object.keys(this.fillMap).length >0){ if(this.fillMap && Object.keys(this.fillMap).length >0){
...@@ -163,10 +185,32 @@ export default class AppOrgSelect extends Vue { ...@@ -163,10 +185,32 @@ export default class AppOrgSelect extends Vue {
}) })
} }
}) })
let tempflag:boolean = false;
if(tempArray.length >0 && tempArray.length >0){
tempArray.forEach((item:any) =>{
if(!item.label) tempflag = true;
})
}
if(tempflag && this.tag && this.codelistType && Object.is(this.codelistType,"DYNAMIC")){
let tempStatus:number = 0;
tempArray.forEach((item:any) =>{
if(!item.label){
tempStatus += 1;
this.fillLabel(item,item.id,(result:any) =>{
item = result;
tempStatus -= 1;
if(tempStatus === 0){
this.selectTreeValue = JSON.stringify(tempArray);
}
})
}
})
}else{
this.selectTreeValue = JSON.stringify(tempArray); this.selectTreeValue = JSON.stringify(tempArray);
} }
} }
} }
}
/** /**
* 加载树数据 * 加载树数据
...@@ -175,7 +219,7 @@ export default class AppOrgSelect extends Vue { ...@@ -175,7 +219,7 @@ export default class AppOrgSelect extends Vue {
*/ */
public loadTreeData(requestUrl:string){ public loadTreeData(requestUrl:string){
if(this.filter){ if(this.filter){
const result:any = this.$store.getters.getCopyData(this.filter); const result:any = this.$store.getters.getOrgData(this.filter);
if(result){ if(result){
this.NodesData = result; this.NodesData = result;
return; return;
...@@ -209,7 +253,9 @@ export default class AppOrgSelect extends Vue { ...@@ -209,7 +253,9 @@ export default class AppOrgSelect extends Vue {
tempValue.forEach((value:any,index:number) =>{ tempValue.forEach((value:any,index:number) =>{
tempResult += index>0?`,${value[item]}`:`${value[item]}`; tempResult += index>0?`,${value[item]}`:`${value[item]}`;
}) })
setTimeout(() => {
this.emitValue(this.fillMap[item],tempResult); this.emitValue(this.fillMap[item],tempResult);
}, 0);
}) })
} }
}else{ }else{
...@@ -225,7 +271,9 @@ export default class AppOrgSelect extends Vue { ...@@ -225,7 +271,9 @@ export default class AppOrgSelect extends Vue {
const tempValue:any = JSON.parse($event)[0]; const tempValue:any = JSON.parse($event)[0];
if(this.fillMap && Object.keys(this.fillMap).length >0){ if(this.fillMap && Object.keys(this.fillMap).length >0){
Object.keys(this.fillMap).forEach((item:any) =>{ Object.keys(this.fillMap).forEach((item:any) =>{
setTimeout(() => {
this.emitValue(this.fillMap[item],tempValue[item]); this.emitValue(this.fillMap[item],tempValue[item]);
}, 0);
}) })
} }
}else{ }else{
...@@ -247,6 +295,28 @@ export default class AppOrgSelect extends Vue { ...@@ -247,6 +295,28 @@ export default class AppOrgSelect extends Vue {
this.$emit('select-change',{name:name,value:value}); this.$emit('select-change',{name:name,value:value});
} }
/**
* 填充label
*
* @memberof AppOrgSelect
*/
public fillLabel(tempObject:any,valueItem:any,callback:any){
if(!tempObject.label && tempObject.id && this.tag && this.codelistType && Object.is(this.codelistType,"DYNAMIC")){
let codeListService:CodeListService = new CodeListService();
codeListService.getItems(this.tag).then((items:any) =>{
if(items && items.length >0){
let result:any = items.find((item:any) =>{
return item.id === valueItem;
})
Object.assign(tempObject,{label:result.label});
}
callback(tempObject);
}).catch((error:any) =>{
console.log(error);
})
}
}
} }
</script> </script>
......
.app-picker {
width: 100%;
.el-select {
.el-input__suffix {
right: 20px;
}
}
.text-value {
.el-icon-circle-close {
display: none;
}
}
.text-value:hover {
.el-icon-circle-close {
display: inline-block;
}
}
.ivu-icon-ios-open-outline {
margin-top: -2px;
margin-left: 5px;
font-size: 15px;
}
}
\ No newline at end of file
<template>
<el-select style="width: 100%;" size='small' @change="onSelect" v-model="value" :disabled="disabled" @visible-change="onSelectOpen">
<el-option v-for="(item, index) in items" :key="index" :label="item.label" :value="item.value"></el-option>
</el-select>
</template>
<script lang="ts">
import { Component, Vue, Prop, Model, Watch } from "vue-property-decorator";
import { Subject } from "rxjs";
import { AppModal } from "@/utils";
@Component({})
export default class AppPicker extends Vue {
/**
* 表单数据
*
* @type {*}
* @memberof AppPicker
*/
@Prop() public data!: any;
/**
* 属性项名称
*
* @type {string}
* @memberof AppPicker
*/
@Prop() public name!: string;
/**
* 视图上下文
*
* @type {*}
* @memberof AppFormDRUIPart
*/
@Prop() public context!: any;
/**
* 编辑器禁用
*
* @type {boolean}
* @memberof AppUpicker
*/
@Prop() disabled?: boolean;
/**
* 视图参数
*
* @type {*}
* @memberof SelectFormBase
*/
@Prop() public viewparams: any;
/**
* 请求参数和请求数据的映射关系
*
* @type {*}
* @memberof AppUpicker
*/
public interaction:any = {};
/**
* 当前表单项绑定的值
*
* @type {string}
* @memberof AppUpicker
*/
public value: string = "";
/**
* 编辑器参数
*
* @type {*}
* @memberof AppUpicker
*/
@Prop() public itemParams?: any;
/**
* 编辑器参数
*
* @type {string}
* @memberof AppUpicker
*/
@Prop() public valueItem?: string;
/**
* 列表项请求路径
*
* @type {string}
* @memberof AppUpicker
*/
public url: string = '';
/**
* 下拉数组
* @type {any[]}
* @memberof AppPicker
*/
public items: any[] = [];
/**
* 请求到的数据
* @type {any[]}
* @memberof AppPicker
*/
public itemList: any[] = [{a:1,b:"zhangsan"},{a:2,b:"lisi"},{a:3,b:"wangwu"}]
/**
* vue 生命周期
*
* @memberof AppPicker
*/
public mounted() {
// 解析编辑器参数
this.analysis(this.itemParams);
// 请求下拉数据
this.fectchItemList(this.url);
}
/**
* 下拉重新加载数据
*
* @memberof AppPicker
*/
public onSelectOpen() {
this.fectchItemList(this.url);
}
/**
* 解析编辑器参数
* @param {*} itemparams
* @memberof AppPicker
*/
public analysis(itemparams:any) {
Object.keys(itemparams).forEach((param)=>{
if(param==='path'){
this.url = itemparams[param]
}else{
this.interaction[param] = itemparams[param]
}
})
}
/**
* 请求下拉列表数据
* @param {string} url
* @memberof AppPicker
*/
public fectchItemList(url:string) {
this.$http
.get(url)
.then((response: any) => {
if (response && response.status==200 && response.data) {
this.itemList = response.data;
// 提取需要的值(value,label)
this.extractItem(this.itemList,this.items);
}
})
.catch((response: any) => {
if (!response || !response.status || !response.data) {
this.$Notice.error({
title: this.$t("app.commonWords.error") as string,
desc: this.$t("app.commonWords.sysException") as string,
});
return;
}
});
}
/**
* 解析下拉列表数据
* @param {any[]} itemList 请求到的数据
* @param {any[]} items 下拉数组
* @memberof AppPicker
*/
public extractItem(itemList:any[],items:any[]) {
this.items.length = 0;
itemList.forEach((item) => {
items.push({
label: item[this.interaction.label],
value: item[this.interaction.value],
});
});
}
public onSelect(val: string) {
let index = this.items.findIndex((item) => Object.is(item.value, val));
if (index >= 0) {
this.onACSelect(this.items[index]);
}
}
/**
* 选中数据回调
* @param item
*/
public onACSelect(item: any): void {
if(this.name){
this.$emit('formitemvaluechange', { name: this.name, value: item.value });
}
if(this.valueItem){
this.$emit('formitemvaluechange', { name: this.valueItem, value: item.value });
}
}
}
</script>
<style lang="less">
@import './app-upicker.less';
</style>
.ivu-select-multiple .ivu-select-item-selected:after{ .ivu-select-multiple .ivu-select-item-selected:after{
display: none; display: none;
} }
.dropdown-list-mpicker-container{
.tree-dropdown-list-mpicker{
width: 100%;
.el-input__inner{
height: 32px !important;
line-height: 32px !important;
}
.el-input__icon{
line-height: 32px;
}
}
}
<template> <template>
<div class="dropdown-list-mpicker-container">
<i-select <i-select
v-if="!hasChildren"
class='dropdown-list-mpicker' class='dropdown-list-mpicker'
multiple multiple
:transfer="true" :transfer="true"
...@@ -16,11 +18,14 @@ ...@@ -16,11 +18,14 @@
</Checkbox> </Checkbox>
</i-option> </i-option>
</i-select> </i-select>
<ibiz-select-tree v-if="hasChildren" class="tree-dropdown-list-mpicker" :disabled="disabled" :NodesData="items" v-model="currentVal" :multiple="true"></ibiz-select-tree>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Vue, Component, Prop, Model } from 'vue-property-decorator'; import { Vue, Component, Prop, Model } from 'vue-property-decorator';
import CodeListService from "@service/app/codelist-service"; import CodeListService from "@service/app/codelist-service";
import { Util } from '@/utils';
@Component({ @Component({
}) })
export default class DropDownListMpicker extends Vue { export default class DropDownListMpicker extends Vue {
...@@ -32,6 +37,13 @@ export default class DropDownListMpicker extends Vue { ...@@ -32,6 +37,13 @@ export default class DropDownListMpicker extends Vue {
*/ */
public codeListService:CodeListService = new CodeListService({ $store: this.$store }); public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 是否有子集
* @type {boolean}
* @memberof DropDownListMpicker
*/
public hasChildren:boolean = false;
/** /**
* 当前选中值 * 当前选中值
* @type {any} * @type {any}
...@@ -131,6 +143,14 @@ export default class DropDownListMpicker extends Vue { ...@@ -131,6 +143,14 @@ export default class DropDownListMpicker extends Vue {
* @memberof DropDownListMpicker * @memberof DropDownListMpicker
*/ */
set currentVal(val: any) { set currentVal(val: any) {
if(this.hasChildren && val){
let tempVal:any = JSON.parse(val);
if(tempVal.length >0){
val = tempVal.map((item:any) =>{
return item.value;
})
}
}
const type: string = this.$util.typeOf(val); const type: string = this.$util.typeOf(val);
val = Object.is(type, 'null') || Object.is(type, 'undefined') ? [] : val; val = Object.is(type, 'null') || Object.is(type, 'undefined') ? [] : val;
let value = val.length > 0 ? val.join(this.valueSeparator) : ''; let value = val.length > 0 ? val.join(this.valueSeparator) : '';
...@@ -143,9 +163,45 @@ export default class DropDownListMpicker extends Vue { ...@@ -143,9 +163,45 @@ export default class DropDownListMpicker extends Vue {
* @memberof DropDownListMpicker * @memberof DropDownListMpicker
*/ */
get currentVal() { get currentVal() {
if(this.hasChildren){
if(this.itemValue){
let list:Array<any> = [];
let selectedvalueArray:Array<any> = [];
let curSelectedValue:Array<any> = this.itemValue.split(this.valueSeparator);
this.getItemList(list,this.items);
if(curSelectedValue.length > 0){
curSelectedValue.forEach((selectedVal:any) =>{
let tempResult:any = list.find((item:any) =>{
return item.value == selectedVal;
})
selectedvalueArray.push(tempResult);
})
}
return selectedvalueArray.length >0?JSON.stringify(selectedvalueArray):null;
}else{
return null;
}
}
return this.itemValue? this.itemValue.split(this.valueSeparator):[]; return this.itemValue? this.itemValue.split(this.valueSeparator):[];
} }
/**
* 获取代码表列表
*
* @memberof DropDownListMpicker
*/
public getItemList(list:Array<any>,items:Array<any>){
if(items && items.length >0){
items.forEach((item:any) =>{
if(item.children){
this.getItemList(list,item.children);
}
list.push(item);
})
}
}
/** /**
* 代码表 * 代码表
* *
...@@ -186,6 +242,7 @@ export default class DropDownListMpicker extends Vue { ...@@ -186,6 +242,7 @@ export default class DropDownListMpicker extends Vue {
const codelist = this.$store.getters.getCodeList(this.tag); const codelist = this.$store.getters.getCodeList(this.tag);
if (codelist) { if (codelist) {
this.items = [...JSON.parse(JSON.stringify(codelist.items))]; this.items = [...JSON.parse(JSON.stringify(codelist.items))];
this.handleLevelCodeList(Util.deepCopy(this.items));
} else { } else {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`);
} }
...@@ -198,6 +255,7 @@ export default class DropDownListMpicker extends Vue { ...@@ -198,6 +255,7 @@ export default class DropDownListMpicker extends Vue {
let _param = data.param; let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => { this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
this.items = res; this.items = res;
this.handleLevelCodeList(Util.deepCopy(this.items));
}).catch((error:any) => { }).catch((error:any) => {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`);
}); });
...@@ -220,11 +278,57 @@ export default class DropDownListMpicker extends Vue { ...@@ -220,11 +278,57 @@ export default class DropDownListMpicker extends Vue {
let _param = data.param; let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => { this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
this.items = res; this.items = res;
this.handleLevelCodeList(Util.deepCopy(this.items));
}).catch((error:any) => { }).catch((error:any) => {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`); console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`);
}); });
} }
} }
/**
* 处理层级代码表
*
* @param {*} items
* @memberof DropDownListMpicker
*/
public handleLevelCodeList(items: Array<any>){
if(items && items.length >0){
this.hasChildren = items.some((item:any) =>{
return item.pvalue;
})
if(this.hasChildren){
let list:Array<any> = [];
items.forEach((codeItem:any) =>{
if(!codeItem.pvalue){
let valueField:string = codeItem.value;
this.setChildCodeItems(valueField,items,codeItem);
list.push(codeItem);
}
})
this.items = list;
}
}
}
/**
* 计算子类代码表
*
* @param {*} items
* @memberof DropDownListMpicker
*/
public setChildCodeItems(pValue:string,result:Array<any>,codeItem:any){
result.forEach((item:any) =>{
if(item.pvalue == pValue){
let valueField:string = item.value;
this.setChildCodeItems(valueField,result,item);
if(!codeItem.children){
codeItem.children = [];
}
codeItem.children.push(item);
}
})
}
} }
</script> </script>
......
.dropdown-list{ .dropdown-list-container{
.dropdown-list{
display: inline-block; display: inline-block;
}
.tree-dropdown-list{
width: 100%;
.el-input__inner{
height: 32px !important;
line-height: 32px !important;
}
.el-input__icon{
line-height: 32px;
}
}
} }
\ No newline at end of file
<template> <template>
<i-select <div class="dropdown-list-container">
<i-select v-if="!hasChildren"
class='dropdown-list' class='dropdown-list'
:transfer="true" :transfer="true"
v-model="currentVal" v-model="currentVal"
...@@ -10,11 +11,14 @@ ...@@ -10,11 +11,14 @@
:placeholder="$t('components.dropDownList.placeholder')"> :placeholder="$t('components.dropDownList.placeholder')">
<i-option v-for="(item, index) in items" :key="index" :value="item.value">{{($t('codelist.'+tag+'.'+item.value)!== ('codelist.'+tag+'.'+item.value))?$t('codelist.'+tag+'.'+item.value) : item.text}}</i-option> <i-option v-for="(item, index) in items" :key="index" :value="item.value">{{($t('codelist.'+tag+'.'+item.value)!== ('codelist.'+tag+'.'+item.value))?$t('codelist.'+tag+'.'+item.value) : item.text}}</i-option>
</i-select> </i-select>
<ibiz-select-tree v-if="hasChildren" class="tree-dropdown-list" :disabled="disabled" :NodesData="items" v-model="currentVal" :multiple="false"></ibiz-select-tree>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Vue, Component, Watch, Prop, Model } from 'vue-property-decorator'; import { Vue, Component, Watch, Prop, Model } from 'vue-property-decorator';
import CodeListService from "@service/app/codelist-service"; import CodeListService from "@service/app/codelist-service";
import { Util } from '@/utils';
@Component({ @Component({
}) })
...@@ -42,6 +46,13 @@ export default class DropDownList extends Vue { ...@@ -42,6 +46,13 @@ export default class DropDownList extends Vue {
*/ */
public queryParam:any; public queryParam:any;
/**
* 是否有子集
* @type {boolean}
* @memberof DropDownList
*/
public hasChildren:boolean = false;
/** /**
* 当前选中值 * 当前选中值
* @type {any} * @type {any}
...@@ -152,6 +163,10 @@ export default class DropDownList extends Vue { ...@@ -152,6 +163,10 @@ export default class DropDownList extends Vue {
* @memberof DropDownList * @memberof DropDownList
*/ */
set currentVal(val: any) { set currentVal(val: any) {
if(this.hasChildren && val){
let tempVal:any = JSON.parse(val);
val = tempVal.length >0?tempVal[0].value:null;
}
const type: string = this.$util.typeOf(val); const type: string = this.$util.typeOf(val);
val = Object.is(type, 'null') || Object.is(type, 'undefined') ? undefined : val; val = Object.is(type, 'null') || Object.is(type, 'undefined') ? undefined : val;
this.$emit('change', val); this.$emit('change', val);
...@@ -163,9 +178,33 @@ export default class DropDownList extends Vue { ...@@ -163,9 +178,33 @@ export default class DropDownList extends Vue {
* @memberof DropDownList * @memberof DropDownList
*/ */
get currentVal() { get currentVal() {
if(this.hasChildren && this.itemValue){
let list:Array<any> = [];
this.getItemList(list,this.items);
let result:any = list.find((item:any) =>{
return item.value == this.itemValue;
})
return JSON.stringify([result]);
}
return this.itemValue; return this.itemValue;
} }
/**
* 获取代码表列表
*
* @memberof DropDownList
*/
public getItemList(list:Array<any>,items:Array<any>){
if(items && items.length >0){
items.forEach((item:any) =>{
if(item.children){
this.getItemList(list,item.children);
}
list.push(item);
})
}
}
/** /**
* 代码表 * 代码表
* *
...@@ -287,6 +326,51 @@ export default class DropDownList extends Vue { ...@@ -287,6 +326,51 @@ export default class DropDownList extends Vue {
}catch(error){ }catch(error){
console.warn('代码表值类型和属性类型不匹配,自动强制转换异常,请修正代码表值类型和属性类型匹配'); console.warn('代码表值类型和属性类型不匹配,自动强制转换异常,请修正代码表值类型和属性类型匹配');
} }
this.handleLevelCodeList(Util.deepCopy(this.items));
}
/**
* 处理层级代码表
*
* @param {*} items
* @memberof DropDownList
*/
public handleLevelCodeList(items: Array<any>){
if(items && items.length >0){
this.hasChildren = items.some((item:any) =>{
return item.pvalue;
})
if(this.hasChildren){
let list:Array<any> = [];
items.forEach((codeItem:any) =>{
if(!codeItem.pvalue){
let valueField:string = codeItem.value;
this.setChildCodeItems(valueField,items,codeItem);
list.push(codeItem);
}
})
this.items = list;
}
}
}
/**
* 计算子类代码表
*
* @param {*} items
* @memberof DropDownList
*/
public setChildCodeItems(pValue:string,result:Array<any>,codeItem:any){
result.forEach((item:any) =>{
if(item.pvalue == pValue){
let valueField:string = item.value;
this.setChildCodeItems(valueField,result,item);
if(!codeItem.children){
codeItem.children = [];
}
codeItem.children.push(item);
}
})
} }
} }
</script> </script>
......
...@@ -3,13 +3,14 @@ import { AuthServiceRegister } from '@/authservice/auth-service-register'; ...@@ -3,13 +3,14 @@ import { AuthServiceRegister } from '@/authservice/auth-service-register';
import { UtilServiceRegister } from '@/utilservice/util-service-register'; import { UtilServiceRegister } from '@/utilservice/util-service-register';
import { EntityServiceRegister } from '@/service/entity-service-register'; import { EntityServiceRegister } from '@/service/entity-service-register';
import { CounterServiceRegister } from '@/counter/counter-service-register'; import { CounterServiceRegister } from '@/counter/counter-service-register';
import { CodeListRegister } from '@codelist/codelist-register';
declare global { declare global {
interface Window { interface Window {
uiServiceRegister: UIServiceRegister, uiServiceRegister: UIServiceRegister,
authServiceRegister: AuthServiceRegister, authServiceRegister: AuthServiceRegister,
utilServiceRegister: UtilServiceRegister, utilServiceRegister: UtilServiceRegister,
entityServiceRegister: EntityServiceRegister, entityServiceRegister: EntityServiceRegister,
counterServiceRegister: CounterServiceRegister counterServiceRegister: CounterServiceRegister,
codeListRegister:CodeListRegister
} }
} }
\ No newline at end of file
import SysOperator from '@/codelist/sys-operator'; import store from '@/store';
import { Store } from 'vuex'; import EntityService from '../entity-service';
/** /**
* 动态代码表服务类 * 动态代码表服务类
...@@ -16,10 +16,10 @@ export default class CodeListService { ...@@ -16,10 +16,10 @@ export default class CodeListService {
* @type {(any | null)} * @type {(any | null)}
* @memberof CodeListService * @memberof CodeListService
*/ */
private $store: Store<any> | null = null; private $store: any;
constructor(opts: any = {}) { constructor(opts: any = {}) {
this.$store = opts.$store; this.$store = store;
} }
/** /**
...@@ -28,7 +28,7 @@ export default class CodeListService { ...@@ -28,7 +28,7 @@ export default class CodeListService {
* @returns {(any | null)} * @returns {(any | null)}
* @memberof CodeListService * @memberof CodeListService
*/ */
public getStore(): Store<any> | null { public getStore(): any {
return this.$store; return this.$store;
} }
...@@ -49,14 +49,79 @@ export default class CodeListService { ...@@ -49,14 +49,79 @@ export default class CodeListService {
*/ */
public static codelistCached:Map<string,any> = new Map(); public static codelistCached:Map<string,any> = new Map();
/**
* 数据服务基类
*
* @type {Minorentity}
* @memberof CodeListService
*/
public entityService:EntityService = new EntityService();
/** /**
* 代码表--云系统操作者 * 获取代码表服务
* *
* @type {SysOperator} * @protected
* @param {string} name 实体名称
* @returns {Promise<any>}
* @memberof EntityService
*/
public getService(name: string): Promise<any> {
return (window as any)['codeListRegister'].getService(name);
}
/**
* 获取静态代码表
*
* @param {string} tag 代码表标识
* @returns {Promise<any[]>}
* @memberof CodeListService * @memberof CodeListService
*/ */
public SysOperator: SysOperator = new SysOperator(); public getStaticItems(tag: string):Promise<any[]>{
return new Promise((resolve:any,reject:any) =>{
const codelist = this.$store.getters.getCodeList(tag);
if (codelist) {
let items: Array<any> = [...JSON.parse(JSON.stringify(codelist.items))];
resolve(items);
}
})
}
/**
* 获取预定义代码表
*
* @param {string} tag 代码表标识
* @returns {Promise<any[]>}
* @memberof CodeListService
*/
public getPredefinedItems(tag: string,data?: any, isloading?: boolean):Promise<any[]>{
return new Promise((resolve:any,reject:any) =>{
if(CodeListService.codelistCached.get(`${tag}`)){
let items:any = CodeListService.codelistCached.get(`${tag}`).items;
if(items.length >0) resolve(items);
}
const callback:Function = (tag:string,promise:Promise<any>) =>{
promise.then((res:any) =>{
let result:any = res.data;
if(result.items && result.items.length > 0){
CodeListService.codelistCached.set(`${tag}`,{items:result.items});
return resolve(result.items);
}else{
return resolve([]);
}
}).catch((result:any) =>{
return reject(result);
})
}
// 加载中,UI又需要数据,解决连续加载同一代码表问题
if(CodeListService.codelistCache.get(`${tag}`)){
callback(tag,CodeListService.codelistCache.get(`${tag}`));
}else{
let result:Promise<any> = this.entityService.getPredefinedCodelist(tag);
CodeListService.codelistCache.set(`${tag}`,result);
callback(tag,result);
}
})
}
/** /**
* 获取动态代码表 * 获取动态代码表
...@@ -66,25 +131,32 @@ export default class CodeListService { ...@@ -66,25 +131,32 @@ export default class CodeListService {
* @returns {Promise<any[]>} * @returns {Promise<any[]>}
* @memberof CodeListService * @memberof CodeListService
*/ */
public getItems(tag: string,context:any = {}, data?: any, isloading?: boolean,): Promise<any[]> { public getItems(tag: string,context:any = {}, data?: any, isloading?: boolean): Promise<any[]> {
let _this: any = this; let _this: any = this;
if(context && context.srfsessionid){ if(context && context.srfsessionid){
delete context.srfsessionid; delete context.srfsessionid;
} }
let isEnableCache:boolean = _this[tag].isEnableCache;
let cacheTimeout:any = _this[tag].cacheTimeout;
return new Promise((resolve:any,reject:any) =>{ return new Promise((resolve:any,reject:any) =>{
this.getService(tag).then((codelist:any) =>{
if(Object.is(codelist.predefinedType,"RUNTIME")){
this.getPredefinedItems(tag).then((res:any) =>{
resolve(res);
})
return;
}
let isEnableCache:boolean = codelist.isEnableCache;
let cacheTimeout:any = codelist.cacheTimeout;
// 启用缓存 // 启用缓存
if(isEnableCache){ if(isEnableCache){
// 加载完成,从本地缓存获取 // 加载完成,从本地缓存获取
if(CodeListService.codelistCached.get(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`)){ if(CodeListService.codelistCached.get(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`)){
let items:any = CodeListService.codelistCached.get(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`); let items:any = CodeListService.codelistCached.get(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`).items;
if(items.length >0){ if(items.length >0){
if(cacheTimeout !== -1){ if(cacheTimeout !== -1){
if(new Date().getTime() > _this[tag].expirationTime){ if(new Date().getTime() > codelist.expirationTime){
_this[tag].getItems(context,data,isloading).then((result:any) =>{ codelist.getItems(context,data,isloading).then((result:any) =>{
CodeListService.codelistCached.set(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`,{items:result}); CodeListService.codelistCached.set(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`,{items:result});
_this[tag].expirationTime = new Date().getTime() + cacheTimeout; codelist.expirationTime = new Date().getTime() + cacheTimeout;
resolve(result); resolve(result);
}).catch((error:any) =>{ }).catch((error:any) =>{
Promise.reject([]); Promise.reject([]);
...@@ -97,10 +169,9 @@ export default class CodeListService { ...@@ -97,10 +169,9 @@ export default class CodeListService {
} }
} }
} }
if (_this[tag]) { if (codelist) {
const callback:Function = (context:any ={},data:any ={},tag:string,promise:Promise<any>) =>{ const callback:Function = (context:any ={},data:any ={},tag:string,promise:Promise<any>) =>{
promise.then((result:any) =>{ promise.then((result:any) =>{
console.log()
if(result.length > 0){ if(result.length > 0){
CodeListService.codelistCached.set(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`,{items:result}); CodeListService.codelistCached.set(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`,{items:result});
return resolve(result); return resolve(result);
...@@ -115,17 +186,17 @@ export default class CodeListService { ...@@ -115,17 +186,17 @@ export default class CodeListService {
if(CodeListService.codelistCache.get(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`)){ if(CodeListService.codelistCache.get(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`)){
callback(context,data,tag,CodeListService.codelistCache.get(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`)); callback(context,data,tag,CodeListService.codelistCache.get(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`));
}else{ }else{
let result:Promise<any> = _this[tag].getItems(context,data,isloading); let result:Promise<any> = codelist.getItems(context,data,isloading);
CodeListService.codelistCache.set(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`,result); CodeListService.codelistCache.set(`${JSON.stringify(context)}-${JSON.stringify(data)}-${tag}`,result);
if(cacheTimeout !== -1){ if(cacheTimeout !== -1){
_this[tag].expirationTime = new Date().getTime() + cacheTimeout; codelist.expirationTime = new Date().getTime() + cacheTimeout;
} }
callback(context,data,tag,result); callback(context,data,tag,result);
} }
} }
}else{ }else{
if (_this[tag]) { if (codelist) {
_this[tag].getItems(context,data,isloading).then((result:any) =>{ codelist.getItems(context,data,isloading).then((result:any) =>{
resolve(result); resolve(result);
}).catch((error:any) =>{ }).catch((error:any) =>{
Promise.reject([]); Promise.reject([]);
...@@ -134,6 +205,10 @@ export default class CodeListService { ...@@ -134,6 +205,10 @@ export default class CodeListService {
return Promise.reject([]); return Promise.reject([]);
} }
} }
}).catch((error:any) =>{
console.warn("获取代码表异常");
return Promise.reject([]);
})
}) })
} }
} }
\ No newline at end of file
import { Store } from 'vuex';
import { Http } from '@/utils'; import { Http } from '@/utils';
import CodeListService from "@service/app/codelist-service"; import CodeListService from "@service/app/codelist-service";
...@@ -10,15 +9,6 @@ import CodeListService from "@service/app/codelist-service"; ...@@ -10,15 +9,6 @@ import CodeListService from "@service/app/codelist-service";
*/ */
export default class EntityService { export default class EntityService {
/**
* Vue 状态管理器
*
* @private
* @type {(any | null)}
* @memberof EntityService
*/
private $store: Store<any> | null = null;
/** /**
* 获取实体数据服务 * 获取实体数据服务
* *
...@@ -101,21 +91,10 @@ export default class EntityService { ...@@ -101,21 +91,10 @@ export default class EntityService {
* @memberof EntityService * @memberof EntityService
*/ */
constructor(opts: any = {}) { constructor(opts: any = {}) {
this.$store = opts.$store;
this.tempStorage = localStorage; this.tempStorage = localStorage;
this.initBasicData(); this.initBasicData();
} }
/**
* 获取状态管理器
*
* @returns {(any | null)}
* @memberof EntityService
*/
public getStore(): Store<any> | null {
return this.$store;
}
/** /**
* 获取代码表 * 获取代码表
* *
...@@ -123,22 +102,16 @@ export default class EntityService { ...@@ -123,22 +102,16 @@ export default class EntityService {
*/ */
public getCodeList(tag:string,codelistType:string,context:any = {},param:any ={}){ public getCodeList(tag:string,codelistType:string,context:any = {},param:any ={}){
return new Promise((resolve:any,reject:any) =>{ return new Promise((resolve:any,reject:any) =>{
let codeListService = new CodeListService();
if(tag && Object.is(codelistType,"STATIC")){ if(tag && Object.is(codelistType,"STATIC")){
let returnItems:Array<any> = []; codeListService.getStaticItems(tag).then((items:any) =>{
const codelist = (this.getStore() as Store<any>).getters.getCodeList(tag); resolve(items);
if (codelist) { })
returnItems = [...JSON.parse(JSON.stringify(codelist.items))];
} else {
console.log(`----${tag}----代码表不存在`);
}
resolve(returnItems);
}else if(tag && Object.is(codelistType,"DYNAMIC")){ }else if(tag && Object.is(codelistType,"DYNAMIC")){
let codeListService = new CodeListService({ $store: this.$store });
codeListService.getItems(tag,context,param).then((res:any) => { codeListService.getItems(tag,context,param).then((res:any) => {
resolve(res); resolve(res);
}).catch((error:any) => { }).catch((error:any) => {
reject(`${tag}代码表不存在`); reject(`${tag}代码表不存在`);
console.log(`----${tag}----代码表不存在`);
}); });
} }
}) })
...@@ -988,4 +961,15 @@ export default class EntityService { ...@@ -988,4 +961,15 @@ export default class EntityService {
return Http.getInstance().post(`/v7/changepwd`,data,isloading); return Http.getInstance().post(`/v7/changepwd`,data,isloading);
} }
/**
* 获取数字字典
*
* @param tag
* @param data
* @param isloading
*/
public async getPredefinedCodelist(tag:string,data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/dictionarys/codelist/${tag}`,data,isloading);
}
} }
\ No newline at end of file
...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's ...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's
---- ----
FTL stack trace ("~" means nesting-related): FTL stack trace ("~" means nesting-related):
- Failed at: ${item.getKeyPSAppDEField().getCodeNa... [in template "TEMPLCODE_zh_CN" at line 566, column 26] - Failed at: ${item.getKeyPSAppDEField().getCodeNa... [in template "TEMPLCODE_zh_CN" at line 570, column 26]
---- ----
\ No newline at end of file
...@@ -13,6 +13,8 @@ import org.mybatis.spring.annotation.MapperScan; ...@@ -13,6 +13,8 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
...@@ -30,6 +32,9 @@ import java.util.List; ...@@ -30,6 +32,9 @@ import java.util.List;
}) })
public class webApplication extends WebMvcConfigurerAdapter{ public class webApplication extends WebMvcConfigurerAdapter{
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(webApplication.class,args); SpringApplication.run(webApplication.class,args);
} }
...@@ -37,6 +42,6 @@ public class webApplication extends WebMvcConfigurerAdapter{ ...@@ -37,6 +42,6 @@ public class webApplication extends WebMvcConfigurerAdapter{
@Override @Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers); super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver()); argumentResolvers.add(resolver);
} }
} }
...@@ -14,6 +14,8 @@ import org.springframework.context.annotation.ComponentScan; ...@@ -14,6 +14,8 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.List; import java.util.List;
import cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j @Slf4j
@EnableDiscoveryClient @EnableDiscoveryClient
...@@ -34,6 +36,9 @@ import java.util.List; ...@@ -34,6 +36,9 @@ import java.util.List;
@EnableScheduling @EnableScheduling
public class DevBootApplication extends WebMvcConfigurerAdapter{ public class DevBootApplication extends WebMvcConfigurerAdapter{
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DevBootApplication.class,args); SpringApplication.run(DevBootApplication.class,args);
} }
...@@ -41,6 +46,6 @@ public class DevBootApplication extends WebMvcConfigurerAdapter{ ...@@ -41,6 +46,6 @@ public class DevBootApplication extends WebMvcConfigurerAdapter{
@Override @Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers); super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver()); argumentResolvers.add(resolver);
} }
} }
...@@ -24,5 +24,17 @@ zuul: ...@@ -24,5 +24,17 @@ zuul:
path: /ibzorganizations/** path: /ibzorganizations/**
serviceId: ${ibiz.ref.service.ou:ibzou-api} serviceId: ${ibiz.ref.service.ou:ibzou-api}
stripPrefix: false stripPrefix: false
oudict:
path: /dictionarys/**/Ibzou**
serviceId: ${ibiz.ref.service.ou:ibzou-api}
stripPrefix: false
uaadict:
path: /dictionarys/**/SysOperator
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}
stripPrefix: false
dict:
path: /dictionarys/**
serviceId: ${ibiz.ref.service.dict:ibzdict-api}
stripPrefix: false
sensitive-headers: sensitive-headers:
- Cookie,Set-Cookie,Authorization - Cookie,Set-Cookie,Authorization
...@@ -15,6 +15,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter ...@@ -15,6 +15,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
...@@ -40,6 +42,9 @@ import java.util.List; ...@@ -40,6 +42,9 @@ import java.util.List;
@EnableScheduling @EnableScheduling
public class ibzdiskapiApplication extends WebMvcConfigurerAdapter{ public class ibzdiskapiApplication extends WebMvcConfigurerAdapter{
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ibzdiskapiApplication.class, args); SpringApplication.run(ibzdiskapiApplication.class, args);
} }
...@@ -47,6 +52,6 @@ public class ibzdiskapiApplication extends WebMvcConfigurerAdapter{ ...@@ -47,6 +52,6 @@ public class ibzdiskapiApplication extends WebMvcConfigurerAdapter{
@Override @Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers); super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver()); argumentResolvers.add(resolver);
} }
} }
...@@ -10,10 +10,16 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver; ...@@ -10,10 +10,16 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer; import org.springframework.web.method.support.ModelAndViewContainer;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Slf4j @Slf4j
@Configuration
public class SearchContextHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { public class SearchContextHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
@Value("${ibiz.pageLimit:1000}")
private int pageLimit=1000;
private static ObjectMapper objectMapper=new ObjectMapper(); private static ObjectMapper objectMapper=new ObjectMapper();
@Override @Override
...@@ -29,6 +35,9 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod ...@@ -29,6 +35,9 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod
for (String key : params.keySet()) { for (String key : params.keySet()) {
set.put(key,params.get(key)[0]); set.put(key,params.get(key)[0]);
} }
if((!set.containsKey("size")) ){
set.put("size",pageLimit);
}
String json=objectMapper.writeValueAsString(set); String json=objectMapper.writeValueAsString(set);
return objectMapper.readValue(json,parameter.getParameterType()); return objectMapper.readValue(json,parameter.getParameterType());
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册