1.7版本发布,详情查看版本说明

This commit is contained in:
zhengjie
2019-04-11 11:15:30 +08:00
parent 0642c46288
commit 94585f26f0
86 changed files with 2287 additions and 537 deletions

View File

@@ -0,0 +1,139 @@
<template>
<div class="app-container">
<el-row :gutter="10">
<el-col :xs="24" :sm="24" :md="10" :lg="10" :xl="10">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>字典列表</span>
<el-button
v-if="checkPermission(['ADMIN','DICT_ALL','DICT_CREATE'])"
class="filter-item"
size="mini"
style="float: right;padding: 4px 10px"
type="primary"
icon="el-icon-plus"
@click="$refs.header.$refs.form.dialog = true">新增</el-button>
</div>
<eHeader ref="header" :query="query" :sup_this="sup_this"/>
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" highlight-current-row style="width: 100%;" @current-change="handleCurrentChange">
<el-table-column :show-overflow-tooltip="true" prop="name" label="名称"/>
<el-table-column :show-overflow-tooltip="true" prop="remark" label="描述"/>
<el-table-column label="操作" width="150px" align="center">
<template slot-scope="scope">
<edit v-if="checkPermission(['ADMIN','DICT_ALL','DICT_EDIT'])" :data="scope.row" :sup_this="sup_this"/>
<el-popover
v-if="checkPermission(['ADMIN','DICT_ALL','DICT_DELETE'])"
:ref="scope.row.id"
placement="top"
width="180">
<p>此操作将删除字典与对应的字典详情确定要删除吗</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button>
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button>
</div>
<el-button slot="reference" type="danger" size="mini">删除</el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination
:total="total"
style="margin-top: 8px;"
layout="total, prev, pager, next, sizes"
@size-change="sizeChange"
@current-change="pageChange"/>
</el-card>
</el-col>
<el-col :xs="24" :sm="24" :md="14" :lg="14" :xl="14">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>字典详情
<span style="color: #317EF3">
{{ this.$refs.dictDetail ? this.$refs.dictDetail.dictName : '' }}
</span>
</span>
<el-button
v-if="checkPermission(['ADMIN','DICT_ALL','DICT_CREATE']) && this.$refs.dictDetail && this.$refs.dictDetail.dictName"
class="filter-item"
size="mini"
style="float: right;padding: 4px 10px"
type="primary"
icon="el-icon-plus"
@click="$refs.dictDetail.$refs.header.$refs.form.dialog = true">新增</el-button>
</div>
<dictDetail ref="dictDetail"/>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { del } from '@/api/dict'
import eHeader from './module/header'
import edit from './module/edit'
import dictDetail from '../dictDetail/index'
export default {
components: { eHeader, edit, dictDetail },
mixins: [initData],
data() {
return {
delLoading: false, sup_this: this
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/dict'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
const query = this.query
const type = query.type
const value = query.value
if (type && value) { this.params[type] = value }
if (this.$refs.dictDetail) {
this.$refs.dictDetail.data = []
this.$refs.dictDetail.dictName = ''
}
return true
},
subDelete(id) {
this.delLoading = true
del(id).then(res => {
this.delLoading = false
this.$refs[id].doClose()
this.init()
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
}).catch(err => {
this.delLoading = false
this.$refs[id].doClose()
console.log(err.response.data.message)
})
},
handleCurrentChange(val) {
if (val) {
this.$refs.dictDetail.dictName = val.name
this.$refs.dictDetail.dictId = val.id
this.$refs.dictDetail.init()
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,40 @@
<template>
<div>
<el-button size="mini" type="success" @click="to">编辑</el-button>
<eForm ref="form" :sup_this="sup_this" :is-add="false"/>
</div>
</template>
<script>
import eForm from './form'
export default {
components: { eForm },
props: {
data: {
type: Object,
required: true
},
sup_this: {
type: Object,
required: true
}
},
methods: {
to() {
const _this = this.$refs.form
_this.form = {
id: this.data.id,
name: this.data.name,
remark: this.data.remark
}
_this.dialog = true
}
}
}
</script>
<style scoped>
div{
display: inline-block;
margin-right: 3px;
}
</style>

View File

@@ -0,0 +1,105 @@
<template>
<el-dialog :append-to-body="true" :visible.sync="dialog" :title="isAdd ? '新增字典' : '编辑字典'" width="500px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="字典名称" prop="name">
<el-input v-model="form.name" style="width: 370px;"/>
</el-form-item>
<el-form-item label="描述">
<el-input v-model="form.remark" style="width: 370px;"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { add, edit } from '@/api/dict'
export default {
props: {
isAdd: {
type: Boolean,
required: true
},
sup_this: {
type: Object,
default: null
}
},
data() {
return {
loading: false, dialog: false,
form: {
id: '',
name: '',
remark: ''
},
rules: {
name: [
{ required: true, message: '请输入名称', trigger: 'blur' }
]
}
}
},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.loading = true
if (this.isAdd) {
this.doAdd()
} else this.doEdit()
}
})
},
doAdd() {
add(this.form).then(res => {
this.resetForm()
this.$notify({
title: '添加成功',
type: 'success',
duration: 2500
})
this.loading = false
this.sup_this.init()
}).catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
doEdit() {
edit(this.form).then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.sup_this.init()
}).catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = {
id: '',
name: '',
remark: ''
}
}
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,46 @@
<template>
<div class="head-container">
<!-- 搜索 -->
<el-input v-model="query.value" clearable placeholder="输入搜索内容" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
<el-select v-model="query.type" clearable placeholder="类型" class="filter-item" style="width: 130px">
<el-option v-for="item in queryTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-button class="filter-item" size="mini" type="primary" icon="el-icon-search" @click="toQuery">搜索</el-button>
<div style="display: inline-block;margin: 0px 2px;">
<eForm ref="form" :is-add="true" :sup_this="sup_this"/>
</div>
</div>
</template>
<script>
import checkPermission from '@/utils/permission' // 权限判断函数
import eForm from './form'
export default {
components: { eForm },
props: {
query: {
type: Object,
required: true
},
sup_this: {
type: Object,
required: true
}
},
data() {
return {
queryTypeOptions: [
{ key: 'name', display_name: '字典名称' },
{ key: 'remark', display_name: '描述' }
]
}
},
methods: {
checkPermission,
toQuery() {
this.sup_this.page = 0
this.sup_this.init()
}
}
}
</script>