123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- // index: function () {
- // $(".btn-add").data("area", ["1020px", "775px"]);
- // // 初始化表格参数配置
- // Table.api.init({
- // extend: {
- // index_url: 'diary/index' + location.search,
- // add_url: 'diary/add',
- // edit_url: 'diary/edit',
- // del_url: 'diary/del',
- // multi_url: 'diary/multi',
- // import_url: 'diary/import',
- // table: 'diary',
- // }
- // });
- // var table = $("#table");
- // // 初始化表格
- // table.bootstrapTable({
- // url: $.fn.bootstrapTable.defaults.extend.index_url,
- // pk: 'id',
- // sortName: 'id',
- // columns: [
- // [
- // {
- // checkbox: true
- // },
- // {
- // field: 'order_number',
- // title: __('Id')
- // },
- // {
- // field: 'unit_id_text',
- // title: __('单位')
- // },
- // {
- // field: 'people_id_text',
- // title: __('People_id')
- // },
- // {
- // field: 'blog_date',
- // title: __('Blog_date'),
- // operate: 'LIKE'
- // },
- // {
- // field: 'orgcadre',
- // title: __('Orgcadre'),
- // operate: 'LIKE'
- // },
- // {
- // field: 'orgsoldier',
- // title: __('Orgsoldier'),
- // operate: 'RANGE'
- // },
- // {
- // field: 'orgcivilian',
- // title: __('Orgcivilian'),
- // operate: 'LIKE'
- // },
- // // {field: 'lead_text', title: __('Lead'), operate: 'LIKE'},
- // {
- // field: 'operate',
- // title: __('Operate'),
- // table: table,
- // events: Table.api.events.operate,
- // buttons: [
- // {
- // name: '查看',
- // text: '查看',
- // title: '查看',
- // classname: 'btn btn-xs btn-info btn-view btn-dialog ',
- // icon: 'fa fa-search',
- // url: 'diary/details',
- // extend: 'data-area=\'["1020px","775px"]\'',
- // refresh: true
- // }
- // ],
- // formatter: Table.api.formatter.operate
- // }
- // ]
- // ]
- // });
- // // 为表格绑定事件
- // Table.api.bindevent(table);
- // table.on('post-body.bs.table', function () {
- // $(".btn-editone").data("area", ["1020px", "1020px"]);
- // })
- // },
- index: function () {
- $(".btn-add").data("area", ["1020px", "775px"]);
- // 初始化表格参数配置
- Table.api.init();
- this.table.first();
- this.table.second();
- },
- table: {
- first: function () {
- // 表格1
- var table1 = $("#table1");
- table1.bootstrapTable({
- url: 'diary/unit_ysrj',
- toolbar: '#toolbar1',
- sortName: 'id',
- search: false,
- pagination: false,
- columns: [
- [
- {
- field: 'operate', title: __('单位'), table: table1, events: Table.api.events.operate, buttons: [
- {
- name: 'log',
- title: '',
- text: function(row){return row.name},
- classname: 'btn btn-success btn-xs btn-click btn-custom',
- click: function (e, data) {
- console.log(data)
- $("#myTabContent2 .form-commonsearch input[name='unit_id']").val(data.id);
- $("#myTabContent2 .btn-refresh").trigger("click");
- },
- visible:function(row){
- if(row.isok == 1)return true;
- return false;
- }
- },
- {
- name: 'log',
- title: '',
- text: function(row){return row.name},
- classname: 'btn btn-danger btn-xs btn-click btn-custom',
- click: function (e, data) {
- console.log(data)
- $("#myTabContent2 .form-commonsearch input[name='unit_id']").val(data.id);
- $("#myTabContent2 .btn-refresh").trigger("click");
- },
- visible:function(row){
- if(row.isok == 0)return true;
- return false;
- }
- }
- ], formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格1绑定事件
- Table.api.bindevent(table1);
- },
- second: function () {
- // 表格2
- var table2 = $("#table2");
- table2.bootstrapTable({
- url: 'diary/index' + location.search,
- extend: {
- index_url: 'diary/index' + location.search,
-
- add_url: 'diary/add',
-
- edit_url: 'diary/edit',
-
- del_url: 'diary/del',
-
- multi_url: 'diary/multi',
-
- import_url: 'diary/import',
-
- table: 'diary',
- },
- toolbar: '#toolbar2',
- sortName: 'id',
- search: false,
- columns: [
- [
- {
- checkbox: true
- },
- {
- field: 'order_number',
- title: __('Id'),operate:false
- },
- {
- field: 'unit_id',
- title: __('单位ID'),visible:false
- },
- {
- field: 'unit_id_text',
- title: __('单位'),operate:false
- },
- {
- field: 'people_id_text',
- title: __('People_id'),operate:false
- },
- {
- field: 'blog_date',
- title: __('Blog_date'),operate:false
- },
- {
- field: 'orgcadre',
- title: __('Orgcadre'),operate:false
- },
- {
- field: 'orgsoldier',
- title: __('Orgsoldier'),operate:false
- },
- {
- field: 'orgcivilian',
- title: __('Orgcivilian')
- ,operate:false
- },
- // {field: 'lead_text', title: __('Lead'), operate: 'LIKE'},
- {
- field: 'operate',
- title: __('Operate'),
- table: table2,
- events: Table.api.events.operate,
- buttons: [
- {
- name: '查看',
- text: '查看',
- title: '查看',
- classname: 'btn btn-xs btn-info btn-view btn-dialog ',
- icon: 'fa fa-search',
- url: 'diary/details',
- extend: 'data-area=\'["1020px","775px"]\'',
- refresh: true
- },
- {
- name: '审批',
- text: '审批',
- title: '审批',
- classname: 'btn btn-xs btn-info btn-view btn-dialog ',
- icon: 'fa fa-search',
- url: 'diary/examine',
- extend: 'data-area=\'["1020px","775px"]\'',
- refresh: true,
- visible:function(row){
- if(row.examine == 0 && row.people_id1 == Config.admin.id || row.examine == 0 && row.admin_id == Config.admin.id){
- return true;
- }else{
- return false;
- }
- }
- },
- {
- name: '审批不通过',
- text: '审批不通过',
- title: '审批不通过',
- classname: 'btn btn-xs btn-info',
- icon: 'fa fa-search',
- refresh: true,
- visible:function(row){
- if(row.examine == 2 && row.people_id1 == Config.admin.id || row.examine == 2 && row.admin_id == Config.admin.id){
- return true;
- }else{
- return false;
- }
- }
- }
- ],
-
- formatter: function(value,row,index){
- var that = $.extend({},this);
- var table = $(that.table).clone(true);
- if(row.examine=="1"){
- $(table).data("operate-edit",null);
- that.table = table;
- }
- return Table.api.formatter.operate.call(that,value,row,index)
- //console.log(value);
- //console.log(row);
- //console.log(index);
- }
- // formatter: Table.api.formatter.operate
- }
- ]
- ]
- });
- // 为表格2绑定事件
- Table.api.bindevent(table2);
- table2.on('post-body.bs.table', function () {
- $(".btn-editone").data("area", ["1020px", "775px"]);
- })
- }
- },
- add: function () {
- Controller.api.bindevent();
- $(document).on("change", "#J_unitselect", function () {
- $.get('diary/huoq', {
- id: $("#J_unitselect").val()
- }, function (res) {
- $('#c-orgcadre').val(res.data.orgcadre);
- $('#c-orgsoldier').val(res.data.orgsoldier);
- $('#c-orgcivilian').val(res.data.orgcivilian);
- $('#c-nowcadre').val(res.data.nowcadre);
- $('#c-nowsoldier').val(res.data.nowsoldier);
- $('#c-nowcivilian').val(res.data.nowcivilian);
- });
- //选择单位获取一周工作计划当日内容
- Controller.api.getweekwork();
- });
- $(document).on("changed", "#c-blog_date", function () {
- Controller.api.getweekwork();
- });
-
- $('#fff').on('keyup','.J_should_arrive,.J_real_to',function(){
- var o = $(this).parents('tr');
- var a = o.find('.J_should_arrive').val();
- var b = o.find('.J_real_to').val();
- if(a && b)o.find('.J_percentage').val((b/a*100).toFixed(2)+"%");
- });
-
- $("#c-people_id,#c-dutylead,#c-dutyA,#c-dutyB,#c-dutyC,#c-dutyD,#c-dutyE,#c-dutyF,#c-lead,.people_id1").data("params", function (obj) {
- //console.log($(this).attr('id'))
- var unit_id = $('#J_unitselect').val();
- return {
- "custom[unit_id][0]": "in",
- "custom[unit_id][1]": unit_id
- };
- });
- //因为日期选择框不会触发change事件,导致无法刷新textarea,所以加上判断
- $(document).on("dp.change", "#add-form .datetimepicker", function () {
- $(this).parent().prev().find("input").trigger("change");
- });
- $(document).on("fa.event.appendfieldlist", "#add-form .btn-append", function (e, obj) {
- Form.events.selectpage(obj);
- Form.events.datetimepicker(obj);
- });
- $(document).on('click', '.btn-append', function () {
- var form = $("#add-form");
- require(['bootstrap-datetimepicker'], function () {
- var options = {
- format: 'LT',
- icons: {
- time: 'fa fa-clock-o',
- date: 'fa fa-calendar',
- up: 'fa fa-chevron-up',
- down: 'fa fa-chevron-down',
- previous: 'fa fa-chevron-left',
- next: 'fa fa-chevron-right',
- today: 'fa fa-history',
- clear: 'fa fa-trash',
- close: 'fa fa-remove'
- },
- showTodayButton: true,
- showClose: true
- };
- $('.datetimepicker3', form).parent().css('position', 'relative');
- $('.datetimepicker3', form).datetimepicker(options).on('dp.change', "#add-form .datetimepicker3", function (e) {
- $(this, document).trigger("changed");
-
- });
- });
- $(".people_id1,.people_id2,.people_id3,.people_id4,.people_id6,.people_id5").data("params", function (obj) {
- var unit_id = $('#J_unitselect').val();
- return {
- "custom[unit_id][0]": "in",
- "custom[unit_id][1]": unit_id
- };
- });
- });
-
-
-
- },
- edit: function () {
- Controller.api.bindevent();
-
-
- $(document).on("changed", "#c-blog_date", function () {
- Controller.api.getweekwork();
- });
- $(document).on("change", "#J_unitselect", function () {
- $.get('diary/huoq', {
- id: $("#J_unitselect").val()
- }, function (res) {
- $('#c-orgcadre').val(res.data.orgcadre);
- $('#c-orgsoldier').val(res.data.orgsoldier);
- $('#c-orgcivilian').val(res.data.orgcivilian);
- $('#c-nowcadre').val(res.data.nowcadre);
- $('#c-nowsoldier').val(res.data.nowsoldier);
- $('#c-nowcivilian').val(res.data.nowcivilian);
- //选择单位获取一周工作计划当日内容
- Controller.api.getweekwork();
- });
- });
- $("#c-people_id,#c-dutylead,#c-dutyA,#c-dutyB,#c-dutyC,#c-dutyD,#c-dutyE,#c-dutyF,#c-lead,.people_id1").data("params", function (obj) {
- console.log($(this).attr('id'))
- var unit_id = $('#J_unitselect').val();
- return {
- "custom[unit_id][0]": "in",
- "custom[unit_id][1]": unit_id
- };
- });
- //因为日期选择框不会触发change事件,导致无法刷新textarea,所以加上判断
- $(document).on("dp.change", "#edit-form .datetimepicker", function () {
- $(this).parent().prev().find("input").trigger("change");
- });
- $(document).on("fa.event.appendfieldlist", "#edit-form .btn-append", function (e, obj) {
- Form.events.selectpage(obj);
- Form.events.datetimepicker(obj);
- });
- $(document).on('click', '.btn-append', function () {
- var form = $("#edit-form");
- require(['bootstrap-datetimepicker'], function () {
- var options = {
- format: 'LT',
- icons: {
- time: 'fa fa-clock-o',
- date: 'fa fa-calendar',
- up: 'fa fa-chevron-up',
- down: 'fa fa-chevron-down',
- previous: 'fa fa-chevron-left',
- next: 'fa fa-chevron-right',
- today: 'fa fa-history',
- clear: 'fa fa-trash',
- close: 'fa fa-remove'
- },
- showTodayButton: true,
- showClose: true
- };
- $('.datetimepicker3', form).parent().css('position', 'relative');
- $('.datetimepicker3', form).datetimepicker(options).on('dp.change', "#edit-form .datetimepicker3", function (e) {
- $(this, document).trigger("changed");
- });
- });
- $(".people_id1,.people_id2,.people_id3,.people_id4,.people_id6,.people_id5").data("params", function (obj) {
- var unit_id = $('#J_unitselect').val();
- return {
- "custom[unit_id][0]": "in",
- "custom[unit_id][1]": unit_id
- };
- });
- });
- },
- examine: function () {
- Controller.api.bindevent();
- $('#J_ok').click(function(){
- var id = $('#id').val();
- Layer.confirm('确定要通过吗?',{shade:false},function(index){
- $.get('diary/auth_status',{ids:id,examine:1},function(res){
- parent.Layer.closeAll();
- parent.$("a.btn-refresh").trigger("click");
- parent.Layer.msg(res.msg);
- });
- });
- });
-
- $('#J_no').click(function(){
- var id = $('#id').val();
- Layer.prompt({
- title:'驳回原因'
- },function(val,index){
- if(val){
- $.get('diary/auth_status',{ids:id,examine:2,contents:val},function(res){
- parent.Layer.closeAll();
- parent.$("a.btn-refresh").trigger("click");
- parent.Layer.msg(res.msg);
- });
- }else{
- Layer.msg('请输入原因');
- }
-
-
- })
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- getweekwork: function () {
- var date = $('#c-blog_date').val();
- var J_unitselect = $('#J_unitselect').val();
- var data = [];
- $.get('weekwork_register/index2', {
- time: date,
- unit_id: J_unitselect
- }, function (res) {
- $('#weekwork').val(res.data);
- $("#weekwork").css({
- 'background': '#F00'
- });
- $("#weekwork").trigger("fa.event.refreshfieldlist");
- // Form.events.fieldlist($('#weekwork'));
- console.log(res.data)
- });
- }
- }
- };
- return Controller;
- });
|