Browse Source

组件优化

main
likunming 6 months ago
parent
commit
bf4b0932f3
  1. 12
      io.sc.platform.core.frontend/src/platform/components/form/WForm.vue
  2. 4
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue
  3. 25
      io.sc.platform.core.frontend/src/platform/components/select/WGridSelect.vue
  4. 468
      io.sc.platform.core.frontend/src/views/likm/Drawer.vue
  5. 3
      io.sc.platform.core.frontend/src/views/likm/Grid.vue
  6. 10
      io.sc.platform.core.frontend/src/views/likm/TreeGrid.vue

12
io.sc.platform.core.frontend/src/platform/components/form/WForm.vue

@ -103,7 +103,7 @@ const defaultValueHandler = (field) => {
field.multiple
) {
return [];
} else if (field.type === 'w-code-mirror') {
} else if (field.type === 'w-code-mirror' || field.type === 'w-date') {
return '';
}
return undefined;
@ -137,8 +137,10 @@ watch(
},
);
const fieldsComputed = computed(() => {
localFlag.value;
if (!Tools.isEmpty(localFlag.value)) {
return fields_.value;
}
return [];
});
for (const field of fields_.value as any) {
@ -208,11 +210,17 @@ const getData = () => {
* @param data 数据对象(JSON格式)
*/
const setData = (data) => {
if (Tools.isEmpty(data)) {
for (const field of fields_.value as any) {
formData[field.name] = defaultValueHandler(field);
}
} else {
for (const field of fields_.value as any) {
if (data[field.name] !== undefined) {
formData[field.name] = data[field.name];
}
}
}
};
/**
* 对外暴露方法-重置表单

4
io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

@ -800,7 +800,7 @@ const allTickedStatus = () => {
ticked_.push(item);
}
});
if (ticked_.length === table.rows.length) {
if (ticked_.length === table.rows.length && table.rows.length > 0) {
table.allTicked = true;
} else if (ticked_.length > 0) {
table.allTicked = null;
@ -1198,7 +1198,7 @@ const setSelectedStatus = (arr, status) => {
};
const setTickedStatus = (arr, status, cascadeChildren = true) => {
arr.forEach((item) => {
item[table.selectedField] = status;
item[table.tickedField] = status;
if (props.tree && cascadeChildren && item.children && item.children.length > 0) {
setTickedStatus(item.children, status, cascadeChildren);
}

25
io.sc.platform.core.frontend/src/platform/components/select/WGridSelect.vue

@ -15,7 +15,6 @@
:readonly="fieldMethodsClass.getReadOnly(props, { value: modelValue, displayValue: displayValueComputed })"
:disable="fieldMethodsClass.getDisable(props, { value: modelValue, displayValue: displayValueComputed })"
:clearable="false"
@update:model-value="fieldMethodsClass.updateValue"
@focus="
() => {
textSelectRef?.blur();
@ -32,7 +31,7 @@
<div style="width: 700px; height: 300px">
<w-grid
ref="gridRef"
v-bind="props.grid"
v-bind="{ ...props.grid, onRowClick: undefined }"
db-click-operation="none"
:checkbox-selection="props.multiple || false"
:dense="true"
@ -58,7 +57,7 @@
</template>
<script setup lang="ts">
import { ref, computed, useAttrs, onBeforeMount, toRaw } from 'vue';
import { ref, computed, useAttrs, toRaw, watch } from 'vue';
import { Tools, axios } from '@/platform';
import { FormFieldProps } from '@/platform/components/form/FormField.ts';
import { FormFieldMethods } from '../form/FormField';
@ -223,8 +222,23 @@ const rowClick = (args) => {
console.info('error========模型值不匹配');
}
isShow.value = false;
if (props.grid['onRowClick'] && typeof props.grid['onRowClick'] === 'function') {
props.grid['onRowClick'](args);
}
};
watch(
() => modelValue.value,
(newVal, oldVal) => {
if (newVal !== oldVal) {
fieldMethodsClass.updateValue(newVal);
}
if (!modelObjectValue.value || (modelObjectValue.value.length === 0 && newVal !== oldVal)) {
setObjectValueByValue(newVal);
}
},
);
//
const setObjectValueByValue = async (value) => {
if ((Array.isArray(value) && value.length > 0) || (typeof value === 'string' && !Tools.isEmpty(value))) {
@ -257,11 +271,6 @@ const setObjectValueByValue = async (value) => {
}
};
onBeforeMount(() => {
//
setObjectValueByValue(modelValue.value);
});
defineExpose({
validate: fieldMethodsClass.validate,
setValue: fieldMethodsClass.setValue,

468
io.sc.platform.core.frontend/src/views/likm/Drawer.vue

@ -1,88 +1,426 @@
<template>
<div class="w-[500px] h-[300px]">
<w-echarts
:option="{
title: {
left: 'center',
text: '资产余额',
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
<div class="h-full">
<q-splitter v-model="state.splitterModel" class="h-full">
<template #before>
<div class="h-full pr-1">
<w-grid
ref="mainGridRef"
title="标准模型映射列表"
:data-url="Environment.apiContextPath('api/rwa/params/data/mapping/main')"
:sort-no="false"
dense
:checkbox-selection="false"
:query-form-cols-num="3"
:query-form-fields="[
{ name: 'mappingTable', label: '目标表', type: 'w-text' },
{ name: 'mappingFeild', label: '目标字段', type: 'w-text' },
{ name: 'remark', label: '备注', type: 'w-text' },
{ name: 'fromTable', label: '来源表', type: 'w-text' },
{ name: 'fromFeild', label: '来源表字段', type: 'w-text' },
{ name: 'mappingTp', label: '映射方式', type: 'w-select', options: optionsMappingType },
{
name: 'isValid',
label: '是否有效',
type: 'w-select',
options: [
{ label: '有效', value: '1' },
{ label: '无效', value: '0' },
],
},
]"
:columns="[
// { name: 'listId', label: 'ID' },
{ name: 'mappingTable', label: '目标表', width: 150 },
{ name: 'mappingFeild', label: '目标字段', width: 100 },
{ name: 'remark', label: '备注', width: 100 },
{ name: 'fromTable', label: '来源表', width: 150 },
{ name: 'fromFeild', label: '来源表字段', width: 100 },
{ name: 'mappingTp', label: '映射方式', format: Formater.dictionary(dictMappingType) },
{ name: 'expression', label: '算式运算表达式' },
{ name: 'cacheTable', label: '缓存取值表' },
{ name: 'cacheFeild', label: '缓存取值字段' },
{ name: 'isValid', label: '是否有效', align: 'center', format: isValidFormat },
{ name: 'sortNo', label: '字段排序' },
]"
:editor="{
dialog: {
width: '60%',
},
form: {
colsNum: 3,
fields: [
{
name: 'listId',
label: '所属清单ID',
requiredIf: true,
type: 'w-grid-select',
displayValue: 'id',
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
title: '标准模型映射清单',
dataUrl: Environment.apiContextPath('/api/rwa/params/data/mapping/list'),
sortBy: ['sortNo'],
pageable: false,
columns: [
{ name: 'id', label: '清单ID' },
{ name: 'fromTable', label: '来源表名称' },
{ name: 'toTable', label: '目标表名称' },
{ name: 'sortNo', label: '字段排序' },
{ name: 'toTableCacheKey', label: '缓存关键字' },
{ name: 'csvAppendFlg', label: '是否在csv续写数据', format: csvAppendFormat },
],
onRowClick: (args) => {
setListId(args.row);
},
},
onUpdateValue: (args) => {
console.info('onUpdateValue=========', args);
},
},
dataZoom: [
{
type: 'slider',
show: true, //
borderColor: '#2563eb', //
showDetail: false, // detail
startValue: 0, //
endValue: 10, //
filterMode: 'empty',
width: '80%', //
height: 8, //
left: 'center', //
zoomLoxk: true, //
handleSize: 0, //
bottom: 0, //
name: 'isValid',
label: '是否有效',
requiredIf: true,
type: 'w-select',
defaultValue: '1',
options: [
{ label: '有效', value: '1' },
{ label: '无效', value: '0' },
],
},
{ name: 'sortNo', label: '字段排序', requiredIf: true, type: 'w-number' },
{
type: 'inside',
zoomOnMouseWheel: false, //
moveOnMouseMove: true, //
moveOnMouseWheel: true, //
name: 'mappingTable',
label: '目标表',
requiredIf: true,
type: 'w-text',
readOnlyIf: () => {
return true;
},
},
],
xAxis: [
{
type: 'category',
data: [
'黄浦支行',
'徐汇支行',
'长宁支行',
'静安支行',
'普陀支行',
'虹口支行',
'杨浦支行',
'浦东支行',
'闵行支行',
'宝山支行',
'嘉定支行',
'金山支行',
'松江支行',
'青浦支行',
'奉贤支行',
'崇明支行',
],
axisTick: {
alignWithLabel: true,
name: 'mappingFeild',
label: '目标字段',
requiredIf: true,
type: 'w-select',
colSpan: 2,
clearable: true,
options: state.mainMappingFieldOptions,
},
{
name: 'fromTable',
label: '来源表',
requiredIf: true,
type: 'w-text',
readOnlyIf: () => {
return true;
},
},
{ name: 'fromFeild', label: '来源表字段', type: 'w-select', colSpan: 2, clearable: true, options: state.mainFromFieldOptions },
{ name: 'remark', label: '备注', type: 'w-text', colSpan: 2 },
{ name: 'mappingTp', label: '映射方式', requiredIf: true, type: 'w-select', options: optionsMappingType },
{ name: 'cacheTable', label: '缓存取值表', type: 'w-text' },
{ name: 'cacheFeild', label: '缓存取值字段', type: 'w-text', colSpan: 2 },
{ name: 'expression', label: '算式运算表达式', type: 'w-textarea', rows: 3, colSpan: 'full' },
],
yAxis: [
},
}"
:toolbar-actions="[
'query',
'reset',
'separator',
[
{ name: 'operator', label: '操作', icon: 'build' },
'add',
{
type: 'value',
name: '单位:万元',
extend: 'edit',
beforeClick: (args) => {
console.info('args=======', args.selected);
getFieldOptions(args.selected['mappingTable'], FieldFlagEnums.MAIN_MAPPING_FIELD);
getFieldOptions(args.selected['fromTable'], FieldFlagEnums.MAIN_FROM_FIELD);
return true;
},
},
'remove',
],
series: [
'separator',
]"
:sort-by="['mappingTable', 'sortNo']"
:pagination="{
rowsPerPage: 100,
}"
@row-click="
(args) => {
if (!Tools.isUndefinedOrNull(detailGridRef)) {
detailGridRef.setQueryCriteriaFieldValue('mappingId', args.row.id);
detailGridRef.refresh();
}
}
"
></w-grid>
</div>
</template>
<template #after>
<div class="h-full pl-1">
<w-grid
ref="detailGridRef"
title="标准模型映射明细"
:data-url="Environment.apiContextPath('api/rwa/params/data/mapping/detail')"
:auto-fetch-data="false"
:query-criteria="{
fieldName: 'mappingId',
operator: 'equals',
value: '',
}"
:sort-no="true"
dense
:pageable="false"
:checkbox-selection="false"
:columns="[
{ name: 'fromTable', label: '来源表名称', width: 150, hidden: true },
{ name: 'fromFeild', label: '来源表字段', width: 200 },
{ name: 'valGetType', label: '取值方式', format: Formater.dictionary(dictValueGetType) },
{ name: 'cacheTable', label: '缓存取值表' },
{ name: 'cacheFeild', label: '缓存取值字段' },
{ name: 'fromDataTp', label: '字段值类型', format: Formater.dictionary(dictDataType) },
{ name: 'matchTp', label: '值匹配方式', format: Formater.dictionary(dictMatchType) },
{ name: 'matchVal', label: '字段匹配目标值' },
{ name: 'startSign', label: '条件开始标识', format: Formater.dictionary(dictConditionStart) },
{ name: 'endSign', label: '条件结束标识', format: Formater.dictionary(dictConditionEnd) },
{ name: 'isReturn', label: '是否返回结果值', format: isReturnFormat, align: 'center' },
{ name: 'returnVal', label: '返回结果值' },
{ name: 'sortNo', label: '条件排序' },
]"
:editor="{
dialog: {
width: '60%',
},
form: {
colsNum: 2,
fields: [
{
type: 'bar',
barWidth: '10%',
data: [1700, 1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 600, 500, 400, 300, 200, 100],
name: 'fromFeild',
label: '来源表字段',
type: 'w-select',
options: state.mainFromFieldOptions,
useInput: true,
clearable: true,
onInputValue: (value) => {
if (
!Tools.isEmpty(value) &&
detailGridRef
.getEditorForm()
.getFields()
['fromFeild'].options.findIndex((item) => {
return item['value'] === value;
}) < 0
) {
detailGridRef.getEditorForm().getFields()['fromFeild'].options.push({ label: value, value });
detailGridRef.getEditorForm().setFieldValue('fromFeild', value);
}
},
},
{ name: 'valGetType', label: '取值方式', type: 'w-select', options: optionsValueGetType },
{ name: 'cacheTable', label: '缓存取值表', type: 'w-text' },
{ name: 'cacheFeild', label: '缓存取值字段', type: 'w-text' },
{ name: 'fromDataTp', label: '字段值类型', type: 'w-select', options: optionsDataType },
{ name: 'matchTp', label: '值匹配方式', type: 'w-select', options: optionsMatchType },
{ name: 'matchVal', label: '字段匹配目标值', type: 'w-text' },
{ name: 'startSign', label: '条件开始标识', type: 'w-select', options: optionsConditionStart },
{ name: 'endSign', label: '条件结束标识', type: 'w-select', options: optionsConditionEnd },
{
name: 'isReturn',
label: '是否返回结果值',
type: 'w-select',
options: [
{ label: '返回', value: '1' },
{ label: '不返回', value: '0' },
],
},
{ name: 'returnVal', label: '返回结果值', type: 'w-text' },
{ name: 'sortNo', label: '条件排序', type: 'w-number' },
],
},
}"
></w-echarts>
:toolbar-actions="[
{
extend: 'add',
enableIf: () => {
if (!Tools.isUndefinedOrNull(mainGridRef) && !Tools.isUndefinedOrNull(mainGridRef.getSelectedRow())) {
return true;
}
return false;
},
beforeClick: () => {
if (!Tools.isUndefinedOrNull(mainGridRef) && !Tools.isUndefinedOrNull(mainGridRef.getSelectedRow())) {
getFieldOptions(mainGridRef.getSelectedRow()['fromTable'], FieldFlagEnums.MAIN_FROM_FIELD);
}
return true;
},
},
'edit',
'remove',
'separator',
]"
:pagination="{
rowsPerPage: 100,
}"
:sort-by="['sortNo']"
@before-editor-data-submit="
(args) => {
args['data'] = mainGridRef.getSelectedRow()['id'];
args.callback(args['data']);
}
"
></w-grid>
</div>
</template>
</q-splitter>
</div>
</template>
<script setup lang="ts"></script>
<script setup lang="ts">
import { ref, reactive } from 'vue';
import { Environment, DictionaryTools, Options, Tools, Formater, axios } from '@/platform';
const dictMappingType = await DictionaryTools.fetch('RWA_P_DP_MAPPING_TYPE');
const dictValueGetType = await DictionaryTools.fetch('RWA_P_DP_VAL_GET_TYPE');
const dictDataType = await DictionaryTools.fetch('RWA_P_DP_DATA_TYPE');
const dictMatchType = await DictionaryTools.fetch('RWA_P_DP_MATCH_TYPE');
const dictConditionStart = await DictionaryTools.fetch('RWA_P_DP_CONDITION_S');
const dictConditionEnd = await DictionaryTools.fetch('RWA_P_DP_CONDITION_E');
const optionsMappingType = Options.dictionary(dictMappingType);
const optionsValueGetType = Options.dictionary(dictValueGetType);
const optionsDataType = Options.dictionary(dictDataType);
const optionsMatchType = Options.dictionary(dictMatchType);
const optionsConditionStart = Options.dictionary(dictConditionStart);
const optionsConditionEnd = Options.dictionary(dictConditionEnd);
const mainGridRef = ref();
const detailGridRef = ref();
/**
* 字段标识
*/
enum FieldFlagEnums {
MAIN_MAPPING_FIELD, //
MAIN_FROM_FIELD, //
}
const state = reactive({
baseTableListOptions: <any>[],
mainMappingFieldOptions: <any>[],
mainFromFieldOptions: <any>[],
splitterModel: 60,
});
const csvAppendFormat = (val, row) => {
if (!Tools.isEmpty(val) && val === '1') {
return {
componentType: 'q-chip',
attrs: {
square: true,
outline: true,
label: '续写',
color: 'green',
size: 'sm',
},
};
} else if (!Tools.isEmpty(val) && val === '0') {
return {
componentType: 'q-chip',
attrs: {
square: true,
outline: true,
label: '覆盖',
color: 'red',
size: 'sm',
},
};
}
return '';
};
const setListId = (listData) => {
mainGridRef.value.getEditorForm().setFieldValue('listId', listData['id']);
mainGridRef.value.getEditorForm().setFieldValue('mappingTable', listData['toTable']);
mainGridRef.value.getEditorForm().setFieldValue('fromTable', listData['fromTable']);
getFieldOptions(listData['toTable'], FieldFlagEnums.MAIN_MAPPING_FIELD);
getFieldOptions(listData['fromTable'], FieldFlagEnums.MAIN_FROM_FIELD);
mainGridRef.value.getEditorForm().setFieldValue('mappingFeild', null);
mainGridRef.value.getEditorForm().setFieldValue('fromFeild', null);
};
const getFieldOptions = (table: string, fieldFlag: FieldFlagEnums) => {
if (Tools.isEmpty(table)) {
return;
}
axios
.get(Environment.apiContextPath('api/template/config/columns/' + table))
.then((resp) => {
if (fieldFlag === FieldFlagEnums.MAIN_MAPPING_FIELD) {
state.mainMappingFieldOptions = [];
if (resp.data && resp.data.length > 0) {
resp.data.forEach((field) => {
state.mainMappingFieldOptions.push({
label: field['name'] + (!Tools.isEmpty(field['remarks']) ? '(' + field['remarks'] + ')' : ''),
value: field['name'],
});
});
}
} else if (fieldFlag === FieldFlagEnums.MAIN_FROM_FIELD) {
state.mainFromFieldOptions = [];
if (resp.data && resp.data.length > 0) {
resp.data.forEach((field) => {
state.mainFromFieldOptions.push({
label: field['name'] + (!Tools.isEmpty(field['remarks']) ? '(' + field['remarks'] + ')' : ''),
value: field['name'],
});
});
}
}
})
.catch((error) => {
console.info('error==========', error);
});
};
const isValidFormat = (val, row) => {
if (!Tools.isEmpty(val)) {
if (val === '1') {
return {
componentType: 'q-icon',
attrs: {
name: 'check_circle',
color: 'green',
size: 'xs',
},
};
} else if (val === '0') {
return {
componentType: 'q-icon',
attrs: {
name: 'cancel',
color: 'red',
size: 'xs',
},
};
} else {
return val;
}
}
return '';
};
const isReturnFormat = (val, row) => {
if (!Tools.isEmpty(val) && val === '1') {
return {
componentType: 'q-icon',
attrs: {
name: 'check_circle',
color: 'green',
size: 'xs',
},
};
}
return '';
};
</script>

3
io.sc.platform.core.frontend/src/views/likm/Grid.vue

@ -4,7 +4,8 @@
ref="gridRef"
title="示例列表"
:data-url="Environment.apiContextPath('/api/system/application')"
:toolbar-actions="['add', 'edit']"
:toolbar-actions="['add', 'edit', 'query']"
:query-form-fields="[{ name: 'code', label: '编码', type: 'w-text' }]"
:columns="[
{ name: 'code', label: '编码', type: 'w-text' },
{ name: 'name', label: '名称', type: 'w-text' },

10
io.sc.platform.core.frontend/src/views/likm/TreeGrid.vue

@ -37,6 +37,16 @@
{ name: 'order', label: '排序号' },
]"
:toolbar-actions="['expand']"
@row-click="
(args) => {
console.info('args1=======', args);
}
"
@row-db-click="
(args) => {
console.info('args2=======', args);
}
"
></w-grid>
</div>
</template>

Loading…
Cancel
Save