<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('选择供应商')" />
</head>

<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-10 search-collapse">
				<form id="role-form">

					<div class="select-list">
						<ul>
							<li>供应商名称：<input type="text" name="supplierName" />
							</li>
							<li>手机号码：<input type="text" name="mobile" />
							</li>
							<li><a class="btn btn-primary btn-rounded btn-sm"
								onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm"
								onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
	var industryDatas = [[${@dict.getType('industry')}]];
    var supplierStatusDatas = [[${@dict.getType('supplier_status')}]];
    var supplierDegreeDatas = [[${@dict.getType('supplier_degree')}]];
    var supplierCreditDatas = [[${@dict.getType('supplier_credit')}]];
    var prefix = ctx + "crm/supplier";

    $(function() {
        var options = {
            url: prefix + "/list",
            queryParams: queryParams,
	        sortName: "createTime",
	        sortOrder: "desc",
            showSearch: false,
	        showRefresh: false,
	        showToggle: false,
	        showColumns: false,
	        clickToSelect: true,
	        rememberSelected: true,
	        sortName: "createTime",
	        sortOrder: "desc",
            modalName: "产品供应商",
            columns: [{
            	radio: true
            },
            {
                field : 'supplierId', 
                title : '供应商ID',
	            sortable: true
            },
            {
                field : 'supplierName', 
                title : '名称',
	            sortable: true
            },
            {
                field : 'nameShort', 
                title : '简称',
	            sortable: true
            },
            {
                field : 'leader', 
                title : '负责人',
	            sortable: true
            },
            {
                field : 'mobile', 
                title : '手机',
	            sortable: true
            },
            {
                field : 'industry', 
                title : '所属行业',
                formatter: function(value, row, index) {
                   return $.table.selectDictLabel(industryDatas, value);
                },
	            sortable: true
            },
            {
                field : 'supplierStatus', 
                title : '状态',
                formatter: function(value, row, index) {
                   return $.table.selectDictLabel(supplierStatusDatas, value);
                },
	            sortable: true
            },
            {
                field : 'supplierDegree', 
                title : '等级',
                formatter: function(value, row, index) {
                   return $.table.selectDictLabel(supplierDegreeDatas, value);
                },
	            sortable: true
            },
            {
                field : 'supplierCredit', 
                title : '信誉度',
                formatter: function(value, row, index) {
                   return $.table.selectDictLabel(supplierCreditDatas, value);
                },
	            sortable: true
            }]
        };
        $.table.init(options);
    });
		
		function queryParams(params) {
			var search = $.table.queryParams(params);
			return search;
		}
		
		/* 添加产品-选择供应商-提交 */
		function submitHandler() {
			var id = $.table.selectFirstColumns();
			var name = $.table.selectColumns("supplierName");
			if (id.length == 0) {
       			$.modal.alertWarning("请选择一条记录");
       			return;
       		}
			$.modal.close();
			// 父页面的方法
			// parent.selectUsers();
			// 父页面的变量
			parent.$('#supplierId').val();
			parent.$('#supplierName').val();
			parent.$('#supplierId').val(id);
			parent.$('#supplierName').val(name);
		}
	</script>
</body>
</html>