Commit 3be06ee0d6d211738ac63d19df1bf1be01cd6b11
Merge branch 'dev' of http://bj.gitlab.cnlive.com/cnlive_project/cnlive-community-web-vue into dev
Showing
4 changed files
with
163 additions
and
114 deletions
src/api/housekeeper/buildinMganager.ts
| ... | ... | @@ -8,52 +8,19 @@ export function getTableList(params:any) { |
| 8 | 8 | params: params |
| 9 | 9 | }) |
| 10 | 10 | } |
| 11 | -// 根据条件查询列表 | |
| 12 | -export function residentListByCondition(params:any) { | |
| 13 | - return request({ | |
| 14 | - method: 'get', | |
| 15 | - url: '/resident/residentListByCondition', | |
| 16 | - params: params | |
| 17 | - }) | |
| 18 | -} | |
| 19 | - | |
| 20 | -// 房屋信息 | |
| 21 | -export function getHouse(params:any) { | |
| 11 | +// 修改 | |
| 12 | +export function insertOrUpdate(params:any) { | |
| 22 | 13 | return request({ |
| 23 | 14 | method: 'post', |
| 24 | - url: '/house/getHouse', | |
| 25 | - params: params | |
| 26 | - }) | |
| 27 | -} | |
| 28 | -// 删除 | |
| 29 | -export function deleteResident(params:any) { | |
| 30 | - return request({ | |
| 31 | - method: 'delete', | |
| 32 | - url: '/resident/deleteResident', | |
| 33 | - params: params | |
| 15 | + url: '/housekeeper/insertOrUpdate', | |
| 16 | + data: params | |
| 34 | 17 | }) |
| 35 | 18 | } |
| 36 | 19 | // 删除 |
| 37 | -export function changeBinding(params:any) { | |
| 20 | +export function deleteHousekeeper(params:any) { | |
| 38 | 21 | return request({ |
| 39 | 22 | method: 'PUT', |
| 40 | - url: '/resident/changeBinding', | |
| 41 | - params: params | |
| 42 | - }) | |
| 43 | -} | |
| 44 | -// 获取详情 | |
| 45 | -export function getResidentById(params:any) { | |
| 46 | - return request({ | |
| 47 | - method: 'get', | |
| 48 | - url: '/resident/getResidentById', | |
| 23 | + url: '/housekeeper/deleteHousekeeper', | |
| 49 | 24 | params: params |
| 50 | 25 | }) |
| 51 | 26 | } |
| 52 | -// 修改 | |
| 53 | -export function update(params:any) { | |
| 54 | - return request({ | |
| 55 | - method: 'post', | |
| 56 | - url: '/resident/update', | |
| 57 | - data: params | |
| 58 | - }) | |
| 59 | -} | ... | ... |
src/api/request.ts
| ... | ... | @@ -27,23 +27,25 @@ instance.interceptors.request.use( |
| 27 | 27 | instance.interceptors.response.use( |
| 28 | 28 | response => { |
| 29 | 29 | if (response) { |
| 30 | - console.log(response?.data?.errorCode) | |
| 31 | - switch (~~response?.data?.errorCode) { | |
| 32 | - case 0: | |
| 33 | - return response | |
| 34 | - break; | |
| 35 | - case 10002: | |
| 36 | - ElMessage.error(response?.data?.errorMessage || '登录失效'); | |
| 37 | - router.push({ | |
| 38 | - path: 'login' | |
| 39 | - }) | |
| 40 | - break; | |
| 41 | - case 500: | |
| 42 | - ElMessage.error(`${response?.data?.errorMessage},请联系管理员`) | |
| 43 | - Promise.reject(response?.data) | |
| 44 | - break; | |
| 45 | - default: | |
| 46 | - ElMessage.error(response?.data?.errorMessage || '操作失败'); | |
| 30 | + if (response?.data?.errorCode === 0) { | |
| 31 | + return response | |
| 32 | + } else { | |
| 33 | + | |
| 34 | + switch (~~response?.data?.errorCode) { | |
| 35 | + case 10002: | |
| 36 | + ElMessage.error(response?.data?.errorMessage || '登录失效'); | |
| 37 | + router.push({ | |
| 38 | + path: 'login' | |
| 39 | + }) | |
| 40 | + break; | |
| 41 | + case 500: | |
| 42 | + ElMessage.error(`${response?.data?.errorMessage}`) | |
| 43 | + break; | |
| 44 | + default: | |
| 45 | + ElMessage.error(response?.data?.errorMessage || '操作失败'); | |
| 46 | + break | |
| 47 | + } | |
| 48 | + return Promise.reject() | |
| 47 | 49 | } |
| 48 | 50 | } |
| 49 | 51 | }, | ... | ... |
src/views/housekeeper/buildinMganager/detail.vue
| 1 | 1 | <script setup lang="ts"> |
| 2 | -import { reactive, ref, onMounted,getCurrentInstance } from "vue"; | |
| 2 | +import { reactive, ref, getCurrentInstance,defineExpose } from "vue"; | |
| 3 | 3 | import type { ElForm } from "element-plus"; |
| 4 | -import { addOrUpdate } from "@/api/community/residence.ts"; | |
| 4 | +import { insertOrUpdate } from "@/api/housekeeper/buildinMganager.ts"; | |
| 5 | 5 | |
| 6 | 6 | const ruleFormRef = ref<InstanceType<typeof ElForm>>(); |
| 7 | -let instance: ComponentInternalInstance | null = getCurrentInstance();//获取app实例 | |
| 7 | +let instance: ComponentInternalInstance | null = getCurrentInstance(); //获取app实例 | |
| 8 | 8 | // 声明props |
| 9 | 9 | const props = defineProps({ |
| 10 | 10 | formObj: { |
| 11 | 11 | type: Object, |
| 12 | 12 | default: { |
| 13 | 13 | name: null, |
| 14 | - address: null, | |
| 15 | - locality: null, | |
| 16 | - buildingCount: null, | |
| 17 | - storeroomCount: null, | |
| 18 | - truckSpaceCount: null, | |
| 14 | + mobile: null, | |
| 15 | + idcard: null, | |
| 16 | + type: null, | |
| 17 | + gender: null, | |
| 18 | + censusRegister: null, | |
| 19 | + birthdate: null, | |
| 20 | + nationality: null, | |
| 19 | 21 | }, |
| 20 | 22 | }, |
| 21 | 23 | }); |
| 22 | 24 | |
| 23 | 25 | let loading = ref(false); |
| 24 | 26 | |
| 27 | +const data = reactive({ | |
| 28 | + options: [ | |
| 29 | + { label: "选举", value: 0 }, | |
| 30 | + { label: "派驻", value: 1 }, | |
| 31 | + ], | |
| 32 | + genderList: [ | |
| 33 | + { label: "男", value: 1 }, | |
| 34 | + { label: "女", value: 0 }, | |
| 35 | + ], | |
| 36 | +}); | |
| 37 | + | |
| 25 | 38 | // 表单验证 |
| 26 | 39 | const rules = reactive({ |
| 27 | 40 | name: [ |
| 28 | 41 | { |
| 29 | 42 | required: true, |
| 30 | - message: "请输入小区名", | |
| 43 | + message: "请输入姓名", | |
| 31 | 44 | trigger: "blur", |
| 32 | 45 | }, |
| 33 | 46 | ], |
| 34 | - locality: [ | |
| 47 | + mobile: [ | |
| 35 | 48 | { |
| 36 | 49 | required: true, |
| 37 | - message: "请输入所在地区", | |
| 50 | + message: "请输入手机号", | |
| 38 | 51 | trigger: "blur", |
| 39 | 52 | }, |
| 40 | 53 | ], |
| 41 | - address: [ | |
| 54 | + idcard: [ | |
| 42 | 55 | { |
| 43 | 56 | required: true, |
| 44 | - message: "请输入地址", | |
| 57 | + message: "请输入身份证号", | |
| 45 | 58 | trigger: "blur", |
| 46 | 59 | }, |
| 47 | 60 | ], |
| 48 | - buildingCount: [ | |
| 61 | + type: [ | |
| 49 | 62 | { |
| 50 | 63 | required: true, |
| 51 | - message: "请输入楼座数", | |
| 52 | - trigger: "blur", | |
| 64 | + message: "请选择类型", | |
| 65 | + trigger: "change", | |
| 53 | 66 | }, |
| 54 | 67 | ], |
| 55 | - storeroomCount: [ | |
| 68 | + gender: [ | |
| 56 | 69 | { |
| 57 | 70 | required: true, |
| 58 | - message: "请输入储藏室数", | |
| 59 | - trigger: "blur", | |
| 60 | - }, | |
| 61 | - ], | |
| 62 | - truckSpaceCount: [ | |
| 63 | - { | |
| 64 | - required: true, | |
| 65 | - message: "请输入车位数", | |
| 66 | - trigger: "blur", | |
| 71 | + message: "请输入选择性别", | |
| 72 | + trigger: "change", | |
| 67 | 73 | }, |
| 68 | 74 | ], |
| 69 | 75 | }); |
| ... | ... | @@ -82,54 +88,124 @@ let submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => { |
| 82 | 88 | if (!formEl) return; |
| 83 | 89 | formEl.validate((valid) => { |
| 84 | 90 | if (valid) { |
| 85 | - addOrUpdate(props.formObj).then((res) => { | |
| 86 | - loading.value = false; | |
| 87 | - emit("success"); | |
| 91 | + insertOrUpdate(props.formObj).then((res) => { | |
| 92 | + loading.value = false; | |
| 93 | + emit("success"); | |
| 88 | 94 | }); |
| 89 | 95 | } else { |
| 90 | - instance?.proxy?.$message.error('请完善信息')//调用 | |
| 96 | + instance?.proxy?.$message.error("请完善信息"); //调用 | |
| 91 | 97 | loading.value = false; |
| 92 | 98 | return false; |
| 93 | 99 | } |
| 94 | 100 | }); |
| 95 | 101 | }; |
| 96 | - | |
| 102 | +/** | |
| 103 | + * 重置 | |
| 104 | + */ | |
| 105 | +let resetForm = () => { | |
| 106 | + ruleFormRef.value.resetFields(); | |
| 107 | +}; | |
| 97 | 108 | /** |
| 98 | 109 | * 取消提交 |
| 99 | 110 | */ |
| 100 | 111 | const cancel: void = () => { |
| 101 | 112 | emit("cancel"); |
| 102 | 113 | }; |
| 114 | + | |
| 115 | +defineExpose({ | |
| 116 | + resetForm | |
| 117 | +}); | |
| 103 | 118 | </script> |
| 104 | 119 | |
| 105 | 120 | <template> |
| 106 | - <el-form ref="ruleFormRef" :model="props.formObj" :rules="rules" label-width="100px"> | |
| 107 | - <el-form-item label="小区名称:" prop="name"> | |
| 108 | - <el-input v-model="props.formObj.name" placeholder="请输入名称"></el-input> | |
| 121 | + <el-form | |
| 122 | + ref="ruleFormRef" | |
| 123 | + :model="props.formObj" | |
| 124 | + :rules="rules" | |
| 125 | + label-width="100px" | |
| 126 | + :inline="true" | |
| 127 | + > | |
| 128 | + <el-form-item label="姓名:" prop="name"> | |
| 129 | + <el-input | |
| 130 | + v-model="props.formObj.name" | |
| 131 | + placeholder="请输入名称" | |
| 132 | + ></el-input> | |
| 109 | 133 | </el-form-item> |
| 110 | - <el-form-item label="所在地区:" prop="locality"> | |
| 111 | - <el-input v-model="props.formObj.locality" placeholder="请输入所在地区"></el-input> | |
| 134 | + <el-form-item label="手机号:" prop="mobile"> | |
| 135 | + <el-input | |
| 136 | + v-model="props.formObj.mobile" | |
| 137 | + placeholder="请输入所在地区" | |
| 138 | + ></el-input> | |
| 112 | 139 | </el-form-item> |
| 113 | - <el-form-item label="详细地址:" prop="address"> | |
| 114 | - <el-input v-model="props.formObj.address" placeholder="请输入详细地址"></el-input> | |
| 140 | + <el-form-item label="身份证号:" prop="idcard"> | |
| 141 | + <el-input | |
| 142 | + v-model="props.formObj.idcard" | |
| 143 | + placeholder="请输入详细地址" | |
| 144 | + ></el-input> | |
| 115 | 145 | </el-form-item> |
| 116 | - <el-form-item label="楼座数:" prop="buildingCount"> | |
| 117 | - <el-input v-model="props.formObj.buildingCount" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入楼座数"></el-input> | |
| 146 | + <el-form-item label="类型:" prop="type"> | |
| 147 | + <el-select | |
| 148 | + style="width: 200px" | |
| 149 | + v-model="props.formObj.type" | |
| 150 | + placeholder="请选择类型" | |
| 151 | + clearable | |
| 152 | + > | |
| 153 | + <el-option | |
| 154 | + v-for="item in data.options" | |
| 155 | + :key="item.value" | |
| 156 | + :label="item.label" | |
| 157 | + :value="item.value" | |
| 158 | + > | |
| 159 | + </el-option> | |
| 160 | + </el-select> | |
| 118 | 161 | </el-form-item> |
| 119 | - <el-form-item label="储藏室数:" prop="storeroomCount"> | |
| 120 | - <el-input v-model="props.formObj.storeroomCount" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入储藏室数"></el-input> | |
| 162 | + | |
| 163 | + <el-form-item label="性别:" prop="gender"> | |
| 164 | + <el-select | |
| 165 | + v-model="props.formObj.gender" | |
| 166 | + placeholder="请选择" | |
| 167 | + style="width: 200px" | |
| 168 | + > | |
| 169 | + <el-option | |
| 170 | + v-for="item in data.genderList" | |
| 171 | + :key="item.value" | |
| 172 | + :label="item.label" | |
| 173 | + :value="item.value" | |
| 174 | + > | |
| 175 | + </el-option> | |
| 176 | + </el-select> | |
| 121 | 177 | </el-form-item> |
| 122 | - <el-form-item label="车位数:" prop="truckSpaceCount"> | |
| 123 | - <el-input v-model="props.formObj.truckSpaceCount" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入车位数"></el-input> | |
| 178 | + <el-form-item label="户籍所在地:" prop="censusRegister"> | |
| 179 | + <el-input | |
| 180 | + v-model="props.formObj.censusRegister" | |
| 181 | + placeholder="请输入车位数" | |
| 182 | + ></el-input> | |
| 124 | 183 | </el-form-item> |
| 125 | - <el-form-item> | |
| 126 | - <el-button | |
| 127 | - type="primary" | |
| 128 | - @click="submitForm(ruleFormRef)" | |
| 129 | - :loading="loading" | |
| 130 | - >保存</el-button | |
| 184 | + <el-form-item label="出生日期:" prop="birthdate"> | |
| 185 | + <el-date-picker | |
| 186 | + style="width: 200px" | |
| 187 | + v-model="props.formObj.birthdate" | |
| 188 | + type="date" | |
| 189 | + placeholder="选择时间" | |
| 131 | 190 | > |
| 132 | - <el-button @click="cancel">取消</el-button> | |
| 191 | + </el-date-picker> | |
| 192 | + </el-form-item> | |
| 193 | + <el-form-item label="民族:" prop="nationality"> | |
| 194 | + <el-input | |
| 195 | + v-model="props.formObj.nationality" | |
| 196 | + placeholder="请输入车位数" | |
| 197 | + ></el-input> | |
| 133 | 198 | </el-form-item> |
| 199 | + <el-row> | |
| 200 | + <el-form-item> | |
| 201 | + <el-button | |
| 202 | + type="primary" | |
| 203 | + @click="submitForm(ruleFormRef)" | |
| 204 | + :loading="loading" | |
| 205 | + >保存</el-button | |
| 206 | + > | |
| 207 | + <el-button @click="cancel">取消</el-button> | |
| 208 | + </el-form-item> | |
| 209 | + </el-row> | |
| 134 | 210 | </el-form> |
| 135 | 211 | </template> | ... | ... |
src/views/housekeeper/buildinMganager/index.vue
| 1 | 1 | <script setup lang="ts"> |
| 2 | -import { reactive, onMounted, getCurrentInstance } from "vue"; | |
| 3 | -import { getTableList } from "@/api/housekeeper/buildinMganager.ts"; | |
| 2 | +import { reactive, onMounted,ref, getCurrentInstance } from "vue"; | |
| 3 | +import { getTableList,deleteHousekeeper } from "@/api/housekeeper/buildinMganager.ts"; | |
| 4 | 4 | import Detail from "./detail.vue"; |
| 5 | 5 | import Pagination from "@/components/Pagination/index.vue"; |
| 6 | 6 | |
| 7 | 7 | let instance: ComponentInternalInstance | null = getCurrentInstance(); //获取app实例 |
| 8 | + | |
| 9 | +const detailRef = ref(null); | |
| 8 | 10 | // 数据筛选 |
| 9 | 11 | const searchData = reactive({ |
| 10 | 12 | type: "", |
| ... | ... | @@ -33,6 +35,7 @@ const search = (): void => { |
| 33 | 35 | data.loading = true; |
| 34 | 36 | getTableList(searchData) |
| 35 | 37 | .then((res) => { |
| 38 | + console.log(res) | |
| 36 | 39 | data.tableList = res.data.data; |
| 37 | 40 | data.total = res.data.data.total; |
| 38 | 41 | data.loading = false; |
| ... | ... | @@ -53,16 +56,16 @@ const edit = (row: Object) => { |
| 53 | 56 | }; |
| 54 | 57 | /** |
| 55 | 58 | * 删除 |
| 56 | - * @param { number } neighborhoodId 小区ID | |
| 59 | + * @param { number } housekeeperId 唯一标识 | |
| 57 | 60 | */ |
| 58 | -const remove = (neighborhoodId: number) => { | |
| 61 | +const remove = (housekeeperId: number) => { | |
| 59 | 62 | instance?.proxy?.$messageBox |
| 60 | 63 | .confirm("确认要进行此操作?", "提示", { |
| 61 | 64 | confirmButtonText: "确定", |
| 62 | 65 | cancelButtonText: "取消", |
| 63 | 66 | }) |
| 64 | 67 | .then(() => { |
| 65 | - deleteNeighborhood({ neighborhoodId: neighborhoodId }).then((res) => { | |
| 68 | + deleteHousekeeper({ housekeeperId: housekeeperId }).then((res) => { | |
| 66 | 69 | instance?.proxy?.$message.success("操作成功"); //调用 |
| 67 | 70 | search(); |
| 68 | 71 | }); |
| ... | ... | @@ -81,8 +84,9 @@ const changeData: void = () => { |
| 81 | 84 | * 弹框关闭 |
| 82 | 85 | */ |
| 83 | 86 | const dialogClose: void = () => { |
| 84 | - data.title = "新增小区"; | |
| 87 | + data.title = "新增楼管"; | |
| 85 | 88 | data.formObj = {}; |
| 89 | + detailRef.value.resetForm(); | |
| 86 | 90 | }; |
| 87 | 91 | onMounted(() => { |
| 88 | 92 | search(); |
| ... | ... | @@ -161,10 +165,10 @@ onMounted(() => { |
| 161 | 165 | <el-dialog |
| 162 | 166 | v-model="data.dialogVisible" |
| 163 | 167 | :title="data.title" |
| 164 | - width="30%" | |
| 165 | 168 | @close="dialogClose" |
| 166 | 169 | > |
| 167 | 170 | <Detail |
| 171 | + ref="detailRef" | |
| 168 | 172 | @cancel="data.dialogVisible = false" |
| 169 | 173 | @success="changeData" |
| 170 | 174 | :formObj="data.formObj" | ... | ... |