sys_mail_send.lview 12.3 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
	&author:DJ
	$date:2013/11/12
	$purpose:短信发送
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="sys.SYS405.get_zj_sys_mailing_list_id" rootPath="mail_list_id_rp"/>
        <a:model-query fetchAll="true" model="sys.SYS405.exp_employees_mail" rootPath="emp_mail_list"/>
        <a:model-query fetchAll="true" model="sys.SYS405.hls_bp_contact_mail" rootPath="bp_contact_mail_list"/>
    </a:init-procedure>
    <a:view>
        <a:link id="bmLink_send_sms" model="sys.SYS405.sys_mail_list" modelaction="execute"/>
        <a:link id="uploadFile_link" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="upload_filename_link" model="sys.SYS405.get_attach_file_name" modelaction="update"/>
        <script charset="utf-8" src="${/request/@context_path}/kindeditor/kindeditor-min.js" type="text/javascript"/>
        <script charset="utf-8" src="${/request/@context_path}/kindeditor/lang/zh_CN.js" type="text/javascript"/>
        <script type="text/javascript"><![CDATA[
            var mailEditorList = [];
            
            function mailEdit_create(list) {
                var k = KindEditor;
                var config = {
                    width: '654px',
                    height: '350px',
                    resizeType: 0,
                    allowPreviewEmoticons: false,
                    allowImageUpload: false,
                    items: ['undo', 'redo', '|', 'cut', 'copy', 'paste', 'plainpaste', '|', 'preview', 'print', '|', 'insertorderedlist', 'insertunorderedlist', '|', 'table', 'link', 'unlink', 'pagebreak', 'hr', '|', '/', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', '|', 'lineheight', 'justifyleft', 'justifycenter', 'justifyright', 'indent', 'outdent', '|', 'selectall', 'removeformat', '|']
                };
            
                for (var i = 0;i < list.length;i++) {
                    list[i]['value'] = k.create('textarea[id="' + list[i]['name'] + '"]', config);
                }
            }
            
            function lock_window() {
                Leaf.Masker.mask(Ext.getBody(), '正在提交');
            }
            
            function unlock_window() {
                Leaf.Masker.unmask(Ext.getBody());
            }
            
            function mailEditorWriteBack(record) {
                var list = mailEditorList;
            
                for (var i = 0;i < list.length;i++) {
                    var value = list[i]['value'].html();
                    var name = list[i]['name'];
                    record.set(name, value);
                }
            }
            
            function mailEditorClear() {
                var list = mailEditorList;
            
                for (var i = 0;i < list.length;i++) {
                    list[i]['value'].html('');
                }
            }
            
            function clearMail() {
                //$('mailCreateDs').reset();
                //mailEditorClear();
                location.href="${/request/@context_path}/modules/sys/SYS405/sys_mail_send.lview";
            }
            
            function submitMail() {
                lock_window();
                var ds = $('mailCreateDs');
            
                var record = ds.getAt(0);
            
                mailEditorWriteBack(record);
            
                if (Ext.isEmpty(record.get('body'))) {
                    Leaf.showMessage('${l:PROMPT}', '邮件正文不能为空!');
                    unlock_window();
                    return;
                }
            
                if (!ds.validate()) {
                    unlock_window();
                    return;
                }
            
                unlock_window();
                Leaf.showConfirm('${l:HLS.PROMPT}', '是否确认提交邮件?', function() {
                    lock_window();
                    Leaf.request({
                        url: $('bmLink_send_sms').getUrl(),
                        para: {
                            'mail_to': record.get('mail_to'),
                            'mail_cc': record.get('mail_cc'),
                            'subject': record.get('subject'),
                            'body': record.get('body'),
99
                            // 'mail_list_id':record.get('mail_list_id')
Spencer Chang's avatar
Spencer Chang committed
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
                        },
                        success: function(res) {
                            unlock_window();
                            Leaf.SideBar.show({
                                msg: '提交成功',
                                duration: 2000
                            });
                            clearMail();
                        },
                        failure: function() {
                            unlock_window();
                        },
                        error: function() {
                            unlock_window();
                        },
                        scope: this
                    });
                }, function() {});
            
            }
            
            function getmailStr(ds) {
                var str = '';
                var records = ds.getSelected();
                for (var i = 0,
                    j = records.length;i < j;i++) {
                    var mail = records[i].get('mail');
                    if (!Ext.isEmpty(mail)) {
                        str = str + mail + ';';
                    }
                }
                return str;
            }
            
            function get_mail_string(ds) {
                var str = '';
                var email = {};
                var records = ds.getAll();
                for (var i = 0;i < records.length;i++) {
                    if (records[i].get('checked') == 'Y') {
                        if (records[i].get('email')) {
                            email[records[i].get('email')] = records[i].get('email');
                        }
                    }
                }
                for (emails in email) {
                    if ((emails)) {
                        str += emails + ';';
                    }
                }
                return str;
            }
            
            function generate_mail_to() {
                var str = get_mail_string($('empMailDs')) + getmailStr($('bpContactMailDs'));
                $('mailCreateDs').getAt(0).set('mail_to', str);
            }
            
            function generate_mail_cc() {
                var str = get_mail_string($('empMailDs')) + getmailStr($('bpContactMailDs'));
                $('mailCreateDs').getAt(0).set('mail_cc', str);
            }
            
            function mailCreateDs_add(ds, record) {
                record.set('mail_list_id', '${/model/mail_list_id_rp/record/@mail_list_id}');
            }
            
            function attachMail() {
                url = $('uploadFile_link').getUrl() + '?table_name=ZJ_SYS_MAILING_LIST&useSubFolder=Y&header_id=' + '${/model/mail_list_id_rp/record/@mail_list_id}';
                var win = new Leaf.Window({
                    url: url,
                    title: '附件上传',
                    id: 'uploadFile_win',
                    width: 850,
                    height: 400
                });
                win.on('close', function() {
                    var record = $('mailCreateDs').getCurrentRecord();
                    var mail_list_id = record.get('mail_list_id');
                    Leaf.request({
                        url: $('upload_filename_link').getUrl(),
                        para: {
                            mail_list_id: mail_list_id
                        },
                        success: function(args) {
                            var file_name = args.result.file_name;
                            record.set('attachment_file', file_name);
                        }
                    });
                });
            
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="mailCreateDs" autoCreate="true">
                <a:fields>
                    <a:field name="subject" required="true"/>
                    <a:field name="mail_to" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="mailCreateDs_add"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="empMailDs">
                <a:datas dataSource="/model/emp_mail_list"/>
            </a:dataSet>
            <a:dataSet id="bpContactMailDs" selectable="true">
                <a:datas dataSource="/model/bp_contact_mail_list"/>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="clearMail" text="清空"/>
                <!--   <a:gridButton click="attachMail" text="附件"/> -->
                <a:gridButton click="submitMail" text="提交"/>
            </a:screenTopToolbar>
            <a:hBox>
                <a:vBox>
                    <a:form title=" ">
                        <a:textArea name="mail_to" bindTarget="mailCreateDs" height="80" prompt="收件人" width="650"/>
                        <a:textArea name="mail_cc" bindTarget="mailCreateDs" height="40" prompt="抄送" width="650"/>
                        <a:textField name="subject" bindTarget="mailCreateDs" height="40" prompt="主题" width="654"/>
                        <a:textField name="attachment_file" bindTarget="mailCreateDs" prompt="附件" readOnly="true" width="654"/>
                        <a:textArea name="body" id="body" bindTarget="mailCreateDs" height="270" prompt="正文" width="650"/>
                    </a:form>
                </a:vBox>
                <a:vBox>
                    <a:button click="generate_mail_to" height="40" style="margin-top:50px;" text="&lt;---"/>
                    <a:button click="generate_mail_cc" height="40" style="margin-top:25px;" text="&lt;---"/>
                </a:vBox>
                <a:vBox>
                    <a:tabPanel marginHeight="120" width="420">
                        <a:tabs>
                            <a:tab prompt="员工" width="100">
                                <!--  <a:grid bindTarget="empMailDs" marginHeight="170" width="360">
                                    <a:columns>
                                        <a:column name="person" autoAdjust="false" prompt="姓名" showTitle="true" width="100"/>
                                        <a:column name="mail" autoAdjust="false" prompt="邮箱" showTitle="true" width="200"/>
                                    </a:columns>
                                </a:grid> -->
                                <a:treeGrid bindTarget="empMailDs" idField="unit_id" marginHeight="170" parentField="parent_unit_id" sequenceField="seq" showCheckBox="true" width="410">
                                    <a:columns>
                                        <a:column name="unit_name" width="150"/>
                                        <a:column name="name" prompt="姓名" width="60"/>
                                        <a:column name="email" prompt="邮箱" width="170"/>
                                    </a:columns>
                                </a:treeGrid>
                            </a:tab>
                            <a:tab prompt="客户" width="100">
                                <a:grid bindTarget="bpContactMailDs" marginHeight="170" width="400">
                                    <a:columns>
                                        <a:column name="person" autoAdjust="false" prompt="姓名" showTitle="true" width="100"/>
                                        <a:column name="mail" autoAdjust="false" prompt="邮箱" showTitle="true" width="230"/>
                                    </a:columns>
                                </a:grid>
                            </a:tab>
                        </a:tabs>
                    </a:tabPanel>
                </a:vBox>
            </a:hBox>
            <script type="text/javascript"><![CDATA[
	            Leaf.onReady(function(K) {
	            
	                var list = mailEditorList;
	            
	                list[0] = {
	                    name: 'body'
	                };
	            
	                mailEdit_create(list);
	            
	            });
            ]]></script>
        </a:screenBody>
    </a:view>
</a:screen>