| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'system/message/index' + location.search,
- add_url: 'system/message/add',
- edit_url: 'system/message/edit',
- del_url: 'system/message/del',
- multi_url: 'system/message/multi',
- import_url: 'system/message/import',
- send_message: 'system/message/send_message',
- table: 'system_message',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {
- field: 'identity_type',
- title: __('Identity_type'),
- searchList: {
- "agent": __('Agent'),
- "store": __('Store'),
- "massager": __('Massager'),
- "user": __('User')
- },
- formatter: Table.api.formatter.normal
- },
- {field: 'user.nickname', title: __('用户昵称'), operate: 'LIKE'},
- {field: 'massager.name', title: __('助教昵称'), operate: 'LIKE'},
- {field: 'title', title: __('Title'), operate: 'LIKE'},
- {field: 'is_read', title: __('Is_read'), formatter: (value) => ["否", "是"][value]},
- {
- field: 'updatetime',
- title: __('Updatetime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- autocomplete: false,
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- send_message: function () {
- $("#c-identity-type").change(function () {
- var identity_type = $("#c-identity-type").val();
- var group_type = $("#c-group_type").val();
- if (identity_type === "user") {
- $("#target_massager_div").css("display", "none");
- $("#user_group").css("display", group_type === "ALL" ? "none" : "block");
- $("#target_user_div").css("display", group_type === "ALL" ? "none" : "block");
- } else {
- $("#user_group").css("display", "none");
- $("#target_user_div").css("display", "none");
- $("#target_massager_div").css("display", group_type === "ALL" ? "none" : "block");
- }
- });
- $("#group_type").change(function () {
- var group_type = $("#c-group_type").val();
- var identity_type = $("#c-identity-type").val();
- if (identity_type === "user") {
- $("#target_massager_div").css("display", "none");
- $("#user_group").css("display", group_type === "ALL" ? "none" : "block");
- $("#target_user_div").css("display", group_type === "ALL" ? "none" : "block");
- } else {
- $("#user_group").css("display", "none");
- $("#target_user_div").css("display", "none");
- $("#target_massager_div").css("display", group_type === "ALL" ? "none" : "block");
- }
- });
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|