Skip to content

Commit

Permalink
Synchronize modification of front-end content
Browse files Browse the repository at this point in the history
  • Loading branch information
Jzow committed Aug 15, 2024
1 parent 6633ac8 commit f7dffd1
Show file tree
Hide file tree
Showing 21 changed files with 320 additions and 194 deletions.
20 changes: 16 additions & 4 deletions web/src/api/product/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
QueryProductReq,
UpdateBatchProductInfoReq,
ProductExtendPriceResp,
QueryProductExtendPriceReq, ProductStockSkuReq, ProductStockSkuResp,
QueryProductExtendPriceReq, ProductStockSkuResp,
} from "@/api/product/model/productModel";
import {ErrorMessageMode, SuccessMessageMode} from "#/axios";

Expand All @@ -20,7 +20,8 @@ enum Api {
updateBatchProductInfo = '/product/updateBatchProductInfo',
getProductSku = '/product/sku/pageList',
getProductSkuByBarCode = '/product/sku/getProduct',
getProductListInfo = '/product/sku/productStockSku'
getProductListInfo = '/product/sku/productStockSku',
exportProductData = '/product/export'
}

export function getProductCode() {
Expand Down Expand Up @@ -115,11 +116,22 @@ export function getProductSkuByBarCode(barCode: number | string, warehouseId: nu
);
}

