diff --git a/src/api/equipment-management/equipment-category.js b/src/api/equipment-management/equipment-category.js
index 89581734..44a1a8fd 100644
--- a/src/api/equipment-management/equipment-category.js
+++ b/src/api/equipment-management/equipment-category.js
@@ -4,7 +4,7 @@ const BASE = 'production_configuration/device_model/device_category/'
function apiParams (method, data = {}) {
return {
- method: `equipment_management_equipment_model_equipment_category_${method}`,
+ method: `production_configuration_device_model_device_category_${method}`,
platform: 'background',
...data
}
diff --git a/src/api/equipment-management/equipment-registry.js b/src/api/equipment-management/equipment-registry.js
index 4ee24c5b..d4623650 100644
--- a/src/api/equipment-management/equipment-registry.js
+++ b/src/api/equipment-management/equipment-registry.js
@@ -28,6 +28,23 @@ export function batchDeleteItems (data) {
return request({ url: BASE + 'batch_delete', method: 'delete', data: params('production_configuration_device_model_device_management_batch_delete', data) })
}
+export function getImportTemplate (data) {
+ return request({
+ url: BASE + 'get_import_template',
+ method: 'post',
+ responseType: 'blob',
+ data: params('production_configuration_device_model_device_management_get_import_template', data)
+ })
+}
+
+export function importData (data) {
+ return request({
+ url: BASE + 'device_data_import',
+ method: 'post',
+ data: params('production_configuration_device_model_device_management_device_data_import', data)
+ })
+}
+
export function createExportTask (data) {
return request({ url: BASE + 'device_data_export_task', method: 'post', data: params('production_configuration_device_model_device_management_device_export_task', data) })
}
diff --git a/src/api/production-master-data/production-line.js b/src/api/production-master-data/production-line.js
index 3864b2cb..b3e43be6 100644
--- a/src/api/production-master-data/production-line.js
+++ b/src/api/production-master-data/production-line.js
@@ -10,6 +10,14 @@ function apiParams (method, data = {}) {
}
}
+export function getProductionLineALL (data) {
+ return request({
+ url: BASE + 'all',
+ method: 'get',
+ params: apiParams('all', data)
+ })
+}
+
export function getProductionLineList (data) {
return request({
url: BASE + 'list',
diff --git a/src/locales/en.json b/src/locales/en.json
index 273aff10..13dd698c 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -862,16 +862,21 @@
"add": "Add",
"edit": "Edit",
"delete": "Delete",
+ "batch_delete": "Batch Delete",
+ "import": "Import",
"export": "Export",
"operation": "Operation",
- "add_title": "Add",
- "edit_title": "Edit",
+ "add_title": "Add Equipment",
+ "edit_title": "Edit Equipment",
"confirm": "Confirm",
"cancel": "Cancel",
"tip": "Prompt",
"confirm_delete": "Delete this record?",
+ "confirm_batch_delete": "Batch delete selected equipment?",
"confirm_export": "Create export task?",
"operation_success": "Operation succeeded",
+ "create_download_task_success": "Download task created",
+ "please_select_data": "Please select data",
"keyword": "Keyword",
"enter_keyword": "Enter keyword",
"remark": "Remark",
@@ -883,14 +888,41 @@
"enter_device_code": "Enter device code",
"device_name": "Device Name",
"enter_device_name": "Enter device name",
+ "device_category": "Device Category",
+ "select_device_category": "Please select device category",
+ "design_ppm": "Design PPM",
+ "enter_design_ppm": "Please enter design PPM",
+ "ip": "IP",
+ "enter_ip": "Please enter IP",
+ "manufacturer": "Manufacturer",
+ "enter_manufacturer": "Please enter manufacturer",
+ "fixed_asset_code": "Fixed Asset Code",
+ "enter_fixed_asset_code": "Please enter fixed asset code",
+ "entry_time": "Entry Time",
+ "select_entry_time": "Please select entry time",
"device_id": "Device ID",
"enter_device_id": "Enter device ID",
"device_type": "Device Type",
"enter_device_type": "Enter device type",
"area": "Area",
"enter_area": "Enter area",
+ "select_area": "Please select area",
"line": "Line",
"enter_line": "Enter line",
+ "production_line": "Production Line",
+ "select_production_line": "Please select production line",
+ "select_factory_first": "Please select area first",
+ "length_1_100": "Length must be 1 to 100 characters",
+ "device_data_import": "Equipment Import",
+ "import_warning": "Only xlsx or xls files following the template can be uploaded",
+ "import_table": "Import Table",
+ "select_file": "Select File",
+ "download_template": "Download Template",
+ "preview": "Preview",
+ "import_template_name": "Equipment Import Template",
+ "import_file_format_error": "Please upload xls or xlsx file",
+ "import_missing_column": "Column [{name}] does not exist in the file. Please check.",
+ "import_no_data": "Please import data first",
"standard": "Standard",
"enter_standard": "Enter standard",
"inspection_item_code": "Inspection Item Code",
diff --git a/src/locales/zh-chs.json b/src/locales/zh-chs.json
index f556950f..52ad9f57 100644
--- a/src/locales/zh-chs.json
+++ b/src/locales/zh-chs.json
@@ -862,16 +862,21 @@
"add": "新增",
"edit": "编辑",
"delete": "删除",
+ "batch_delete": "批量删除",
+ "import": "导入",
"export": "导出",
"operation": "操作",
- "add_title": "新增",
- "edit_title": "编辑",
+ "add_title": "新增设备信息",
+ "edit_title": "编辑设备信息",
"confirm": "确定",
"cancel": "取消",
"tip": "提示",
"confirm_delete": "确认删除该记录?",
+ "confirm_batch_delete": "确认批量删除选中的设备信息?",
"confirm_export": "确认创建导出任务?",
"operation_success": "操作成功",
+ "create_download_task_success": "创建下载任务成功",
+ "please_select_data": "请选择数据",
"keyword": "关键字",
"enter_keyword": "请输入关键字",
"remark": "备注",
@@ -883,14 +888,41 @@
"enter_device_code": "请输入设备编码",
"device_name": "设备名称",
"enter_device_name": "请输入设备名称",
+ "device_category": "设备类别",
+ "select_device_category": "请选择设备类别",
+ "design_ppm": "设计PPM",
+ "enter_design_ppm": "请输入设计PPM",
+ "ip": "IP",
+ "enter_ip": "请输入IP",
+ "manufacturer": "厂商",
+ "enter_manufacturer": "请输入厂商",
+ "fixed_asset_code": "设备固定资产编码",
+ "enter_fixed_asset_code": "请输入设备固定资产编码",
+ "entry_time": "进场时间",
+ "select_entry_time": "请选择进场时间",
"device_id": "设备ID",
"enter_device_id": "请输入设备ID",
"device_type": "设备类别",
"enter_device_type": "请输入设备类别",
"area": "所属区域",
"enter_area": "请输入所属区域",
+ "select_area": "请选择所区",
"line": "所属产线",
"enter_line": "请输入所属产线",
+ "production_line": "产线",
+ "select_production_line": "请选择产线",
+ "select_factory_first": "请先选择所区",
+ "length_1_100": "长度在 1 到 100 个字符",
+ "device_data_import": "设备信息导入",
+ "import_warning": "上传的文件后缀必须是 xlsx 或 xls,且根据模板上传,否则不能上传成功",
+ "import_table": "导入表格",
+ "select_file": "选择文件",
+ "download_template": "下载模板",
+ "preview": "预览",
+ "import_template_name": "设备数据导入模板",
+ "import_file_format_error": "请上传 xls 或 xlsx 文件",
+ "import_missing_column": "文件不存在【{name}】数据列,请检查",
+ "import_no_data": "请先导入数据",
"standard": "标准",
"enter_standard": "请输入标准",
"inspection_item_code": "点检项目编码",
diff --git a/src/views/equipment-management/equipment-model/equipment-registry/index.vue b/src/views/equipment-management/equipment-model/equipment-registry/index.vue
index 27d118b3..63f59500 100644
--- a/src/views/equipment-management/equipment-model/equipment-registry/index.vue
+++ b/src/views/equipment-management/equipment-model/equipment-registry/index.vue
@@ -4,22 +4,25 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ $t(key('search')) }}
@@ -42,21 +45,131 @@
@selection-change="onSelect"
/>
-
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t(key('cancel')) }}
+ {{ $t(key('confirm')) }}
+
+
+
+
+
+
+
+
+ {{ $t(key('select_file')) }}
+
+ {{ $t(key('download_template')) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t(key('cancel')) }}
+ {{ $t(key('confirm')) }}
+
+
@@ -66,12 +179,24 @@ import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import PageTable from '@/components/page-table'
-import PageDialogForm from '@/components/page-dialog-form'
-import { getList, createItem, editItem, deleteItem, createExportTask } from '@/api/equipment-management/equipment-registry'
+import {
+ getList,
+ createItem,
+ editItem,
+ deleteItem,
+ batchDeleteItems,
+ getImportTemplate,
+ importData,
+ createExportTask
+} from '@/api/equipment-management/equipment-registry'
+import { getEquipmentCategoryALL } from '@/api/equipment-management/equipment-category'
+import { getFactoryAreaALL } from '@/api/production-master-data/factory-area'
+import { getProductionLineALL } from '@/api/production-master-data/production-line'
+import { downloadRename, readExcel } from '@/utils/file'
export default {
name: 'equipment-management-equipment-registry',
- components: { PageTable, PageDialogForm },
+ components: { PageTable },
mixins: [i18nMixin('page.equipment_management.equipment_model.equipment_registry'), confirmMixin],
data () {
return {
@@ -83,122 +208,66 @@ export default {
dialogTitle: '',
editId: '',
handleType: 'create',
- search: {
- device_code: '',
- device_name: ''
- },
+ search: { code: '', name: '', device_category_id: '', area_id: '', line_id: '' },
pagination: { current: 1, size: 10, total: 0 },
- formData: {
- device_code: '',
- device_name: '',
- device_type_id: '',
- device_status: '',
- area_id: '',
- line_id: '',
- remark: ''
- },
+ formData: this.emptyForm(),
+ deviceCategoryOptions: [],
+ areaOptions: [],
+ searchLineOptions: [],
+ formLineOptions: [],
+ importVisible: false,
+ importFileList: [],
+ importRows: [],
+ importTableLoading: false,
+ importTemplateLoading: false,
+ importSubmitting: false,
rules: {
- device_code: [{ required: true, message: this.key('enter_device_code'), trigger: 'blur' }],
- device_name: [{ required: true, message: this.key('enter_device_name'), trigger: 'blur' }]
+ code: [
+ { required: true, message: this.key('enter_device_code'), trigger: 'blur' },
+ { min: 1, max: 100, message: this.key('length_1_100'), trigger: 'blur' }
+ ],
+ name: [
+ { required: true, message: this.key('enter_device_name'), trigger: 'blur' },
+ { min: 1, max: 100, message: this.key('length_1_100'), trigger: 'blur' }
+ ],
+ device_category_id: [{ required: true, message: this.key('select_device_category'), trigger: 'change' }],
+ area_id: [{ required: true, message: this.key('select_area'), trigger: 'change' }],
+ line_id: [{ required: true, message: this.key('select_production_line'), trigger: 'change' }],
+ design_ppm: [{ required: true, message: this.key('enter_design_ppm'), trigger: 'blur' }]
},
columns: [],
toolbarButtons: [],
- rowButtons: [],
- formCols: [
- [
- {
- type: 'input',
- prop: 'device_code',
- label: this.key('device_code'),
- placeholder: this.key('enter_device_code'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'input',
- prop: 'device_name',
- label: this.key('device_name'),
- placeholder: this.key('enter_device_name'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'input',
- prop: 'device_type_id',
- label: this.key('device_type'),
- placeholder: this.key('enter_device_type'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'input',
- prop: 'device_status',
- label: this.key('status'),
- placeholder: this.key('enter_status'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'input',
- prop: 'area_id',
- label: this.key('area'),
- placeholder: this.key('enter_area'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'input',
- prop: 'line_id',
- label: this.key('line'),
- placeholder: this.key('enter_line'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'input',
- prop: 'remark',
- label: this.key('remark'),
- placeholder: this.key('enter_remark'),
- inputType: 'textarea',
- autosize: { minRows: 2, maxRows: 6 },
- clearable: true,
- style: { width: '90%' }
- }
- ]
- ]
+ rowButtons: []
}
},
created () {
this.columns = useTableColumns([
- { prop: 'device_code', label: this.key('device_code'), minWidth: 140 },
- { prop: 'device_name', label: this.key('device_name'), minWidth: 140 },
- { prop: 'device_type_name', label: this.key('device_type'), minWidth: 140 },
- { prop: 'device_status', label: this.key('status'), minWidth: 140 },
- { prop: 'area_name', label: this.key('area'), minWidth: 140 },
- { prop: 'line_name', label: this.key('line'), minWidth: 140 },
- { prop: 'remark', label: this.key('remark'), minWidth: 140 },
+ { type: 'selection', width: 55 },
+ { prop: 'sort', label: this.key('sort'), width: 80 },
+ { prop: 'code', label: this.key('device_code'), minWidth: 130 },
+ { prop: 'name', label: this.key('device_name'), minWidth: 130 },
+ { prop: 'device_category_name', label: this.key('device_category'), minWidth: 130 },
+ { prop: 'design_ppm', label: this.key('design_ppm'), minWidth: 110 },
+ { prop: 'area_name', label: this.key('area'), minWidth: 120 },
+ { prop: 'line_name', label: this.key('production_line'), minWidth: 120 },
+ { prop: 'ip', label: this.key('ip'), minWidth: 120 },
+ { prop: 'manufacturer', label: this.key('manufacturer'), minWidth: 130 },
+ { prop: 'fixed_asset_code', label: this.key('fixed_asset_code'), minWidth: 150 },
+ { prop: 'entry_time', label: this.key('entry_time'), minWidth: 120 },
+ { prop: 'remark', label: this.key('remark'), minWidth: 160 },
+ { prop: 'create_time', label: this.key('create_time'), minWidth: 160 },
{ prop: '_actions', label: this.key('operation'), width: 170, fixed: 'right' }
])
const btns = useTableButtons({
toolbar: [
- { key: 'add', label: this.key('add'), icon: 'el-icon-plus', type: 'primary', auth: '/device_management/device_model/device_management/create', onClick: this.openAdd },
- { key: 'export', label: this.key('export'), icon: 'el-icon-download', auth: '/device_management/device_model/device_management/export', onClick: this.handleExport }
+ { key: 'add', label: this.key('add'), icon: 'el-icon-plus', type: 'primary', auth: '/production_configuration/device_model/device_management/create', onClick: this.openAdd },
+ { key: 'batchDelete', label: this.key('batch_delete'), icon: 'el-icon-delete', type: 'danger', auth: '/production_configuration/device_model/device_management/batch-delete', needSelection: true, onClick: this.handleBatchDelete },
+ { key: 'import', label: this.key('import'), icon: 'el-icon-upload2', type: 'success', auth: '/production_configuration/device_model/device_management/import', onClick: this.openImport },
+ { key: 'export', label: this.key('export'), icon: 'el-icon-download', auth: '/production_configuration/device_model/device_management/export', onClick: this.handleExport }
],
row: [
- { key: 'edit', label: this.key('edit'), icon: 'el-icon-edit', auth: '/device_management/device_model/device_management/edit', onClick: this.openEdit },
- { key: 'delete', label: this.key('delete'), icon: 'el-icon-delete', color: 'danger', auth: '/device_management/device_model/device_management/delete', onClick: this.handleDelete }
+ { key: 'edit', label: this.key('edit'), icon: 'el-icon-edit', auth: '/production_configuration/device_model/device_management/edit', onClick: this.openEdit },
+ { key: 'delete', label: this.key('delete'), icon: 'el-icon-delete', color: 'danger', auth: '/production_configuration/device_model/device_management/delete', onClick: this.handleDelete }
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
@@ -206,11 +275,34 @@ export default {
this.fetchData()
},
methods: {
+ emptyForm () {
+ return {
+ code: '',
+ name: '',
+ ip: '',
+ manufacturer: '',
+ device_category_id: '',
+ fixed_asset_code: '',
+ design_ppm: '',
+ area_id: '',
+ line_id: '',
+ entry_time: '',
+ remark: ''
+ }
+ },
normalizeResponse (res) {
- const data = res && res.data !== undefined ? res.data : res
- if (Array.isArray(data)) return { list: data, total: data.length }
- if (data && Array.isArray(data.data)) return { list: data.data, total: Number(data.count || data.total || data.data.length) }
- if (data && data.data && Array.isArray(data.data.data)) return { list: data.data.data, total: Number(data.data.count || data.data.total || data.data.data.length) }
+ const getTotal = (source, fallback) => {
+ if (!source) return fallback
+ const total = source.count ?? source.total ?? source.total_count ?? source.record_count
+ const value = Number(total)
+ return Number.isNaN(value) ? fallback : value
+ }
+ const containers = [res, res && res.data, res && res.data && res.data.data].filter(Boolean)
+ for (const item of containers) {
+ if (Array.isArray(item)) return { list: item, total: getTotal(res, item.length) }
+ const list = item.data || item.list || item.rows || item.records || item.items
+ if (Array.isArray(list)) return { list, total: getTotal(item, getTotal(res, list.length)) }
+ }
return { list: [], total: 0 }
},
async fetchData () {
@@ -229,12 +321,9 @@ export default {
this.fetchData()
},
onReset () {
- this.search = {
- device_code: '',
- device_name: ''
- }
- this.pagination.current = 1
- this.fetchData()
+ this.search = { code: '', name: '', device_category_id: '', area_id: '', line_id: '' }
+ this.searchLineOptions = []
+ this.onSearch()
},
onPageChange (page) {
this.pagination.current = page.current
@@ -244,80 +333,189 @@ export default {
onSelect (rows) {
this.selectedRows = rows
},
- resetForm () {
- this.formData = {
- device_code: '',
- device_name: '',
- device_type_id: '',
- device_status: '',
- area_id: '',
- line_id: '',
- remark: ''
+ async loadDeviceCategories () {
+ if (this.deviceCategoryOptions.length) return
+ const res = await getEquipmentCategoryALL()
+ this.deviceCategoryOptions = this.normalizeResponse(res).list.map(item => ({ label: item.name, value: item.id, code: item.code }))
+ },
+ async loadAreas () {
+ if (this.areaOptions.length) return
+ const res = await getFactoryAreaALL()
+ this.areaOptions = this.normalizeResponse(res).list.map(item => ({ label: item.name, value: item.area_id || item.id }))
+ },
+ async loadLines (areaId) {
+ if (!areaId) {
+ this.$message.warning(this.$t(this.key('select_factory_first')))
+ return []
}
+ const res = await getProductionLineALL({ area_id: areaId })
+ return this.normalizeResponse(res).list.map(item => ({ label: item.name, value: item.id }))
+ },
+ async loadSearchLines () {
+ this.searchLineOptions = await this.loadLines(this.search.area_id)
+ },
+ async loadFormLines () {
+ this.formLineOptions = await this.loadLines(this.formData.area_id)
+ },
+ onSearchAreaChange () {
+ this.search.line_id = ''
+ this.searchLineOptions = []
+ },
+ onFormAreaChange () {
+ this.formData.line_id = ''
+ this.formLineOptions = []
+ },
+ resetForm () {
+ this.formData = this.emptyForm()
this.editId = ''
+ this.formLineOptions = []
+ this.$nextTick(() => this.$refs.form && this.$refs.form.clearValidate())
},
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_title')
- this.$nextTick(() => {
- this.$refs.dialogForm && this.$refs.dialogForm.reset()
- this.resetForm()
- this.dialogVisible = true
- })
+ this.resetForm()
+ this.loadDeviceCategories()
+ this.loadAreas()
+ this.dialogVisible = true
},
- openEdit (row) {
+ async openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_title')
this.editId = row.id
- this.formData = {
- device_code: row.device_code || '',
- device_name: row.device_name || '',
- device_type_id: row.device_type_id || '',
- device_status: row.device_status || '',
- area_id: row.area_id || '',
- line_id: row.line_id || '',
- remark: row.remark || ''
- }
+ this.formData = { ...this.emptyForm(), ...row }
+ await Promise.all([this.loadDeviceCategories(), this.loadAreas()])
+ if (this.formData.area_id) this.formLineOptions = await this.loadLines(this.formData.area_id)
this.dialogVisible = true
},
- async onDialogSubmit () {
- this.submitting = true
- try {
- if (this.handleType === 'create') await createItem(this.formData)
- else await editItem({ ...this.formData, id: this.editId })
- this.$message.success(this.$t(this.key('operation_success')))
- this.dialogVisible = false
- this.fetchData()
- } finally {
- this.submitting = false
- }
+ onDialogSubmit () {
+ this.$refs.form.validate(async valid => {
+ if (!valid) return
+ this.submitting = true
+ try {
+ if (this.handleType === 'create') await createItem(this.formData)
+ else await editItem({ ...this.formData, id: this.editId })
+ this.$message.success(this.$t(this.key('operation_success')))
+ this.dialogVisible = false
+ this.fetchData()
+ } finally {
+ this.submitting = false
+ }
+ })
},
onDialogClose () {
this.resetForm()
},
async handleDelete (row) {
- const cancelled = await this.$confirmAction(
- { message: this.key('confirm_delete'), title: this.key('tip') },
- () => deleteItem({ id: [row.id] })
- )
+ const cancelled = await this.$confirmAction({ message: this.key('confirm_delete'), title: this.key('tip') }, () => deleteItem({ id: [row.id] }))
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.pagination.current = Math.min(this.pagination.current, Math.ceil((this.pagination.total - 1) / this.pagination.size) || 1)
this.fetchData()
},
- async handleExport () {
- const cancelled = await this.$confirmAction(
- { message: this.key('confirm_export'), title: this.key('tip') },
- () => createExportTask({ ...this.search })
- )
+ async handleBatchDelete () {
+ if (!this.selectedRows.length) {
+ this.$message.error(this.$t(this.key('please_select_data')))
+ return
+ }
+ const ids = this.selectedRows.map(item => item.id)
+ const cancelled = await this.$confirmAction({ message: this.key('confirm_batch_delete'), title: this.key('tip') }, () => batchDeleteItems({ id: ids }))
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
+ this.fetchData()
+ },
+ openImport () {
+ this.resetImport()
+ this.importVisible = true
+ },
+ resetImport () {
+ this.importFileList = []
+ this.importRows = []
+ },
+ async downloadTemplate () {
+ this.importTemplateLoading = true
+ try {
+ const res = await getImportTemplate({})
+ downloadRename(res, 'xlsx', this.$t(this.key('import_template_name')))
+ } finally {
+ this.importTemplateLoading = false
+ }
+ },
+ getImportValue (row, names) {
+ for (const name of names) {
+ if (row[name] !== undefined && row[name] !== null) return row[name]
+ }
+ return ''
+ },
+ async onImportFileChange (file) {
+ if (!file || !/\.(xls|xlsx)$/i.test(file.name)) {
+ this.$message.error(this.$t(this.key('import_file_format_error')))
+ this.importFileList = []
+ return
+ }
+ this.importFileList = [file]
+ this.importTableLoading = true
+ try {
+ const rows = await readExcel(file.raw)
+ const required = ['设备编码', '设备名称', 'IP', '设备类别', '产线', '设计PPM', '厂商', '设备固定资产编码', '进场时间', '备注']
+ const first = rows[0] || {}
+ const missing = required.find(name => !Object.prototype.hasOwnProperty.call(first, name))
+ if (missing) {
+ this.$message.error(this.$t(this.key('import_missing_column'), { name: missing }))
+ this.importRows = []
+ return
+ }
+ this.importRows = rows.map(row => ({
+ code: this.getImportValue(row, ['设备编码']),
+ name: this.getImportValue(row, ['设备名称']),
+ ip: this.getImportValue(row, ['IP']),
+ device_category_name: this.getImportValue(row, ['设备类别']),
+ line_name: this.getImportValue(row, ['产线']),
+ design_ppm: this.getImportValue(row, ['设计PPM']),
+ manufacturer: this.getImportValue(row, ['厂商']),
+ fixed_asset_code: this.getImportValue(row, ['设备固定资产编码']),
+ entry_time: this.getImportValue(row, ['进场时间']),
+ remark: this.getImportValue(row, ['备注'])
+ }))
+ } finally {
+ this.importTableLoading = false
+ }
+ },
+ async submitImport () {
+ if (!this.importRows.length) {
+ this.$message.error(this.$t(this.key('import_no_data')))
+ return
+ }
+ this.importSubmitting = true
+ try {
+ await importData({ import_data: JSON.stringify(this.importRows) })
+ this.$message.success(this.$t(this.key('operation_success')))
+ this.importVisible = false
+ this.fetchData()
+ } finally {
+ this.importSubmitting = false
+ }
+ },
+ async handleExport () {
+ const cancelled = await this.$confirmAction({ message: this.key('confirm_export'), title: this.key('tip') }, () => createExportTask({ ...this.search, action: 'download' }))
+ if (cancelled) return
+ this.$message.success(this.$t(this.key('create_download_task_success')))
+ if (this.$router && this.$router.push) {
+ this.$router.push({ name: 'task' }).catch(() => {})
+ }
}
}
}