提交 ef7c98ba 编写于 作者: Mosher's avatar Mosher

update:更新

1、表格列类型获取逻辑调整
2、多数据视图快速分组加载逻辑调整
3、预置导出行为调整
4、标签组件格式化逻辑调整
上级 b24eb94b
......@@ -23,9 +23,13 @@
<AppSpan
name="{{#if item.dataItemName}}{{lowerCase item.dataItemName}}{{else}}{{item.codeName}}{{/if}}"
:value="text"
{{#if item.psAppDEField}}
:dataType="{{item.psAppDEField.stdDataType}}"
{{/if}}
{{#each ctrl.psDEGridDataItems as | dataItem |}}
{{#eq dataItem.name item.dataItemName}}
{{#if dataItem.dataType}}
:dataType="{{dataItem.dataType}}"
{{/if}}
{{/eq}}
{{/each}}
valueFormat="{{item.valueFormat}}"
:precision="{{#if item.precision}}{{item.precision}}{{else}}0{{/if}}"
></AppSpan>
......
......@@ -8,7 +8,7 @@
<span>
<a-input-number v-model:value="startPage" @change="onChange('start')" :min="1" @click.stop :controls="false" />
~
<a-input-number v-model:value="endPage" @change="onChange('end')" @click.stop :min="1" :controls="false" />
<a-input-number v-model:value="endPage" @change="onChange('end')" @click.stop :min="2" :controls="false" />
<a-button type="text" @click="exportExcel('custom', $event)">GO</a-button>
</span>
</a-menu-item>
......@@ -38,7 +38,7 @@ const props = withDefaults(defineProps<exportExcelProps>(), {});
// 初始化选择值
const startPage = ref(1);
const endPage = ref(10);
const endPage = ref(2);
/**
* 导出数据
......
......@@ -21,7 +21,7 @@ const handleClick = ($event: any) => {
selectItem.value = $event;
emit('onQuickGroupEvent', {
tag: 'quickGroup',
action: "valueChange",
action: 'valueChange',
data: $event,
});
};
......@@ -31,27 +31,50 @@ const codeListService = App.getCodeListService();
onBeforeMount(() => {
if (codeListService) {
codeListService.getCodeListItems({ tag: props.quickGroupModel.codeListTag, context: props.context, viewParams: props.viewParams }).then((codeListItems: any[]) => {
items.value = codeListItems;
// 默认选中第一项
if (codeListItems.length) {
handleClick(items.value[0]);
}
})
codeListService
.getCodeListItems({
tag: props.quickGroupModel.codeListTag,
context: props.context,
viewParams: props.viewParams,
})
.then((codeListItems: any[]) => {
items.value = codeListItems;
// 默认选中第一项
if (codeListItems.length) {
emit('onQuickGroupEvent', {
tag: 'quickGroup',
action: 'initSuccess',
data: items.value[0],
});
}
})
.catch((error: any) => {
emit('onQuickGroupEvent', {
tag: 'quickGroup',
action: 'initError',
data: null,
});
});
}
});
</script>
<template>
<a-space class="app-quick-group" :size="0">
<a-button class="quick-group-item" v-for="(item, index) in items" :key="index" type="text" @click="handleClick(item)">
<a-button
class="quick-group-item"
v-for="(item, index) in items"
:key="index"
type="text"
@click="handleClick(item)"
>
<span :style="{ color: item.color }">
<AppIconText v-if="!item.children" :text="item.text" :iconClass="item.iconClass" :imgPath="item.imgPath" />
<a-dropdown v-else>
<AppIconText :text="item.text" :iconClass="item.iconClass" :imgPath="item.imgPath" />
<template #overlay>
<a-menu>
<a-menu-item v-for="(childItem,index) in item.children" :key="index">
<a-menu-item v-for="(childItem, index) in item.children" :key="index">
<AppIconText :text="childItem.text" :iconClass="childItem.iconClass" :imgPath="childItem.imgPath" />
</a-menu-item>
</a-menu>
......
<script setup lang="ts">
import { IParam, EditorBase, IContext } from "@core";
import { IParam, EditorBase, IContext, DataTypes, isExistAndNotEmpty } from "@core";
import moment from "moment";
import { onBeforeMount, ref, Ref } from "vue";
interface SpanProps {
/**
......@@ -24,7 +25,7 @@ interface SpanProps {
* @type {string}
* @memberof AppSpan
*/
dataType?: string;
dataType?: number;
/**
* 单位名称
......@@ -92,9 +93,14 @@ interface SpanProps {
const props = withDefaults(defineProps<SpanProps>(), {
unitName: "",
precision: 2,
dataType: 0
});
const { handleEditorNavParams, loadCodeListData } = new EditorBase();
const { navContext, navViewParam } = handleEditorNavParams(props);
// 数据类型
const dataTypeValue = computed(() => {
return DataTypes.toString(props.dataType);
})
let text: Ref<string> = ref("");
let textFormat: Ref<string> = ref("");
// 初始化值
......@@ -119,18 +125,24 @@ const initText = () => {
}
if (props.valueFormat) {
textFormat.value = props.valueFormat;
} else if (
Object.is(props.dataType, "DATETIME") ||
Object.is(props.dataType, "DATE") ||
Object.is(props.dataType, "TIME") ||
Object.is(props.dataType, "SMALLDATETIME")
) {
} else if (DataTypes.isDate(dataTypeValue.value)) {
textFormat.value = "YYYY-MM-DD HH:mm:ss";
} else if (Object.is(props.dataType, "NUMBER")) {
} else if (DataTypes.isNumber(dataTypeValue.value)) {
textFormat.value = `#${props.unitName}`;
}
}
const getFormatDate = () => {
if (!isExistAndNotEmpty(props.value)) {
return '';
}
const value = moment(props.value).format(textFormat.value);
if (value !== 'Invalid date') {
return value;
}
return props.value;
}
onBeforeMount(() => {
// 监听值变化
watch(() => props.value, (newVal: any, oldVal: any) => { if (newVal !== oldVal) initText(); });
......@@ -140,7 +152,9 @@ onBeforeMount(() => {
<template>
<div :class="['app-editor-container', 'app-span', `app-span-${name}`]">
<span v-format="textFormat">{{text}}</span>
<span v-if="DataTypes.isDate(dataTypeValue)">{{getFormatDate()}}</span>
<span v-else-if="textFormat" v-format="textFormat">{{text}}</span>
<span v-else>{{text}}</span>
</div>
</template>
......
......@@ -408,12 +408,16 @@ export class AppSysAction {
* @return {*}
*/
public static async exportExcel(params: IUIActionParams) {
const { actionEnvironment } = params;
const { actionEnvironment, event } = params;
const exportParams: IParam = {};
if (event && (event as any).exportParams) {
Object.assign(exportParams, (event as any).exportParams);
}
// 视图里获取多数据部件
if (actionEnvironment.xDataControl && hasFunction(actionEnvironment.xDataControl, "exportExcel")) {
await actionEnvironment.xDataControl.exportExcel();
await actionEnvironment.xDataControl.exportExcel(exportParams);
} else if (isExist(actionEnvironment.exportExcel)) {
await actionEnvironment.exportExcel();
await actionEnvironment.exportExcel(exportParams);
}
}
}
......@@ -76,7 +76,11 @@ export class MDView extends MainView {
// 初始化搜索栏引用
this.searchBar = ref(null);
onMounted(() => {
this.xDataControlLoad();
const { enableQuickGroup, quickGroupPSCodeList } = this.state;
// 开启快速分组时,挂载完成不主动加载数据
if (!enableQuickGroup || !quickGroupPSCodeList) {
this.xDataControlLoad();
}
});
}
......@@ -131,9 +135,11 @@ export class MDView extends MainView {
* @memberof MDView
*/
public handleQuickGroupSearch(args: any = {}): void {
this.state.quickGroupData = JSON.parse(args.data);
const tag = this.getMDCtrl().name;
this.next({ tag: tag, action: 'load', data: null });
if (args.data) {
this.state.quickGroupData = JSON.parse(args.data);
const tag = this.getMDCtrl().name;
this.next({ tag: tag, action: 'load', data: null });
}
}
/**
......@@ -211,10 +217,6 @@ export class MDView extends MainView {
if (searchBar) {
Object.assign(args, searchBar.getData());
}
// 快速搜索
// if (this.view && !this.view.isExpandSearchForm) {
// Object.assign(args, { query: this.view.query });
// }
// 快速分组
const { quickGroupData } = this.state;
if (quickGroupData && Object.keys(quickGroupData).length) {
......@@ -286,12 +288,22 @@ export class MDView extends MainView {
/**
* @description 处理快速分组事件
* @param {IActionParam} $event
* @param {IActionParam} actionParam
* @memberof MDView
*/
public onQuickGroupEvent($event: IActionParam) {
if ($event) {
this.handleQuickGroupSearch($event.data);
public onQuickGroupEvent(actionParam: IActionParam) {
const { action, data } = actionParam;
switch (action) {
case 'valueChange': // 值变化
this.handleQuickGroupSearch(data);
return;
case 'initSuccess': // 初始化完成
if (data.data) {
this.state.quickGroupData = JSON.parse(data.data);
}
case 'initError': // 初始化失败
this.xDataControlLoad();
break;
}
}
......
......@@ -892,7 +892,7 @@ export class FormControl extends MainControl {
* @memberof FormControl
*/
private async formValidateStatus(): Promise<boolean> {
const form = this.getXDataCtrl()?.value;
const form = this.xDataControl;
let result: boolean = true;
if (form && hasFunction(form, 'validate')) {
try {
......
......@@ -507,13 +507,18 @@ export class MDControl extends MainControl {
// 最大行
if (Object.is(opt.type, 'maxRowCount')) {
Object.assign(tempViewParams, { page: 0, size: opt.maxRowCount ? opt.maxRowCount : 1000 });
// } else if (Object.is(opt.type, 'activatedPage')) {
} else {
} else if (Object.is(opt.type, 'activatedPage')) {
// 当前激活页
const { current, pageSize } = mdCtrlPaging;
Object.assign(tempViewParams, { page: current - 1, size: pageSize });
this.doExport(items);
return;
} else if (Object.is(opt.type, 'custom')) {
const { pageSize } = this.state;
const { startPage, endPage } = opt;
if (startPage && endPage) {
Object.assign(tempViewParams, { page: 0, offset: (startPage - 1) * pageSize, size: (endPage - startPage + 1) * pageSize });
}
}
// 远程获取
const { noSort, minorSortDir, minorSortPSDEF } = mdCtrlSort;
......
......@@ -43,7 +43,7 @@ export class TreeExpBarControl extends ExpBarControl {
protected useSearch() {
const search = (value: any, event: MouseEvent) => {
const { viewSubject } = this.state;
const xData = this.getXDataCtrl();
const xData = this.xDataControl;
if (xData) {
viewSubject.next({ tag: xData.name, action: 'search', data: { query: value } });
}
......
......@@ -3,38 +3,38 @@
* 数据类型
*
*/
export class DataTypes {
export class DataTypes {
static readonly DataTypes: any = {
UNKNOWN : 0, //
BIGINT : 1,
BINARY : 2,
BIT : 3,
CHAR : 4,
DATETIME : 5,
DECIMAL : 6,
FLOAT : 7,
IMAGE : 8,
INT : 9,
MONEY : 10,
NCHAR : 11,
NTEXT : 12,
NVARCHAR : 13,
NUMERIC : 14,
REAL : 15,
SMALLDATETIME : 16,
SMALLINT : 17,
SMALLMONEY : 18,
SQL_VARIANT : 19,
SYSNAME : 20,
TEXT : 21,
TIMESTAMP : 22,
TINYINT : 23,
VARBINARY : 24,
VARCHAR : 25,
UNIQUEIDENTIFIER : 26,
DATE : 27, // 纯日期型
TIME : 28, // 纯时间
BIGDECIMAL : 29, // 大数值
UNKNOWN: 0, //
BIGINT: 1,
BINARY: 2,
BIT: 3,
CHAR: 4,
DATETIME: 5,
DECIMAL: 6,
FLOAT: 7,
IMAGE: 8,
INT: 9,
MONEY: 10,
NCHAR: 11,
NTEXT: 12,
NVARCHAR: 13,
NUMERIC: 14,
REAL: 15,
SMALLDATETIME: 16,
SMALLINT: 17,
SMALLMONEY: 18,
SQL_VARIANT: 19,
SYSNAME: 20,
TEXT: 21,
TIMESTAMP: 22,
TINYINT: 23,
VARBINARY: 24,
VARCHAR: 25,
UNIQUEIDENTIFIER: 26,
DATE: 27, // 纯日期型
TIME: 28, // 纯时间
BIGDECIMAL: 29, // 大数值
}
/**
......@@ -46,11 +46,11 @@ export class DataTypes {
* @return {*}
* @memberof DataTypes
*/
protected static equalsIgnoreCase(value:string, value2: string){
return value.toLocaleLowerCase() == value2.toLocaleLowerCase();
protected static equalsIgnoreCase(value: string, value2: string) {
return value.toLocaleLowerCase() == value2.toLocaleLowerCase();
}
/**
/**
* @description 字符串转数值
* @static
* @param {string} strValue
......@@ -58,11 +58,11 @@ export class DataTypes {
* @memberof DataTypes
*/
public static fromString(strValue: string): number {
let result = this.DataTypes[strValue.toUpperCase()];
return result || this.DataTypes.VARCHAR;
}
let result = this.DataTypes[strValue.toUpperCase()];
return result || this.DataTypes.VARCHAR;
}
/**
/**
* @description 是否为number类型
* @static
* @param {string} strValue
......@@ -70,15 +70,31 @@ export class DataTypes {
* @memberof DataTypes
*/
public static isNumber(strValue: string): boolean {
const numberTypes: any[] = ['BIGINT','BINARY','DECIMAL','FLOAT','INT','MONEY','NUMERIC','REAL','SMALLINT','SMALLMONEY','TINYINT','VARBINARY'];
if(numberTypes.indexOf(strValue) !== -1){
return true;
}else{
return false
const numberTypes: any[] = ['BIGINT', 'BINARY', 'DECIMAL', 'FLOAT', 'INT', 'MONEY', 'NUMERIC', 'REAL', 'SMALLINT', 'SMALLMONEY', 'TINYINT', 'VARBINARY'];
if (numberTypes.indexOf(strValue) !== -1) {
return true;
} else {
return false
}
}
}
/**
/**
* @description 是否是日期类型
* @static
* @param {string} strValue
* @return {*} {boolean}
* @memberof DataTypes
*/
public static isDate(strValue: string): boolean {
const numberTypes: any[] = ['DATETIME', 'DATE', 'TIME', 'SMALLDATETIME'];
if (numberTypes.indexOf(strValue) !== -1) {
return true;
} else {
return false
}
}
/**
* @description 获取字符串名称
* @static
* @param {number} nDataType
......@@ -87,13 +103,13 @@ export class DataTypes {
*/
public static toString(nDataType: number) {
let result = 'VARCHAR';
for(let key in this.DataTypes){
if(nDataType == this.DataTypes[key]){
for (let key in this.DataTypes) {
if (nDataType == this.DataTypes[key]) {
result = key;
break;
}
}
return result;
}
return result;
}
}
......@@ -410,12 +410,14 @@ export class FormatController {
} else if (temp === '?') {
returnHtml += ' ';
}
if (
isQianfenwei &&
(codeZhengshuNumCount - finishedNumCount) % 3 === 1 &&
codeZhengshuNumCount - finishedNumCount !== 1
) {
returnHtml += ',';
if (temp === '0') {
if (
isQianfenwei &&
(codeZhengshuNumCount - finishedNumCount) % 3 === 1 &&
codeZhengshuNumCount - finishedNumCount !== 1
) {
returnHtml += ',';
}
}
newFormatRule = newFormatRule.slice(1);
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册