封装请求字典数据方法
Showing
3 changed files
with
42 additions
and
47 deletions
| ... | @@ -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: '', | ... | ... |
| ... | @@ -35,30 +35,26 @@ | ... | @@ -35,30 +35,26 @@ |
| 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="新建" | ||
| 40 | :visible.sync="dialogVisible" | ||
| 41 | width="40%" | ||
| 42 | > | ||
| 43 | <Create @closeDialog="closeDialog"></Create> | 39 | <Create @closeDialog="closeDialog"></Create> |
| 44 | </el-dialog> | 40 | </el-dialog> |
| 45 | </el-header> | 41 | </el-header> |
| 46 | <el-main> | 42 | <el-main> |
| 47 | <router-view/> | 43 | <router-view /> |
| 48 | </el-main> | 44 | </el-main> |
| 49 | </el-container> | 45 | </el-container> |
| 50 | </el-container> | 46 | </el-container> |
| 51 | </div> | 47 | </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, |
| ... | @@ -187,7 +183,7 @@ | ... | @@ -187,7 +183,7 @@ |
| 187 | }, | 183 | }, |
| 188 | }, | 184 | }, |
| 189 | watch: { | 185 | watch: { |
| 190 | "$route.path": function (newPath) { | 186 | "$route.path": function(newPath) { |
| 191 | //监测路由变化,高亮顶部导航 | 187 | //监测路由变化,高亮顶部导航 |
| 192 | this.headTop.forEach((item, index) => { | 188 | this.headTop.forEach((item, index) => { |
| 193 | item.select = false; | 189 | item.select = false; |
| ... | @@ -195,13 +191,13 @@ | ... | @@ -195,13 +191,13 @@ |
| 195 | item.select = true; | 191 | item.select = true; |
| 196 | } | 192 | } |
| 197 | }); | 193 | }); |
| 198 | if(newPath == '/zd'){ | 194 | if (newPath == "/zd") { |
| 199 | this.getRightTree(this.$store.state.zdbsm) | 195 | this.getRightTree(this.$store.state.zdbsm); |
| 200 | } | 196 | } |
| 201 | }, | 197 | }, |
| 202 | "$store.state.zdbsm": function (bsm) { | 198 | "$store.state.zdbsm": function(bsm) { |
| 203 | this.getRightTree(bsm) | 199 | this.getRightTree(bsm); |
| 204 | } | 200 | }, |
| 205 | }, | 201 | }, |
| 206 | created() { | 202 | created() { |
| 207 | if (this.$route.meta) { | 203 | if (this.$route.meta) { |
| ... | @@ -223,7 +219,7 @@ | ... | @@ -223,7 +219,7 @@ |
| 223 | icon: "fa fa-address-card-o", | 219 | icon: "fa fa-address-card-o", |
| 224 | path: "/add", | 220 | path: "/add", |
| 225 | }, | 221 | }, |
| 226 | {name: "更正", icon: "fa fa-address-card-o", path: "/modify"}, | 222 | { name: "更正", icon: "fa fa-address-card-o", path: "/modify" }, |
| 227 | { | 223 | { |
| 228 | name: "变更", | 224 | name: "变更", |
| 229 | icon: "fa fa-address-card-o", | 225 | icon: "fa fa-address-card-o", |
| ... | @@ -243,14 +239,30 @@ | ... | @@ -243,14 +239,30 @@ |
| 243 | // this.navSelect(indId); | 239 | // this.navSelect(indId); |
| 244 | // this.sortNavigation(this.navigationList, indId); | 240 | // this.sortNavigation(this.navigationList, indId); |
| 245 | // } | 241 | // } |
| 242 | this.getDic(); | ||
| 246 | }, | 243 | }, |
| 247 | methods: { | 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 | }); | ||
| 259 | }, | ||
| 248 | getRightTree(bsm) { | 260 | getRightTree(bsm) { |
| 249 | getTree(bsm).then(res => { | 261 | getTree(bsm).then((res) => { |
| 250 | if (res.success) { | 262 | if (res.success) { |
| 251 | this.pd=res.result | 263 | this.pd = res.result; |
| 252 | } | 264 | } |
| 253 | }) | 265 | }); |
| 254 | }, | 266 | }, |
| 255 | sortNavigation(data, selectId) { | 267 | sortNavigation(data, selectId) { |
| 256 | let headTop = this.headTop; | 268 | let headTop = this.headTop; |
| ... | @@ -309,12 +321,12 @@ | ... | @@ -309,12 +321,12 @@ |
| 309 | //关闭新建子组件弹框 | 321 | //关闭新建子组件弹框 |
| 310 | closeDialog() { | 322 | closeDialog() { |
| 311 | this.dialogVisible = false; | 323 | this.dialogVisible = false; |
| 312 | } | ||
| 313 | }, | 324 | }, |
| 314 | }; | 325 | }, |
| 326 | }; | ||
| 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 { |
| ... | @@ -419,5 +431,5 @@ | ... | @@ -419,5 +431,5 @@ |
| 419 | // line-height: 160px; | 431 | // line-height: 160px; |
| 420 | padding: 0; | 432 | padding: 0; |
| 421 | } | 433 | } |
| 422 | } | 434 | } |
| 423 | </style> | 435 | </style> | ... | ... |
-
Please register or sign in to post a comment