wangyx 3 months ago
parent
commit
272066fc93
  1. 7
      src/api/system/dept.js
  2. 4
      src/layout/components/Navbar.vue
  3. 13
      src/utils/ruoyi.js
  4. 11
      src/views/mz/building/index.vue
  5. 88
      src/views/mz/house/index.vue
  6. 12
      src/views/records/checkin/index.vue
  7. 15
      src/views/residence/checkIn/index.vue

7
src/api/system/dept.js

@ -49,4 +49,11 @@ export function delDept(deptId) {
url: '/system/dept/' + deptId,
method: 'delete'
})
}
// 房屋专属左侧组织树
export function getdeptList() {
return request({
url: '/mz/building/getdeptList',
method: 'get'
})
}

4
src/layout/components/Navbar.vue

@ -88,7 +88,9 @@ export default {
type: 'warning'
}).then(() => {
this.$store.dispatch('LogOut').then(() => {
location.href = '/index';
this.$router.replace({
path: "/login"
});
})
}).catch(() => {});
}

13
src/utils/ruoyi.js

@ -157,7 +157,7 @@ export function mergeRecursive(source, target) {
* @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children'
*/
export function handleTree(data, id, parentId, children) {
export function handleTree(data, id, parentId, children, maxLevel) {
let config = {
id: id || 'id',
parentId: parentId || 'parentId',
@ -185,16 +185,21 @@ export function handleTree(data, id, parentId, children) {
}
for (let t of tree) {
adaptToChildrenList(t);
adaptToChildrenList(t, 1);
}
function adaptToChildrenList(o) {
function adaptToChildrenList(o, level) {
if (childrenListMap[o[config.id]] !== null) {
if (maxLevel && level >= maxLevel) {
// 当达到最大层级时,清除子节点数据
o[config.childrenList] = [];
return;
}
o[config.childrenList] = childrenListMap[o[config.id]];
}
if (o[config.childrenList]) {
for (let c of o[config.childrenList]) {
adaptToChildrenList(c);
adaptToChildrenList(c, level + 1);
}
}
}

11
src/views/mz/building/index.vue

@ -50,7 +50,13 @@
</div>
</template>
</el-table-column>
<el-table-column label="楼栋名称" align="center" prop="buildingName" />
<el-table-column label="楼栋名称" align="center" prop="buildingName">
<template slot-scope="scope">
<a style="color:#409eff" @click="toHouse(scope.row)">
{{ scope.row.buildingName }}
</a>
</template>
</el-table-column>
<el-table-column label="楼层数" align="center" prop="floorCount" />
<el-table-column label="房屋数" align="center" prop="houseCount" />
<el-table-column label="房间数" align="center" prop="roomCount" />
@ -200,6 +206,9 @@ export default {
this.getApartmentList();
},
methods: {
toHouse(row) {
this.$router.push({ path: "/mz/house", query: { deptId: row.id } });
},
/** 转换组织数据结构 */
handleNodeClick(node, data) {
this.queryParams.apartmentId = node.deptId;

88
src/views/mz/house/index.vue

@ -2,7 +2,9 @@
<div class="app-container">
<div class="flex w-full h-full">
<div class="tree mr-10 card">
<el-tree :data="treeList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
<el-tree :data="treeList" :props="defaultProps" @node-click="handleNodeClick" :default-expanded-keys="expandedKeys" :default-checked-keys="checkedKeys" :auto-expand-parent="true"
:expand-on-click-node="false" :highlight-current="true" ref="tree" node-key="deptId"
:accordion="true"></el-tree>
</div>
<div class="card flex-1" style="width: calc(100% - 170px)">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
@ -122,13 +124,7 @@
</el-form-item>
</el-col>
</el-row>
<el-row v-if="form.hire === '2'">
<el-col :span="12">
<el-form-item label="最大可租住天数" prop="days" >
<el-input-number v-model="form.days" :min="0" placeholder="请输入建筑面积" style="width: 200px;" :disabled="disabled"/>
</el-form-item>
</el-col>
</el-row>
<el-row type="flex" style="margin-bottom:10px">
<el-col :span="12">
<el-col :span="6" type="flex" style="text-align:right;margin-right:15px;height: 100%;align-items: center;display: flex;justify-content: end;">
@ -240,7 +236,6 @@ export default {
remark: null,
floor: 0,
hire:'1',
days:null,
},
//
rules: {
@ -265,9 +260,7 @@ export default {
hire: [
{ required: true, message: '请选择长租房/短租房', trigger: 'change' }
],
days: [
{ validator: validateDays, trigger: 'blur' }
],
},
deptList: [],
defaultProps: {
@ -280,7 +273,10 @@ export default {
buildingOption: [],
unitOptions: [],
disabled:false,
treeList:[]
treeList:[],
expandedKeys: [],// key
checkedKeys: [],// key
showTree: true,
};
},
components: {
@ -378,7 +374,6 @@ export default {
remark: null,
floor: 0,
hire:'1',
days:null,
};
this.resetForm("form");
},
@ -493,9 +488,70 @@ export default {
this.form.unitId = '';
this.unitOptions = [];
await this.getUnitbyBuddingId(this.form.buildingId)
}
},
//
handleExpandTree(apartmentId) {
if (!apartmentId) return;
const targetId = Number(apartmentId);
const findParents = (node, targetId, parents = []) => {
if (Number(node.deptId) === targetId) {
return [...parents, node.deptId];
}
if (node.children) {
for (let child of node.children) {
const result = findParents(child, targetId, [...parents, node.deptId]);
if (result) return result;
}
}
return null;
};
let path = null;
for (let node of this.treeList) {
path = findParents(node, targetId);
if (path) break;
}
if (path) {
// :accordion="true"
this.expandedKeys = path;
this.checkedKeys = [path[path.length - 1]];
} else {
console.warn('未找到匹配的节点路径');
}
},
},
watch:{}
watch:{
$route: {
handler: function (newVal, oldVal) {
if (newVal.query) {
this.queryParams = {
...this.queryParams,
...newVal.query,
};
this.treeList = [];
this.showTree = false;
this.$nextTick(() => {
// el-tree
this.showTree = true;
this.getList();
// deptList
if (this.treeList.length === 0) {
this.getDeptList().then(() => {
this.handleExpandTree(newVal.query.deptId);
});
} else {
this.handleExpandTree(newVal.query.deptId);
}
});
} else {
this.getDeptList()
}
},
immediate: true,
deep: true,
},
}
};
</script>
<style lang="scss" scoped>

12
src/views/records/checkin/index.vue

@ -726,17 +726,7 @@ export default {
deptName(val) {
this.$refs.tree.filter(val);
},
$route:{
handler: function (newVal, oldVal) {
console.log(newVal);
if (newVal.query) {
this.queryParams.idCard = newVal.query.idCard;
this.handleQuery()
}
},
immediate: true,
deep: true,
}
},
created() {
this.getList();

15
src/views/residence/checkIn/index.vue

@ -423,6 +423,21 @@ export default {
mounted() {
//
},
watch: {
//
$route:{
handler: function (newVal, oldVal) {
if (newVal.query) {
this.$nextTick(()=>{
this.checnInForm.idCard = newVal.query.idCard;
this.handleQuery()
})
}
},
immediate: true,
deep: true,
}
}
};
</script>

Loading…
Cancel
Save