|
|
|
|
@ -31,6 +31,14 @@
|
|
|
|
|
>
|
|
|
|
|
<Icon icon="ep:plus" class="mr-5px" /> {{ t('action.add') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
type="warning"
|
|
|
|
|
plain
|
|
|
|
|
@click="openImport"
|
|
|
|
|
v-hasPermi="['erp:product:import']"
|
|
|
|
|
>
|
|
|
|
|
<Icon icon="ep:upload" class="mr-5px" /> {{ t('action.import') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
type="success"
|
|
|
|
|
plain
|
|
|
|
|
@ -97,6 +105,49 @@
|
|
|
|
|
|
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
|
|
|
<ProductForm ref="formRef" @success="getList" />
|
|
|
|
|
|
|
|
|
|
<Dialog v-model="importDialogVisible" :title="t('action.import')" width="400">
|
|
|
|
|
<el-upload
|
|
|
|
|
ref="uploadRef"
|
|
|
|
|
v-model:file-list="importFileList"
|
|
|
|
|
:action="importUrl + '?updateSupport=' + updateSupport"
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
:disabled="importLoading"
|
|
|
|
|
:headers="uploadHeaders"
|
|
|
|
|
:limit="1"
|
|
|
|
|
:on-error="handleImportError"
|
|
|
|
|
:on-exceed="handleImportExceed"
|
|
|
|
|
:on-success="handleImportSuccess"
|
|
|
|
|
accept=".xlsx, .xls"
|
|
|
|
|
drag
|
|
|
|
|
>
|
|
|
|
|
<Icon icon="ep:upload" />
|
|
|
|
|
<div class="el-upload__text">
|
|
|
|
|
将文件拖到此处,或点击上传
|
|
|
|
|
</div>
|
|
|
|
|
<template #tip>
|
|
|
|
|
<div class="el-upload__tip text-center">
|
|
|
|
|
<div class="el-upload__tip">
|
|
|
|
|
<el-checkbox v-model="updateSupport" />
|
|
|
|
|
是否更新已存在的数据
|
|
|
|
|
</div>
|
|
|
|
|
<span>仅支持 .xlsx, .xls 格式</span>
|
|
|
|
|
<el-link
|
|
|
|
|
:underline="false"
|
|
|
|
|
style="font-size: 12px; vertical-align: baseline"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="importTemplate"
|
|
|
|
|
>
|
|
|
|
|
下载导入模板
|
|
|
|
|
</el-link>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-upload>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button :disabled="importLoading" type="primary" @click="submitImport">{{ t('common.ok') }}</el-button>
|
|
|
|
|
<el-button @click="importDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
@ -108,8 +159,9 @@ import ProductForm from './ProductForm.vue'
|
|
|
|
|
import { DICT_TYPE } from '@/utils/dict'
|
|
|
|
|
import { defaultProps, handleTree } from '@/utils/tree'
|
|
|
|
|
import { erpPriceTableColumnFormatter } from '@/utils'
|
|
|
|
|
import BomForm from "@/views/mes/bom/BomForm.vue";
|
|
|
|
|
import {checkPermi} from "@/utils/permission";
|
|
|
|
|
import BomForm from '@/views/mes/bom/BomForm.vue'
|
|
|
|
|
import { checkPermi } from '@/utils/permission'
|
|
|
|
|
import { getAccessToken, getTenantId } from '@/utils/auth'
|
|
|
|
|
|
|
|
|
|
/** ERP 产品列表 */
|
|
|
|
|
defineOptions({ name: 'ErpProduct' })
|
|
|
|
|
@ -129,6 +181,15 @@ const queryParams = reactive({
|
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
|
|
|
|
|
|
|
const importDialogVisible = ref(false)
|
|
|
|
|
const importLoading = ref(false)
|
|
|
|
|
const uploadRef = ref()
|
|
|
|
|
const importUrl =
|
|
|
|
|
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/erp/product/import'
|
|
|
|
|
const uploadHeaders = ref()
|
|
|
|
|
const importFileList = ref([])
|
|
|
|
|
const updateSupport = ref(0)
|
|
|
|
|
|
|
|
|
|
/** 查询列表 */
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
@ -188,6 +249,52 @@ const handleExport = async () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const openImport = () => {
|
|
|
|
|
importDialogVisible.value = true
|
|
|
|
|
importLoading.value = false
|
|
|
|
|
importFileList.value = []
|
|
|
|
|
updateSupport.value = 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const submitImport = async () => {
|
|
|
|
|
if (importFileList.value.length === 0) {
|
|
|
|
|
message.error('请选择导入文件')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
uploadHeaders.value = {
|
|
|
|
|
Authorization: 'Bearer ' + getAccessToken(),
|
|
|
|
|
tenantId: getTenantId()
|
|
|
|
|
}
|
|
|
|
|
importLoading.value = true
|
|
|
|
|
uploadRef.value?.submit()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleImportSuccess = (response: any) => {
|
|
|
|
|
if (!response || response.code !== 0) {
|
|
|
|
|
message.error(response?.msg || '导入失败')
|
|
|
|
|
importLoading.value = false
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
message.success('导入成功')
|
|
|
|
|
importLoading.value = false
|
|
|
|
|
importDialogVisible.value = false
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleImportError = () => {
|
|
|
|
|
message.error('导入失败')
|
|
|
|
|
importLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleImportExceed = () => {
|
|
|
|
|
message.error('只能上传一个文件')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const importTemplate = async () => {
|
|
|
|
|
const res = await ProductApi.importProductTemplate()
|
|
|
|
|
download.excel(res, '产品导入模板.xls')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 初始化 **/
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
queryParams.categoryId = 2
|
|
|
|
|
|