5636b7b0 by 杨威

封装请求字典数据方法

1 parent 92b7581b
...@@ -5,31 +5,14 @@ ...@@ -5,31 +5,14 @@
5 </template> 5 </template>
6 6
7 <script> 7 <script>
8 import { getDdicByMC } from "../src/api/common";
9 export default { 8 export default {
10 mounted() { 9 mounted() {
11 this.getDic();
12 window.addEventListener("unload", this.saveState); 10 window.addEventListener("unload", this.saveState);
13 }, 11 },
14 methods: { 12 methods: {
15 saveState() { 13 saveState() {
16 sessionStorage.setItem("state", JSON.stringify(this.$store.state)); 14 sessionStorage.setItem("state", JSON.stringify(this.$store.state));
17 }, 15 },
18 //请求字典数据
19 getDic() {
20 let s = this.$store.state;
21 s.zjzlList = s.zjzlList.length == 0 ? this.getDicData("证件种类") : s.zjzlList;
22 s.gjList = s.gjList.length == 0 ? this.getDicData("国家和地区") : s.gjList;
23 s.ssList = s.ssList.length == 0 ? this.getDicData("省市") : s.ssList;
24 s.qlrlxList = s.qlrlxList.length == 0 ? this.getDicData("权利人类型") : s.qlrlxList;
25 s.xbList = s.xbList.length == 0 ? this.getDicData("性别") : s.xbList;
26 s.sshyList = s.sshyList.length == 0 ? this.getDicData("国民经济行业分类代码") : s.sshyList;
27 },
28 getDicData(name) {
29 getDdicByMC(name).then((res) => {
30 return res.result;
31 });
32 },
33 }, 16 },
34 }; 17 };
35 </script> 18 </script>
......
...@@ -10,15 +10,15 @@ Vue.use(Vuex) ...@@ -10,15 +10,15 @@ Vue.use(Vuex)
10 const store = new Vuex.Store({ 10 const store = new Vuex.Store({
11 state: sessionStorage.getItem('state') ? JSON.parse(sessionStorage.getItem('state')) : { 11 state: sessionStorage.getItem('state') ? JSON.parse(sessionStorage.getItem('state')) : {
12 zdbsm: '', 12 zdbsm: '',
13 xzqList: [],
14 djqList: [],
15 djzqList: [],
16 zjzlList:[], 13 zjzlList:[],
17 gjList:[], 14 gjList:[],
18 ssList:[], 15 ssList:[],
19 qlrlxList:[], 16 qlrlxList:[],
20 xbList:[], 17 xbList:[],
21 sshyList:[], 18 sshyList:[],
19 xzqList: [],
20 djqList: [],
21 djzqList: [],
22 //创建自然幢时需要用到的临时存储信息 22 //创建自然幢时需要用到的临时存储信息
23 zrzbsm: '', 23 zrzbsm: '',
24 xmmc: '', 24 xmmc: '',
......
1 <template> 1 <template>
2 <div class="home-box"> 2 <div class="home-box">
3 <el-container> 3 <el-container>
4 <el-aside :class="{ 'aside-show': isActive }"> 4 <el-aside :class="{ 'aside-show': isActive }">
5 <div class="logo-box" :class="{ 'logo-box-show': isActive }"> 5 <div class="logo-box" :class="{ 'logo-box-show': isActive }">
6 <img 6 <img
7 class="logo-img" 7 class="logo-img"
8 src="@/assets/images/logo-realestate.png" 8 src="@/assets/images/logo-realestate.png"
9 alt="" 9 alt=""
10 /> 10 />
11 <span class="logo-text" v-show="!textLogo">不动产权籍调查系统</span> 11 <span class="logo-text" v-show="!textLogo">不动产权籍调查系统</span>
12 </div> 12 </div>
13 <div class="treeModule"> 13 <div class="treeModule">
14 <LineTree :pd="pd" @itemClick="itemClick"></LineTree> 14 <LineTree :pd="pd" @itemClick="itemClick"></LineTree>
15 </div> 15 </div>
16 </el-aside> 16 </el-aside>
17 <el-container> 17 <el-container>
18 <el-header height="100px"> 18 <el-header height="100px">
19 <div class="header-top"> 19 <div class="header-top">
20 <div class="top-items" @click="toggleClick"> 20 <div class="top-items" @click="toggleClick">
21 <i class="fa fa-outdent hamburger" v-show="!isActive"></i> 21 <i class="fa fa-outdent hamburger" v-show="!isActive"></i>
22 <i class="fa fa-indent hamburger" v-show="isActive"></i> 22 <i class="fa fa-indent hamburger" v-show="isActive"></i>
23 </div> 23 </div>
24 <div 24 <div
25 class="top-items" 25 class="top-items"
26 v-for="(item, index) in headTop" 26 v-for="(item, index) in headTop"
27 :key="index + '1'" 27 :key="index + '1'"
28 :class="{ 'is-active': item.select }" 28 :class="{ 'is-active': item.select }"
29 @click="selectTopItems(index)" 29 @click="selectTopItems(index)"
30 > 30 >
31 <i :class="item.icon"></i> 31 <i :class="item.icon"></i>
32 <span>{{ item.name }}</span> 32 <span>{{ item.name }}</span>
33 </div> 33 </div>
34 </div> 34 </div>
35 <div class="header-bottom"> 35 <div class="header-bottom">
36 <Navigation ref="navigation"></Navigation> 36 <Navigation ref="navigation"></Navigation>
37 </div> 37 </div>
38 <el-dialog 38 <el-dialog title="新建" :visible.sync="dialogVisible" width="40%">
39 title="新建" 39 <Create @closeDialog="closeDialog"></Create>
40 :visible.sync="dialogVisible" 40 </el-dialog>
41 width="40%" 41 </el-header>
42 > 42 <el-main>
43 <Create @closeDialog="closeDialog"></Create> 43 <router-view />
44 </el-dialog> 44 </el-main>
45 </el-header> 45 </el-container>
46 <el-main> 46 </el-container>
47 <router-view/> 47 </div>
48 </el-main>
49 </el-container>
50 </el-container>
51 </div>
52 </template> 48 </template>
53 <script> 49 <script>
54 import util from "@/libs/util.js"; 50 import util from "@/libs/util.js";
55 import Navigation from "../components/IvyElement/navigation"; 51 import Navigation from "../components/IvyElement/navigation";
56 import Create from "./panel/create/index"; 52 import Create from "./panel/create/index";
57 import LineTree from "../components/lineTree/lineTree"; 53 import LineTree from "../components/lineTree/lineTree";
58 import {setTimeout} from "timers"; 54 import { setTimeout } from "timers";
59 import {getTree} from "../api/common" 55 import { getTree,getDdicByMC } from "../api/common";
60 56
61 export default { 57 export default {
62 components: { 58 components: {
63 Navigation, 59 Navigation,
64 LineTree, 60 LineTree,
65 Create, 61 Create,
62 },
63 data() {
64 return {
65 navigationList: [],
66 isActive: false,
67 textLogo: false,
68 activePath: "",
69 defaultActive: "",
70 headTop: [
71 {
72 path: "/create",
73 select: false,
74 },
75 {
76 path: "/add",
77 select: false,
78 },
79 {
80 path: "/modify",
81 select: false,
82 },
83 {
84 path: "/change",
85 select: false,
86 },
87 {
88 path: "/search",
89 select: false,
90 },
91 ],
92 tempTab: [
93 {
94 path: "/zrz",
95 name: "自然幢",
96 },
97 {
98 path: "/dz",
99 name: "多幢",
100 },
101 {
102 path: "/h",
103 name: "户",
104 },
105 {
106 path: "/zd",
107 name: "宗地",
108 },
109 ],
110 // 上导航选中id
111 indId: undefined,
112 menuList: [],
113 pathAndCodeObj: {
114 "/article-draft": "PSH004",
115 "/article-publish": "PSH005",
116 "/article-recycle": "PSH006",
117 "/notice-draft": "PSH007",
118 "/notice-publish": "PSH008",
119 "/notice-recycle": "PSH009",
120 "/column_management": "PSH018",
121 "/announcement_template": "PSH019",
122 "/business_management": "PSH020",
123 },
124 pd: [
125 {
126 mc: "行政区(1)",
127 children: [],
128 },
129 {
130 mc: "行政区(2)",
131 children: [
132 {
133 mc: "地籍区1",
134 children: [],
135 },
136 {
137 mc: "地籍区2",
138 children: [
139 {
140 mc: "国有",
141 children: [
142 {
143 mc: "宗地代码1933",
144 isZD: true,
145 },
146 {
147 mc: "自然幢2100",
148 isZD: false,
149 },
150 ],
151 },
152 ],
153 },
154 {
155 label: "地籍区3",
156 children: [],
157 },
158 {
159 label: "地籍区4",
160 children: [],
161 },
162 ],
163 },
164 {
165 mc: "行政区(3)",
166 children: [],
167 },
168 {
169 mc: "行政区(4)",
170 children: [],
171 },
172 {
173 mc: "行政区(5)",
174 children: [],
175 },
176 ],
177 dialogVisible: false,
178 };
179 },
180 computed: {
181 permission_routes() {
182 return this.$store.state.permission_routes.navigation;
183 },
184 },
185 watch: {
186 "$route.path": function(newPath) {
187 //监测路由变化,高亮顶部导航
188 this.headTop.forEach((item, index) => {
189 item.select = false;
190 if (item.path == newPath) {
191 item.select = true;
192 }
193 });
194 if (newPath == "/zd") {
195 this.getRightTree(this.$store.state.zdbsm);
196 }
197 },
198 "$store.state.zdbsm": function(bsm) {
199 this.getRightTree(bsm);
200 },
201 },
202 created() {
203 if (this.$route.meta) {
204 this.defaultActive = this.$route.meta.code;
205 }
206 if (this.permission_routes.length !== 0) {
207 this.navigationList = this.permission_routes;
208 } else {
209 // let list = JSON.parse(util.cookies.get('navigation-1')).concat(JSON.parse(util.cookies.get('navigation')))
210 //mock数据
211 let list = [
212 {
213 name: "新建",
214 icon: "fa fa-address-card-o",
215 path: "/create",
216 },
217 {
218 name: "添加",
219 icon: "fa fa-address-card-o",
220 path: "/add",
221 },
222 { name: "更正", icon: "fa fa-address-card-o", path: "/modify" },
223 {
224 name: "变更",
225 icon: "fa fa-address-card-o",
226 path: "/change",
227 },
228 {
229 name: "综合查询",
230 icon: "fa fa-address-card-o",
231 path: "/search",
232 },
233 ];
234 this.navigationList = list;
235 }
236 this.sortNavigation(this.navigationList, 0);
237 // if (util.cookies.get("indId")) {
238 // let indId = util.cookies.get("indId") - 0;
239 // this.navSelect(indId);
240 // this.sortNavigation(this.navigationList, indId);
241 // }
242 this.getDic();
243 },
244 methods: {
245 //请求字典数据
246 async getDic() {
247 let s = this.$store.state;
248 s.zjzlList = s.zjzlList.length == 0 ?await this.getDicData("证件种类") : s.zjzlList;
249 s.gjList = s.gjList.length == 0 ?await this.getDicData("国家和地区") : s.gjList;
250 s.ssList = s.ssList.length == 0 ?await this.getDicData("省市") : s.ssList;
251 s.qlrlxList = s.qlrlxList.length == 0 ?await this.getDicData("权利人类型") : s.qlrlxList;
252 s.xbList = s.xbList.length == 0 ? await this.getDicData("性别") : s.xbList;
253 s.sshyList = s.sshyList.length == 0 ?await this.getDicData("国民经济行业分类代码") : s.sshyList;
254 },
255 async getDicData(name) {
256 return await getDdicByMC(name).then((res)=> {
257 return res.result
258 });
66 }, 259 },
67 data() { 260 getRightTree(bsm) {
68 return { 261 getTree(bsm).then((res) => {
69 navigationList: [], 262 if (res.success) {
70 isActive: false, 263 this.pd = res.result;
71 textLogo: false, 264 }
72 activePath: "", 265 });
73 defaultActive: "", 266 },
74 headTop: [ 267 sortNavigation(data, selectId) {
75 { 268 let headTop = this.headTop;
76 path: "/create", 269 data.forEach((item, index) => {
77 select: false, 270 headTop[index].name = item.name;
78 }, 271 headTop[index].icon = item.icon;
79 { 272 });
80 path: "/add", 273 },
81 select: false, 274 // menuSelect(data, selectId) {
82 }, 275 // this.menuList = data[selectId].children;
83 { 276 // },
84 path: "/modify", 277 handleOpen(key, keyPath) {
85 select: false, 278 console.log(key, keyPath);
86 }, 279 },
87 { 280 handleClose(key, keyPath) {
88 path: "/change", 281 console.log(key, keyPath);
89 select: false, 282 },
90 }, 283 toggleClick() {
91 { 284 this.isActive = !this.isActive;
92 path: "/search", 285 if (!this.isActive) {
93 select: false, 286 setTimeout(() => {
94 }, 287 this.textLogo = this.isActive;
95 ], 288 }, 200);
96 tempTab: [ 289 } else {
97 { 290 this.textLogo = this.isActive;
98 path: "/zrz", 291 }
99 name: "自然幢", 292 },
100 }, 293 selectTopItems(ind) {
101 { 294 if (ind == 0) {
102 path: "/dz", 295 //点击新建,弹框
103 name: "多幢", 296 this.dialogVisible = true;
104 }, 297 } else {
105 { 298 this.dialogVisible = false;
106 path: "/h", 299 this.indId = ind;
107 name: "户", 300 // this.menuSelect(this.navigationList, ind);
108 }, 301 // this.$store.dispatch("setTabs/init_tabs");
109 { 302 // this.$store.dispatch("setTabs/set_active_index", "/panel");
110 path: "/zd", 303 this.$router.push(this.headTop[ind].path);
111 name: "宗地", 304 this.navSelect(ind);
112 }, 305 // util.cookies.set("indId", ind);
113 ], 306 }
114 // 上导航选中id 307 },
115 indId: undefined, 308 // 上导航选中id
116 menuList: [], 309 navSelect(id) {
117 pathAndCodeObj: { 310 this.headTop.forEach((item, index) => {
118 "/article-draft": "PSH004", 311 item.select = false;
119 "/article-publish": "PSH005", 312 if (index == id) {
120 "/article-recycle": "PSH006", 313 item.select = true;
121 "/notice-draft": "PSH007", 314 }
122 "/notice-publish": "PSH008", 315 });
123 "/notice-recycle": "PSH009", 316 },
124 "/column_management": "PSH018", 317 //树控件点击事件
125 "/announcement_template": "PSH019", 318 itemClick(data) {
126 "/business_management": "PSH020", 319 console.log(data);
127 }, 320 },
128 pd: [ 321 //关闭新建子组件弹框
129 { 322 closeDialog() {
130 mc: "行政区(1)", 323 this.dialogVisible = false;
131 children: [], 324 },
132 }, 325 },
133 { 326 };
134 mc: "行政区(2)",
135 children: [
136 {
137 mc: "地籍区1",
138 children: [],
139 },
140 {
141 mc: "地籍区2",
142 children: [
143 {
144 mc: "国有",
145 children: [
146 {
147 mc: "宗地代码1933",
148 isZD: true,
149 },
150 {
151 mc: "自然幢2100",
152 isZD: false,
153 },
154 ],
155 },
156 ],
157 },
158 {
159 label: "地籍区3",
160 children: [],
161 },
162 {
163 label: "地籍区4",
164 children: [],
165 },
166 ],
167 },
168 {
169 mc: "行政区(3)",
170 children: [],
171 },
172 {
173 mc: "行政区(4)",
174 children: [],
175 },
176 {
177 mc: "行政区(5)",
178 children: [],
179 },
180 ],
181 dialogVisible: false,
182 };
183 },
184 computed: {
185 permission_routes() {
186 return this.$store.state.permission_routes.navigation;
187 },
188 },
189 watch: {
190 "$route.path": function (newPath) {
191 //监测路由变化,高亮顶部导航
192 this.headTop.forEach((item, index) => {
193 item.select = false;
194 if (item.path == newPath) {
195 item.select = true;
196 }
197 });
198 if(newPath == '/zd'){
199 this.getRightTree(this.$store.state.zdbsm)
200 }
201 },
202 "$store.state.zdbsm": function (bsm) {
203 this.getRightTree(bsm)
204 }
205 },
206 created() {
207 if (this.$route.meta) {
208 this.defaultActive = this.$route.meta.code;
209 }
210 if (this.permission_routes.length !== 0) {
211 this.navigationList = this.permission_routes;
212 } else {
213 // let list = JSON.parse(util.cookies.get('navigation-1')).concat(JSON.parse(util.cookies.get('navigation')))
214 //mock数据
215 let list = [
216 {
217 name: "新建",
218 icon: "fa fa-address-card-o",
219 path: "/create",
220 },
221 {
222 name: "添加",
223 icon: "fa fa-address-card-o",
224 path: "/add",
225 },
226 {name: "更正", icon: "fa fa-address-card-o", path: "/modify"},
227 {
228 name: "变更",
229 icon: "fa fa-address-card-o",
230 path: "/change",
231 },
232 {
233 name: "综合查询",
234 icon: "fa fa-address-card-o",
235 path: "/search",
236 },
237 ];
238 this.navigationList = list;
239 }
240 this.sortNavigation(this.navigationList, 0);
241 // if (util.cookies.get("indId")) {
242 // let indId = util.cookies.get("indId") - 0;
243 // this.navSelect(indId);
244 // this.sortNavigation(this.navigationList, indId);
245 // }
246 },
247 methods: {
248 getRightTree(bsm) {
249 getTree(bsm).then(res => {
250 if (res.success) {
251 this.pd=res.result
252 }
253 })
254 },
255 sortNavigation(data, selectId) {
256 let headTop = this.headTop;
257 data.forEach((item, index) => {
258 headTop[index].name = item.name;
259 headTop[index].icon = item.icon;
260 });
261 },
262 // menuSelect(data, selectId) {
263 // this.menuList = data[selectId].children;
264 // },
265 handleOpen(key, keyPath) {
266 console.log(key, keyPath);
267 },
268 handleClose(key, keyPath) {
269 console.log(key, keyPath);
270 },
271 toggleClick() {
272 this.isActive = !this.isActive;
273 if (!this.isActive) {
274 setTimeout(() => {
275 this.textLogo = this.isActive;
276 }, 200);
277 } else {
278 this.textLogo = this.isActive;
279 }
280 },
281 selectTopItems(ind) {
282 if (ind == 0) {
283 //点击新建,弹框
284 this.dialogVisible = true;
285 } else {
286 this.dialogVisible = false;
287 this.indId = ind;
288 // this.menuSelect(this.navigationList, ind);
289 // this.$store.dispatch("setTabs/init_tabs");
290 // this.$store.dispatch("setTabs/set_active_index", "/panel");
291 this.$router.push(this.headTop[ind].path);
292 this.navSelect(ind);
293 // util.cookies.set("indId", ind);
294 }
295 },
296 // 上导航选中id
297 navSelect(id) {
298 this.headTop.forEach((item, index) => {
299 item.select = false;
300 if (index == id) {
301 item.select = true;
302 }
303 });
304 },
305 //树控件点击事件
306 itemClick(data) {
307 console.log(data);
308 },
309 //关闭新建子组件弹框
310 closeDialog() {
311 this.dialogVisible = false;
312 }
313 },
314 };
315 </script> 327 </script>
316 <style lang="less" scoped> 328 <style lang="less" scoped>
317 .home-box { 329 .home-box {
318 width: 100%; 330 width: 100%;
319 height: 100vh; 331 height: 100vh;
320 .el-container { 332 .el-container {
321 height: 100%; 333 height: 100%;
322 } 334 }
323 .el-header { 335 .el-header {
324 background-color: #fff; 336 background-color: #fff;
325 padding: 0 !important; 337 padding: 0 !important;
326 .header-top { 338 .header-top {
327 height: 60px; 339 height: 60px;
328 border-bottom: 1px solid rgba(242, 242, 242, 1); 340 border-bottom: 1px solid rgba(242, 242, 242, 1);
329 box-sizing: border-box; 341 box-sizing: border-box;
330 .top-items { 342 .top-items {
331 cursor: pointer; 343 cursor: pointer;
332 height: 60px; 344 height: 60px;
333 padding: 0 30px; 345 padding: 0 30px;
334 font-size: 16px; 346 font-size: 16px;
335 line-height: 60px; 347 line-height: 60px;
336 float: left; 348 float: left;
337 position: relative; 349 position: relative;
338 color: #4a4a4a; 350 color: #4a4a4a;
339 i { 351 i {
340 margin-right: 6px; 352 margin-right: 6px;
341 } 353 }
342 .hamburger { 354 .hamburger {
343 font-size: 16px; 355 font-size: 16px;
344 line-height: 60px; 356 line-height: 60px;
345 color: #000; 357 color: #000;
346 } 358 }
347 } 359 }
348 .top-items:not(:last-child)::after { 360 .top-items:not(:last-child)::after {
349 content: ""; 361 content: "";
350 width: 1px; 362 width: 1px;
351 height: 14px; 363 height: 14px;
352 background: #eaeaea; 364 background: #eaeaea;
353 position: absolute; 365 position: absolute;
354 right: -1px; 366 right: -1px;
355 top: 24px; 367 top: 24px;
356 } 368 }
357 .top-items.is-active { 369 .top-items.is-active {
358 color: #006cff; 370 color: #006cff;
359 } 371 }
360 } 372 }
361 .header-bottom { 373 .header-bottom {
362 height: 50px; 374 height: 50px;
363 box-shadow: 0px 2px 4px 0px rgba(222, 222, 222, 0.7); 375 box-shadow: 0px 2px 4px 0px rgba(222, 222, 222, 0.7);
364 border-bottom: 1px solid rgba(234, 234, 234, 1); 376 border-bottom: 1px solid rgba(234, 234, 234, 1);
365 box-sizing: border-box; 377 box-sizing: border-box;
366 } 378 }
367 } 379 }
368 .el-aside { 380 .el-aside {
369 width: 290px !important; 381 width: 290px !important;
370 background-color: #1d50dd; 382 background-color: #1d50dd;
371 color: #333; 383 color: #333;
372 // text-align: center; 384 // text-align: center;
373 overflow: hidden; 385 overflow: hidden;
374 transition: width 0.3s; 386 transition: width 0.3s;
375 .logo-box { 387 .logo-box {
376 width: 100%; 388 width: 100%;
377 height: 120px; 389 height: 120px;
378 border-bottom: 1px solid rgba(255, 255, 255, 0.2); 390 border-bottom: 1px solid rgba(255, 255, 255, 0.2);
379 padding: 30px 0 28px 0; 391 padding: 30px 0 28px 0;
380 box-sizing: border-box; 392 box-sizing: border-box;
381 display: flex; 393 display: flex;
382 flex-direction: column; 394 flex-direction: column;
383 justify-content: space-between; 395 justify-content: space-between;
384 align-items: center; 396 align-items: center;
385 transition: width 0.3s; 397 transition: width 0.3s;
386 .logo-img { 398 .logo-img {
387 width: 38px; 399 width: 38px;
388 height: 38px; 400 height: 38px;
389 } 401 }
390 .logo-text { 402 .logo-text {
391 font-size: 14px; 403 font-size: 14px;
392 color: rgba(255, 255, 255, 1); 404 color: rgba(255, 255, 255, 1);
393 line-height: 14px; 405 line-height: 14px;
394 } 406 }
395 } 407 }
396 .treeModule { 408 .treeModule {
397 box-sizing: border-box; 409 box-sizing: border-box;
398 padding: 20px 20px; 410 padding: 20px 20px;
399 } 411 }
400 .logo-box-show { 412 .logo-box-show {
401 width: 64px; 413 width: 64px;
402 } 414 }
403 .el-menu { 415 .el-menu {
404 border-right: 0; 416 border-right: 0;
405 } 417 }
406 .el-submenu .el-menu-item { 418 .el-submenu .el-menu-item {
407 text-align: left; 419 text-align: left;
408 text-indent: 15px; 420 text-indent: 15px;
409 } 421 }
410 } 422 }
411 .aside-show { 423 .aside-show {
412 width: 64px !important; 424 width: 64px !important;
413 } 425 }
414 426
415 .el-main { 427 .el-main {
416 background-color: #f1f4fc; 428 background-color: #f1f4fc;
417 color: #333; 429 color: #333;
418 // text-align: center; 430 // text-align: center;
419 // line-height: 160px; 431 // line-height: 160px;
420 padding: 0; 432 padding: 0;
421 } 433 }
422 } 434 }
423 </style> 435 </style>
......