提交 366b75a1 编写于 作者: xignzi006's avatar xignzi006

Merge remote-tracking branch 'origin/master'

......@@ -2,6 +2,7 @@ package cn.ibizlab.codegen.templating.handlebars;
import cn.ibizlab.codegen.utils.Inflector;
import cn.ibizlab.codegen.utils.StringAdvUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.jknack.handlebars.Helper;
import com.github.jknack.handlebars.Options;
import com.github.jknack.handlebars.TagType;
......@@ -117,6 +118,12 @@ public enum StringHelpers implements Helper<Object> {
protected CharSequence safeApply(final Object value, final Options options) {
return Inflector.getInstance().pluralize(StringAdvUtils.camelcase(value.toString()).toLowerCase());
}
},
jsonParse {
@Override
protected CharSequence safeApply(Object context, Options options) throws IOException {
return options.fn(JSONObject.parseObject(context.toString()));
}
};
......@@ -137,7 +144,7 @@ public enum StringHelpers implements Helper<Object> {
* @param options The options object.
* @return A string result.
*/
protected abstract CharSequence safeApply(Object context, Options options);
protected abstract CharSequence safeApply(Object context, Options options) throws IOException;
}
......@@ -26,7 +26,7 @@
codeListType="{{item.psEditor.psAppCodeList.codeListType}}"
{{/if}}
{{#if item.dataType}}
dataType="{{item.dataType}}"
:dataType="{{item.dataType}}"
{{/if}}
{{#if item.psEditor.editorParams.unitName}}
unitName="{{item.psEditor.editorParams.unitName}}"
......
......@@ -24,17 +24,21 @@
{{#if item.psEditor.readOnly}}
:readonly="{{item.psEditor.readOnly}}"
{{/if}}
{{#if item.psEditor.editorParams.precision}}
:precision="{{item.psEditor.editorParams.precision}}"
{{/if}}
{{#if item.psEditor.editorParams.stepValue}}
:step="{{item.psEditor.editorParams.stepValue}}"
{{/if}}
{{#if item.psEditor.editorParams.minValue}}
:min="{{item.psEditor.editorParams.minValue}}"
{{/if}}
{{#if item.psEditor.editorParams.maxValue}}
:max="{{item.psEditor.editorParams.maxValue}}"
{{#if item.psEditor.editorParams}}
{{#jsonParse item.psEditor.editorParams}}
{{#if precision}}
:precision="{{precision}}"
{{/if}}
{{#if step}}
:step="{{step}}"
{{/if}}
{{#if max}}
:max="{{max}}"
{{/if}}
{{#if min}}
:min="{{min}}"
{{/if}}
{{/jsonParse}}
{{/if}}
{{#if (or (eq ctrlType 'form') (eq ctrlType 'panel'))}}
:value="state.data.{{item.psEditor.name}}"
......
......@@ -130,9 +130,12 @@ const handleContentShowStatusChange = (event: MouseEvent) => {
}
}
.ant-card-body {
height: calc(100% - 38px);
height: 100%;
padding-top: 6px;
}
.ant-card-head + .ant-card-body {
height: calc(100% - 38px);
}
}
.show-content-icon {
position: absolute;
......
......@@ -162,7 +162,7 @@ const handelViewEvent = (actionParam: IActionParam) => {
case 'viewDataChange':
viewDataChange(data);
break;
case 'close':
case 'viewClose':
close(data);
break;
}
......
<script setup lang="ts">
import { onBeforeMount, Ref, ref } from 'vue';
import { SearchOutlined, ExportOutlined } from '@ant-design/icons-vue';
import { deepCopy, IParam, IActionParam, EditorBase, IContext, PickupView } from '@core';
import { SearchOutlined, ExportOutlined, CloseCircleOutlined } from '@ant-design/icons-vue';
import { deepCopy, IParam, IActionParam, EditorBase, IContext, PickupView, isExistAndNotEmpty } from '@core';
interface DataPickerProps {
/**
* @description 编辑器名称
......@@ -116,12 +116,12 @@ interface DataPickerProps {
/**
* @description 无AC
*/
noAc?:boolean;
noAc?: boolean;
/**
* @description 显示按钮
*/
showButton?:boolean;
showButton?: boolean;
/**
* @description 是否下拉
......@@ -200,15 +200,18 @@ const onSearch = (value: string) => {
App.getNotificationService().warning({ message: '获取数据失败', desription: '查询参数不存在' });
} else {
const { serviceName, interfaceName } = props.acParams;
props.service.getItems(serviceName, interfaceName, _navContext, _navViewParam).then((response: any) => {
if (!response) {
App.getNotificationService().warning({ message: '获取数据失败', desription: '' });
return;
}
items.value = [...response];
}).catch((error: any) => {
App.getNotificationService().warning({ message: '获取数据失败', desription: error?.message });
})
props.service
.getItems(serviceName, interfaceName, _navContext, _navViewParam)
.then((response: any) => {
if (!response) {
App.getNotificationService().warning({ message: '获取数据失败', desription: '' });
return;
}
items.value = [...response];
})
.catch((error: any) => {
App.getNotificationService().warning({ message: '获取数据失败', desription: error?.message });
});
}
};
......@@ -216,6 +219,7 @@ const filterOption = (inputValue: string, option: IParam) => {
return option[props.deMajorField].toUpperCase().indexOf(inputValue.toUpperCase()) >= 0;
};
// 选中
const onSelect = (value: any) => {
const selectItem = items.value.find((item: IParam) => Object.is(item[props.deKeyField!], value));
emit('editorEvent', {
......@@ -223,17 +227,35 @@ const onSelect = (value: any) => {
action: 'valueChange',
data: selectItem[props.deMajorField!],
});
emit('editorEvent', { tag: props.valueItem, action: 'valueChange', data: selectItem[props.deKeyField!] });
if (props.valueItem) {
emit('editorEvent', { tag: props.valueItem, action: 'valueChange', data: selectItem[props.deKeyField!] });
}
fillPickUpData(selectItem);
};
// 清空值
const clear = (value: any) => {
emit('editorEvent', {
tag: props.name,
action: 'valueChange',
data: null,
});
if (props.valueItem) {
emit('editorEvent', { tag: props.valueItem, action: 'valueChange', data: null });
}
};
// 编辑器抛值
const doEditorEmit = (data: any[]): any => {
let majorValue: any = '';
let keyValue: any = '';
data.forEach((item: any) => {
majorValue = item[props.deMajorField] ? majorValue + (majorValue ? props.separator : '') + item[props.deMajorField] : majorValue + (majorValue ? props.separator : '') + item['srfmajortext'];
keyValue = item[props.deKeyField] ? keyValue + (keyValue ? props.separator : '') + item[props.deKeyField] : keyValue + (keyValue ? props.separator : '') + item['srfkey'];
majorValue = item[props.deMajorField]
? majorValue + (majorValue ? props.separator : '') + item[props.deMajorField]
: majorValue + (majorValue ? props.separator : '') + item['srfmajortext'];
keyValue = item[props.deKeyField]
? keyValue + (keyValue ? props.separator : '') + item[props.deKeyField]
: keyValue + (keyValue ? props.separator : '') + item['srfkey'];
});
if (props.valueItem) {
emit('editorEvent', { tag: props.valueItem, action: 'valueChange', data: keyValue });
......@@ -252,9 +274,28 @@ const openView = () => {
return;
}
const params: IParam = {};
if (!Object.is(view.openMode,'POPOVER') && !Object.is(view.openMode,'POPOVER')) {
Object.assign(params,{openMode: 'POPUPMODAL'})
// 选中数据
const selectedData: IParam = {};
// 值项
if (props.data && props.valueItem && isExistAndNotEmpty(props.data[props.valueItem])) {
Object.assign(selectedData, { srfkey: props.data[props.valueItem] });
}
if (isExistAndNotEmpty(props.value)) {
Object.assign(selectedData, { srfmajortext: props.value });
}
// 导航参数
const tempViewParams = deepCopy(navViewParam);
Object.assign(tempViewParams, { selectedData: [selectedData] });
if (!Object.is(view.openMode, 'POPOVER') && !Object.is(view.openMode, 'POPOVER')) {
Object.assign(params, { openMode: 'POPUPMODAL' });
}
Object.assign(params, {
context: deepCopy(navContext),
viewParams: tempViewParams
});
const subject = App.getOpenViewService().openView(view, params);
const subjectEvent = subject?.subscribe((data: any) => {
if (data?.ret == 'OK' && data.resultData) {
......@@ -267,7 +308,6 @@ const openView = () => {
const onChange = (date: string, dateString: string) => {
// todo
};
</script>
<template>
......@@ -277,7 +317,6 @@ const onChange = (date: string, dateString: string) => {
<template v-else-if="!isAC && !isDropdown">
<a-auto-complete
:class="['app-editor-container', 'app-data-picker', `app-data-picker-${name}`]"
:allowClear="true"
v-model:value="value"
:placeholder="placeholder"
:options="items"
......@@ -291,6 +330,7 @@ const onChange = (date: string, dateString: string) => {
</template>
<a-input :placeholder="placeholder">
<template #suffix>
<CloseCircleOutlined @click="clear" />
<SearchOutlined v-if="pickUpView" class="certain-category-icon" @click="openView" />
<ExportOutlined v-if="linkView" @click="openLinkView" />
</template>
......@@ -308,7 +348,6 @@ const onChange = (date: string, dateString: string) => {
<template v-else-if="isDropdown">
<a-select
:class="['app-editor-container', 'app-data-picker', `app-data-picker-${name}`]"
allowClear
showSearch
v-model:value="value"
:disabled="disabled"
......@@ -318,6 +357,7 @@ const onChange = (date: string, dateString: string) => {
:placeholder="placeholder"
>
<template #suffixIcon>
<CloseCircleOutlined @click="clear" />
<SearchOutlined v-if="pickUpView" @click="openPickUpView" />
<ExportOutlined v-if="linkView" @click="openLinkView" />
</template>
......@@ -328,4 +368,18 @@ const onChange = (date: string, dateString: string) => {
</template>
</template>
<style scoped></style>
<style scoped lang="scss">
.app-data-picker {
.anticon {
padding: 0 3px;
}
.anticon-close-circle {
display: none;
}
&:hover {
.anticon-close-circle {
display: block;
}
}
}
</style>
<template>
<div class="app-stepper">
<a-input :value="result" :min="min" :max="max" :step="step" :precision="precision" :disabled="disabled || readonly">
<a-input-number v-model:value="result" :min="min" :max="max" :step="step" :precision="precision" :disabled="disabled || readonly" :controls="false">
<template #addonBefore>
<a-button type="text" :disabled="disabled || readonly || result <= min" @click="btnReduce">-</a-button>
</template>
<template #addonAfter>
<a-button type="text" :disabled="disabled || readonly || result >= max" @click="btnIcrease">+</a-button>
</template>
</a-input>
</a-input-number>
</div>
</template>
<script setup lang="ts">
......@@ -128,10 +128,10 @@ const btnIcrease = () => {
background: transparent;
}
}
.ant-input-group-addon {
.ant-input-number-group-addon {
padding: 0;
}
.ant-input {
.ant-input-number-input {
text-align: center;
}
}
......
import { PickupViewState } from '@core';
import { IParam, PickupViewState } from '@core';
/**
* @description 多选视图状态
......@@ -7,5 +7,11 @@ import { PickupViewState } from '@core';
* @extends {PickupViewState}
*/
export interface MPickupViewState extends PickupViewState {
/**
* 选中数据
*
* @type {IParam[]}
* @memberof MPickupViewState
*/
selections: IParam[];
}
import { IActionParam, IParam, PickupView } from "@core";
import { MainView } from "../main-view";
import { IParam, PickupView } from "@core";
import { MPickupViewProps } from "./mpickup-view-prop";
import { MPickupViewState } from "./mpickup-view-state";
......@@ -18,18 +17,25 @@ export class MPickupView extends PickupView {
*/
public declare state: MPickupViewState;
public select: IParam = {};
/**
* @description 视图输入参数
* @type {MPickupViewProps}
* @memberof MPickupView
*/
public declare props: MPickupViewProps;
public useSelections: any[] = [];
public select: IParam = {};
public onMoveRight() {
this.useSelections.push(this.selectData);
const { selections, selectedData } = toRefs(this.state);
selections.value.push(selectedData.value);
}
public onMoveLeft() {
const index = this.useSelections.findIndex((selection: any) => Object.is(this.select.srfkey, selection.srfkey));
const { selections } = toRefs(this.state);
const index = selections.value.findIndex((selection: any) => Object.is(this.select.srfkey, selection.srfkey));
if (index !== -1) {
this.useSelections.splice(index, 1);
selections.value.splice(index, 1);
}
}
......@@ -38,7 +44,8 @@ export class MPickupView extends PickupView {
}
public onAllMoveLeft() {
this.useSelections = [];
const { selections } = toRefs(this.state);
selections.value.splice(0, selections.value.length);
}
/**
......@@ -50,7 +57,6 @@ export class MPickupView extends PickupView {
const superParams = super.moduleInstall();
return {
...superParams,
useSelections: this.useSelections,
onMoveRight: this.onMoveRight.bind(this),
onMoveLeft: this.onMoveLeft.bind(this),
onAllMoveRight: this.onAllMoveRight.bind(this),
......
import { GridViewState } from '@core';
import { GridViewState, IParam } from '@core';
/**
* @description 选择视图状态
......@@ -7,5 +7,11 @@ import { GridViewState } from '@core';
* @extends {GridViewState}
*/
export interface PickupGridViewState extends GridViewState {
/**
* 选中数据
*
* @type {IParam[]}
* @memberof PickupGridViewState
*/
selectedData: IParam[];
}
import { ControlAction, MainViewState } from '@core';
import { MainViewState, IParam } from '@core';
/**
* @description 选择视图状态
......@@ -7,5 +7,12 @@ import { ControlAction, MainViewState } from '@core';
* @extends {ViewStateBase}
*/
export interface PickupViewState extends MainViewState {
/**
* 选中数据
*
* @type {IParam[]}
* @memberof PickupViewState
*/
selectedData: IParam[];
}
......@@ -18,19 +18,22 @@ export class PickupView extends MainView {
*/
public declare state: PickupViewState;
public selectData: any[] = [];
/**
* @description 选择视图输入参数
* @type {PickupViewProps}
* @memberof PickupView
*/
public declare props: PickupViewProps;
/**
* @description 使用加载功能模块
* @param {PickupViewProps} props 传入的props
* 使用视图初始化模块
*
* @memberof PickupView
*/
public useLoad(props: PickupViewProps) {
const { viewSubject } = this.state;
onMounted(() => {
viewSubject.next({ tag: 'grid', action: "load", data: {} })
})
public useViewInit() {
super.useViewInit();
const { viewParams } = this.state;
this.state.selectedData = ref(viewParams.selectedData) || ref([]);
}
/**
......@@ -38,7 +41,7 @@ export class PickupView extends MainView {
* @memberof PickupView
*/
public onCancel() {
this.emit('close', []);
this.emit('viewEvent', { tag: this.state.viewName, action: 'viewClose', data: null });
}
/**
......@@ -46,24 +49,27 @@ export class PickupView extends MainView {
* @memberof PickupView
*/
public onConfirm() {
this.emit('viewEvent', { data: this.selectData, tag: '', action: 'close' })
this.emit('viewEvent', { tag: this.state.viewName, action: 'viewDataChange', data: this.state.selectedData });
this.emit('viewEvent', { tag: this.state.viewName, action: 'viewClose', data: null });
}
/**
* 处理部件事件
*
* @param {IActionParam} actionParam
* @memberof PickupView
*/
public onCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
// TODO
if (action === 'selectionChange') {
this.selectData = data;
this.emit('viewEvent', { data: this.selectData, tag: '', action: 'viewDataChange' })
}
if (action === 'close') {
this.emit('viewEvent', { data: this.selectData, tag: '', action: 'viewDataChange' })
const { selectedData } = toRefs(this.state);
if (data && data.length > 0) {
selectedData.value = [...data];
}
}
super.onCtrlEvent(actionParam);
}
/**
* @description 安装视图所有功能模块的方法
* @return {*}
......@@ -73,7 +79,6 @@ export class PickupView extends MainView {
const superParams = super.moduleInstall();
return {
...superParams,
selectData:this.selectData,
onCancel: this.onCancel.bind(this),
onConfirm: this.onConfirm.bind(this)
};
......
......@@ -93,7 +93,7 @@ export class ViewBase {
window.history.back();
} else {
// 非路由模式继续向外抛关闭视图事件
this.emit('viewEvent', { tag: this.state.viewName, action: 'closeView', data: this.xDataControl?.getData() });
this.emit('viewEvent', { tag: this.state.viewName, action: 'viewClose', data: this.xDataControl?.getData() });
}
}
......@@ -228,7 +228,7 @@ export class ViewBase {
*/
public onCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
if (Object.is(action, 'closeView')) {
if (Object.is(action, 'viewClose')) {
this.closeView();
}
}
......
......@@ -87,6 +87,14 @@ export class ControlBase {
});
}
/**
* 使用部件初始化模块
*
* @protected
* @memberof ControlBase
*/
protected useCtrlInit(): void {};
/**
* 获取当前激活数据
*
......@@ -101,7 +109,7 @@ export class ControlBase {
*
*/
public closeView() {
this.emit('ctrlEvent', { tag: this.props.name, action: 'closeView', data: undefined });
this.emit('ctrlEvent', { tag: this.props.name, action: 'viewClose', data: undefined });
}
/**
......@@ -124,7 +132,9 @@ export class ControlBase {
// 处理导航参数
this.useControlContextParams();
// 使用计数器服务
this.useCounterService();
this.useCounterService();
// 使用部件初始化模块
this.useCtrlInit();
return {
state: this.state,
name: this.state.controlName,
......
import { DataTypes, dateFormat, deepCopy, GridControlState, IActionParam, IParam, isExistAndNotEmpty, MDControl, Verify } from "@core";
import { DataTypes, dateFormat, deepCopy, GridControlState, IActionParam, IParam, isExistAndNotEmpty, MDControl } from "@core";
import { createUUID } from "qx-util";
import schema, { ErrorList, FieldErrorList } from 'async-validator';
import { Ref } from "vue";
......@@ -25,15 +25,6 @@ export class GridControl extends MDControl {
*/
private formRef: any;
/**
* @description
* @param {GridControlProps} props
* @memberof GridControl
*/
public setState() {
super.setState();
}
/**
* @description 使用自定义模块(蚂蚁金服UI自定义)
* @memberof GridControl
......@@ -61,48 +52,18 @@ export class GridControl extends MDControl {
return {
onClick: () => {
// 单击激活
if (this.state.rowActiveMode === 1) {
if (!rowEditState) {
const activeIndex: number = this.state.selectedRowKeys.findIndex((key: string) => {
return record.srfkey === key;
});
if (activeIndex === -1) {
this.state.selectedRowKeys.push(record.srfkey);
this.state.selectedData.push(record);
} else {
this.state.selectedRowKeys = this.state.selectedRowKeys.filter((key: string) => {
return key !== record.srfkey;
})
this.state.selectedData = this.state.selectedData.filter((item: any) => {
return item.srfkey !== record.srfkey;
})
}
if (!record.children) {
this.emit("ctrlEvent", { tag: this.props.name, action: "selectionChange", data: [record] });
this.emit("ctrlEvent", { tag: this.props.name, action: "rowClick", data: [record] });
}
if (this.state.rowActiveMode === 1 && !rowEditState) {
this.selectRow(record, index);
if (!record.children) {
this.emit("ctrlEvent", { tag: this.props.name, action: "rowClick", data: [record] });
}
}
},
onDblclick: () => {
// 双击激活
if (this.state.rowActiveMode === 2) {
if (this.state.rowActiveMode === 2 && !rowEditState) {
if (!record.children) {
const activeIndex: number = this.state.selectedRowKeys.findIndex((key: string) => {
return record.srfkey === key;
});
if (activeIndex === -1) {
this.state.selectedRowKeys.push(record.srfkey);
this.state.selectedData.push(record);
} else {
this.state.selectedRowKeys = this.state.selectedRowKeys.filter((key: string) => {
return key !== record.srfkey;
})
this.state.selectedData = this.state.selectedData.filter((item: any) => {
return item.srfkey !== record.srfkey;
})
}
this.selectRow(record, index);
this.emit("ctrlEvent", { tag: this.props.name, action: "rowDbClick", data: [record] });
}
}
......@@ -116,11 +77,12 @@ export class GridControl extends MDControl {
}
// 表格选择功能配置
const useRowSelectionOption = computed(() => {
// 作为导航部件或单选时不呈现多选框
if (selectFirstDefault) {
return false;
}
return {
type: isSingleSelect ? 'radio' : 'checkbox',
type: this.state.isMultiple ? 'checkbox' : 'radio',
columnWidth: selectColumnWidth,
selectedRowKeys: this.state.selectedRowKeys,
checkStrictly: false,
......@@ -143,7 +105,7 @@ export class GridControl extends MDControl {
}
})
// 选中赋值
this.state.selectedData = selection;
this.state.selections = selection;
this.emit("ctrlEvent", { tag: this.props.name, action: "selectionChange", data: selection })
},
};
......@@ -396,16 +358,22 @@ export class GridControl extends MDControl {
* @memberof GridControl
*/
public handleDefaultSelect() {
const { selectedData, selectFirstDefault, controlName, items } = this.state;
const { selectedRowKeys } = toRefs(this.state);
const { selectedData, selectFirstDefault, items } = this.state;
const { selectedRowKeys, selections } = toRefs(this.state);
if (selectedData?.length > 0) {
const _selectedRowKeys: string[] = [];
const _selections: IParam[] = [];
selectedData.forEach((selected: IParam) => {
if (selected.srfkey) {
_selectedRowKeys.push(selected.srfkey);
const item = items.find((item: IParam) => item.srfkey === selected.srfkey);
if (item) {
_selections.push(item);
}
}
});
selectedRowKeys.value = _selectedRowKeys;
selectedRowKeys.value = [..._selectedRowKeys];
selections.value = [..._selections];
} else if (selectFirstDefault) {
if (items && items.length > 0) {
this.emit("ctrlEvent", {
......@@ -828,6 +796,35 @@ export class GridControl extends MDControl {
return validateStatus;
}
/**
* 选中行(手动单击或双击激活行触发)
*
* @private
* @param {IParam} record
* @param {number} index
* @memberof GridControl
*/
private selectRow(record: IParam, index: number) {
const { isMultiple } = this.state;
const { selections, selectedRowKeys } = toRefs(this.state);
const _index = selections.value.findIndex((selection: any) => selection.srfkey === record.srfkey);
// 存在选中则删除
if (_index !== -1) {
selections.value.splice(_index, 1);
selectedRowKeys.value.splice(_index, 1);
} else {
// 单选清空已选中
if (!isMultiple) {
selections.value.splice(_index, selections.value.length);
selectedRowKeys.value.splice(_index, selectedRowKeys.value.length);
}
selections.value.push(record);
selectedRowKeys.value.push(record.srfkey);
}
this.emit('ctrlEvent', { tag: this.props.name, action: 'selectionChange', data: selections.value });
}
/**
* @description 安装部件所有功能模块的方法
* @return {*}
......
......@@ -144,10 +144,10 @@ export class ListControl extends MDControl {
*/
private handleDefaultSelect() {
const { selectFirstDefault } = this.state;
const { selectedData, items } = toRefs(this.state);
const { selections, items } = toRefs(this.state);
if (selectFirstDefault) {
if (items.value && items.value.length > 0) {
selectedData.value.push(items.value[0]);
selections.value.push(items.value[0]);
this.emit("ctrlEvent", {
tag: this.props.name,
action: "selectionChange",
......@@ -195,19 +195,19 @@ export class ListControl extends MDControl {
*/
const onListItemSelected = (item: IParam, event: MouseEvent) => {
const { isMultiple } = this.state;
const { selectedData } = toRefs(this.state);
const index = selectedData.value.findIndex((selection: any) => selection.srfkey === item.srfkey);
const { selections } = toRefs(this.state);
const index = selections.value.findIndex((selection: any) => selection.srfkey === item.srfkey);
// 存在选中则删除
if (index !== -1) {
selectedData.value.splice(index, 1);
selections.value.splice(index, 1);
} else {
// 单选清空已选中
if (!isMultiple) {
selectedData.value.splice(index, selectedData.value.length);
selections.value.splice(index, selections.value.length);
}
selectedData.value.push(item);
selections.value.push(item);
}
this.emit('ctrlEvent', { tag: this.props.name, action: 'selectionChange', data: selectedData.value });
this.emit('ctrlEvent', { tag: this.props.name, action: 'selectionChange', data: selections.value });
}
/**
......@@ -216,8 +216,8 @@ export class ListControl extends MDControl {
* @returns
*/
const isSelected = (item: IParam): boolean => {
const { selectedData } = toRefs(this.state);
return selectedData.value.findIndex((selection: any) => selection.srfkey === item.srfkey) !== -1;
const { selections } = toRefs(this.state);
return selections.value.findIndex((selection: any) => selection.srfkey === item.srfkey) !== -1;
}
/**
......
......@@ -72,12 +72,19 @@ export interface MDControlState extends MainControlState {
rowActiveMode: 0 | 1 | 2;
/**
* @description 选中数据
* @description 选中数据(选择视图传递)
* @type {IParam[]}
* @memberof MDControlState
*/
selectedData: IParam[];
/**
* @description 选中数据
* @type {IParam[]}
* @memberof MDControlState
*/
selections: IParam[];
/**
* @description 选中行keys
* @type {string[]}
......
......@@ -16,23 +16,45 @@ export class MDControl extends MainControl {
public declare state: MDControlState;
/**
* @description
* @description 设置多数据部件状态
* @memberof MDControl
*/
public setState() {
super.setState();
// 交联输入Props
this.state.isMultiple = toRef(this.props, 'isMultiple') as any;
this.state.isMultiple = toRef(this.props, 'multiple') as any;
this.state.rowEditState = toRef(this.props, 'rowEditState') as any;
this.state.rowActiveMode = toRef(this.props, 'rowActiveMode') as any;
if (this.props['selectedData']) {
this.state.selectedData = UIBase.toOneWayRef(this.props, 'selectedData') as any;
} else {
if (!this.state.selectedData) {
this.state.selectedData = ref([]) as any;
this.state.selectFirstDefault = toRef(this.props, 'selectFirstDefault') as any;
}
protected useCtrlInit() {
super.useCtrlInit();
this.handleSelectedData();
}
/**
* 处理选中数据
*
* @private
* @memberof MDControl
*/
protected handleSelectedData() {
const { viewParams } = this.state;
// 存在该字段则表示在选择视图中
if (viewParams && viewParams.selectedData) {
const data = viewParams.selectedData[0];
const keys = data?.srfkey?.split(',') || [];
this.state.selectedData = [];
if (keys.length) {
keys.forEach((key: string) => {
this.state.selectedData.push({ srfkey: key });
});
} else {
// 无值时给一个空对象,确保清空选中数据
this.state.selectedData.push({});
}
}
this.state.selectFirstDefault = toRef(this.props, 'selectFirstDefault') as any;
}
/**
......@@ -626,7 +648,7 @@ export class MDControl extends MainControl {
* @memberof MDControl
*/
public getData(): IParam[] {
return this.state.selectedData;
return this.state.selections;
}
/**
......
......@@ -27,5 +27,5 @@ export interface PickupViewPanelControlState extends MainControlState {
* @type {string}
* @memberof PickupViewPanelControlState
*/
selectedData: string;
selectedData: IParam[];
}
\ No newline at end of file
import { IActionParam, MainControl } from '@core';
import { IParam } from '@core/interface';
import { PickupViewPanelControlProps } from './pickup-view-panel-control-prop';
import { PickupViewPanelControlState } from './pickup-view-panel-control-state';
......@@ -17,6 +18,16 @@ export class PickupViewPanelControl extends MainControl {
*/
public declare state: PickupViewPanelControlState;
/**
* 设置部件状态
*
* @memberof PickupViewPanelControl
*/
public setState(): void {
super.setState();
this.state.selectedData = toRef(this.props, 'selectedData') as any;
}
/**
* @description
* @param {PickupViewPanelControlProps} props
......@@ -49,8 +60,32 @@ export class PickupViewPanelControl extends MainControl {
const { tag, action, data } = actionParam;
const { controlName } = this.state;
if (Object.is("selectionChange", action)) {
this.emit("onCtrlEvent", { tag: this.props.name, action: action, data: data });
this.handleSelectionChange(data);
}
}
/**
* 处理数据变化
*
* @private
* @param {IParam[]} items
* @return {*}
* @memberof PickupViewPanelControl
*/
private handleSelectionChange(items: IParam[]) {
if (items && items.length) {
const { appDeKeyFieldName, appDeMajorFieldName } = this.state;
const _items: IParam[] = [];
items.forEach((item: IParam, index: number) => {
_items.push({
srfkey: item.srfkey ? item.srfkey : item[appDeKeyFieldName.toLowerCase()],
srfmajortext: item.srfmajortext ? item.srfmajortext : item[appDeMajorFieldName.toLowerCase()]
});
});
this.emit("onCtrlEvent", { tag: this.props.name, action: 'selectionChange', data: _items });
return;
}
this.emit("onCtrlEvent", { tag: this.props.name, action: 'selectionChange', data: [] });
}
/**
......
......@@ -30,7 +30,7 @@ const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法
const mpickupView = new MPickupView(viewState, props, emit).moduleInstall();
const { state, onCancel, onConfirm, onCtrlEvent, useSelections, onMoveRight, onMoveLeft, onAllMoveRight, onAllMoveLeft } = mpickupView;
const { state, onCancel, onConfirm, onCtrlEvent, onMoveRight, onMoveLeft, onAllMoveRight, onAllMoveLeft } = mpickupView;
</script>
<template>
......@@ -62,6 +62,7 @@ const { state, onCancel, onConfirm, onCtrlEvent, useSelections, onMoveRight, onM
:viewParams="state.viewParams"
:controlAction="state.{{name}}.action"
:viewSubject="state.viewSubject"
:multiple="true"
:parent="mpickupView"
@onCtrlEvent="onCtrlEvent"
></{{codeName}}PickupViewPanel>
......@@ -77,7 +78,7 @@ const { state, onCancel, onConfirm, onCtrlEvent, useSelections, onMoveRight, onM
</a-space>
</a-col>
<a-col :span="5" class="split__right">
<div v-for="(item,index) in useSelections" :key="index">\{{item.srfmajortext}}</div>
<div v-for="(item,index) in state.selections" :key="index">\{{item.srfmajortext}}</div>
</a-col>
</a-row>
<template v-slot:footer>
......
export const viewState = {
enableQuickSearch: {{#if page.enableQuickSearch}}{{page.enableQuickSearch}}{{else}}false{{/if}},
expandSearchForm: {{#if page.expandSearchForm}}{{page.expandSearchForm}}{{else}}false{{/if}},
expandSearchForm: {{#if page.expandSearchForm}}{{page.expandSearchForm}}{{else}}false{{/if}},
gridRowActiveMode: {{page.gridRowActiveMode}},
rowEditState: {{#if page.enableRowEdit}}{{page.rowEditDefault}}{{else}}false{{/if}},
{{> @macro/front-end/views/view-base-config.hbs}}
};
\ No newline at end of file
......@@ -22,11 +22,13 @@ interface Props {
viewParams?: IParam;
openType?: "ROUTE" | "MODAL" | "EMBED";
viewSubject?: Subject<IActionParam>;
selectedData?: string;
selectedData?: string;
multiple?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
openType:'ROUTE',
openType: 'ROUTE',
multiple: false,
viewSubject: () => new Subject<IActionParam>()
})
......@@ -105,7 +107,7 @@ const { state, grid, onCtrlEvent, onQuickGroupEvent, onQuickSearchEvent } = pick
ref="grid"
name="{{name}}"
:context="state.context"
:multiple="false"
:multiple="multiple"
:rowEditState="state.rowEditState"
:rowActiveMode="state.gridRowActiveMode"
:showBusyIndicator="true"
......
......@@ -29,7 +29,7 @@ const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法
const pickupView = new PickupView(viewState, props, emit).moduleInstall();
const { state, onCancel, onConfirm, onCtrlEvent, selectData } = pickupView;
const { state, onCancel, onConfirm, onCtrlEvent } = pickupView;
</script>
<template>
......@@ -57,7 +57,7 @@ const { state, onCancel, onConfirm, onCtrlEvent, selectData } = pickupView;
:viewParams="state.viewParams"
:controlAction="state.{{name}}.action"
:viewSubject="state.viewSubject"
:selectData="selectData"
:selectedData="state.selectedData"
:parent="pickupView"
@onCtrlEvent="onCtrlEvent"
></{{codeName}}PickupViewPanel>
......
......@@ -81,6 +81,7 @@ export const ctrlState = {
],
{{/if}}
items: [],
selections: [],
selectedRowKeys: [],
// 多数据部件分组
mdCtrlGroup: {
......
......@@ -14,7 +14,6 @@ interface Props {
multiple?: boolean;
rowEditState?: boolean;
rowActiveMode?: 0 | 1 | 2;
selectedData?: IParam[];
selectFirstDefault?: boolean;
controlAction: ControlAction;
showBusyIndicator?: boolean;
......
......@@ -45,6 +45,7 @@ export const ctrlState = {
appDeKeyFieldName: '{{#if ctrl.psAppDataEntity.keyPSAppDEField}}{{ctrl.psAppDataEntity.keyPSAppDEField.codeName}}{{/if}}',
appDeMajorFieldName: '{{#if ctrl.psAppDataEntity.majorPSAppDEField}}{{ctrl.psAppDataEntity.majorPSAppDEField.codeName}}{{/if}}',
controlService: new ListService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ),
selections: [],
dataItems: [
{{#if ctrl.psDEListDataItems}}
{{#each ctrl.psDEListDataItems as | dataItem |}}
......
......@@ -17,7 +17,6 @@ interface Props {
context: IContext;
viewParams: IParam;
multiple?: boolean;
selectedData?: IParam[];
selectFirstDefault?: boolean;
controlAction: ControlAction;
showBusyIndicator?: boolean;
......
export const ctrlState = {
appEntityCodeName: '{{ctrl.psAppDataEntity.codeName}}',
appDeCodeName:'{{ctrl.psAppDataEntity.codeName}}',
appDeLogicName: '{{ctrl.psAppDataEntity.logicName}}',
appDeKeyFieldName: '{{#if ctrl.psAppDataEntity.keyPSAppDEField}}{{ctrl.psAppDataEntity.keyPSAppDEField.codeName}}{{/if}}',
appDeMajorFieldName: '{{#if ctrl.psAppDataEntity.majorPSAppDEField}}{{ctrl.psAppDataEntity.majorPSAppDEField.codeName}}{{/if}}',
controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}',
selectedData: [],
data: {},
};
\ No newline at end of file
......@@ -17,6 +17,7 @@ interface Props {
selectedData?: string;
isShowButton?: boolean;
viewSubject: Subject<IActionParam>;
multiple?: boolean;
}
const props = withDefaults(defineProps < Props > (), {
......@@ -25,6 +26,7 @@ const props = withDefaults(defineProps < Props > (), {
isSingleSelect: false,
isShowButton: true,
showBusyIndicator: true,
multiple: false
})
// emit声明
......@@ -51,10 +53,11 @@ defineExpose({ name, state});
:isShowButton="state.isShowButton"
:selectedData="state.selectedData"
:viewSubject="state.viewSubject"
:multiple="multiple"
@viewEvent="onViewEvent"
/>
{{else}}
{{else}}
<div class="app-pickup-view-panel--empty">视图不存在,请配置选择视图</div>
{{/if}}
{{/if}}
</div>
</template>
\ No newline at end of file
......@@ -225,5 +225,6 @@ export const ctrlState = {
echoSelectedNodes: [],
expandedKeys: [],
selectedKeys: [],
selectedNodes: []
selectedNodes: [],
selections: []
};
\ No newline at end of file
......@@ -8,7 +8,6 @@ interface Props {
name:string,
parent: IParam;
context: IContext;
selectedData?: IParam[];
selectFirstDefault?: boolean;
isBranchAvailable?: boolean;
viewParams?: IParam;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册