mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-04 09:35:20 +08:00
jeecg-boot 1.1 稳定版本发布
This commit is contained in:
@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:width="modalWidth"
|
||||
:visible="visible"
|
||||
:footer="null"
|
||||
@cancel="handleCancel"
|
||||
cancelText="关闭">
|
||||
<!--table区 -->
|
||||
<div class="marginCss">
|
||||
<a-table
|
||||
ref="table"
|
||||
size="small"
|
||||
bordered
|
||||
rowKey="id"
|
||||
:columns="columns"
|
||||
:dataSource="dataSource"
|
||||
:rowClassName="setdataCss"
|
||||
:loading="loading"
|
||||
:scroll="{ y: 700 }"
|
||||
:pagination="false">
|
||||
<span slot="dataVersionTitle1"><a-icon type="smile-o" /> 版本:{{dataVersion1Num}}</span>
|
||||
<span slot="dataVersionTitle2"><a-icon type="smile-o" /> 版本:{{dataVersion2Num}}</span>
|
||||
<template slot="avatarslot" slot-scope="text, record">
|
||||
<div class="anty-img-wrap">
|
||||
<img :src="getAvatarView(record)"/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getAction} from '@/api/manage'
|
||||
|
||||
export default {
|
||||
name: 'DataLogCompareModal',
|
||||
data() {
|
||||
return {
|
||||
modalWidth: 1000,
|
||||
modaltoggleFlag: true,
|
||||
confirmDirty: false,
|
||||
title: '操作',
|
||||
visible: false,
|
||||
model: {},
|
||||
confirmLoading: false,
|
||||
headers: {},
|
||||
//版本号
|
||||
dataVersion1Num:'',
|
||||
dataVersion2Num:'',
|
||||
//表头
|
||||
columns: [
|
||||
{
|
||||
title: '字段名',
|
||||
align: 'left',
|
||||
dataIndex: 'code',
|
||||
width: '30%',
|
||||
}, {
|
||||
align: 'left',
|
||||
dataIndex: 'dataVersion1',
|
||||
width: '30%',
|
||||
slots: { title: 'dataVersionTitle1' },
|
||||
}, {
|
||||
title: '',
|
||||
dataIndex: 'imgshow',
|
||||
align: 'center',
|
||||
scopedSlots: {customRender: "avatarslot"},
|
||||
width: '10%',
|
||||
}, {
|
||||
align: 'left',
|
||||
dataIndex: 'dataVersion2',
|
||||
width: '30%',
|
||||
slots: { title: 'dataVersionTitle2' },
|
||||
}
|
||||
],
|
||||
//数据集
|
||||
dataSource: [],
|
||||
loading: false,
|
||||
url: {
|
||||
queryCompareUrl: "/sys/dataLog/queryCompareList",
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
loadData(dataId1, dataId2) {
|
||||
this.dataSource = [];
|
||||
let that = this;
|
||||
getAction(that.url.queryCompareUrl, {dataId1: dataId1, dataId2: dataId2}).then((res) => {
|
||||
if (res.success) {
|
||||
that.dataVersion1Num = res.result[0].dataVersion;
|
||||
that.dataVersion2Num = res.result[1].dataVersion;
|
||||
let json1 = JSON.parse(res.result[0].dataContent);
|
||||
let json2 = JSON.parse(res.result[1].dataContent);
|
||||
for (var item1 in json1) {
|
||||
for (var item2 in json2) {
|
||||
if (item1 == item2) {
|
||||
this.dataSource.push({
|
||||
code: item1,
|
||||
imgshow: '',
|
||||
dataVersion1: json1[item1],
|
||||
dataVersion2: json2[item2],
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(res.message);
|
||||
}
|
||||
})
|
||||
},
|
||||
compareModal(dataId1, dataId2) {
|
||||
this.visible = true
|
||||
this.loadData(dataId1, dataId2);
|
||||
},
|
||||
handleCancel() {
|
||||
this.close()
|
||||
},
|
||||
modalFormOk() {
|
||||
},
|
||||
close() {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
this.disableSubmit = false;
|
||||
},
|
||||
setdataCss(record) {
|
||||
let className = 'trcolor';
|
||||
const dataVersion1 = record.dataVersion1;
|
||||
const dataVersion2 = record.dataVersion2;
|
||||
if (dataVersion1 != dataVersion2) {
|
||||
return className;
|
||||
}
|
||||
},
|
||||
getAvatarView: function (avatar) {
|
||||
if (avatar.dataVersion1 != avatar.dataVersion2) {
|
||||
return "/goright.png";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.anty-img-wrap {
|
||||
height: 25px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.anty-img-wrap > img {
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.marginCss {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
@import '../../../assets/less/index.less';
|
||||
</style>
|
||||
153
ant-design-jeecg-vue/src/views/system/modules/DataLogModal.vue
Normal file
153
ant-design-jeecg-vue/src/views/system/modules/DataLogModal.vue
Normal file
@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-modal
|
||||
:width="modalWidth"
|
||||
:visible="visible"
|
||||
title="数据对比窗口"
|
||||
:confirmLoading="confirmLoading"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
cancelText="取消">
|
||||
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form @submit="handleSubmit" :form="form" class="form">
|
||||
<a-row class="form-row" :gutter="24">
|
||||
<a-col :md="12" :sm="8">
|
||||
<a-form-item label="数据库表名" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
|
||||
<a-input placeholder="请输入数据库表名" v-decorator="[ 'dataTale', {}]" @blur="handleTableBlur" disabled/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :md="12" :sm="8">
|
||||
<a-form-item label="数据ID" :label-col="{ span: 5 }" :wrapper-col="{ span: 15 }">
|
||||
<a-input placeholder="请输入数据ID" v-decorator="[ 'dataId', {}]" @blur="handleIdBlur" disabled/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-row class="form-row" :gutter="24">
|
||||
<a-col :md="12" :sm="8">
|
||||
<a-form-item label="版本号1" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
|
||||
<a-select placeholder="请选择版本号" v-decorator="[ 'dataVersion1', {}]" @change="handleChange1">
|
||||
<a-select-option v-for="(log,logindex) in DataVersionList" :key="logindex.toString()" :value="log.id">
|
||||
{{ log.dataVersion }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :md="12" :sm="8">
|
||||
<a-form-item label="版本号2" :label-col="{ span: 5 }" :wrapper-col="{ span: 15 }">
|
||||
<a-select placeholder="请选择版本号" v-decorator="[ 'dataVersion2', {}]" @change="handleChange2">
|
||||
<a-select-option v-for="(log,logindex) in DataVersionList" :key="logindex.toString()" :value="log.id">
|
||||
{{ log.dataVersion }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
<data-log-compare-modal ref="modal" @ok="modalFormOk" ></data-log-compare-modal>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAction } from '@/api/manage'
|
||||
import DataLogCompareModal from './DataLogCompareModal'
|
||||
export default {
|
||||
name: 'DataLogModal',
|
||||
components: { DataLogCompareModal },
|
||||
dataId1:'',
|
||||
dataId2: '',
|
||||
dataTable1:'',
|
||||
dataID3:'',
|
||||
|
||||
data () {
|
||||
return {
|
||||
modalWidth:700,
|
||||
modaltoggleFlag:true,
|
||||
confirmDirty: false,
|
||||
title:"操作",
|
||||
visible: false,
|
||||
model: {},
|
||||
confirmLoading: false,
|
||||
headers:{},
|
||||
form:this.$form.createForm(this),
|
||||
url: {
|
||||
queryDataVerListUrl:"/sys/dataLog/queryDataVerList",
|
||||
},
|
||||
DataVersionList:[],
|
||||
}
|
||||
},
|
||||
created () {
|
||||
},
|
||||
methods: {
|
||||
addModal(records){
|
||||
const dataTable = records[0].dataTable
|
||||
const dataId = records[0].dataId;
|
||||
const dataVersion1 = records[0].dataVersion;
|
||||
const dataVersion2 = records[1].dataVersion;
|
||||
this.dataId1 = records[0].id;
|
||||
this.dataId2 = records[1].id;
|
||||
this.dataTable1 = records[0].dataTable
|
||||
this.dataID3 = records[0].dataId
|
||||
this.initDataVersionList();
|
||||
this.form.resetFields();
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue({dataTale:dataTable,dataId:dataId,dataVersion1:dataVersion1,dataVersion2:dataVersion2});
|
||||
});
|
||||
},
|
||||
handleOk () {
|
||||
this.close();
|
||||
this.$refs.modal.compareModal(this.dataId1 ,this.dataId2);
|
||||
this.$refs.modal.title="数据比较";
|
||||
},
|
||||
handleCancel(){
|
||||
this.close()
|
||||
},
|
||||
handleSubmit(){
|
||||
},
|
||||
close () {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
this.disableSubmit = false;
|
||||
},
|
||||
modalFormOk () {
|
||||
},
|
||||
initDataVersionList(){
|
||||
let that = this;
|
||||
getAction(that.url.queryDataVerListUrl,{dataTable:this.dataTable1,dataId:this.dataID3}).then((res)=>{
|
||||
if(res.success){
|
||||
this.DataVersionList = res.result;
|
||||
}else{
|
||||
this.DataVersionList=[];
|
||||
this.dataId1 = '',
|
||||
this.dataId2='',
|
||||
console.log(res.message);
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
handleChange1(value) {
|
||||
this.dataId1 = value;
|
||||
},
|
||||
handleChange2(value) {
|
||||
this.dataId2 = value;
|
||||
},
|
||||
handleTableBlur(e){
|
||||
this.dataTable1 = e.target.value;
|
||||
this.initDataVersionList();
|
||||
},
|
||||
handleIdBlur(e){
|
||||
this.dataID3 = e.target.value;
|
||||
this.initDataVersionList();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@ -120,7 +120,6 @@
|
||||
for (let i = 0; i < res.result.length; i++) {
|
||||
let temp = res.result[i];
|
||||
that.departTree.push(temp);
|
||||
console.log(temp.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -101,13 +101,10 @@
|
||||
if(this.userId == null){
|
||||
getAction(this.url.userId).then((res)=>{
|
||||
if(res.success){
|
||||
that.$message.success(res.message);
|
||||
let formData = {userId:res.result,
|
||||
departIdList:this.departList}
|
||||
departIdList:this.departList}
|
||||
console.log(formData)
|
||||
that.$emit('ok', formData);
|
||||
}else{
|
||||
that.$message.warning("添加失败!");
|
||||
}
|
||||
}).finally(() => {
|
||||
that.departList = [];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:title="title"
|
||||
:width="600"
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:confirmLoading="confirmLoading"
|
||||
@ok="handleOk"
|
||||
@ -15,7 +15,7 @@
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="名称">
|
||||
<a-input placeholder="请输入名称" v-decorator="['itemText', validatorRules.itemText]" />
|
||||
<a-input placeholder="请输入名称" v-decorator="['itemText', validatorRules.itemText]"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
@ -36,14 +36,15 @@
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="排序值">
|
||||
<a-input-number :min="1" v-decorator="['sortOrder',{'initialValue':1}]"/> 值越小越靠前,支持小数
|
||||
<a-input-number :min="1" v-decorator="['sortOrder',{'initialValue':1}]"/>
|
||||
值越小越靠前,支持小数
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="是否启用"
|
||||
hasFeedback >
|
||||
hasFeedback>
|
||||
<a-switch checkedChildren="启用" unCheckedChildren="禁用" @change="onChose" v-model="visibleCheck"/>
|
||||
</a-form-item>
|
||||
|
||||
@ -54,45 +55,45 @@
|
||||
|
||||
<script>
|
||||
import pick from 'lodash.pick'
|
||||
import {addDictItem,editDictItem} from '@/api/api'
|
||||
import {addDictItem, editDictItem, getDictItemList} from '@/api/api'
|
||||
|
||||
export default {
|
||||
name: "DictItemModal",
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
title:"操作",
|
||||
title: "操作",
|
||||
visible: false,
|
||||
visibleCheck: true,
|
||||
model: {},
|
||||
dictId:"",
|
||||
status:1,
|
||||
dictId: "",
|
||||
status: 1,
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 5 },
|
||||
xs: {span: 24},
|
||||
sm: {span: 5},
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 },
|
||||
xs: {span: 24},
|
||||
sm: {span: 16},
|
||||
},
|
||||
confirmLoading: false,
|
||||
form: this.$form.createForm(this),
|
||||
validatorRules:{
|
||||
itemText:{rules: [{ required: true, message: '请输入名称!' }]},
|
||||
itemValue:{rules: [{ required: true, message: '请输入数据值!' }]},
|
||||
validatorRules: {
|
||||
itemText: {rules: [{required: true, message: '请输入名称!'}]},
|
||||
itemValue: {rules: [{required: true, message: '请输入数据值!'}]},
|
||||
},
|
||||
}
|
||||
},
|
||||
created () {
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
add (dictId) {
|
||||
add(dictId) {
|
||||
this.dictId = dictId;
|
||||
this.edit({});
|
||||
},
|
||||
edit (record) {
|
||||
if(record.id){
|
||||
edit(record) {
|
||||
if (record.id) {
|
||||
this.dictId = record.dictId;
|
||||
this.visibleCheck = (record.status == 1)?true:false;
|
||||
this.visibleCheck = (record.status == 1) ? true : false;
|
||||
}
|
||||
this.form.resetFields();
|
||||
this.model = Object.assign({}, record);
|
||||
@ -100,20 +101,34 @@
|
||||
this.model.status = this.status;
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model,'itemText','itemValue','description','sortOrder'))
|
||||
this.form.setFieldsValue(pick(this.model, 'itemText', 'itemValue', 'description', 'sortOrder'))
|
||||
});
|
||||
},
|
||||
// 将查询字典对象数据的方法拆分出来,需要的时候再加载
|
||||
getDictItemList() {
|
||||
// 查询字典数据
|
||||
var params = this.getQueryParams();//查询条件
|
||||
getDictItemList(params).then((res) => {
|
||||
if (res.success) {
|
||||
this.dataSource = res.result.records;
|
||||
console.log(this.dataSource)
|
||||
this.ipagination.total = res.result.total;
|
||||
this.loadrefresh = false;
|
||||
this.loading = false;
|
||||
}
|
||||
})
|
||||
},
|
||||
onChose(checked) {
|
||||
if(checked){
|
||||
this.status=1;
|
||||
this.visibleCheck=true;
|
||||
}else{
|
||||
this.status=0;
|
||||
this.visibleCheck=false;
|
||||
if (checked) {
|
||||
this.status = 1;
|
||||
this.visibleCheck = true;
|
||||
} else {
|
||||
this.status = 0;
|
||||
this.visibleCheck = false;
|
||||
}
|
||||
},
|
||||
// 确定
|
||||
handleOk () {
|
||||
handleOk() {
|
||||
const that = this;
|
||||
// 触发表单验证
|
||||
this.form.validateFields((err, values) => {
|
||||
@ -122,16 +137,16 @@
|
||||
let formData = Object.assign(this.model, values);
|
||||
formData.status = this.status;
|
||||
let obj;
|
||||
if(!this.model.id){
|
||||
obj=addDictItem(formData);
|
||||
}else{
|
||||
obj=editDictItem(formData);
|
||||
if (!this.model.id) {
|
||||
obj = addDictItem(formData);
|
||||
} else {
|
||||
obj = editDictItem(formData);
|
||||
}
|
||||
obj.then((res)=>{
|
||||
if(res.success){
|
||||
obj.then((res) => {
|
||||
if (res.success) {
|
||||
that.$message.success(res.message);
|
||||
that.$emit('ok');
|
||||
}else{
|
||||
} else {
|
||||
that.$message.warning(res.message);
|
||||
}
|
||||
}).finally(() => {
|
||||
@ -142,10 +157,10 @@
|
||||
})
|
||||
},
|
||||
// 关闭
|
||||
handleCancel () {
|
||||
handleCancel() {
|
||||
this.close();
|
||||
},
|
||||
close () {
|
||||
close() {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
},
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="字典名称">
|
||||
<a-input placeholder="请输入字典名称" v-decorator="[ 'dictName', validatorRules.dictName]" />
|
||||
<a-input placeholder="请输入字典名称" v-decorator="[ 'dictName', validatorRules.dictName]"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
@ -39,56 +39,75 @@
|
||||
|
||||
<script>
|
||||
import pick from 'lodash.pick'
|
||||
import {addDict,editDict} from '@/api/api'
|
||||
import {addDict, editDict, duplicateCheck} from '@/api/api'
|
||||
|
||||
export default {
|
||||
name: "DictModal",
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
value:1,
|
||||
title:"操作",
|
||||
value: 1,
|
||||
title: "操作",
|
||||
visible: false,
|
||||
model: {},
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 5 },
|
||||
xs: {span: 24},
|
||||
sm: {span: 5},
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 },
|
||||
xs: {span: 24},
|
||||
sm: {span: 16},
|
||||
},
|
||||
confirmLoading: false,
|
||||
form: this.$form.createForm(this),
|
||||
validatorRules:{
|
||||
dictName:{rules: [{ required: true, message: '请输入字典名称!' }]},
|
||||
dictCode:{rules: [{ required: true, message: '请输入字典编码!' }]},
|
||||
validatorRules: {
|
||||
dictName: {rules: [{required: true, message: '请输入字典名称!'}]},
|
||||
dictCode: {
|
||||
rules: [{required: true, message: '请输入字典编码!'},
|
||||
{validator: this.validateDictCode,}]
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
created () {
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
validateDictCode(rule, value, callback) {
|
||||
// 重复校验
|
||||
var params = {
|
||||
tableName: "sys_dict",
|
||||
fieldName: "dict_code",
|
||||
fieldVal: value,
|
||||
dataId: this.model.id,
|
||||
};
|
||||
duplicateCheck(params).then((res) => {
|
||||
if (res.success) {
|
||||
callback();
|
||||
} else {
|
||||
callback(res.message);
|
||||
}
|
||||
});
|
||||
},
|
||||
handleChange(value) {
|
||||
this.model.status = value;
|
||||
},
|
||||
add () {
|
||||
add() {
|
||||
this.edit({});
|
||||
},
|
||||
edit (record) {
|
||||
if(record.id){
|
||||
edit(record) {
|
||||
if (record.id) {
|
||||
this.visiblekey = true;
|
||||
}else{
|
||||
} else {
|
||||
this.visiblekey = false;
|
||||
}
|
||||
this.form.resetFields();
|
||||
this.model = Object.assign({}, record);
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model,'dictName','dictCode','description'))
|
||||
this.form.setFieldsValue(pick(this.model, 'dictName', 'dictCode', 'description'))
|
||||
});
|
||||
},
|
||||
// 确定
|
||||
handleOk () {
|
||||
handleOk() {
|
||||
const that = this;
|
||||
// 触发表单验证
|
||||
this.form.validateFields((err, values) => {
|
||||
@ -97,17 +116,17 @@
|
||||
let formData = Object.assign(this.model, values);
|
||||
let obj;
|
||||
console.log(formData)
|
||||
if(!this.model.id){
|
||||
if (!this.model.id) {
|
||||
formData.delFlag = "1";
|
||||
obj=addDict(formData);
|
||||
}else{
|
||||
obj=editDict(formData);
|
||||
obj = addDict(formData);
|
||||
} else {
|
||||
obj = editDict(formData);
|
||||
}
|
||||
obj.then((res)=>{
|
||||
if(res.success){
|
||||
obj.then((res) => {
|
||||
if (res.success) {
|
||||
that.$message.success(res.message);
|
||||
that.$emit('ok');
|
||||
}else{
|
||||
} else {
|
||||
that.$message.warning(res.message);
|
||||
}
|
||||
}).finally(() => {
|
||||
@ -118,10 +137,10 @@
|
||||
})
|
||||
},
|
||||
// 关闭
|
||||
handleCancel () {
|
||||
handleCancel() {
|
||||
this.close();
|
||||
},
|
||||
close () {
|
||||
close() {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
},
|
||||
|
||||
@ -0,0 +1,162 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:title="title"
|
||||
:width="1000"
|
||||
:visible="visible"
|
||||
:confirmLoading="confirmLoading"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
cancelText="关闭">
|
||||
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form :form="form">
|
||||
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="规则名称">
|
||||
<a-input placeholder="请输入规则名称" v-decorator="['ruleName', validatorRules.ruleName]"/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
v-show="showRuleColumn"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="规则字段">
|
||||
<a-input placeholder="请输入规则字段" v-decorator="['ruleColumn', validatorRules.ruleColumn]"/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="条件规则">
|
||||
<j-dict-select-tag @change="handleChangeRuleCondition" v-decorator="['ruleConditions', validatorRules.ruleConditions]" placeholder="请输入条件规则" :triggerChange="true" dictCode="rule_conditions"/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="规则值">
|
||||
<a-input placeholder="请输入规则值" v-decorator="['ruleValue', validatorRules.ruleValue]"/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script>
|
||||
import {httpAction, getAction} from '@/api/manage'
|
||||
import pick from 'lodash.pick'
|
||||
|
||||
export default {
|
||||
name: 'PermissionDataRuleModal',
|
||||
data() {
|
||||
return {
|
||||
queryParam: {},
|
||||
title: '操作',
|
||||
visible: false,
|
||||
model: {},
|
||||
ruleConditionList: [],
|
||||
labelCol: {
|
||||
xs: {span: 24},
|
||||
sm: {span: 5}
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: {span: 24},
|
||||
sm: {span: 16}
|
||||
},
|
||||
confirmLoading: false,
|
||||
form: this.$form.createForm(this),
|
||||
permissionId: '',
|
||||
validatorRules: {
|
||||
ruleConditions: {rules: [{required: true, message: '请选择条件!'}]},
|
||||
ruleName: {rules: [{required: true, message: '请输入规则名称!'}]},
|
||||
ruleValue: {rules: [{required: true, message: '请输入规则值!'}]},
|
||||
ruleColumn: {rules: []}
|
||||
},
|
||||
url: {
|
||||
list: '/sys/dictItem/list',
|
||||
add: '/sys/permission/addPermissionRule',
|
||||
edit: '/sys/permission/editPermissionRule'
|
||||
},
|
||||
showRuleColumn:true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
add(permId) {
|
||||
this.permissionId = permId
|
||||
this.edit({})
|
||||
},
|
||||
edit(record) {
|
||||
this.form.resetFields()
|
||||
this.model = Object.assign({}, record)
|
||||
if (record.permissionId) {
|
||||
this.model.permissionId = record.permissionId
|
||||
} else {
|
||||
this.model.permissionId = this.permissionId
|
||||
}
|
||||
this.visible = true
|
||||
this.initRuleCondition()
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model, 'ruleName', 'ruleColumn', 'ruleConditions', 'ruleValue'))
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.$emit('close')
|
||||
this.visible = false
|
||||
},
|
||||
handleOk() {
|
||||
const that = this
|
||||
// 触发表单验证
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
that.confirmLoading = true
|
||||
let httpurl = ''
|
||||
let method = ''
|
||||
if (!this.model.id) {
|
||||
httpurl += this.url.add
|
||||
method = 'post'
|
||||
} else {
|
||||
httpurl += this.url.edit
|
||||
method = 'put'
|
||||
}
|
||||
let formData = Object.assign(this.model, values)
|
||||
httpAction(httpurl, formData, method).then((res) => {
|
||||
if (res.success) {
|
||||
that.$message.success(res.message)
|
||||
that.$emit('ok')
|
||||
} else {
|
||||
that.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false
|
||||
that.close()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleCancel() {
|
||||
this.close()
|
||||
},
|
||||
initRuleCondition(){
|
||||
if(this.model.ruleConditions && this.model.ruleConditions=='USE_SQL_RULES'){
|
||||
this.showRuleColumn = false
|
||||
}else{
|
||||
this.showRuleColumn = true
|
||||
}
|
||||
},
|
||||
handleChangeRuleCondition(val){
|
||||
if(val=='USE_SQL_RULES'){
|
||||
this.form.setFieldsValue({
|
||||
ruleColumn:''
|
||||
})
|
||||
this.showRuleColumn = false
|
||||
}else{
|
||||
this.showRuleColumn = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@ -1,23 +1,21 @@
|
||||
<template>
|
||||
<a-modal
|
||||
<a-drawer
|
||||
:title="title"
|
||||
:width="900"
|
||||
:width="drawerWidth"
|
||||
@close="handleCancel"
|
||||
:visible="visible"
|
||||
:confirmLoading="confirmLoading"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
:okButtonProps="{ props: {disabled: disableSubmit} }"
|
||||
cancelText="关闭"
|
||||
wrapClassName="ant-modal-cust-warp"
|
||||
style="top:5%;height: 95%;">
|
||||
:wrapStyle="{height: 'calc(100% - 108px)',overflow: 'auto',paddingBottom: '108px'}"
|
||||
>
|
||||
<div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form :form="form">
|
||||
|
||||
<a-form-item label="菜单类型" :labelCol="labelCol" :wrapperCol="wrapperCol" >
|
||||
<a-radio-group @change="onChangeMenuType" v-decorator="['menuType',{'initialValue':1}]">
|
||||
<a-radio-group @change="onChangeMenuType" v-decorator="['menuType',{'initialValue':0}]">
|
||||
<a-radio :value="0">一级菜单</a-radio>
|
||||
<a-radio :value="1">子菜单</a-radio>
|
||||
<a-radio :value="2">按钮</a-radio>
|
||||
<a-radio :value="2">按钮/数据权限</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
|
||||
@ -94,6 +92,14 @@
|
||||
<a-input-number placeholder="请输入菜单排序" style="width: 200px" v-decorator="[ 'sortNo', {'initialValue':1.0,'rule':validatorRules.sortNo}]" :readOnly="disableSubmit"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
:wrapperCol="wrapperCol"
|
||||
label="是否路由菜单">
|
||||
<a-switch checkedChildren="是" unCheckedChildren="否" v-model="routeSwitch"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
v-show="show"
|
||||
:labelCol="labelCol"
|
||||
@ -116,7 +122,14 @@
|
||||
<!-- 选择图标 -->
|
||||
<icons @choose="handleIconChoose" @close="handleIconCancel" :iconChooseVisible="iconChooseVisible"></icons>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
<a-row :style="{textAlign:'right'}">
|
||||
<a-button :style="{marginRight: '8px'}" @click="handleCancel">
|
||||
关闭
|
||||
</a-button>
|
||||
<a-button :disabled="disableSubmit" @click="handleOk" type="primary">确定</a-button>
|
||||
</a-row>
|
||||
</div>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -129,6 +142,7 @@
|
||||
components: {Icons},
|
||||
data () {
|
||||
return {
|
||||
drawerWidth:700,
|
||||
treeData:[],
|
||||
treeValue: '0-0-4',
|
||||
title:"操作",
|
||||
@ -138,6 +152,7 @@
|
||||
localMenuType:'1',
|
||||
alwaysShow:false,//表单元素-聚合路由
|
||||
menuHidden:false,//表单元素-隐藏路由
|
||||
routeSwitch:true, //是否路由菜单
|
||||
show:true,//根据菜单类型,动态显示隐藏表单元素
|
||||
menuLabel:'菜单名称',
|
||||
labelCol: {
|
||||
@ -181,17 +196,20 @@
|
||||
this.edit();
|
||||
},
|
||||
edit (record) {
|
||||
this.resetScreenSize(); // 调用此方法,根据屏幕宽度自适应调整抽屉的宽度
|
||||
this.form.resetFields();
|
||||
this.model = Object.assign({}, record);
|
||||
//菜单类型切换
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//根据菜单类型,动态展示页面字段
|
||||
if(record){
|
||||
console.log(record)
|
||||
this.alwaysShow = !record.alwaysShow?false:true;
|
||||
this.menuHidden = !record.hidden?false:true;
|
||||
this.routeSwitch = record.route;
|
||||
|
||||
//console.log('record.menuType', record.menuType);
|
||||
this.show = record.menuType==2?false:true;
|
||||
this.menuLabel = record.menuType==2?'按钮名称':'菜单名称';
|
||||
this.menuLabel = record.menuType==2?'按钮/权限名称':'菜单名称';
|
||||
|
||||
if(this.model.parentId){
|
||||
this.localMenuType = 1;
|
||||
@ -199,9 +217,15 @@
|
||||
this.localMenuType = 0;
|
||||
}
|
||||
}else{
|
||||
if(this.model.parentId){
|
||||
this.localMenuType = 1;
|
||||
}else{
|
||||
this.localMenuType = 0;
|
||||
}
|
||||
this.show = true;
|
||||
this.menuLabel = '菜单名称';
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
this.visible = true;
|
||||
this.loadTree();
|
||||
@ -223,6 +247,7 @@
|
||||
that.confirmLoading = true;
|
||||
this.model.alwaysShow = this.alwaysShow;
|
||||
this.model.hidden = this.menuHidden;
|
||||
this.model.route = this.routeSwitch;
|
||||
let formData = Object.assign(this.model, values);
|
||||
console.log(formData);
|
||||
let obj;
|
||||
@ -260,7 +285,7 @@
|
||||
this.localMenuType=e.target.value
|
||||
if(e.target.value == 2){
|
||||
this.show = false;
|
||||
this.menuLabel = '按钮名称';
|
||||
this.menuLabel = '按钮/权限名称';
|
||||
}else{
|
||||
this.show = true;
|
||||
this.menuLabel = '菜单名称';
|
||||
@ -278,6 +303,15 @@
|
||||
this.form.icon = value
|
||||
this.iconChooseVisible = false
|
||||
},
|
||||
// 根据屏幕变化,设置抽屉尺寸
|
||||
resetScreenSize(){
|
||||
let screenWidth = document.body.clientWidth;
|
||||
if(screenWidth < 500){
|
||||
this.drawerWidth = screenWidth;
|
||||
}else{
|
||||
this.drawerWidth = 700;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<a-drawer
|
||||
title="数据规则/按钮权限配置"
|
||||
width=365
|
||||
:closable="false"
|
||||
@close="onClose"
|
||||
:visible="visible"
|
||||
>
|
||||
|
||||
<a-tabs defaultActiveKey="1">
|
||||
<a-tab-pane tab="数据规则" key="1">
|
||||
|
||||
<a-checkbox-group v-model="dataruleChecked" v-if="dataruleList.length>0">
|
||||
<a-row>
|
||||
<a-col :span="24" v-for="(item,index) in dataruleList" :key=" 'dr'+index ">
|
||||
<a-checkbox :value="item.id">{{ item.ruleName }}</a-checkbox>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<div style="width: 100%;margin-top: 15px">
|
||||
<a-button @click="saveDataruleForRole" type="primary" size="small" icon="save">点击保存</a-button>
|
||||
</div>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-checkbox-group>
|
||||
<div v-else><h3>无配置信息!</h3></div>
|
||||
|
||||
</a-tab-pane>
|
||||
<!--<a-tab-pane tab="按钮权限" key="2">敬请期待!!!</a-tab-pane>-->
|
||||
</a-tabs>
|
||||
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ARow from 'ant-design-vue/es/grid/Row'
|
||||
import ACol from 'ant-design-vue/es/grid/Col'
|
||||
import { getAction,postAction } from '@/api/manage'
|
||||
|
||||
export default {
|
||||
name: 'RoleDataruleModal',
|
||||
components: { ACol, ARow },
|
||||
data(){
|
||||
return {
|
||||
functionId:'',
|
||||
roleId:'',
|
||||
visible:false,
|
||||
tabList: [{
|
||||
key: '1',
|
||||
tab: '数据规则',
|
||||
}, {
|
||||
key: '2',
|
||||
tab: '按钮权限',
|
||||
}],
|
||||
activeTabKey: '1',
|
||||
url:{
|
||||
datarule:"/sys/role/datarule",
|
||||
},
|
||||
dataruleList:[],
|
||||
dataruleChecked:[]
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
loadData(){
|
||||
getAction(`${this.url.datarule}/${this.functionId}/${this.roleId}`).then(res=>{
|
||||
console.log(res)
|
||||
if(res.success){
|
||||
this.dataruleList = res.result.datarule
|
||||
let drChecked = res.result.drChecked
|
||||
if(drChecked){
|
||||
this.dataruleChecked = drChecked.split(",")
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
saveDataruleForRole(){
|
||||
if(!this.dataruleChecked || this.dataruleChecked.length==0){
|
||||
this.$message.warning("请现勾选数据权限然后保存!")
|
||||
return false;
|
||||
}
|
||||
let params = {
|
||||
permissionId:this.functionId,
|
||||
roleId:this.roleId,
|
||||
dataRuleIds:this.dataruleChecked.join(",")
|
||||
}
|
||||
console.log("保存数据权限",params)
|
||||
postAction(this.url.datarule,params).then(res=>{
|
||||
if(res.success){
|
||||
this.$message.success(res.message)
|
||||
}else{
|
||||
this.$message.error(res.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
show(functionId,roleId){
|
||||
this.onReset()
|
||||
this.functionId = functionId
|
||||
this.roleId = roleId
|
||||
this.visible=true
|
||||
this.loadData()
|
||||
},
|
||||
onClose(){
|
||||
this.visible=false
|
||||
this.onReset()
|
||||
},
|
||||
onTabChange (key) {
|
||||
this.activeTabKey = key
|
||||
},
|
||||
onReset(){
|
||||
this.functionId=''
|
||||
this.roleId=''
|
||||
this.dataruleList=[]
|
||||
this.dataruleChecked=[]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@ -1,20 +1,19 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:width="modalWidth"
|
||||
<a-drawer
|
||||
:title="title"
|
||||
:maskClosable="true"
|
||||
:width="drawerWidth"
|
||||
placement="right"
|
||||
:closable="true"
|
||||
@close="handleCancel"
|
||||
:visible="visible"
|
||||
:confirmLoading="confirmLoading"
|
||||
:okButtonProps="{ props: {disabled: disableSubmit} }"
|
||||
@ok="handleSubmit"
|
||||
@cancel="handleCancel"
|
||||
cancelText="关闭"
|
||||
wrapClassName="ant-modal-cust-warp"
|
||||
style="top:5%;height: auto;overflow-y: hidden">
|
||||
style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
|
||||
|
||||
<template slot="title">
|
||||
<div style="width: 100%;">
|
||||
<span>{{ title }}</span>
|
||||
<span style="display:inline-block;width:calc(100% - 56px);padding-top: 2px;padding-right:10px;text-align: right">
|
||||
<a-button @click="togglescreen" style="height:18px;width:18px;padding: 0;border-width: 2px"> </a-button>
|
||||
<span style="display:inline-block;width:calc(100% - 51px);padding-right:10px;text-align: right">
|
||||
<a-button @click="toggleScreen" icon="appstore" style="height:20px;width:20px;border:0px"></a-button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -23,25 +22,25 @@
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form :form="form">
|
||||
|
||||
<a-form-item label="用户账号" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback>
|
||||
<a-form-item label="用户账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-input placeholder="请输入用户账号" v-decorator="[ 'username', validatorRules.username]" :readOnly="!!model.id"/>
|
||||
</a-form-item>
|
||||
|
||||
<template v-if="!model.id">
|
||||
<a-form-item label="登陆密码" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
|
||||
<a-form-item label="登陆密码" :labelCol="labelCol" :wrapperCol="wrapperCol" >
|
||||
<a-input type="password" placeholder="请输入登陆密码" v-decorator="[ 'password', validatorRules.password]" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="确认密码" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
|
||||
<a-form-item label="确认密码" :labelCol="labelCol" :wrapperCol="wrapperCol" >
|
||||
<a-input type="password" @blur="handleConfirmBlur" placeholder="请重新输入登陆密码" v-decorator="[ 'confirmpassword', validatorRules.confirmpassword]"/>
|
||||
</a-form-item>
|
||||
</template>
|
||||
|
||||
<a-form-item label="用户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
|
||||
<a-form-item label="用户名字" :labelCol="labelCol" :wrapperCol="wrapperCol" >
|
||||
<a-input placeholder="请输入用户名称" v-decorator="[ 'realname', validatorRules.realname]" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="角色分配" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
|
||||
<a-form-item label="角色分配" :labelCol="labelCol" :wrapperCol="wrapperCol" >
|
||||
<a-select
|
||||
mode="multiple"
|
||||
style="width: 100%"
|
||||
@ -50,14 +49,18 @@
|
||||
<a-select-option v-for="(role,roleindex) in roleList" :key="roleindex.toString()" :value="role.id">
|
||||
{{ role.roleName }}
|
||||
</a-select-option>
|
||||
|
||||
|
||||
</a-select>
|
||||
|
||||
</a-form-item>
|
||||
|
||||
|
||||
|
||||
<!--部门分配-->
|
||||
<a-form-item label="部门分配" :labelCol="labelCol" :wrapperCol="wrapperCol" >
|
||||
<a-input-search
|
||||
placeholder="点击右侧按钮选择部门"
|
||||
v-model="checkedDepartNameString"
|
||||
disabled
|
||||
@search="onSearch">
|
||||
<a-button slot="enterButton" icon="search">选择</a-button>
|
||||
</a-input-search>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="头像" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-upload
|
||||
@ -78,50 +81,68 @@
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="生日" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
|
||||
<a-form-item label="生日" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-date-picker
|
||||
style="width: 100%"
|
||||
placeholder="请选择生日"
|
||||
v-decorator="['birthday', {initialValue:!model.birthday?null:moment(model.birthday,dateFormat)}]"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
|
||||
<a-select
|
||||
v-decorator="[ 'sex', {initialValue:model.sex && model.sex.toString()}]"
|
||||
placeholder="请选择性别">
|
||||
<a-select-option value="1">男</a-select-option>
|
||||
<a-select-option value="2">女</a-select-option>
|
||||
<a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-select v-decorator="[ 'sex', {}]" placeholder="请选择性别">
|
||||
<a-select-option :value="1">男</a-select-option>
|
||||
<a-select-option :value="2">女</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
|
||||
<a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-input placeholder="请输入邮箱" v-decorator="[ 'email', validatorRules.email]" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol" hasFeedback >
|
||||
<a-form-item label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-input placeholder="请输入手机号码" v-decorator="[ 'phone', validatorRules.phone]" />
|
||||
</a-form-item>
|
||||
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
<depart-window ref="departWindow" @ok="modalFormOk"></depart-window>
|
||||
|
||||
<div class="drawer-bootom-button" v-show="!disableSubmit">
|
||||
<a-popconfirm title="确定放弃编辑?" @confirm="handleCancel" okText="确定" cancelText="取消">
|
||||
<a-button style="margin-right: .8rem">取消</a-button>
|
||||
</a-popconfirm>
|
||||
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">提交</a-button>
|
||||
</div>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import pick from 'lodash.pick'
|
||||
import moment from 'moment'
|
||||
import Vue from 'vue'
|
||||
// 引入搜索部门弹出框的组件
|
||||
import departWindow from './DepartWindow'
|
||||
import { ACCESS_TOKEN } from "@/store/mutation-types"
|
||||
import {doMian,addUser,editUser,queryUserRole,queryall,checkUsername} from '@/api/api'
|
||||
|
||||
import { getAction, httpAction } from '@/api/manage'
|
||||
import {addUser,editUser,queryUserRole,queryall,checkUsername } from '@/api/api'
|
||||
export default {
|
||||
name: "RoleModal",
|
||||
components: {
|
||||
departWindow,
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
modalWidth:800,
|
||||
drawerWidth:700,
|
||||
modaltoggleFlag:true,
|
||||
confirmDirty: false,
|
||||
selectedDepartKeys:[], //保存用户选择部门id
|
||||
checkedDepartKeys:[],
|
||||
checkedDepartNames:[], // 保存部门的名称 =>title
|
||||
checkedDepartNameString:"", // 保存部门的名称 =>title
|
||||
userId:"", //保存用户id
|
||||
disableSubmit:false,
|
||||
userDepartModel:{userId:'',departIdList:[]}, // 保存SysUserDepart的用户部门中间表数据需要的对象
|
||||
dateFormat:"YYYY-MM-DD",
|
||||
validatorRules:{
|
||||
username:{
|
||||
@ -169,8 +190,11 @@
|
||||
headers:{},
|
||||
form:this.$form.createForm(this),
|
||||
url: {
|
||||
fileUpload:doMian+"sys/common/upload",
|
||||
imgerver:doMian+"sys/common/view",
|
||||
addUDepartIds:"/sys/user/addUDepartIds", // 引入为用户添加部门信息需要的url
|
||||
editUDepartIds:"/sys/user/editUDepartIds", // 引入为用户更新部门信息需要的url
|
||||
fileUpload: window._CONFIG['domianURL']+"/sys/common/upload",
|
||||
imgerver: window._CONFIG['domianURL']+"/sys/common/view",
|
||||
userWithDepart: "/sys/user/userDepartList", // 引入为指定用户查看部门信息需要的url
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -185,8 +209,8 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
togglescreen(){
|
||||
//窗口最大化切换
|
||||
toggleScreen(){
|
||||
if(this.modaltoggleFlag){
|
||||
this.modalWidth = window.innerWidth;
|
||||
}else{
|
||||
@ -212,29 +236,59 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
refresh () {
|
||||
this.selectedDepartKeys=[]
|
||||
this.checkedDepartKeys=[]
|
||||
this.checkedDepartNames=[]
|
||||
this.checkedDepartNameString = ""
|
||||
this.userId=""
|
||||
},
|
||||
add () {
|
||||
this.refresh()
|
||||
this.edit({});
|
||||
},
|
||||
edit (record) {
|
||||
this.initialRoleList();
|
||||
this.form.resetFields();
|
||||
this.resetScreenSize(); // 调用此方法,根据屏幕宽度自适应调整抽屉的宽度
|
||||
let that = this;
|
||||
that.initialRoleList();
|
||||
that.checkedDepartNameString = "";
|
||||
that.form.resetFields();
|
||||
if(record.hasOwnProperty("id")){
|
||||
this.loadUserRoles(record.id);
|
||||
that.loadUserRoles(record.id);
|
||||
}
|
||||
this.visible = true;
|
||||
this.model = Object.assign({}, record);
|
||||
let filedsVal = pick(this.model,'username','password','realname','email','phone');
|
||||
filedsVal.confirmpassword = this.model.password;
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(filedsVal);
|
||||
that.userId = record.id;
|
||||
that.visible = true;
|
||||
that.model = Object.assign({}, record);
|
||||
that.$nextTick(() => {
|
||||
that.form.setFieldsValue(pick(this.model,'username','sex','realname','email','phone'))
|
||||
});
|
||||
|
||||
// 调用查询用户对应的部门信息的方法
|
||||
that.checkedDepartKeys = [];
|
||||
that.loadCheckedDeparts();
|
||||
},
|
||||
//
|
||||
loadCheckedDeparts(){
|
||||
let that = this;
|
||||
getAction(that.url.userWithDepart,{userId:that.userId}).then((res)=>{
|
||||
that.checkedDepartNames = [];
|
||||
if(res.success){
|
||||
for (let i = 0; i < res.result.length; i++) {
|
||||
that.checkedDepartNames.push(res.result[i].title);
|
||||
this.checkedDepartNameString = this.checkedDepartNames.join(",");
|
||||
that.checkedDepartKeys.push(res.result[i].key);
|
||||
}
|
||||
}else{
|
||||
console.log(res.message);
|
||||
}
|
||||
})
|
||||
},
|
||||
close () {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
this.disableSubmit = false;
|
||||
this.selectedRole = [];
|
||||
this.userDepartModel = {};
|
||||
this.checkedDepartNames = [];
|
||||
},
|
||||
moment,
|
||||
handleSubmit () {
|
||||
@ -252,8 +306,11 @@
|
||||
let formData = Object.assign(this.model, values);
|
||||
formData.avatar = avatar;
|
||||
formData.selectedroles = this.selectedRole.length>0?this.selectedRole.join(","):'';
|
||||
|
||||
that.addDepartsToUser(that,formData); // 调用根据当前用户添加部门信息的方法
|
||||
let obj;
|
||||
if(!this.model.id){
|
||||
formData.id = this.userId;
|
||||
obj=addUser(formData);
|
||||
}else{
|
||||
obj=editUser(formData);
|
||||
@ -267,6 +324,7 @@
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false;
|
||||
that.checkedDepartNames = [];
|
||||
that.close();
|
||||
})
|
||||
|
||||
@ -276,6 +334,26 @@
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
|
||||
// 根据当前用户添加部门信息的方法
|
||||
addDepartsToUser(that,formData){
|
||||
let httpurl = '';
|
||||
let method = '';
|
||||
if(this.userDepartModel.userId != formData.id){
|
||||
httpurl+=this.url.addUDepartIds;
|
||||
method = 'post';
|
||||
}else{
|
||||
httpurl+=this.url.editUDepartIds;
|
||||
method = 'put';
|
||||
}
|
||||
httpAction(httpurl,this.userDepartModel,method).then((res)=>{
|
||||
if(res.success){
|
||||
this.userDepartModel = {};
|
||||
}else{
|
||||
that.$message.warning(res.message);
|
||||
}
|
||||
})
|
||||
},
|
||||
validateToNextPassword (rule, value, callback) {
|
||||
const form = this.form;
|
||||
if (value && this.confirmDirty) {
|
||||
@ -350,7 +428,33 @@
|
||||
getAvatarView(){
|
||||
return this.url.imgerver +"/"+ this.model.avatar;
|
||||
},
|
||||
// 搜索用户对应的部门API
|
||||
onSearch(){
|
||||
this.$refs.departWindow.add(this.checkedDepartKeys,this.userId);
|
||||
},
|
||||
|
||||
// 获取用户对应部门弹出框提交给返回的数据
|
||||
modalFormOk (formData) {
|
||||
this.checkedDepartNames = [];
|
||||
this.selectedDepartKeys = [];
|
||||
this.userId = formData.userId;
|
||||
this.userDepartModel.userId = formData.userId;
|
||||
for (let i = 0; i < formData.departIdList.length; i++) {
|
||||
this.selectedDepartKeys.push(formData.departIdList[i].key);
|
||||
this.checkedDepartNames.push(formData.departIdList[i].title);
|
||||
this.checkedDepartNameString = this.checkedDepartNames.join(",");
|
||||
}
|
||||
this.userDepartModel.departIdList = this.selectedDepartKeys;
|
||||
},
|
||||
// 根据屏幕变化,设置抽屉尺寸
|
||||
resetScreenSize(){
|
||||
let screenWidth = document.body.clientWidth;
|
||||
if(screenWidth < 500){
|
||||
this.drawerWidth = screenWidth;
|
||||
}else{
|
||||
this.drawerWidth = 700;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -375,4 +479,15 @@
|
||||
padding-bottom:10px;
|
||||
}
|
||||
|
||||
.drawer-bootom-button {
|
||||
position: absolute;
|
||||
bottom: -8px;
|
||||
width: 100%;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
padding: 10px 16px;
|
||||
text-align: right;
|
||||
left: 0;
|
||||
background: #fff;
|
||||
border-radius: 0 0 2px 2px;
|
||||
}
|
||||
</style>
|
||||
@ -9,18 +9,23 @@
|
||||
:visible="visible"
|
||||
style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
|
||||
|
||||
<a-form>
|
||||
<a-form-item label='所拥有的权限'>
|
||||
<a-tree
|
||||
checkable
|
||||
@check="onCheck"
|
||||
:checkedKeys="checkedKeys"
|
||||
:treeData="treeData"
|
||||
@expand="onExpand"
|
||||
:expandedKeys="expandedKeysss"
|
||||
:checkStrictly="checkStrictly"/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<a-form>
|
||||
<a-form-item label='所拥有的权限'>
|
||||
<a-tree
|
||||
checkable
|
||||
@check="onCheck"
|
||||
:checkedKeys="checkedKeys"
|
||||
:treeData="treeData"
|
||||
@expand="onExpand"
|
||||
@select="onTreeNodeSelect"
|
||||
:expandedKeys="expandedKeysss"
|
||||
:checkStrictly="checkStrictly">
|
||||
<span slot="hasDatarule" slot-scope="{slotTitle,icon}">
|
||||
{{ slotTitle }}<a-icon v-if="icon" type="align-left" style="margin-left:5px;color: red;"></a-icon>
|
||||
</span>
|
||||
</a-tree>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<div class="drawer-bootom-button">
|
||||
<a-dropdown style="float: left" :trigger="['click']" placement="topCenter">
|
||||
@ -41,13 +46,21 @@
|
||||
</a-popconfirm>
|
||||
<a-button @click="handleSubmit" type="primary" :loading="loading">提交</a-button>
|
||||
</div>
|
||||
|
||||
<role-datarule-modal ref="datarule"></role-datarule-modal>
|
||||
|
||||
</a-drawer>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import {queryTreeList,queryRolePermission,saveRolePermission} from '@/api/api'
|
||||
import {queryTreeListForRole,queryRolePermission,saveRolePermission} from '@/api/api'
|
||||
import RoleDataruleModal from './RoleDataruleModal.vue'
|
||||
|
||||
export default {
|
||||
name: "RoleModal",
|
||||
components:{
|
||||
RoleDataruleModal
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
roleId:"",
|
||||
@ -64,6 +77,9 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onTreeNodeSelect(id){
|
||||
this.$refs.datarule.show(id[0],this.roleId)
|
||||
},
|
||||
onCheck (o) {
|
||||
if(this.checkStrictly){
|
||||
this.checkedKeys = o.checked;
|
||||
@ -137,7 +153,7 @@
|
||||
watch: {
|
||||
visible () {
|
||||
if (this.visible) {
|
||||
queryTreeList().then((res) => {
|
||||
queryTreeListForRole().then((res) => {
|
||||
this.treeData = res.result.treeList
|
||||
this.allTreeKeys = res.result.ids
|
||||
queryRolePermission({roleId:this.roleId}).then((res)=>{
|
||||
@ -165,4 +181,5 @@
|
||||
background: #fff;
|
||||
border-radius: 0 0 2px 2px;
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user