Former-commit-id: bdcbb26247050d706bad6034abc7f91e905ce568
master
wangbing 5 years ago
parent f947b14c4c
commit 3c3b17e4d1

@ -1,4 +1,4 @@
package xyz.wbsite.module.system.ent;
package ${basePackage}.module.system.ent;
import java.util.ArrayList;
import java.util.List;
@ -12,16 +12,26 @@ import java.util.List;
*/
public class DeptTree extends Dept {
private Long pId;
private String label;
private List<DeptTree> children = new ArrayList<>();
private String value;
public Long getpId() {
return pId;
private List<DeptTree> children;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setpId(Long pId) {
this.pId = pId;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public List<DeptTree> getChildren() {
@ -31,4 +41,9 @@ public class DeptTree extends Dept {
public void setChildren(List<DeptTree> children) {
this.children = children;
}
public void addChild(DeptTree deptTree) {
if (this.children == null) this.children = new ArrayList<>();
this.children.add(deptTree);
}
}

@ -1,18 +1,18 @@
package xyz.wbsite.module.system.mgr;
package ${basePackage}.module.system.mgr;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.module.system.req.DeptCreateRequest;
import xyz.wbsite.module.system.req.DeptDeleteRequest;
import xyz.wbsite.module.system.req.DeptFindRequest;
import xyz.wbsite.module.system.req.DeptGetRequest;
import xyz.wbsite.module.system.req.DeptTreeRequest;
import xyz.wbsite.module.system.req.DeptUpdateRequest;
import xyz.wbsite.module.system.rsp.DeptCreateResponse;
import xyz.wbsite.module.system.rsp.DeptDeleteResponse;
import xyz.wbsite.module.system.rsp.DeptFindResponse;
import xyz.wbsite.module.system.rsp.DeptGetResponse;
import xyz.wbsite.module.system.rsp.DeptTreeResponse;
import xyz.wbsite.module.system.rsp.DeptUpdateResponse;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.req.DeptCreateRequest;
import ${basePackage}.module.system.req.DeptDeleteRequest;
import ${basePackage}.module.system.req.DeptFindRequest;
import ${basePackage}.module.system.req.DeptGetRequest;
import ${basePackage}.module.system.req.DeptTreeRequest;
import ${basePackage}.module.system.req.DeptUpdateRequest;
import ${basePackage}.module.system.rsp.DeptCreateResponse;
import ${basePackage}.module.system.rsp.DeptDeleteResponse;
import ${basePackage}.module.system.rsp.DeptFindResponse;
import ${basePackage}.module.system.rsp.DeptGetResponse;
import ${basePackage}.module.system.rsp.DeptTreeResponse;
import ${basePackage}.module.system.rsp.DeptUpdateResponse;
/**
*

@ -1,35 +1,33 @@
package xyz.wbsite.module.system.mgr;
package ${basePackage}.module.system.mgr;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.SortType;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.utils.IDgenerator;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.utils.Message;
import xyz.wbsite.frame.utils.StringUtil;
import xyz.wbsite.frame.utils.ValidationUtil;
import xyz.wbsite.module.system.ent.Dept;
import xyz.wbsite.module.system.ent.DeptTree;
import xyz.wbsite.module.system.ent.Resource;
import xyz.wbsite.module.system.ent.ResourceTree;
import xyz.wbsite.module.system.mpr.DeptMapper;
import xyz.wbsite.module.system.req.DeptCreateRequest;
import xyz.wbsite.module.system.req.DeptDeleteRequest;
import xyz.wbsite.module.system.req.DeptFindRequest;
import xyz.wbsite.module.system.req.DeptGetRequest;
import xyz.wbsite.module.system.req.DeptTreeRequest;
import xyz.wbsite.module.system.req.DeptUpdateRequest;
import xyz.wbsite.module.system.rsp.DeptCreateResponse;
import xyz.wbsite.module.system.rsp.DeptDeleteResponse;
import xyz.wbsite.module.system.rsp.DeptFindResponse;
import xyz.wbsite.module.system.rsp.DeptGetResponse;
import xyz.wbsite.module.system.rsp.DeptTreeResponse;
import xyz.wbsite.module.system.rsp.DeptUpdateResponse;
import ${basePackage}.frame.base.ErrorType;
import ${basePackage}.frame.base.SortType;
import ${basePackage}.frame.base.Token;
import ${basePackage}.frame.utils.IDgenerator;
import ${basePackage}.frame.utils.MapperUtil;
import ${basePackage}.frame.utils.Message;
import ${basePackage}.frame.utils.StringUtil;
import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.module.system.ent.Dept;
import ${basePackage}.module.system.ent.DeptTree;
import ${basePackage}.module.system.mpr.DeptMapper;
import ${basePackage}.module.system.req.DeptCreateRequest;
import ${basePackage}.module.system.req.DeptDeleteRequest;
import ${basePackage}.module.system.req.DeptFindRequest;
import ${basePackage}.module.system.req.DeptGetRequest;
import ${basePackage}.module.system.req.DeptTreeRequest;
import ${basePackage}.module.system.req.DeptUpdateRequest;
import ${basePackage}.module.system.rsp.DeptCreateResponse;
import ${basePackage}.module.system.rsp.DeptDeleteResponse;
import ${basePackage}.module.system.rsp.DeptFindResponse;
import ${basePackage}.module.system.rsp.DeptGetResponse;
import ${basePackage}.module.system.rsp.DeptTreeResponse;
import ${basePackage}.module.system.rsp.DeptUpdateResponse;
import java.util.ArrayList;
import java.util.HashMap;
@ -245,13 +243,15 @@ public class DeptManagerImpl implements DeptManager {
tree.setId(next.getId());
tree.setDeptCode(next.getDeptCode());
tree.setDeptName(next.getDeptName());
tree.setSupCode(next.getSupCode());
tree.setSupName(next.getSupName());
tree.setDeptAlias(next.getDeptAlias());
tree.setValid(next.getValid());
tree.setRowVersion(next.getRowVersion());
tree.setValue(next.getDeptCode());
tree.setLabel(next.getDeptName());
if (next.getDeptCode() != null && next.getDeptCode().split("_").length == level) {
allMap.put(tree.getDeptCode(), tree);
allMap.put(tree.getValue(), tree);
iterator.remove();
//尝试获取上级资源
String code = next.getDeptCode();
@ -262,8 +262,7 @@ public class DeptManagerImpl implements DeptManager {
if (Ptree != null) break;
}
if (Ptree != null) {
tree.setpId(Ptree.getId());
Ptree.getChildren().add(tree);
Ptree.addChild(tree);
} else {
data.add(tree);
}

@ -49,23 +49,13 @@ public class UserCreateRequest extends BaseRequest {
@Dict(name = "USER_STATUS")
private String userStatus;
/**
*
*/
private Long deptId;
/**
*
*/
@NotEmpty(message = "[deptCode]部门代码不能为空")
@Length(min = 0, max = 50, message = "[deptCode]部门代码长度不合法(0-50)")
private String deptCode;
/**
*
*/
@Length(min = 0, max = 100, message = "[deptName]部门名称长度不合法(0-100)")
private String deptName;
public String getUserName() {
return this.userName;
}
@ -106,14 +96,6 @@ public class UserCreateRequest extends BaseRequest {
this.userStatus = userStatus;
}
public Long getDeptId() {
return this.deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getDeptCode() {
return this.deptCode;
}
@ -121,12 +103,4 @@ public class UserCreateRequest extends BaseRequest {
public void setDeptCode(String deptCode) {
this.deptCode = deptCode;
}
public String getDeptName() {
return this.deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
}

@ -55,23 +55,12 @@ public class UserUpdateRequest extends BaseUpdateRequest {
@Dict(name = "USER_STATUS")
private String userStatus;
/**
*
*/
private Long deptId;
/**
*
*/
@Length(min = 0, max = 50, message = "[deptCode]部门代码长度不合法(0-50)")
private String deptCode;
/**
*
*/
@Length(min = 0, max = 100, message = "[deptName]部门名称长度不合法(0-100)")
private String deptName;
public Long getId() {
return this.id;
}
@ -120,14 +109,6 @@ public class UserUpdateRequest extends BaseUpdateRequest {
this.userStatus = userStatus;
}
public Long getDeptId() {
return this.deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getDeptCode() {
return this.deptCode;
}
@ -135,12 +116,4 @@ public class UserUpdateRequest extends BaseUpdateRequest {
public void setDeptCode(String deptCode) {
this.deptCode = deptCode;
}
public String getDeptName() {
return this.deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,18 +1,18 @@
<script>
jsonService = axios.create({
var jsonService = axios.create({
method: 'post',
timeout: 30000,
baseURL: '',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
});
downloadService = axios.create({
var downloadService = axios.create({
method: 'post',
timeout: 30000,
baseURL: '',
responseType: 'blob',
headers: {'Content-Type': 'application/json;charset=UTF-8'},
});
uploadService = axios.create({
var uploadService = axios.create({
method: 'post',
timeout: 30000,
baseURL: '',
@ -147,99 +147,262 @@
return Promise.resolve(handleError(response.response.status));
})
};
// 定义共享异步请求对象
Vue.prototype.$ajax = {
post: function (config) {
return jsonRequest({
url: "/ajax/" + config["module"] + "/" + config["target"] + "/" + config["method"],
data: JSON.stringify(config["data"]),
})
},
login: function (data) {
return jsonRequest({
url: "/ajax/system/User/login",
data: JSON.stringify(data),
})
},
upload: function (data) {
return upRequest({
url: "/ajax/system/File/upload",
data: data,
})
},
download: function (data) {
return downRequest({
url: "/ajax/system/File/download",
data: JSON.stringify(data),
})
},
create: function (module, target, data) {
return jsonRequest({
url: '/ajax/' + module + "/" + target + "/create",
data: JSON.stringify(data),
})
},
update: function (module, target, data) {
return jsonRequest({
url: '/ajax/' + module + "/" + target + "/update",
data: JSON.stringify(data),
})
},
delete: function (module, target, data) {
return jsonRequest({
url: '/ajax/' + module + "/" + target + "/delete",
data: JSON.stringify(data),
})
},
find: function (module, target, data) {
return jsonRequest({
url: '/ajax/' + module + "/" + target + "/find",
data: JSON.stringify(data),
})
},
get: function (module, target, data) {
return jsonRequest({
url: '/ajax/' + module + "/" + target + "/get",
data: JSON.stringify(data),
})
},
load: function (module, target, data) {
return jsonRequest({
url: '/ajax/' + module + "/" + target + "/load",
data: JSON.stringify(data),
})
},
template: function (module, target, data) {
function Ajax(module, target, method) {
this.mModule = module;
this.mTarget = target;
this.mMethod = method;
this.module = function (module) {
this.mModule = module;
return this;
};
this.target = function (target) {
this.mTarget = target;
return this;
};
this.method = function (method) {
this.mMethod = method;
return this;
};
this.data = function (data) {
this.mData = data;
return this;
};
this.post = function (callback) {
jsonRequest({
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
data: JSON.stringify(this.mData),
}).then(callback)
};
this.create = function (callback) {
this.mMethod = "create";
this.post(callback);
};
this.create = function (callback) {
this.mMethod = "create";
this.post(callback);
};
this.delete = function (callback) {
this.mMethod = "delete";
this.post(callback);
};
this.update = function (callback) {
this.mMethod = "update";
this.post(callback);
};
this.find = function (callback) {
this.mMethod = "find";
this.post(callback);
};
this.get = function (callback) {
this.mMethod = "get";
this.post(callback);
};
this.load = function (callback) {
this.mMethod = "load";
this.post(callback);
};
this.template = function (callback) {
this.mMethod = "template";
return downRequest({
url: "/ajax/" + module + "/" + target + "/template",
data: JSON.stringify(data),
})
},
imports: function (module, target, data) {
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
data: JSON.stringify(this.mData),
}).then(callback)
};
this.imports = function (callback) {
this.mMethod = "imports";
return upRequest({
url: "/ajax/" + module + "/" + target + "/imports",
data: data,
})
},
exports: function (module, target, data) {
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
data: this.mData,
}).then(callback)
};
this.exports = function (callback) {
this.mMethod = "exports";
return downRequest({
url: "/ajax/" + module + "/" + target + "/exports",
data: data,
})
},
};
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
data: JSON.stringify(this.mData),
}).then(callback)
};
}
Vue.config.productionTip = false;
var mixin = {
data: {
activeIndex: 'home',
contextPath: '${context?default("")}',
homePath: '${home?default("")}',
loadingTip: '',
loadingBar: '',
isSubmit: false,
result: [],
select: []
},
methods: {
onSearch: function () {
this.vm.pageNumber = 1;
this.onFind();
},
onReset: function (form) {
this.$refs[form].resetFields();
this.w('重置成功');
},
onPageChange: function (pageNumber) {
this.vm.pageNumber = pageNumber;
this.onFind();
},
onPageSizeChange: function (pageSize) {
this.vm.pageSize = pageSize;
this.onFind();
},
onSelectionChange: function (select) {
this.select = select;
},
onTemplate: function () {
new Ajax()
.module(this.module)
.target(this.target)
.method("template")
.data({})
.template()
},
onImport: function (item) {
utils.selectFile(function (files) {
new Ajax()
.module(this.module)
.target(this.target)
.data(files[0])
.imports();
}.bind(this))
},
onExport: function () {
new Ajax()
.module(this.module)
.target(this.target)
.data( this.vm)
.exports();
},
onSave: function () {
this.$refs['form'].validate(function (valid) {
if (valid) {
if (this.form.id) {
new Ajax()
.module(this.module)
.target(this.target)
.data(this.form)
.update(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
} else {
new Ajax()
.module(this.module)
.target(this.target)
.data(this.form)
.create(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
}
} else {
return false;
}
}.bind(this));
},
onFind: function () {
new Ajax()
.module(this.module)
.target(this.target)
.data(this.vm)
.find(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.result = response.result;
this.vm.totalCount = Number(response.totalCount);
}
}.bind(this))
},
onDelete: function (item) {
this.$confirm('将删除该项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
new Ajax()
.module(this.module)
.target(this.target)
.data({id: item.id})
.delete(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.s("删除成功");
this.onFind();
}
}.bind(this))
}.bind(this)).catch(function (action) {
});
},
onBitchDelete: function () {
if (this.select.length == 0) {
this.w("至少选中一项");
} else {
this.$confirm('将删除已选择的项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
for (var i = 0; i < this.select.length; i++) {
(function (obj) {
new Ajax()
.module(this.module)
.target(this.target)
.data({id: obj.id})
.delete(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
for (var j = 0; j < this.select.length; j++) {
if (this.select[j].id === obj.id) {
this.select.splice(j, 1);
}
}
if (this.select.length === 0) {
this.s("删除成功")
this.onFind();
}
}
}.bind(this))
}.bind(this))(this.select[i]);
}
}.bind(this)).catch(function (action) {
});
}
},
},
created: function () {
},
mounted: function () {
},
filters: {},
watch: {}
};
// 实例化工具
window.nav = new Vue({
data: {
loadingTip: '',
loadingBar: '',
},
methods: {
tipShow: function (msg) {
var message = "<i class='el-icon-loading'></i> 正在加载 ..."
@ -384,137 +547,7 @@
}
})();
},
onSearch: function () {
this.vm.pageNumber = 1;
this.onFind();
},
onReset: function (form) {
this.$refs[form].resetFields();
this.w('重置成功');
},
onPageChange: function (pageNumber) {
this.vm.pageNumber = pageNumber;
this.onFind();
},
onPageSizeChange: function (pageSize) {
this.vm.pageSize = pageSize;
this.onFind();
},
onSelectionChange: function (select) {
this.select = select;
},
onTemplate: function () {
this.$ajax.template(this.module, this.target, {});
},
onImport: function (item) {
utils.selectFile(function (files) {
this.$ajax.imports(this.module, this.target, files[0]);
}.bind(this))
},
onExport: function () {
this.$ajax.exports(this.module, this.target, this.vm);
},
onSave: function () {
this.$refs['form'].validate(function (valid) {
if (valid) {
if (this.form.id) {
this.$ajax.update(this.module, this.target, this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
} else {
this.$ajax.create(this.module, this.target, this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
}
} else {
return false;
}
}.bind(this));
},
onFind: function () {
this.$ajax.find(this.module, this.target, this.vm).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.result = response.result;
this.vm.totalCount = Number(response.totalCount);
}
}.bind(this))
},
onDelete: function (item) {
this.$confirm('将删除该项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
this.$ajax.delete(this.module, this.target, {id: item.id}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.s("删除成功");
this.onFind();
}
}.bind(this));
}.bind(this)).catch(function (action) {
});
},
onBitchDelete: function () {
if (this.select.length == 0) {
this.w("至少选中一项");
} else {
this.$confirm('将删除已选择的项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
for (var i = 0; i < this.select.length; i++) {
(function (obj) {
this.$ajax.delete(this.module, this.target, {id: obj.id}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
for (var j = 0; j < this.select.length; j++) {
if (this.select[j].id === obj.id) {
this.select.splice(j, 1);
}
}
if (this.select.length === 0) {
this.s("删除成功")
this.onFind();
}
}
}.bind(this))
}.bind(this))(this.select[i]);
}
}.bind(this)).catch(function (action) {
});
}
},
},
created: function () {
},
mounted: function () {
},
filters: {},
watch: {}
};
// 实例化工具
window.nav = new Vue({
mixins: [mixin]
}
});
//字典组件
Vue.component('el-input-dict', {
@ -548,13 +581,18 @@
},
created: function () {
if (this.dictName) {
this.$ajax.load("system", "dict", {dictName: this.dictName}).then(function (response) {
if (response.errors.length > 0) {
console.error(response.errors[0].message)
} else {
this.options = response.dictItems;
}
}.bind(this))
new Ajax()
.module("system")
.target("dict")
.method("load")
.data({dictName: this.dictName})
.post(function (response) {
if (response.errors.length > 0) {
console.error(response.errors[0].message)
} else {
this.options = response.dictItems;
}
}.bind(this))
}
},
template: '' +
@ -564,5 +602,65 @@
' <span style="float: right; color: #8492a6; font-size: 12px">{{ item.key }}</span>' +
' </el-option>' +
'</el-select>'
});
//机构选择
Vue.component('el-input-dept', {
data: function () {
return {
options: [],
props:{
multiple: false,
checkStrictly: true
}
}
},
props: {
value: {
type: String,
default: ''
},
size: {
type: String,
default: 'small'
},
clearable: {
type: Boolean,
default: true
},
placeholder: {
type: String,
default: ''
},
},
methods: {
input: function (value) {
this.$emit('input', value);
}
},
created: function () {
new Ajax()
.module("system")
.target("dept")
.method("tree")
.data({dictName: this.dictName})
.post(function (response) {
if (response.errors.length > 0) {
console.error(response.errors[0].message)
} else {
this.options = response.result;
}
}.bind(this))
},
template: '' +
'<el-cascader ' +
' @input="input" ' +
' :show-all-levels="false" ' +
' :options="options" ' +
' :clearable="clearable" ' +
' :size="size" ' +
' :props="props" ' +
' filterable ' +
' :placeholder="placeholder">' +
'</el-cascader>'
})
</script>

