提交 2dd63f13 编写于 作者: ibizdev's avatar ibizdev

ibizdev提交

上级 ab5bf2ce
......@@ -65,6 +65,7 @@ import AppHeaderMenus from './components/app-header-menus/app-header-menus.vue'
import AppColumnLink from './components/app-column-link/app-column-link.vue'
import AppDataUploadView from './components/app-data-upload/app-data-upload.vue'
import DropDownListDynamic from './components/dropdown-list-dynamic/dropdown-list-dynamic.vue'
import AppImagePreview from './components/app-image-preview/app-image-preview.vue'
// 全局挂载UI实体服务注册中心
window['uiServiceRegister'] = uiServiceRegister;
......@@ -139,5 +140,6 @@ export const AppComponents = {
v.component('app-column-link', AppColumnLink);
v.component('app-data-upload', AppDataUploadView);
v.component('dropdown-list-dynamic', DropDownListDynamic);
v.component('app-image-preview', AppImagePreview);
},
};
\ No newline at end of file
......@@ -51,6 +51,14 @@ export default class AppCheckBox extends Vue {
*/
@Prop() public codelistType?: string;
/**
* 代码表值分隔符
*
* @type {string}
* @memberof AppCheckBox
*/
@Prop({default:';'}) public valueSeparator?: string;
/**
* 是否禁用
*
......@@ -151,7 +159,7 @@ export default class AppCheckBox extends Vue {
return selectsArray;
} else if (Object.is(this.currentmode, 'str')) {
if (this.selects !== '') {
return this.selects.split(this.currentseparator);
return this.selects.split(this.valueSeparator);
}
}
} else {
......@@ -181,7 +189,7 @@ export default class AppCheckBox extends Vue {
}
_datas.push(item.value);
});
value = _datas.join(this.currentseparator);
value = _datas.join(this.valueSeparator);
}
this.$emit('change', value);
}
......
.app-data-upload-view{
width: 100%;
height: 100%;
padding: 16px;
.import-temp{
text-align: right;
vertical-align: middle;
color: #409EFF;
}
.data-info-content{
height: 100%;
width: 100%;
overflow: auto;
}
}
\ No newline at end of file
<template>
<div class="app-data-upload-view">
{{$t('info.viewtitle')}}
<el-row :gutter="20">
<el-col :span="4">
<el-button type="primary" @click="handleUpLoad">选取文件</el-button>
<input ref="inputUpLoad" type="file" style="display: none" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @change="importFile"/>
</el-col>
<el-col :span="4">
<el-button type="primary" @click="uploadServer">上传服务器</el-button>
</el-col>
<el-col :span="16">
<div class="import-temp"><span style="cursor: pointer;" @click="downloadTemp">下载导入数据模板</span></div>
</el-col>
</el-row>
<el-divider></el-divider>
<el-row style="height:calc(100% - 128px);padding: 0px 12px;">
<div class="data-info-content" >
<template v-if="importDataArray.length >0">
<ul>
<li v-for="(item,index) in importDataArray" :key="index">
{{'数据标识为'+item[importUniqueItem]+'读取成功......'}}
</li>
</ul>
</template>
<template v-if="importDataArray.length ==0">
{{uploadStatus === true?"导入中......":""}}
</template>
</div>
</el-row>
<el-row :gutter="20">
<el-col :span="4">
<div class="import-temp">
<span style="cursor: pointer;display: inline-block;" @click="downloadSuccessData">{{importSuccessData.length >0?"下载导入成功数据":""}}</span>
</div>
</el-col>
<el-col :span="4">
<div class="import-temp">
<span style="cursor: pointer;display: inline-block;" @click="downloadErrorData">{{importErrorData.length >0?"下载导入失败数据":""}}</span>
</div>
</el-col>
<el-col :span="2" :offset="11">
<el-button type="primary" @click="handleOK">确定</el-button>
</el-col>
<el-col :span="3" style="text-align: center;">
<el-button plain @click="handleCancel">取消</el-button>
</el-col>
</el-row>
</div>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import XLSX from 'xlsx';
import CodeListService from "@service/app/codelist-service";
import EntityService from '@/service/entity-service';
import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
@Component({
i18n: {
......@@ -25,6 +72,456 @@ import { Vue, Component } from 'vue-property-decorator';
})
export default class AppDataUploadView extends Vue {
/**
* 传入视图上下文
*
* @type {string}
* @memberof AppDataUploadView
*/
@Prop() protected viewdata!: string;
/**
* 传入视图参数
*
* @type {string}
* @memberof AppDataUploadView
*/
@Prop() protected viewparam!: string;
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof AppDataUploadView
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 实体服务对象
*
* @protected
* @type {EntityService}
* @memberof AppDataUploadView
*/
protected entityService: EntityService = new EntityService();
/**
* 视图参数
*
* @type {*}
* @memberof AppDataUploadView
*/
protected viewparams:any = {};
/**
* 导入数据模型
*
* @type {Array<*>}
* @memberof AppDataUploadView
*/
protected importDataModel:Array<any> = [];
/**
* 导入数据集合
*
* @type {Array<*>}
* @memberof AppDataUploadView
*/
protected importDataArray:Array<any> = [];
/**
* 导入标识
*
* @type {string}
* @memberof AppDataUploadView
*/
protected importId:string = "";
/**
* 导入数据识别项属性
*
* @type {string}
* @memberof AppDataUploadView
*/
protected importUniqueItem:string ="";
/**
* 导入状态
*
* @type {boolean}
* @memberof AppDataUploadView
*/
protected uploadStatus:boolean = false;
/**
* 导入成功数据
*
* @type {string}
* @memberof AppDataUploadView
*/
protected importSuccessData:Array<any> = [];
/**
* 导入失败数据
*
* @type {string}
* @memberof AppDataUploadView
*/
protected importErrorData:Array<any> = [];
/**
* 读取完成的数据
*
* @type {*}
* @memberof AppDataUploadView
*/
public workBookData:any;
/**
* 所有的代码表
*
* @type {*}
* @memberof AppDataUploadView
*/
public allCodeList:any;
/**
* 属性Map(用作属性转化)
*
* @type {*}
* @memberof AppDataUploadView
*/
public allFieldMap:Map<string,any> = new Map();
/**
* 视图参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof AppDataUploadView
*/
@Watch('viewparam',{immediate: true, deep: true})
onParamData(newVal: any, oldVal: any) {
if(newVal){
Object.assign(this.viewparams, JSON.parse(this.viewparam));
this.initBasic();
}
}
/**
* 初始化基础数据
*
* @memberof AppDataUploadView
*/
public async initBasic(){
if(this.viewparams.importId){
this.importId = this.viewparams.importId;
}
if(this.viewparams.importData){
this.importDataModel = Object.values(this.viewparams.importData);
this.BubbleSort(this.importDataModel,this.importDataModel.length);
}
this.importDataModel.forEach((item:any) =>{
if(item.isuniqueitem){
this.importUniqueItem = item.headername;
}
this.allFieldMap.set(item.headername,item);
});
console.log(this.allFieldMap);
//获取代码表值
this.allCodeList = await this.getChartAllCodeList();
}
/**
* 冒泡排序
*
* @param {*} newVal
* @param {*} oldVal
* @memberof AppDataUploadView
*/
public BubbleSort(array:Array<any>,length:number){
for (let i = 0; i < length; i++){
for (let j = 0; j < length - i - 1; j++){
if (array[j].order > array[j + 1].order){
let temp:any;
temp = array[j + 1];
array[j + 1] = array[j];
array[j] = temp;
}
}
}
}
/**
* 下载导入数据模板
*
* @memberof AppDataUploadView
*/
public downloadTemp(){
this.importExcel(this.viewparams.appDeLogicName+"导入数据模板",[]);
}
/**
* 下载导入成功数据
*
* @memberof AppDataUploadView
*/
public downloadSuccessData(){
this.importExcel(this.viewparams.appDeLogicName+"导入成功数据",this.importSuccessData);
}
/**
* 下载导入失败数据
*
* @memberof AppDataUploadView
*/
public downloadErrorData(){
this.importExcel(this.viewparams.appDeLogicName+"导入失败数据",this.importErrorData);
}
/**
* 选择文件
*
* @memberof AppDataUploadView
*/
public handleUpLoad(){
(this.$refs.inputUpLoad as any).click();
}
/**
* 上传服务器
*
* @memberof AppDataUploadView
*/
public uploadServer(){
if(this.importDataArray.length == 0){
return;
}
let tempDataArray:Array<any> = [];
this.transformData(this.importDataArray,tempDataArray);
this.importDataArray = [];
this.uploadStatus = true;
try{
this.entityService.getService(this.viewparams.serviceName).then((service:any) =>{
service.ImportData(this.viewdata,{name:this.importId,data:tempDataArray}).then((res:any) =>{
console.log(res);
this.uploadStatus = false;
})
}).catch((error:any) =>{
this.uploadStatus = false;
console.error(error);
})
}catch(error){
this.uploadStatus = false;
console.error(error);
};
}
/**
* 导出excel
*
* @memberof AppDataUploadView
*/
public async importExcel (filename:string,_data:any){
const tHeader: Array<any> = [];
this.importDataModel.forEach((item: any) => {
tHeader.push(item.headername);
});
//const data = await this.formatExcelData(filterVal, _data);
const data = _data?_data:[];
this.$export.exportExcel().then((excel:any)=>{
excel.export_json_to_excel({
header: tHeader, //表头 必填
data:data, //具体数据 必填
filename: filename, //非必填
autoWidth: true, //非必填
bookType: "xlsx" //非必填
});
});
};
/**
* 确认
*
* @memberof AppDataUploadView
*/
public handleOK(){
this.$emit('viewdataschange',this.importSuccessData);
}
/**
* 取消
*
* @memberof AppDataUploadView
*/
public handleCancel(){
this.$emit('close',null);
}
/**
* 导入Excel
*
* @memberof AppDataUploadView
*/
public importFile($event:any) {
let obj = $event.target || $event.srcElement;
if (!obj.files) {
return;
}
let f = obj.files[0];
let reader = new FileReader();
reader.onload = (e:any) => {
let data = e.target.result;
this.workBookData = XLSX.read(data, {type: 'binary'});
let xlsxData = XLSX.utils.sheet_to_json(this.workBookData.Sheets[this.workBookData.SheetNames[0]]);
let list1 = this.getFirstRow(this.workBookData);
xlsxData = this.AddXlsxData(xlsxData, list1);
this.importDataArray = JSON.parse(JSON.stringify(xlsxData));
(this.$refs.inputUpLoad as any).value = '';
};
reader.readAsBinaryString(f);
}
/**
* 获取excel第一行的内容
*
* @memberof AppDataUploadView
*/
public getFirstRow(wb:any) {
//// 读取的excel单元格内容
let wbData = wb.Sheets[wb.SheetNames[0]];
// 匹配excel第一行的内容
let re = /^[A-Z]1$/;
let temparr = [];
// excel第一行内容赋值给数组
for (let key in wbData) {
if (wbData.hasOwnProperty(key)) {
if (re.test(key)) {
temparr.push(wbData[key].h);
}
}
}
return temparr;
}
/**
* 增加对应字段空白内容
*
* @memberof AppDataUploadView
*/
public AddXlsxData(xlsxData:any, list1:any) {
// 空白字段替换值
let addData = null;
for (let i = 0; i < xlsxData.length; i++) {
// 要被JSON的数组
for (let j = 0; j < list1.length; j++) {
// excel第一行内容
if (!xlsxData[i][list1[j]]) {
xlsxData[i][list1[j]] = addData;
}
}
}
return xlsxData;
}
/**
* 获取图表所需代码表
*
* @memberof AppDataUploadView
*/
public async getChartAllCodeList(){
let codeListMap:Map<string,any> = new Map();
if(Object.values(this.importDataModel).length >0){
await Object.values(this.importDataModel).forEach(async (singleDataModel:any) =>{
if(singleDataModel.codelist){
let tempCodeListMap:Map<any,any> = new Map();
let res:any = await this.getCodeList(singleDataModel.codelist);
if(res && res.length >0){
res.forEach((codeListItem:any) =>{
tempCodeListMap.set(codeListItem.value,codeListItem.text);
})
}
codeListMap.set(singleDataModel.codelist.tag,tempCodeListMap);
}
})
}
return codeListMap;
}
/**
* 获取代码表
*
* @returns {Promise<any>}
* @memberof AppDataUploadView
*/
public getCodeList(codeListObject:any):Promise<any>{
return new Promise((resolve:any,reject:any) =>{
if(codeListObject.tag && Object.is(codeListObject.type,"STATIC")){
const codelist = this.$store.getters.getCodeList(codeListObject.tag);
if (codelist) {
resolve([...JSON.parse(JSON.stringify(codelist.items))]);
} else {
console.log(`----${codeListObject.tag}----代码表不存在`);
}
}else if(codeListObject.tag && Object.is(codeListObject.type,"DYNAMIC")){
this.codeListService.getItems(codeListObject.tag).then((res:any) => {
resolve(res);
}).catch((error:any) => {
console.log(`----${codeListObject.tag}----代码表不存在`);
});
}
})
}
/**
* 转化数据
*
* @memberof AppDataUploadView
*/
public transformData(data:Array<any>,result:Array<any>){
data.forEach((item:any) =>{
let curObject:any = {};
Object.keys(item).forEach((ele:any) => {
if(this.allFieldMap.get(ele).codelist){
let codelistTag:string = this.allFieldMap.get(ele).codelist.tag;
let codelistIsNumber:boolean = this.allFieldMap.get(ele).codelist.isnumber;
let curCodeList:any = this.transCodeList(codelistTag,codelistIsNumber,true);
Object.defineProperty(curObject, this.allFieldMap.get(ele).name, {
value: curCodeList.get(item[ele]),
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(curObject, this.allFieldMap.get(ele).name, {
value: item[ele],
writable : true,
enumerable : true,
configurable : true
});
}
});
result.push(curObject);
})
}
/**
* 翻译代码表
*
* @memberof AppDataUploadView
*/
public transCodeList(codeListTag:string,codelistIsNumber:boolean,isTransform:boolean){
let curCodeList:any = this.allCodeList.get(codeListTag);
if(isTransform){
let tempCodelist:Map<string,string> = new Map();
curCodeList.forEach((item:string,key:string) =>{
let value:any = codelistIsNumber?Number(key):key;
tempCodelist.set(item,value);
})
curCodeList = tempCodelist;
}
return curCodeList;
}
}
</script>
......
/*** BEGIN:图片上传 ***/
.app-picture-preview {
.preview-file-list-item{
margin: 0 8px 8px 0;
display: inline-block;
position: relative;
}
.preview-file-list-img{
display: inline-block;
position: relative;
width: 148px;
height: 148px;
.el-image{
width: 100%;
height: 100%;
.image-slot{
width: 100%;
height: 100%;
}
}
}
.preview-file-list-actions{
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
font-size: 20px;
text-align: center;
color: #fff;
opacity: 0;
transition: opacity .3s;
.action-download{
margin-left: 15px;
}
}
.preview-file-list-actions:hover{
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
font-size: 20px;
text-align: center;
color: #fff;
opacity: 1;
background-color: rgba(0,0,0,.5);
}
.preview-file-list-actions::after{
display: inline-block;
content: "";
height: 100%;
vertical-align: middle;
}
>div{
display: inline;
}
}
.app-image-preview-model {
width: 100%;
height: 100%;
text-align: center;
.ivu-modal{
top: 50%;
transform: translateY(-50%);
display: inline-block;
.ivu-modal-content{
display: inline-block;
.ivu-modal-close{
display: none;
}
.ivu-modal-body{
display: inline-block;
line-height: 0;
.el-image {
width: auto;
height: auto;
line-height: 0;
.image-slot {
width: auto;
height: auto;
line-height: 0;
img{
max-width: 1200px;
max-height: 1600px;
}
}
}
}
}
}
}
/*** END:图片上传 ***/
\ No newline at end of file
<template>
<div class='app-picture-preview'>
<ul class="">
<li v-for="(file,index) in files" :key="index" class="preview-file-list-item">
<div class='preview-file-list-img'>
<el-image :src="file.url" class='' style=''>
<div slot='error' class='image-slot'>
<img src="/assets/img/picture.png" style='width:100%;height:100%;'>
</div>
</el-image>
<div class='preview-file-list-actions'>
<span class='action-preview'>
<i class='el-icon-zoom-in' @click="onPreview(file)"></i>
</span>
<span class='action-download'>
<i class='el-icon-download' @click="onDownload(file)"></i>
</span>
</div>
</div>
</li>
</ul>
<!-- 预览 -->
<modal v-model="dialogVisible" footer-hide width="auto" class-name='app-image-preview-model'>
<el-image src="dialogImageUrl">
<div slot='error' class='image-slot'>
<img src="/assets/img/picture.png">
</div>
</el-image>
</modal>
</div>
</template>
<script lang = 'ts'>
import { Vue, Component, Prop, Watch, Provide } from 'vue-property-decorator';
import { Environment } from '@/environments/environment';
import { Subject, Unsubscribable } from 'rxjs';
@Component({})
export default class AppImageUpload extends Vue {
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof AppImageUpload
*/
@Prop() public formState?: Subject<any>
/**
* 表单状态事件
*
* @private
* @type {(Unsubscribable | undefined)}
* @memberof AppImageUpload
*/
private formStateEvent: Unsubscribable | undefined;
/**
* 初始化值
*
* @type {*}
* @memberof AppImageUpload
*/
@Prop() public value?: any;
/**
* 数据值变化
*
* @param {*} newval
* @param {*} val
* @returns
* @memberof AppImageUpload
*/
@Watch('value')
onValueChange(newval: any, val: any) {
this.setFiles(newval)
}
/**
* 所属表单项名称
*
* @type {string}
* @memberof AppImageUpload
*/
@Prop() public name!: string;
/**
* 上传文件路径
*
* @memberof AppImageUpload
*/
public uploadUrl = Environment.BaseUrl + Environment.UploadFile;
/**
* 下载文件路径
*
* @memberof AppImageUpload
*/
public downloadUrl = Environment.BaseUrl + Environment.ExportFile;
/**
* 文件列表
*
* @memberof AppImageUpload
*/
@Provide() public files = [];
/**
* 设置files
*
* @private
* @memberof AppImageUpload
*/
private setFiles(value:any): void {
let _files = JSON.parse(value);
if (value && Object.prototype.toString.call(_files)=='[object Array]') {
this.files = _files;
this.files.forEach((file: any) => {
let url = `${this.downloadUrl}/${file.id}`;
file.url = url;
});
} else {
this.files = [];
}
}
/**
* vue 生命周期
*
* @memberof AppImageUpload
*/
public created() {
if (this.formState) {
this.formStateEvent = this.formState.subscribe(($event: any) => {
// 表单加载完成
if (Object.is($event.type, 'load')) {
this.setFiles(this.value);
}
});
}
}
/**
* vue 生命周期
*
* @memberof AppImageUpload
*/
public mounted() {
this.setFiles(this.value);
}
/**
* 组件销毁
*
* @memberof AppImageUpload
*/
public destroyed(): void {
if (this.formStateEvent) {
this.formStateEvent.unsubscribe();
}
}
/**
* 下载文件
*
* @param {*} file
* @memberof AppImageUpload
*/
public onDownload(file: any) {
window.open(file.url);
}
/**
* 预览图片地址
*
* @type {string}
* @memberof AppImageUpload
*/
public dialogImageUrl: string = '';
/**
* 是否显示预览界面
*
* @type {boolean}
* @memberof AppImageUpload
*/
public dialogVisible: boolean = false;
/**
* 预览
*
* @param {*} file
* @memberof AppImageUpload
*/
public onPreview(file: any) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
}
}
</script>
<style lang = "less">
@import './app-image-preview.less';
</style>
\ No newline at end of file
<template>
<radio-group class="app-radio-group" v-model="value" >
<radio-group class="app-radio-group" v-model="selectArray" >
<radio v-for="(_item,index) in items" :key = "index" :label="_item.value" :disabled="isDisabled || _item.disabled">
<span>{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+_item.value) : _item.text}}</span>
</radio>
......@@ -25,41 +25,39 @@ export default class AppRadioGroup extends Vue {
* @type {*}
* @memberof AppRadioGroup
*/
@Model('change') item?: any;
@Model('change') value?: any;
/**
* 获取值
* 代码表标识
*
* @type {string}
* @memberof AppRadioGroup
*/
get value() {
return this.item;
}
@Prop() public tag?: string;
/**
* 设置值
* 代码表类型
*
* @type {string}
* @memberof AppRadioGroup
*/
set value(val: any) {
this.$emit('change', val);
}
@Prop() public codelistType?: string;
/**
* 代码表标识
* 代码表值分隔符
*
* @type {string}
* @memberof AppRadioGroup
*/
@Prop() public tag?: string;
@Prop({default:';'}) public valueSeparator?: string;
/**
* 代码表类型
* 模式(数字或者字符串)
*
* @type {string}
* @memberof AppRadioGroup
* @type {*}
* @memberof AppCheckBox
*/
@Prop() public codelistType?: string;
@Prop({default:'str'}) mode: any;
/**
* 是否禁用
......@@ -115,6 +113,59 @@ export default class AppRadioGroup extends Vue {
})
}
}
/**
* 选中数组
*
* @memberof AppRadioGroup
*/
get selectArray() {
if (this.value) {
if (Object.is(this.mode, 'num') && this.items) {
let selectsArray: Array<any> = [];
let num: number = parseInt(this.value, 10);
this.items.forEach((item: any) => {
if ((num & item.value) == item.value) {
selectsArray.push(item.value);
}
});
return selectsArray;
} else if (Object.is(this.mode, 'str')) {
if (this.value !== '') {
return this.value.split(this.valueSeparator);
}
}
} else {
return [];
}
}
/**
* 设置选中
*
* @memberof AppRadioGroup
*/
set selectArray(val: any) {
let value: null | string | number = null;
if (Object.is(this.mode, 'num')) {
let temp: number = 0;
val.forEach((item: any) => {
temp = temp | parseInt(item, 10);
});
value = temp;
} else if (Object.is(this.mode, 'str')) {
let _datas: string[] = [];
this.items.forEach((item: any) => {
const index = val.findIndex((_key: any) => Object.is(item.value, _key));
if (index === -1) {
return;
}
_datas.push(item.value);
});
value = _datas.join(this.valueSeparator);
}
this.$emit('change', value);
}
}
</script>
<style lang="less">
......
<template>
<span>{{isUseLangres ? $t(text) : text}}</span>
<codelist v-if="tag" :tag="tag" :value="value" :codelistType="codelistType" :renderMode="renderMode" :valueSeparator="valueSeparator" :textSeparator="textSeparator"></codelist>
<span v-else >{{text}}</span>
</template>
<script lang="ts">
import { Vue, Component, Prop,Watch,Model } from 'vue-property-decorator';
import { Vue, Component, Prop, Watch, Model } from 'vue-property-decorator';
import CodeListService from "@service/app/codelist-service";
@Component({})
export default class DropDownList extends Vue {
/**
* 代码表服务对象
* 当前值
*
* @type {CodeListService}
* @type {*}
* @memberof AppSpan
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
@Prop() public value?: any;
/**
* 当前值
* 代码表标识
*
* @type {*}
* @type {string}
* @memberof AppSpan
*/
@Prop() public data?: any;
@Prop() public tag?: string;
/**
* 代码表类型
*
* @type {string}
* @memberof AppSpan
*/
@Prop() public codelistType?: string;
/**
* 获取或模式
* @type {boolean}
* @memberof SelectPicker
*/
@Prop() public renderMode?: string;
/**
* 文本分隔符
* @type {boolean}
* @memberof SelectPicker
*/
@Prop({default:"、"}) public textSeparator?: string;
/**
* 值分隔符
* @type {boolean}
* @memberof SelectPicker
*/
@Prop({default:";"}) public valueSeparator?: string;
/**
* 监控表单属性 data 值
*
* @memberof AppSpan
*/
@Watch('data')
@Watch('value')
onDataChange(newVal: any, oldVal: any) {
if(newVal !== oldVal){
this.load();
......@@ -52,30 +82,6 @@ export default class DropDownList extends Vue {
*/
@Prop() public editorType?: string;
/**
* 代码表标识
*
* @type {string}
* @memberof AppSpan
*/
@Prop() public tag?: string;
/**
* 代码表类型
*
* @type {string}
* @memberof AppSpan
*/
@Prop() public codelistType?: string;
/**
* 代码表
*
* @type {any[]}
* @memberof AppSpan
*/
public items: any[] = [];
/**
* vue 生命周期
*
......@@ -85,76 +91,25 @@ export default class DropDownList extends Vue {
this.load();
}
/**
* 是否使用多语言资源
* @type {boolean}
* @memberof AppSpan
*/
public isUseLangres:boolean = false;
/**
* 加载代码表
*
* @memberof AppSpan
*/
public load(){
if(Object.is(this.editorType,'PICTURE') || Object.is(this.editorType,'PICTURE_ONE') ||Object.is(this.editorType,'FILEUPLOADER')){
let files: any[] = JSON.parse(this.data);
if(this.tag){
return; //代码表走codelist组件
} else if(Object.is(this.editorType,'PICTURE') || Object.is(this.editorType,'PICTURE_ONE') || Object.is(this.editorType,'FILEUPLOADER')){
let files: any[] = JSON.parse(this.value);
let names: any[] = [];
if(files.length && files.length > 0){
files.forEach((item:any) => {
names.push(item.name);
});
this.text = names.join(',');
}else{
if(this.tag && Object.is(this.codelistType,"STATIC")){
const codelist = this.$store.getters.getCodeList(this.tag);
if (codelist) {
this.items = [...JSON.parse(JSON.stringify(codelist.items))];
this.setText();
} else {
console.log(`----${this.tag}----代码表不存在`);
}
}else if(this.tag && Object.is(this.codelistType,"DYNAMIC")){
this.codeListService.getItems(this.tag).then((res:any) => {
this.items = res;
this.setText();
}).catch((error:any) => {
console.log(`----${this.tag}----代码表不存在`);
});
}else{
this.setText();
}
}
}
/**
* 设置显示值
* @memberof AppSpan
*/
public setText(){
this.isUseLangres = false;
if(this.items.length>0){
let currentItem:any = this.items.find((item:any)=>{
return item.value == this.data;
});
if(currentItem){
if(Object.is(this.codelistType,'STATIC')){
this.isUseLangres = true;
this.text = 'codelist.'+this.tag+'.'+this.data;
}else{
this.text = currentItem.label;
}
}else{
// 不匹配显示原值,不存在显示空值
if(this.data){
this.text = this.data;
}else{
this.isUseLangres = true;
this.text = 'codelist.'+this.tag+'.empty';
}
}
}else{
this.text = this.data;
this.text = this.value;
}
}
......
<template>
<div class="codelist">
<span v-if="ifEmpty">{{$t('codelist.'+srfkey+'.empty')}}</span>
<span v-if="ifEmpty">{{$t('codelist.'+tag+'.empty')}}</span>
<template v-if="!ifEmpty">
<template v-if="renderMode == 'string'">
<template v-for="(val, index) in items">
{{ index != 0 ? textSeparator : ''}}
<template v-for="(item, index) in val">
{{ index != 0 ? "、" : ''}}
<i v-if="item.iconCls" :class="item.iconCls"></i>
<span :class="item.textCls" :style="{color:item.color}">{{isUseLangres ? $t(item.text) : item.text}}</span>
</template>
</template>
</template>
<template v-else>
<template v-for="(item, index) in items">
{{ index != 0 ? textSeparator : ''}}
<span>{{ index != 0 ? textSeparator : ''}}</span>
<i v-if="item.iconCls" :class="item.iconCls"></i>
<span :class="item.textCls" :style="{color:item.color}">{{isUseLangres ? $t(item.text) : item.text}}</span>
</template>
</template>
</template>
</div>
</template>
......@@ -43,7 +31,7 @@ export default class CodeList extends Vue {
* @type {string}
* @memberof CodeList
*/
@Prop() public srfkey!: string;
@Prop() public tag!: string;
/**
* 代码表类型
......@@ -62,14 +50,7 @@ export default class CodeList extends Vue {
@Prop() public value?: string;
/**
* 空值显示文本
* @type {boolean}
* @memberof SelectPicker
*/
@Prop() public emptytext?: string;
/**
* 绘制模式
* 获取或模式
* @type {boolean}
* @memberof SelectPicker
*/
......@@ -90,14 +71,14 @@ export default class CodeList extends Vue {
@Prop({default:";"}) public valueSeparator?: string;
/**
* 是否
* 是否为空
*
* @memberof CodeList
*/
public ifEmpty:boolean = false;
/**
* 显示数据
* 显示数据集合
*
* @type {any[]}
* @memberof CodeList
......@@ -150,16 +131,16 @@ export default class CodeList extends Vue {
this.ifEmpty = false;
// 动态代码表处理
if (Object.is(this.codelistType, "DYNAMIC")) {
this.codeListService.getItems(this.srfkey).then((res: any) => {
this.codeListService.getItems(this.tag).then((res: any) => {
let items = res;
_this.setItems(items, _this);
}).catch((error: any) => {
console.log(`----${_this.srfkey}----代码表不存在`);
console.log(`----${_this.tag}----代码表不存在`);
});
// 静态处理
} else if(Object.is(this.codelistType, "STATIC")){
this.isUseLangres = true;
let items = this.$store.getters.getCodeListItems(this.srfkey);
let items = this.$store.getters.getCodeListItems(this.tag);
_this.setItems(items, _this);
}
}
......@@ -176,8 +157,8 @@ export default class CodeList extends Vue {
private setItems(items: any[], _this: any){
if (items) {
let result:any = [];
if(Object.is(this.renderMode,"number")){
this.isUseLangres = false;
if(Object.is(_this.renderMode,"NUM")){
_this.isUseLangres = false;
items.map((_item: any, index: number)=>{
const nValue = parseInt((_this.value as any), 10);
const codevalue = _item.value;
......@@ -185,25 +166,10 @@ export default class CodeList extends Vue {
result.push(_item);
}
});
} else if(Object.is(this.renderMode,"string")){
const arrayValue: Array<any> = (_this.value as any).split(_this.valueSeparator);
arrayValue.map((value: any, index: number) => {
result.push([]);
let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(this.valueSeparator)];
values.map((val:any ,num: number)=>{
const item = this.getItem(items, val);
if(item){
result[index].push(item);
}
});
if(result[index].length == 0){
result.splice(index,1);
}
});
} else {
let values: any[] = Object.is(this.$util.typeOf(this.value), 'number') ? [this.value] : [...(this.value as any).split(this.valueSeparator)];
let values: any[] = Object.is(_this.$util.typeOf(_this.value), 'NUM') ? [_this.value] : [...(_this.value as any).split(_this.valueSeparator)];
values.map((value:any ,index: number)=>{
const item = this.getItem(items, value);
const item = _this.getItem(items, value);
if(item){
result.push(item);
}
......@@ -213,11 +179,7 @@ export default class CodeList extends Vue {
if(result.length != 0){
_this.items = result;
}else{
if(Object.is(this.renderMode,"string")){
_this.items = [[{text:this.value}]];
} else {
_this.items = [{text:this.value}];
}
_this.items = [{text:_this.value}];
}
}
}
......@@ -240,16 +202,13 @@ export default class CodeList extends Vue {
result = { ...arr[0] };
if(Object.is(this.codelistType,'STATIC')){
let value = JSON.parse(JSON.stringify(result));
value.text = 'codelist.'+this.srfkey+'.'+value.value;
value.text = 'codelist.'+this.tag+'.'+value.value;
return value;
}else{
return result;
}
}
}
</script>
......
......@@ -64,6 +64,14 @@ export default class DropDownList extends Vue {
*/
@Prop() public codelistType?: string;
/**
* 代码表值分隔符
*
* @type {string}
* @memberof DropDownListMpicker
*/
@Prop({default:';'}) public valueSeparator?: string;
/**
* 是否禁用
* @type {any}
......@@ -94,7 +102,7 @@ export default class DropDownList extends Vue {
set currentVal(val: any) {
const type: string = this.$util.typeOf(val);
val = Object.is(type, 'null') || Object.is(type, 'undefined') ? [] : val;
let value = val.length > 0 ? val.join(',') : '';
let value = val.length > 0 ? val.join(this.valueSeparator) : '';
this.$emit('change', value);
}
......@@ -104,7 +112,7 @@ export default class DropDownList extends Vue {
* @memberof DropDownListMpicker
*/
get currentVal() {
return this.itemValue? this.itemValue.split(','):[];
return this.itemValue? this.itemValue.split(this.valueSeparator):[];
}
/**
......
......@@ -310,12 +310,21 @@ export default class AppIndexViewBase extends Vue {
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item, {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item, {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[curNavData.value]){
......
......@@ -448,12 +448,21 @@ export default class IBZDictEditViewBase extends Vue {
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item, {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item, {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[curNavData.value]){
......
......@@ -474,12 +474,21 @@ export default class IBZDictGridViewBase extends Vue {
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item, {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item, {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[curNavData.value]){
......
......@@ -448,12 +448,21 @@ export default class IBZDictItemEditViewBase extends Vue {
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item, {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item, {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[curNavData.value]){
......
......@@ -474,12 +474,21 @@ export default class IBZDictItemGridViewBase extends Vue {
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
Object.defineProperty(tempData, item, {
value: null,
writable : true,
enumerable : true,
configurable : true
});
}else{
Object.defineProperty(tempData, item, {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
});
}
}else{
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[curNavData.value]){
......
......@@ -64,10 +64,14 @@ export default class CodeListService {
}
}else{
if (_this[tag]) {
return _this[tag].getItems(context,data,isloading);
}
_this[tag].getItems(context,data,isloading).then((result:any) =>{
resolve(result);
}).catch((error:any) =>{
Promise.reject([]);
})
}else{
return Promise.reject([]);
}
}
})
}
......
......@@ -552,6 +552,19 @@ export default class EntityService {
return this.FetchDefault(context,data,isloading);
}
/**
* ImportData接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
public async ImportData(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/import`,data,isloading);
}
/**
* WFStart接口方法
*
......
......@@ -4,7 +4,7 @@
<row >
<i-col v-show="detailsModel.n_ibzdictid_like.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 12, offset: 0 }" :xl="{ span: 12, offset: 0 }">
<app-form-item name='n_ibzdictid_like' :itemRules="this.rules.n_ibzdictid_like" class='' :caption="$t('ibzdict.default_searchform.details.n_ibzdictid_like')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.n_ibzdictid_like.error" :isEmptyCaption="false" labelPos="LEFT">
<app-span style="width:100px;" :data="data.n_ibzdictid_like" ></app-span>
<app-span :value="data.n_ibzdictid_like" style="width:100px;"></app-span>
</app-form-item>
</i-col>
......
......@@ -33,6 +33,7 @@ public class IBZDict extends EntityBase implements Serializable {
/**
* 字典标识
*/
@DEField(isKeyField=true)
@TableId(value= "ibzdictid",type=IdType.UUID)
private String dictid;
......@@ -82,14 +83,6 @@ public class IBZDict extends EntityBase implements Serializable {
/**
* 字典项目
*/
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
private List<cn.ibizlab.core.dict.domain.IBZDictItem> items;
/**
* 设置 [字典名称]
......
......@@ -33,6 +33,7 @@ public class IBZDictItem extends EntityBase implements Serializable {
/**
* 字典项目标识
*/
@DEField(isKeyField=true)
@TableId(value= "ibzdictitemid",type=IdType.UUID)
private String itemid;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.ibizlab.core.dict.mapper.IBZDictMapper">
<!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性-->
<select id="selectById" resultMap="IBZDictResultMap" databaseId="mysql">
<![CDATA[ select t1.* from (
SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`ENABLE`, t1.`IBZDICTID`, t1.`IBZDICTNAME`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICT` t1
)t1 where ibzdictid=#{id}]]>
</select>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="IBZDictResultMap" type="cn.ibizlab.core.dict.domain.IBZDict" autoMapping="true">
<id property="dictId" column="ibzdictid" /><!--主键字段映射-->
<!--通过mybatis自动注入关系属性[关系实体],fetchType="lazy"为懒加载配置 -->
<collection property="items" ofType="cn.ibizlab.core.dict.domain.IBZDictItem" column="ibzdictid" select="cn.ibizlab.core.dict.mapper.IBZDictItemMapper.selectBydictid" fetchType="lazy"></collection>
</resultMap>
<!--数据集合[Default]-->
<select id="searchDefault" parameterType="cn.ibizlab.core.dict.filter.IBZDictSearchContext" resultMap="IBZDictResultMap">
select t1.* from (
<include refid="Default" />
)t1
<where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
<!--数据查询[Default]-->
<sql id="Default" databaseId="mysql">
select t1.* from (
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`ENABLE`, t1.`IBZDICTID`, t1.`IBZDICTNAME`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICT` t1 ]]>
<![CDATA[
WHERE
t1.ENABLE = 1
]]>
)t1
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="mysql">
select t1.* from (
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`ENABLE`, t1.`IBZDICTID`, t1.`IBZDICTNAME`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICT` t1 ]]>
<![CDATA[
WHERE
t1.ENABLE = 1
]]>
)t1
</sql>
</mapper>
!!!!模版产生代码错误:----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #if MajorPSDER.getMinorPSDataEntity??... [in template "CODETEMPL_zh_CN" at line 85, column 41]
----
\ No newline at end of file
......@@ -5,14 +5,12 @@
<!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性-->
<select id="selectById" resultMap="IBZDictItemResultMap" databaseId="mysql">
<![CDATA[ select t1.* from (
SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DICTID`, t1.`DICTITEMVAL`, t1.`IBZDICTITEMID`, t1.`IBZDICTITEMNAME`, t1.`ITEMCLS`, t1.`ITEMFILTER`, t1.`ITEMICON`, t1.`PITEMVAL`, t1.`SHOWORDER`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICTITEM` t1
)t1 where ibzdictitemid=#{id}]]>
<![CDATA[select t1.* from (SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DICTID`, t1.`DICTITEMVAL`, t1.`IBZDICTITEMID`, t1.`IBZDICTITEMNAME`, t1.`ITEMCLS`, t1.`ITEMFILTER`, t1.`ITEMICON`, t1.`PITEMVAL`, t1.`SHOWORDER`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICTITEM` t1 ) t1 where ibzdictitemid=#{id}]]>
</select>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="IBZDictItemResultMap" type="cn.ibizlab.core.dict.domain.IBZDictItem" autoMapping="true">
<id property="itemId" column="ibzdictitemid" /><!--主键字段映射-->
<id property="itemid" column="ibzdictitemid" /><!--主键字段映射-->
<result property="dictid" column="dictid" /><!--关系字段映射-->
<!--通过mybatis自动注入关系属性[主实体],fetchType="lazy"为懒加载配置 -->
<association property="dict" javaType="cn.ibizlab.core.dict.domain.IBZDict" column="dictid" select="cn.ibizlab.core.dict.mapper.IBZDictMapper.selectById" fetchType="lazy"></association>
......@@ -22,7 +20,7 @@
<select id="selectBydictid" resultMap="IBZDictItemResultMap">
select t1.* from (
<include refid="Default" />
)t1
) t1
where dictid=#{dictid}
</select>
......@@ -37,18 +35,14 @@
<!--数据查询[Default]-->
<sql id="Default" databaseId="mysql">
select t1.* from (
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DICTID`, t1.`DICTITEMVAL`, t1.`IBZDICTITEMID`, t1.`IBZDICTITEMNAME`, t1.`ITEMCLS`, t1.`ITEMFILTER`, t1.`ITEMICON`, t1.`PITEMVAL`, t1.`SHOWORDER`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICTITEM` t1 ]]>
<![CDATA[ ]]>
)t1
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DICTID`, t1.`DICTITEMVAL`, t1.`IBZDICTITEMID`, t1.`IBZDICTITEMNAME`, t1.`ITEMCLS`, t1.`ITEMFILTER`, t1.`ITEMICON`, t1.`PITEMVAL`, t1.`SHOWORDER`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICTITEM` t1
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="mysql">
select t1.* from (
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DICTID`, t1.`DICTITEMVAL`, t1.`IBZDICTITEMID`, t1.`IBZDICTITEMNAME`, t1.`ITEMCLS`, t1.`ITEMFILTER`, t1.`ITEMICON`, t1.`PITEMVAL`, t1.`SHOWORDER`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICTITEM` t1 ]]>
<![CDATA[ ]]>
)t1
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DICTID`, t1.`DICTITEMVAL`, t1.`IBZDICTITEMID`, t1.`IBZDICTITEMNAME`, t1.`ITEMCLS`, t1.`ITEMFILTER`, t1.`ITEMICON`, t1.`PITEMVAL`, t1.`SHOWORDER`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZDICTITEM` t1
]]>
</sql>
</mapper>
......
......@@ -21,8 +21,6 @@
<module>ibzdict-dependencies</module>
<!-- utils -->
<module>ibzdict-util</module>
<!-- comenpents -->
<module>ibzdict-mybatis</module>
<!-- cores -->
<module>ibzdict-core</module>
<!-- services -->
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册