<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>

<script type="text/javascript">
    var rsResourceDimensionDialog={
        dialog :frameElement.dialog,
        appResourceDeatilId : "${appResourceDetail.id}",
        $layout: $("#div_look_form"),
        $form: $("#div_dimension_form"),//表单对象
        $btnSave: $("#btn_save"),//保存按钮对象
        $btnCancel: $("#btn_cancel"),//关闭按钮对象
        $btnSelectDimension:$("#dimensionId"),//下拉框
        $btnDimensionValue:$("#dimensionValue"),//文本框
        $resourceMetadataName:$("#resourceMetadata_name"),//文本框
        init: function () {
            this.initLayout();
            this.initBtn();
        },
        initLayout: function () {
            this.$layout.ligerLayout({
                bottomHeight: 35,
                allowBottomResize: false,
                allowTopResize: false,
                height:"96%"
            });
            //l-layout-left
            $("#div_look_form .l-layout-left").css({"border": "0px"});
            $("#div_look_form .l-layout-right").css({"border": "0px"});
            $("#div_look_form .l-layout-center").css({"border": "0px"});
            $("#div_look_form .l-layout-top").css({"border": "0px"});
            $("#div_look_form .l-layout-bottom").css({"border": "0px"});

            this.$resourceMetadataName.ligerTextBox({width: 240, value:"${metadataName.name}"});
            this.$btnSelectDimension=this.$btnSelectDimension.ligerComboBox({
                width: 125,
                valueField:"dimensionId",
                textField:"name",
                data:JSON.parse('${resultSelect}')
            });
            this.$form.attrScan();
            this.$form.Fields.fillValues({
                dimensionId: '${appResourceDetail.dimensionId}',
                dimensionValue: '${appResourceDetail.dimensionValue}'
            });
            this.$btnDimensionValue=this.$btnDimensionValue.ligerTextBox({width: 240});
        },
        initBtn: function () {
            this.$btnSave.click(function () {
                $.ajax({ //ajax处理
                    type: "POST",
                    url: "${contextRoot}/resource/resource/saveResourceDimension",
                    dataType: "json",
                    data: {appResourceDeatilId:appResourceDeatilId,value:appInfoForm.$btnDimensionValue.getValue(),dimensionId:appInfoForm.$btnSelectDimension.getValue()},
                    success: function (data) {
                        if (data.successFlg) {
                            window.parent.dialogSuccess(data.message,"2");
                        }
                        else {
                            $.ligerDialog.error(data.message);
                        }
                    },
                    error: function (data) {
                        $.ligerDialog.error("Status:" + data.status + "(" + data.statusText + ")");
                    }
                });
            });
            this.$btnCancel.click(function () {
                rsResourceDimensionDialog.dialog.close();
            });
        }
    }
    $(function () {
        rsResourceDimensionDialog.init();
    });
</script>