@ -116,16 +116,21 @@
this.$refs[formName].validate(function (valid) {
if (valid) {
this.isSubmit = true;
this.$ajax.login(this.form).then(function (response) {
this.isSubmit = false;
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.i("登录成功!", function () {
location.href = "/"
});
}
}.bind(this))
new Ajax()
.module("system")
.target("user")
.method("login")
.data(this.form)
.post(function (response) {
this.isSubmit = false;
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.i("登录成功!", function () {
location.href = "/"
});
}
}.bind(this));
} else {
return false;
}

@ -80,6 +80,15 @@
label="主键"
width="140">
</el-table-column>
<el-table-column
align="center"
width="80"
label="是否有效">
<template slot-scope="scope">
<el-tag size="mini" v-if="scope.row.valid">有效</el-tag>
<el-tag size="mini" type="danger" v-if="!scope.row.valid">无效</el-tag>
</template>
</el-table-column>
<el-table-column
align="center"
prop="deptCode"
@ -105,11 +114,6 @@
prop="supName"
label="上级名称">
</el-table-column>
<el-table-column
align="center"
prop="valid"
label="是否有效">
</el-table-column>
<el-table-column
align="center"
prop="createTime"
@ -177,7 +181,7 @@
:filter-node-method="filterTree"
:expand-on-click-node="false">
<div class="tree" slot-scope="{ node, data }">
<span>{{ data.deptName }}<span style="color: #409EFF">[{{data.deptCode}}]</span></span>
<span>{{ data.label }}<span style="color: #409EFF">[{{data.value}}]</span></span>
<span>
<el-button
icon="el-icon-plus"
@ -298,7 +302,7 @@
this.form.title = "部门新增";
this.form.dialog = true;
this.form.id = "";
this.form.deptCode = pItem.deptCode + "_";
this.form.deptCode = pItem.value + "_";
this.form.deptName = "";
this.form.deptAlias = "";
this.form.valid = true;
@ -343,44 +347,52 @@
}
},
onLoadTree: function () {
this.$ajax.post({
module: this.module,
target: this.target,
method: "tree",
data: {}
}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.treeData = response.result;
}
}.bind(this))
new Ajax()
.module("system")
.target("dept")
.method("tree")
.data({})
.post(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.treeData = response.result;
}
}.bind(this))
},
onSave: function () {
this.$refs['form'].validate(function (valid) {
if (valid) {
if (this.form.id) {
this.$ajax.update(this.module, this.target, this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.onLoadTree();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
new Ajax()
.module(this.module)
.target(this.target)
.data(this.form)
.update(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.onLoadTree();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
} else {
this.$ajax.create(this.module, this.target, this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.onLoadTree();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
new Ajax()
.module(this.module)
.target(this.target)
.data(this.form)
.create(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.onLoadTree();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
}
} else {
return false;

@ -237,7 +237,7 @@
break;
case "view":
if (!parent || !parent.index) {
this.e("找不到上级页面!");
nav.e("找不到上级页面!");
} else {
parent.index.addTab({
title: "字典项管理",

@ -150,7 +150,8 @@
<el-row>
<el-col :span="12">
<el-input v-model="treeKeyword" clearable size="mini" placeholder="请输入资源内容" @change="onChange" style="width: 200px;" ></el-input>
<el-input v-model="treeKeyword" clearable size="mini" placeholder="请输入资源内容" @change="onChange"
style="width: 200px;"></el-input>
</el-col>
<el-col :span="12">
<el-button-group style="float: right;">
@ -323,10 +324,10 @@
this.form.valid = pItem.valid;
this.form.rowVersion = pItem.rowVersion;
},
onChange:function (value) {
onChange: function (value) {
this.$refs.tree.filter(value);
},
filterTree:function (value, data) {
filterTree: function (value, data) {
if (!value) return true;
return data.comment.indexOf(value) !== -1;
},
@ -354,44 +355,52 @@
}
},
onLoadTree: function () {
this.$ajax.post({
module: "system",
target: "resource",
method: "tree",
data: {}
}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.treeData = response.result;
}
}.bind(this))
new Ajax()
.module("system")
.target("resource")
.method("tree")
.data({})
.post(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.treeData = response.result;
}
}.bind(this))
},
onSave: function () {
this.$refs['form'].validate(function (valid) {
if (valid) {
if (this.form.id) {
this.$ajax.update(this.module, this.target, this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.onLoadTree();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
new Ajax()
.module(this.module)
.target(this.target)
.data( this.form)
.update(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.onLoadTree();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
} else {
this.$ajax.create(this.module, this.target, this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.onLoadTree();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
new Ajax()
.module(this.module)
.target(this.target)
.data( this.form)
.create(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.onLoadTree();
this.$refs['form'].resetFields();
this.form.dialog = false;
}
}.bind(this))
}
} else {
return false;
@ -400,7 +409,7 @@
},
},
watch: {
treeKeyword:function(val) {
treeKeyword: function (val) {
this.$refs.tree.filter(val);
}
},

@ -226,18 +226,22 @@
this.formResource.title = "分配资源";
this.formResource.dialog = true;
this.formResource.roleId = item.id
this.$ajax.find("system", "roleResource", {roleId: item.id, pageSize: 0}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.$refs.tree.setCheckedKeys([]);
var ids = [];
for (var i = 0; i < response.result.length; i++) {
ids.push(response.result[i].resourceId);
}
this.$refs.tree.setCheckedKeys(ids);
}
}.bind(this));
new Ajax()
.module("system")
.target("roleResource")
.data({roleId: item.id, pageSize: 0})
.find(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.$refs.tree.setCheckedKeys([]);
var ids = [];
for (var i = 0; i < response.result.length; i++) {
ids.push(response.result[i].resourceId);
}
this.$refs.tree.setCheckedKeys(ids);
}
}.bind(this))
break;
case "delete":
this.onDelete(item);
@ -248,36 +252,36 @@
}
},
onCheck: function (item, status) {
this.$ajax.post({
module: "system",
target: "roleResource",
method: "check",
data: {
roleId: this.formResource.roleId,
resourceId: item.id,
checked: status.checkedKeys.indexOf(item.id) !== -1,
}
}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
new Ajax()
.module("system")
.target("roleResource")
.method("check")
.data({
roleId: this.formResource.roleId,
resourceId: item.id,
checked: status.checkedKeys.indexOf(item.id) !== -1,
})
.find(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
}
}.bind(this))
}
}.bind(this))
},
onLoadTree: function () {
this.$ajax.post({
module: "system",
target: "resource",
method: "tree",
data: {}
}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.treeData = response.result;
}
}.bind(this))
new Ajax()
.module("system")
.target("resource")
.method("tree")
.data({})
.post(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.treeData = response.result;
}
}.bind(this))
},
},
mounted: function () {

@ -261,21 +261,19 @@
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
this.$ajax.post({
module: "system",
target: "tokens",
method: "logout",
data: {
token: item.token
}
}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.s("注销成功");
this.onFind();
}
}.bind(this));
new Ajax()
.module("system")
.target("tokens")
.method("logout")
.data({token: item.token})
.post(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.s("注销成功");
this.onFind();
}
}.bind(this))
}.bind(this)).catch(function (action) {
});

