Commit 9896e145 authored by renjintao's avatar renjintao

layout config css store

parent bade8ef3
...@@ -285,6 +285,13 @@ html body { ...@@ -285,6 +285,13 @@ html body {
.pl20 { .pl20 {
padding-left: 20px padding-left: 20px
} }
.pr10 {
padding-right: 10px
}
.pr20 {
padding-right: 20px
}
.bnone { .bnone {
border: none; border: none;
......
<template> <template>
<span class="i-layout-header-trigger i-layout-header-trigger-min"> <span class="i-layout-header-trigger i-layout-header-trigger-min">
<Dropdown :trigger="isMobile ? 'click' : 'hover'" class="i-layout-header-i18n" :class="{ 'i-layout-header-user-mobile': isMobile }" @on-click="handleClick"> <Dropdown transfer :trigger="isMobile ? 'click' : 'hover'" class="i-layout-header-i18n" :class="{ 'i-layout-header-user-mobile': isMobile }" @on-click="handleClick">
<Icon type="md-globe" /> <Icon type="md-globe" />
<DropdownMenu slot="list"> <DropdownMenu slot="list">
<DropdownItem v-for="(item, key) in languages" :key="key" :name="key" :selected="locale === key"> <DropdownItem v-for="(item, key) in languages" :key="key" :name="key" :selected="locale === key">
...@@ -8,15 +8,19 @@ ...@@ -8,15 +8,19 @@
</DropdownItem> </DropdownItem>
</DropdownMenu> </DropdownMenu>
</Dropdown> </Dropdown>
</span> </span>
</template> </template>
<script> <script>
import Languages from '@/i18n/locale'; import Languages from '@/i18n/locale';
import { mapState, mapActions } from 'vuex'; import {
mapState,
mapActions
} from 'vuex';
export default { export default {
name: 'iHeaderI18n', name: 'iHeaderI18n',
data () { data() {
return { return {
languages: Languages languages: Languages
} }
...@@ -33,10 +37,13 @@ ...@@ -33,10 +37,13 @@
...mapActions('admin/i18n', [ ...mapActions('admin/i18n', [
'setLocale' 'setLocale'
]), ]),
handleClick (locale) { handleClick(locale) {
if (locale === this.locale) return; if (locale === this.locale) return;
this.setLocale({ locale, vm: this }); this.setLocale({
} locale,
vm: this
});
} }
} }
}
</script> </script>
<template> <template>
<span class="i-layout-header-trigger i-layout-header-trigger-min"> <span class="i-layout-header-trigger i-layout-header-trigger-min">
<Dropdown <Dropdown transfer :trigger="isMobile ? 'click' : 'hover'" class="i-layout-header-user" :class="{ 'i-layout-header-user-mobile': isMobile }" @on-click="handleClick">
:trigger="isMobile ? 'click' : 'hover'"
class="i-layout-header-user"
:class="{ 'i-layout-header-user-mobile': isMobile }"
@on-click="handleClick"
>
<Avatar size="small" :src="info.avatar" v-if="info.avatar" /> <Avatar size="small" :src="info.avatar" v-if="info.avatar" />
<Avatar size="small" style="background-color: #87d068" icon="ios-person" v-else-if="!info.avatar" /> <Avatar size="small" style="background-color: #87d068" icon="ios-person" v-else-if="!info.avatar" />
<span class="i-layout-header-user-name" v-if="!isMobile">{{ info.name }}</span> <span class="i-layout-header-user-name" v-if="!isMobile">{{ info.name }}</span>
...@@ -28,10 +23,14 @@ ...@@ -28,10 +23,14 @@
</DropdownItem> </DropdownItem>
</DropdownMenu> </DropdownMenu>
</Dropdown> </Dropdown>
</span> </span>
</template> </template>
<script> <script>
import { mapState, mapActions } from "vuex"; import {
mapState,
mapActions
} from "vuex";
export default { export default {
name: "iHeaderUser", name: "iHeaderUser",
......
...@@ -106,7 +106,7 @@ export default { ...@@ -106,7 +106,7 @@ export default {
res.result.avatarUrl = fileUrlDown + res.result.avatarUrl; res.result.avatarUrl = fileUrlDown + res.result.avatarUrl;
} }
let info = res.result; let info = res.result;
info.tenantCode = info.tenantCode = '';
info.auth = ["admin"]; info.auth = ["admin"];
info.avatar = info.avatarUrl; info.avatar = info.avatarUrl;
info.userId = info.id; info.userId = info.id;
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
</Menu> </Menu>
</div> </div>
<div class="main fg" id="mainDiv"> <div class="main fg" id="mainDiv">
<div class="tr lt40 fr divTop"> <div class="tr lt40 fr divTop pr20">
<Button type="primary" size="small" @click="save">保存</Button> <Button type="primary" size="small" @click="save">保存</Button>
<Button type="text">恢复默认</Button> <Button type="text" size="small" @click="reset">恢复默认</Button>
</div> </div>
<Form ref="form" :model="config" :rules="rules" :label-width="120"> <Form ref="form" :model="config" :rules="rules" :label-width="120">
<div id="site" class="mt50"> <div id="site" class="mt50">
...@@ -136,21 +136,36 @@ ...@@ -136,21 +136,36 @@
</template> </template>
<script> <script>
import config from "~/libs/config"; //import config from "~/libs/config";
export default { export default {
name: "", name: "",
data() { data() {
return { return {
config: config, config: this.$store.state.siteConfig,
rules: {}, rules: {},
}; };
}, },
async fetch({
store,
params
}) {
await store.dispatch('loadSiteConfig') // 加载数据字典
},
mounted() {}, mounted() {},
methods: { methods: {
//保存设置
save() { save() {
//alert(JSON.stringify(this.config)) this.$store.dispatch('saveConfig', this.config)
},
//恢复默认
reset() {
this.config = this.$store.state.defaultConfig; //重置为默认设置信息
let configTemSite = this.$store.state.siteConfig; //获取组合设置信息
if (configTemSite.tenantCode != '') {
this.config.tenantCode = configTemSite.tenantCode
}
}, },
reset() {}, //menu切换
pageTo(val) { pageTo(val) {
var mainDiv = document.getElementById('mainDiv'); var mainDiv = document.getElementById('mainDiv');
var site = document.getElementById('site'); var site = document.getElementById('site');
...@@ -200,7 +215,7 @@ export default { ...@@ -200,7 +215,7 @@ export default {
background: #fff; background: #fff;
height: 40px; height: 40px;
width: calc(~'100% - 560px'); width: calc(~'100% - 560px');
z-index: 9999; z-index: 100;
border-bottom: 1px #e4e6ed solid; border-bottom: 1px #e4e6ed solid;
top: 105px top: 105px
} }
......
...@@ -212,6 +212,12 @@ html body { ...@@ -212,6 +212,12 @@ html body {
.pl20 { .pl20 {
padding-left: 20px; padding-left: 20px;
} }
.pr10 {
padding-right: 10px;
}
.pr20 {
padding-right: 20px;
}
.bnone { .bnone {
border: none; border: none;
} }
......
import createVuexAlong from 'vuex-along' import createVuexAlong from 'vuex-along'
import Api from '@/plugins/request' import Api from '@/plugins/request'
import util from '@/libs/util';
export const state = () => ({ export const state = () => ({
counter: 0, counter: 0,
dictionary: new Map(), //所有字典项 dictionary: new Map(), //所有字典项
...@@ -11,6 +12,7 @@ export const state = () => ({ ...@@ -11,6 +12,7 @@ export const state = () => ({
}, },
siteConfig: {}, siteConfig: {},
defaultConfig: {}, defaultConfig: {},
configId:null,
}) })
export const getters = { export const getters = {
dictionaryByKey: (state) => (key) => { dictionaryByKey: (state) => (key) => {
...@@ -56,10 +58,13 @@ export const mutations = { ...@@ -56,10 +58,13 @@ export const mutations = {
state.dictionary = dictionary; state.dictionary = dictionary;
}, },
setSiteConfig(state, config) { setSiteConfig(state, config) {
state.siteConfig = config; state.siteConfig = JSON.parse(config);
}, },
setDefaultConfig(state, config) { setDefaultConfig(state, config) {
state.defaultConfig = config; state.defaultConfig =JSON.parse(config);
},
setConfigId(state, id) {
state.configId =id;
} }
} }
...@@ -100,8 +105,8 @@ export const actions = { ...@@ -100,8 +105,8 @@ export const actions = {
let params = { let params = {
pageSize: 2, pageSize: 2,
conditions: [{ conditions: [{
"fieldName": "key", "fieldName": "component",
"fieldValue": "defaultConfig,tenant-" + state.userInfo.tenantCode, "fieldValue": "defaultConfig,tenantConfig_" + util.cookies.get('tenantCode'),
"conditionalType": "In", "conditionalType": "In",
}, ] }, ]
} }
...@@ -109,18 +114,43 @@ export const actions = { ...@@ -109,18 +114,43 @@ export const actions = {
result result
} = await Api.post(`${systemUrl}/config/list`, params); } = await Api.post(`${systemUrl}/config/list`, params);
if (result[0]) { if (result[0]) {
commit("setDefaultConfig", result[0]) commit("setDefaultConfig", result[0].content)
} }
if (result[1]) { if (result[1]) {
commit("setSiteConfig", result[1]) commit("setSiteConfig", result[1].content)
}else{ commit("setConfigId",result[1].id)
if(result[0]){ } else {
commit("setSiteConfig", result[0]) if (result[0]) {
commit("setSiteConfig", result[0].content)
} }
} }
}, },
async saveConfig({commit},config){ async saveConfig({
state
}, config) {
if (config.tenantCode != '') {
let configStr=JSON.stringify(config);
let params = {
id: state.configId,
page: "config",
component: "tenantConfig_"+config.tenantCode,
key:config.tenantCode,
content: configStr,
note: "配置信息"
}
await Api.post(`${systemUrl}/config/update`, params);
} else {
config.tenantCode = util.cookies.get('tenantCode')
let configStr=JSON.stringify(config);
let params = {
page: "config",
component: "defaultConfig"+config.tenantCode,
key:config.tenantCode,
content: configStr,
note: "配置信息"
}
await Api.post(`${systemUrl}/config/create`, params);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment