| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'entrust/index' + location.search,
- add_url: 'entrust/add',
- edit_url: 'entrust/edit',
- del_url: 'entrust/del',
- multi_url: 'entrust/multi',
- import_url: 'entrust/import',
- printing_url: 'entrust/printing',
- table: 'entrust',
- }
- });
- 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: 'no', title: __('No'), operate: 'LIKE'},
- {field: 'name', title: __('Name'), operate: 'LIKE'},
- {field: 'sell_bach', title: __('Sell_bach'), operate: 'LIKE'},
- {field: 'bach', title: __('Bach'), operate: 'LIKE'},
- {field: 'sample_info', title:'样品信息', operate: 'LIKE'},
- {field: 'send_sample', title:'送样人', operate: 'LIKE'},
- {field: 'sample_no', title: __('Sample_no'), operate: 'LIKE'},
- {field: 'is_two', title: __('是否双样'),operate:false,formatter: function (value,row,index) {
- if (value == 0){
- value = '单样';
- return '<span style="color: #18bc9c">' +value+ '</span>';
- }else {
- value = '双样';
- return '<span style="color: #f75444">' + value + '</span>';
- }
- }},
- {field: 'standard_name', title: __('Standard_name'), searchList: $.getJSON("entrust/companyselect")},
- {field: 'data_status', title: __('检测数据'),searchList: {"0":'无',"1":'已有'}, formatter: Table.api.formatter.status,function (value,row,index) {
- if (value == 0){
- value = '';
- return '<span style="color: #f75444">' +value+ '</span>';
- }else {
- value = '已有';
- return '<span style="color: #18bc9c">' + value + '</span>';
- }
- }},
- {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
- {field: 'company', title: __('送样单位')},
- {field: 'sample_status', title: __('Sample_status'), operate:false, formatter: Table.api.formatter.status},
- {field: 'create', title: __('Create'), operate:false, addclass:'datetimerange', autocomplete:false},
- {field: 'remark', title: __('Remark'), operate:false},
- // {field: 'work_name',title: '所属公司',operate: 'IN',addclass: 'selectpage',data:'data-multiple="true"'+'data-source=[{"id":"浙江美浓","name":"浙江美浓"},{"id":"涂料","name":"涂料"},{"id":"亚欣","name":"亚欣"}]'},
- {field: 'work_name',title: '所属公司',operate: 'IN',addclass: 'selectpage',data:'data-multiple="true"'+'data-source="Entrust/company"'},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
- buttons: [
- // {
- // name: 'detail',
- // text: __('提交'),
- // title: __('提交'),
- // classname: 'btn btn-xs btn-primary ',
- // icon: 'fa fa-list',
- // extend:'data-area=["50%","40%"]',
- // url: 'entrust/submit/id/{ids}',
- // callback: function (data) {
- // return false;
- // },
- // visible: function (row) {
- // //返回true时按钮显示,返回false隐藏
- // return true;
- // }
- // },
- {
- name: 'log',
- text: __('操作日志'),
- title: __('操作日志'),
- classname: 'btn btn-xs btn-primary btn-dialog',
- icon: 'fa fa-list',
- extend:'data-area=["80%","70%"]',
- url: 'entrust/log',
- callback: function (data) {
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return true;
- }
- },
- // {
- // name: 'data',
- // text: __('检测数据'),
- // title: __('检测数据'),
- // classname: 'btn btn-xs btn-primary btn-dialog',
- // icon: 'fa fa-list',
- // extend:'data-area=["100%","100%"]',
- // url: 'entrust/data/id/{ids}',
- // callback: function (data) {
- //
- // },
- // visible: function (row) {
- // //返回true时按钮显示,返回false隐藏
- // return true;
- // }
- // },
- // {
- // name: 'entrust',
- // text: __('委托单'),
- // title: __('委托单'),
- // classname: 'btn btn-xs btn-primary btn-dialog',
- // icon: 'fa fa-list',
- // extend:'data-area=["100%","100%"]',
- // url: 'entrust/commissionSheet/id/{ids}',
- // callback: function (data) {
- //
- // },
- // visible: function (row) {
- // //返回true时按钮显示,返回false隐藏
- // return true;
- // }
- // }
- ],
- formatter: Table.api.formatter.buttons}
- ]
- ]
- });
- $(".btn-add").data("area", ["100%","100%"]);
- $(".btn-edit").data("area", ["100%","100%"]);
- $(".btn-printing").data("area", ["100%","100%"]);
- table.on('post-body.bs.table', function (e, settings, json, xhr) {
- $(".btn-editone").data("area", ["100%", "100%"]);
- });
- //批量提交
- $(document).on("click",".btn-submits", function () {
- // console.log("提交");
- // var that = this;
- var ids = Table.api.selectedids(table);
- var id = ids.toString();
- console.log(id);
- Fast.api.ajax({
- url:'entrust/submit',
- data:{id:id}
- },function (data,ret) {
- //成功回调
- parent.Toastr.success("提交成功");
- Fast.api.close();
- parent.Fast.api.refreshmenu();
- return false;
- },function (data,ret) {
- parent.Toastr.error(ret.msg);
- Fast.api.close();
- return false;
- });
- return false;
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- // $('#c-name').blur(function () {
- // var str = $(this).val()
- // str = str.replace(/\s+/g,'');//去除所有空格
- // var bach = str.substr(str.length - 7);
- // $('#c-bach').val(bach)
- // $('#c-sell_bach').val(bach)
- // })
- $('.mark').change(function () {
- var mark = parseInt($(this).val());
- var company = $('.company option:selected').val();
- switch (mark) {
- case 1:
- mark = 'A';
- break;
- case 2:
- mark = 'B';
- break;
- case 3:
- mark = 'C';
- break;
- case 4:
- mark = 'D';
- break;
- }
- Fast.api.ajax({
- url: "entrust/getNo",
- type: "post",
- data:{temp: mark,company:company}
- }, function (data) {
- var last_sample_no = mark + data;
- $('#c-sample_no').val(last_sample_no);
- var no = 'JC-'+last_sample_no;
- $('#c-no').val(no);
- return false;
- },function () {
- return false;
- });
- })
- Controller.api.bindevent();
- },
- edit: function () {
- $('.is_two').attr('disabled','disabled');
- var id = $('#c-standard_name').val();
- console.log(id);
- Controller.api.bindevent();
- },
- // submit:function () {
- // $('.submit').click(function () {
- // var temp = parseInt($('.mark').val());
- // var id = $('#id').val();
- // if (temp == 0 || temp == ''){
- // layer.confirm('请选择判定标准!');
- // return false;
- // }
- // if (id == 0 || id == ''){
- // layer.confirm('未获取到参数!');
- // return false;
- // }
- // Fast.api.ajax({
- // url:'entrust/submit',
- // data:{temp:temp,id:id}
- // },function (data,ret) {
- // //成功回调
- // parent.Toastr.success("提交成功");
- // Fast.api.close();
- // parent.Fast.api.refreshmenu();
- // return false;
- // },function (data,ret) {
- // parent.Toastr.error(ret.msg);
- // Fast.api.close();
- // return false;
- // });
- // return false;
- // });
- // Controller.api.bindevent();
- // },
- log:function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'entrust/log',
- }
- });
- var table = $("#table");
- var eid = $('#e_id').val();
- // 初始化表格
- table.bootstrapTable({
- url: 'entrust/log/ids/'+eid,
- // url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: '序号'},
- {field: 'username', title: __('username'), align: 'left'},
- {field: 'operate', title: __('operate'), align: 'left'},
- {field: 'content', title: __('content'), align: 'left'},
- {field: 'create', title: __('操作时间'), align: 'left'},
- ]
- ]
- });
- Controller.api.bindevent();
- },
- data:function () {
- $('.submit').click(function () {
- console.log(1111)
- var id = $('#id').val();
- if (id == 0 || id == ''){
- layer.confirm('未获取到参数!');
- return false;
- }
- Fast.api.ajax({
- url:'entrust/dataSure',
- data:{id:id}
- },function (data,ret) {
- //成功回调
- parent.Toastr.success("确认成功");
- Fast.api.close();
- parent.Fast.api.refreshmenu();
- return false;
- },function (data,ret) {
- parent.Toastr.error("确认失败");
- Fast.api.close();
- return false;
- });
- return false;
- })
- Controller.api.bindevent();
- },
- commissionsheet:function () {
- Controller.api.bindevent();
- Form.api.bindevent($("form[role=form]"), function (data, ret) {
- Toastr.success("成功");
- }, function (data, ret) {
- Toastr.success("失败");
- }, function (success, error) {
- // 判断委托编号是否为空
- var entrust_id = $('#c-entrust_id').val();
- if (entrust_id == '' || entrust_id == undefined) {
- layer.confirm('委托编号不能为空');
- return false;
- }
- // 判断委托方是否为空
- var entrust_user = $('#c-entrust_user').val();
- if (entrust_user == '' || entrust_user == undefined) {
- layer.confirm('委托方不能为空');
- return false;
- }
- // 判断委托日期是否为空
- var entrust_time = $('#c-entrust_time').val();
- if (entrust_time == '' || entrust_time == undefined) {
- layer.confirm('委托日期不能为空');
- return false;
- }
- // 判断样品名称是否为空
- var name = $('#c-name').text();
- if (name == '' || name == undefined) {
- layer.confirm('样品名称不能为空');
- return false;
- }
- // 判断样品数量是否为空
- var num = $('#c-num').val();
- if (num == '' || num == undefined) {
- layer.confirm('样品数量不能为空');
- return false;
- }
- // 判断检测项目是否为空
- var project = $('#c-project').val();
- if (project == '' || project == undefined) {
- layer.confirm('检测项目不能为空');
- return false;
- }
- // 判断样品编号是否为空
- var no = $('#c-no').val();
- if (no == '' || no == undefined) {
- layer.confirm('样品编号不能为空');
- return false;
- }
- // 获取备注选中值
- var requirement = '';
- $("input[name='requirement']:checked").each(function(){
- requirement += $(this).val()+"、";
- });
- // 获取检后样品处理要求选中值
- var deal = '';
- $("input[name='deal']:checked").each(function(){
- deal += $(this).val()+"、";
- });
- // 获取样品保存条件选中值
- var condition = '';
- $("input[name='condition']:checked").each(function (){
- condition += $(this).val()+"、";
- });
- // 获取报告发放选中值
- var isue = '';
- $("input[name='isue']:checked").each(function (){
- isue += $(this).val()+"、";
- });
- // 获取检测依据标准选中值
- var standard = '';
- $("input[name='standard']:checked").each(function(){
- standard += $(this).val()+"、";
- });
- Fast.api.ajax({
- url: 'entrust/commissionsheetup',
- data: {
- entrust_user:entrust_user,
- entrust_time:entrust_time,
- entrust_id:entrust_id,
- name:name,
- num:num,
- project:project,
- no:no,
- status:$("input[name='status']:checked").val(),
- requirement:requirement,
- reportnumber:$('#c-reportnumber').val(),
- deal:deal,
- condition:condition,
- isue:isue,
- testcost:$('#c-testcost').val(),
- standard:standard
- },
- }, function (data, ret) {
- if (ret.code === 1){
- window.print();
- }
- parent.Toastr.success('添加成功');
- Fast.api.close();
- parent.Fast.api.refreshmenu();
- return false;
- }, function (data, ret) {
- parent.Toastr.error(ret.msg);
- Fast.api.close();
- parent.Fast.api.refreshmenu();
- return false;
- });
- return false;
- });
- },
- printing: function (){
- Controller.api.bindevent();
- Form.api.bindevent($("form[role=form]"), function (data, ret) {
- Toastr.success("成功");
- }, function (data, ret) {
- Toastr.success("失败");
- }, function (success, error) {
- // 判断委托编号是否为空
- var entrust_id = $('#c-entrust_id').val();
- if (entrust_id == '' || entrust_id == undefined) {
- layer.confirm('委托编号不能为空');
- return false;
- }
- // 判断委托方是否为空
- var entrust_user = $('#c-entrust_user').val();
- if (entrust_user == '' || entrust_user == undefined) {
- layer.confirm('委托方不能为空');
- return false;
- }
- // 判断委托日期是否为空
- var entrust_time = $('#c-entrust_time').val();
- if (entrust_time == '' || entrust_time == undefined) {
- layer.confirm('委托日期不能为空');
- return false;
- }
- // 循环获取样品信息
- var sampledata = [];
- var samplelist = $('#tableprint').find("tr");//样品种数
- for (var i=4;i<samplelist.length-8;i++){
- var samdata = [];
- var name = $(samplelist).eq(i).find('#c-name').text();
- var status = $(samplelist).eq(i).find("input[name='status']:checked").val();
- var num = $(samplelist).eq(i).find('#c-num').val();
- if (num == '' || num == undefined) {
- layer.confirm('样品数量不能为空');
- return false;
- }
- var object = $(samplelist).eq(i).find('#c-project').val();
- var no = $(samplelist).eq(i).find('#c-no').val();
- samdata.push(name);
- samdata.push(status);
- samdata.push(num);
- samdata.push(object);
- samdata.push(no);
- sampledata.push(samdata);
- }
- console.log(sampledata);
- // 获取备注选中值
- var requirement = '';
- $("input[name='requirement']:checked").each(function(){
- requirement += $(this).val()+"、";
- });
- // 获取检后样品处理要求选中值
- var deal = '';
- $("input[name='deal']:checked").each(function(){
- deal += $(this).val()+"、";
- });
- // 获取样品保存条件选中值
- var condition = '';
- $("input[name='condition']:checked").each(function (){
- condition += $(this).val()+"、";
- });
- // 获取报告发放选中值
- var isue = '';
- $("input[name='isue']:checked").each(function (){
- isue += $(this).val()+"、";
- });
- // 获取检测依据标准选中值
- var standard = '';
- $("input[name='standard']:checked").each(function(){
- standard += $(this).val()+"、";
- });
- Fast.api.ajax({
- url: 'entrust/printingup',
- data: {
- entrust_user:entrust_user,
- entrust_time:entrust_time,
- entrust_id:entrust_id,
- sampledata:sampledata,
- requirement:requirement,
- reportnumber:$('#c-reportnumber').val(),
- deal:deal,
- condition:condition,
- isue:isue,
- testcost:$('#c-testcost').val(),
- standard:standard
- },
- }, function (data, ret) {
- if (ret.code === 1){
- window.print();
- }
- parent.Toastr.success('添加成功');
- Fast.api.close();
- parent.Fast.api.refreshmenu();
- return false;
- }, function (data, ret) {
- parent.Toastr.error(ret.msg);
- Fast.api.close();
- parent.Fast.api.refreshmenu();
- return false;
- });
- return false;
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|