<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei
    $Date: 2023-8-27 下午01:54:29
    $Revision: 1.0  
    $Purpose:  租赁物维护(经营性租赁)入口
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="prj2000_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
		<a:link id="prj_project_link" model="prj.PRJ2000.pur_order_wfl" modelaction="execute"/>
        <a:link id="prj2000_pur_order_deteail_link_id" url="${/request/@context_path}/modules/prj/PRJ2000/purchase_order_deteail.lview"></a:link>
        <script type="text/javascript"><![CDATA[


            //查询时调用(grid)
           /* window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                if (ds == $(ds_id)) {
                    aut_authority_list_validate_query(ds, qpara);
                }
            };*/
        //新建
        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var param = {};
                param['function_code'] = 'PRJ2000D';
                param['function_usage'] = 'CREATE';
                param['url_title'] = '采购申请单维护';
                //param['default_value_dsid']=ds_id;
                hls_doc_get_layout_code('prj2000_get_layout_code_link_id', param, 'prj2000_pur_order_deteail_link_id', ds_id, '${/parameter/@layout_code}');


        };
		//取消
        window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
            debugger;
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            var records = $(ds_id).getSelected();
            var projectId = records[0].data.project_id;
            if(records[0].data.project_status=='APPROVING' || records[0].data.project_status=='APPROVED' || records[0].data.project_status=='CANCEL'){
                Leaf.showMessage('${l:PROMPT}', '请选择新建或审批退回的采购单进行取消操作!');
                return;
        };
            Leaf.showConfirm('${l:PROMPT}', '是否确定取消该单据?', function () {
                Leaf.request({
                    url: $('prj_project_link').getUrl(),
                    para:{project_id:projectId},
                    success: function () {
                        Leaf.SideBar.show({
                            msg: '取消成功',
                            duration: 2000
                        });
                        $(ds_id).query();
                    },
                    scope: this
                });
            }, function () {
            }, null, null);
        };


        //租赁物导出
        window['${/parameter/@layout_code}_G_PUR_ORDER_USER_BUTTON1_layout_dynamic_tab_click'] = function () {
            var lease_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            var grid_id = lease_item_ds_id.replace('ds', 'layout_grid_id');
            $(grid_id)._export();

        };

        function prj2000d_get_detail(id, name, query_only){
            debugger;
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
            var project_id=record.get('project_id');
            var projectStatus=record.get('project_status');
            var param = {};
            if(projectStatus=='NEW' || projectStatus=='APPROVED_RETURN'){
                param['function_code'] = 'PRJ2000D';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '采购申请单维护';
                param['project_id'] = project_id;
            }
            if(projectStatus=='APPROVING' || projectStatus=='CANCEL' || projectStatus=='APPROVED'){
                param['function_code'] = 'PRJ2000D_WFL';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'READONLY'
                param['url_title'] = '采购申请单维护';
                param['project_id'] = project_id;
            }
            hls_doc_get_layout_code('prj2000_get_layout_code_link_id', param, 'prj2000_pur_order_deteail_link_id', ds_id, '${/parameter/@layout_code}');

        }

        //超链接渲染
        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {
            var link_function = '';
            window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
            if (name == 'project_number') {
                link_function = 'prj2000d_get_detail';
                return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' +value + '</a>';
            }
        };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <!--<a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CON501&amp;function_code=PRJ501N"/>-->
    </a:view>
</a:screen>