完成访客搭建,完善之前审核界面
This commit is contained in:
@@ -178,14 +178,15 @@
|
||||
import { ref } from 'vue';
|
||||
import PageHeader from '@/components/Pageheader/index.vue';
|
||||
import { HouseRentalVO } from '@/api/system/houseRental/type';
|
||||
import { CascaderValue, UploadFiles, UploadInstance, UploadProps, UploadRawFile, UploadUserFile } from 'element-plus';
|
||||
import { CascaderValue, UploadInstance, UploadProps, UploadUserFile } from 'element-plus';
|
||||
|
||||
import { getCommunitylistAPI } from '@/api/system/community';
|
||||
import { getVillageTree } from '@/api/system/house';
|
||||
import { convertBuildingToTree, getHousePathById, hasFormData, splitStringUrl } from '@/utils/house';
|
||||
import { getHousePathById, hasFormData, splitStringUrl } from '@/utils/house';
|
||||
import { addHouseRental, getHouseRental, updateHouseRental, uploadHouseImage } from '@/api/system/houseRental';
|
||||
import { validator } from '@/utils/Reg';
|
||||
import { useHouseStore } from '@/store/modules/house';
|
||||
|
||||
const houseStore = useHouseStore();
|
||||
const { treedata } = storeToRefs(houseStore);
|
||||
const uploadUrl = import.meta.env.VITE_APP_BASE_API + '/houseRental/uploadImages';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_rental_method } = toRefs<any>(proxy?.useDict('com_rental_method'));
|
||||
@@ -233,32 +234,21 @@ const rules = ref({
|
||||
// ! 编辑租赁-=================================================================================
|
||||
const userid = ref(null);
|
||||
// !== 楼栋房屋 =============================================================================
|
||||
const treedata = ref([]);
|
||||
function gettreedata() {
|
||||
getCommunitylistAPI().then((res) => {
|
||||
const currentviliage = res.rows.find((item) => item.choiceStatus === 0);
|
||||
if (currentviliage.villageId) {
|
||||
getVillageTree(currentviliage.villageId).then((res) => {
|
||||
treedata.value = convertBuildingToTree(res.data.buildings);
|
||||
console.log(treedata.value);
|
||||
// !== 编辑用户 =============================================================================
|
||||
if (route.query.id) {
|
||||
userid.value = route.query.id;
|
||||
getHouseRental(userid.value).then((res) => {
|
||||
console.log(res);
|
||||
form.value = {
|
||||
...form.value,
|
||||
...res.data
|
||||
};
|
||||
const imgurllist = splitStringUrl(form.value.houseImageUrl);
|
||||
fileList.value = imgurllist;
|
||||
const arr = getHousePathById(treedata.value, form.value.houseId);
|
||||
userHousepath.value = arr;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (route.query.id) {
|
||||
userid.value = route.query.id;
|
||||
getHouseRental(userid.value).then((res) => {
|
||||
console.log(res);
|
||||
form.value = {
|
||||
...form.value,
|
||||
...res.data
|
||||
};
|
||||
const imgurllist = splitStringUrl(form.value.houseImageUrl);
|
||||
fileList.value = imgurllist;
|
||||
const arr = getHousePathById(treedata.value, form.value.houseId);
|
||||
userHousepath.value = arr;
|
||||
});
|
||||
}
|
||||
}
|
||||
gettreedata();
|
||||
|
||||
@@ -284,6 +274,7 @@ const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
|
||||
};
|
||||
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
||||
console.log(uploadFile, uploadFiles);
|
||||
fileList.value = uploadFiles;
|
||||
};
|
||||
|
||||
// !== 家电 =============================================================================
|
||||
@@ -321,11 +312,11 @@ const submitForm = () => {
|
||||
if (item.raw && item.raw instanceof File) {
|
||||
formdata.append('files', item.raw);
|
||||
} else {
|
||||
str += item.url;
|
||||
str += item.url + ',';
|
||||
}
|
||||
});
|
||||
console.log(formdata);
|
||||
if (!hasFormData(formdata)) return sendForm();
|
||||
if (!hasFormData(formdata)) return sendForm(str);
|
||||
uploadHouseImage(formdata)
|
||||
.then((res) => {
|
||||
if (res.data.success.length > 0) {
|
||||
@@ -343,7 +334,7 @@ const submitForm = () => {
|
||||
});
|
||||
ElMessage.error('图片:' + str + ' 上传失败!');
|
||||
}
|
||||
sendForm();
|
||||
sendForm(str);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err && err.data && err.data.error.length > 0) {
|
||||
@@ -356,16 +347,16 @@ const submitForm = () => {
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
sendForm();
|
||||
sendForm(str);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const sendForm = () => {
|
||||
const sendForm = (val: string) => {
|
||||
form.value.houseImageUrl = val;
|
||||
// edit or add
|
||||
if (userid.value) {
|
||||
console.log('edit');
|
||||
console.log(form.value);
|
||||
updateHouseRental(form.value).then(() => {
|
||||
ElMessage.success('编辑成功');
|
||||
cancelForm();
|
||||
@@ -422,6 +413,7 @@ const cancelForm = () => {
|
||||
padding: 15px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.AddBuildingBody {
|
||||
margin-top: 20px;
|
||||
|
||||
Reference in New Issue
Block a user