@ -14,14 +14,8 @@
<el-form-item label="用户状态" prop="userStatus">
<el-input-dict v-model="vm.userStatus" clearable size="small" placeholder="请输入用户状态" dict-name="USER_STATUS"></el-input-dict>
</el-form-item>
<el-form-item label="部门主键" prop="deptId">
<el-input-number v-model="vm.deptId" clearable size="small" placeholder="请输入部门主键" :step="1" step-strictly></el-input-number>
</el-form-item>
<el-form-item label="部门代码" prop="deptCode">
<el-input v-model="vm.deptCode" clearable size="small" placeholder="请输入部门代码"></el-input>
</el-form-item>
<el-form-item label="部门名称" prop="deptName">
<el-input v-model="vm.deptName" clearable size="small" placeholder="请输入部门名称"></el-input>
<el-form-item label="部门机构" prop="deptCode">
<el-input-dept clearable size="small"></el-input-dept>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" icon="el-icon-search" @click="onSearch">搜索</el-button>
@ -101,20 +95,10 @@
prop="userStatus"
label="用户状态">
</el-table-column>
<el-table-column
align="center"
prop="deptId"
label="部门主键">
</el-table-column>
<el-table-column
align="center"
prop="deptCode"
label="部门代码">
</el-table-column>
<el-table-column
align="center"
prop="deptName"
label="部门名称">
label="所在部门">
</el-table-column>
<el-table-column
align="center"
@ -168,11 +152,8 @@
<el-form-item label="用户状态" prop="userStatus">
<el-input-dict v-model="form.userStatus" clearable size="small" placeholder="请输入用户状态" dict-name="USER_STATUS"></el-input-dict>
</el-form-item>
<el-form-item label="部门机构" prop="deptId">
<el-cascader
:options="deptList"
:props="{ checkStrictly: true }"
clearable></el-cascader>
<el-form-item label="部门机构" prop="deptCode">
<el-input-dept clearable size="small"></el-input-dept>
</el-form-item>
<el-form-item label="用户角色" prop="roleList">
<el-transfer v-model="form.roleList" :data="roleList" :titles="['未选角色','已选角色']"></el-transfer>
@ -246,8 +227,7 @@
{min: 1, max: 100, message: '部门名称长度在 1 到 100 个字符', trigger: 'blur'}
],
},
roleList: [],
deptList: []
roleList: []
},
methods: {
onCreate: function () {
@ -290,36 +270,27 @@
}
},
loadRoles: function () {
this.$ajax.find("system", "role", {pageSize: 0}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.roleList = response.result;
for (var i = 0; i < this.roleList.length; i++) {
this.roleList[i].key = this.roleList[i].id;
this.roleList[i].label = this.roleList[i].name;
}
}
}.bind(this))
new Ajax()
.module("system")
.target("role")
.method("find")
.data({pageSize: 0})
.post(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.roleList = response.result;
for (var i = 0; i < this.roleList.length; i++) {
this.roleList[i].key = this.roleList[i].id;
this.roleList[i].label = this.roleList[i].name;
}
}
}.bind(this))
},
loadDepts: function () {
this.$ajax.find("system", "dept", {pageSize: 0}).then(function (response) {
if (response.errors.length > 0) {
this.e(response.errors[0].message);
} else {
this.deptList = response.result;
for (var i = 0; i < this.deptList.length; i++) {
this.deptList[i].key = this.deptList[i].id;
this.deptList[i].label = this.deptList[i].name;
}
}
}.bind(this))
}
},
mounted: function () {
this.onFind();
this.loadRoles();
this.loadDepts();
},
})
</script>

