diff --git a/src/api/mes/board/screen.js b/src/api/mes/board/screen.js new file mode 100644 index 0000000..c5d0d6b --- /dev/null +++ b/src/api/mes/board/screen.js @@ -0,0 +1,63 @@ +import request from '@/utils/request' + +export function listBoardScreen(query) { + return request({ + url: '/mes/board/screen/list', + method: 'get', + params: query + }) +} + +export function getBoardScreen(screenId) { + return request({ + url: '/mes/board/screen/' + screenId, + method: 'get' + }) +} + +export function addBoardScreen(data) { + return request({ + url: '/mes/board/screen', + method: 'post', + data + }) +} + +export function updateBoardScreen(data) { + return request({ + url: '/mes/board/screen', + method: 'put', + data + }) +} + +export function delBoardScreen(screenId) { + return request({ + url: '/mes/board/screen/' + screenId, + method: 'delete' + }) +} + +export function getBoardScreenConfig(screenId) { + return request({ + url: '/mes/board/screen/config', + method: 'get', + params: { screenId } + }) +} + +export function saveBoardScreenConfig(data) { + return request({ + url: '/mes/board/screen/config', + method: 'post', + data + }) +} + +export function resetBoardScreenConfig(screenId) { + return request({ + url: '/mes/board/screen/config', + method: 'delete', + params: { screenId } + }) +} diff --git a/src/api/mes/board/workshop.js b/src/api/mes/board/workshop.js new file mode 100644 index 0000000..aacd1bd --- /dev/null +++ b/src/api/mes/board/workshop.js @@ -0,0 +1,9 @@ +import request from '@/utils/request' + +export function getWorkshopBoardData(screenCode) { + return request({ + url: '/mes/board/workshop/data', + method: 'get', + params: { screenCode } + }) +} diff --git a/src/api/mes/md/screenbinding.js b/src/api/mes/md/screenbinding.js new file mode 100644 index 0000000..bba6924 --- /dev/null +++ b/src/api/mes/md/screenbinding.js @@ -0,0 +1,130 @@ +import request from '@/utils/request' + +const DEFAULT_SCREEN_CODE = 'WORKSHOP_BOARD_DEFAULT' + +function createEmptyScreenBindingConfig(screenCode = DEFAULT_SCREEN_CODE) { + return { + screenCode, + workshopId: null, + workshopCode: '', + workshopName: '', + updatedAt: '', + basicBindings: [], + machineConfigs: [] + } +} + +function toUiBinding(binding) { + return { + bindingId: binding.bindingId, + screenCode: binding.screenCode, + workshopId: binding.workshopId, + workshopCode: binding.workshopCode, + workshopName: binding.workshopName, + sourceType: binding.sourceType || 'FIXED', + pointId: binding.pointId, + pointCode: binding.pointCode || '', + pointName: binding.pointName || '', + fixedValue: binding.fixedValue || '', + defaultValue: binding.defaultValue || '', + displayUnit: binding.displayUnit || '', + precisionDigit: binding.precisionDigit, + sortNum: binding.sortNum, + statusClass: binding.statusClass || 'is-running', + enableFlag: binding.enableFlag || 'Y', + key: binding.bindingKey, + label: binding.bindingName + } +} + +function toUiConfig(data) { + const emptyConfig = createEmptyScreenBindingConfig(data.screenCode || DEFAULT_SCREEN_CODE) + return { + ...emptyConfig, + screenCode: data.screenCode || emptyConfig.screenCode, + workshopId: data.workshopId === undefined ? emptyConfig.workshopId : data.workshopId, + workshopCode: data.workshopCode || emptyConfig.workshopCode, + workshopName: data.workshopName || emptyConfig.workshopName, + updatedAt: data.updatedAt || emptyConfig.updatedAt, + basicBindings: (data.basicBindings || []).map(toUiBinding), + machineConfigs: (data.machineConfigs || []).map(item => ({ + id: item.id, + statusClass: item.statusClass || 'is-running', + bindings: (item.bindings || []).map(toUiBinding) + })) + } +} + +function toApiBinding(binding, scope, machineId, statusClass) { + return { + bindingId: binding.bindingId, + screenCode: binding.screenCode, + workshopId: binding.workshopId, + workshopCode: binding.workshopCode, + workshopName: binding.workshopName, + bindingScope: scope, + machineId, + bindingKey: binding.key, + bindingName: binding.label, + sourceType: binding.sourceType, + pointId: binding.pointId, + pointCode: binding.pointCode, + pointName: binding.pointName, + fixedValue: binding.fixedValue, + defaultValue: binding.defaultValue, + displayUnit: binding.displayUnit, + precisionDigit: binding.precisionDigit, + statusClass: statusClass || binding.statusClass, + sortNum: binding.sortNum, + enableFlag: binding.enableFlag, + remark: binding.remark + } +} + +function toApiConfig(config) { + return { + screenCode: config.screenCode, + workshopId: config.workshopId, + workshopCode: config.workshopCode, + workshopName: config.workshopName, + basicBindings: (config.basicBindings || []).map(item => toApiBinding(item, 'BASIC', 0, item.statusClass)), + machineConfigs: (config.machineConfigs || []).map(machine => ({ + id: machine.id, + statusClass: machine.statusClass, + bindings: (machine.bindings || []).map(item => toApiBinding(item, 'MACHINE', machine.id, machine.statusClass)) + })) + } +} + +export function getScreenBindingConfig(screenCode) { + return request({ + url: '/mes/md/screenbinding/config', + method: 'get', + params: { screenCode } + }).then(response => ({ + ...response, + data: toUiConfig(response.data || {}) + })) +} + +export function saveScreenBindingConfig(data) { + return request({ + url: '/mes/md/screenbinding/config', + method: 'post', + data: toApiConfig(data) + }).then(response => ({ + ...response, + data: toUiConfig(response.data || {}) + })) +} + +export function resetScreenBindingConfig(screenCode) { + return request({ + url: '/mes/md/screenbinding/config', + method: 'delete', + params: { screenCode } + }).then(response => ({ + ...response, + data: toUiConfig(response.data || {}) + })) +} diff --git a/src/views/mes/board/workshop/index.vue b/src/views/mes/board/workshop/index.vue index 4322bdc..93be1c9 100644 --- a/src/views/mes/board/workshop/index.vue +++ b/src/views/mes/board/workshop/index.vue @@ -3,11 +3,11 @@