135 lines
6.3 KiB
JavaScript
135 lines
6.3 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'supplement/orders/index' + location.search,
|
|
add_url: 'supplement/orders/add',
|
|
edit_url: 'supplement/orders/edit',
|
|
del_url: 'supplement/orders/del',
|
|
multi_url: 'supplement/orders/multi',
|
|
import_url: 'supplement/orders/import',
|
|
table: 'supplement_orders',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
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.nickname', title: '创建人'},
|
|
{field: 'area.merge_name', title: '地区',searchable:false},
|
|
{field: 'item_name', title: __('Item_name')},
|
|
{field: 'source_name', title: __('Source_name')},
|
|
{field: 'platform_order_no', title: __('Platform_order_no'), operate: 'LIKE'},
|
|
{field: 'buyer_account', title: __('Buyer_account'), operate: 'LIKE'},
|
|
{field: 'amount', title: __('Amount'), operate:'BETWEEN'},
|
|
{field: 'commission', title: __('Commission'), operate:'BETWEEN'},
|
|
{field: 'screenshots', title: '图片', operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
|
|
{field: 'created_at', title: __('Created_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
{field: 'updated_at', title: __('Updated_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
{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();
|
|
Controller.api.map();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
Controller.api.map();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
},
|
|
map:function () {
|
|
$("#c-city").on("cp:updated", function () {
|
|
var citypicker = $(this).data("citypicker");
|
|
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
|
|
|
|
$("#area_id").val(code);
|
|
$("#area_name").val(citypicker.getVal());
|
|
});
|
|
// $("#area_map").data("callback", function (res) {
|
|
// Form.api.target($('#c-address'));
|
|
// });
|
|
$(document).on('click', "#area_map", function (e) {
|
|
const data = $("#c-city").val();
|
|
if (!data){
|
|
Toastr.error('请先选择区域');
|
|
return false;
|
|
}
|
|
|
|
var that = this;
|
|
var callback = $(that).data('callback');
|
|
var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
|
|
var lat_id = $(that).data("lat-id") ? $(that).data("lat-id") : "";
|
|
var lng_id = $(that).data("lng-id") ? $(that).data("lng-id") : "";
|
|
var zoom_id = $(that).data("zoom-id") ? $(that).data("zoom-id") : "";
|
|
var lat = lat_id ? $("#" + lat_id).val() : '';
|
|
var lng = lng_id ? $("#" + lng_id).val() : '';
|
|
var city_code = $("#c-city").val();
|
|
var zoom = zoom_id ? $("#" + zoom_id).val() : '';
|
|
var url = "/addons/address/index/select?a=1";
|
|
url += (lat && lng) ? 'lat=' + lat + '&lng=' + lng +
|
|
(input_id ? "&address=" + $("#" + input_id).val() : "")
|
|
+(zoom ? "&zoom=" + zoom : "") : ''
|
|
;
|
|
if (city_code){
|
|
url += city_code ? "&city_code=" + city_code : "";
|
|
}
|
|
// console.log(url);
|
|
Fast.api.open(url, '位置选择', {
|
|
callback: function (res) {
|
|
input_id && $("#" + input_id).val(res.address).trigger("change");
|
|
lat_id && $("#" + lat_id).val(res.lat).trigger("change");
|
|
lng_id && $("#" + lng_id).val(res.lng).trigger("change");
|
|
zoom_id && $("#" + zoom_id).val(res.zoom).trigger("change");
|
|
|
|
try {
|
|
//执行回调函数
|
|
if (typeof callback === 'function') {
|
|
callback.call(that, res);
|
|
}
|
|
} catch (e) {
|
|
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
var _data = items;
|
|
|
|
$('#item_id').zdCascader({
|
|
data: _data,
|
|
onChange: function ($this, data, allPathData) {
|
|
// console.log(data,allPathData);
|
|
$('#item_id_value').val(data.value);
|
|
}
|
|
});
|
|
$('#item_id').val($('#item_id').data('value')).focus();
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|