文件属性必填校验

This commit is contained in:
mrs_12345@163.com 2022-06-29 13:58:50 +08:00
parent 6d40c53630
commit 5acf86a4cd

View File

@ -17,16 +17,16 @@
<!--string类型-->
<template v-if="item.type=='string' && item.id != 'PLNAME'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input :size=size :disabled="item.readonly" v-model="item.value" @blur="saveStringPropVal(item.id, item.value, item.attrSource)"></el-input>
<el-input :size=size :disabled="item.readonly" v-model="item.value" @blur="saveStringPropVal(item.id, item.value, item.attrSource,item)"></el-input>
</div>
</div>
</template>
<!--textarea类型-->
<template v-if="item.type=='textarea'">
<div class="property-item">
<label class="property-label" style="vertical-align: bottom;">{{item.label}}</label>
<label class="property-label" style="vertical-align: bottom;"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input
:size=size
@ -35,7 +35,7 @@
placeholder="请输入内容"
v-model="item.value"
:disabled="item.readonly"
@blur="saveStringPropVal(item.id, item.value, item.attrSource)"
@blur="saveStringPropVal(item.id, item.value, item.attrSource,item)"
>
</el-input>
</div>
@ -44,19 +44,19 @@
<!--number类型-->
<template v-if="item.type=='number'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input-number @change="saveNumberPropVal(item.id, item.value, item.attrSource)" :size=size style="width: 100%;cursor: pointer;" controls-position="right" :step="1" v-model="item.value" :disabled="item.readonly"></el-input-number>
<el-input-number @change="saveNumberPropVal(item.id, item.value, item.attrSource,item)" :size=size style="width: 100%;cursor: pointer;" controls-position="right" :step="1" v-model="item.value" :disabled="item.readonly"></el-input-number>
</div>
</div>
</template>
<!--boolean类型-->
<template v-if="item.type=='boolean'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<template>
<el-select @change="saveSingleSelectVal(item.id, item.value, item.attrSource)" :disabled="item.readonly" clearable :size=size style="width: 100%" v-model="item.value" placeholder="请选择">
<el-select @change="saveSingleSelectVal(item.id, item.value, item.attrSource,item)" :disabled="item.readonly" clearable :size=size style="width: 100%" v-model="item.value" placeholder="请选择">
<el-option
v-for="option in item.options"
:key="option.value"
@ -71,10 +71,10 @@
<!--select类型-->
<template v-if="item.type=='select'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<template>
<el-select @change="saveSingleSelectVal(item.id, item.value, item.attrSource)" :disabled="item.readonly" clearable :size=size style="width: 100%" v-model="item.value" placeholder="请选择">
<el-select @change="saveSingleSelectVal(item.id, item.value, item.attrSource,item)" :disabled="item.readonly" clearable :size=size style="width: 100%" v-model="item.value" placeholder="请选择">
<el-option
v-for="option in item.options"
:key="option.value"
@ -89,10 +89,10 @@
<!--select_m类型-->
<template v-if="item.type=='select_m'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<template>
<el-select @change="saveMultipleSelectVal(item.id, item.value, item.attrSource)" :disabled="item.readonly" :size=size style="width: 100%" multiple v-model="item.value" placeholder="请选择">
<el-select @change="saveMultipleSelectVal(item.id, item.value, item.attrSource,item)" :disabled="item.readonly" :size=size style="width: 100%" multiple v-model="item.value" placeholder="请选择">
<el-option
v-for="option in item.options"
:key="option.value"
@ -107,25 +107,25 @@
<!--deptAddress类型平台部门地址簿-->
<template v-if="item.type=='deptAddress'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input :size=size :disabled="item.readonly" readonly @click.native="choiceBpmOrgAddressComponent(group.groupPath, item.type, item.id, item.readonly)" v-model="item.value"></el-input>
<el-input :size=size :disabled="item.readonly" readonly @click.native="choiceBpmOrgAddressComponent(group.groupPath, item.type, item.id, item.readonly,item.isRequired,item.label)" v-model="item.value"></el-input>
</div>
</div>
</template>
<!--userAddress类型平台人员地址簿-->
<template v-if="item.type=='userAddress'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input :size=size :disabled="item.readonly" readonly @click.native="choiceBpmOrgAddressComponent(group.groupPath,item.type, item.id, item.readonly)" v-model="item.value"></el-input>
<el-input :size=size :disabled="item.readonly" readonly @click.native="choiceBpmOrgAddressComponent(group.groupPath,item.type, item.id, item.readonly,item.isRequired,item.label)" v-model="item.value"></el-input>
</div>
</div>
</template>
<!--relation-org-shape类型PAL组织形状调用-->
<template v-if="item.type=='relationOrg'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input :size=size :disabled="item.readonly" readonly v-model="item.value"></el-input>
</div>
@ -134,43 +134,43 @@
<!--awsorg类型-->
<template v-if="item.type=='awsorg'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input :size=size :disabled="item.readonly" readonly @click.native="choiceAwsOrgComponent(item.ref, item.type, item.id, item.label, item.readonly)" v-model="item.value"></el-input>
<el-input :size=size :disabled="item.readonly" readonly @click.native="choiceAwsOrgComponent(item.ref, item.type, item.id, item.label, item.readonly,item.isRequired)" v-model="item.value"></el-input>
</div>
</div>
</template>
<!--relation类型-->
<template v-if="item.type=='relation'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input :size=size :disabled="item.readonly" readonly @click.native="choiceRelationComponent(item.ref, item.type, item.id, item.label, item.readonly, item.fileIds, item.shapeIds)" v-model="item.value"></el-input>
<el-input :size=size :disabled="item.readonly" readonly @click.native="choiceRelationComponent(item.ref, item.type, item.id, item.label, item.readonly, item.fileIds, item.shapeIds,item.isRequired)" v-model="item.value"></el-input>
</div>
</div>
</template>
<!-- link类型 -->
<template v-if="item.type=='link' && item.id != 'PLNAME'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input :size=size :disabled="item.readonly" v-model="item.value" @blur="saveStringPropVal(item.id, item.value, item.attrSource)"></el-input>
<el-input :size=size :disabled="item.readonly" v-model="item.value" @blur="saveStringPropVal(item.id, item.value, item.attrSource,item)"></el-input>
</div>
</div>
</template>
<!-- DateTimePicker 类型 -->
<template v-if="item.type=='DateTimePicker'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-date-picker value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%;" type="datetime" placeholder="请选择日期时间" @blur="saveStringPropVal(item.id, item.value, item.attrSource)" :disabled="item.readonly" v-model="item.value" ></el-date-picker>
<el-date-picker value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%;" type="datetime" placeholder="请选择日期时间" @blur="saveStringPropVal(item.id, item.value, item.attrSource,item)" :disabled="item.readonly" v-model="item.value" ></el-date-picker>
</div>
</div>
</template>
<!-- table 类型 -->
<template v-if="item.type=='table'">
<div class="property-item">
<label class="property-label">{{item.label}}</label>
<label class="property-label"><span v-if="item.isRequired!==undefined && item.isRequired" class="required"></span>{{item.label}}</label>
<div class="property-value">
<el-input :size=size :disabled="item.readonly" readonly v-model="dialogTableInput">
<template slot="suffix">
@ -287,7 +287,8 @@
bpmOrgAddress: {
visible: false,
addressType: "user",
multiple: false
multiple: false,
isRequired: false
},
palRelationAddressVisible: false,
title: '',
@ -299,7 +300,8 @@
method: '',
wsId: this.$store.getters.getWsIdFn,
teamId: this.$store.getters.getTeamIdFn,
multiple: false
multiple: false,
isRequired: false
},
propertyData: [
{
@ -311,6 +313,7 @@
size: 'medium',
currPropertyId: '',
currPropertyType: '',
currPropertyLabel: '',
currGroup: '',
currCategory: '',
currMethod: '',
@ -409,37 +412,53 @@
}
this.tableDialogVisible = false
},
saveStringPropVal(attrId, value, attrSource) {//
saveStringPropVal(attrId, value, attrSource,obj) {//
if (value == undefined) {
value = '';
}
if (obj.isRequired !== undefined && obj.isRequired && value == '') {
this.$message({message: `[${obj.label}]不允许为空`,type: 'warning'});
return false
}
if (attrSource && attrSource == 'default') {
this.saveDefaultpropToDb(attrId, value);
} else {
this.saveCustomPropToDb(attrId, value);
}
},
saveNumberPropVal(attrId, value, attrSource) {//
saveNumberPropVal(attrId, value, attrSource,obj) {//
if (value == undefined) {
value = '';
}
if (obj.isRequired !== undefined && obj.isRequired && value == '') {
this.$message({message: `[${obj.label}]不允许为空`,type: 'warning'});
return false
}
if (attrSource && attrSource == 'default') {
this.saveDefaultpropToDb(attrId, value);
} else {
this.saveCustomPropToDb(attrId, value);
}
},
saveSingleSelectVal(attrId, value, attrSource) {// boolean
saveSingleSelectVal(attrId, value, attrSource,obj) {// boolean
if (value == undefined) {
value = '';
}
if (obj.isRequired !== undefined && obj.isRequired && value == '') {
this.$message({message: `[${obj.label}]不允许为空`,type: 'warning'});
return false
}
if (attrSource && attrSource == 'default') {
this.saveDefaultpropToDb(attrId, value);
} else {
this.saveCustomPropToDb(attrId, value);
}
},
saveMultipleSelectVal(attrId, value, attrSource) {//
saveMultipleSelectVal(attrId, value, attrSource,obj) {//
if (obj.isRequired !== undefined && obj.isRequired && value == '') {
this.$message({message: `[${obj.label}]不允许为空`,type: 'warning'});
return false
}
value = value.join(',');
if (attrSource && attrSource == 'default') {
this.saveDefaultpropToDb(attrId, value);
@ -499,10 +518,11 @@
console.log(error);
})
},
choiceRelationComponent(ref, type, id, label, readonly, fileIds, shapeIds) {// PAL/
choiceRelationComponent(ref, type, id, label, readonly, fileIds, shapeIds,isRequired) {// PAL/
if (!readonly) {
this.currPropertyId = id;
this.currPropertyType = type;
this.currPropertyLabel = label
const method = ref.method;
if (method.indexOf('.') > -1) {
this.currCategory = method.substring(0, method.indexOf('.'));
@ -521,36 +541,46 @@
this.relation.category = this.currCategory;
this.relation.method = this.currMethod;
this.relation.multiple = ref.multiple;
this.relation.isRequired = isRequired
this.palRelationAddressVisible = true;
}
},
choiceBpmOrgAddressComponent(group, type, id, readonly) {// 簿
choiceBpmOrgAddressComponent(group, type, id, readonly,isRequired,label) {// 簿
if (!readonly) {
this.currPropertyId = id;
this.currPropertyType = type;
this.currPropertyLabel = label
if (type == "deptAddress") {//
this.title = '责任部门';
this.bpmOrgAddress.addressType = 'dept';
this.bpmOrgAddress.visible = true;
this.bpmOrgAddress.isRequired = isRequired
} else if (type == "userAddress") {//
this.title = '责任人';
this.bpmOrgAddress.addressType = 'user';
this.bpmOrgAddress.visible = true;
this.bpmOrgAddress.isRequired = isRequired
}
}
},
choiceAwsOrgComponent(ref, type, id, label, readonly) {// AWS//
choiceAwsOrgComponent(ref, type, id, label, readonly,isRequired) {// AWS//
if (!readonly) {
this.currPropertyId = id;
this.currPropertyType = type;
this.currPropertyLabel = label
this.title = label;
this.bpmOrgAddress.addressType = ref.scope.join(',');
this.bpmOrgAddress.multiple = ref.multiple;
this.bpmOrgAddress.visible = true;
this.bpmOrgAddress.isRequired = isRequired
}
},
saveBpmOrgAddressResult(data) {
this.bpmOrgAddress.visible = false;
if (this.bpmOrgAddress.isRequired && data.length == 0) {
this.$message({message: `[${this.currPropertyLabel}]不允许为空`,type: 'warning'});
return false;
}
//
const params = [];
for (let i = 0; i < data.length; i++) {
@ -560,6 +590,10 @@
},
//
saveRelationResult(data) {
if(this.relation.isRequired && data.length == 0) {
this.$message({message: `[${this.currPropertyLabel}]不允许为空`,type: 'warning'});
return false;
}
//
const jsonContent = {
fileId : this.id,
@ -665,6 +699,11 @@
.property-item {
margin-top: 15px;
}
.required::before{
content: '*';
color: red;
padding-right: 2px;
}
.property-label {
width: 11%;
display: inline-block;