website/public/assets/js/backend/jdgw/nav.js
2025-05-09 01:14:04 +08:00

90 lines
3.2 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
var navIndex = new Vue({
el: '#app',
data: function() {
return {
nav: [],
openIds:[],
openIco:"/assets/addons/jdgw/images/dedeexplode.gif",
closeIco:"/assets/addons/jdgw/images/dedecontract.gif"
}
},
mounted() {
var that = this
that.navList();
},
updated(){
var that = this
$(function(){
  $(".btn-diyedit, .btn-diyadd").data("end", function(){
that.navList();
});
  });
},
methods:{
open(viewIndex) {
this.nav[viewIndex].open = !this.nav[viewIndex].open
this.openIds = [];
for (var i=0;i<this.nav.length;i++){
if(this.nav[i].open){
this.openIds.push(this.nav[i].id)
}
}
},
del(id){
var that = this;
Layer.confirm("确定删除此栏目?",
{icon: 3, title: __('Warning'), shadeClose: true},
function (index) {
Fast.api.ajax({url:'jdgw/nav/del', data:{ids:id}}, function (data, ret) {
that.navList();
});
Layer.close(index);
}
);
},
editSort(id, e){
var that = this;
var weigh = e.target.value;
$.ajax({
type: 'POST',
url: 'jdgw/nav/editWeigh',
data: {weigh: weigh, id: id},
success: function(res) {
that.navList()
}});
},
navList(){
var that = this;
$.ajax({
type: 'POST',
data:{openIds:that.openIds},
url: 'jdgw/nav/index',
success:function(res){
that.nav = res.data
}
});
},
}
})
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});