Merge branches 'master' and 'operation-record' of https://github.com/flipped-aurora/gin-vue-admin into operation-record
Conflicts: server/config.yaml
This commit is contained in:
@@ -4,7 +4,7 @@ import VuexPersistence from 'vuex-persist'
|
||||
|
||||
import { user } from "@/store/module/user"
|
||||
import { router } from "@/store/module/router"
|
||||
|
||||
import { dictionary } from "@/store/module/dictionary"
|
||||
Vue.use(Vuex)
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ const vuexLocal = new VuexPersistence({
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
user,
|
||||
router
|
||||
router,
|
||||
dictionary
|
||||
},
|
||||
plugins: [vuexLocal.plugin]
|
||||
})
|
||||
@@ -0,0 +1,42 @@
|
||||
import { findSysDictionary } from '@/api/sysDictionary'
|
||||
|
||||
export const dictionary = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
dictionaryMap: {},
|
||||
},
|
||||
mutations: {
|
||||
setDictionaryMap(state, dictionaryMap) {
|
||||
state.dictionaryMap = { ...state.dictionaryMap, ...dictionaryMap }
|
||||
},
|
||||
|
||||
},
|
||||
actions: {
|
||||
// 从后台获取动态路由
|
||||
async getDictionary({ commit, state }, type) {
|
||||
if (state.dictionaryMap[type]) {
|
||||
return state.dictionaryMap[type]
|
||||
} else {
|
||||
const res = await findSysDictionary({ type })
|
||||
if (res.code == 0) {
|
||||
const dictionaryMap = {}
|
||||
const dict = []
|
||||
res.data.resysDictionary.sysDictionaryDetails && res.data.resysDictionary.sysDictionaryDetails.map(item => {
|
||||
dict.push({
|
||||
label: item.label,
|
||||
value: item.value
|
||||
})
|
||||
})
|
||||
dictionaryMap[res.data.resysDictionary.type] = dict
|
||||
commit("setDictionaryMap", dictionaryMap)
|
||||
return state.dictionaryMap[type]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getters:{
|
||||
getDictionary(state){
|
||||
return state.dictionaryMap
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { store } from '@/store/index'
|
||||
// 获取字典方法 使用示例 getDict('sex').then(res) 或者 async函数下 const res = await getDict('sex')
|
||||
export const getDict = async (type) => {
|
||||
await store.dispatch("dictionary/getDictionary", type)
|
||||
return store.getters["dictionary/getDictionary"][type]
|
||||
}
|
||||
@@ -57,13 +57,7 @@
|
||||
></el-cascader>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色ID" prop="authorityId">
|
||||
<el-input-number
|
||||
:disabled="dialogType=='edit'"
|
||||
step-strictly
|
||||
:step="1"
|
||||
autocomplete="off"
|
||||
v-model="form.authorityId"
|
||||
></el-input-number>
|
||||
<el-input :disabled="dialogType=='edit'" autocomplete="off" v-model="form.authorityId"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色姓名" prop="authorityName">
|
||||
<el-input autocomplete="off" v-model="form.authorityName"></el-input>
|
||||
@@ -111,6 +105,13 @@ export default {
|
||||
name: "Authority",
|
||||
mixins: [infoList],
|
||||
data() {
|
||||
var mustUint = (rule, value, callback) => {
|
||||
if (!(/^[0-9]*[1-9][0-9]*$/).test(value)){
|
||||
return callback(new Error("请输入正整数"));
|
||||
}
|
||||
return callback()
|
||||
};
|
||||
|
||||
return {
|
||||
AuthorityOption: [
|
||||
{
|
||||
@@ -134,7 +135,8 @@ export default {
|
||||
},
|
||||
rules: {
|
||||
authorityId: [
|
||||
{ required: true, message: "请输入角色ID", trigger: "blur" }
|
||||
{ required: true, message: "请输入角色ID", trigger: "blur" },
|
||||
{validator: mustUint, trigger: 'blur' }
|
||||
],
|
||||
authorityName: [
|
||||
{ required: true, message: "请输入角色名", trigger: "blur" }
|
||||
@@ -296,6 +298,7 @@ export default {
|
||||
this.setAuthorityOptions(this.tableData, this.AuthorityOption, false);
|
||||
},
|
||||
setAuthorityOptions(AuthorityData, optionsData, disabled) {
|
||||
this.form.authorityId = String(this.form.authorityId);
|
||||
AuthorityData &&
|
||||
AuthorityData.map(item => {
|
||||
if (item.children && item.children.length) {
|
||||
@@ -350,9 +353,9 @@ export default {
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.authority {
|
||||
.el-input-number{
|
||||
.el-input-number {
|
||||
margin-left: 15px;
|
||||
span{
|
||||
span {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -104,6 +104,8 @@
|
||||
<el-button @click="enterDialog" type="primary">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<div style="margin-top:40px;color:red">获取字典且缓存方法已在前端utils/dictionary 已经封装完成 不必自己书写 使用方法查看文件内注释</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -114,10 +116,9 @@ import {
|
||||
updateSysDictionary,
|
||||
findSysDictionary,
|
||||
getSysDictionaryList
|
||||
} from "@/api/sys_dictionary"; // 此处请自行替换地址
|
||||
} from "@/api/sysDictionary"; // 此处请自行替换地址
|
||||
import { formatTimeToStr } from "@/utils/data";
|
||||
import infoList from "@/components/mixins/infoList";
|
||||
|
||||
export default {
|
||||
name: "SysDictionary",
|
||||
mixins: [infoList],
|
||||
@@ -239,7 +240,7 @@ export default {
|
||||
this.dialogFormVisible = true;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
async created() {
|
||||
this.getTableData();
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -113,7 +113,7 @@ import {
|
||||
updateSysDictionaryDetail,
|
||||
findSysDictionaryDetail,
|
||||
getSysDictionaryDetailList
|
||||
} from "@/api/sys_dictionary_detail"; // 此处请自行替换地址
|
||||
} from "@/api/sysDictionaryDetail"; // 此处请自行替换地址
|
||||
import { formatTimeToStr } from "@/utils/data";
|
||||
import infoList from "@/components/mixins/infoList";
|
||||
|
||||
Reference in New Issue
Block a user