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

ibiz4j 发布系统代码

上级 1d820a20
......@@ -12,6 +12,7 @@ import { authServiceRegister } from '@/authservice/auth-service-register';
import { utilServiceRegister } from '@/utilservice/util-service-register';
import { entityServiceRegister } from '@/service/entity-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 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'
import AppFormItem from './components/app-form-item/app-form-item.vue'
import AppPicker from './components/app-picker/app-picker.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 AppFormItem2 from './components/app-form-item2/app-form-item2.vue'
import CodeList from './components/codelist/codelist.vue'
......@@ -89,6 +91,8 @@ window['utilServiceRegister'] = utilServiceRegister;
window['entityServiceRegister'] = entityServiceRegister;
// 全局挂载计数器服务注册中心
window['counterServiceRegister'] = counterServiceRegister;
// 全局挂载代码表服务注册中心
window['codeListRegister'] = codeListRegister;
export const AppComponents = {
install(v: any, opt: any) {
......@@ -127,6 +131,7 @@ export const AppComponents = {
v.component('app-form-item',AppFormItem);
v.component('app-picker', AppPicker);
v.component('app-mpicker', AppMpicker);
v.component('app-upicker', AppUpicker);
v.component('app-form-group2', AppFormGroup2);
v.component('app-form-item2', AppFormItem2);
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 {
*/
public expirationTime:any;
/**
* 预定义类型
*
* @type string
* @memberof SysOperator
*/
public predefinedType:string ='OPERATOR';
/**
* 缓存超长时长
*
......
......@@ -6,6 +6,7 @@
<script lang="ts">
import { Vue, Component, Watch, Prop, Model } from 'vue-property-decorator';
import CodeListService from '@/service/app/codelist-service';
@Component({
})
export default class AppDepartmentSelect extends Vue {
......@@ -18,6 +19,20 @@ export default class AppDepartmentSelect extends Vue {
*/
@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 {
}
this.oldurl = _url;
// 缓存机制
const result:any = this.$store.getters.getCopyData(_url);
const result:any = this.$store.getters.getDepData(this.filter);
if(result){
this.Nodesdata = result;
return;
}
this.$http.get(_url).then((response: any) => {
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) => {
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) });
......@@ -163,13 +178,19 @@ export default class AppDepartmentSelect extends Vue {
// 单选
if(!this.multiple){
if(this.fillMap && Object.keys(this.fillMap).length >0){
let templateValue = {};
let templateValue:any = {};
Object.keys(this.fillMap).forEach((item:any) =>{
if(this.data && this.data[this.fillMap[item]]){
Object.assign(templateValue,{[item]:this.data[this.fillMap[item]]});
}
})
this.selectTreeValue = JSON.stringify([templateValue]);
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]);
}
}
}else{
// 多选
......@@ -188,8 +209,30 @@ export default class AppDepartmentSelect extends Vue {
})
}
})
this.selectTreeValue = JSON.stringify(tempArray);
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);
}
}
}
}
......@@ -208,10 +251,35 @@ export default class AppDepartmentSelect extends Vue {
let _name = this.fillMap[attribute];
let values = selectArr.map((item:any) => item[attribute]);
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>
......
......@@ -6,6 +6,8 @@
<script lang = 'ts'>
import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import { Http } from '@/utils';
import CodeListService from "@service/app/codelist-service";
import { observable } from 'rxjs';
@Component({})
export default class AppOrgSelect extends Vue {
......@@ -37,6 +39,20 @@ export default class AppOrgSelect extends Vue {
*/
@Prop() public filter?:string;
/**
* 代码表标识
*
* @memberof AppOrgSelect
*/
@Prop() public tag?:string;
/**
* 代码表类型
*
* @memberof AppOrgSelect
*/
@Prop() public codelistType?:string;
/**
* 是否多选
*
......@@ -138,13 +154,19 @@ export default class AppOrgSelect extends Vue {
// 单选
if(!this.multiple){
if(this.fillMap && Object.keys(this.fillMap).length >0){
let templateValue = {};
Object.keys(this.fillMap).forEach((item:any) =>{
if(this.data && this.data[this.fillMap[item]]){
Object.assign(templateValue,{[item]:this.data[this.fillMap[item]]});
let templateValue:any = {};
Object.keys(this.fillMap).forEach((item:any) =>{
if(this.data && 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{
// 多选
......@@ -163,8 +185,30 @@ export default class AppOrgSelect extends Vue {
})
}
})
this.selectTreeValue = JSON.stringify(tempArray);
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);
}
}
}
}
......@@ -175,7 +219,7 @@ export default class AppOrgSelect extends Vue {
*/
public loadTreeData(requestUrl:string){
if(this.filter){
const result:any = this.$store.getters.getCopyData(this.filter);
const result:any = this.$store.getters.getOrgData(this.filter);
if(result){
this.NodesData = result;
return;
......@@ -209,7 +253,9 @@ export default class AppOrgSelect extends Vue {
tempValue.forEach((value:any,index:number) =>{
tempResult += index>0?`,${value[item]}`:`${value[item]}`;
})
this.emitValue(this.fillMap[item],tempResult);
setTimeout(() => {
this.emitValue(this.fillMap[item],tempResult);
}, 0);
})
}
}else{
......@@ -225,7 +271,9 @@ export default class AppOrgSelect extends Vue {
const tempValue:any = JSON.parse($event)[0];
if(this.fillMap && Object.keys(this.fillMap).length >0){
Object.keys(this.fillMap).forEach((item:any) =>{
this.emitValue(this.fillMap[item],tempValue[item]);
setTimeout(() => {
this.emitValue(this.fillMap[item],tempValue[item]);
}, 0);
})
}
}else{
......@@ -247,6 +295,28 @@ export default class AppOrgSelect extends Vue {
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>
......
.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{
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>
<i-select
class='dropdown-list-mpicker'
multiple
:transfer="true"
transfer-class-name="dropdown-list-mpicker-transfer"
v-model="currentVal"
:disabled="disabled === true ? true : false"
:clearable="true"
:filterable="filterable === true ? true : false"
@on-open-change="onClick"
:placeholder="$t('components.dropDownListMpicker.placeholder')">
<i-option v-for="(item, index) in items" :key="index" :value="item.value.toString()" :label="item.text">
<Checkbox :value = "(currentVal.indexOf(item.value.toString()))==-1?false:true">
{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+item.value) : item.text}}
</Checkbox>
</i-option>
</i-select>
<div class="dropdown-list-mpicker-container">
<i-select
v-if="!hasChildren"
class='dropdown-list-mpicker'
multiple
:transfer="true"
transfer-class-name="dropdown-list-mpicker-transfer"
v-model="currentVal"
:disabled="disabled === true ? true : false"
:clearable="true"
:filterable="filterable === true ? true : false"
@on-open-change="onClick"
:placeholder="$t('components.dropDownListMpicker.placeholder')">
<i-option v-for="(item, index) in items" :key="index" :value="item.value.toString()" :label="item.text">
<Checkbox :value = "(currentVal.indexOf(item.value.toString()))==-1?false:true">
{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+item.value) : item.text}}
</Checkbox>
</i-option>
</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>
<script lang="ts">
import { Vue, Component, Prop, Model } from 'vue-property-decorator';
import CodeListService from "@service/app/codelist-service";
import { Util } from '@/utils';
@Component({
})
export default class DropDownListMpicker extends Vue {
......@@ -32,6 +37,13 @@ export default class DropDownListMpicker extends Vue {
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 是否有子集
* @type {boolean}
* @memberof DropDownListMpicker
*/
public hasChildren:boolean = false;
/**
* 当前选中值
* @type {any}
......@@ -131,6 +143,14 @@ export default class DropDownListMpicker extends Vue {
* @memberof DropDownListMpicker
*/
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);
val = Object.is(type, 'null') || Object.is(type, 'undefined') ? [] : val;
let value = val.length > 0 ? val.join(this.valueSeparator) : '';
......@@ -143,9 +163,45 @@ export default class DropDownListMpicker extends Vue {
* @memberof DropDownListMpicker
*/
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):[];
}
/**
* 获取代码表列表
*
* @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 {
const codelist = this.$store.getters.getCodeList(this.tag);
if (codelist) {
this.items = [...JSON.parse(JSON.stringify(codelist.items))];
this.handleLevelCodeList(Util.deepCopy(this.items));
} else {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`);
}
......@@ -198,6 +255,7 @@ export default class DropDownListMpicker extends Vue {
let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
this.items = res;
this.handleLevelCodeList(Util.deepCopy(this.items));
}).catch((error:any) => {
console.log(`----${this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`);
});
......@@ -220,11 +278,57 @@ export default class DropDownListMpicker extends Vue {
let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
this.items = res;
this.handleLevelCodeList(Util.deepCopy(this.items));
}).catch((error:any) => {
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>
......
.dropdown-list{
display: inline-block;
}
.dropdown-list-container{
.dropdown-list{
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>
<i-select
<div class="dropdown-list-container">
<i-select v-if="!hasChildren"
class='dropdown-list'
:transfer="true"
v-model="currentVal"
......@@ -9,12 +10,15 @@
@on-open-change="onClick"
: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-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>
<script lang="ts">
import { Vue, Component, Watch, Prop, Model } from 'vue-property-decorator';
import CodeListService from "@service/app/codelist-service";
import { Util } from '@/utils';
@Component({
})
......@@ -42,6 +46,13 @@ export default class DropDownList extends Vue {
*/
public queryParam:any;
/**
* 是否有子集
* @type {boolean}
* @memberof DropDownList
*/
public hasChildren:boolean = false;
/**
* 当前选中值
* @type {any}
......@@ -152,6 +163,10 @@ export default class DropDownList extends Vue {
* @memberof DropDownList
*/
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);
val = Object.is(type, 'null') || Object.is(type, 'undefined') ? undefined : val;
this.$emit('change', val);
......@@ -163,9 +178,33 @@ export default class DropDownList extends Vue {
* @memberof DropDownList
*/
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;
}
/**
* 获取代码表列表
*
* @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 {
}catch(error){
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>
......
......@@ -3,13 +3,14 @@ import { AuthServiceRegister } from '@/authservice/auth-service-register';
import { UtilServiceRegister } from '@/utilservice/util-service-register';
import { EntityServiceRegister } from '@/service/entity-service-register';
import { CounterServiceRegister } from '@/counter/counter-service-register';
import { CodeListRegister } from '@codelist/codelist-register';
declare global {
interface Window {
uiServiceRegister: UIServiceRegister,
authServiceRegister: AuthServiceRegister,
utilServiceRegister: UtilServiceRegister,
entityServiceRegister: EntityServiceRegister,
counterServiceRegister: CounterServiceRegister
counterServiceRegister: CounterServiceRegister,
codeListRegister:CodeListRegister
}
}
\ No newline at end of file
import { Store } from 'vuex';
import { Http } from '@/utils';
import CodeListService from "@service/app/codelist-service";
......@@ -10,15 +9,6 @@ import CodeListService from "@service/app/codelist-service";
*/
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 {
* @memberof EntityService
*/
constructor(opts: any = {}) {
this.$store = opts.$store;
this.tempStorage = localStorage;
this.initBasicData();
}
/**
* 获取状态管理器
*
* @returns {(any | null)}
* @memberof EntityService
*/
public getStore(): Store<any> | null {
return this.$store;
}
/**
* 获取代码表
*
......@@ -123,22 +102,16 @@ export default class EntityService {
*/
public getCodeList(tag:string,codelistType:string,context:any = {},param:any ={}){
return new Promise((resolve:any,reject:any) =>{
let codeListService = new CodeListService();
if(tag && Object.is(codelistType,"STATIC")){
let returnItems:Array<any> = [];
const codelist = (this.getStore() as Store<any>).getters.getCodeList(tag);
if (codelist) {
returnItems = [...JSON.parse(JSON.stringify(codelist.items))];
} else {
console.log(`----${tag}----代码表不存在`);
}
resolve(returnItems);
codeListService.getStaticItems(tag).then((items:any) =>{
resolve(items);
})
}else if(tag && Object.is(codelistType,"DYNAMIC")){
let codeListService = new CodeListService({ $store: this.$store });
codeListService.getItems(tag,context,param).then((res:any) => {
resolve(res);
}).catch((error:any) => {
reject(`${tag}代码表不存在`);
console.log(`----${tag}----代码表不存在`);
});
}
})
......@@ -988,4 +961,15 @@ export default class EntityService {
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
----
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;
import org.springframework.boot.SpringApplication;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
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;
@Slf4j
......@@ -30,6 +32,9 @@ import java.util.List;
})
public class webApplication extends WebMvcConfigurerAdapter{
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run(webApplication.class,args);
}
......@@ -37,6 +42,6 @@ public class webApplication extends WebMvcConfigurerAdapter{
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> 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;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.List;
import cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@EnableDiscoveryClient
......@@ -34,6 +36,9 @@ import java.util.List;
@EnableScheduling
public class DevBootApplication extends WebMvcConfigurerAdapter{
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run(DevBootApplication.class,args);
}
......@@ -41,6 +46,6 @@ public class DevBootApplication extends WebMvcConfigurerAdapter{
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(new cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver());
argumentResolvers.add(resolver);
}
}
......@@ -24,5 +24,17 @@ zuul:
path: /ibzorganizations/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}
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:
- Cookie,Set-Cookie,Authorization
......@@ -15,6 +15,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@Slf4j
......@@ -40,6 +42,9 @@ import java.util.List;
@EnableScheduling
public class ibzdiskapiApplication extends WebMvcConfigurerAdapter{
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run(ibzdiskapiApplication.class, args);
}
......@@ -47,6 +52,6 @@ public class ibzdiskapiApplication extends WebMvcConfigurerAdapter{
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> 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;
import org.springframework.web.method.support.ModelAndViewContainer;
import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Slf4j
@Configuration
public class SearchContextHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
@Value("${ibiz.pageLimit:1000}")
private int pageLimit=1000;
private static ObjectMapper objectMapper=new ObjectMapper();
@Override
......@@ -29,6 +35,9 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod
for (String key : params.keySet()) {
set.put(key,params.get(key)[0]);
}
if((!set.containsKey("size")) ){
set.put("size",pageLimit);
}
String json=objectMapper.writeValueAsString(set);
return objectMapper.readValue(json,parameter.getParameterType());
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册