|
@@ -5,6 +5,12 @@
|
|
|
<el-tabs tab-position="left" v-model="activeTab">
|
|
|
<el-tab-pane name="first" label="车位信息">
|
|
|
<el-row>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="楼号" prop="ids">
|
|
|
+ <el-cascader v-model="formData.ids" :options="treeData" :props="{value:'id'}"
|
|
|
+ @change="selectBuilding" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="车位编号" prop="parkingNumber">
|
|
|
<el-input v-model="formData.parkingNumber"></el-input>
|
|
@@ -133,7 +139,7 @@
|
|
|
<script setup>
|
|
|
import { reactive, ref } from "vue";
|
|
|
import request from "/@/api/request";
|
|
|
-import { parking } from "/@/api/controllerUrls";
|
|
|
+import { buildingTree, parking } from "/@/api/controllerUrls";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import pictureUpload from "/@/components/pictureUpload/index.vue";
|
|
|
import pictureUpload2 from "/@/components/pictureUpload/multiple.vue";
|
|
@@ -159,14 +165,18 @@ function open(type1, data, districtId, communityId, buildingId) {
|
|
|
formData.districtId = districtId;
|
|
|
formData.communityId = communityId;
|
|
|
formData.buildingId = buildingId;
|
|
|
+ formData.ids = [formData.districtId,formData.communityId,formData.buildingId]
|
|
|
} else {
|
|
|
getInitData(data.id);
|
|
|
}
|
|
|
|
|
|
+ getTreeData();
|
|
|
+
|
|
|
showDialog.value = true;
|
|
|
}
|
|
|
|
|
|
let formData = reactive({
|
|
|
+ ids:[],
|
|
|
districtId: "",
|
|
|
communityId: "",
|
|
|
buildingId: "",
|
|
@@ -184,10 +194,13 @@ let formData = reactive({
|
|
|
saleStatus: 0,//出售状态
|
|
|
contactNumber: "",//联系电话
|
|
|
parkingShow: "<p><br></p>",//车位简介
|
|
|
- parkingStatus:0,//是否上架
|
|
|
+ parkingStatus: 0//是否上架
|
|
|
});
|
|
|
|
|
|
let formRules = {
|
|
|
+ ids: [
|
|
|
+ { required: true, message: "不能为空" }
|
|
|
+ ],
|
|
|
parkingNumber: [
|
|
|
{ required: true, message: "不能为空" }
|
|
|
],
|
|
@@ -206,6 +219,8 @@ let formRules = {
|
|
|
};
|
|
|
|
|
|
|
|
|
+let treeData = ref([]);
|
|
|
+
|
|
|
function getInitData(event) {
|
|
|
request.index(parking, {
|
|
|
id: event
|
|
@@ -216,8 +231,45 @@ function getInitData(event) {
|
|
|
formData[key] = res.data[key];
|
|
|
}
|
|
|
formData.id = event;
|
|
|
+ formData.ids = [res.data.districtId,res.data.communityId,res.data.buildingId]
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function getTreeData() {
|
|
|
+
|
|
|
+ request.index(buildingTree, {}, "").then((res) => {
|
|
|
+ if (res.code == 1) {
|
|
|
+ treeData.value = resetTreeData(res.data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function resetTreeData(data) {
|
|
|
+ for (let i in data) {
|
|
|
+ if (data[i].hasOwnProperty("children")) {
|
|
|
+ data[i]["children"] = resetTreeData(data[i]["children"]);
|
|
|
+ }
|
|
|
+ if (data[i].hasOwnProperty("label")) {
|
|
|
+
|
|
|
+ } else if (data[i].hasOwnProperty("districtName")) {
|
|
|
+ data[i]["label"] = data[i]["districtName"];
|
|
|
+ } else if (data[i].hasOwnProperty("communityName")) {
|
|
|
+ data[i]["label"] = data[i]["communityName"];
|
|
|
+ } else if (data[i].hasOwnProperty("buildingNumber")) {
|
|
|
+ data[i]["label"] = data[i]["buildingNumber"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+}
|
|
|
+
|
|
|
+function selectBuilding(e) {
|
|
|
+ formData.districtId = formData.ids[0] ? formData.ids[0] : null;
|
|
|
+ formData.communityId = formData.ids[1] ? formData.ids[1] : null;
|
|
|
+ formData.buildingId = formData.ids[2] ? formData.ids[2] : null;
|
|
|
}
|
|
|
|
|
|
function submit() {
|
|
@@ -227,14 +279,20 @@ function submit() {
|
|
|
ElMessage({ type: "warning", message: "请选择售卖类型", grouping: true });
|
|
|
return;
|
|
|
}
|
|
|
+ if (formData.buildingId == null) {
|
|
|
+ ElMessage({ type: "warning", message: "未正确选择楼号", grouping: true });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let reqData = Object.assign({},formData)
|
|
|
+ delete reqData.ids
|
|
|
if (type.value === "add") {
|
|
|
- request.add(parking, formData).then((res) => {
|
|
|
+ request.add(parking, reqData).then((res) => {
|
|
|
if (res.code === 1) {
|
|
|
showDialog.value = false;
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- request.edit(parking, formData).then((res) => {
|
|
|
+ request.edit(parking, reqData).then((res) => {
|
|
|
if (res.code === 1) {
|
|
|
showDialog.value = false;
|
|
|
}
|