123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var feedbackTypeList = {};
- var processStatusList = {};
- var statusList = {};
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'feedback/index' + location.search,
- add_url: 'feedback/add',
- edit_url: 'feedback/edit',
- del_url: 'feedback/del',
- multi_url: 'feedback/multi',
- import_url: 'feedback/import',
- table: 'shop_feedback',
- }
- });
- var table = $("#table");
- feedbackTypeList = JSON.parse(Config.feedbackTypeSearchList);
- processStatusList = JSON.parse(Config.processStatusSearchList);
- statusList = JSON.parse(Config.statusSearchList);
- console.log(feedbackTypeList);
- console.log(processStatusList);
- console.log(statusList);
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- fixedColumns: true,
- fixedRightNumber: 1,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {
- field: 'user.username', title: __('User_id'), operate: false,
- formatter: function (value, row, index) {
- // 显示用户头像和用户名
- var avatar = row.user && row.user.avatar ? row.user.avatar : '/assets/img/avatar.png';
- var username = row.user && row.user.username ? row.user.username : '游客';
-
- return '<div style="display:flex;align-items:center;">' +
- '<img src="' + avatar + '" style="width:40px;height:40px;border-radius:50%;margin-right:10px;" />' +
- '<span style="color:#a55bff;">' + username + '</span>' +
- '</div>';
- }
- },
- {field: 'type', title: __('Type'), searchList: feedbackTypeList,formatter: Controller.api.formatter.type},
- {field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
- {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
- {field: 'phone', title: __('Phone'), operate: 'LIKE'},
- {field: 'process_status', title: __('Process_status'), searchList: processStatusList,formatter:Controller.api.formatter.process_status},
- {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.remark},
- {field: 'status', title: __('Status'), searchList: statusList, formatter:Table.api.formatter.status},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- {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);
- },
- recyclebin: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- 'dragsort_url': ''
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: 'feedback/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: '140px',
- 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: 'feedback/restore',
- refresh: true
- },
- {
- name: 'Destroy',
- text: __('Destroy'),
- classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
- icon: 'fa fa-times',
- url: 'feedback/destroy',
- refresh: true
- }
- ],
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- type: function(value, row, index) {
- var type = feedbackTypeList[value] || value;
- var cssClass = '';
-
- // 根据不同类型设置不同的样式
- if (value === 'PRODUCT_FUNCTION_FEEDBACK') {
- cssClass = 'success'; // 绿色
- } else if (value === 'PRODUCT_BUG_FEEDBACK') {
- cssClass = 'danger'; // 红色
- } else if (value === 'OTHER_FEEDBACK') {
- cssClass = 'info'; // 蓝色
- }
-
- return '<span class="label label-' + cssClass + '">' + type + '</span>';
- },
- process_status: function(value, row, index) {
- var processStatus = processStatusList[value] || value;
- var cssClass = value == 1 ? 'warning' : 'success';
-
- return '<span class="label label-' + cssClass + '">' + processStatus + '</span>';
- }
- }
- }
- };
- return Controller;
- });
|