export function getProductStockSku(params: ProductStockSkuReq) {
export function getProductStockSku() {
return defHttp.post<BaseDataResp<ProductStockSkuResp[]>>(
{
url: Api.getProductListInfo,
params
timeout: 100000,
}
);
}

export function exportProduct(params: QueryProductReq) {
return defHttp.get<BaseDataResp<Blob>>(
{
url: `${Api.exportProductData}`,
params,
responseType: "blob",
timeout: 100000, // 设置超时时间为100秒
}
);
}
156 changes: 82 additions & 74 deletions web/src/components/Tools/ImportFileModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
:title="title"
:width="500"
:confirm-loading="confirmLoading"
:maskStyle="{'top':'50px','left':'154px'}"
:maskStyle="{'top':'50px','left':'70px'}"
:maskClosable="false"
v-model:open="open"
@cancel="handleCancel"
:okText="t('product.info.import')"
@ok="uploadFile"
style="top:20%;height: 55%;">
<template slot="footer">
<a-button key="back" @click="handleCancel">取消</a-button>
</template>
<a-spin :spinning="confirmLoading">
<a-row class="form-row" :gutter="24">
<a-col :md="24" :sm="24">
Expand All @@ -24,22 +22,22 @@
<a-row class="form-row" :gutter="24">
<a-col :md="24" :sm="24">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="t('product.info.importInfo.setup2')">
<a-upload name="file" :showUploadList="false" :multiple="false" :customRequest="uploadFile">
<a-button type="primary">
<cloud-upload-outlined />
{{ t('product.info.import') }}
</a-button>
</a-upload>
</a-form-item>
<a-upload name="file" :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove" :multiple="false" :max-count="1">
<a-button type="primary">
<cloud-upload-outlined />
{{ t('product.info.selectFile') }}
</a-button>
</a-upload>
</a-form-item>
</a-col>
</a-row>
</a-spin>
</a-modal>
</div>
</a-modal>
</div>
</template>
<script lang="ts">
import {ref, h} from 'vue';
import {Modal, Upload, Button, Spin, Row, Col, FormItem, UploadFile} from "ant-design-vue";
import {Modal, Upload, Button, Spin, Row, Col, FormItem, UploadFile, UploadProps} from "ant-design-vue";
import { CloudUploadOutlined } from '@ant-design/icons-vue';
import type { UploadChangeParam } from 'ant-design-vue';
import {useMessage} from "@/hooks/web/useMessage";
Expand Down Expand Up @@ -79,6 +77,23 @@ export default {
const templateUrl = ref('');
const templateName = ref('');
const downloadUrl = ref('');
const fileList = ref<UploadProps['fileList']>([]);
const uploading = ref<boolean>(false);
const handleRemove: UploadProps['onRemove'] = file => {
const index = fileList.value.indexOf(file);
const newFileList = fileList.value.slice();
newFileList.splice(index, 1);
fileList.value = newFileList;
};
const beforeUpload: UploadProps['beforeUpload'] = file => {
// 清空fileList
fileList.value = []
fileList.value = [...(fileList.value || []), file];
return false;
};
const [registerTable, { reload }] = useTable()
function initModal(path:string, name:string) {
Expand All @@ -97,74 +112,64 @@ export default {
}
const productBarcodeExistModal = (message: string, info: UploadFile) => {
if (message === 'existDataBase') {
// 显示数据库已存在的提示
Modal.info({
title: t('product.info.checkBarCodeExist'),
icon: h(ExclamationCircleOutlined),
content: h('div', { style: 'color:red;' }, t('product.info.dataBaseExist')),
});
} else {
// 解析并显示错误信息
const messageList = JSON.parse(message);
// 解析并显示错误信息
const messageList = JSON.parse(message);
// 生成内容消息
const contentMessage = messageList.map((item: { productCode: string; productName: string[]; }) =>
h('div', [
h('div', {}, `${t('product.info.table.productName')}:`),
item.productName.map(name => h('div', { style: 'color:red;' }, name)), // 处理换行
h('div', {}, `${t('product.info.table.barCode')}:`),
h('p', { style: 'color:red;' }, item.productCode),
h('p'),
])
);
// 生成内容消息
const contentMessage = messageList.map((item: { productCode: string; productName: string[]; }) =>
h('div', [
h('div', {}, `${t('product.info.table.productName')}:`),
item.productName.map(name => h('div', { style: 'color:red;' }, name)), // 处理换行
h('div', {}, `${t('product.info.table.barCode')}:`),
h('p', { style: 'color:red;' }, item.productCode),
h('p'),
])
);
// 添加覆盖提示
contentMessage.push(
h('strong', { style: 'color:black;' }, t('product.info.dataCover'))
);
// 添加覆盖提示
contentMessage.push(
h('strong', { style: 'color:black;' }, t('product.info.dataCover'))
);
// 显示确认对话框
Modal.confirm({
title: t('product.info.checkBarCodeExist'),
icon: h(ExclamationCircleOutlined),
content: contentMessage,
okText: t('sys.modal.cover'),
cancelText: t('sys.modal.cancel'),
async onOk() {
const fileObject: UploadCoverProductParams = {
file: info,
type: 0,
};
try {
await productCoverUpload(fileObject);
} catch (error) {
createMessage.info(t('sys.api.refreshBrowser'));
handleCancel();
} finally {
handleCancel(); // 确保在异步操作完成后执行
}
},
onCancel() {
// 显示确认对话框
Modal.confirm({
title: t('product.info.checkBarCodeExist'),
icon: h(ExclamationCircleOutlined),
content: contentMessage,
okText: t('sys.modal.cover'),
cancelText: t('sys.modal.cancel'),
async onOk() {
const fileObject: UploadCoverProductParams = {
file: info,
type: 1,
};
try {
await productCoverUpload(fileObject);
} catch (error) {
createMessage.info(t('sys.api.refreshBrowser'));
handleCancel();
},
// 添加滚动条样式
bodyStyle: {
maxHeight: 'calc(100vh - 200px)',
overflowY: 'auto',
},
});
}
} finally {
handleCancel(); // 确保在异步操作完成后执行
}
},
onCancel() {
handleCancel();
},
// 添加滚动条样式
bodyStyle: {
maxHeight: 'calc(100vh - 200px)',
overflowY: 'auto',
},
});
};
async function uploadFile(info: UploadChangeParam) {
async function uploadFile() {
const fileObject: UploadFileParams = {
file: info.file,
file: fileList.value[0]
}
const result = await uploadXlsx(fileObject);
if (result.code === 'P0512') {
close();
productBarcodeExistModal(result.msg, info.file)
productBarcodeExistModal(result.msg, fileList.value[0])
} else {
handleCancel()
await reload();
Expand All @@ -187,8 +192,11 @@ export default {
open,
CloudUploadOutlined,
uploadFile,
handleRemove,
beforeUpload,
fileList,
registerTable,
};
},
};
</script>
</script>
2 changes: 2 additions & 0 deletions web/src/locales/lang/en/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default {
batchDelete: 'Batch Delete',
batchEnable: 'Batch Enable',
batchDisable: 'Batch Disable',
selectFile: 'Select File',
import: 'Import',
export: 'Export',
batchEdit: 'Batch Edit',
Expand All @@ -35,6 +36,7 @@ export default {
checkBarCodeExist: 'Import Data - Detect duplicate products',
dataBaseExist: 'There are duplicate product barcodes in the database, please check.',
dataCover: 'Do you need overwrite the existing data?',
exportData: 'Commodity Information Data ',
header: {
categoryName: 'Product category',
keyWord: 'Keyword',
Expand Down
6 changes: 3 additions & 3 deletions web/src/locales/lang/en/purchase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
scanCodeData: 'Scan code to enter data',
collapseScanCode: 'Collapse scan code',
scanCodeTip: 'Click here with the mouse',
addProduct: 'Select to return product',
addProduct: 'Select purchase products',
insertRow: 'Insert A Row',
deleteRow: 'Delete Selected Rows',
addRowData: 'Please add a row of data',
Expand Down Expand Up @@ -138,7 +138,7 @@ export default {
scanCodeData: 'Scan code to enter data',
collapseScanCode: 'Collapse scan code',
scanCodeTip: 'Click here with the mouse',
addProduct: 'Select to return product',
addProduct: 'Select purchase products',
insertRow: 'Insert A Row',
deleteRow: 'Delete Selected Rows',
addRowData: 'Please add a row of data',
Expand Down Expand Up @@ -246,7 +246,7 @@ export default {
scanCodeData: 'Scan code to enter data',
collapseScanCode: 'Collapse scan code',
scanCodeTip: 'Click here with the mouse',
addProduct: 'Select to return product',
addProduct: 'Select returned products',
insertRow: 'Insert A Row',
deleteRow: 'Delete Selected Rows',
addRowData: 'Please add a row of data',
Expand Down
4 changes: 2 additions & 2 deletions web/src/locales/lang/en/retail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
scanCodeData: 'Scan code to enter data',
collapseScanCode: 'Collapse scan code',
scanCodeTip: 'Click here with the mouse',
addProduct: 'Select to add product',
addProduct: 'Select retail products',
insertRow: 'Insert A Row',
deleteRow: 'Delete Selected Rows',
addRowData: 'Please add a row of data',
Expand Down Expand Up @@ -135,7 +135,7 @@ export default {
scanCodeData: 'Scan code to enter data',
collapseScanCode: 'Collapse scan code',
scanCodeTip: 'Click here with the mouse',
addProduct: 'Select to return product',
addProduct: 'Select returned products',
insertRow: 'Insert A Row',
deleteRow: 'Delete Selected Rows',
addRowData: 'Please add a row of data',
Expand Down
6 changes: 3 additions & 3 deletions web/src/locales/lang/en/sales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
scanCodeData: 'Scan code to enter data',
collapseScanCode: 'Collapse scan code',
scanCodeTip: 'Click here with the mouse',
addProduct: 'Select to return product',
addProduct: 'Select sales products',
insertRow: 'Insert A Row',
deleteRow: 'Delete Selected Rows',
addRowData: 'Please add a row of data',
Expand Down Expand Up @@ -137,7 +137,7 @@ export default {
scanCodeData: 'Scan code to enter data',
collapseScanCode: 'Collapse scan code',
scanCodeTip: 'Click here with the mouse',
addProduct: 'Select to shipments product',
addProduct: 'Select sales products',
insertRow: 'Insert A Row',
deleteRow: 'Delete Selected Rows',
addRowData: 'Please add a row of data',
Expand Down Expand Up @@ -245,7 +245,7 @@ export default {
scanCodeData: 'Scan code to enter data',
collapseScanCode: 'Collapse scan code',
scanCodeTip: 'Click here with the mouse',
addProduct: 'Select to Return product',
addProduct: 'Select returned products',
insertRow: 'Insert A Row',
deleteRow: 'Delete Selected Rows',
addRowData: 'Please add a row of data',
Expand Down
2 changes: 1 addition & 1 deletion web/src/locales/lang/en/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default {
confirmDelete: 'Are you sure to delete this data?',
confirmExport: 'Confirm Export',
confirmExportTextOne: 'Export',
confirmExportTextTwo: 'piece of data, please be patient.',
confirmExportTextTwo: 'Data loading, please be patient',
confirmExportTextThree: 'If you need to export detailed data (which may take a long time), please check the box below.',
confirmExportTextFour: 'Need to export detailed data',
type: 'Type',
Expand Down
2 changes: 2 additions & 0 deletions web/src/locales/lang/zh-CN/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default {
batchDelete: '批量删除',
batchEnable: '批量启用',
batchDisable: '批量禁用',
selectFile: '选择文件',
import: '导入',
export: '导出',
batchEdit: '批量编辑',
Expand All @@ -35,6 +36,7 @@ export default {
checkBarCodeExist: '导入数据-检测商品出现重复',
dataBaseExist: '数据库中存在重复的商品条码,请检查。',
dataCover: '是否需要覆盖现有数据?',
exportData: '商品信息数据 ',
header: {
categoryName: '商品类别',
keyWord: '关键词',
Expand Down
Loading

0 comments on commit f7dffd1

Please sign in to comment.