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.ArrayList;
import java.util.List; import java.util.List;
@ -12,16 +12,26 @@ import java.util.List;
*/ */
public class DeptTree extends Dept { public class DeptTree extends Dept {
private Long pId; private String label;
private List<DeptTree> children = new ArrayList<>(); private String value;
public Long getpId() { private List<DeptTree> children;
return pId;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
} }
public void setpId(Long pId) { public String getValue() {
this.pId = pId; return value;
}
public void setValue(String value) {
this.value = value;
} }
public List<DeptTree> getChildren() { public List<DeptTree> getChildren() {
@ -31,4 +41,9 @@ public class DeptTree extends Dept {
public void setChildren(List<DeptTree> children) { public void setChildren(List<DeptTree> children) {
this.children = 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 ${basePackage}.frame.base.Token;
import xyz.wbsite.module.system.req.DeptCreateRequest; import ${basePackage}.module.system.req.DeptCreateRequest;
import xyz.wbsite.module.system.req.DeptDeleteRequest; import ${basePackage}.module.system.req.DeptDeleteRequest;
import xyz.wbsite.module.system.req.DeptFindRequest; import ${basePackage}.module.system.req.DeptFindRequest;
import xyz.wbsite.module.system.req.DeptGetRequest; import ${basePackage}.module.system.req.DeptGetRequest;
import xyz.wbsite.module.system.req.DeptTreeRequest; import ${basePackage}.module.system.req.DeptTreeRequest;
import xyz.wbsite.module.system.req.DeptUpdateRequest; import ${basePackage}.module.system.req.DeptUpdateRequest;
import xyz.wbsite.module.system.rsp.DeptCreateResponse; import ${basePackage}.module.system.rsp.DeptCreateResponse;
import xyz.wbsite.module.system.rsp.DeptDeleteResponse; import ${basePackage}.module.system.rsp.DeptDeleteResponse;
import xyz.wbsite.module.system.rsp.DeptFindResponse; import ${basePackage}.module.system.rsp.DeptFindResponse;
import xyz.wbsite.module.system.rsp.DeptGetResponse; import ${basePackage}.module.system.rsp.DeptGetResponse;
import xyz.wbsite.module.system.rsp.DeptTreeResponse; import ${basePackage}.module.system.rsp.DeptTreeResponse;
import xyz.wbsite.module.system.rsp.DeptUpdateResponse; 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.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import xyz.wbsite.frame.base.ErrorType; import ${basePackage}.frame.base.ErrorType;
import xyz.wbsite.frame.base.SortType; import ${basePackage}.frame.base.SortType;
import xyz.wbsite.frame.base.Token; import ${basePackage}.frame.base.Token;
import xyz.wbsite.frame.utils.IDgenerator; import ${basePackage}.frame.utils.IDgenerator;
import xyz.wbsite.frame.utils.MapperUtil; import ${basePackage}.frame.utils.MapperUtil;
import xyz.wbsite.frame.utils.Message; import ${basePackage}.frame.utils.Message;
import xyz.wbsite.frame.utils.StringUtil; import ${basePackage}.frame.utils.StringUtil;
import xyz.wbsite.frame.utils.ValidationUtil; import ${basePackage}.frame.utils.ValidationUtil;
import xyz.wbsite.module.system.ent.Dept; import ${basePackage}.module.system.ent.Dept;
import xyz.wbsite.module.system.ent.DeptTree; import ${basePackage}.module.system.ent.DeptTree;
import xyz.wbsite.module.system.ent.Resource; import ${basePackage}.module.system.mpr.DeptMapper;
import xyz.wbsite.module.system.ent.ResourceTree; import ${basePackage}.module.system.req.DeptCreateRequest;
import xyz.wbsite.module.system.mpr.DeptMapper; import ${basePackage}.module.system.req.DeptDeleteRequest;
import xyz.wbsite.module.system.req.DeptCreateRequest; import ${basePackage}.module.system.req.DeptFindRequest;
import xyz.wbsite.module.system.req.DeptDeleteRequest; import ${basePackage}.module.system.req.DeptGetRequest;
import xyz.wbsite.module.system.req.DeptFindRequest; import ${basePackage}.module.system.req.DeptTreeRequest;
import xyz.wbsite.module.system.req.DeptGetRequest; import ${basePackage}.module.system.req.DeptUpdateRequest;
import xyz.wbsite.module.system.req.DeptTreeRequest; import ${basePackage}.module.system.rsp.DeptCreateResponse;
import xyz.wbsite.module.system.req.DeptUpdateRequest; import ${basePackage}.module.system.rsp.DeptDeleteResponse;
import xyz.wbsite.module.system.rsp.DeptCreateResponse; import ${basePackage}.module.system.rsp.DeptFindResponse;
import xyz.wbsite.module.system.rsp.DeptDeleteResponse; import ${basePackage}.module.system.rsp.DeptGetResponse;
import xyz.wbsite.module.system.rsp.DeptFindResponse; import ${basePackage}.module.system.rsp.DeptTreeResponse;
import xyz.wbsite.module.system.rsp.DeptGetResponse; import ${basePackage}.module.system.rsp.DeptUpdateResponse;
import xyz.wbsite.module.system.rsp.DeptTreeResponse;
import xyz.wbsite.module.system.rsp.DeptUpdateResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -245,13 +243,15 @@ public class DeptManagerImpl implements DeptManager {
tree.setId(next.getId()); tree.setId(next.getId());
tree.setDeptCode(next.getDeptCode()); tree.setDeptCode(next.getDeptCode());
tree.setDeptName(next.getDeptName()); tree.setDeptName(next.getDeptName());
tree.setSupCode(next.getSupCode()); tree.setDeptAlias(next.getDeptAlias());
tree.setSupName(next.getSupName());
tree.setValid(next.getValid()); tree.setValid(next.getValid());
tree.setRowVersion(next.getRowVersion()); tree.setRowVersion(next.getRowVersion());
tree.setValue(next.getDeptCode());
tree.setLabel(next.getDeptName());
if (next.getDeptCode() != null && next.getDeptCode().split("_").length == level) { if (next.getDeptCode() != null && next.getDeptCode().split("_").length == level) {
allMap.put(tree.getDeptCode(), tree); allMap.put(tree.getValue(), tree);
iterator.remove(); iterator.remove();
//尝试获取上级资源 //尝试获取上级资源
String code = next.getDeptCode(); String code = next.getDeptCode();
@ -262,8 +262,7 @@ public class DeptManagerImpl implements DeptManager {
if (Ptree != null) break; if (Ptree != null) break;
} }
if (Ptree != null) { if (Ptree != null) {
tree.setpId(Ptree.getId()); Ptree.addChild(tree);
Ptree.getChildren().add(tree);
} else { } else {
data.add(tree); data.add(tree);
} }

@ -49,23 +49,13 @@ public class UserCreateRequest extends BaseRequest {
@Dict(name = "USER_STATUS") @Dict(name = "USER_STATUS")
private String userStatus; private String userStatus;
/**
*
*/
private Long deptId;
/** /**
* *
*/ */
@NotEmpty(message = "[deptCode]部门代码不能为空")
@Length(min = 0, max = 50, message = "[deptCode]部门代码长度不合法(0-50)") @Length(min = 0, max = 50, message = "[deptCode]部门代码长度不合法(0-50)")
private String deptCode; private String deptCode;
/**
*
*/
@Length(min = 0, max = 100, message = "[deptName]部门名称长度不合法(0-100)")
private String deptName;
public String getUserName() { public String getUserName() {
return this.userName; return this.userName;
} }
@ -106,14 +96,6 @@ public class UserCreateRequest extends BaseRequest {
this.userStatus = userStatus; this.userStatus = userStatus;
} }
public Long getDeptId() {
return this.deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getDeptCode() { public String getDeptCode() {
return this.deptCode; return this.deptCode;
} }
@ -121,12 +103,4 @@ public class UserCreateRequest extends BaseRequest {
public void setDeptCode(String deptCode) { public void setDeptCode(String deptCode) {
this.deptCode = 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") @Dict(name = "USER_STATUS")
private String userStatus; private String userStatus;
/**
*
*/
private Long deptId;
/** /**
* *
*/ */
@Length(min = 0, max = 50, message = "[deptCode]部门代码长度不合法(0-50)") @Length(min = 0, max = 50, message = "[deptCode]部门代码长度不合法(0-50)")
private String deptCode; private String deptCode;
/**
*
*/
@Length(min = 0, max = 100, message = "[deptName]部门名称长度不合法(0-100)")
private String deptName;
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
@ -120,14 +109,6 @@ public class UserUpdateRequest extends BaseUpdateRequest {
this.userStatus = userStatus; this.userStatus = userStatus;
} }
public Long getDeptId() {
return this.deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getDeptCode() { public String getDeptCode() {
return this.deptCode; return this.deptCode;
} }
@ -135,12 +116,4 @@ public class UserUpdateRequest extends BaseUpdateRequest {
public void setDeptCode(String deptCode) { public void setDeptCode(String deptCode) {
this.deptCode = 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> <script>
jsonService = axios.create({ var jsonService = axios.create({
method: 'post', method: 'post',
timeout: 30000, timeout: 30000,
baseURL: '', baseURL: '',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, headers: {'Content-Type': 'application/json;charset=UTF-8'},
}); });
downloadService = axios.create({ var downloadService = axios.create({
method: 'post', method: 'post',
timeout: 30000, timeout: 30000,
baseURL: '', baseURL: '',
responseType: 'blob', responseType: 'blob',
headers: {'Content-Type': 'application/json;charset=UTF-8'}, headers: {'Content-Type': 'application/json;charset=UTF-8'},
}); });
uploadService = axios.create({ var uploadService = axios.create({
method: 'post', method: 'post',
timeout: 30000, timeout: 30000,
baseURL: '', baseURL: '',
@ -147,99 +147,262 @@
return Promise.resolve(handleError(response.response.status)); return Promise.resolve(handleError(response.response.status));
}) })
}; };
// 定义共享异步请求对象 function Ajax(module, target, method) {
Vue.prototype.$ajax = { this.mModule = module;
post: function (config) { this.mTarget = target;
return jsonRequest({ this.mMethod = method;
url: "/ajax/" + config["module"] + "/" + config["target"] + "/" + config["method"],
data: JSON.stringify(config["data"]), this.module = function (module) {
}) this.mModule = module;
}, return this;
login: function (data) { };
return jsonRequest({ this.target = function (target) {
url: "/ajax/system/User/login", this.mTarget = target;
data: JSON.stringify(data), return this;
}) };
}, this.method = function (method) {
upload: function (data) { this.mMethod = method;
return upRequest({ return this;
url: "/ajax/system/File/upload", };
data: data, this.data = function (data) {
}) this.mData = data;
}, return this;
download: function (data) { };
return downRequest({ this.post = function (callback) {
url: "/ajax/system/File/download", jsonRequest({
data: JSON.stringify(data), url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
}) data: JSON.stringify(this.mData),
}, }).then(callback)
create: function (module, target, data) { };
return jsonRequest({ this.create = function (callback) {
url: '/ajax/' + module + "/" + target + "/create", this.mMethod = "create";
data: JSON.stringify(data), this.post(callback);
}) };
}, this.create = function (callback) {
update: function (module, target, data) { this.mMethod = "create";
return jsonRequest({ this.post(callback);
url: '/ajax/' + module + "/" + target + "/update", };
data: JSON.stringify(data), this.delete = function (callback) {
}) this.mMethod = "delete";
}, this.post(callback);
delete: function (module, target, data) { };
return jsonRequest({ this.update = function (callback) {
url: '/ajax/' + module + "/" + target + "/delete", this.mMethod = "update";
data: JSON.stringify(data), this.post(callback);
}) };
}, this.find = function (callback) {
find: function (module, target, data) { this.mMethod = "find";
return jsonRequest({ this.post(callback);
url: '/ajax/' + module + "/" + target + "/find", };
data: JSON.stringify(data), this.get = function (callback) {
}) this.mMethod = "get";
}, this.post(callback);
get: function (module, target, data) { };
return jsonRequest({ this.load = function (callback) {
url: '/ajax/' + module + "/" + target + "/get", this.mMethod = "load";
data: JSON.stringify(data), this.post(callback);
}) };
}, this.template = function (callback) {
load: function (module, target, data) { this.mMethod = "template";
return jsonRequest({
url: '/ajax/' + module + "/" + target + "/load",
data: JSON.stringify(data),
})
},
template: function (module, target, data) {
return downRequest({ return downRequest({
url: "/ajax/" + module + "/" + target + "/template", url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
data: JSON.stringify(data), data: JSON.stringify(this.mData),
}) }).then(callback)
}, };
imports: function (module, target, data) { this.imports = function (callback) {
this.mMethod = "imports";
return upRequest({ return upRequest({
url: "/ajax/" + module + "/" + target + "/imports", url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
data: data, data: this.mData,
}) }).then(callback)
}, };
exports: function (module, target, data) { this.exports = function (callback) {
this.mMethod = "exports";
return downRequest({ return downRequest({
url: "/ajax/" + module + "/" + target + "/exports", url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
data: data, data: JSON.stringify(this.mData),
}) }).then(callback)
}, };
}; }
Vue.config.productionTip = false; Vue.config.productionTip = false;
var mixin = { var mixin = {
data: { data: {
activeIndex: 'home', activeIndex: 'home',
contextPath: '${context?default("")}', contextPath: '${context?default("")}',
homePath: '${home?default("")}', homePath: '${home?default("")}',
loadingTip: '',
loadingBar: '',
isSubmit: false, isSubmit: false,
result: [], result: [],
select: [] 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: { methods: {
tipShow: function (msg) { tipShow: function (msg) {
var message = "<i class='el-icon-loading'></i> 正在加载 ..." 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', { Vue.component('el-input-dict', {
@ -548,13 +581,18 @@
}, },
created: function () { created: function () {
if (this.dictName) { if (this.dictName) {
this.$ajax.load("system", "dict", {dictName: this.dictName}).then(function (response) { new Ajax()
if (response.errors.length > 0) { .module("system")
console.error(response.errors[0].message) .target("dict")
} else { .method("load")
this.options = response.dictItems; .data({dictName: this.dictName})
} .post(function (response) {
}.bind(this)) if (response.errors.length > 0) {
console.error(response.errors[0].message)
} else {
this.options = response.dictItems;
}
}.bind(this))
} }
}, },
template: '' + template: '' +
@ -564,5 +602,65 @@
' <span style="float: right; color: #8492a6; font-size: 12px">{{ item.key }}</span>' + ' <span style="float: right; color: #8492a6; font-size: 12px">{{ item.key }}</span>' +
' </el-option>' + ' </el-option>' +
'</el-select>' '</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> </script>

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

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

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

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

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

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

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

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

Loading…
Cancel
Save

Powered by TurnKey Linux.