| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'LodopFuncs'], function ($, undefined, Backend, Table, Form, LodopFuncs) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init();
- this.table.first();
- this.table.second();
- //绑定
- // $('#bind').click(function (e) {
- // var ids = $('#table1').bootstrapTable('getSelections')[0]['id'];
- //
- // $.get('qcode_bach/bind',{'ids':ids},function (data) {
- // if(data.code==1){
- // Toastr.success(data.msg)
- // $('#table2').bootstrapTable('refresh');
- // }else{
- // Toastr.error(data.msg)
- // }
- // },'json');
- // layer.confirm('确定提交选中的 1 项?!', {
- // btn: ['确定', '取消'],
- // cancel: function(index, layero) {
- // }
- // },function (index) {
- // $.get('qcode_bach/bind',{'ids':ids},function (data) {
- // if(data.code==1){
- // Toastr.success(data.msg)
- // table2.bootstrapTable('refresh');
- // }else{
- // Toastr.error(data.msg)
- // }
- // },'json');
- // Layer.close(index);
- //
- // },function (){})
- // })
- //绑定
- // $('#unbind').click(function (e) {
- // layer.confirm('确定提交选中的 1 项?!', {
- // btn: ['确定', '取消'],
- // cancel: function(index, layero) {
- // }
- // },function (index) {
- // var ids = $('#table2').bootstrapTable('getSelections')[0]['id'];
- //
- // $.get('qcode_bach/unbind',{'ids':ids},function (data) {
- // if(data.code==1){
- // Toastr.success(data.msg)
- // $('#table2').bootstrapTable('refresh');
- // }else{
- // Toastr.error(data.msg)
- // }
- // },'json');
- // Layer.close(index);
- //
- // },function (){})
- //
- // })
- },
- table: {
- first: function () {
- // 表格1
- var table1 = $("#table1");
- table1.bootstrapTable({
- url: 'qcode_bach/table1',
- extend: {
- index_url: 'qcode_bach/table1' + location.search,
- add_url: 'qcode_bach/add',
- edit_url: 'qcode_bach/edit',
- del_url: 'qcode_bach/del',
- table: 'qcode_bach',
- },
- onClickRow:function(row, $element, field)
- {
- console.log(JSON.stringify(row));
- },
- toolbar: '#toolbar1',
- pk: 'id',
- sortName: 'id',
- pageSize: 8,
- pageList: [8, 20, 50, 'All'],
- search: false,
- singleSelect: true,
- columns: [
- [
- {checkbox: true},
- {field: 'matter_name', title: __('Matter_name'), operate: 'LIKE'},
- {field: 'l_flow', title: __('L_flow'), operate: 'LIKE'},
- {field: 'large_endnum', title: __('Large_endnum'), operate: 'LIKE'},
- {field: 'bach_num', title: __('Bach_num'), operate: 'LIKE'},
- {field: 'larger_num', title: __('Larger_num'), operate: 'LIKE'},
- {field: 'print_date', title: __('Print_date'), operate: 'LIKE'},
- {field: 'company_name', title: __('Company_name'), operate: 'LIKE'},
- {field: 'matter_no', title: __('Matter_no'), operate: 'LIKE'},
- // {field: 'notes', title: __('Notes')},
- {field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格1绑定事件
- Table.api.bindevent(table1);
- },
- second: function () {
- // 表格2
- var table2 = $("#table2");
- table2.bootstrapTable({
- url: 'qcode_bach/table2',
- extend: {
- index_url: '',
- add_url: '',
- edit_url: '',
- del_url: '',
- multi_url: '',
- table: '',
- },
- toolbar: '#toolbar2',
- pk: 'id',
- sortName: 'id',
- pageSize: 8,
- pageList: [8, 20, 50, 'All'],
- search: false,
- singleSelect: true,
- columns: [
- [
- {checkbox: true},
- {field: 'l_flow', title: __('当前托盘'), operate: 'LIKE'},
- {field: 'code', title: __('Code'), operate: 'LIKE'},
- {field: 'print_date', title: __('Print_date'), operate: 'LIKE'},
- {field: 'p_nums', title: __('P_nums'), operate: 'LIKE'},
- {field: 'small_num', title: __('Small_num'), operate: 'LIKE'},
- {field: 'l_weight', title: __('L_weight'), operate: 'LIKE'},
- {field: 'l_print', title: __('L_print'), operate: 'LIKE'},
- {field: 'l_status', title: __('L_status'), operate: 'LIKE'},
- // {field: 'notes', title: __('Notes')},
- // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格2绑定事件
- Table.api.bindevent(table2);
- }
- },
- /*recyclebin: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- 'dragsort_url': ''
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: 'qcode_bach/recyclebin' + location.search,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'name', title: __('Name'), align: 'left'},
- {
- 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: 'qcode_bach/restore',
- refresh: true
- },
- {
- name: 'Destroy',
- text: __('Destroy'),
- classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
- icon: 'fa fa-times',
- url: 'qcode_bach/destroy',
- refresh: true
- }
- ],
- formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },*/
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- reprint: function () {
- $("#sel-n").data("params", function (obj) {
- //obj为SelectPage对象
- return {custom: {name: $("#sel-n").val()}};
- });
- $("#sel-p").data("params", function (obj) {
- //obj为SelectPage对象
- return {custom: {name: $("#sel-p").val()}};
- });
- $("#sel-c").data("params", function (obj) {
- //obj为SelectPage对象
- return {custom: {name: $("#sel-c").val()}};
- });
- $("#btn").click(function (e) {
- e.preventDefault();
- var data = $("form").serialize();
- $.post('qcode_bach/reprint',{data},function (res) {
- if (res.code==1){
- //打印二维码
- var html = '<style type="text/css">\n' +
- '.tg {border-collapse:collapse;border-spacing:0;font-weight:500;}\n' +
- '.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}\n' +
- '.tg .tg-s6z2{text-align:center;}\n' +
- '</style>\n' +
- '<div width="340px">\n' +
- '<table class="tg" width="340px">\n' +
- '<caption style="width: 300px;">'+res.data.company_name+'</caption>\n' +
- '<tr>\n' +
- '<td style="width: 70px;">规格:</td>\n' +
- '<td colspan="5" style="word-break:break-all;border-color:black;">'+res.data.product_name+'</td>\n' +
- '</tr>\n' +
- '<tr>\n' +
- '<td>配盘数:</td>\n' +
- '<td colspan="2">'+res.data.sqrcd+'</td>\n' +
- '<td>辅单位:</td>\n' +
- '<td colspan="2">'+res.data.sec_unit+'</td>\n' +
- '</tr>\n' +
- '<tr>\n' +
- '<td>数量:</td>\n' +
- '<td colspan="2">'+res.data.num+'</td>\n' +
- '<td>主单位:</td>\n' +
- '<td colspan="2">'+res.data.main_unit+'</td>\n' +
- '</tr>\n' +
- '<tr>\n' +
- '<td>生产日期:</td>\n' +
- '<td colspan="5">'+res.data.date+'</td>\n' +
- '</tr>\n' +
- '<tr>\n' +
- '<td>生产批号:</td>\n' +
- '<td colspan="5">'+res.data.batch+'</td>\n' +
- '</tr>\n' +
- '<tr>\n' +
- '<td colspan="6" style="word-break:break-all; border-color:black; font-size: 13px;">'+res.data.qrcode+'</td>\n' +
- '</tr>\n' +
- '</table>\n' +
- '<div style="position:absolute;top: 300px;left: 47px">\n' +
- '<img src="'+res.data.pCode+'" > </td>\n' +
- '</div>\n' +
- '<div style="position:absolute;top: 400px;left: 300px;width: 50px;text-align: center;"><span style="font-weight: 500;word-break:normal;font-size: 16px">大件号'+res.data.l_flow+'</span></div>\n' +
- '</div>';
- var printPdf = (html,qrcode) => {
- let LODOP=getLodop();
- LODOP.SET_LICENSES("","152A06E8F6CBD6AC1F213ABFCB0D8604","C94CEE276DB2187AE6B65D56B3FC2848","");
- LODOP.PRINT_INIT("河南中烟大件二维码打码");
- LODOP.SET_PRINT_STYLE("FontSize",16);
- LODOP.SET_PRINT_STYLE("Bold",1);
- LODOP.SET_PRINT_PAGESIZE(1, 1000, 1500, "CreateCustomPage");
- LODOP.ADD_PRINT_HTM(15,20,350,545,html);
- // LODOP.SET_PRINT_STYLEA(0,"QRCodeVersion",14);
- // LODOP.SET_PRINT_STYLEA(0,"QRCodeErrorLevel","M");
- // LODOP.ADD_PRINT_BARCODE(18,715,'27mm','27mm',"QRCode",qrcode);
- // LODOP.PRINT() // 直接打印
- // LODOP.PRINT_DESIGN() // 设计模式
- LODOP.PREVIEW() //打印预览
- }
- printPdf(html)
- }else{
- Toastr.error(res.msg);
- }
- })
- })
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|