sys_sms_send.lview 9 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
<?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.SYS401.exp_employees_mobile" rootPath="emp_mobile_list"/>
        <a:model-query fetchAll="true" model="sys.SYS401.hls_bp_contact_mobile" rootPath="bp_contact_mobile_list"/>
    </a:init-procedure>
    <a:view>
        <a:link id="bmLink_send_sms" model="sys.SYS401.sys_sms_list" modelaction="execute"/>
        <a:link id="sys_sms_send_from_tplt_link_id" url="${/request/@context_path}/modules/sys/SYS401/sys_sms_send_from_tplt.lview"/>
        <script type="text/javascript"><![CDATA[
            function lock_window() {
                Leaf.Masker.mask(Ext.getBody(), '正在提交');
            }
            
            function unlock_window() {
                Leaf.Masker.unmask(Ext.getBody());
            }
            
            function clearSms() {
                $('smsCreateDs').reset();
            }
            
            function submitSms() {
                lock_window();
                var ds = $('smsCreateDs');
                if (!ds.validate()) {
                    unlock_window();
                    return;
                }
                var record = ds.getAt(0);
                var text = record.get('text');
                var length = String(text).length;
            
                unlock_window();
                Leaf.showConfirm('${l:HLS.PROMPT}', '每条短信最多350个字,当前字数为' + length + ',将发送' + Math.ceil(length / 350) + '条,是否确认?', function() {
                    lock_window();
                    Leaf.request({
                        url: $('bmLink_send_sms').getUrl(),
                        para: {
                            'all_phone_number': record.get('all_phone_number'),
                            'text': record.get('text')
                        },
                        success: function(res) {
                            unlock_window();
                            Leaf.SideBar.show({
                                msg: '提交成功',
                                duration: 2000
                            });
                            clearSms();
                        },
                        failure: function() {
                            unlock_window();
                        },
                        error: function() {
                            unlock_window();
                        },
                        scope: this
                    });
                }, function() {});
            
            }
            
            function validate_smsCreateDs(record, name, value) {
                if (name == 'all_phone_number') {
                    var reg = /^[0-9;]*$/;
                    if (reg.test(value)) {
                        return true;
                    }
                    return '只能包含数字和分号(分隔符)';
                }
            }
            
            function getMobileStr(ds) {
                var str = '';
                var mobile_obj = {};
                var records = ds.getAll();
                for (var i = 0;i < records.length;i++) {
                    if (records[i].get('checked') == 'Y') {
                        var mobile = records[i].get('mobil');
                        if (!Ext.isEmpty(mobile)) {
                            mobile_obj[mobile] = mobile;
                        }
                    }
                }
                for (mobiles in mobile_obj) {
                    if (!Ext.isEmpty(mobiles)) {
                        str = str + mobiles + ';';
                    }
                }
                return str;
            }
            
            function get_employee_mobile(ds) {
                var str = '';
                var mobile_obj = {};
                var records = ds.getAll();
                for (var i = 0;i < records.length;i++) {
                    if (records[i].get('checked') == 'Y') {
                        var mobile = records[i].get('mobil');
                        if (!Ext.isEmpty(mobile)) {
                            mobile_obj[mobile] = mobile;
                        }
                    }
                }
                for (mobiles in mobile_obj) {
                    if (!Ext.isEmpty(mobiles)) {
                        str = str + mobiles + ';';
                    }
                }
                return str;
            }
            
            function generateMobileStr() {
                var str = get_employee_mobile($('empMobileDs')) + getMobileStr($('bpContactMobileDs'));
                $('smsCreateDs').getAt(0).set('all_phone_number', str);
            }
            
            function selectTplt() {
                new Leaf.Window({
                    id: 'sys_sms_send_from_tplt_win_id',
                    url: $('sys_sms_send_from_tplt_link_id').getUrl(),
                    params: {
                        winid: 'sys_sms_send_from_tplt_win_id',
                        notify_type: 'SMS',
                        dsid: 'smsCreateDs'
                    },
                    width: 450,
                    height: 400
                });
            }

            //设置短信内容
            Leaf.onReady(function () {
                $('smsCreateDs').data[0].set('text','${/parameter/@text}');
            })
        ]]></script>
        <a:dataSets>
            <a:dataSet id="smsCreateDs" autoCreate="true">
                <a:fields>
                    <a:field name="text" required="true"/>
                    <a:field name="all_phone_number" required="true" validator="validate_smsCreateDs"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="empMobileDs">
                <a:datas dataSource="/model/emp_mobile_list"/>
            </a:dataSet>
            <a:dataSet id="bpContactMobileDs">
                <a:datas dataSource="/model/bp_contact_mobile_list"/>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="clearSms" text="清空"/>
                <a:gridButton click="submitSms" text="提交短信"/>
                <!--<a:gridButton click="selectTplt" text="选择短信模板"/>-->
            </a:screenTopToolbar>
            <a:hBox>
                <a:vBox>
                    <a:form title=" ">
                        <a:textArea name="all_phone_number" bindTarget="smsCreateDs" height="150" prompt="手机号" width="650"/>
                        <a:textArea name="text" transformCharacter="false"  bindTarget="smsCreateDs" height="150" prompt="短信内容" width="650"/>
                    </a:form>
                </a:vBox>
                <a:vBox>
                    <a:button click="generateMobileStr" height="40" style="margin-top:50px;" text="&lt;---"/>
                </a:vBox>
                <a:vBox>
                    <a:tabPanel marginHeight="120" width="420">
                        <a:tabs>
                            <a:tab prompt="员工" width="100">
                                <!-- <a:grid bindTarget="empMobileDs" marginHeight="170" width="360">
                                    <a:columns>
                                        <a:column name="person" autoAdjust="false" prompt="姓名" showTitle="true" width="200"/>
                                        <a:column name="mobile" prompt="手机" width="100"/>
                                    </a:columns>
                                </a:grid> -->
                                <a:treeGrid bindTarget="empMobileDs" 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="100"/>
                                        <a:column name="mobil" prompt="手机" width="120"/>
                                    </a:columns>
                                </a:treeGrid>
                            </a:tab>
                            <a:tab prompt="客户" width="100">
                                <a:treeGrid bindTarget="bpContactMobileDs" 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="100"/>
                                        <a:column name="mobil" prompt="手机" width="120"/>
                                    </a:columns>
                                </a:treeGrid>
                            </a:tab>
                        </a:tabs>
                    </a:tabPanel>
                </a:vBox>
            </a:hBox>
        </a:screenBody>
    </a:view>
</a:screen>