con_contract_location.lview 16.2 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hand  
    $Date: 2016-5-2 上午10:17:06  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <!--  <a:model-query model="cont.CON555B.con_contract_location_ln" rootPath="con555B_get_location"/> --><![CDATA[
        
        
 
    ]]></a:init-procedure>
    <a:view>
        <a:link id="con_contract_getnumber_link" model="cont.CON555B.con555_get_info" modelaction="execute"/>
        <a:link id="con_modify_location_con_status_link" model="cont.CON555B.con_contract_location_ln" modelaction="execute"/>
        <a:link id="hls_doc_file_print_confirm" url="${/request/@context_path}/modules/hls/HLS811/hls_doc_file_print_con_confirm.lview"/>
        <a:link id="sys_user_link" model="cont.CON555B.sys_user" modelaction="query"/>
        <script type="text/javascript"><![CDATA[
            function lock_screen() {
                detail_mask = $('con_contract_location_window').wrap;
                Leaf.Masker.mask(detail_mask, 'con_contract_location_window');
            }
            
            function unlock_screen() {
                detail_mask = $('con_contract_location_window').wrap;
                Leaf.Masker.unmask(detail_mask);
            }
            
            function con555B_con_location_back() {
                $('con_contract_location_window').close();
            }
            
            function get_number(num) {
                var num2;
                if (num < 10) {
                    num2 = '00' + num;
            
                } else if (num >= 10 && num < 100) {
                    num2 = '0' + num;
            
                } else {
                    num2 = num;
                }
                return num2;
            }
            var is_save_lag = 'N';
            
            function con555B_con_location_confirm() {

                if (is_save_lag == 'Y') {
                    Leaf.showMessage('${l:HLS.PROMPT}', '已保存,不可再重复保存!');
                    return;
                }
            
                var rec = $('con_contract_location_ln_result_ds').getCurrentRecord();
                var rec_lease_term_ds = $('lease_term_ds').getCurrentRecord();
                var years = rec.get('years');
                var lease_term = rec_lease_term_ds.get('lease_term');
                var doc_type = rec.get('doc_type');
                var chest_number = rec.get('chest_number');
                var location_id = rec.get('location_id');
                // var doc_number = rec.get('doc_number');
                // if (!rec.dirty) {
                // return;
                // }
                if (p_location_id == location_id) {
                    if (${/parameter/@document_status} == '40' || ${/parameter/@document_status} =='20') {
                        Leaf.showMessage('${l:HLS.PROMPT}', '箱子未改变不能保存!');
                    }
                    return;
                }
            
                if (Ext.isEmpty(chest_number)) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '箱号不能为空!');
                    return;
                }
            
                // if (years != lease_term && doc_type == '20') {
                // Leaf.showMessage('${l:HLS.PROMPT}', '箱子的年份与合同年份不相等!');
                // return;
                // }
                var number;
                Leaf.request({
                    url: $('con_contract_getnumber_link').getUrl(),
                    para: {
                        location_id: rec.get('location_id')
                    },
                    sync: true,
                    success: function(res) {
                        // if (rec.get('doc_type') == '10') {
                        number = res.result.doc_number;
                        //  } else {
                        //      number = res.result.location_number2;
                        // }
            
                    }
                });
                if (number > 0) {
                    number = number + 1;
                } else {
                    number = 1;
                }
                var location_number = chest_number + '_' + get_number(number);
                rec.set('docu_number', location_number);
                rec.set('doc_number', number);
            
                var date = new Date();
                var year = date.getFullYear();
                var month = date.getMonth() + 1;
                var day = date.getDate();
                var dd = year + '-' + month + '-' + day;
                rec.set('storage_date', dd);
            
                if ($('con_contract_location_ln_result_ds').validate() && $('contract_lease_item_ds').validate()) {
                    lock_screen();
                    $('con_contract_location_ln_result_ds').submit();
                    $('contract_lease_item_ds').submit();
            
                }
            
                // if(${/parameter/@doc_type}=='10'){
                // $('save1').disable();
                // }else{
                // $('save2').disable();
                // }
            }
            
            function location_ln_result_submitsuccess(ds, res) {
                //con555B_con_location_back();
                $('con_contract_location_ln_result_ds').query();
                is_save_lag = 'Y';
                unlock_screen();
            }
            
            function location_ln_result_add(ds, res, index) {
                var date = new Date();
                var year = date.getFullYear();
                var month = date.getMonth() + 1;
                var day = date.getDate();
                var dd = year + '-' + month + '-' + day;
                res.set('storage_date', dd);
                var chest_number = ds.getCurrentRecord().getField('chest_number');
                chest_number.setLovPara('doc_type', ${/parameter/@doc_type});
            }
            
            function beforesubmit_result_ds(ds) {
                //
                var rec = ds.getCurrentRecord();
                Leaf.request({
                    url: $('con_modify_location_con_status_link').getUrl(),
                    para: {
                        contract_id: ${/parameter/@contract_id},
                        doc_type: '${/parameter/@doc_type}'
                    },
                    sync: true,
                    success: function(res) {
            
                       }
                });
            }
            
            function contract_lease_item_load(ds) {
            
                if ('${/parameter/@doc_type}' == '10') {
                    var contract_lease_item_id = document.getElementById('contract_lease_item_id');
                    contract_lease_item_id.style.display = 'none';
                    ds.getField('license_number').setRequired(false);
                    ds.getField('item_frame_number').setRequired(false);
                    ds.getField('color_of_apprearance').setRequired(false);
                    ds.getField('item_engine_number').setRequired(false);
                    ds.getField('mortgage_date').setRequired(false);
                }
            }
            var p_location_id = -1;
            
            function result_ds_load(ds) {

                var date = new Date();
                var year = date.getFullYear();
                var month = date.getMonth() + 1;
                var day = date.getDate();
                var dd = year + '-' + month + '-' + day;
            
            
                var recs = ds.getAll();
                if (recs.length == 0) {
                    ds.create([], 0);
                    var chest_number = ds.getCurrentRecord().getField('chest_number');
                    var lease_term = $('lease_term_ds').getCurrentRecord().get('lease_term');
                    chest_number.setLovPara('doc_type', ${/parameter/@doc_type});
                    chest_number.setLovPara('years', lease_term);
                    recs[0].set('storage_date', dd);
            
                } else {
                    var chest_number = ds.getCurrentRecord().getField('chest_number');
                    var lease_term = $('lease_term_ds').getCurrentRecord().get('lease_term');
                    chest_number.setLovPara('doc_type', ${/parameter/@doc_type});
                    chest_number.setLovPara('years', lease_term);
                    p_location_id = ds.getCurrentRecord().get('location_id');
                }
                Leaf.request({
                    url: $('sys_user_link').getUrl(),
                    para: {
                        user_id: ${/session/@user_id}
                    },
                    sync: true,
                    success: function(data) {
                        if (data.result.record && !data.result.record.length) {
                            var datas = ds.getAll();
                            datas[0].set('created_by_n', data.result.record.user_name);
                        }
                    }
                });
            
            }
            
            function contract_print() {

                var record = $('con_contract_location_ln_result_ds').getCurrentRecord();
                var document_id = record.get('con_contract_location_ln');
                if (Ext.isEmpty(document_id)) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '未保存,不能打印登记证标签!');
                    return;
                }
                new Leaf.Window({
                    id: '${/parameter/@layout_code}_con_contract_content_confirm_win_id',
                    params: {
                        document_id: document_id,
                        document_table: 'CON_CONTRACT_LOCATION_LN'
                    },
                    url: $('hls_doc_file_print_confirm').getUrl(),
                    title: '合同文本生成',
                    width: 1300,
                    height: 550
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="sys_user_ds" autoQuery="true" model="cont.CON555B.sys_user" queryUrl="${/request/@context_path}/autocrud/cont.CON555B.sys_user/query?user_id=${/session/@user_id}"/>
            <a:dataSet id="chest_number_ds" autoQuery="true" model="cont.CON555B.con_contract_location" queryUrl="${/request/@context_path}/autocrud/cont.CON555B.con_contract_location/query?doc_type=${/parameter/@doc_type}"/>
            <a:dataSet id="doc_type_ds2" lookupCode="DOC_TYPE"/>
            <a:dataSet id="con_contract_location_ln_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="doc_type" defaultValue="${/parameter/@doc_type}"/>
                    <a:field name="contract_id" defaultValue="${/parameter/@contract_id}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_location_ln_result_ds" autoQuery="true" model="cont.CON555B.con_contract_location_ln" queryDataSet="con_contract_location_ln_query_ds">
                <a:fields>
                    <a:field name="location_con_status" defaultValue="normal"/>
                    <a:field name="con_contract_location_ln"/>
                    <a:field name="location_id"/>
                    <a:field name="years"/>
                    <a:field name="storage"/>
                    <!--  <a:field name="chest_number" required="true"/> -->
                    <!--                     <a:field name="chest_number_n" displayField="chest_number" options="chest_number_ds" required="true" returnField="chest_number" valueField="chest_number"/>
 -->
                    <a:field name="chest_number" lovHeight="500" lovService="cont.CON555B.con_contract_location" lovWidth="600" required="true">
                        <a:mapping>
                            <a:map from="location_id" to="location_id"/>
                            <a:map from="chest_number" to="chest_number"/>
                            <a:map from="storage" to="storage"/>
                            <a:map from="years" to="years"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="chest_floors"/>
                    <a:field name="docu_number" readOnly="true"/>
                    <a:field name="docu_amount"/>
                    <a:field name="note"/>
                    <a:field name="doc_type" defaultValue="${/parameter/@doc_type}" readOnly="true"/>
                    <a:field name="doc_type_n" defaultValue="${/parameter/@doc_type_n}" displayField="code_value_name" options="doc_type_ds2" readOnly="true" returnField="doc_type" valueField="code_value"/>
                    <a:field name="storage_date" readOnly="true"/>
                    <a:field name="contract_id" defaultValue="${/parameter/@contract_id}"/>
                    <a:field name="created_by" defaultValue="${/session/@user_id}"/>
                    <a:field name="created_by_n" readOnly="true"/>
                    <a:field name="doc_number"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="location_ln_result_submitsuccess"/>
                    <!--    <a:event name="add" handler="location_ln_result_add"/> -->
                    <a:event name="beforesubmit" handler="beforesubmit_result_ds"/>
                    <a:event name="load" handler="result_ds_load"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="contract_lease_item_ds" autoQuery="true" model="cont.CON555B.con_contract_lease_item" queryUrl="${/request/@context_path}/autocrud/cont.CON555B.con_contract_lease_item/query?contract_id=${/parameter/@contract_id}">
                <a:fields>
                    <a:field name="license_number" required="true"/>
                    <a:field name="item_frame_number" required="true"/>
                    <a:field name="color_of_apprearance" required="true"/>
                    <a:field name="item_engine_number" required="true"/>
                    <a:field name="mortgage_date" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="contract_lease_item_load"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="lease_term_ds" autoCreate="true">
                <a:fields>
                    <a:field name="lease_term" defaultValue="${/parameter/@lease_term}" readOnly="true"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="con555B_con_location_back" text="HLS.BACK"/>
                <a:gridButton click="con555B_con_location_confirm" text="确认"/>
                <a:gridButton click="contract_print" text="登记证标签打印"/>
            </a:screenTopToolbar>
            <a:form column="4" title="归档入库">
                <a:lov name="chest_number" bindTarget="con_contract_location_ln_result_ds" prompt="箱号"/>
                <a:textField name="docu_number" bindTarget="con_contract_location_ln_result_ds" prompt="档案编号"/>
                <a:comboBox name="doc_type_n" bindTarget="con_contract_location_ln_result_ds" prompt="文件类型"/>
                <a:datePicker name="storage_date" bindTarget="con_contract_location_ln_result_ds" prompt="入库日期"/>
                <a:textField name="lease_term" bindTarget="lease_term_ds" prompt="年份"/>
                <a:textField name="created_by_n" bindTarget="con_contract_location_ln_result_ds" prompt="归档人员"/>
            </a:form>
            <div id="contract_lease_item_id">
                <a:form column="4" title="归档入库">
                    <a:textField name="license_number" bindTarget="contract_lease_item_ds" prompt="车牌"/>
                    <a:textField name="item_frame_number" bindTarget="contract_lease_item_ds" prompt="车架号"/>
                    <a:textField name="color_of_apprearance" bindTarget="contract_lease_item_ds" prompt="颜色"/>
                    <a:textField name="item_engine_number" bindTarget="contract_lease_item_ds" prompt="发动机号"/>
                    <a:datePicker name="mortgage_date" bindTarget="contract_lease_item_ds" prompt="抵押日期"/>
                </a:form>
            </div>
        </a:screenBody>
    </a:view>
</a:screen>