<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <th:block th:include="include :: header('患者管理品配置')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>

<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <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="SSpglJfspProductinfo-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="mdmCode"/>
                </div>

                <!-- D值品编码 -->
                <div class="customize-form-group">
                    <label>D值品编码:</label>
                    <input type="text" class="styled-input" placeholder="请输入D值品编码" name="d_value_code"/>
                </div>

                <!-- D值品名称 -->
                <div class="customize-form-group">
                    <label>D值品名称:</label>
                    <input type="text" class="styled-input" placeholder="请输入D值品名称" name="dValueName"/>
                </div>

                <!-- 规格 -->
                <div class="customize-form-group">
                    <label>规格:</label>
                    <input type="text" class="styled-input" placeholder="请输入规格" name="specification"/>
                </div>

                <!-- 通用名 -->
                <div class="customize-form-group">
                    <label>通用名:</label>
                    <input type="text" class="styled-input" placeholder="请输入通用名" name="genericName"/>
                </div>

                <!-- 商品名 -->
                <div class="customize-form-group">
                    <label>商品名:</label>
                    <input type="text" class="styled-input" placeholder="请输入商品名" name="productName"/>
                </div>

                <!-- 厂家简称 -->
                <div class="customize-form-group">
                    <label>厂家简称:</label>
                    <input type="text" class="styled-input" placeholder="请输入厂家简称" name="manufacturerShortName"/>
                </div>
                    <div class="customize-form-group">
                        <label>是否关联D值:</label>
                        <select name="isdvalue" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}">
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                <!-- 是否随访管理品 -->
                <div class="customize-form-group">
                    <label>是否随访管理品:</label>
                    <select name="isFollowUpManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>

                <!-- 是否冷链管理品 -->
                <div class="customize-form-group">
                    <label>是否冷链管理品:</label>
                    <select name="isColdChainManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>

                <!-- 是否登记管理品 -->
                <div class="customize-form-group">
                    <label>是否登记管理品:</label>
                    <select name="isRegisteredManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>

                <!-- 是否慈善援助管理品 -->
                <div class="customize-form-group">
                    <label>是否慈善援助管理品:</label>
                    <select name="isCharityAidManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>

                <!-- 给药方式 -->
                <div class="customize-form-group">
                    <label>给药方式:</label>
                    <select name="administrationMethod" class="styled-input" th:with="type=${@dict.getType('sys_select_dtp_yyff')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
                <!-- 企业流向管理方式 -->
                <div class="customize-form-group">
                    <label>企业流向管理方式:</label>
                    <select name="enterpriseFlowManagement" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yppz_qylxglfs')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
                <!-- 状态 -->
                <div class="customize-form-group">
                    <label>状态:</label>
                    <select name="status" class="styled-input" th:with="type=${@dict.getType('sys_hzgl_qyty_status')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
             </div>
             </form>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" id="button-open-2"  shiro:hasPermission="system:user:add">
                    <i class="fa fa-plus"></i> 新增患者管理品
                </a>
                <a class="btn btn-success" onclick="$.operate.add2()" shiro:hasPermission="system:user:add">
                    <i class="fa fa-plus"></i> 新增复购配置
                </a>
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:user:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-success" onclick="orderColumns()">-->
<!--                    <i class="fa fa-refresh"></i> 恢复顺序-->
<!--                </a>-->
            </div>

            <div class="col-sm-12 select-table table-bordered" style="width: 100%; overflow-x: hidden;">
