Browse Source

平台设备管理/图片展示组件/

zhuth 6 years ago
parent
commit
eb23c32480

+ 5 - 1
frontend/pc-web/app/view/basic/student/StudentDetail.js

@@ -13,7 +13,7 @@ Ext.define('school.view.basic.student.StudentDetail', {
     _statusCodeField: null,
     _auditmanField: null,
     _auditdateField: null,
-    // _readUrl: 'http://10.1.80.47:9520/api/shcool/student/read',
+    // _readUrl: 'http://10.1.80.36:9520/api/school/student/read',
     _readUrl: '/api/school/student/read',
     // _saveUrl: 'http://10.1.80.36:9520/api/school/student/save',
     _saveUrl: '/api/school/student/save',
@@ -27,6 +27,10 @@ Ext.define('school.view.basic.student.StudentDetail', {
                 xtype: 'hidden',
                 name: 'stu_id',
                 fieldLabel: 'id',
+            }, {
+                xtype: 'remoteimgfield',
+                name: 'stu_img',
+                // fieldLabel: '头像',
             }, {
                 xtype: 'textfield',
                 name: 'stu_number',

+ 201 - 0
frontend/pc-web/app/view/core/form/field/RemoteImgField.js

@@ -0,0 +1,201 @@
+Ext.define('school.view.core.form.field.RemoteImgField', {
+    extend: 'Ext.form.FieldContainer',
+    alias: 'widget.remoteimgfield',
+
+    layout: "hbox",
+    defaults: {
+        hideLabel: true
+    },
+    isFormField: true,
+    defaultBindProperty: 'value',
+    cls: 'remoteimg-field',
+
+    initComponent: function () {
+        var me = this;
+
+        Ext.apply(me, {
+            items: [{
+                xtype: 'hidden',
+                name: 'imgPath'
+            }, {
+                xtype: 'image',
+                height: 170,
+                width: 135,
+                hidden: true,
+                src: '',
+                style: {
+                    'background-color': '#e6dede'
+                }
+            }, {
+                xtype: 'filefield',
+                name: 'file',
+                cls: 'upload-bth',
+                height: 170,
+                width: 135,
+                buttonText: '上传头像',
+                buttonOnly: true,
+                hideLabel: true,
+                // hidden: true,
+                buttonConfig: {
+                    cls: 'x-filefield-button'
+                },
+                listeners: {
+                    change: function (field) {
+                        if (!!field.value) {
+                            me.upload(field);
+                        }
+                    }
+                }
+            }, {
+                xtype: 'component',
+                cls: 'tool-bar',
+                hidden: true,
+                html: '<div class="tools"><span title="放大" class="tool enlarge x-fa fa-expand"></span><span title="删除" class="tool delete x-ss ss-delete1"></span></div>',
+                listeners: {
+                    boxready: function(component) {
+                        component.el.dom.onclick = function() {
+                            if(event.target.classList.contains('enlarge')) {
+                                me.enlargeImg();
+                            }else if(event.target.classList.contains('delete')) {
+                                me.deleteImg();
+                            }
+                        };
+                    }
+                }
+            }]
+        });
+
+        me.callParent(arguments);
+    },
+
+    listeners: {
+        boxready: function(container, width, height, e) {
+            container.el.dom.onmouseenter = function() {
+                if(container.getValue()) {
+                    container.items.items[3].setHidden(false);
+                }
+            };
+            container.el.dom.onmouseleave = function() {
+                if(container.getValue()) {
+                    container.items.items[3].setHidden(true);
+                }
+            }
+        }
+    },
+
+    setValue: function(v) {
+        var me = this,
+        items = me.items.items,
+        imgPath = items[0],
+        img = items[1],
+        fileField = items[2];
+
+        imgPath.setValue(v);
+        img.setSrc(v);
+        fileField.setHidden(true);
+        img.setHidden(false);
+
+        me.publishState('value', v);
+    },
+
+    getValue: function() {
+        return this.items.items[0].value;
+    },
+
+    getValueField: function () {
+        return this.items.items[0];
+    },
+
+    isValid: function () {
+        return this.getValueField().isValid();
+    },
+
+    isDirty: function () {
+        return this.getValueField().isDirty();
+    },
+
+    setReadOnly: function () {
+
+    },
+
+    /**
+     * 上传附件
+     */
+    upload: function (field) {
+        var me = this;
+        var fd = new FormData();
+        fd.append('file', field.fileInputEl.dom.files[0]);
+        fd.append('folderId', 0);
+        me.setLoading(true);
+        Ext.Ajax.request({
+            // url: 'http://10.1.80.36:9520/api/file/upload', //这里是填写需要跨域访问的URL
+            url: '/api/file/upload',//这里是填写需要跨域访问的URL
+            cors: true,
+            useDefaultXhrHeader: false,
+            method: 'post',
+            rawData: fd,
+            headers: {
+                'Access-Control-Allow-Origin': '*',
+                'Authorization': school.util.State.get('session').token,
+                //"Content-Type": 'multipart/form-data'  //文件上传的格式, 
+                "Content-Type": null
+            },
+            success: function (response, opts) {
+                me.setLoading(false);
+                var res = Ext.decode(response.responseText);
+                if (res.success) {
+                    school.util.BaseUtil.showSuccessToast('上传成功');
+                    var data = res.data,
+                    accessPath = data.accessPath;
+
+                    me.setValue(accessPath);
+                } else {
+                    school.util.BaseUtil.showErrorToast('上传失败: ' + res.message);
+                }
+            },
+            failure: function (response, opts) {
+                me.setLoading(false);
+                var res = Ext.decode(response.responseText);
+                school.util.BaseUtil.showErrorToast('上传失败: ' + res.message);
+            }
+        });
+    },
+
+    enlargeImg: function() {
+        var me = this;
+        var win = Ext.getCmp('enlarge-win');
+        if(!win) {
+            win = Ext.create('Ext.window.Window', {
+                width: 350,
+                height: 400,
+                layout: 'fit',
+                items: [{
+                    xtype: 'image',
+                    src: me.getValue()
+                }]
+            });
+        }
+        win.show();
+    },
+
+    deleteImg: function() {
+        var me = this,
+        items = me.items.items,
+        imgPath = items[0],
+        img = items[1],
+        fileField = items[2];
+
+        school.util.BaseUtil.showConfirm('确认删除', '是否确认删除该头像?')
+        .then(function(yes) {
+            if(yes == 'yes') {
+                imgPath.setValue(null);
+                img.setSrc(null);
+                fileField.setHidden(false);
+                img.setHidden(true);
+        
+                me.publishState('value', null);
+            }
+        });
+    }
+
+});

+ 37 - 0
frontend/pc-web/app/view/core/form/field/RemoteImgField.scss

@@ -0,0 +1,37 @@
+.remoteimg-field {
+    img, .upload-bth {
+        left: 50% !important;
+        margin-left: -67.5px !important;
+    }
+
+    .x-filefield-button {
+        margin-top: 50% !important;
+    }
+
+    .tool-bar {
+        width: 100% !important;
+        height: 24px !important;
+        top: 146px !important;
+        left: 0 !important;
+        .tools {
+            width: 135px;
+            height: 24px;
+            margin: 0 auto;
+            display: flex;
+            justify-content: flex-end;
+            background: white;
+            opacity: 0.3;
+
+            .tool {
+                width: 24px;
+                line-height: 24px;
+                text-align: center;
+                cursor: pointer;
+
+                &:hover {
+                    font-size: 16px;
+                }
+            }
+        }
+    }  
+}

+ 8 - 1
frontend/pc-web/app/view/main/Navigation.js

@@ -159,7 +159,14 @@ Ext.define('school.view.main.Navigation', {
         var tabId = record.get('id');
         var config = record.get('config') || [];
         var menu = view.up('menu');
-        school.util.BaseUtil.openTab(viewType, tabTitle, tabId, config);
+        var op = record.get('op') || 'tab';
+
+        if(op == 'tab') {
+            school.util.BaseUtil.openTab(viewType, tabTitle, tabId, config);
+        }else if(op == 'blank') {
+            window.open('http://localhost:8080');
+        }
+        
         menu.hide();
     }
 });

+ 1 - 0
frontend/pc-web/app/view/setting/msgtemplate/PanelController.js

@@ -102,6 +102,7 @@ Ext.define('school.view.setting.msgtemplate.PanelController', {
                 xtype: 'textfield',
                 fieldLabel: '模板ID',
                 name: 'templateId',
+                width: 450,
                 value: data.templateId
             }, {
                 xtype: 'button',

BIN
frontend/pc-web/packages/font-school/resources/fonts/iconfont.eot


File diff suppressed because it is too large
+ 0 - 0
frontend/pc-web/packages/font-school/resources/fonts/iconfont.js


+ 3 - 0
frontend/pc-web/packages/font-school/resources/fonts/iconfont.svg

@@ -44,6 +44,9 @@ Created by iconfont
     <glyph glyph-name="delete" unicode="&#59650;" d="M512 896C227.84 896 0 668.16 0 384s227.84-512 512-512 512 227.84 512 512S796.16 896 512 896zM726.016 169.98400000000004c-13.824-13.824-37.376-13.824-51.2 0L512 332.79999999999995l-162.816-162.816c-13.824-13.824-37.376-13.824-51.2 0s-13.824 37.376 0 51.2L460.8 384 297.984 546.816c-13.824 13.824-13.824 37.376 0 51.2s37.376 13.824 51.2 0L512 435.2l162.816 162.816c13.824 13.824 37.376 13.824 51.2 0s13.824-37.376 0-51.2L563.2 384l162.816-162.816c18.944-13.824 18.944-39.424 0-51.2z"  horiz-adv-x="1024" />
 
     
+    <glyph glyph-name="delete1" unicode="&#59665;" d="M519.440384 896c-104.681472 0-189.863936-82.92352-193.45408-186.834944H81.721344C54.528 709.165056 32.4608 687.1552 32.4608 660.025344s22.0672-49.139712 49.260544-49.139712h54.39488V60.108799999999974c0-103.399424 70.301696-187.858944 157.026304-187.858944H735.47776c86.718464 0 157.02016 83.94752 157.02016 187.858944V610.373632h49.268736c27.193344 0 49.260544 22.009856 49.260544 49.139712s-22.0672 49.139712-49.260544 49.139712h-229.376C709.30432 813.07648 624.121856 896 519.432192 896h0.008192z m-101.091328-186.834944c3.473408 53.426176 47.75936 94.912512 101.08928 94.697472 53.884928 0 97.503232-41.46176 100.583424-94.697472h-201.672704z m-125.206528-744.77568c-30.795776 0-64.657408 39.411712-64.657408 95.719424V610.373632h571.652096V59.59680000000003c0-56.307712-33.869824-95.721472-64.653312-95.721472h-442.34752v0.512h0.006144zM369.7664 111.12447999999995c21.000192 0 38.180864 20.856832 38.180864 46.936064V425.914368c0 26.07104-17.180672 46.936064-38.178816 46.936064-21.000192 0-38.180864-20.856832-38.180864-46.936064v-267.853824c0-26.07104 16.703488-46.936064 38.180864-46.936064z m138.401792 0c20.992 0 38.172672 20.856832 38.172672 46.936064V425.914368c0 26.07104-17.178624 46.936064-38.17472 46.936064-21.004288 0-38.176768-20.856832-38.176768-46.936064v-267.853824c0-26.07104 17.178624-46.936064 38.178816-46.936064z m145.55136 0c21.000192 0 38.180864 20.856832 38.180864 46.936064V425.914368c0 26.07104-17.180672 46.936064-38.180864 46.936064-20.998144 0-38.178816-20.856832-38.178816-46.936064v-267.853824c0-26.07104 16.703488-46.936064 38.178816-46.936064z"  horiz-adv-x="1024" />
+
+    
     <glyph glyph-name="add" unicode="&#59649;" d="M512 384m-512 0a512 512 0 1 1 1024 0 512 512 0 1 1-1024 0ZM585.142857 457.142857h219.428572v-146.285714H585.142857v-219.428572H438.857143V310.85714299999995H219.428571V457.142857h219.428572V676.571429h146.285714v-219.428572z"  horiz-adv-x="1024" />
 
     

BIN
frontend/pc-web/packages/font-school/resources/fonts/iconfont.ttf


BIN
frontend/pc-web/packages/font-school/resources/fonts/iconfont.woff


BIN
frontend/pc-web/packages/font-school/resources/fonts/iconfont.woff2


+ 4 - 0
frontend/pc-web/packages/font-school/sass/etc/icons.scss

@@ -30,6 +30,10 @@
   content: "\e902";
 }
 
+.ss-delete1:before {
+  content: "\e911";
+}
+
 .ss-add:before {
   content: "\e901";
 }

File diff suppressed because it is too large
+ 0 - 2
frontend/pc-web/packages/font-school/sass/src/all.scss


+ 3 - 2
frontend/pc-web/resources/json/navigation.json

@@ -59,8 +59,9 @@
         "view": "setting-msgtemplate-panel"
     }, {
         "id": "setting-device-list",
-        "text": "设备参数",
-        "view": "setting-device-list"
+        "text": "平台设备管理",
+        "view": "setting-device-list",
+        "op": "blank"
     }, {
         "id": "setting-operatelog-operatelog",
         "text": "操作日志",

Some files were not shown because too many files changed in this diff