@ -6,10 +6,18 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import ${basePackage}.frame.base.Token;
import ${basePackage}.module.system.mgr.UserManager;
import ${basePackage}.module.system.req.*;
import ${basePackage}.module.system.rsp.*;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.module.system.mgr.UserManager;
import xyz.wbsite.module.system.req.UserCreateRequest;
import xyz.wbsite.module.system.req.UserDeleteRequest;
import xyz.wbsite.module.system.req.UserFindRequest;
import xyz.wbsite.module.system.req.UserGetRequest;
import xyz.wbsite.module.system.req.UserUpdateRequest;
import xyz.wbsite.module.system.rsp.UserCreateResponse;
import xyz.wbsite.module.system.rsp.UserDeleteResponse;
import xyz.wbsite.module.system.rsp.UserFindResponse;
import xyz.wbsite.module.system.rsp.UserGetResponse;
import xyz.wbsite.module.system.rsp.UserUpdateResponse;
import static org.junit.Assert.assertTrue;
@ -35,16 +43,14 @@ public class UserTest {
@Test
public void testCreate() {
UserCreateRequest request = new UserCreateRequest();
request.setUserName("用户账户");
request.setUserCode("用户代码");
request.setUserAlias("用户别名");
request.setUserPwd("用户密码");
request.setUserName("test");
request.setUserCode("");
request.setUserAlias("test");
request.setUserPwd("123456");
request.setUserStatus("code");
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
request.setDeptCode("A01");
UserCreateResponse response = userManager.create(request,token);
UserCreateResponse response = userManager.create(request, token);
assertTrue(!response.hasError());
}
@ -54,23 +60,21 @@ public class UserTest {
//创建数据
UserCreateRequest createRequest = new UserCreateRequest();
createRequest.setUserName("用户账户");
createRequest.setUserCode("用户代码");
createRequest.setUserAlias("用户别名");
createRequest.setUserPwd("用户密码");
createRequest.setUserName("test");
createRequest.setUserCode("");
createRequest.setUserAlias("test");
createRequest.setUserPwd("123456");
createRequest.setUserStatus("code");
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setDeptCode("A01");
UserCreateResponse createResponse = userManager.create(createRequest,token);
UserCreateResponse createResponse = userManager.create(createRequest, token);
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
//删除数据
UserDeleteRequest request = new UserDeleteRequest();
request.setId(createResponse.getId());
UserDeleteResponse response = userManager.delete(request,token);
UserDeleteResponse response = userManager.delete(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@ -79,14 +83,12 @@ public class UserTest {
public void testUpdate() {
//创建数据
UserCreateRequest createRequest = new UserCreateRequest();
createRequest.setUserName("用户账户");
createRequest.setUserCode("用户代码");
createRequest.setUserAlias("用户别名");
createRequest.setUserPwd("用户密码");
createRequest.setUserName("test");
createRequest.setUserCode("");
createRequest.setUserAlias("test");
createRequest.setUserPwd("123456");
createRequest.setUserStatus("code");
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setDeptCode("A01");
UserCreateResponse createResponse = userManager.create(createRequest, token);
@ -95,16 +97,14 @@ public class UserTest {
//更新数据
UserUpdateRequest request = new UserUpdateRequest();
request.setId(createResponse.getId());
request.setUserName("用户账户");
request.setUserCode("用户代码");
request.setUserAlias("用户别名");
request.setUserPwd("用户密码");
request.setUserName("test");
request.setUserCode("");
request.setUserAlias("test");
request.setUserPwd("123456");
request.setUserStatus("code");
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptName("部门名称");
request.setDeptCode("A01");
UserUpdateResponse response = userManager.update(request,token);
UserUpdateResponse response = userManager.update(request, token);
assertTrue(!response.hasError() && response.getResult() == 1L);
}
@ -112,15 +112,15 @@ public class UserTest {
@Test
public void testFind() {
UserFindRequest request = new UserFindRequest();
request.setUserName("用户账户");
request.setUserCode("用户代码");
request.setUserAlias("用户别名");
request.setUserName("test");
request.setUserCode("");
request.setUserAlias("test");
request.setUserStatus("code");
request.setDeptId(1L);
request.setDeptCode("部门代码");
request.setDeptCode("A01");
request.setDeptName("部门名称");
UserFindResponse response = userManager.find(request,token);
UserFindResponse response = userManager.find(request, token);
assertTrue(!response.hasError());
}
@ -129,14 +129,12 @@ public class UserTest {
public void testGet() {
//创建数据
UserCreateRequest createRequest = new UserCreateRequest();
createRequest.setUserName("用户账户");
createRequest.setUserCode("用户代码");
createRequest.setUserAlias("用户别名");
createRequest.setUserPwd("用户密码");
createRequest.setUserName("test");
createRequest.setUserCode("");
createRequest.setUserAlias("test");
createRequest.setUserPwd("123456");
createRequest.setUserStatus("code");
createRequest.setDeptId(1L);
createRequest.setDeptCode("部门代码");
createRequest.setDeptName("部门名称");
createRequest.setDeptCode("A01");
UserCreateResponse createResponse = userManager.create(createRequest, token);
@ -146,7 +144,7 @@ public class UserTest {
UserGetRequest request = new UserGetRequest();
request.setId(createResponse.getId());
UserGetResponse response = userManager.get(request,token);
UserGetResponse response = userManager.get(request, token);
assertTrue(!response.hasError() && response.getUser() != null);
}

Loading…
Cancel
Save

Powered by TurnKey Linux.