Commit 61d88aa9 authored by kaitly205422@163.com's avatar kaitly205422@163.com

添加验证楼层名称重复

parent 65a42085
...@@ -45,6 +45,10 @@ export default { ...@@ -45,6 +45,10 @@ export default {
props: { props: {
buildingId: { buildingId: {
type: String, type: String,
},
floorList: {
type: Array,
default: () => []
} }
}, },
destroyed() { destroyed() {
...@@ -62,12 +66,25 @@ export default { ...@@ -62,12 +66,25 @@ export default {
this.$emit('close', data) this.$emit('close', data)
}, },
onSubmit(values) { onSubmit(values) {
console.log(this.buildingId)
if (!this.buildingId) { if (!this.buildingId) {
return; return;
} }
this.form.buildingId = this.buildingId this.form.buildingId = this.buildingId
this.form.name = this.form.name + '' const name = this.form.name + ''
/* 检测类型当前楼层是否已存在 */
const typeObj = this.floorList.find(item => item.text === this.form.type);
if (typeObj && typeObj.children.find(item => item.text === name)) {
this.$toast.fail({
message: "楼层已存在",
duration: 2000
});
return;
}
if (!this.form.name.endsWith('')) {
this.form.name = name
}
postFun('/risk/plan/floor', this.form) postFun('/risk/plan/floor', this.form)
.then(res => { .then(res => {
this.$toast.clear(); this.$toast.clear();
......
...@@ -324,7 +324,7 @@ ...@@ -324,7 +324,7 @@
</div> </div>
</van-popup> </van-popup>
<div v-if="isFloor"> <div v-if="isFloor">
<addFloor @close="closeFloor" :buildingId="form.buildingIds" /> <addFloor @close="closeFloor" :buildingId="form.buildingIds" :floorList="floorSource" />
</div> </div>
<!-- 管控责任人 --> <!-- 管控责任人 -->
<van-popup v-model="showTrouble" position="bottom"> <van-popup v-model="showTrouble" position="bottom">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment