<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="pageLink_template_maintain" url="${/request/@context_path}/modules/zjwfl/ZJWFL1090/zj_sys_notify_template_update.lview"/>
        <a:link id="pageLink_person_define" url="${/request/@context_path}/modules/zjwfl/ZJWFL1090/zj_sys_notify_template_ln.lview"/>
        <script type="text/javascript"><![CDATA[
        
            function query_notifyDs(){
                $('notifyDs').query();
            }
            
            function refresh_notifyDs(){
            	var ds = $('notifyDs');
            	ds.query(ds.currentPage);
            }
            
            function template_maintain(notify_template_id,notify_type)
            {
                var win = new Leaf.Window({
                    id : 'zj_sys_notify_template_update', 
                    url:$('pageLink_template_maintain').getUrl(),
                    params : {
                    	notify_template_id : notify_template_id,
                    	notify_type : notify_type,
                    	usage_type : 'WFL'
                    },
                    title : '模板维护',
                    height : 550,
                    width :1000
                });
                
                win.on('close',function (){
                	refresh_notifyDs();
                });
            }
            
            function person_define(notify_template_id)
            {
                new Leaf.Window({
                    id : 'zj_sys_notify_template_ln', 
                    url:$('pageLink_person_define').getUrl(),
                    params : {
                    	notify_template_id : notify_template_id
                    },
                    title : '通知人',
                    height : 450,
                    width :700
                });
            }
            
            
            function render_notifyDs_grid(value,record,name)
            {
                if(!record.isNew)
                {
                    if(name=='template_maintain')
	                {
	                    return '<a href="javascript:template_maintain(' + record.get('notify_template_id') + ',\'' + record.get('notify_type') + '\')">' + '编辑' + '</a>';
	                }
	                else if(name=='person_define')
	                {
	                    if(Ext.isEmpty(record.get('workflow_type_code')))
	                    {
	                        return '<a href="javascript:person_define(' + record.get('notify_template_id') + ')">' + '通知人' + '</a>';
	                    }
	                    return '';
	                }
                }
                return '';
            }
                
            function editorFun_notifyDs_grid(record,name)
            {
                if(record.isNew)
                {
                    if(name=='workflow_type_code')
                	{
                    	return 'notifyDs_grid_lov';
	                }
	                else if(name=='notify_template_code')
	                {
	                    return 'notifyDs_grid_tf_upper';
	                }
	                return '';
                }
                return '';
            }
        
        ]]></script>
        <a:dataSets>
            <a:dataSet id="notifyTypeDs" lookupCode="ZJ_WFL_NOTIFY_TYPE"/>
            <a:dataSet id="para_notifyDs" autoCreate="true" model="zjwfl.ZJWFL1090.zj_sys_notify_template">
                <a:fields>
                    <a:field name="usage_type" defaultValue="WFL"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="notifyDs" autoPageSize="true" autoQuery="true" fetchAll="false" model="zjwfl.ZJWFL1090.zj_sys_notify_template" queryDataSet="para_notifyDs" selectable="true">
                <a:fields>
                    <a:field name="notify_template_code" required="true"/>
                    <a:field name="notify_type_desc" displayField="code_value_name" options="notifyTypeDs" required="true" returnField="notify_type" valueField="code_value"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="workflow_type_code" lovGridHeight="300" lovHeight="450" lovLabelWidth="100" lovService="zjwfl.zj_wfl_workflow_type_lov" lovWidth="550" required="true" title="工作流类型">
                        <a:mapping>
                            <a:map from="workflow_type_id" to="workflow_type_id"/>
                            <a:map from="workflow_type_code" to="workflow_type_code"/>
                            <a:map from="workflow_type_desc" to="workflow_type_desc"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form column="2" labelWidth="100" marginWidth="30" title="SYS_PROMPT.QUERY_TITLE">
                <a:textField name="notify_template_code" bindTarget="para_notifyDs" typeCase="upper" width="200">
                    <a:events>
                        <a:event name="enterdown" handler="query_notifyDs"/>
                    </a:events>
                </a:textField>
                <a:textField name="description" bindTarget="para_notifyDs" width="200">
                    <a:events>
                        <a:event name="enterdown" handler="query_notifyDs"/>
                    </a:events>
                </a:textField>
            </a:form>
            <a:hBox>
                <a:button click="query_notifyDs" text="HAP_QUERY"/>
            </a:hBox>
            <a:grid id="notifyDs_grid" bindTarget="notifyDs" marginHeight="180" marginWidth="30" navBar="true">
                <a:toolBar>
                    <a:button type="add"/>
                    <a:button type="delete"/>
                    <a:button type="save"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="workflow_type_code" autoAdjust="false" editorFunction="editorFun_notifyDs_grid" prompt="工作流类型" showTitle="true" width="200"/>
                    <a:column name="workflow_type_desc" autoAdjust="false" prompt="工作流描述" showTitle="true" width="200"/>
                    <a:column name="notify_template_code" autoAdjust="false" editorFunction="editorFun_notifyDs_grid" showTitle="true" width="250"/>
                    <a:column name="description" autoAdjust="false" editor="notifyDs_grid_tf" showTitle="true" width="350"/>
                    <a:column name="notify_type_desc" editor="notifyDs_grid_comb" width="80"/>
                    <a:column name="enabled_flag" editor="notifyDs_grid_check" width="50"/>
                    <a:column name="template_maintain" align="center" renderer="render_notifyDs_grid" width="60"/>
                </a:columns>
                <a:editors>
                    <a:textField id="notifyDs_grid_tf_upper" maxLength="30" typeCase="upper"/>
                    <a:textField id="notifyDs_grid_tf"/>
                    <a:lov id="notifyDs_grid_lov"/>
                    <a:checkBox id="notifyDs_grid_check"/>
                    <a:comboBox id="notifyDs_grid_comb"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>