feat: 增加批量作废接口查询

This commit is contained in:
zhangds 2023-06-15 09:44:08 +08:00
parent 2d841bf21f
commit 54735790a8
5 changed files with 199 additions and 111 deletions

View File

@ -981,4 +981,15 @@ export const dingTaskQuery = (id) => {
export const searchPendingOrderByObject = (data) => {
return req("get", baseurl + "/order/searchPendingOrderByObject", data);
};
// 批量作废--文件上传
export const searchPendingOrderByHash = (data) => {
return req("post", baseurl + "/order/searchPendingOrderByHash", data);
};
// 批量作废--列表check
export const searchPendingOrderByKeys = (data) => {
return req("post", baseurl + "/order/searchPendingOrderByKeys", data);
};
export { req };

View File

@ -6,16 +6,16 @@ import "./style.less";
const columns = [
{
title: "行号",
name: "id"
name: "id",
},
{
title: "key",
name: "key"
name: "key",
},
{
title: "错误原因",
name: "msg"
}
name: "msg",
},
];
const UseUploadExcel = (props) => {
@ -78,7 +78,7 @@ const UseUploadExcel = (props) => {
return {
key: item.key,
id: index + 1,
msg: erObj(item.msg)
msg: erObj(item.msg),
};
});
setTableData(errArr);
@ -176,23 +176,23 @@ const UseUploadExcel = (props) => {
const uploadTop = () => {
return (
<div>
<div className='step-bar'>
<div className='step-group'>
<div className='step-code active'>1</div>
<span className='step-label active'>上传文件</span>
<div className="step-bar">
<div className="step-group">
<div className="step-code active">1</div>
<span className="step-label active">上传文件</span>
</div>
<div className='step-center'>
<div className='step-line'></div>
<div className="step-center">
<div className="step-line"></div>
</div>
<div className='step-group'>
<div className='step-code'>2</div>
<span className='step-label'>导入完成</span>
<div className="step-group">
<div className="step-code">2</div>
<span className="step-label">导入完成</span>
</div>
</div>
<div className='upload-panel1'>
<div className='upload-label'>直接上传</div>
<div className='upload-info'>
<div className="upload-panel1">
<div className="upload-label">直接上传</div>
<div className="upload-info">
<div> - 支持文件类型xlsxlsxcsv</div>
<div>
- 支持所有基础字段的导入一次至多导入 100
@ -210,12 +210,12 @@ const UseUploadExcel = (props) => {
*/
const uploadExcel = () => {
return (
<div className='upload-excel-01'>
<div className="upload-excel-01">
<input
ref={uploadInputRef}
type='file'
accept='.xls,.xlsx,.csv'
className='upload-input'
type="file"
accept=".xls,.xlsx,.csv"
className="upload-input"
onClick={(e) => (e.target.value = "")}
onChange={(e) => fileChange(e)}
/>
@ -223,8 +223,9 @@ const UseUploadExcel = (props) => {
style={{
background: "#1890ff",
color: "#FFFFFF",
border: "none"
}}>
border: "none",
}}
>
上传文件
</Button>
</div>
@ -237,16 +238,16 @@ const UseUploadExcel = (props) => {
*/
const tipSuccess = () => {
return (
<div className='upload-success'>
<Icon type='check-circle' className='success-icon' />
<div className="upload-success">
<Icon type="check-circle" className="success-icon" />
<span>文件解析成功 点击 "确定导入" 即可导入</span>
</div>
);
};
const tipErr = () => {
return (
<div className='upload-error'>
<Icon type='error-circle' className='error-icon' />
<div className="upload-error">
<Icon type="error-circle" className="error-icon" />
<span>文件解析失败, 请查看导入规则并更新文件</span>
</div>
);
@ -258,21 +259,21 @@ const UseUploadExcel = (props) => {
*/
const upFilesExcel = () => {
return (
<div className='up-files-excel'>
<div className='user-file-box'>
<p className='user-file-name'>
<Icon type='text-guide-o' />
<div className="up-files-excel">
<div className="user-file-box">
<p className="user-file-name">
<Icon type="text-guide-o" />
{filesName}
</p>
<div className='file-update-box'>
<div className="file-update-box">
<input
type='file'
accept='.xls,.xlsx,.csv'
className='upload-input1'
type="file"
accept=".xls,.xlsx,.csv"
className="upload-input1"
onClick={(e) => (e.target.value = "")}
onChange={(e) => fileChange(e)}
/>
<Icon type='up-circle-o' />
<Icon type="up-circle-o" />
<span>更新文件</span>
</div>
</div>
@ -297,26 +298,27 @@ const UseUploadExcel = (props) => {
*/
const uploadFooter = () => {
return (
<div className='upload-panel1'>
<div className='upload-label'>下载模板并填写后上传</div>
<div className='upload-info'>
<div className="upload-panel1">
<div className="upload-label">下载模板并填写后上传</div>
<div className="upload-info">
<div>
请先下载数字世界营销管理系统_keys_模板并按照模板填写后再上传
</div>
</div>
<Button
type='default'
className='btn-upload1'
onClick={() => downloadMBExcel()}>
type="default"
className="btn-upload1"
onClick={() => downloadMBExcel()}
>
下载模板
</Button>
<div className='btn-group'>
<Button type='default' onClick={() => bachOnClose()}>
<div className="btn-group">
<Button type="default" onClick={() => bachOnClose()}>
取消
</Button>
<Button
type='primary'
type="primary"
disabled={disabledSureBtn}
onClick={(e) => {
importBtn(e);
@ -324,8 +326,9 @@ const UseUploadExcel = (props) => {
style={{
background: "#1890ff",
color: "#FFFFFF",
border: "none"
}}>
border: "none",
}}
>
确定导入
</Button>
</div>
@ -352,42 +355,44 @@ const UseUploadExcel = (props) => {
const partSuccess = () => {
return (
<div>
<div className='file-upload-tip'>
<div className="file-upload-tip">
文件上传成功. {totalData} 条key码,其中 {totalData - errCoun}
条可成功导入
</div>
<div className='file-errmsg1'>
<div className="file-errmsg1">
发现以下 {errCoun} 条不符合要求,将不会被导入
</div>
<div className='gridpanel1'>
<div className="gridpanel1">
<Grid
columns={columns}
datasets={tableData}
scroll={{ y: 250 }}
size='large'
size="large"
/>
</div>
<div className='foot-bar'>
<div className='btn-group'>
<div className="foot-bar">
<div className="btn-group">
<Button
type='default'
type="default"
onClick={(e) => {
resetUpload();
}}>
}}
>
重新上传
</Button>
<Button
type='primary'
type="primary"
onClick={(e) => {
importBtn(e);
}}
style={{
background: "#1890ff",
color: "#FFFFFF",
border: "none"
}}>
border: "none",
}}
>
确定导入
</Button>
</div>
@ -400,14 +405,14 @@ const UseUploadExcel = (props) => {
<div>
{visible ? (
<div>
<div className='modal'></div>
<div className='import-excel' style={{ height: "auto" }}>
<BlockLoading loading={loading} iconText='解析中...' icon='circle'>
<div className='import-header'>
<div className='import-title'>{title}</div>
<div className="modal"></div>
<div className="import-excel" style={{ height: "auto" }}>
<BlockLoading loading={loading} iconText="解析中..." icon="circle">
<div className="import-header">
<div className="import-title">{title}</div>
<Icon
type='close'
className='import-close'
type="close"
className="import-close"
onClick={() => bachOnClose()}
/>
</div>

View File

@ -271,25 +271,34 @@ const UseKeyList = () => {
return item.key;
});
let formdata = {
keys: keys,
};
keyBatchCancel(formdata).then((res) => {
handelResponse(
res,
(req, msg) => {
Notify.success("批量作废成功");
clearSelectTableBtn();
setState({
multipleDisabledBtn: true,
isQuery: !state.isQuery,
let param = { keys: keys };
try {
commonSearchOrder(param, 2).then((res) => {
if (res === 1 || res === 2) {
let formdata = {
keys: keys,
};
keyBatchCancel(formdata).then((res) => {
handelResponse(
res,
(req, msg) => {
Notify.success("批量作废成功");
clearSelectTableBtn();
setState({
multipleDisabledBtn: true,
isQuery: !state.isQuery,
});
},
(err) => {
Notify.error(err);
}
);
});
},
(err) => {
Notify.error(err);
}
);
});
});
} catch (err) {
console.log("pages/plan/keyList/index.jsx =>", err);
}
};
/**
@ -602,7 +611,7 @@ const UseKeyList = () => {
onClick={() => multipleCancel()}
disabled={state.multipleDisabledBtn}
>
批量作废
批量作废2
</Button>
<Button
onClick={() => multipleUse()}

View File

@ -0,0 +1,53 @@
import {
searchPendingOrderByObject,
searchPendingOrderByHash,
} from "@/assets/api.js";
import { Sweetalert } from "zent";
// === 公用接口函数 ===
/**
*
* @param {
* type值: 1key批次 2兑换码批次 3优惠券批次 4key码
* object_value:兑换id
* } data
* @param {0批量作废--文件上传, 1批量作废--列表选中 2普通查询(默认)} apiType
* @returns 0用户取消作废1订单下面没有待领取订单直接作废 2订单下面有待领取订单弹窗告知用户是否继续
*/
const commonSearchOrder = (data, apiType = 2) => {
return new Promise(async (res, rej) => {
let res = null;
if (apiType === 1) {
}
searchPendingOrderByObject(data).then((searchRes) => {
console.log("searchRes =>", searchRes);
if (searchRes.code === 200) {
if (searchRes.data.have === true) {
Sweetalert.confirm({
type: "warning",
closeBtn: true,
title: "确认操作",
content: (
<p>该key批次(key兑换码)下面有待领取订单是否继续作废 </p>
),
onConfirm() {
res(2);
},
onCancel() {
res(0);
},
className: "questModal",
parentComponent: this,
});
} else {
res(1);
}
} else {
rej(searchRes);
}
});
});
};
export { commonSearchOrder };

View File

@ -1,4 +1,8 @@
import { searchPendingOrderByObject } from "@/assets/api.js";
import {
searchPendingOrderByObject,
searchPendingOrderByHash,
searchPendingOrderByKeys,
} from "@/assets/api.js";
import { Sweetalert } from "zent";
// === 公用接口函数 ===
@ -8,37 +12,43 @@ import { Sweetalert } from "zent";
* type值: 1key批次 2兑换码批次 3优惠券批次 4key码
* object_value:兑换id
* } data
* @param {1批量作废--文件上传, 2批量作废--列表选中 3普通查询(默认)} apiType
* @returns 0用户取消作废1订单下面没有待领取订单直接作废 2订单下面有待领取订单弹窗告知用户是否继续
*/
const commonSearchOrder = (data) => {
return new Promise((res, rej) => {
searchPendingOrderByObject(data).then((searchRes) => {
console.log("searchRes =>", searchRes);
if (searchRes.code === 200) {
if (searchRes.data.have === true) {
Sweetalert.confirm({
type: "warning",
closeBtn: true,
title: "确认操作",
content: (
<p>该key批次(key兑换码)下面有待领取订单是否继续作废 </p>
),
onConfirm() {
res(2);
},
onCancel() {
res(0);
},
className: "questModal",
parentComponent: this,
});
} else {
res(1);
}
const commonSearchOrder = (data, apiType = 3) => {
return new Promise(async (res, rej) => {
let searchRes = null;
if (apiType === 1) {
searchRes = await searchPendingOrderByHash(data);
} else if (apiType === 2) {
searchRes = await searchPendingOrderByKeys(data);
} else {
searchRes = await searchPendingOrderByObject(data);
}
if (searchRes.code === 200) {
if (searchRes.data.have === true) {
Sweetalert.confirm({
type: "warning",
closeBtn: true,
title: "确认操作",
content: (
<p>该key批次(key兑换码)下面有待领取订单是否继续作废 </p>
),
onConfirm() {
res(2);
},
onCancel() {
res(0);
},
className: "questModal",
parentComponent: this,
});
} else {
rej(searchRes);
res(1);
}
});
} else {
rej(searchRes);
}
});
};