139 lines
6.5 KiB
JavaScript
139 lines
6.5 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'mattertemplatecategorizedcontent/index' + location.search,
|
|
add_url: 'mattertemplatecategorizedcontent/add',
|
|
edit_url: 'mattertemplatecategorizedcontent/edit',
|
|
del_url: 'mattertemplatecategorizedcontent/del',
|
|
multi_url: 'mattertemplatecategorizedcontent/multi',
|
|
import_url: 'mattertemplatecategorizedcontent/import',
|
|
table: 'mattertemplatecategorizedcontent',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'id', title: __('Id')},
|
|
{field: 'day', title: __('Day')},
|
|
{field: 'times', title: __('Times')},
|
|
{field: 'mattertemplatecategorization.name', title: __('Mattertemplatecategorization.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
add: function () {
|
|
$('#add-form,#edit-form').on('click', '.shili_huashu_btn', function () {
|
|
let txt = $(this).closest('.form_group_add').find('.c-hui-fang-yao-dian');
|
|
$.post('ai/talk_skill',{txt:txt.val()},function (res) {
|
|
// layer.close(load_index);
|
|
//回显
|
|
$(this).closest('.form_group_add').find('.c-content').val(res.data);
|
|
},'json');
|
|
});
|
|
// $('.shili_huashu_btn').on('click',function (e){
|
|
// //读取下拉框的值
|
|
// var groupdiv=$('.shili_huashu_btn').parent().parent().find('form_group_add');
|
|
// console.log($(this).parent().find('.c-hui-fang-yao-dian').val());
|
|
// let txt = $('.c-hui-fang-yao-dian').val();
|
|
// console.log(txt);
|
|
// // console.log(e);
|
|
// // let load_index = layer.load(1);
|
|
// $.post('ai/talk_skill',{txt:txt},function (res) {
|
|
// // layer.close(load_index);
|
|
// //回显
|
|
// $('.c-content').val(res.data);
|
|
// },'json');
|
|
// });
|
|
$('#c-add_group_content').on('click',function (res){
|
|
res.preventDefault();
|
|
var html = $('.form_group_add').html();
|
|
|
|
html = "<div class='form_group_add'>"+html+"</div>";
|
|
$('#c-add_group_last_div').before(html);
|
|
});
|
|
$('#add-form').on('click', '.deleteButton', function () {
|
|
// 获取当前删除按钮所在的大 div 并移除
|
|
var number = $('.form_group_add').length;
|
|
if (number == 1){layer.msg('至少保留一个')}else
|
|
$(this).closest('.form_group_add').remove();
|
|
});
|
|
$('#edit-form').on('click', '.deleteButton', function () {
|
|
// 获取当前删除按钮所在的大 div 并移除
|
|
var number = $('.form_group_add').length;
|
|
if (number == 1){layer.msg('至少保留一个')}else
|
|
$(this).closest('.form_group_add').remove();
|
|
});
|
|
$('#submit-button').on('click',function (res){
|
|
var inputInfo = [];
|
|
$('.form_group_add input , .form_group_add textarea ').each(function () {
|
|
var value = $(this).val();
|
|
var valueName = $(this).attr('name');
|
|
inputInfo.push({ name: valueName, value: value });
|
|
});
|
|
var mattertemplatecategorization_id=$('#c-mattertemplatecategorization_id').val();
|
|
var create_time=$('#c-create_time').val();
|
|
var update_time=$('#c-update_time').val();
|
|
$.post('Mattertemplatecategorizedcontent/add',
|
|
{inputInfo:inputInfo,mattertemplatecategorization_id:mattertemplatecategorization_id,
|
|
create_time:create_time,update_time:update_time},function (res) {
|
|
// layer.close(load_index);
|
|
//回显
|
|
if (res.code == 1){
|
|
layer.msg('添加成功');
|
|
}else {
|
|
layer.msg('添加失败');
|
|
}
|
|
},'json');
|
|
});
|
|
$('#submit-button-edit').on('click',function (res){
|
|
var inputInfo = [];
|
|
$('.form_group_add input , .form_group_add textarea ').each(function () {
|
|
var value = $(this).val();
|
|
var valueName = $(this).attr('name');
|
|
inputInfo.push({ name: valueName, value: value });
|
|
});
|
|
var mattertemplatecategorization_id=$('#c-mattertemplatecategorization_id').val();
|
|
var create_time=$('#c-create_time').val();
|
|
var update_time=$('#c-update_time').val();
|
|
$.post('Mattertemplatecategorizedcontent/newEdit',
|
|
{inputInfo:inputInfo,mattertemplatecategorization_id:mattertemplatecategorization_id,
|
|
create_time:create_time,update_time:update_time},function (res) {
|
|
// layer.close(load_index);
|
|
//回显
|
|
if (res.code == 1){
|
|
layer.msg('添加成功');
|
|
}else {
|
|
layer.msg('添加失败');
|
|
}
|
|
},'json');
|
|
});
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|