Browse Source

设备参数界面

zhuth 6 years ago
parent
commit
6eb1f25d4e

+ 1 - 0
frontend/pc-web/app/view/basic/subject/List.js

@@ -37,6 +37,7 @@ Ext.define('school.view.basic.subject.List', {
                 selModel: {
                 selModel: {
                     type: 'cellmodel'
                     type: 'cellmodel'
                 },
                 },
+                disableDetail: true,
                 hiddenTools: false,
                 hiddenTools: false,
                 toolBtns: [{
                 toolBtns: [{
                     xtype: 'button',
                     xtype: 'button',

+ 25 - 29
frontend/pc-web/app/view/basic/subject/ListController.js

@@ -73,7 +73,7 @@ Ext.define('school.view.basic.subject.ListController', {
         if(targetCls.contains('fa-pencil')) {
         if(targetCls.contains('fa-pencil')) {
             me.modifyClick(record.data);
             me.modifyClick(record.data);
         }else if(targetCls.contains('fa-trash-o')) {
         }else if(targetCls.contains('fa-trash-o')) {
-            me.onDeleteClick(record.data.subject_id);
+            me.onDeleteClick(record);
         }
         }
     },
     },
 
 
@@ -144,41 +144,37 @@ Ext.define('school.view.basic.subject.ListController', {
         win.show();
         win.show();
     },
     },
 
 
-    onDeleteClick: function(id) {
+    onDeleteClick: function(record) {
         let me = this,
         let me = this,
         view = me.getView(),
         view = me.getView(),
         grid = view.down('grid'),
         grid = view.down('grid'),
-        selectedRecords = grid.getSelection(),
+        id = record.data.subject_id,
         data;
         data;
 
 
-        data = id ? [{
+        data = [{
             id: id
             id: id
-        }] : selectedRecords.map(function(r) {
-            return {
-                id: r.get('subject_id')
-            };
-        });
-
-        if(data.length == 0) {
-            school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
-            return;
-        }
+        }];
 
 
-        grid.setLoading(true);
-        school.util.BaseUtil.request({
-            // url: 'http://10.1.80.47:9560/student/batchDelete',
-            url: '/api/school/subject/batchDelete',
-            method: 'POST',
-            params: JSON.stringify({
-                baseDTOs: data
-            })
-        }).then(function(res) {
-            grid.setLoading(false);
-            school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
-            grid.store.loadPage(grid.store.currentPage);
-        }).catch(function(e) {
-            grid.setLoading(false);
-            school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
+        school.util.BaseUtil.showConfirm('确认删除', '确定要删除学科' + record.get('subject_name') + '吗?')
+        .then(function(yes) {
+            if(yes == 'yes') {
+                grid.setLoading(true);
+                school.util.BaseUtil.request({
+                    // url: 'http://10.1.80.47:9560/student/batchDelete',
+                    url: '/api/school/subject/batchDelete',
+                    method: 'POST',
+                    params: JSON.stringify({
+                        baseDTOs: data
+                    })
+                }).then(function(res) {
+                    grid.setLoading(false);
+                    school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
+                    grid.store.loadPage(grid.store.currentPage);
+                }).catch(function(e) {
+                    grid.setLoading(false);
+                    school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
+                });
+            }
         });
         });
     }
     }
 
 

+ 90 - 0
frontend/pc-web/app/view/setting/device/List.js

@@ -0,0 +1,90 @@
+/**
+ * 设备参数列表
+ */
+Ext.define('school.view.setting.device.List', {
+    extend: 'school.view.core.base.BasePanel',
+    xtype: 'setting-device-list',
+
+    controller: 'setting-device-list',
+
+    // dataUrl: 'http://10.1.80.47:9520/api/device/device/list',
+    dataUrl: '/api/device/device/list',
+    _title: '设备参数',
+    caller: null,
+    pathKey: null,
+
+    initComponent: function() {
+        var me = this;
+        Ext.apply(this, {
+            searchField: [{
+                xtype: 'textfield',
+                name: 'deviceName',
+                fieldLabel: '名称'
+            }],
+            gridConfig: {
+                addTitle: '设备参数',
+                addXtype: null,
+                idField: 'id',
+                codeField: null,
+                detailField: null,
+                dataUrl: me.dataUrl,
+                caller: null,
+                rootProperty: 'data.list',
+                totalProperty: 'data.total',
+                actionColumn: [],
+                selModel: {
+                    type: 'cellmodel'
+                },
+                disableDetail: true,
+                hiddenTools: false,
+                toolBtns: [{
+                    xtype: 'button',
+                    text: '新增',
+                    handler: 'onAddClick'
+                }],
+                columns : [{
+                    text: '设备ID',
+                    dataIndex: 'deviceId'
+                }, {
+                    text: '设备IP',
+                    dataIndex: 'deviceIp',
+                    width: 120
+                }, {
+                    text: '设备名称',
+                    dataIndex: 'deviceName',
+                    width: 120
+                }, {
+                    text: '用户',
+                    dataIndex: 'deviceUser'
+                }, {
+                    text: '密码',
+                    dataIndex: 'devicePassword'
+                }, {
+                    text: '端口',
+                    dataIndex: 'devicePort'
+                }, {
+                    text: '备注',
+                    dataIndex: 'deviceRemark',
+                    width: 150
+                }, {
+                    xtype:'actioncolumn',
+                    width:70,
+                    dataIndex:'actioncolumn',
+                    text:'操作',
+                    align: 'center',
+                    items: [{
+                        tooltip: '编辑',
+                        iconCls: 'x-fa fa-pencil fa-fw'
+                    },{
+                        iconCls:'x-fa fa-trash-o fa-fw',
+                        tooltip: '删除'
+                    }],
+                    listeners: {
+                        click: 'onActionClick'
+                    }
+                }]
+            },
+        });
+        this.callParent(arguments);
+    }
+});

+ 246 - 0
frontend/pc-web/app/view/setting/device/ListController.js

@@ -0,0 +1,246 @@
+Ext.define('school.view.basic.class.ListCardController', {
+    extend: 'school.view.core.base.BasePanelController',
+    alias: 'controller.setting-device-list',
+
+    onAddClick: function () {
+        let me = this,
+        view = me.getView(),
+        win = Ext.getCmp('device-addwin');
+
+        if (!win) {
+            win = Ext.create('Ext.window.Window', {
+                title: '新增设备信息',
+                width: 450,
+                height: 380,
+                id: 'device-addwin',
+                constrain: true,
+                modal: true,
+                bodyPadding: 10,
+                layout: 'fit',
+                items: [{
+                    xtype: 'form',
+                    layout: 'column',
+                    defaults: {
+                        columnWidth: 1
+                    },
+                    items: [{
+                        xtype: 'textfield',
+                        name: 'deviceIp',
+                        emptyText: '设备IP',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'deviceName',
+                        emptyText: '设备名称',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'deviceUser',
+                        emptyText: '用户',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'devicePassword',
+                        emptyText: '密码',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'devicePort',
+                        emptyText: '端口',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'deviceRemark',
+                        emptyText: '备注'
+                    }],
+                    buttonAlign: 'center',
+                    buttons: [{
+                        text: '确定',
+                        formBind: true,
+                        handler: function () {
+                            let form = this.up('form');
+                            let values = form.getValues();
+                            let url, params, headers;
+                            
+                            params = JSON.stringify(values);
+
+                            view.setLoading(true);
+                            school.util.BaseUtil.request({
+                                // url: 'http://10.1.80.47:9520/api/device/device/save',
+                                url: '/api/device/device/save',
+                                method: 'POST',
+                                params: params,
+                                headers: headers
+                            }).then(function (res) {
+                                view.setLoading(false);
+                                win.close();
+                                school.util.BaseUtil.showSuccessToast('添加成功');
+                                view.refresh();
+                            }).catch(function (e) {
+                                view.setLoading(false);
+                                school.util.BaseUtil.showErrorToast('添加失败: ' + e.message);
+                            });
+                        }
+                    }]
+                }]
+            });
+            view.add(win);
+        }
+        win.show();
+    },
+
+    onActionClick: function(tableView, td, row, col, e, record, tr) {
+        let me = this;
+        let targetCls = event.target.classList;
+        if(targetCls.contains('fa-pencil')) {
+            me.modifyClick(record.data);
+        }else if(targetCls.contains('fa-trash-o')) {
+            me.onDeleteClick(record);
+        }
+    },
+
+    modifyClick: function (data) {
+        let me = this,
+        view = me.getView(),
+        win = Ext.getCmp('device-modifywin');
+
+        if (!win) {
+            win = Ext.create('Ext.window.Window', {
+                title: '修改设备信息',
+                width: 450,
+                height: 380,
+                id: 'device-modifywin',
+                constrain: true,
+                modal: true,
+                bodyPadding: 10,
+                layout: 'fit',
+                items: [{
+                    xtype: 'form',
+                    layout: 'column',
+                    defaults: {
+                        columnWidth: 1
+                    },
+                    items: [{
+                        xtype: 'textfield',
+                        name: 'deviceId',
+                        emptyText: '设备ID',
+                        hidden: true,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'deviceIp',
+                        emptyText: '设备IP',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'deviceName',
+                        emptyText: '设备名称',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'deviceUser',
+                        emptyText: '用户',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'devicePassword',
+                        emptyText: '密码',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'devicePort',
+                        emptyText: '端口',
+                        allowBlank: false,
+                        maxLength: 20
+                    }, {
+                        xtype: 'textfield',
+                        name: 'deviceRemark',
+                        emptyText: '备注'
+                    }],
+                    buttonAlign: 'center',
+                    buttons: [{
+                        text: '确定',
+                        formBind: true,
+                        handler: function () {
+                            let form = this.up('form');
+                            let values = form.getValues();
+                            let params, headers;
+                            
+                            params = JSON.stringify(values);
+
+                            view.setLoading(true);
+                            school.util.BaseUtil.request({
+                                // url: 'http://10.1.80.47:9520/api/device/device/save',
+                                url: '/api/device/device/save',
+                                method: 'POST',
+                                params: params,
+                                headers: headers
+                            }).then(function (res) {
+                                view.setLoading(false);
+                                win.close();
+                                school.util.BaseUtil.showSuccessToast('修改成功');
+                                view.refresh();
+                            }).catch(function (e) {
+                                view.setLoading(false);
+                                school.util.BaseUtil.showErrorToast('修改失败: ' + e.message);
+                            });
+                        }
+                    }]
+                }]
+            });
+            view.add(win);
+            win.down('form').getForm().findField('deviceId').setValue(data.deviceId);
+            win.down('form').getForm().findField('deviceIp').setValue(data.deviceIp);
+            win.down('form').getForm().findField('deviceName').setValue(data.deviceName);
+            win.down('form').getForm().findField('deviceUser').setValue(data.deviceUser);
+            win.down('form').getForm().findField('devicePassword').setValue(data.devicePassword);
+            win.down('form').getForm().findField('devicePort').setValue(data.devicePort);
+            win.down('form').getForm().findField('deviceRemark').setValue(data.deviceRemark);
+        }
+        win.show();
+    },
+
+    onDeleteClick: function(record) {
+        let me = this,
+        view = me.getView(),
+        grid = view.down('grid'),
+        id = record.data.deviceId,
+        data;
+
+        data = [{
+            id: id
+        }];
+
+        school.util.BaseUtil.showConfirm('确认删除', '确定要删除设备' + record.get('deviceName') + '吗?')
+        .then(function(yes) {
+            if(yes == 'yes') {
+                grid.setLoading(true);
+                school.util.BaseUtil.request({
+                    // url: 'http://10.1.80.47:9520/api/device/device/batchDelete',
+                    url: '/api/device/device/batchDelete',
+                    method: 'POST',
+                    params: JSON.stringify({
+                        baseDTOs: data
+                    })
+                }).then(function(res) {
+                    grid.setLoading(false);
+                    school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录');
+                    grid.store.loadPage(grid.store.currentPage);
+                }).catch(function(e) {
+                    grid.setLoading(false);
+                    school.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
+                });
+            }
+        });
+    }
+
+});

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

@@ -58,9 +58,9 @@
         "text": "角色授权",
         "text": "角色授权",
         "view": "setting-access-roleaccess"
         "view": "setting-access-roleaccess"
     }, {
     }, {
-        "id": "device-param",
+        "id": "setting-device-list",
         "text": "设备参数",
         "text": "设备参数",
-        "view": "device-param"
+        "view": "setting-device-list"
     }, {
     }, {
         "id": "setting-operatelog-operatelog",
         "id": "setting-operatelog-operatelog",
         "text": "操作日志",
         "text": "操作日志",