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

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

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