<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: trd
    $Date: 2024-5-11 下午4:03:43
    $Revision: 1.0  
    $Purpose: 二手机产品线细分
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
          <script type="text/javascript"><![CDATA[
            function division_detail_add() {
             $('hls_division_detail_grid').showEditorByRecord($('hls_division_detail_result_ds').create());
           }

           function division_detail_grid_clear() {
                $('hls_division_detail_grid').clear();
            }

           function division_detail_grid_query() {
            $('hls_division_detail_result_ds').query();
           }


          /*function division_detail_delete() {
              $('hls_division_detail_grid').remove();
          }*/

           function agent_detail_add() {
            var bankDs=$('hls_division_detail_result_ds');
            var record=bankDs.getCurrentRecord();
            if(Ext.isEmpty(record))
            {
                return ;
            }
            else if(record.isNew)
            {
                Leaf.showMessage('${l:HLS.PROMPT}','请先保存产品明细，才能新增代理店');
                return ;
            }
            $('hls_agent_division_detail_grid').showEditorByRecord($('hls_agent_division_detail_result_ds').create({
                division_detail_id:record.get('division_detail_id'),
                division_detail_code:record.get('division_detail_code')
            }));

        }

         function agent_detail_grid_clear() {
            $('hls_agent_division_detail_grid').clear();
        }

          function division_detail_submit() {
            var result_ds = $('hls_division_detail_result_ds');
            if (result_ds.validate()) {
                result_ds.submit();
            }
          }



          function divisionCodeFunction(record, name) {
                if (record.isNew) {
                    return 'division_detail_tf';
                } else {
                    return '';
                }
            }

          function agentCodeFunction(record, name) {
          if (record.isNew) {
              return 'agent_bp_code_lv';
          } else {
              return '';
          }
      }

        ]]></script>
        <a:dataSets>
             <a:dataSet id="hls_division_detail_result_ds" autoQuery="true" fetchAll="true" model="hls.HLS103.hls_division_detail" selectionModel="single" selectable="true" submitUrl="hls_detail.lsc">
                <a:fields>
                    <a:field name="division" defaultValue="${/parameter/@division}" readOnly="true"/>
                    <a:field name="description" defaultValue="${/parameter/@description}" readOnly="true"/>
                    <a:field name="division_detail_code" required="true"/>
                    <a:field name="division_detail_name" required="true"/>
                    <a:field name="enable_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                 </a:fields>
            </a:dataSet>
            <a:dataSet id="hls_agent_division_detail_result_ds" bindName="agent_info" bindTarget="hls_division_detail_result_ds"  autoQuery="true" fetchAll="false" model="hls.HLS103.hls_agent_division_detail" queryUrl="${/request/@context_path}/autocrud/hls.HLS103.hls_agent_division_detail/query?division_detail_code=${/parameter/@division_detail_code}" selectable="true">
            <a:fields>
                <a:field name="division_detail_code" readOnly="true"/>
                <a:field name="agent_bp_code" lovGridHeight="300" lovHeight="450" lovLabelWidth="120"
                               lovService="basic.hls_bp_master_v_for_lov?bp_category=AGENT" lovWidth="600" title="代理店">
                 <a:mapping>
                  <a:map from="bp_id" to="agent_bp_id"/>
                  <a:map from="bp_code" to="agent_bp_code"/>
                  <a:map from="bp_name" to="agent_bp_name"/>
                  </a:mapping>
                </a:field>
                <a:field name="enable_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
             </a:fields>
        </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="division_detail_add" text="新增产品线细分"/>
                <a:gridButton click="division_detail_grid_clear" text="移除产品线细分"/>
                <a:gridButton click="division_detail_grid_query" text="HLS.QUERY"/>
                <a:gridButton click="agent_detail_add" text="新增代理店"/>
                <a:gridButton click="agent_detail_grid_clear" text="移除代理店"/>
                <a:gridButton click="division_detail_submit" text="HLS.SAVE"/>
                <!--<a:gridButton click="division_detail_delete" text="HLS.DELETE"/>-->

               </a:screenTopToolbar>
            <a:grid id="hls_division_detail_grid" bindTarget="hls_division_detail_result_ds" Height="200" width="600">
                <a:columns>
                     <a:column name="description" align="left" sortable="true" width="100"/>
                     <a:column name="division_detail_code" align="center" prompt="产品线细分编码"  editorFunction="divisionCodeFunction" width="100"/>
                     <a:column name="division_detail_name" align="center" prompt="产品线细分名称"  editorFunction="divisionCodeFunction" width="200"/>
                     <a:column name="enable_flag" align="center" prompt="启用" editor="division_detail_grid_editor_check" width="60"/>
              </a:columns>
                <a:editors>
                     <a:textField id="division_detail_tf"/>
                     <a:checkBox id="division_detail_grid_editor_check"/>
                    </a:editors>
            </a:grid>
           <a:grid id="hls_agent_division_detail_grid" bindTarget="hls_agent_division_detail_result_ds" Height="200" width="600">
            <a:columns>
                <a:column name="division_detail_code" prompt="产品线细分编码" align="left" sortable="true" width="100"/>
                <a:column name="agent_bp_code" align="center" prompt="代理店编码"  editorFunction="agentCodeFunction" width="100"/>
                <a:column name="agent_bp_name" align="center" prompt="代理店名称"  width="250"/>
                <a:column name="enable_flag" align="center" prompt="启用" editor="agent_division_grid_editor_check" width="60"/>
            </a:columns>
            <a:editors>
               <a:lov id="agent_bp_code_lv"/>
               <a:checkBox id="agent_division_grid_editor_check"/>
            </a:editors>
        </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
