227 lines
6.4 KiB
Vue
227 lines
6.4 KiB
Vue
<template>
|
|
<div class="AddBuildingBox">
|
|
<PageHeader :title="storeRoomid ? '编辑储藏室' : '添加储藏室'"></PageHeader>
|
|
<div class="AddBuildingBody">
|
|
<div class="title">基本信息</div>
|
|
<div class="addBuildingFormBody">
|
|
<el-form class="formBody" label-position="left" ref="formRef" :model="form" :rules="rules" label-width="100px">
|
|
<el-row>
|
|
<el-col :span="11">
|
|
<el-form-item label="楼栋" prop="buildingId">
|
|
<el-select @change="handleChangeBuild" v-model="form.buildingId" placeholder="请选择楼栋">
|
|
<el-option v-for="item in Buildinglists" :key="item.id" :label="item.buildingName" :value="item.id" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="2"></el-col>
|
|
<el-col :span="11">
|
|
<el-form-item label="单元" prop="unit">
|
|
<el-select v-model="form.unitNo" placeholder="请选择单元">
|
|
<el-option v-for="item in units" :key="item.no" :label="item.name" :value="item.no" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="11">
|
|
<el-form-item label="储藏室号" prop="storeroomNo">
|
|
<el-input v-model.number="form.storeroomNo" placeholder="请输入储藏室号" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="2"></el-col>
|
|
<el-col :span="11">
|
|
<el-form-item label="建筑面积" prop="houseArea">
|
|
<el-input v-model="form.houseArea" placeholder="请输入建筑面积" />
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="11">
|
|
<el-form-item label="公摊面积" prop="shareArea">
|
|
<el-input v-model="form.shareArea" placeholder="请输入公摊面积" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="2"></el-col>
|
|
<el-col :span="11">
|
|
<el-form-item label="实用面积" prop="internalArea">
|
|
<el-input v-model="form.internalArea" placeholder="请输入实用面积" />
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input type="textarea" :rows="5" v-model="form.remark" placeholder="请输入备注" />
|
|
</el-form-item>
|
|
<el-form-item style="margin-top: 30px">
|
|
<el-button type="primary" @click="submitForm">提交</el-button>
|
|
<el-button @click="cancelForm">取消</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref } from 'vue';
|
|
import PageHeader from '@/components/Pageheader/index.vue';
|
|
import { getBuildinglistAPI, getBuildinglists, getBuildingOnly, getHouselistAPI } from '@/api/system/house';
|
|
import { addStoreroom, getStoreroom, updateStoreroom } from '@/api/system/storeroom';
|
|
import { StoreroomVO } from '@/api/system/storeroom/types';
|
|
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
const formRef = ref();
|
|
const form = ref<StoreroomVO>({
|
|
id: null,
|
|
buildingId: '',
|
|
unitNo: '',
|
|
storeroomNo: '',
|
|
houseArea: null,
|
|
shareArea: null,
|
|
internalArea: null,
|
|
houseId: '',
|
|
status: 0,
|
|
remark: ''
|
|
});
|
|
const rules = ref({
|
|
buildingId: [{ required: true, message: '请选择楼栋', trigger: 'blur' }],
|
|
unitNo: [{ required: true, message: '请选择单元', trigger: 'blur' }],
|
|
storeroomNo: [{ required: true, message: '请输入储藏室号', trigger: 'blur' }]
|
|
});
|
|
|
|
const storeRoomid = ref(null);
|
|
const units = ref([]);
|
|
const Buildinglists = ref([]);
|
|
|
|
// 获取储藏室信息
|
|
function getStoreRoominfo(id: string) {
|
|
getStoreroom(id).then((res) => {
|
|
form.value = {
|
|
...form.value,
|
|
...res.data
|
|
};
|
|
if (form.value.buildingId) {
|
|
handleChangeBuild(form.value.buildingId, () => {
|
|
form.value.unitNo = res.data.unitNo;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
// 根据小区id获取楼栋单元
|
|
function init() {
|
|
getBuildinglists().then((res) => {
|
|
Buildinglists.value = res.rows;
|
|
});
|
|
}
|
|
init();
|
|
onMounted(() => {
|
|
if (route.query.id) {
|
|
storeRoomid.value = route.query.id;
|
|
getStoreRoominfo(storeRoomid.value);
|
|
}
|
|
});
|
|
// 根据楼栋id获取单元
|
|
function handleChangeBuild(val: string, callback?: () => void) {
|
|
getBuildingOnly(val).then((res) => {
|
|
units.value = Array.from({ length: res.data.unitCount }).map((_, index) => {
|
|
return {
|
|
no: index + 1,
|
|
name: index + 1 + '单元'
|
|
};
|
|
});
|
|
callback && callback();
|
|
});
|
|
}
|
|
const submitForm = () => {
|
|
formRef.value?.validate(async (valid: boolean) => {
|
|
if (valid) {
|
|
const data = {
|
|
...form.value
|
|
};
|
|
if (storeRoomid.value !== null) {
|
|
updateStoreroom(data).then(() => {
|
|
ElMessage.success('修改成功');
|
|
cancelForm();
|
|
});
|
|
} else {
|
|
addStoreroom(data).then(() => {
|
|
ElMessage.success('添加成功');
|
|
cancelForm();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
};
|
|
const cancelForm = () => {
|
|
router.back();
|
|
};
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.AddBuildingBox {
|
|
padding: 15px;
|
|
height: 100%;
|
|
width: 100%;
|
|
}
|
|
.AddBuildingBody {
|
|
margin-top: 20px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
background-color: white;
|
|
padding: 15px;
|
|
.title {
|
|
height: 40px;
|
|
line-height: 40px;
|
|
padding-left: 20px;
|
|
background-color: rgba(255, 255, 255, 1);
|
|
color: rgba(16, 16, 16, 1);
|
|
border-bottom: 1px solid #bbbbbb;
|
|
margin-bottom: 60px;
|
|
}
|
|
|
|
.addBuildingFormBody {
|
|
.formBody {
|
|
width: 1050px;
|
|
margin: 0 auto;
|
|
|
|
.el-form-item__content,
|
|
.el-select,
|
|
.el-input {
|
|
width: 440px;
|
|
margin-right: 10px;
|
|
}
|
|
.el-form-item {
|
|
margin-bottom: 20px;
|
|
align-items: center;
|
|
}
|
|
.unitBox {
|
|
.el-input {
|
|
width: 440px;
|
|
margin-right: 10px;
|
|
}
|
|
}
|
|
.el-button {
|
|
width: 80px;
|
|
height: 35px;
|
|
margin-right: 20px;
|
|
}
|
|
|
|
.houseTypebox {
|
|
display: flex;
|
|
align-items: center;
|
|
.el-input {
|
|
width: 100px;
|
|
margin-right: 0px;
|
|
}
|
|
span {
|
|
margin: 0 20px;
|
|
}
|
|
}
|
|
}
|
|
padding-bottom: 40px;
|
|
}
|
|
}
|
|
</style>
|