123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: async function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'user_order/index' + location.search,
- add_url: 'user_order/add',
- edit_url: 'user_order/edit',
- del_url: 'user_order/del',
- multi_url: 'user_order/multi',
- import_url: 'user_order/import',
- table: 'user_order',
- }
- });
- var table = $("#table");
- let statusList = await $.getJSON('user_order/status')
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- searchFormVisible:true,
- sortName: 'id',
- columns: [
- [
- //{checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
- {field: 'no', title: __('订单号'), operate: '='},
- {field: 'from_city', title: __('From_city')},
- {field: 'to_city', title: __('To_city')},
- {
- field: 'images',
- title: __('Images'),
- operate: false,
- events: Table.api.events.image,
- formatter: Table.api.formatter.images
- },
- {field: 'real_amount', title: __('Real_amount'), operate: 'BETWEEN'},
- {field: 'discount_amount', title: __('Coupon_amount'), operate: 'BETWEEN'},
- {
- field: 'status',
- title: __('Status'),
- searchList: statusList,
- formatter: Table.api.formatter.label
- },
- {field: 'created_at', title: __('Created_at'), formatter: Table.api.formatter.datetime,operate: 'RANGE',addclass: 'datetimerange'},
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.buttons,
- buttons:[
- {
- name: 'detail',
- text: __('详情'),
- title: __('详情'),
- classname: 'btn btn-xs btn-primary btn-dialog btn-detail',
- icon: 'fa fa-list',
- url: 'user_order/edit',
- callback: function (data) {
- //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return true;
- }
- },
- {
- name: 'send_detail',
- text: __('运送详情'),
- title: __('运送详情'),
- classname: 'btn btn-xs btn-primary btn-dialog btn-send_detail',
- icon: 'fa fa-list',
- url: 'user_order/send_detail',
- callback: function (data) {
- //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return $('#table').data('operate-send_detail')===1;
- }
- },
- {
- name: 'remark',
- text: __('备注'),
- title: __('备注'),
- classname: 'btn btn-xs btn-danger btn-click',
- icon: 'fa fa-wikipedia-w',
- url: 'user_order/remark',
- click: function (data) {
- let _this=this
- layer.prompt({
- formType: 2,
- title: '请填写备注',
- area: ['500px', '150px'],
- btnAlign: 'c',
- yes: function(index, layero){
- // 获取文本框输入的值
- var value = layero.find(".layui-layer-input").val();
- if (value) {
- let load=layer.load(2)
- $.post(_this.href,{remark:value,ids:data.id},function (res) {
- if(res.code===1) {
- $('.btn-refresh').trigger('click')
- layer.msg('操作成功')
- layer.close(index)
- }else{
- layer.alert(res.msg)
- }
- layer.close(load)
- })
- } else {
- layer.alert("输入值为空!");
- }
- }
- })
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return $('#table').data('operate-send_detail')===1;
- }
- },
- {
- name: 'delete',
- text: __('删除'),
- title: __('删除'),
- classname: 'btn btn-xs btn-danger btn-click',
- icon: 'fa fa-delicious',
- url: 'user_order/delete',
- click: function (data) {
- let _this=this
- layer.confirm('确认删除吗?',function (){
- let load=layer.load(2)
- $.post(_this.href,{},function (res) {
- if(res.code===1){
- layer.msg('删除成功')
- $('.btn-refresh').trigger('click')
- }else{
- layer.msg(res.msg)
- }
- layer.close(load)
- })
- })
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return $('#table').data('operate-delete')===1 && row.status===80;
- }
- },
- {
- name: 'delete',
- text: __('驳回此订单'),
- title: __('驳回此订单'),
- classname: 'btn btn-xs btn-info btn-click',
- icon: 'fa fa-delicious',
- url: 'user_order/cancel',
- click: function (data) {
- let _this=this
- layer.confirm('确认驳回吗?',function (){
- let load=layer.load(2)
- $.post(_this.href,{},function (res) {
- if(res.code===1){
- layer.msg('驳回成功')
- $('.btn-refresh').trigger('click')
- }else{
- layer.msg(res.msg)
- }
- layer.close(load)
- })
- })
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return $('#table').data('operate-cancel')===1 && row.status===1;
- }
- },
- ],
- }
- ]
- ],
- onLoadSuccess:function(data){
- $('#turnover').text(data.turnover)
- // 这里就是数据渲染结束后的回调函数
- $(".btn-detail,.btn-send_detail").data("area", ['1000px','100%']);
- $(".btn-detail,.btn-send_detail").data("shade", [0.5,"#000"]);
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- $('.deal_remark').click(function (){
- let id=$(this).data('id')
- layer.open({
- content:'请选择操作',
- btn:['立即结算','拒绝结算','取消操作'],
- yes:function (idx){
- $.post('user_order/deal_settle',{ids:id,status:1},function (res) {
- if(res.code===1) {
- Fast.api.close({})
- layer.msg('操作成功')
- layer.close(idx)
- window.location.reload()
- }else{
- layer.alert(res.msg)
- }
- })
- },
- btn2:function (idx){
- $.post('user_order/deal_settle',{ids:id,status:2},function (res) {
- if(res.code===1) {
- Fast.api.close({})
- layer.msg('操作成功')
- layer.close(idx)
- window.location.reload()
- }else{
- layer.alert(res.msg)
- }
- })
- },
- btn3:function (idx){
- layer.close(idx)
- }
- })
- })
- $('.deal_refund').click(function (){
- let id=$(this).data('id')
- layer.open({
- content:'请选择操作',
- btn:['同意退款','拒绝退款','取消操作'],
- yes:function (idx){
- $.post('user_order/deal_refund',{ids:id,status:1},function (res) {
- if(res.code===1) {
- Fast.api.close({})
- layer.msg('操作成功')
- layer.close(idx)
- window.location.reload()
- }else{
- layer.alert(res.msg)
- }
- })
- },
- btn2:function (idx){
- $.post('user_order/deal_refund',{ids:id,status:2},function (res) {
- if(res.code===1) {
- Fast.api.close({})
- layer.msg('操作成功')
- layer.close(idx)
- window.location.reload()
- }else{
- layer.alert(res.msg)
- }
- })
- },
- btn3:function (idx){
- layer.close(idx)
- }
- })
- })
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|