| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'product/areas/index' + location.search+'?ids='+Config.ids,
- add_url: 'product/areas/add'+'?ids='+Config.ids,
- del_url: 'product/areas/del',
- multi_url: 'product/areas/multi',
- import_url: 'product/areas/import',
- table: 'product_area',
- }
- });
-
- 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'), operate: false},
- {field: 'product_id', title: __('Product_id'), operate: false},
- {field: 'province', title: __('Province'), operate: false},
- {field: 'city', title: __('City'), operate: false},
- {field: 'area', title: __('Area'), operate: false},
- {field: 'county', title: __('County'), operate: false},
- {field: 'address', title: __('Address'), operate: 'LIKE'},
- {field: 'status', title: __('状态'), searchList: { "1": __('正常'), "0": __('已出售')}, formatter: Table.api.formatter.status },
- {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
- { field: 'operate', title: __('Operate'),
- buttons:[
- {
- name:'importlog',//名称开始按钮 classname: 'btn btn-xs btn-primary btn-dialog',
- text:'导入日志',//文本
- classname:'btn btn-xs btn-info btn-primary btn-dialog',//按钮样式
- icon:'fa fa-cog',//图标
- url:'ledger/importlog/index',//请求的方法
- extend:'data-area=["80%","85%"]',
- refresh:true,//一开始界面需要刷新
- },
- ],
- table: table, events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $(".btn-add").data("area", ["60%", "50%"]);
- //导入地区
- $(document).on("click",".btn-exports",function(){
- Fast.api.open('product/areas/exports?ids='+Config.ids, '导入地区',{
- //接收产品弹窗Fast.api.close传过来的参数
- callback:function(data){
-
- }
- });
- })
- },
- add: function () {
- Controller.api.bindevent();
- let obj = $('#c-address')
- $(document).on('change','.province',function(){
- let txt = $(this).find("option:selected").text();
- obj.val(txt)
- });
- //城市
- $(document).on('change','.city',function(){
- let txt = $(this).find("option:selected").text();
- var arr = obj.val().split("-");
- arr.splice(1, 1);
- if(txt != '请选择') arr[1] = txt
- obj.val(arr.join('-'))
- });
- //地区
- $(document).on('change','.area',function(){
- let txt = $(this).find("option:selected").text();
- var arr = obj.val().split("-");
- arr.splice(2, 1);
- if(txt != '请选择') arr[2] = txt
- obj.val(arr.join('-'))
- });
- //乡镇
- $(document).on('change','.county',function(){
- let txt = $(this).find("option:selected").text();
- var arr = obj.val().split("-");
- arr.splice(3, 1);
- if(txt != '请选择') arr[3] = txt
- obj.val(arr.join('-'))
- });
- },
- exports: function () {
- Controller.api.bindevent();
- },
- importlog: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- Form.api.bindevent($("form#cxselectform"));
- }
- }
- };
- return Controller;
- });
|