<!--                <p class="select-title">按住表格列拖拽</p>-->
                <table id="bootstrap-table"  class="fixed-layout-table"></table>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: bootstrap-table-fixed-columns-js" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('gxhpz:yppz:edit')}]];
    var removeFlag = [[${@permission.hasPermi('gxhpz:yppz:remove')}]];
    var detailFlag = [[${@permission.hasPermi('gxhpz:yppz:view')}]];
    var prefix = ctx + "yppz/drugConfig";
    $(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);
        }
        queryArchivesList();
    });

    $("#button-open-2").click(function(){
        $.modal.open('新增患者管理品', prefix + "/add", '980', '920');
    })
    function queryArchivesList() {
        var options = {
            url: prefix + "/drugconfigList",
            viewUrl: prefix + "/drugConfigDetail/{id}",
            detailUrl: prefix + "/drugConfigDetail/{id}",
            createUrl: prefix + "/add",
            createUrl2: prefix + "/toCorrelationAdd",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            updateUrl2: prefix + "/toCorrelation/{id}",
            /*exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",*/
            sortName: "d_value_code",
            sortOrder: "asc",
            modalName: "患者管理品",
            modalName2: "复购配置",
            fitColumns: true,
            striped: true,
            autoRowHeight: true,
            rowNumbers: true,
            showFooter:true,  //是否显示表格底部区域。
            clickToSelect: true, //是否启用点击行时选中整行的功能。
            singleSelect: false, //是否仅允许选择一行
            fixedColumns: true,
            //fixedNumber: 3,
            fixedRightNumber: 1,
            columns: [
                // {
                // checkbox: true
                // },
                { field: 'id', title: '主键', align: 'center', visible: false },
                { field: 'mdmCode', title: '药品编码', align: 'center' },
                {
                    visible: editFlag == 'hidden' ? false : true,
                    title: 'D值关联状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        // 返回拼接后的字符串，既包含原始值也包含问号图标
                        return statusTools2(row);
                    }
                },
                { field: 'd_value_code', title: 'D值品编码', align: 'center' },
                { field: 'dValueName', title: 'D值品名称', align: 'center' },
                { field: 'genericName', title: '通用名', align: 'center' },
                { field: 'productName', title: '商品名', align: 'center' },
                { field: 'specification', title: '规格', align: 'center' },
                { field: 'packaging', title: '包装', align: 'center' },
                { field: 'manufacturerShortName', title: '厂家简称', align: 'center' },
                { field: 'isFollowUpManaged', title: '随访管理品', align: 'center',
                    formatter: function(value, row, index) {
                        switch (value) {
                            case 0:
                                return '否';
                                break;
                            case 1:
                                return '是';
                                break;
                            default:
                                return '-';
                        }
                    }},
                { field: 'isColdChainManaged', title: '冷链管理品', align: 'center',
                    formatter: function(value, row, index) {
                        switch (value) {
                            case 0:
                                return '否';
                                break;
                            case 1:
                                return '是';
                                break;
                            default:
                                return '-';
                        }
                    } },
                { field: 'isRegisteredManaged', title: '登记管理品', align: 'center',
                    formatter: function(value, row, index) {
                        switch (value) {
                            case 0:
                                return '否';
                                break;
                            case 1:
                                return '是';
                                break;
                            default:
                                return '-';
                        }
                    } },
                { field: 'isCharityAidManaged', title: '慈善援助品', align: 'center',
                    formatter: function(value, row, index) {
                        switch (value) {
                            case 0:
                                return '否';
                                break;
                            case 1:
                                return '是';
                                break;
                            default:
                                return '-';
                        }
                    } },
                { field: 'administrationMethod', title: '给药方式', align: 'center' },
                { field: 'enterpriseFlowManagement', title: '流向方式', align: 'center' },
                { field: 'updatedTime', title: '管理品更新日期', align: 'center' },
                { field: 'createdTime', title: '管理品创建时间', align: 'center' },
                { field: 'dvcreatedTime', title: 'D值关联时间', align: 'center' },
                { field: 'dvupdatedTime', title: 'D值更新时间', align: 'center' },
                { field: 'indicationDescription', title: '适应症', align: 'center' },
                { field: 'dosageAndAdministration', title: '用法用量', align: 'center' },
                { field: 'manufacturer', title: '厂家', align: 'center' },
                { field: 'createdBy', title: '创建人', align: 'center' },
                // {
                //     visible: editFlag == 'hidden' ? false : true,
                //     title: '配置状态',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         return statusTools(row);
                //     }
                // },
                // { field: 'status', title: '状态', align: 'center'  ,
                //     formatter: function(value, row, index) {
                //         switch (value) {
                //             case 0:
                //                 return '<span class=\"btn-danger">已停用</span>';
                //                 break;
                //             case 1:
                //                 return '<span class=\"btn-primary">已启用</span>';
                //                 break;
                //             default:
                //                 return '<span class=\"btn-warning">-</span>';
                //         }
                //     }},
                // { field: 'saleStatus', title: '销售状态', align: 'center' ,
                //     formatter: function(value, row, index) {
                //         switch (value) {
                //             case 0:
                //                 return '停售';
                //                 break;
                //             case 1:
                //                 return '可售';
                //                 break;
                //             default:
                //                 return '-';
                //         }
                //     }},
                // { field: 'createdTime', title: '创建时间', align: 'center' },
                // { field: 'updatedBy', title: '更新人', align: 'center' },
                // { field: 'dvupdatedby', title: 'D值更新人', align: 'center' },
                // { field: 'productImagePath', title: '商品图片路径', align: 'center' },

                {
                    title: '操作',
                    align: 'center',
                    width: 180,
                    formatter: function(value, row, index) {
                        if (row.id) {
                            var actions = [];
                            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-warning btn-xs ' + detailFlag + '" href="javascript:void(0)"  onclick="$.operate.view(\'' + row.id + '\')"><i class="fa fa-eye"></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('');
                        } else {
                            return "";
                        }
                    }
                }]
        };
        $.table.init(options);
    }
    function orderColumns() {
        $('#bootstrap-table').bootstrapTable('orderColumns', {
            id: 0,
            mdmCode: 1,
            'D值关联状态': 2, // 注意：这个字段没有指定field属性，因此不能直接使用这个名称来排序。
            d_value_code: 3,
            dValueName: 4,
            genericName: 5,
            productName: 6,
            specification: 7,
            packaging: 8,
            manufacturerShortName: 9,
            isFollowUpManaged: 10,
            isColdChainManaged: 11,
            isRegisteredManaged: 12,
            isCharityAidManaged: 13,
            administrationMethod: 14,
            enterpriseFlowManagement: 15,
            updatedTime: 16,
            createdTime: 17,
            dvcreatedTime: 18,
            dvupdatedTime: 19,
            indicationDescription: 20,
            dosageAndAdministration: 21,
            manufacturer: 22,
            createdBy: 23
        })
    }
    /* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
    function resetPre() {
        resetDate();
        $("#SSpglJfspProductinfo-form")[0].reset();
        $.table.search();
        _refresh();
    }
    function edit_page(id){
        table.set();
        var url = "/404.html";
        if ($.common.isNotEmpty(id)) {
            url = table.options.updateUrl.replace("{id}", id);
        } else {
            var id = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (id.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            url = table.options.updateUrl.replace("{id}", id);
        }
        $.modal.openTab("修改" + table.options.modalName, url + "?editTage=1" );
    }

    /* 用户状态显示 */
    function statusTools(row) {
        if (row.status == 0) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')" style="color: red;"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')" style="color: green;"></i>  ';
        }
    }
    /* D值关联和停用*/
    function statusTools2(row) {
        if (row.dvalueStatus == '2') {
            return '<a class="btn btn-success btn-xs ' + editFlag + '" onclick="$.operate.edit2(\'' + row.id + '\')">去关联</a>&nbsp;|状态:未关联 ';
        } else if (row.dvalueStatus == 1) {
            return '<i class="fa fa-toggle-on text-info fa-2x" onclick="stoped(\'' + row.id + '\')" style="color: green; font-size: 16px;">启用中</i>';
        } else if (row.dvalueStatus == 0) {
            return '<i class="fa fa-toggle-off text-info fa-2x" onclick="start(\'' + row.id + '\')" style="color: red;font-size: 16px;">已停止</i>';
        } else {
            return '<a class="btn btn-success btn-xs ' + editFlag + '" onclick="$.operate.edit2(\'' + row.id + '\')">去关联</a>&nbsp;|状态:未关联 ';
        }
            }
    /* 停用 */
    function disable(id) {
        $.modal.confirm("确认要停用用户吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
        })
    }
    /* 启用 */
    function enable(id) {
        $.modal.confirm("确认要启用用户吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
        })
    }
    /* 去关联 */
    function correlation(id) {
        //弹框做操作
        // $.modal.confirm("确认要启用用户吗？", function() {
        //     $.operate.post(prefix + "/toCorrelation", { "id": id, "status": 1 });
        // })
        onclick="$.operate.edit(\'' + row.id + '\')"
        var options = {
            title: '添加复购品',
            url: prefix + "/toCorrelation"+id,
            callBack: doSubmit2
        };
        $.modal.openOptions(options);
    }
    /* 启用关联 */
    function start(id) {
        $.modal.confirm("确认要启用D值关联吗？", function() {
            $.operate.post(prefix + "/changesdvalueStatus", { "id": id, "dvalueStatus": 1 });
        })
    }
    /* 停止关联 */
    function stoped(id) {
        $.modal.confirm("确认要停用D值关联吗？", function() {
            $.operate.post(prefix + "/changesdvalueStatus", { "id": id, "dvalueStatus": 0 });
        })
    }

</script>
<style>
    .fa-2x {
        font-size: 2em;
    }

</style>
</body>

</html>
//