123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- Table.api.init({
- extend: {
- index_url: 'shopro/notification/config/index' + location.search,
- add_url: 'shopro/notification/config/add',
- edit_url: 'shopro/notification/config/edit',
- del_url: 'shopro/notification/config/del',
- multi_url: 'shopro/notification/config/multi',
- table: 'shopro_notification_config',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [{
- checkbox: true
- },
- {
- field: 'id',
- title: __('Id')
- },
- {
- field: 'platform',
- title: __('Platform')
- },
- {
- field: 'name',
- title: __('Name')
- },
- {
- field: 'event',
- title: __('Event')
- },
- {
- field: 'status',
- title: __('Status'),
- searchList: {
- "0": __('Status 0'),
- "1": __('Status 1')
- },
- formatter: Table.api.formatter.status
- },
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'updatetime',
- title: __('Updatetime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- 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);
- },
- config: function () {
- var notification_index = new Vue({
- el: "#notification-index",
- data() {
- return {
- tipCloseFlag: true,
- notificationDialog: false,
- notificationData: [],
- notificationForm: {},
- editIndex:null,
- editPlatform:null
- }
- },
- mounted() {
- this.getnotificationData();
- },
- methods: {
- getnotificationData(){
- let that=this;
- Fast.api.ajax({
- url: 'shopro/notification/config',
- type:'GET',
- loading: true,
- data: {}
- }, function (ret, res) {
- that.notificationData=res.data;
- return false;
- })
- },
- tipClose() {
- this.tipCloseFlag = false;
- },
- changeStatua(platform, event, name, status) {
- let that = this;
- Fast.api.ajax({
- url: 'shopro/notification/set_status',
- loading: true,
- type: "POST",
- data: {
- platform: platform,
- event: event,
- name: name,
- status: status
- }
- }, function (ret, res) {
- that.getnotificationData();
- })
- },
- fieldDel(index){
- this.notificationForm.fields.splice(index,1)
- },
- notificationClose(type) {
- let that = this;
- if(this.editPlatform!='email'){
- that.notificationForm.template_id=that.notificationForm.template_id.replace(/\s*/g,"");
- }
- if (type == 'yes') {
- let content=JSON.stringify(that.notificationForm)
- if(this.editPlatform=='email'){
- content=$('#c-content').val()
- }
- Fast.api.ajax({
- url: 'shopro/notification/set_template',
- loading: true,
- data: {
- platform: that.editMsg.platform,
- event: that.editMsg.event,
- name: that.editMsg.name,
- content: content
- }
- }, function (ret, res) {
- that.getnotificationData();
- that.notificationDialog = false;
- that.notificationForm = {};
- that.editMsg={};
- })
- } else {
- that.notificationForm = {};
- that.editMsg={};
- that.notificationDialog = false;
- }
- },
- edit(index, type) {
- this.editMsg=this.notificationData[index][type];
- this.notificationForm = JSON.parse(JSON.stringify(this.notificationData[index][type].content_arr));
- this.editPlatform=type;
- if(this.editPlatform=='email'){
- this.$nextTick(callback=>{
- Controller.api.bindevent();
- $('#c-content').html(this.notificationData[index][type].content)
- })
- }
- this.notificationDialog = true;
- },
- addfield() {
- this.notificationForm.fields.push({
- 'name': '',
- 'template_field': '',
- 'value': '',
- });
- },
- },
- })
- },
- recyclebin: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- 'dragsort_url': ''
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: 'shopro/notification/recyclebin' + location.search,
- pk: 'id',
- sortName: 'id',
- columns: [
- [{
- checkbox: true
- },
- {
- field: 'id',
- title: __('Id')
- },
- {
- field: 'deletetime',
- title: __('Deletetime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'operate',
- width: '130px',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- buttons: [{
- name: 'Restore',
- text: __('Restore'),
- classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
- icon: 'fa fa-rotate-left',
- url: 'shopro/notification/restore',
- refresh: true
- },
- {
- name: 'Destroy',
- text: __('Destroy'),
- classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
- icon: 'fa fa-times',
- url: 'shopro/notification/destroy',
- refresh: true
- }
- ],
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|