| | |
| | | tableResizeHandler: null, |
| | | dialogForm: createFormDefaults(), |
| | | dialogDisplay: createDisplayDefaults(), |
| | | stationEditorFields: ['stationList', 'barcodeStationList', 'inStationList', 'outStationList', 'runBlockReassignLocStationList', 'isOutOrderList', 'isLiftTransferList'], |
| | | jsonEditorRows: {}, |
| | | dialogRules: createFormRules() |
| | | }; |
| | | }, |
| | |
| | | resetDialogState: function () { |
| | | this.dialogForm = createFormDefaults(); |
| | | this.dialogDisplay = createDisplayDefaults(); |
| | | this.jsonEditorRows = {}; |
| | | if (this.$refs.dialogForm) { |
| | | this.$refs.dialogForm.clearValidate(); |
| | | } |
| | |
| | | self.$nextTick(function () { |
| | | self.resetDialogState(); |
| | | fillFormFromRow(row, self.dialogForm, self.dialogDisplay); |
| | | self.initJsonEditorRows(); |
| | | if (self.$refs.dialogForm) { |
| | | self.$refs.dialogForm.clearValidate(); |
| | | } |
| | |
| | | submitDialog: function () { |
| | | var self = this; |
| | | if (!self.$refs.dialogForm) { |
| | | return; |
| | | } |
| | | self.syncAllJsonEditors(); |
| | | var jsonError = self.validateAllJsonEditors(); |
| | | if (jsonError) { |
| | | self.$message.warning(jsonError); |
| | | return; |
| | | } |
| | | self.$refs.dialogForm.validate(function (valid) { |
| | |
| | | return true; |
| | | }); |
| | | }, |
| | | initJsonEditorRows: function () { |
| | | var self = this; |
| | | var editors = window.WcsJsonEditors; |
| | | self.stationEditorFields.forEach(function (field) { |
| | | self.$set(self.jsonEditorRows, field, editors.parseStationList(self.dialogForm[field])); |
| | | }); |
| | | }, |
| | | syncAllJsonEditors: function () { |
| | | var self = this; |
| | | var editors = window.WcsJsonEditors; |
| | | self.stationEditorFields.forEach(function (field) { |
| | | self.$set(self.dialogForm, field, editors.buildStationListJson(self.jsonEditorRows[field])); |
| | | }); |
| | | }, |
| | | validateAllJsonEditors: function () { |
| | | var self = this; |
| | | var editors = window.WcsJsonEditors; |
| | | var error = ''; |
| | | self.stationEditorFields.forEach(function (field) { |
| | | if (error) return; |
| | | error = editors.validateStationList(self.jsonEditorRows[field]); |
| | | }); |
| | | return error; |
| | | }, |
| | | addStationRow: function (field) { |
| | | if (!this.jsonEditorRows[field]) { |
| | | this.$set(this.jsonEditorRows, field, []); |
| | | } |
| | | this.jsonEditorRows[field].push(window.WcsJsonEditors.createEmptyStation()); |
| | | this.syncAllJsonEditors(); |
| | | }, |
| | | removeStationRow: function (field, index) { |
| | | this.jsonEditorRows[field].splice(index, 1); |
| | | this.syncAllJsonEditors(); |
| | | }, |
| | | toggleNested: function (field, rowIndex, nestedKey) { |
| | | var row = this.jsonEditorRows[field][rowIndex]; |
| | | var showKey = '_show' + nestedKey.charAt(0).toUpperCase() + nestedKey.slice(1); |
| | | this.$set(row, showKey, !row[showKey]); |
| | | }, |
| | | addNestedStation: function (field, rowIndex, nestedKey) { |
| | | var row = this.jsonEditorRows[field][rowIndex]; |
| | | var nested = {}; |
| | | window.WcsJsonEditors.STATION_OBJ_FIELDS.forEach(function (k) { nested[k] = ''; }); |
| | | this.$set(row, nestedKey, nested); |
| | | var showKey = '_show' + nestedKey.charAt(0).toUpperCase() + nestedKey.slice(1); |
| | | this.$set(row, showKey, true); |
| | | this.syncAllJsonEditors(); |
| | | }, |
| | | removeNestedStation: function (field, rowIndex, nestedKey) { |
| | | this.$set(this.jsonEditorRows[field][rowIndex], nestedKey, null); |
| | | this.syncAllJsonEditors(); |
| | | }, |
| | | syncStationField: function (field) { |
| | | this.$set(this.dialogForm, field, window.WcsJsonEditors.buildStationListJson(this.jsonEditorRows[field])); |
| | | }, |
| | | removeSelection: function () { |
| | | var self = this; |
| | | var ids = self.selection.map(function (row) { |