supplierreconciliation.js 3.9 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

var rowId = "";

//单据的时间
var operTime = "";

layui.config({
    base: basePath,
    version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'table', 'jquery', 'winui', 'form', 'laydate'], function (exports) {
    winui.renderColor();
    var $ = layui.$,
        form = layui.form,
        laydate = layui.laydate,
        table = layui.table;
    
    //初始化统计时间
	operTime = getOneYMFormatDate();
	
	//获取本月日期
	function getOneYMFormatDate(){
		 var date = new Date;
		 var year = date.getFullYear(); 
		 var month = date.getMonth() + 1;
		 month = (month < 10 ? "0" + month : month); 
		 return year.toString() + "-" + month.toString();
	}
	
W
weizhiqiang 已提交
31
    laydate.render({elem: '#operTime', type: 'month', value: operTime});
doc_wei's avatar
doc_wei 已提交
32 33 34 35 36 37 38 39
	
	//初始化数据
	initTable();
	function initTable(){
	    table.render({
	        id: 'messageTable',
	        elem: '#messageTable',
	        method: 'post',
doc_wei's avatar
doc_wei 已提交
40
	        url: flowableBasePath + 'statistics006',
doc_wei's avatar
doc_wei 已提交
41 42 43 44 45 46 47
	        where: {operTime: operTime, organName: $("#organName").val()},
	        even: true,
	        page: true,
	        limits: [8, 16, 24, 32, 40, 48, 56],
	        limit: 8,
	        cols: [[
	            { title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers'},
W
weizhiqiang 已提交
48
	            { field: 'defaultNumber', title: '单据编号', align: 'left', width: 250, templet: function (d) {
doc_wei's avatar
doc_wei 已提交
49
			        var str = '<a lay-event="details" class="notice-title-click">' + d.defaultNumber + '</a>';
W
weizhiqiang 已提交
50
			        if (!isNull(d.linkNumber)){
doc_wei's avatar
doc_wei 已提交
51 52 53
			        	str += '<span class="state-new">[转]</span>';
				        if(d.status == 2){
				        	str += '<span class="state-up"> [正常]</span>';
doc_wei's avatar
doc_wei 已提交
54
				        } else {
doc_wei's avatar
doc_wei 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
				        	str += '<span class="state-down"> [预警]</span>';
				        }
			        }
			        return str;
			    }},
			    { field: 'subTypeName', title: '单据类型', align: 'left', width: 100},
	            { field: 'supplierName', title: '供应商名称', align: 'left', width: 120},
	            { field: 'totalPrice', title: '合计金额', align: 'left', width: 100},
	            { field: 'changeAmount', title: '实际支付', align: 'left', width: 120},
	            { field: 'operTime', title: '退货数量', align: 'center', width: 150}
	        ]],
		    done: function(){
		    	matchingLanguage();
		    }
	    });
	    table.on('tool(messageTable)', function (obj) {
	        var data = obj.data;
	        var layEvent = obj.event;
	        if (layEvent === 'details') { //详情
	        	details(data);
	        }
	    });
	    form.render();
	}
	
	// 详情
W
weizhiqiang 已提交
81
	function details(data) {
doc_wei's avatar
doc_wei 已提交
82 83 84 85 86 87 88
		rowId = data.id;
		var url = erpOrderUtil.getErpDetailUrl({subType: data.subType});
		_openNewWindows({
			url: url, 
			title: "单据详情",
			pageId: "otherwarehousdetails",
			area: ['90vw', '90vh'],
W
weizhiqiang 已提交
89
			callBack: function (refreshCode) {
doc_wei's avatar
doc_wei 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
			}});
	}
	
    
    form.on('submit(formSearch)', function (data) {
        
        if (winui.verifyForm(data.elem)) {
            loadTable();
        }
        return false;
    });

    $("body").on("click", "#reloadTable", function() {
        loadTable();
    });

    $("body").on("click", "#formSearch", function () {
        refreshTable();
    })
    
    //刷新
W
weizhiqiang 已提交
111 112
    function loadTable() {
    	if(isNull($("#operTime").val())) {//一定要记得,当createTime为空时
doc_wei's avatar
doc_wei 已提交
113
    		winui.window.msg("请选择日期.", {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
114 115
    	}else {
    		operTime = $("#operTime").val();
116
	        table.reloadData("messageTable", {where:{operTime: operTime, organName: $("#organName").val()}});
doc_wei's avatar
doc_wei 已提交
117 118 119 120 121
    	}
    }

    //搜索
    function refreshTable(){
W
weizhiqiang 已提交
122
    	if(isNull($("#operTime").val())) {//一定要记得,当createTime为空时
doc_wei's avatar
doc_wei 已提交
123
    		winui.window.msg("请选择日期.", {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
124 125
    	}else {
    		operTime = $("#operTime").val();
126
	        table.reloadData("messageTable", {page: {curr: 1}, where:{operTime: operTime, organName: $("#organName").val()}})
doc_wei's avatar
doc_wei 已提交
127 128 129 130 131
    	}
    }

    exports('customerreconciliation', {});
});