<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('线索列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>手机号：</label>
                            <input type="text" name="phone"/>
                        </li>
                        <li>
                            客服: <select name="saleId" id="saleId">
                                <option text="请选择" value=""></option>
                                <option th:each="user:${users}" th:value="${user.userId}"
                                        th:text="${user.userName}"></option>
                            </select>
                        </li>
                        <li>
                            App来源：<select name="remark" th:with="type=${@dict.getType('app_source')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            加微：<select name="isAddWx" th:with="type=${@dict.getType('is_add_wx')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            有效：<select name="isEffective" th:with="type=${@dict.getType('is_effective')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            意向：<select name="isPlan" th:with="type=${@dict.getType('is_plan')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            成交：<select name="isDeal" th:with="type=${@dict.getType('is_deal')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            来源应用：<select name="sourceApp">
                            <option value="">所有</option>
                            <option value="1">黑猫搞定逾期</option>
                            <option value="2">大象债务处理</option>
                            <option value="8">百度来源</option>
                        </select>
                        </li>
                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                        </li>
                        <li class="select-time">
                            <label>分配时间： </label>
                            <input type="text" class="time-input" id="updateStartTime" placeholder="开始时间" name="params[updateStartTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="updateEndTime" placeholder="结束时间" name="params[updateEndTime]"/>
                        </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="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary multiple disabled" onclick="changeBatchUser()" shiro:hasPermission="system:clew:edit">
                <i class="fa fa-remove"></i> 批量分配
            </a>
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:clew:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:clew:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:clew:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:clew:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </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 editFlag = [[${@permission.hasPermi('system:clew:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:clew:remove')}]];

    var isAddWx = [[${@dict.getType('is_add_wx')}]];
    var isEffective = [[${@dict.getType('is_effective')}]];
    var isPlan = [[${@dict.getType('is_plan')}]];
    var isDeal = [[${@dict.getType('is_deal')}]];
    var customerStatus = [[${@dict.getType('customer_status')}]];
    var assignStatus = [[${@dict.getType('assign_status')}]];

    var prefix = ctx + "system/clew";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "线索",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'sourceAppName',
                    title: '来源App'
                },
                {
                    field: 'phone',
                    title: '手机号'
                },
                {
                    field: 'customerName',
                    title: '姓名'
                },
                {
                    field: 'wxName',
                    title: '微信昵称',
                    visible: false
                },
                {
                    field: 'debtType',
                    title: '债务类型',
                    visible: false
                },
                {
                    field: 'debtMoney',
                    title: '债务金额'
                },
                {
                    field: 'remark',
                    title: 'App来源'
                },
                {
                    field: 'customerRemark',
                    title: '客户情况备注'
                },
                {
                    field: 'twoCustomerRemark',
                    title: '二次跟进情况'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'updateTime',
                    title: '分配时间'
                },
                {
                    field: 'assignTimes',
                    title: '二次分配',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(assignStatus, value);
                    }
                },
                {
                    field: 'sourceType',
                    title: '推广来源',
                    visible: false
                },
                {
                    field: 'customerStatus',
                    title: '客户状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(customerStatus, value);
                    }
                },
                {
                    field: 'customerLevel',
                    title: '客户评级',
                    visible: false
                },
                {
                    field: 'nextTime',
                    title: '下次跟进日期',
                    visible: false
                },
                {
                    field: 'touchQrcode',
                    title: '是否长按识别二维码',
                    visible: false
                },
                {
                    field: 'contactNumber',
                    title: '跟进次数',
                    visible: false
                },
                {
                    field: 'isTouch',
                    title: '是否触达',
                    visible: false
                },
                {
                    field: 'isAddWx',
                    title: '是否加微',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(isAddWx, value);
                    }
                },
                {
                    field: 'isEffective',
                    title: '是否有效',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(isEffective, value);
                    }
                },
                {
                    field: 'isPlan',
                    title: '是否意向',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(isPlan, value);
                    }
                },
                {
                    field: 'isDeal',
                    title: '成交状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(isDeal, value);
                    }
                },
                {
                    field: 'wxAccount',
                    title: '成交金额'
                },
                {
                    field: 'provinceName',
                    title: '省份'
                },
                {
                    field: 'cityName',
                    title: '城市',
                    visible: false
                },
                {
                    field: 'contactTime',
                    title: '方便接电话时间',
                    visible: false
                },
                {
                    field: 'otherPhone',
                    title: '其他联系方式',
                    visible: false
                },
                {
                    field: 'company',
                    title: '广告主',
                    visible: false
                },
                {
                    field: 'sourceSaleName',
                    title: '原始销售'
                },
                {
                    field: 'saleName',
                    title: '销售'
                },
                {
                    field: 'infoFlow',
                    title: '信息流',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="changeUser(\'' + row.id + '\')"><i class="fa fa-remove"></i>分配客服</a>');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    /* 用户管理-停用 */
    function getBackClew(id) {
        $.modal.confirm("确定要取回该线索吗？", function() {
            $.operate.post(prefix + "/getBackClew", { "id": id});
        })
    }

    /* 用户管理启用 */
    function addPublicClew(id) {
        $.modal.confirm("确定要加入公海池吗？", function() {
            $.operate.post(prefix + "/addPublicClew", { "id": id});
        })
    }

    /* 选择供应商 */
    function changeUser(clewId) {
        var url = prefix + '/changeUser/' + clewId;
        $.modal.open("选择客服", url, '800', '300');
    }

    function changeBatchUser(){
        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认分配吗？", function() {
            $.modal.open("选择客服", prefix + '/changeBatchUser/' + rows.join(), '800', '300');
        })
    }
</script>
</body>
</html>