| | |
| | | |
| | | ]); |
| | | |
| | | var wrkMastLogFieldOrder = [ |
| | | 'wrkNo', |
| | | 'wmsWrkNo', |
| | | 'wrkSts', |
| | | 'ioType', |
| | | 'ioTime', |
| | | 'appeTime', |
| | | 'ioPri', |
| | | 'sourceStaNo', |
| | | 'staNo', |
| | | 'sourceLocNo', |
| | | 'locNo', |
| | | 'crnNo', |
| | | 'dualCrnNo', |
| | | 'batch', |
| | | 'batchSeq', |
| | | 'barcode', |
| | | 'modiUser', |
| | | 'modiTime', |
| | | 'appeUser', |
| | | 'systemMsg', |
| | | 'errorTime', |
| | | 'errorMemo', |
| | | 'memo', |
| | | 'id' |
| | | ]; |
| | | |
| | | var wrkMastLogFieldSettings = { |
| | | wrkNo: { |
| | | label: '工作号', |
| | | searchable: true, |
| | | quickSearch: true, |
| | | sortable: true, |
| | | minWidth: 110 |
| | | }, |
| | | wmsWrkNo: { |
| | | label: 'WMS工作号', |
| | | searchable: true, |
| | | quickSearch: true, |
| | | minWidth: 140 |
| | | }, |
| | | wrkSts: { |
| | | label: '工作状态', |
| | | kind: 'enum', |
| | | tableProp: 'wrkSts$', |
| | | exportField: 'wrkSts$', |
| | | enumOptions: [], |
| | | searchable: true, |
| | | quickSearch: true, |
| | | minWidth: 160 |
| | | }, |
| | | ioType: { |
| | | label: '入出库类型', |
| | | kind: 'enum', |
| | | tableProp: 'ioType$', |
| | | exportField: 'ioType$', |
| | | enumOptions: [], |
| | | searchable: true, |
| | | quickSearch: true, |
| | | minWidth: 160 |
| | | }, |
| | | ioTime: { |
| | | label: '工作时间', |
| | | tableProp: 'ioTime$', |
| | | exportField: 'ioTime$', |
| | | kind: 'date', |
| | | searchable: true, |
| | | quickSearch: true, |
| | | defaultVisible: false, |
| | | minWidth: 300 |
| | | }, |
| | | appeTime: { |
| | | label: '工作时间', |
| | | tableProp: 'appeTime$', |
| | | exportField: 'appeTime$', |
| | | sortable: true, |
| | | minWidth: 168 |
| | | }, |
| | | ioPri: { |
| | | label: '优先级', |
| | | minWidth: 90 |
| | | }, |
| | | sourceStaNo: { |
| | | label: '源站', |
| | | kind: 'enum', |
| | | enumOptions: [], |
| | | searchable: true, |
| | | minWidth: 120 |
| | | }, |
| | | staNo: { |
| | | label: '目标站', |
| | | kind: 'enum', |
| | | enumOptions: [], |
| | | searchable: true, |
| | | minWidth: 120 |
| | | }, |
| | | sourceLocNo: { |
| | | label: '源库位', |
| | | minWidth: 120 |
| | | }, |
| | | locNo: { |
| | | label: '目标库位', |
| | | minWidth: 120 |
| | | }, |
| | | crnNo: { |
| | | label: '堆垛机', |
| | | minWidth: 100 |
| | | }, |
| | | dualCrnNo: { |
| | | label: '双工位堆垛机', |
| | | minWidth: 140 |
| | | }, |
| | | batch: { |
| | | label: '批次', |
| | | minWidth: 100 |
| | | }, |
| | | batchSeq: { |
| | | label: '批次序列', |
| | | minWidth: 110 |
| | | }, |
| | | barcode: { |
| | | label: '条码', |
| | | searchable: true, |
| | | minWidth: 140 |
| | | }, |
| | | modiUser: { |
| | | label: '修改人员', |
| | | tableProp: 'modiUser$', |
| | | exportField: 'modiUser$', |
| | | defaultVisible: false |
| | | }, |
| | | modiTime: { |
| | | label: '修改时间', |
| | | tableProp: 'modiTime$', |
| | | exportField: 'modiTime$', |
| | | defaultVisible: false, |
| | | minWidth: 168 |
| | | }, |
| | | appeUser: { |
| | | label: '创建者', |
| | | tableProp: 'appeUser$', |
| | | exportField: 'appeUser$', |
| | | defaultVisible: false |
| | | }, |
| | | systemMsg: { |
| | | label: '系统消息', |
| | | textarea: true, |
| | | defaultVisible: false, |
| | | minWidth: 220 |
| | | }, |
| | | errorTime: { |
| | | label: '异常时间', |
| | | tableProp: 'errorTime$', |
| | | exportField: 'errorTime$', |
| | | defaultVisible: false, |
| | | minWidth: 168 |
| | | }, |
| | | errorMemo: { |
| | | label: '异常说明', |
| | | textarea: true, |
| | | defaultVisible: false, |
| | | minWidth: 220 |
| | | }, |
| | | memo: { |
| | | label: '备注', |
| | | textarea: true, |
| | | defaultVisible: false, |
| | | minWidth: 220 |
| | | }, |
| | | id: { |
| | | label: '编号', |
| | | defaultVisible: false, |
| | | minWidth: 90 |
| | | } |
| | | }; |
| | | |
| | | fieldMeta = filterFieldMetaByOrder(fieldMeta, wrkMastLogFieldOrder, wrkMastLogFieldSettings); |
| | | |
| | | function filterFieldMetaByOrder(list, order, settings) { |
| | | var metaMap = {}; |
| | | (list || []).forEach(function (field) { |
| | | if (!field || !field.field) { |
| | | return; |
| | | } |
| | | metaMap[field.field] = Object.assign({}, field); |
| | | }); |
| | | return (order || []).map(function (fieldName) { |
| | | if (!metaMap[fieldName]) { |
| | | return null; |
| | | } |
| | | var merged = Object.assign({}, metaMap[fieldName], settings && settings[fieldName] ? settings[fieldName] : {}); |
| | | if (merged.searchable === undefined) { |
| | | merged.searchable = false; |
| | | } |
| | | if (merged.quickSearch === undefined) { |
| | | merged.quickSearch = false; |
| | | } |
| | | if (merged.editable === undefined) { |
| | | merged.editable = false; |
| | | } |
| | | if (merged.defaultVisible === undefined) { |
| | | merged.defaultVisible = true; |
| | | } |
| | | return merged; |
| | | }).filter(Boolean); |
| | | } |
| | | |
| | | function formatFieldLabel(field) { |
| | | var raw = field && field.label ? String(field.label).trim() : ''; |
| | | if (raw) { |
| | |
| | | } |
| | | |
| | | function isSearchableField(field) { |
| | | return !!field && field.kind !== 'image' && !field.textarea; |
| | | return !!field && field.searchable === true && field.kind !== 'image' && !field.textarea; |
| | | } |
| | | |
| | | function isSortableField(field) { |
| | | if (!field) { |
| | | return false; |
| | | } |
| | | if (field.primaryKey) { |
| | | return true; |
| | | if (typeof field.sortable === 'boolean') { |
| | | return field.sortable; |
| | | } |
| | | return field.kind !== 'image' && !field.textarea && field.kind !== 'foreign'; |
| | | } |
| | |
| | | } |
| | | |
| | | function createDefaultVisibleColumnKeys() { |
| | | return fieldMeta.map(function (field) { |
| | | return fieldMeta.filter(function (field) { |
| | | return field.defaultVisible !== false; |
| | | }).map(function (field) { |
| | | return field.field; |
| | | }); |
| | | } |
| | |
| | | }; |
| | | } |
| | | |
| | | function getFieldByName(fieldName) { |
| | | for (var i = 0; i < fieldMeta.length; i += 1) { |
| | | if (fieldMeta[i] && fieldMeta[i].field === fieldName) { |
| | | return fieldMeta[i]; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | function buildEnumOptions(records, valueField, labelField) { |
| | | var options = []; |
| | | var seen = {}; |
| | | (records || []).forEach(function (item) { |
| | | if (!item) { |
| | | return; |
| | | } |
| | | var rawValue = item[valueField]; |
| | | if (isEmptyValue(rawValue)) { |
| | | return; |
| | | } |
| | | var key = String(rawValue); |
| | | if (seen[key]) { |
| | | return; |
| | | } |
| | | seen[key] = true; |
| | | options.push({ |
| | | rawValue: key, |
| | | label: isEmptyValue(item[labelField]) ? key : String(item[labelField]) |
| | | }); |
| | | }); |
| | | return options; |
| | | } |
| | | |
| | | function handleForbidden(res) { |
| | | if (res && res.code === 403) { |
| | | top.location.href = baseUrl + '/'; |
| | |
| | | }); |
| | | }, |
| | | quickSearchableFields: function () { |
| | | var result = []; |
| | | this.searchableFields.forEach(function (field) { |
| | | if (result.length >= 3 || field.kind === 'date') { |
| | | return; |
| | | } |
| | | result.push(field); |
| | | return this.searchableFields.filter(function (field) { |
| | | return field.quickSearch === true; |
| | | }); |
| | | return result; |
| | | }, |
| | | advancedSearchableFields: function () { |
| | | var quickKeys = this.quickSearchableFields.map(function (field) { |
| | | return field.field; |
| | | }); |
| | | return this.searchableFields.filter(function (field) { |
| | | return quickKeys.indexOf(field.field) === -1; |
| | | return field.quickSearch !== true; |
| | | }); |
| | | }, |
| | | hasAdvancedFilters: function () { |
| | |
| | | }, |
| | | editableFields: function () { |
| | | return this.fieldMeta.filter(function (field) { |
| | | return !field.primaryKey; |
| | | return !field.primaryKey && field.editable === true; |
| | | }); |
| | | }, |
| | | exportColumns: function () { |
| | |
| | | } |
| | | }, |
| | | created: function () { |
| | | this.loadSearchEnumOptions(); |
| | | this.loadTable(); |
| | | }, |
| | | mounted: function () { |
| | |
| | | } |
| | | this.$set(this.searchForm, field.field, ''); |
| | | }, |
| | | loadSearchEnumOptions: function () { |
| | | var self = this; |
| | | [ |
| | | { |
| | | field: 'wrkSts', |
| | | url: baseUrl + '/basWrkStatus/list/auth', |
| | | valueField: 'wrkSts', |
| | | labelField: 'wrkDesc', |
| | | limit: 200 |
| | | }, |
| | | { |
| | | field: 'ioType', |
| | | url: baseUrl + '/basWrkIotype/list/auth', |
| | | valueField: 'ioType', |
| | | labelField: 'ioDesc', |
| | | limit: 200 |
| | | }, |
| | | { |
| | | field: 'staNo', |
| | | url: baseUrl + '/basStation/list/auth', |
| | | valueField: 'stationId', |
| | | labelField: 'stationId', |
| | | limit: 500 |
| | | }, |
| | | { |
| | | field: 'sourceStaNo', |
| | | url: baseUrl + '/basStation/list/auth', |
| | | valueField: 'stationId', |
| | | labelField: 'stationId', |
| | | limit: 500 |
| | | } |
| | | ].forEach(function (config) { |
| | | $.ajax({ |
| | | url: config.url, |
| | | method: 'GET', |
| | | headers: self.authHeaders(), |
| | | data: { |
| | | curr: 1, |
| | | limit: config.limit |
| | | }, |
| | | success: function (res) { |
| | | if (self.handleForbidden(res)) { |
| | | return; |
| | | } |
| | | if (!res || res.code !== 200) { |
| | | return; |
| | | } |
| | | var payload = res.data || {}; |
| | | var field = getFieldByName(config.field); |
| | | if (!field) { |
| | | return; |
| | | } |
| | | self.$set(field, 'enumOptions', buildEnumOptions(payload.records, config.valueField, config.labelField)); |
| | | } |
| | | }); |
| | | }); |
| | | }, |
| | | buildQueryParams: function () { |
| | | var self = this; |
| | | var params = { |