5636b7b0 by 杨威

封装请求字典数据方法

1 parent 92b7581b
......@@ -5,31 +5,14 @@
</template>
<script>
import { getDdicByMC } from "../src/api/common";
export default {
mounted() {
this.getDic();
window.addEventListener("unload", this.saveState);
},
methods: {
saveState() {
sessionStorage.setItem("state", JSON.stringify(this.$store.state));
},
//请求字典数据
getDic() {
let s = this.$store.state;
s.zjzlList = s.zjzlList.length == 0 ? this.getDicData("证件种类") : s.zjzlList;
s.gjList = s.gjList.length == 0 ? this.getDicData("国家和地区") : s.gjList;
s.ssList = s.ssList.length == 0 ? this.getDicData("省市") : s.ssList;
s.qlrlxList = s.qlrlxList.length == 0 ? this.getDicData("权利人类型") : s.qlrlxList;
s.xbList = s.xbList.length == 0 ? this.getDicData("性别") : s.xbList;
s.sshyList = s.sshyList.length == 0 ? this.getDicData("国民经济行业分类代码") : s.sshyList;
},
getDicData(name) {
getDdicByMC(name).then((res) => {
return res.result;
});
},
},
};
</script>
......
......@@ -10,15 +10,15 @@ Vue.use(Vuex)
const store = new Vuex.Store({
state: sessionStorage.getItem('state') ? JSON.parse(sessionStorage.getItem('state')) : {
zdbsm: '',
xzqList: [],
djqList: [],
djzqList: [],
zjzlList:[],
gjList:[],
ssList:[],
qlrlxList:[],
xbList:[],
sshyList:[],
xzqList: [],
djqList: [],
djzqList: [],
//创建自然幢时需要用到的临时存储信息
zrzbsm: '',
xmmc: '',
......