|
|
@@ -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);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+});
|