supplier.Index.js 4.99 KB
webpackJsonp([182],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	'use strict';
	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	var ENUM = {
	    status: {100: '暂存', 200: '审核中', 300: '通过', 900: '驳回'},
	    isFreeze: {'Y': '已冻结', 'N': '生效中'},
	    operations: {1: '创建', 2: '编辑', 3: '冻结', 4: '解冻'}
	};

	new common.dropDown({el: '#supplier-name', ajax: 'supplier'});
	new common.dropDown({el: "#status"});
	new common.dropDown({el: "#time-sort"});
	new common.dropDown({el: "#isFreeze"});

	var btnAuthority = JSON.parse($("#btnAuthority").val());

	var g = new common.grid({
	    el: "#basicTable",
	    parms: function () {
	        return {
	            id: common.util.__input("supplier-name"),
	            status: common.util.__input("status"),
	            timeSort: common.util.__input("time-sort"),
	            isFreeze: common.util.__input("isFreeze")
	        };
	    },
	    columns: [
	        {display: "供应商ID", name: "id"},
	        {display: "供应商", name: "supplierName"},
	        {display: "更新时间", name: "updateTime"},
	        {
	            display: "最近操作", name: "operations", hidden: btnAuthority.columnsHidOper, render: function (item) {
	            return ENUM.operations[item.operations];
	        }
	        },
	        {
	            display: "状态", name: "status", render: function (item) {
	            return ENUM.status[item.status];
	        }
	        },
	        {
	            display: "是否生效", name: "isFreeze", hidden: btnAuthority.columnsHidisFr, render: function (item) {
	            return ENUM.isFreeze[item.isFreeze];
	        }
	        },
	        {
	            display: "操作", name: "id", render: function (item) {
	            var HtmArr = [];
	            // 是否冻结 Y-是,N-否
	            // 状态 100-暂存,200-审核中,300-通过,900-驳回
	            // 最近操作 1-创建,2-编辑, 3-冻结, 4-解冻
	            if (btnAuthority.edit) {
	                HtmArr.push('<a href="/supplier/infoopt/' + item.id + '" class="btn btn-info btn-xs">查看</a>');
	            } else {
	                HtmArr.push('<a href="/supplier/info/' + item.id + '" class="btn btn-info btn-xs">查看</a>');
	            }
	            if (item.status != "200") {
	                //updatecheck
	                if (btnAuthority.updatecheck) {
	                    HtmArr.push('<a href="/supplier/updatecheck/' + item.id + '" class="btn btn-success btn-xs btn-edit">编辑</a>');
	                } else {
	                    HtmArr.push('<a href="/supplier/update/' + item.id + '" class="btn btn-success btn-xs btn-edit">编辑</a>');
	                }
	            }
	            //暂存时,有提交
	            if (item.status == "100") {
	                HtmArr.push('<a href="JavaScript:;" data-index="' + item.__index + '" class="btn btn-primary btn-xs btn-submit">提交</a>');
	            }
	            if (btnAuthority.resetlock && item.isFreeze == "Y" && (item.status == "300" || item.status == "900")) {
	                HtmArr.push('<a href="javascript:;" data-index="' + item.__index + '" class="btn btn-warning btn-xs btn-recovery">恢复</a>');
	            }
	            if (btnAuthority.resetlock && item.isFreeze == "N" && (item.status == "300" || item.status == "900")) {
	                HtmArr.push('<a href="javascript:;" data-index="' + item.__index + '" class="btn btn-danger btn-xs btn-freeze">冻结</a>');
	            }
	            return HtmArr.join('');
	        }
	        }
	    ]
	})

	g.init($("#gridurl").val());

	$("#filter-btn").click(function () {
	    g.reload(1);
	});

	var Bll = {
	    toast: function (content, fn) {
	        common.dialog.confirm("温馨提示", content, function () {
	            common.util.__ajax({
	                url: '/supplier/index/status',
	                data: fn()
	            }, function () {
	                g.reload();
	            });
	        });
	    }
	}

	//提交操作
	$(document).on('click', '.btn-submit', function () {
	    var item = g.rows[$(this).data("index")];
	    var data = function () {
	        return {
	            id: item.id,
	            status: 200,
	            operations: item.operations
	        };
	    }
	    Bll.toast("确定要提交该申请吗?", data);
	});

	//冻结操作
	$(document).on('click', '.btn-freeze', function () {
	    var item = g.rows[$(this).data("index")];
	    var data = function () {
	        return {
	            id: item.id,
	            isFreeze: "Y",
	            operations: "3",
	            status: 200
	        };
	    }
	    Bll.toast("确定要冻结申请吗?", data);
	});

	//解冻操作
	$(document).on('click', '.btn-recovery', function () {
	    var item = g.rows[$(this).data("index")];
	    var data = function () {
	        return {
	            id: item.id,
	            isFreeze: "N",
	            operations: "4",
	            status: 200
	        };
	    }
	    Bll.toast("确定要解冻申请吗?", data);
	});



/***/ }
]);