goods_policy_entrance.lview 8.65 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: syj
    $Date: 2018年7月10日10:13:26
    $Revision: 1.0
    $Purpose: 商品拆分入口
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="save_button_link_id" model="cont.CON810.batch_goods_tmp" modelaction="batch_update"/>
        <a:link id="goods_batch_import_upload_link_id"
                url="${/request/@context_path}/modules/cont/CON810/goods_batch_import_upload.lview"/>
        <a:link id="con810_atm_attachment_multi_query" model="cont.CON810.fnd_atm_attachment_multi_query"
                modelaction="query"/>
        <script type="text/javascript"><![CDATA[
        function import_button() {
            var record = $('goods_batch_ds').getCurrentRecord();

            if ($('goods_batch_ds').isModified()) {
                Leaf.showErrorMessage('错误', '页面有未保存数据,请先保存后再提交!');
                return;
            }

            if (record.length == 0) {
                Leaf.showMessage('${l:PROMPT}', '${l:FND.PLEASE_ADD_LINE}');
                return;
            } else {
                var batch_id = record.get('batch_id');
                var win = new Leaf.Window({
                    id: 'goods_batch_import_upload_winid',
                    url: $('goods_batch_import_upload_link_id').getUrl(),
                    params: {
                        batch_id: batch_id,
                        win_id: 'goods_batch_import_upload_winid',
                        parent_ds_id: 'goods_batch_ds'
                    },
                    title: '导入',
                    width: 420,
                    height: 300
                });
                win.on('close', function () {
                    $('goods_batch_ds').query();
                });
            }
        }


        function return_btn() {
            history.go(-1);
        }


        function add_btn() {
            $('goods_batch_grid_id').showEditorByRecord($('goods_batch_ds').create());
        }

        function query_btn() {
            $('goods_batch_ds').query();
        }

        function save_btn() {
            Leaf.Masker.mask(Ext.getBody());
            var ds = $('goods_batch_ds');
            var records = ds.getAll();
            var datas = [];
            for (var i = 0; i < records.length; i++) {
                records[i].set('_status', 'execute');
                datas.push(records[i].data);
            }
            if (ds.validate()) {
                Leaf.request({
                    url: $('save_button_link_id').getUrl(),
                    para: datas,
                    success: function () {
                        Leaf.SideBar.show({
                            msg: '保存成功!',
                            duration: 2000
                        });
                        Leaf.Masker.unmask(Ext.getBody());
                        query_btn();
                    },
                    failure: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                        query_btn();
                    },
                    error: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                        query_btn();
                    },
                    scope: this
                });
            }else{
                Leaf.Masker.unmask(Ext.getBody());
            }
        }

        function edit_renderer(value, record, name) {

            if (name == 'batch_date' || name == 'date_to' || name == 'date_from') {
                return Leaf.formatDate(value);
            }
        }

        function edit_function(record, name) {
            if (name == 'batch_date'  || name == 'date_from') {
                if (record.isNew) {
                    return 'good_batch_dp';
                } else {
                    return '';
                }
            }
            if (name == 'division_n') {
                if (record.isNew) {
                    return 'good_batch_cb';
                } else {
                    return '';
                }
            }
            if (name == 'batch_name') {
                if (record.isNew) {
                    return 'good_batch_tf';
                } else {
                    return '';
                }
            }

        }


        //预览超链接渲染
        function con810_preview_render(value, record, name) {
            return '<a href="javascript:showMeSomeRespect(' + record.id + ')">' + '预览' + '</a>'
        }

        //预览方法
        function showMeSomeRespect(recordId) {
            Leaf.Masker.mask(Ext.getBody());
            var record = $('goods_batch_ds').findById(recordId);
            var table_pk_value = record.get('batch_id');
            var table_name = 'T_GOODS_BATCH';
            Leaf.request({
                url: $('con810_atm_attachment_multi_query').getUrl(),
                para: {
                    table_name: table_name,
                    table_pk_value: table_pk_value
                },
                success: function (res) {
                    if (res.result.record && res.result.record.record_id) {
                        window.open('${/request/@context_path}/sys/office/view?_csrf=${/session/@_csrf.token}&sourceTypeCode=fnd_atm_attachment_multi&sourcePkValue=' + res.result.record.record_id);
                    } else {
                        Leaf.showErrorMessage('提示','尚未导入!');
                    }
                    Leaf.Masker.unmask(Ext.getBody());

                }

            });
        }

        ]]></script>
        <a:dataSets>
            <a:dataSet id="goods_policy_division_ds" lookupCode="GOODS_POLICY_DIVISION"/>
            <a:dataSet id="goods_batch_ds" autoQuery="true" model="cont.CON810.t_goods_batch" selectionModel="single"
                       pageSize="15" selectable="true">
                <a:fields>
                    <a:field name="division_n" requiredMessage="请输入必输字段:产品线" displayField="code_value_name" options="goods_policy_division_ds"
                             required="true" returnField="division" valueField="code_value"/>
                    <a:field name="division"/>
                    <a:field name="enable_flag" checkedValue="Y" defaultValue="N" uncheckedValue="N" readOnly="true"/>

                    <a:field name="batch_name" required="true"/>
                    <a:field name="batch_date" required="true"/>
                    <a:field name="date_from" required="true"/>
                    <a:field name="date_to" required="true"/>

                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <!--<a:gridButton click="return_btn" text="退出"/>-->
                <a:gridButton click="add_btn" text="新增"/>
                <a:gridButton click="query_btn" text="刷新"/>
                <a:gridButton click="save_btn" text="保存"/>
                <a:toolbarButton click="import_button" text="导入"/>
            </a:screenTopToolbar>
            <a:grid id="goods_batch_grid_id" bindTarget="goods_batch_ds" marginHeight="100" marginWidth="30"
                    navBar="true">
                <a:columns>
                    <a:column name="batch_number" align="center" prompt="政策批次号" width="200"/>
                    <a:column name="batch_name" prompt="批次名称" editorFunction="edit_function" width="350"/>
                    <a:column name="batch_date" prompt="创建时间" renderer="edit_renderer" editorFunction="edit_function"
                              width="180"/>
                    <a:column name="date_from" prompt="有效期从" renderer="edit_renderer" editorFunction="edit_function"
                              width="180"/>
                    <a:column name="date_to" prompt="有效期到" renderer="edit_renderer" editor="good_batch_dp"
                              width="180"/>
                    <a:column name="division_n" prompt="产品线" editorFunction="edit_function" width="200" />
                    <a:column name="enable_flag" prompt="启用" editor="good_batch_ck" width="80"/>
                    <a:column name="preview" prompt="预览" align="center" renderer="con810_preview_render" width="100"/>
                </a:columns>
                <a:editors>
                    <a:numberField id="good_batch_nf"/>
                    <a:textField id="good_batch_tf"/>
                    <a:datePicker id="good_batch_dp"/>
                    <a:comboBox id="good_batch_cb"/>
                    <a:checkBox id="good_batch_ck"/>
                </a:editors>
            </a:grid>
        </a:screenBody>

    </a:view>
</a:screen>