文件属性必填校验

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