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

update:更新表格部件及多数据部件基类

上级 ffffd796
...@@ -5,6 +5,7 @@ interface FormGroupProps { ...@@ -5,6 +5,7 @@ interface FormGroupProps {
name: string; name: string;
layoutOpts?: ILayoutOpts; layoutOpts?: ILayoutOpts;
label?: string; label?: string;
showLabel?: boolean,
required?: boolean; required?: boolean;
visible?: boolean; visible?: boolean;
labelWidth?: number; labelWidth?: number;
...@@ -18,6 +19,7 @@ interface FormGroupEmit { ...@@ -18,6 +19,7 @@ interface FormGroupEmit {
const props = withDefaults(defineProps<FormGroupProps>(), { const props = withDefaults(defineProps<FormGroupProps>(), {
required: false, required: false,
visible: true, visible: true,
showLabel: true
}); });
const emit = defineEmits<FormGroupEmit>(); const emit = defineEmits<FormGroupEmit>();
...@@ -54,7 +56,7 @@ const initRules = () => { ...@@ -54,7 +56,7 @@ const initRules = () => {
:labelCol="{ style: { width: `${labelWidth}px` } }" :labelCol="{ style: { width: `${labelWidth}px` } }"
:validateStatus="error ? 'error' : 'validating'" :validateStatus="error ? 'error' : 'validating'"
> >
<template #label> <template #label v-if="showLabel">
<label :class="labelClass"> <label :class="labelClass">
<div class="label-title">{{ label }}</div> <div class="label-title">{{ label }}</div>
</label> </label>
......
...@@ -212,10 +212,10 @@ export class AppSysAction { ...@@ -212,10 +212,10 @@ export class AppSysAction {
* @return {*} * @return {*}
*/ */
public static remove(params: IUIActionParams) { public static remove(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment, data } = params;
// 视图里获取多数据部件 // 视图里获取多数据部件
if (hasFunction(actionEnvironment.xDataControl, "remove")) { if (hasFunction(actionEnvironment.xDataControl, "remove")) {
actionEnvironment.xDataControl.remove(); actionEnvironment.xDataControl.remove(data);
} else if (isExist(actionEnvironment.remove)) { } else if (isExist(actionEnvironment.remove)) {
actionEnvironment.remove(); actionEnvironment.remove();
} }
......
...@@ -507,7 +507,7 @@ export class GridControl extends MDControl { ...@@ -507,7 +507,7 @@ export class GridControl extends MDControl {
} }
createDefaultItems.forEach((item: IParam) => { createDefaultItems.forEach((item: IParam) => {
const { createDVT, createDV, property, valueFormat, fieldType } = item; const { createDVT, createDV, property, valueFormat, fieldType } = item;
if (createDVT && row.hasOwnProperty(property)) { if (createDVT && (row.hasOwnProperty(property) || property in row)) {
switch (createDVT) { switch (createDVT) {
case "CONTEXT": case "CONTEXT":
if (createDV) { if (createDV) {
...@@ -527,7 +527,7 @@ export class GridControl extends MDControl { ...@@ -527,7 +527,7 @@ export class GridControl extends MDControl {
row[property] = context["srfuserid"]; row[property] = context["srfuserid"];
break; break;
case "CURTIME": case "CURTIME":
row[property] = valueFormat ? dateFormat(new Date(), valueFormat) : new Date(); row[property] = valueFormat ? dateFormat(new Date(), valueFormat) : (new Date()).toDateString();
break; break;
case "PARAM": case "PARAM":
if (item.createDV) { if (item.createDV) {
...@@ -556,7 +556,7 @@ export class GridControl extends MDControl { ...@@ -556,7 +556,7 @@ export class GridControl extends MDControl {
const setDefault = (row: IParam = {}) => { const setDefault = (row: IParam = {}) => {
updateDefaultItems.forEach((item: IParam) => { updateDefaultItems.forEach((item: IParam) => {
const { updateDV, updateDVT, property, valueFormat, fieldType } = item; const { updateDV, updateDVT, property, valueFormat, fieldType } = item;
if (updateDVT && row.hasOwnProperty(property)) { if (updateDVT && (row.hasOwnProperty(property) || property in row)) {
switch (updateDVT) { switch (updateDVT) {
case "CONTEXT": case "CONTEXT":
if (updateDV) { if (updateDV) {
...@@ -576,7 +576,7 @@ export class GridControl extends MDControl { ...@@ -576,7 +576,7 @@ export class GridControl extends MDControl {
row[property] = context["srfuserid"]; row[property] = context["srfuserid"];
break; break;
case "CURTIME": case "CURTIME":
row[property] = valueFormat ? dateFormat(new Date(), valueFormat) : new Date(); row[property] = valueFormat ? dateFormat(new Date(), valueFormat) : (new Date()).toDateString();
break; break;
case "PARAM": case "PARAM":
if (item.createDV) { if (item.createDV) {
......
...@@ -195,7 +195,7 @@ export class MDControl extends MainControl { ...@@ -195,7 +195,7 @@ export class MDControl extends MainControl {
const { viewSubject, controlName } = this.state; const { viewSubject, controlName } = this.state;
const remove = async (opt: IParam[] = []) => { const remove = async (opt: IParam[] = []) => {
try { try {
const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeCodeName } = this.state; const { controlService, context, viewParams, showBusyIndicator, controlAction, appDeCodeName, appDeMajorFieldName } = this.state;
const { items } = toRefs(this.state); const { items } = toRefs(this.state);
if (!controlAction.removeAction) { if (!controlAction.removeAction) {
return; return;
...@@ -215,23 +215,48 @@ export class MDControl extends MainControl { ...@@ -215,23 +215,48 @@ export class MDControl extends MainControl {
}); });
if (_data.length > 0) { if (_data.length > 0) {
const keys: string[] = []; const keys: string[] = [];
_data.forEach((item: IParam) => { // 删除确认信息
let confirmInfo: string = '';
_data.forEach((item: IParam, index: number) => {
keys.push(item.srfkey); keys.push(item.srfkey);
const text = item[appDeMajorFieldName.toLowerCase()] || item.srfmajortext;
if (index < 5) {
if (index !== 0 && isExistAndNotEmpty(text)) {
confirmInfo += '、';
}
confirmInfo += text;
}
}); });
const _removeAction = keys.length > 1 ? 'removeBatch' : controlAction.removeAction; confirmInfo += ` ${_data.length < 5 ? ' ' : ' ... '}${_data.length} 条数据`;
let _context = deepCopy(context); // 移除空白主键信息
Object.assign(_context, { [appDeCodeName]: keys }); confirmInfo = confirmInfo.replace(/[null]/g, '').replace(/[undefined]/g, '');
let _viewParams = deepCopy(viewParams); const removeData = async () => {
const arg: IParam = { const _removeAction = keys.length > 1 ? 'removeBatch' : controlAction.removeAction;
[appDeCodeName]: keys, let _context = deepCopy(context);
}; Object.assign(_context, { [appDeCodeName.toLowerCase()]: keys });
Object.assign(arg, { viewParams: _viewParams }); let _viewParams = deepCopy(viewParams);
const response = await controlService.remove(_context, arg, { const arg: IParam = {
action: _removeAction, [appDeCodeName.toLowerCase()]: keys,
isLoading: showBusyIndicator, };
}); Object.assign(arg, { viewParams: _viewParams });
if (response.status || response.status == 200) { const response = await controlService.remove(_context, arg, {
action: _removeAction,
isLoading: showBusyIndicator,
});
if (response.status || response.status == 200) {
}
} }
// 弹出提示模态
Modal.confirm({
title: '删除警告',
content: `确认删除 ${confirmInfo} 吗?删除操作将不可恢复`,
okText: '确认',
cancelText: '取消',
onOk: () => {
removeData();
},
onCancel: () => { }
});
} }
} catch (error) { } catch (error) {
// TODO 错误异常处理 // TODO 错误异常处理
...@@ -290,7 +315,7 @@ export class MDControl extends MainControl { ...@@ -290,7 +315,7 @@ export class MDControl extends MainControl {
}); });
this.setCreateDefault(response.data); this.setCreateDefault(response.data);
if (response.status || response.status == 200) { if (response.status || response.status == 200) {
items.value = [...items.value, [response.data]]; items.value.push(response.data);
} }
} catch (error) { } catch (error) {
// TODO 错误异常处理 // TODO 错误异常处理
......
...@@ -22,7 +22,9 @@ export class ControlVO extends ControlVOBase { ...@@ -22,7 +22,9 @@ export class ControlVO extends ControlVOBase {
export const ctrlState = { export const ctrlState = {
controlCodeName: '{{ctrl.codeName}}', controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}', controlName: '{{ctrl.name}}',
appEntityCodeName:'{{ctrl.appEntity.codeName}}', appDeCodeName:'{{ctrl.appEntity.codeName}}',
appDeKeyFieldName: '{{#if ctrl.appEntity.keyPSAppDEField}}{{ctrl.appEntity.keyPSAppDEField.codeName}}{{/if}}',
appDeMajorFieldName: '{{#if ctrl.appEntity.majorPSAppDEField}}{{ctrl.appEntity.majorPSAppDEField.codeName}}{{/if}}',
controlService: new GridService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ), controlService: new GridService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ),
// 新建默认值 // 新建默认值
createDefaultItems: [ createDefaultItems: [
...@@ -32,8 +34,12 @@ export const ctrlState = { ...@@ -32,8 +34,12 @@ export const ctrlState = {
createDV: "{{editItem.createDV}}", createDV: "{{editItem.createDV}}",
createDVT: "{{editItem.createDVT}}", createDVT: "{{editItem.createDVT}}",
property: "{{lowerCase editItem.codeName}}", property: "{{lowerCase editItem.codeName}}",
{{#if editItem.psAppDEField}} {{#if (and editItem.psEditor editItem.psEditor.dateTimeFormat)}}
valueFormat: "{{editItem.psEditor.dateTimeFormat}}",
{{else if editItem.psAppDEField}}
valueFormat: "{{editItem.psAppDEField.valueFormat}}", valueFormat: "{{editItem.psAppDEField.valueFormat}}",
{{/if}}
{{#if editItem.psAppDEField}}
fieldType: "{{editItem.psAppDEField.stdDataType}}" fieldType: "{{editItem.psAppDEField.stdDataType}}"
{{/if}} {{/if}}
}{{#unless @last}},{{/unless}} }{{#unless @last}},{{/unless}}
...@@ -121,8 +127,12 @@ export const ctrlState = { ...@@ -121,8 +127,12 @@ export const ctrlState = {
updateDV: "{{editItem.updateDV}}", updateDV: "{{editItem.updateDV}}",
updateDVT: "{{editItem.updateDVT}}", updateDVT: "{{editItem.updateDVT}}",
property: "{{lowerCase editItem.codeName}}", property: "{{lowerCase editItem.codeName}}",
{{#if editItem.psAppDEField}} {{#if (and editItem.psEditor editItem.psEditor.dateTimeFormat)}}
valueFormat: "{{editItem.psEditor.dateTimeFormat}}",
{{else if editItem.psAppDEField}}
valueFormat: "{{editItem.psAppDEField.valueFormat}}", valueFormat: "{{editItem.psAppDEField.valueFormat}}",
{{/if}}
{{#if editItem.psAppDEField}}
fieldType: "{{editItem.psAppDEField.stdDataType}}" fieldType: "{{editItem.psAppDEField.stdDataType}}"
{{/if}} {{/if}}
}{{#unless @last}},{{/unless}} }{{#unless @last}},{{/unless}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册