<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <th:block th:include="include :: header('跟进人信息')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>

<body><div class="main-content">


    <div class="row">
        <div class="col-sm-12 search-collapse">
            <div class="query-condition-container">
                <h4 class="query-condition-title">查询条件</h4>
                <div class="query-buttons">
                    <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="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                </div>
            </div>
            <form id="tag-form" class="customize-search-form">
                <div class="customize-form-group-container">
                    <div class="customize-form-group">
                        <label>姓名:</label>
                        <input type="text" class="styled-input" placeholder="请输入姓名/手机号" name="query" style="width: 350px;"/>
                    </div>

<!--                    <div class="customize-form-group">-->
<!--                        <label>角色:</label>-->
<!--                        <select name="position" id="position" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yppz_roles')}">-->
<!--                            <option value="">请选择</option>-->
<!--                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                        </select>-->
<!--                    </div>-->
                </div>
            </form>
        </div>

    </div>
    <div class="row">
        <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 viewFlag = [[${@permission.hasPermi('dtp:configInfo:list')}]];
    var prefix = ctx + "dtp/pmService";

    $(function() {
        var panehHidden = false;
        if ($(this).width() < 1590) {
            panehHidden = true;
        }
        //$('body').layout({ initClosed: panehHidden, west__size: 185, resizeWithWindow: false });
        // 回到顶部绑定
        // if ($.fn.toTop !== undefined) {
        // 	var opt = {
        // 		win:$('.ui-layout-center'),
        // 		doc:$('.ui-layout-center')
        // 	};
        // 	$('#scroll-up').toTop(opt);
        // }
        queryUserList();
    });

    function queryUserList() {
        var options = {
            url: prefix + "/selectPharmacistsByStoreId",
            viewUrl: prefix + "/view/{id}",
            exportUrl: prefix + "/export",
            //sortName: "createTime",
            //sortOrder: "desc",
            modalName: "任务跟进人",
            showFooter:true,  //是否显示表格底部区域。
            clickToSelect: true, //是否启用点击行时选中整行的功能。
            singleSelect: true, //是否仅允许选择一行
            fixedColumns: true,
            //fixedNumber: 3,
            //fixedRightNumber: 1,
            columns: [
                {
                    checkbox: true // 如果需要复选框列的话保留此项
                },
                { field: "id", title: "主键", visible: false }, // 假设你不希望在表格中直接显示主键
                { field: "pharmacistName", title: "姓名" },
                { field: "position", title: "职位角色", visible: true }, // 审核药师，任务跟进人
                { field: "storeName", title: "所属门店名称" },
                { field: "phone", title: "手机号" },
                { field: "storeId", title: "所属门店ID", visible: false }, // 根据实际需求决定是否展示
                { field: "reviewPassword", title: "审核密码", visible: false }, // 敏感信息通常不展示
                { field: "createTime", title: "创建时间", visible: false },
                { field: "updateTime", title: "更新时间", visible: false },
                { field: "createBy", title: "创建人" , visible: false},
                { field: "updateBy", title: "修改人" , visible: false},
                { field: "status", title: "员工状态", formatter: function(value, row, index) {
                        if (value === 0) return '离职';
                        if (value === 1) return '在职';
                        if (value === 2) return '请假';
                        return '未知';
                    }}
            ]
        };
        $.table.init(options);
    }

    /* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
    function resetPre() {
        resetDate();
        $("#tag-form")[0].reset();
        $("#deptId").val("");
        $("#parentId").val("");
        $(".curSelectedNode").removeClass("curSelectedNode");
        $.table.search();
    }
    /* 添加用户-选择用户-提交(子页面调用父页面形式) */
    function submitHandler(index, layero) {
        debugger
        var rows = $.table.selectFirstColumns();

        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.close();
        // 父页面的方法
        // activeWindow().selectUsers();
        // 父页面的变量
        activeWindow().$('#userids').html('我是通过方式一来的：' + rows.join());
    }

    /* 添加用户-选择用户-提交(回调形式-父页面调用子页面) */
    function getSelections() {
        return $.table.selectFirstColumns();
    }

    function selectTableObject() {
        // 动态选择所有列并映射到更具描述性的名称
        var columnsData = {
            id: $.table.selectColumns('id'),
            pharmacistName: $.table.selectColumns('pharmacistName'),
            position: $.table.selectColumns('position'),
            storeName: $.table.selectColumns('storeName'),
            phone: $.table.selectColumns('phone'),
            storeId: $.table.selectColumns('storeId'),
            reviewPassword: $.table.selectColumns('reviewPassword'),
            createTime: $.table.selectColumns('createTime'),
            updateTime: $.table.selectColumns('updateTime'),
            createBy: $.table.selectColumns('createBy'),
            updateBy: $.table.selectColumns('updateBy'),
            status: $.table.selectColumns('status')
        };

        // 构建返回的对象数组
        var selectedRows = [];

        // 假设 $.table.selectColumns 返回的是一个数组，我们检查每个字段是否为空或未定义来判断是否有选择
        for (var i = 0; i < columnsData.id.length; i++) {
            if (columnsData.id[i]) { // 如果 id 存在，则认为该行被选中
                var row = {
                    id: columnsData.id[i],
                    pharmacistName: columnsData.pharmacistName[i],
                    position: columnsData.position[i],
                    storeName: columnsData.storeName[i],
                    phone: columnsData.phone[i],
                    storeId: columnsData.storeId[i],
                    reviewPassword: columnsData.reviewPassword[i],
                    createTime: columnsData.createTime[i],
                    updateTime: columnsData.updateTime[i],
                    createBy: columnsData.createBy[i],
                    updateBy: columnsData.updateBy[i],
                    status: function(value) {
                        if (value === 0) return '离职';
                        if (value === 1) return '在职';
                        if (value === 2) return '请假';
                        return '未知';
                    }(columnsData.status[i])
                };
                selectedRows.push(row);
            }
        }

        return selectedRows;
    }
    /*回调返回所有的选中行数据*/
    function selectColumns2() {
        return $.table.selectColumns2();
    }
    $("#bootstrap-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) {
        var rows = $.common.equals("uncheck-all", e.type) ? rowsBefore : rowsAfter;
        var rowIds = $.table.affectedRowIds(rows);
        $("#rowIds").val(rowIds);
    });
</script>
</body>

</html>
