mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 18:22:11 +08:00
完成字典,组织去vue
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
layui.config({
|
||||
base: "/js/"
|
||||
}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth','utils'], function () {
|
||||
}).use(['form', 'vue', 'ztree', 'layer', 'jquery', 'table', 'droptree', 'openauth', 'utils'], function () {
|
||||
var form = layui.form,
|
||||
layer = layui.layer,
|
||||
$ = layui.jquery;
|
||||
@@ -9,33 +9,41 @@ layui.config({
|
||||
|
||||
$("#menus").loadMenus("Category");
|
||||
|
||||
var initVal = { //初始化的值
|
||||
Id: '',
|
||||
Name: '',
|
||||
TypeName: '',
|
||||
TypeId: '',
|
||||
Description: ''
|
||||
}
|
||||
|
||||
//加载表头
|
||||
$.getJSON('/Categories/All',
|
||||
{ page: 1, limit: 1 },
|
||||
function(data) {
|
||||
var columns = data.columnFields.filter(u => u.IsList ===true).map(function (e) {
|
||||
{page: 1, limit: 1},
|
||||
function (data) {
|
||||
var columns = data.columnFields.filter(u => u.IsList === true).map(function (e) {
|
||||
return {
|
||||
field: e.ColumnName,
|
||||
title: e.Comment
|
||||
};
|
||||
});
|
||||
columns.unshift({
|
||||
type: 'checkbox',
|
||||
fixed: 'left'
|
||||
});
|
||||
table.render({
|
||||
elem: '#mainList',
|
||||
page: true,
|
||||
url: '/Categories/All',
|
||||
cols: [columns]
|
||||
, response: {
|
||||
statusCode: 200 //规定成功的状态码,默认:0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
columns.unshift({
|
||||
type: 'checkbox',
|
||||
fixed: 'left'
|
||||
});
|
||||
table.render({
|
||||
elem: '#mainList',
|
||||
page: true,
|
||||
url: '/Categories/All',
|
||||
cols: [columns]
|
||||
, response: {
|
||||
statusCode: 200 //规定成功的状态码,默认:0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//主列表加载,可反复调用进行刷新
|
||||
var config= {}; //table的参数,如搜索key,点击tree的id
|
||||
var config = {}; //table的参数,如搜索key,点击tree的id
|
||||
var mainList = function (options) {
|
||||
if (options != undefined) {
|
||||
$.extend(config, options);
|
||||
@@ -45,49 +53,26 @@ layui.config({
|
||||
where: config
|
||||
, response: {
|
||||
statusCode: 200 //规定成功的状态码,默认:0
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//添加(编辑)对话框
|
||||
var editDlg = function() {
|
||||
var vm;
|
||||
var update = false; //是否为更新
|
||||
var show = function (data) {
|
||||
var editDlg = function () {
|
||||
var show = function (update, data) {
|
||||
var title = update ? "编辑信息" : "添加";
|
||||
layer.open({
|
||||
title: title,
|
||||
area: ["500px", "400px"],
|
||||
type: 1,
|
||||
content: $('#divEdit'),
|
||||
success: function() {
|
||||
if(vm == undefined){
|
||||
vm = new Vue({
|
||||
el: "#formEdit",
|
||||
data(){
|
||||
return {
|
||||
tmp:data //使用一个tmp封装一下,后面可以直接用vm.tmp赋值
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
tmp(val){
|
||||
this.$nextTick(function () {
|
||||
form.render(); //刷新select等
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
form.render();
|
||||
var _this = this;
|
||||
layui.droptree("/Categories/AllTypes", "#TypeName", "#TypeId", false,function (ids, names) {
|
||||
_this.tmp.TypeName = ids;
|
||||
_this.tmp.TypeId = names;
|
||||
});
|
||||
}
|
||||
});
|
||||
}else{
|
||||
vm.tmp = Object.assign({}, vm.tmp,data)
|
||||
}
|
||||
success: function () {
|
||||
layui.droptree("/Categories/AllTypes", "#TypeName", "#TypeId", false);
|
||||
if (data == undefined) {
|
||||
form.val("formEdit", initVal);
|
||||
} else {
|
||||
form.val("formEdit", data);
|
||||
}
|
||||
},
|
||||
end: mainList
|
||||
});
|
||||
@@ -97,10 +82,10 @@ layui.config({
|
||||
}
|
||||
//提交数据
|
||||
form.on('submit(formSubmit)',
|
||||
function(data) {
|
||||
function (data) {
|
||||
$.post(url,
|
||||
data.field,
|
||||
function(data) {
|
||||
function (data) {
|
||||
layer.msg(data.Message);
|
||||
},
|
||||
"json");
|
||||
@@ -109,24 +94,20 @@ layui.config({
|
||||
}
|
||||
return {
|
||||
add: function() { //弹出添加
|
||||
update = false;
|
||||
show({
|
||||
Id: ''
|
||||
});
|
||||
show(false);
|
||||
},
|
||||
update: function(data) { //弹出编辑框
|
||||
update = true;
|
||||
show(data);
|
||||
show(true,data);
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
|
||||
//监听表格内部按钮
|
||||
table.on('tool(list)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'detail') { //查看
|
||||
layer.msg('ID:' + data.Id + ' 的查看操作');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -136,26 +117,28 @@ layui.config({
|
||||
var checkStatus = table.checkStatus('mainList')
|
||||
, data = checkStatus.data;
|
||||
openauth.del("/Categories/Delete",
|
||||
data.map(function (e) { return e.Id; }),
|
||||
data.map(function (e) {
|
||||
return e.Id;
|
||||
}),
|
||||
mainList);
|
||||
}
|
||||
, btnAdd: function () { //添加
|
||||
editDlg.add();
|
||||
}
|
||||
, btnEdit: function () { //编辑
|
||||
var checkStatus = table.checkStatus('mainList')
|
||||
, data = checkStatus.data;
|
||||
if (data.length != 1) {
|
||||
layer.msg("请选择编辑的行,且同时只能编辑一行");
|
||||
return;
|
||||
}
|
||||
editDlg.update(data[0]);
|
||||
}
|
||||
, btnEdit: function () { //编辑
|
||||
var checkStatus = table.checkStatus('mainList')
|
||||
, data = checkStatus.data;
|
||||
if (data.length != 1) {
|
||||
layer.msg("请选择编辑的行,且同时只能编辑一行");
|
||||
return;
|
||||
}
|
||||
editDlg.update(data[0]);
|
||||
}
|
||||
|
||||
, search: function () { //搜索
|
||||
mainList({ key: $('#key').val() });
|
||||
mainList({key: $('#key').val()});
|
||||
}
|
||||
, btnRefresh: function() {
|
||||
, btnRefresh: function () {
|
||||
mainList();
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user