| | |
| | | } |
| | | ]; |
| | | |
| | | function applySelectTypeOptions(options) { |
| | | var normalizedOptions = []; |
| | | (options || []).forEach(function (item) { |
| | | var rawValue = ''; |
| | | var label = ''; |
| | | if (item && typeof item === 'object') { |
| | | rawValue = item.value !== undefined ? item.value : (item.rawValue !== undefined ? item.rawValue : (item.label !== undefined ? item.label : '')); |
| | | label = item.label !== undefined ? item.label : rawValue; |
| | | } else { |
| | | rawValue = item; |
| | | label = item; |
| | | } |
| | | rawValue = isEmptyValue(rawValue) ? '' : String(rawValue); |
| | | label = isEmptyValue(label) ? rawValue : String(label); |
| | | if (!rawValue) { |
| | | return; |
| | | } |
| | | normalizedOptions.push({ |
| | | rawValue: rawValue, |
| | | label: label |
| | | }); |
| | | }); |
| | | fieldMeta.forEach(function (field) { |
| | | if (field.field !== 'selectType') { |
| | | return; |
| | | } |
| | | field.kind = 'enum'; |
| | | field.enumOptions = normalizedOptions; |
| | | }); |
| | | } |
| | | |
| | | function isEmptyValue(value) { |
| | | return value === null || value === undefined || value === ''; |
| | | } |
| | |
| | | } |
| | | }, |
| | | created: function () { |
| | | this.fetchSelectTypeOptions(); |
| | | this.loadTable(); |
| | | }, |
| | | mounted: function () { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | fetchSelectTypeOptions: function () { |
| | | var self = this; |
| | | $.ajax({ |
| | | url: baseUrl + '/config/getSelectTypes', |
| | | method: 'POST', |
| | | headers: self.authHeaders(), |
| | | success: function (res) { |
| | | if (self.handleForbidden(res)) { |
| | | return; |
| | | } |
| | | if (!res || res.code !== 200) { |
| | | return; |
| | | } |
| | | applySelectTypeOptions(Array.isArray(res.data) ? res.data : []); |
| | | self.fieldMeta = fieldMeta.slice(); |
| | | self.allColumns = fieldMeta.slice(); |
| | | self.requestTableLayout(80); |
| | | } |
| | | }); |
| | | }, |
| | | handleSearch: function () { |
| | | this.page.curr = 1; |
| | | this.loadTable(); |