<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ouyangzhaochang2663 $
    $Date: 2011/02/21 08:37:47 $
    $Revision: 1.13 $
    $Purpose: UPDATE BY DJ 重构大部分代码
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="pageLink_edit_user" url="${/request/@context_path}/modules/sys/SYS8210/sys_user_edit.lview"/>
        <a:link id="pageLink_set_password" url="${/request/@context_path}/modules/sys/SYS8210/sys_user_set_password.lview"/>
        <a:link id="pageLink_create_user" url="${/request/@context_path}/modules/sys/SYS8210/sys_user_create.lview"/>
        <a:link id="pageLink_role_assign" url="${/request/@context_path}/modules/sys/SYS8210/sys_user_role_assign.lview"/>
        <a:link id="project_submit_link_id" model="prj.PRJ001.wh_train_project" modelaction="execute"/>
        <script><![CDATA[

        function project_query() {
            $('projectDs').query();
        }

        function project_create(){
            new Leaf.Window({
                id:'sys_user_create',
                url:$('pageLink_create_user').getUrl(),
                title:'${l:SYS_USER.ADD_NEW_USER}',
                height:380,
                width:530
            });
        }

        function project_update(id){
            new Leaf.Window({id:'sys_user_edit',
                url:$('pageLink_edit_user').getUrl(),
                params:{
                    user_id:id
                },
                title:'${l:SYS_USER.EDIT_USER}',
                height:380,
                width:530
            });
        }

        function winOpen_query_project(project_id){
            new Leaf.Window({id:'sys_user_edit',
                url:$('pageLink_edit_user').getUrl(),
                params:{
                    project_id:project_id
                },
                title:'项目查询',
                height:380,
                width:530
            });
        }

        function project_number_renderer(value, record, name){
            var project_id = record.get('project_id');
            var project_number = record.get('project_number');
            if(name=='project_number')
            {
                return '<a href="javascript:winOpen_query_project(\'' + project_id + '\');">' + value + '</a>';

            }
            return '';
        }

        function project_submit() {
            var records=$('projectDs_grid').getSelected();
            if(records.length!=1)
            {
                Leaf.showMessage('${l:PROMPT_MESSAGE}', '请选择一条记录');
                return;
            }
            var record = records[0];
            Leaf.showConfirm('确认','您确定提交审核吗?',function(){
                Leaf.request({
                    url:$('project_submit_link_id').getUrl(),
                    para:{
                        project_id:record.get('project_id')
                    },
                    success: function() {
                        Leaf.SideBar.show({
                            msg: '提交成功',
                            duration: 2000
                        });
                        project_query();
                    },
                    scope: this
                });
            });
        }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="statusDs" loadData="true" lookupCode="项目列表"/>
            <a:dataSet id="para_projectDs" autoCreate="true">
                <a:fields>
                    <a:field name="status_n" displayField="code_value_name" options="statusDs" returnField="status" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="projectDs" autoQuery="true" model="prj.PRJ001.wh_train_project" pageSize="15" queryDataSet="para_projectDs"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="project_query" text="查询"/>
                <a:gridButton click="project_create" text="新增"/>
                <a:gridButton click="project_update" text="修改"/>
                <a:gridButton click="project_submit" text="提交审批"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="100" title="HLS.QUERY_TITLE">
                <a:textField name="project_number" bindTarget="para_projectDs" prompt="项目编码"/>
                <a:numberField name="amount" bindTarget="para_projectDs" prompt="项目金额"/>
                <a:comboBox name="status_n" bindTarget="para_projectDs" prompt="项目状态"/>
            </a:form>
            <a:grid id="projectDs_grid" bindTarget="projectDs" marginHeight="180" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="project_number" prompt="项目编码" width="150"  renderer="project_number_renderer"/>
                    <a:column name="amount" align="center" prompt="项目金额" renderer="Leaf.formatDate"/>
                    <!--<a:column name="status_n" prompt="项目状态"/>-->
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>