提交 2d09c171 编写于 作者: RedPig97's avatar RedPig97

update:更新

上级 3657452c
......@@ -4,8 +4,8 @@
{{#*inline "AC_FS_NOBUTTON"}}{{>@macro/editor/auto-complete.hbs}}{{/inline}}
{{#*inline "CHECKBOXLIST"}}{{>@macro/editor/checkbox-list.hbs}}{{/inline}}
{{#*inline "CHECKBOX"}}{{>@macro/editor/checkbox.hbs}}{{/inline}}
{{#*inline "LISTBOXPICKUP"}}{{>@macro/editor/checkbox-list.hbs}}{{/inline}}
{{#*inline "LISTBOX"}}{{>@macro/editor/checkbox-list.hbs}}{{/inline}}
{{#*inline "LISTBOXPICKUP"}}{{>@macro/editor/list-box.hbs}}{{/inline}}
{{#*inline "LISTBOX"}}{{>@macro/editor/list-box.hbs}}{{/inline}}
{{#*inline "PICKEREX_LINKONLY"}}{{>@macro/editor/data-picker.hbs}}{{/inline}}
{{#*inline "PICKER"}}{{>@macro/editor/data-picker.hbs}}{{/inline}}
{{#*inline "PICKEREX_NOBUTTON"}}{{>@macro/editor/data-picker.hbs}}{{/inline}}
......
......@@ -45,4 +45,3 @@
@editorEvent="($event) => handleEditorEvent(index,$event)"
{{/eq}}
/>
<IbizListBox
name="{{item.codeName}}"
:data="state.data"
:server="state.controlService"
:deMajorField="state.appDeMajorFieldName"
:deKeyField="state.appDeKeyFieldName"
editorType='{{item.psEditor.editorType}}'
{{#if item.psEditor.editorParams.mode}}
:mode="{{item.psEditor.editorParams.mode}}"
{{/if}}
{{#if item.psEditor.editorParams.valueType}}
:valueType="{{item.psEditor.editorParams.valueType}}"
{{/if}}
{{#if item.psEditor.editorParams.acParams}}
:acParams="{{item.psEditor.editorParams.acParams}}"
{{/if}}
{{#if item.psEditor.editorParams.multiple}}
:multiple="{{item.psEditor.editorParams.multiple}}"
{{/if}}
{{#if item.psEditor.disabled}}
:disabled="{{item.psEditor.disabled}}"
{{/if}}
{{#if item.psEditor.isReadOnly}}
:readonly="{{item.psEditor.isReadOnly}}"
{{/if}}
{{#if item.psEditor.codeList}}
codeListTag="{{item.psEditor.codeList.codeListTag}}"
codeListType="{{item.psEditor.codeList.codeListType}}"
valueSeparator="{{item.psEditor.codeList.valueSeparator}}"
{{/if}}
{{#if item.psEditor.psNavigateContexts}}
localContext="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateContexts}}"
{{/if}}
{{#if item.psEditor.psNavigateParams}}
localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{/if}}
:context="state.context"
:viewParams="state.viewParams"
{{#if (or (eq ctrlType 'form') (eq ctrlType 'panel'))}}
:value="state.data.{{item.psEditor.name}}"
@editorEvent="handleEditorEvent"
{{/if}}
{{#eq ctrlType 'grid'}}
:value="record.{{item.psEditor.name}}"
@editorEvent="($event) => handleEditorEvent(index,$event)"
{{/eq}}
/>
<script setup lang="ts">
import {
EditorBase,
IActionParam,
IParam,
IContext
} from "@core";
import { computed, onBeforeMount, ref, Ref } from "vue";
import { EditorBase, IActionParam, IParam, IContext, typeOf } from '@core';
import { computed, onBeforeMount, ref, Ref } from 'vue';
interface CheckboxListProps {
/**
* 值
*
* @type {*}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
value: any;
......@@ -19,7 +14,7 @@ interface CheckboxListProps {
* 属性名称
*
* @type {*}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
name: string;
......@@ -27,39 +22,39 @@ interface CheckboxListProps {
* 传入表单数据
*
* @type {*}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
data: IParam;
/**
* 模式(数字或者字符串)
* 代码表值分隔符
*
* @type {*}
* @memberof AppCheckBox
* @type {string}
* @memberof CheckboxListProps
*/
mode: "string" | "number";
valueSeparator: string;
/**
* 代码表值分隔符
* 模式(数字或者字符串)
*
* @type {string}
* @memberof AppCheckBox
* @type {'string' | 'number'}
* @memberof CheckboxListProps
*/
valueSeparator: string;
mode: 'string' | 'number';
/**
* 属性类型
*
* @type {'string' | 'number'}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
valueType: "string" | "number";
valueType: 'string' | 'number';
/**
* 代码表标识
*
* @type {string}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
codeListTag: string;
......@@ -67,7 +62,7 @@ interface CheckboxListProps {
* 代码表类型
*
* @type {string}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
codeListType: string;
......@@ -75,7 +70,7 @@ interface CheckboxListProps {
* 视图上下文
*
* @type {*}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
context: IContext;
......@@ -83,7 +78,7 @@ interface CheckboxListProps {
* 视图参数
*
* @type {*}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
viewParams: IParam;
......@@ -91,7 +86,7 @@ interface CheckboxListProps {
* 局部上下文导航参数
*
* @type {any}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
localContext: IParam;
......@@ -99,7 +94,7 @@ interface CheckboxListProps {
* 局部导航参数
*
* @type {any}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
localParam: IParam;
......@@ -107,7 +102,7 @@ interface CheckboxListProps {
* 是否禁用
*
* @type {boolean}
* @memberof AppCheckBox
* @memberof CheckboxListProps
*/
disabled?: boolean;
......@@ -120,15 +115,15 @@ interface CheckboxListProps {
}
interface EditorEmit {
(name: "editorEvent", value: IActionParam): void;
(name: 'editorEvent', value: IActionParam): void;
}
const props = withDefaults(defineProps<CheckboxListProps>(), {
disabled: false,
readonly: false,
valueType: "string",
valueSeparator: ",",
mode: "string",
valueType: 'string',
valueSeparator: ',',
mode: 'string',
});
const emit = defineEmits<EditorEmit>();
const { handleEditorNavParams, handleLevelCodeList, loadCodeListData } = new EditorBase();
......@@ -136,8 +131,18 @@ const { navContext, navViewParam } = handleEditorNavParams(props);
let items: Ref<IParam[]> = ref([]);
const selectArray: Ref<boolean> = computed(() => {
if (props.value) {
let selects = props.value.split(props.valueSeparator);
return selects;
if (Object.is(props.mode, 'string')) {
return props.value.split(props.valueSeparator);
} else {
let selectsArray: Array<any> = [];
let num: number = parseInt(props.value, 10);
items.value.forEach((item: any) => {
if ((num & item.value) == item.value) {
selectsArray.push(item.value);
}
});
return selectsArray;
}
} else {
return [];
}
......@@ -145,29 +150,63 @@ const selectArray: Ref<boolean> = computed(() => {
const onChange = ($event: any[]) => {
let value: null | string | number = null;
let _datas: string[] = [];
items.value.forEach((item: any) => {
if (Object.is(props.mode,'string')) {
let _datas: string[] = [];
items.value.forEach((item: any) => {
const index = $event.findIndex((_key: any) => Object.is(item.value, _key));
if (index === -1) {
return;
return;
}
_datas.push(item.value);
});
value = _datas.join(props.valueSeparator);
emit("editorEvent", {
});
value = _datas.join(props.valueSeparator);
} else {
let temp: number = 0;
$event.forEach((item: any) => {
temp = temp | parseInt(item, 10);
});
value = temp;
}
emit('editorEvent', {
tag: props.name,
action: "valueChange",
action: 'valueChange',
data: value,
});
};
const formatCodeList = (items: Array<any>) => {
let matching: boolean = false;
let result: Array<any> = [];
try {
items.forEach((item: any) => {
const type = typeOf(item.value);
if (type != props.valueType) {
matching = true;
if (type === 'number') {
item.value = item.value.toString();
} else {
if (type == 'null') {
props.valueType == 'number' ? (item.value = 0) : (item.value = '');
} else if (item.value.indexOf('.') == -1) {
item.value = parseInt(item.value);
} else {
item.value = parseFloat(item.value);
}
}
}
result.push(item);
});
if (matching) {
console.warn('代码表值类型和属性类型不匹配,自动强制转换');
}
return result;
} catch (error) {
console.warn('代码表值类型和属性类型不匹配,自动强制转换异常,请修正代码表值类型和属性类型匹配');
return [];
}
};
onBeforeMount(() => {
loadCodeListData(
props.codeListTag,
props.codeListType,
navContext,
navViewParam
).then((codeListData: IParam[]) => {
items.value = handleLevelCodeList(codeListData);
loadCodeListData(props.codeListTag, props.codeListType, navContext, navViewParam).then((codeListData: IParam[]) => {
items.value = formatCodeList(handleLevelCodeList(codeListData));
});
});
</script>
......
......@@ -70,16 +70,25 @@ const onChange = ($event: any) => {
</script>
<template>
<div :class="['app-editor-container',`app-input-${name}`]">
<div :class="['ibiz-editor-container','ibiz-input',`ibiz-input-${name}`]">
<a-input
allowClear
v-if="Object.is('text', type) || Object.is('number', type)"
v-if="Object.is('text', type)"
v-model:value="value"
:disabled="disabled"
:maxlength="maxLength"
:type="type"
@blur="onChange"
:placeholder="showMaxLength ? `最大内容长度为${maxLength}` : placeholder" />
<a-input-number
v-if="Object.is('number', type)"
:value="value"
:disabled="disabled"
:max="max"
:min="min"
:precision="precision"
@change="onChange"
:placeholder="placeholder" />
<a-input-password
v-if="Object.is('password', type)"
v-model:value="value"
......@@ -95,8 +104,4 @@ const onChange = ($event: any) => {
@blur="onChange"
:placeholder="placeholder"/>
</div>
</template>
<style scoped>
</style>
\ No newline at end of file
</template>
\ No newline at end of file
<script setup lang="ts">
import { EditorBase, IActionParam, IParam, IContext, typeOf } from '@core';
import { computed, onBeforeMount, ref, Ref } from 'vue';
interface ListBoxProps {
/**
* 值
*
* @type {*}
* @memberof ListBoxProps
*/
value: any;
/**
* 属性名称
*
* @type {*}
* @memberof ListBoxProps
*/
name: string;
/**
* 传入表单数据
*
* @type {*}
* @memberof ListBoxProps
*/
data: IParam;
/**
* 代码表值分隔符
*
* @type {string}
* @memberof ListBoxProps
*/
valueSeparator: string;
/**
* 模式(数字或者字符串)
*
* @type {'string' | 'number'}
* @memberof CheckboxListProps
*/
mode: 'string' | 'number';
/**
* 属性类型
*
* @type {'string' | 'number'}
* @memberof ListBoxProps
*/
valueType: 'string' | 'number';
/**
* 代码表标识
*
* @type {string}
* @memberof ListBoxProps
*/
codeListTag: string;
/**
* 代码表类型
*
* @type {string}
* @memberof ListBoxProps
*/
codeListType: string;
/**
* 表单服务
*
* @type {*}
* @memberof ListBoxProps
*/
service: any;
/**
* 编辑器类型
*
* @type {*}
* @memberof ListBoxProps
*/
editorType: 'LISTBOX' | 'LISTBOXPICKUP';
/**
* ac参数
*
* @type {*}
* @memberof ListBoxProps
*/
acParams: any;
/**
* 视图上下文
*
* @type {*}
* @memberof ListBoxProps
*/
context: IContext;
/**
* 视图参数
*
* @type {*}
* @memberof ListBoxProps
*/
viewParams: IParam;
/**
* 局部上下文导航参数
*
* @type {any}
* @memberof ListBoxProps
*/
localContext: IParam;
/**
* 局部导航参数
*
* @type {any}
* @memberof ListBoxProps
*/
localParam: IParam;
/**
* 是否多选
*
* @type {any}
* @memberof ListBoxProps
*/
multiple: Boolean;
/**
* 应用实体主信息属性名称
*
* @type {string}
* @memberof ListBoxProps
*/
deMajorField: string;
/**
* 应用实体主键属性名称
*
* @type {string}
* @memberof ListBoxProps
*/
deKeyField: string;
/**
* 是否禁用
*
* @type {boolean}
* @memberof ListBoxProps
*/
disabled?: boolean;
/**
* 只读模式
*
* @type {boolean}
*/
readonly?: boolean;
}
interface EditorEmit {
(name: 'editorEvent', value: IActionParam): void;
}
const props = withDefaults(defineProps<ListBoxProps>(), {
disabled: false,
readonly: false,
valueType: 'string',
valueSeparator: ',',
mode: 'string',
editorType: 'LISTBOX',
acParams: {},
deMajorField: 'srfmajortext',
deKeyField: 'srfkey',
});
const emit = defineEmits<EditorEmit>();
const { handleEditorNavParams, handleLevelCodeList, loadCodeListData } = new EditorBase();
const { navContext, navViewParam } = handleEditorNavParams(props);
let items: Ref<IParam[]> = ref([]);
const selectArray: Ref<boolean> = computed(() => {
if (props.multiple) {
if (Object.is('LISTBOX', props.editorType)) {
if (Object.is(props.mode, 'string')) {
return props.value.split(props.valueSeparator);
} else {
let selectsArray: Array<any> = [];
let num: number = parseInt(props.value, 10);
items.value.forEach((item: any) => {
if ((num & item.value) == item.value) {
selectsArray.push(item.value);
}
});
return selectsArray;
}
} else {
return props.value.split(props.valueSeparator);
}
} else {
return [props.value];
}
});
const curMajorField: Ref<string> = computed(() => {
return Object.is(props.editorType, 'LISTBOX') ? 'text' : props.deMajorField;
});
const curKeyField: Ref<string> = computed(() => {
return Object.is(props.editorType, 'LISTBOX') ? 'value' : props.deKeyField;
});
const onChange = ($event: any[]) => {
let value: null | string | number = null;
if (Object.is(props.mode, 'string')) {
let _datas: string[] = [];
items.value.forEach((item: any) => {
const index = $event.findIndex((_key: any) => Object.is(item.value, _key));
if (index === -1) {
return;
}
_datas.push(item.value);
});
value = _datas.join(props.valueSeparator);
} else {
let temp: number = 0;
$event.forEach((item: any) => {
temp = temp | parseInt(item, 10);
});
value = temp;
}
emit('editorEvent', {
tag: props.name,
action: 'valueChange',
data: value,
});
};
const formatCodeList = (items: Array<any>) => {
let matching: boolean = false;
let result: Array<any> = [];
try {
items.forEach((item: any) => {
const type = typeOf(item.value);
if (type != props.valueType) {
matching = true;
if (type === 'number') {
item.value = item.value.toString();
} else {
if (type == 'null') {
props.valueType == 'number' ? (item.value = 0) : (item.value = '');
} else if (item.value.indexOf('.') == -1) {
item.value = parseInt(item.value);
} else {
item.value = parseFloat(item.value);
}
}
}
result.push(item);
});
if (matching) {
console.warn('代码表值类型和属性类型不匹配,自动强制转换');
}
return result;
} catch (error) {
console.warn('代码表值类型和属性类型不匹配,自动强制转换异常,请修正代码表值类型和属性类型匹配');
return [];
}
};
const loadData = () => {
if (!props.service) {
console.warn('部件服务错误');
} else if (!props.acParams?.serviceName) {
console.warn('未拥有serviceName参数');
} else if (!props.acParams?.interfaceName) {
console.warn('未拥有interfaceName参数');
} else {
props.service
.getItems(props.acParams.serviceName, props.acParams.interfaceName, navContext, navViewParam)
.then((response: any) => {
if (response) {
items.value = [...response];
}
})
.catch((response: any) => {
console.error('加载数据失败');
});
}
};
onBeforeMount(() => {
if (Object.is('LISTBOX', props.editorType)) {
loadCodeListData(props.codeListTag, props.codeListType, navContext, navViewParam).then((codeListData: IParam[]) => {
items.value = formatCodeList(handleLevelCodeList(codeListData));
});
} else if (Object.is('LISTBOXPICKUP', props.editorType)) {
loadData();
}
});
</script>
<template>
<div :class="['ibiz-editor-container', 'ibiz-list-box', `ibiz-list-box-${name}`]">
<template v-if="multiple">
<a-checkbox-group @change="onChange" :value="selectArray" :options="items" :disabled="disabled || readonly" />
</template>
<template v-else>
<a-radio-group @change="onChange" :value="value" :options="items" :disabled="disabled || readonly" />
</template>
</div>
</template>
.ibiz-input {
width: 100%;
.ant-input-number {
width: 100%;
}
}
\ No newline at end of file
@use './ibizInput.scss';
@use './ibizListBox.scss';
\ No newline at end of file
......@@ -52,6 +52,14 @@ export const CtrlConfig = {
controlName: '{{ctrl.name}}',
controlService: new EditFormService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ),
data: new ControlVO({}),
{{#each ctrl.psAppDataEntity.allPSAppDEFields as | appDEField | }}
{{#if appDEField.keyField}}
appDeKeyFieldName: '{{appDEField.codeName}}',
{{/if}}
{{#if appDEField.majorField}}
appDeMajorFieldName: '{{appDEField.codeName}}',
{{/if}}
{{/each}}
enableAutoSave: {{ctrl.enableAutoSave}},
detailsModel: {
{{#each ctrl.psDEFormPages as | FormPage | }}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册