迁移正向追溯模块
This commit is contained in:
27
src/api/data-platform/traceability/forward.js
Normal file
27
src/api/data-platform/traceability/forward.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { request } from '@/api/_service'
|
||||
|
||||
const BASE = 'data_middleground/basic_traceability/positive_direction_traceability/'
|
||||
|
||||
function apiParams (method, data = {}) {
|
||||
return {
|
||||
method,
|
||||
platform: 'background',
|
||||
...data
|
||||
}
|
||||
}
|
||||
|
||||
export function getForwardTraceabilityList (data) {
|
||||
return request({
|
||||
url: BASE + 'list',
|
||||
method: 'get',
|
||||
params: apiParams('data_middleground_basic_traceability_positive_direction_traceability_list', data)
|
||||
})
|
||||
}
|
||||
|
||||
export function createForwardTraceabilityExportTask (data) {
|
||||
return request({
|
||||
url: BASE + 'export_task',
|
||||
method: 'post',
|
||||
data: apiParams('data_middleground_basic_traceability_positive_direction_traceability_export_task', data)
|
||||
})
|
||||
}
|
||||
@@ -1223,6 +1223,33 @@
|
||||
"device_code": "Device Code",
|
||||
"node_not_found": "No matching node found",
|
||||
"query_before_export": "Query traceability data before export"
|
||||
},
|
||||
"forward": {
|
||||
"query": "Search",
|
||||
"reset": "Reset",
|
||||
"export": "Export",
|
||||
"item_code": "Material Code",
|
||||
"enter_item_code": "Enter material code",
|
||||
"item_batch": "Material Batch",
|
||||
"enter_item_batch": "Enter material batch",
|
||||
"item_id": "Semi-finished ID",
|
||||
"enter_item_id": "Enter semi-finished ID",
|
||||
"battery_id": "Battery Barcode",
|
||||
"batch_id": "Batch No.",
|
||||
"item_name": "Material Name",
|
||||
"device_code": "Device Code",
|
||||
"work_unit": "Process Unit",
|
||||
"process_code": "Process Code",
|
||||
"finish_time": "Completion Time",
|
||||
"operation": "Operation",
|
||||
"reverse": "Reverse Traceability",
|
||||
"no_data": "No data",
|
||||
"export_confirm": "Create forward traceability export task?",
|
||||
"prompt": "Prompt",
|
||||
"confirm": "Confirm",
|
||||
"cancel": "Cancel",
|
||||
"please_select_filter_condition": "Select at least one filter condition",
|
||||
"create_download_task_success": "Download task created successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,6 +1223,33 @@
|
||||
"device_code": "设备编码",
|
||||
"node_not_found": "未找到匹配节点",
|
||||
"query_before_export": "请先查询追溯数据后再导出"
|
||||
},
|
||||
"forward": {
|
||||
"query": "查询",
|
||||
"reset": "重置",
|
||||
"export": "导出",
|
||||
"item_code": "物料编码",
|
||||
"enter_item_code": "请输入物料编码",
|
||||
"item_batch": "物料批次",
|
||||
"enter_item_batch": "请输入物料批次",
|
||||
"item_id": "半成品码",
|
||||
"enter_item_id": "请输入半成品码",
|
||||
"battery_id": "电池条码",
|
||||
"batch_id": "批次号",
|
||||
"item_name": "物料名称",
|
||||
"device_code": "设备编码",
|
||||
"work_unit": "工序单元",
|
||||
"process_code": "工序编码",
|
||||
"finish_time": "完成时间",
|
||||
"operation": "操作",
|
||||
"reverse": "反向追溯",
|
||||
"no_data": "暂无数据",
|
||||
"export_confirm": "确认创建正向追溯数据导出任务?",
|
||||
"prompt": "提示",
|
||||
"confirm": "确定",
|
||||
"cancel": "取消",
|
||||
"please_select_filter_condition": "请选择筛选条件",
|
||||
"create_download_task_success": "创建下载任务成功"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ export default {
|
||||
name: `${pre}basic_traceability-reverse_direction_traceability`,
|
||||
meta: { ...meta, cache: true, title: '反向追溯' },
|
||||
component: _import('data-platform/traceability/backward')
|
||||
},
|
||||
{
|
||||
path: 'basic_traceability/positive_direction_traceability',
|
||||
name: `${pre}basic_traceability-positive_direction_traceability`,
|
||||
meta: { ...meta, cache: true, title: '正向追溯' },
|
||||
component: _import('data-platform/traceability/forward')
|
||||
}
|
||||
])('data_middleground-')
|
||||
}
|
||||
|
||||
217
src/views/data-platform/traceability/forward/index.vue
Normal file
217
src/views/data-platform/traceability/forward/index.vue
Normal file
@@ -0,0 +1,217 @@
|
||||
<template>
|
||||
<d2-container>
|
||||
<template #header>
|
||||
<div class="search-bar">
|
||||
<el-form ref="searchForm" :inline="true" :model="search" size="mini">
|
||||
<el-form-item :label="$t(key('item_code'))" prop="item_code">
|
||||
<el-input
|
||||
v-model.trim="search.item_code"
|
||||
:placeholder="$t(key('enter_item_code'))"
|
||||
clearable
|
||||
style="width:220px"
|
||||
@keyup.enter.native="onSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t(key('item_batch'))" prop="item_batch">
|
||||
<el-input
|
||||
v-model.trim="search.item_batch"
|
||||
:placeholder="$t(key('enter_item_batch'))"
|
||||
clearable
|
||||
style="width:220px"
|
||||
@keyup.enter.native="onSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t(key('item_id'))" prop="item_id">
|
||||
<el-input
|
||||
v-model.trim="search.item_id"
|
||||
:placeholder="$t(key('enter_item_id'))"
|
||||
clearable
|
||||
style="width:220px"
|
||||
@keyup.enter.native="onSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" :disabled="loading" @click="onSearch">
|
||||
{{ $t(key('query')) }}
|
||||
</el-button>
|
||||
<el-button icon="el-icon-download" :disabled="loading" @click="exportTask">
|
||||
{{ $t(key('export')) }}
|
||||
</el-button>
|
||||
<el-button icon="el-icon-refresh" :disabled="loading" @click="onReset">
|
||||
{{ $t(key('reset')) }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<page-table
|
||||
:columns="columns"
|
||||
:data="pagedData"
|
||||
:loading="loading"
|
||||
:toolbar-buttons="[]"
|
||||
:row-buttons="rowButtons"
|
||||
:pagination="pagination"
|
||||
:table-attrs="{ size: 'mini', rowKey: rowKey, highlightCurrentRow: true }"
|
||||
auto-height
|
||||
@page-change="onPageChange"
|
||||
>
|
||||
<template #empty>
|
||||
<el-empty :description="$t(key('no_data'))" :image-size="80" />
|
||||
</template>
|
||||
</page-table>
|
||||
</d2-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useTableColumns } from '@/composables/useTableColumns'
|
||||
import { i18nMixin } from '@/composables/useI18n'
|
||||
import PageTable from '@/components/page-table'
|
||||
import {
|
||||
createForwardTraceabilityExportTask,
|
||||
getForwardTraceabilityList
|
||||
} from '@/api/data-platform/traceability/forward'
|
||||
|
||||
export default {
|
||||
name: 'data-platform-traceability-forward',
|
||||
components: { PageTable },
|
||||
mixins: [i18nMixin('page.data_platform.traceability.forward')],
|
||||
data () {
|
||||
return {
|
||||
loading: false,
|
||||
search: {
|
||||
item_code: '',
|
||||
item_batch: '',
|
||||
item_id: ''
|
||||
},
|
||||
tableData: [],
|
||||
pagination: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
total: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
columns () {
|
||||
return useTableColumns([
|
||||
{ prop: 'battery_id', label: this.key('battery_id'), minWidth: 170, showOverflowTooltip: true },
|
||||
{ prop: 'batch', label: this.key('batch_id'), minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'item_name', label: this.key('item_name'), minWidth: 180, showOverflowTooltip: true },
|
||||
{ prop: 'item_code', label: this.key('item_code'), minWidth: 170, showOverflowTooltip: true },
|
||||
{ prop: 'item_batch', label: this.key('item_batch'), minWidth: 170, showOverflowTooltip: true },
|
||||
{ prop: 'device_code', label: this.key('device_code'), minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'workingsubclass', label: this.key('work_unit'), minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'process_code', label: this.key('process_code'), minWidth: 150, showOverflowTooltip: true },
|
||||
{ prop: 'finish_time', label: this.key('finish_time'), minWidth: 170, showOverflowTooltip: true }
|
||||
], {
|
||||
selectionWidth: 0,
|
||||
indexWidth: 55,
|
||||
operationWidth: 120
|
||||
})
|
||||
},
|
||||
rowButtons () {
|
||||
return [
|
||||
{
|
||||
key: 'reverse',
|
||||
label: this.key('reverse'),
|
||||
type: 'primary',
|
||||
icon: 'el-icon-position',
|
||||
size: 'mini',
|
||||
onClick: this.goBackwardTraceability
|
||||
}
|
||||
]
|
||||
},
|
||||
pagedData () {
|
||||
const start = (this.pagination.current - 1) * this.pagination.size
|
||||
return this.tableData.slice(start, start + this.pagination.size)
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
rowKey (row) {
|
||||
return row.id || `${row.battery_id || ''}-${row.item_code || ''}-${row.item_batch || ''}-${row.finish_time || ''}`
|
||||
},
|
||||
responseData (res) {
|
||||
return res && res.data !== undefined ? res.data : res
|
||||
},
|
||||
buildParams () {
|
||||
return {
|
||||
...this.search,
|
||||
page_no: this.pagination.current,
|
||||
page_size: this.pagination.size
|
||||
}
|
||||
},
|
||||
validateSearch () {
|
||||
if (this.search.item_code && !this.search.item_batch) {
|
||||
this.$message.error(this.$t(this.key('enter_item_batch')))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
async fetchData () {
|
||||
if (!this.validateSearch()) return
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await getForwardTraceabilityList(this.buildParams())
|
||||
const data = this.responseData(res)
|
||||
this.tableData = Array.isArray(data) ? data : []
|
||||
this.pagination.total = this.tableData.length
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
onSearch () {
|
||||
this.pagination.current = 1
|
||||
this.fetchData()
|
||||
},
|
||||
onReset () {
|
||||
this.search = {
|
||||
item_code: '',
|
||||
item_batch: '',
|
||||
item_id: ''
|
||||
}
|
||||
this.pagination.current = 1
|
||||
this.fetchData()
|
||||
},
|
||||
onPageChange (page) {
|
||||
this.pagination = { ...this.pagination, ...page }
|
||||
},
|
||||
hasFilter () {
|
||||
return Object.keys(this.search).some(key => this.search[key])
|
||||
},
|
||||
async exportTask () {
|
||||
if (!this.hasFilter()) {
|
||||
this.$message.error(this.$t(this.key('please_select_filter_condition')))
|
||||
return
|
||||
}
|
||||
await this.$confirm(this.$t(this.key('export_confirm')), this.$t(this.key('prompt')), {
|
||||
type: 'warning',
|
||||
confirmButtonText: this.$t(this.key('confirm')),
|
||||
cancelButtonText: this.$t(this.key('cancel'))
|
||||
})
|
||||
await createForwardTraceabilityExportTask({
|
||||
...this.search,
|
||||
total: this.pagination.total,
|
||||
action: 'download'
|
||||
})
|
||||
this.$message.success(this.$t(this.key('create_download_task_success')))
|
||||
this.$router.push({ name: 'task' })
|
||||
},
|
||||
goBackwardTraceability (row) {
|
||||
this.$router.push({
|
||||
name: 'data_middleground-basic_traceability-reverse_direction_traceability',
|
||||
params: { battery_id: row.battery_id }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search-bar {
|
||||
margin-bottom: -18px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user