提交 7447b3b3 编写于 作者: KK's avatar KK

搜索表单同步值规则

上级 4252170a
<#ibizinclude> <#ibizinclude>
./CONTROL-BASE.template.ftl ./CONTROL-BASE.template.ftl
</#ibizinclude> </#ibizinclude>
<#ibizinclude>../../@NAVPARAMS/FUNC/PUBLIC.vue.ftl</#ibizinclude>
<#assign import_block> <#assign import_block>
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail'; import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { Util } from '@/ibiz-core/utils';
</#assign> </#assign>
<#ibizinclude> <#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl ../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
...@@ -85,6 +86,14 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -85,6 +86,14 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
*/ */
@Prop() protected removeAction!: string; @Prop() protected removeAction!: string;
/**
* 视图参数
*
* @type {*}
* @memberof YDDTBJ
*/
@Prop({ default: false }) protected isautoload?: boolean;
/** /**
* 部件行为--loaddraft * 部件行为--loaddraft
* *
...@@ -133,6 +142,16 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -133,6 +142,16 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
*/ */
protected formState: Subject<any> = new Subject(); protected formState: Subject<any> = new Subject();
/**
* 应用状态事件
*
* @public
* @type {(Subscription | undefined)}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public appStateEvent: Subscription | undefined;
/** /**
* 忽略表单项值变化 * 忽略表单项值变化
* *
...@@ -205,6 +224,14 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -205,6 +224,14 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
*/ */
protected saveState:any ; protected saveState:any ;
/**
* 异常信息缓存
*
* @type {any}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public errorCache :any = {};
/** /**
* 属性值规则 * 属性值规则
* *
...@@ -214,11 +241,32 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -214,11 +241,32 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
protected rules: any = { protected rules: any = {
<#list ctrl.getAllPSDEFormDetails() as formdetail> <#list ctrl.getAllPSDEFormDetails() as formdetail>
<#if formdetail.getDetailType?? && formdetail.getDetailType() == 'FORMITEM'> <#if formdetail.getDetailType?? && formdetail.getDetailType() == 'FORMITEM'>
<#assign itemRuleCount = 0/>
<#if ctrl.getPSDEFormItemVRs()??>
<#list ctrl.getPSDEFormItemVRs() as fideValueRule>
<#if fideValueRule.getPSDEFormItemName() == formdetail.getName()>
<#if fideValueRule.getPSSysValueRule()??>
<#assign valueRule = fideValueRule.getPSSysValueRule()/>
<#if valueRule.getRuleType?? && valueRule.getRuleType()??>
<#if valueRule.getRuleType() == "REG">
<#assign itemRuleCount += 1/>
<#elseif valueRule.getRuleType() == "SCRIPT">
<#assign itemRuleCount += 1/>
</#if>
</#if>
</#if>
<#if fideValueRule.getCheckMode?? && fideValueRule.getCheckMode()?? && fideValueRule.getCheckMode() != 2 && fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??>
<#assign itemRuleCount += 1/>
</#if>
</#if>
</#list>
</#if>
<#if itemRuleCount gt 0 || formdetail.isAllowEmpty() == false>
${formdetail.getName()}: [ ${formdetail.getName()}: [
{ type: '<#assign datatype=srfjavatype(formdetail.getStdDataType())><#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>number<#else>string</#if>', message: '${formdetail.getCaption()} 值必须为<#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>数值<#else>字符串</#if>类型', trigger: 'change' }, <#if formdetail.isAllowEmpty() == false>
{ type: '<#assign datatype=srfjavatype(formdetail.getStdDataType())><#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>number<#else>string</#if>', message: '${formdetail.getCaption()} 值必须为<#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>数值<#else>字符串</#if>类型', trigger: 'blur' }, { required: true, type: '<#assign datatype=srfjavatype(formdetail.getStdDataType())><#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>number<#else>string</#if>', message: 'required', trigger: 'change' },
{ required: <#if formdetail.isAllowEmpty()>false<#else>true</#if>, type: '<#assign datatype=srfjavatype(formdetail.getStdDataType())><#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>number<#else>string</#if>', message: '${formdetail.getCaption()} 值不能为空', trigger: 'change' }, { required: true, type: '<#assign datatype=srfjavatype(formdetail.getStdDataType())><#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>number<#else>string</#if>', message: 'required', trigger: 'blur' },
{ required: <#if formdetail.isAllowEmpty()>false<#else>true</#if>, type: '<#assign datatype=srfjavatype(formdetail.getStdDataType())><#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>number<#else>string</#if>', message: '${formdetail.getCaption()} 值不能为空', trigger: 'blur' }, </#if>
<#if formdetail.getEditorType?? && formdetail.getEditorType()?? && formdetail.isAllowEmpty?? && formdetail.isAllowEmpty()??> <#if formdetail.getEditorType?? && formdetail.getEditorType()?? && formdetail.isAllowEmpty?? && formdetail.isAllowEmpty()??>
<#if formdetail.getEditorType() == 'CHECKBOX' && !formdetail.isAllowEmpty()> <#if formdetail.getEditorType() == 'CHECKBOX' && !formdetail.isAllowEmpty()>
{ validator: (rule:any, value:any, callback:any) => { { validator: (rule:any, value:any, callback:any) => {
...@@ -233,6 +281,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -233,6 +281,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
<#if ctrl.getPSDEFormItemVRs()??> <#if ctrl.getPSDEFormItemVRs()??>
<#list ctrl.getPSDEFormItemVRs() as fideValueRule> <#list ctrl.getPSDEFormItemVRs() as fideValueRule>
<#if fideValueRule.getPSDEFormItemName() == formdetail.getName()> <#if fideValueRule.getPSDEFormItemName() == formdetail.getName()>
<#-- 系统值规则 -->
<#if fideValueRule.getPSSysValueRule()??> <#if fideValueRule.getPSSysValueRule()??>
<#assign valueRule = fideValueRule.getPSSysValueRule()/> <#assign valueRule = fideValueRule.getPSSysValueRule()/>
<#if valueRule.getRuleType?? && valueRule.getRuleType()??> <#if valueRule.getRuleType?? && valueRule.getRuleType()??>
...@@ -243,14 +292,115 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -243,14 +292,115 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
</#if> </#if>
</#if> </#if>
</#if> </#if>
<#-- 属性值规则 -->
<#if fideValueRule.getCheckMode?? && fideValueRule.getCheckMode()?? && fideValueRule.getCheckMode() != 2 && fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??>
<#assign deRule = fideValueRule.getPSDEFValueRule()/>
{validator:(rule:any, value:any)=>{return this.verifyDeRules("${fideValueRule.getPSDEFormItemName()}").isPast}}
</#if>
</#if> </#if>
</#list> </#list>
</#if> </#if>
], ],
</#if>
</#if> </#if>
</#list> </#list>
} }
/**
* 属性值规则
*
* @type {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public deRules:any = {
<#if ctrl.getPSDEFormItemVRs?? && ctrl.getPSDEFormItemVRs()??>
<#list ctrl.getPSDEFormItemVRs() as fideValueRule>
<#if fideValueRule.getCheckMode?? && fideValueRule.getCheckMode()?? && fideValueRule.getCheckMode() != 2 && fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??>
<#assign deRule = fideValueRule.getPSDEFValueRule()/>
<#if fideValueRule.getPSDEFormItemName?? && fideValueRule.getPSDEFormItemName()??>
${fideValueRule.getPSDEFormItemName()}:[
<#if deRule.getPSDEFVRGroupCondition?? && deRule.getPSDEFVRGroupCondition()?? && deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions?? && deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions()??>
<#list deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions() as condItem>
<@getDeRule condItem />
</#list>
</#if>],
</#if>
</#if>
</#list>
</#if>
};
/**
* 校验属性值规则
*
* @public
* @param {{ name: string }} { name }
* @memberof MobNewFormBase
*/
public verifyDeRules(name:string,rule:any = this.deRules,op:string = "AND") :{isPast:boolean,infoMessage:string}{
let falg:any = {infoMessage:""};
if(!rule[name]){
return falg;
}
let opValue = op == 'AND'? true :false;
let startOp = (val:boolean)=>{
if(falg.isPast){
if(opValue){
falg.isPast = falg && val;
}else{
falg.isPast = falg || val;
}
}else{
falg.isPast = val;
}
}
rule[name].forEach((item:any) => {
let dataValue = item.deName?this.data[this.service.getItemNameByDeName(item.deName)]:"";
// 常规规则
if(item.type == 'SIMPLE'){
startOp(!this.$verify.checkFieldSimpleRule(dataValue,item.condOP,item.paramValue,item.ruleInfo,item.paramType,this.data,item.isKeyCond));
falg.infoMessage = item.ruleInfo;
this.errorCache[item.deName] = item.ruleInfo;
}
// 数值范围
if(item.type == 'VALUERANGE2'){
startOp( !this.$verify.checkFieldValueRangeRule(dataValue,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
this.errorCache[item.deName] = item.ruleInfo;
falg.infoMessage = item.ruleInfo;
}
// 正则式
if (item.type == "REGEX") {
startOp(!this.$verify.checkFieldRegExRule(dataValue,item.regExCode,item.ruleInfo,item.isKeyCond));
this.errorCache[item.deName] = item.ruleInfo;
falg.infoMessage = item.ruleInfo;
}
// 长度
if (item.type == "STRINGLENGTH") {
startOp(!this.$verify.checkFieldStringLengthRule(dataValue,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
this.errorCache[item.deName] = item.ruleInfo;
falg.infoMessage = item.ruleInfo;
}
// 系统值规则
if(item.type == "SYSVALUERULE") {
startOp(!this.$verify.checkFieldSysValueRule(dataValue,item.sysRule.regExCode,item.ruleInfo,item.isKeyCond));
this.errorCache[item.deName] = item.ruleInfo;
falg.infoMessage = item.ruleInfo;
}
// 分组
if(item.type == 'GROUP'){
falg = this.verifyDeRules('group',item)
if(item.isNotMode){
falg.isPast = !falg.isPast;
}
}
});
if(!falg.hasOwnProperty("isPast")){
falg.isPast = true;
}
return falg;
}
/** /**
* 详情模型集合 * 详情模型集合
* *
...@@ -333,7 +483,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -333,7 +483,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal } * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof ${srfclassname('${ctrl.codeName}')} * @memberof ${srfclassname('${ctrl.codeName}')}
*/ */
private formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void { private async formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }){
<#if P.getPartCode(item,'FORM_LOGIC').code?length gt 0> <#if P.getPartCode(item,'FORM_LOGIC').code?length gt 0>
${P.getPartCode(item,'FORM_LOGIC').code} ${P.getPartCode(item,'FORM_LOGIC').code}
</#if> </#if>
...@@ -344,13 +494,63 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -344,13 +494,63 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
if (Object.is(name, '${formitem.name}')) { if (Object.is(name, '${formitem.name}')) {
const details: string[] = [<#list itemUpdate.getPSDEFIUpdateDetails() as detail><#if detail_index gt 0>, </#if>'${detail.getPSDEFormDetailName()?lower_case}'</#list>]; const details: string[] = [<#list itemUpdate.getPSDEFIUpdateDetails() as detail><#if detail_index gt 0>, </#if>'${detail.getPSDEFormDetailName()?lower_case}'</#list>];
this.updateFormItems('${itemUpdate.codeName}', this.data, details, ${itemUpdate.isShowBusyIndicator()?c}); if(await this.validItem('${formitem.name}', this.data['${formitem.name}'])){
this.updateFormItems('${itemUpdate.getPSAppDEMethod().getCodeName()}', this.data, details, ${itemUpdate.isShowBusyIndicator()?c});
}
} }
</#if> </#if>
</#list> </#list>
</#if> </#if>
} }
/**
* 表单项校验逻辑
*
* @public
* @param name 属性名
* @memberof Main2Base
*/
public validItem(property:string, data:any):Promise<any>{
return new Promise((resolve, reject) => {
if(!property || !this.rules[property]){
resolve(true);
}
Util.validateItem(property,data,this.rules[property]).then(()=>{
this.detailsModel[property].setError("");
resolve(true);
}).catch(({ errors, fields }) => {
const {field , message } = errors[0];
let _message :any = (this.$t(`project.mobnewform_form.details.<#noparse>${field}</#noparse>`) as string) +' '+ this.$t(`app.form.rules.<#noparse>${message}</#noparse>`);
this.detailsModel[property].setError(this.errorCache[property]?this.errorCache[property]: _message);
resolve(false);
});
});
}
/**
* 校验全部
*
* @public
* @param {{ filter: string}} { filter}
* @returns {void}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public async validAll(filter:string = "defult") {
let validateState = true;
let filterProperty = ""
if(filter === 'new'){
filterProperty= '${appde.getKeyPSAppDEField().getCodeName()?lower_case}'
}
for (let item of Object.keys(this.rules)) {
if(!await this.validItem(item,this.data[item]) && item != filterProperty){
validateState = false;
}
}
return validateState
}
/** /**
* 表单值变化 * 表单值变化
* *
...@@ -363,6 +563,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -363,6 +563,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
if (this.ignorefieldvaluechange) { if (this.ignorefieldvaluechange) {
return; return;
} }
this.validItem(name,this.data[name]);
this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal }); this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal });
this.formLogic({ name: name, newVal: newVal, oldVal: oldVal }); this.formLogic({ name: name, newVal: newVal, oldVal: oldVal });
this.dataChang.next(JSON.stringify(this.data)); this.dataChang.next(JSON.stringify(this.data));
...@@ -404,6 +605,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -404,6 +605,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
if(Object.is(action,'loadDraft')){ if(Object.is(action,'loadDraft')){
this.createDefault(); this.createDefault();
} }
if(Object.is(action,'load')){
this.updateDefault();
}
this.$nextTick(function () { this.$nextTick(function () {
this.ignorefieldvaluechange = false; this.ignorefieldvaluechange = false;
}) })
...@@ -472,23 +676,6 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -472,23 +676,6 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
}); });
} }
/**
* 表单校验状态
*
* @returns {boolean}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
protected formValidateStatus(): boolean {
const refArr: Array<string> = [<#list ctrl.getPSDEFormItems() as formItem><#if formItem.getEditorType?? && formItem.getEditorType() != 'HIDDEN'>'${formItem.getName()}_item', </#if></#list>];
let falg = true;
refArr.forEach((item: any) => {
if (this.$refs[item] && (this.$refs[item] as any).validateRules && !(this.$refs[item] as any).validateRules()) {
falg = false;
}
});
return falg;
}
/** /**
* 获取全部值 * 获取全部值
* *
...@@ -676,6 +863,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -676,6 +863,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* @memberof ${srfclassname('${ctrl.codeName}')} * @memberof ${srfclassname('${ctrl.codeName}')}
*/ */
protected afterCreated(){ protected afterCreated(){
if(this.isautoload){
this.autoLoad({srfkey:this.context.${ctrl.getPSAppDataEntity().getCodeName()?lower_case}});
}
if (this.viewState) { if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => { this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) { if (!Object.is(tag, this.name)) {
...@@ -726,6 +916,16 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -726,6 +916,16 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.$emit('load', this.data); this.$emit('load', this.data);
</#if> </#if>
}); });
if(AppCenterService && AppCenterService.getMessageCenter()){
this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{
if(!Object.is(name,"${ctrl.getPSAppDataEntity().getCodeName()}")){
return;
}
if(Object.is(action,'appRefresh') && data.appRefreshAction && this.context.${ctrl.getPSAppDataEntity().getCodeName()?lower_case}){
this.refresh([data]);
}
})
}
} }
/** /**
...@@ -749,6 +949,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -749,6 +949,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
if (this.dataChangEvent) { if (this.dataChangEvent) {
this.dataChangEvent.unsubscribe(); this.dataChangEvent.unsubscribe();
} }
if(this.appStateEvent){
this.appStateEvent.unsubscribe();
}
<#if destroyed_block??> <#if destroyed_block??>
${destroyed_block} ${destroyed_block}
</#if> </#if>
...@@ -880,7 +1083,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -880,7 +1083,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
* @memberof ${srfclassname('${ctrl.codeName}')} * @memberof ${srfclassname('${ctrl.codeName}')}
*/ */
protected async autoSave(opt: any = {}): Promise<any> { protected async autoSave(opt: any = {}): Promise<any> {
if (!this.formValidateStatus()) { if (!await this.validAll()) {
return Promise.reject(); return Promise.reject();
} }
const arg: any = { ...opt }; const arg: any = { ...opt };
...@@ -928,13 +1131,15 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -928,13 +1131,15 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
protected async save(opt: any = {}, showResultInfo?: boolean, isStateNext: boolean = true): Promise<any> { protected async save(opt: any = {}, showResultInfo?: boolean, isStateNext: boolean = true): Promise<any> {
showResultInfo = showResultInfo === undefined ? true : false; showResultInfo = showResultInfo === undefined ? true : false;
opt.saveEmit = opt.saveEmit === undefined ? true : false; opt.saveEmit = opt.saveEmit === undefined ? true : false;
if (!this.formValidateStatus()) {
this.$notice.error('值规则校验异常');
return Promise.reject();
}
const arg: any = { ...opt }; const arg: any = { ...opt };
const data = this.getValues(); const data = this.getValues();
Object.assign(arg, data); Object.assign(arg, data);
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
if (this.data.srfuf =='1'? !await this.validAll():!await this.validAll('new')) {
this.$notice.error('值规则校验异常');
return Promise.reject();
}
if (isStateNext) { if (isStateNext) {
<#assign drcounter = 0> <#assign drcounter = 0>
<#list ctrl.getAllPSDEFormDetails() as formdetail> <#list ctrl.getAllPSDEFormDetails() as formdetail>
...@@ -949,12 +1154,13 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -949,12 +1154,13 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
return Promise.reject(); return Promise.reject();
} }
} }
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
if (!action) { if (!action) {
let actionName: any = Object.is(data.srfuf, '1') ? "updateAction" : "createAction"; let actionName: any = Object.is(data.srfuf, '1') ? "updateAction" : "createAction";
this.$notice.error(this.viewName+this.$t('app.view')+this.$t('app.ctrl.form')+actionName+ this.$t('app.notConfig')); this.$notice.error(this.viewName+this.$t('app.view')+this.$t('app.ctrl.form')+actionName+ this.$t('app.notConfig'));
return Promise.reject(); return Promise.reject();
} }
Object.assign(this.viewparams,{ <#if appde.getMajorPSAppDEField()??>${appde.getMajorPSAppDEField().getCodeName()?lower_case}<#else>srfmajortext</#if>: arg.<#if appde.getMajorPSAppDEField()??>${appde.getMajorPSAppDEField().getCodeName()?lower_case}<#else>srfmajortext</#if>});
Object.assign(arg, this.viewparams); Object.assign(arg, this.viewparams);
let response: any = null; let response: any = null;
if (Object.is(data.srfuf, '1')) { if (Object.is(data.srfuf, '1')) {
...@@ -969,6 +1175,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -969,6 +1175,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.$emit('save', data); this.$emit('save', data);
} }
<#if ctrl.getControlType() == 'FORM'> <#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:Object.assign(data,{appRefreshAction:action===this.createAction?false:true})});
this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag }); this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
</#if> </#if>
this.$nextTick(() => { this.$nextTick(() => {
...@@ -1013,6 +1220,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -1013,6 +1220,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.$emit('remove', data); this.$emit('remove', data);
this.formState.next({ type: 'remove', data: data }); this.formState.next({ type: 'remove', data: data });
this.data.ismodify = false; this.data.ismodify = false;
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$notice.success((data.srfmajortext ? data.srfmajortext : '') + '&nbsp;'+ this.$t('app.message.deleteSccess')); this.$notice.success((data.srfmajortext ? data.srfmajortext : '') + '&nbsp;'+ this.$t('app.message.deleteSccess'));
} else if (response && response.status !== 401) { } else if (response && response.status !== 401) {
const { error: _data } = response; const { error: _data } = response;
...@@ -1036,9 +1246,11 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -1036,9 +1246,11 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
Object.assign(arg, this.viewparams); Object.assign(arg, this.viewparams);
let response: any = await this.service.wfstart(_this.WFStartAction, { ...this.context }, arg, this.showBusyIndicator); let response: any = await this.service.wfstart(_this.WFStartAction, { ...this.context }, arg, this.showBusyIndicator);
if (response && response.status === 200) { if (response && response.status === 200) {
this.$notice.success('工作流启动成功'); <#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
return response
} else if (response && response.status !== 401) { } else if (response && response.status !== 401) {
this.$notice.error('工作流启动失败, ' + response.error.message);
} }
return response; return response;
} }
...@@ -1062,9 +1274,11 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -1062,9 +1274,11 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
} }
const response: any = await this.service.wfsubmit(this.currentAction, { ...this.context }, datas, this.showBusyIndicator, arg); const response: any = await this.service.wfsubmit(this.currentAction, { ...this.context }, datas, this.showBusyIndicator, arg);
if (response && response.status === 200) { if (response && response.status === 200) {
this.$notice.success('工作流提交成功'); <#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
return response
} else if (response && response.status !== 401) { } else if (response && response.status !== 401) {
this.$notice.error('工作流提交失败, ' + response.error.message);
return response; return response;
} }
} }
...@@ -1101,6 +1315,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -1101,6 +1315,9 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.fillForm(_data, 'updateFormItem'); this.fillForm(_data, 'updateFormItem');
this.formLogic({ name: '', newVal: null, oldVal: null }); this.formLogic({ name: '', newVal: null, oldVal: null });
this.dataChang.next(JSON.stringify(this.data)); this.dataChang.next(JSON.stringify(this.data));
<#if ctrl.getControlType() == 'FORM'>
AppCenterService.notifyMessage({name:"${ctrl.getPSAppDataEntity().getCodeName()}",action:'appRefresh',data:data});
</#if>
this.$nextTick(() => { this.$nextTick(() => {
this.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data }); this.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data });
}); });
...@@ -1212,15 +1429,70 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -1212,15 +1429,70 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
*/ */
public createDefault(){ public createDefault(){
<#list ctrl.getAllPSDEFormDetails() as formdetail><#t> <#list ctrl.getAllPSDEFormDetails() as formdetail><#t>
<#if formdetail.getCreateDV?? && formdetail.getCreateDV()??><#t> <#if formdetail.getCreateDVT?? && formdetail.getCreateDVT()?? && formdetail.getCreateDVT() != ''>
<#if !(formdetail.getCreateDV() == '')><#t>
if (this.data.hasOwnProperty('${formdetail.getCodeName()?lower_case}')) { if (this.data.hasOwnProperty('${formdetail.getCodeName()?lower_case}')) {
<#-- 当前操作用户(名称) -->
<#if formdetail.getCreateDVT() == 'OPERATORNAME'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.context['srfusername'];
<#-- 当前操作用户(编号) -->
<#elseif formdetail.getCreateDVT() == 'OPERATOR'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.context['srfuserid'];
<#-- 当前时间 -->
<#elseif formdetail.getCreateDVT() == 'CURTIME'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date());
</#if>
<#if formdetail.getCreateDV?? && formdetail.getCreateDV()??><#t>
<#-- 网页请求 --> <#-- 网页请求 -->
<#if formdetail.getCreateDVT() == 'CONTEXT'> <#if formdetail.getCreateDVT() == 'CONTEXT'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.viewparams['${formdetail.getCreateDV()}']; this.data['${formdetail.getCodeName()?lower_case}'] = this.viewparams['${formdetail.getCreateDV()}'];
<#-- 用户全局对象 -->
<#elseif formdetail.getCreateDVT() == 'SESSION'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.context['${formdetail.getCreateDV()}'];
<#-- 当前应用数据 -->
<#elseif formdetail.getCreateDVT() == 'APPDATA'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.context['${formdetail.getCreateDV()}'];
<#elseif formdetail.getCreateDVT() == 'OPERATORNAME'>
<#elseif formdetail.getCreateDVT() == 'OPERATOR'>
<#elseif formdetail.getCreateDVT() == 'CURTIME'>
<#else>
<#-- 默认值 -->
<#assign datatype=srfjavatype(formdetail.getStdDataType())>
this.data['${formdetail.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${formdetail.getCreateDV()}<#else>'${formdetail.getCreateDV()}'</#if>;
</#if>
</#if>
}
</#if>
</#list>
}
/**
* 更新默认值
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public updateDefault(){
<#list ctrl.getAllPSDEFormDetails() as formdetail><#t>
<#if formdetail.getUpdateDV?? && formdetail.getUpdateDV()??><#t>
<#if !(formdetail.getUpdateDVT() == '')><#t>
if (this.data.hasOwnProperty('${formdetail.getCodeName()?lower_case}') && !this.data.${formdetail.getCodeName()?lower_case}) {
<#-- 网页请求 -->
<#if formdetail.getUpdateDVT() == 'CONTEXT'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.viewparams['${formdetail.getUpdateDV()}'];
<#-- 用户全局对象 -->
<#elseif formdetail.getUpdateDVT() == 'SESSION'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.context['${formdetail.getUpdateDV()}'];
<#-- 当前应用数据 -->
<#elseif formdetail.getUpdateDVT() == 'APPDATA'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.context['${formdetail.getUpdateDV()}'];
<#-- 当前操作用户(名称) -->
<#elseif formdetail.getUpdateDVT() == 'OPERATORNAME'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.context['srfusername'];
<#-- 当前操作用户(编号) -->
<#elseif formdetail.getUpdateDVT() == 'OPERATOR'>
this.data['${formdetail.getCodeName()?lower_case}'] = this.context['srfuserid'];
<#else> <#else>
<#-- 默认值 --> <#-- 默认值 -->
this.data['${formdetail.getCodeName()?lower_case}'] = '${formdetail.getCreateDV()}'; <#assign datatype=srfjavatype(formdetail.getStdDataType())>
this.data['${formdetail.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${formdetail.getUpdateDV()}<#else>'${formdetail.getUpdateDV()}'</#if>;
</#if> </#if>
} }
</#if> </#if>
...@@ -1261,11 +1533,29 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; ...@@ -1261,11 +1533,29 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
this.$emit('load', this.data); this.$emit('load', this.data);
} }
</#if> </#if>
</#if> </#if>
<#-- 搜索表单:End -->
/**
* 计算表单按钮权限状态
*
* @param {*} [data] 传入数据
* @memberof EditorsBase
*/
public computeButtonState(data:any){
let targetData:any = this.transformData(data);
if(this.detailsModel && Object.keys(this.detailsModel).length >0){
Object.keys(this.detailsModel).forEach((name:any) =>{
if(this.detailsModel[name] && this.detailsModel[name].uiaction && this.detailsModel[name].uiaction.dataaccaction && Object.is(this.detailsModel[name].detailType,"BUTTON")){
let tempUIAction:any = JSON.parse(JSON.stringify(this.detailsModel[name].uiaction));
this.$viewTool.calcActionItemAuthState(targetData,[tempUIAction],this.globaluiservice);
this.detailsModel[name].visible = tempUIAction.visabled;
this.detailsModel[name].disabled = tempUIAction.disabled;
}
})
}
}
<#ibizinclude> <#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl ../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude> </#ibizinclude>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册