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) => { export const searchPendingOrderByObject = (data) => {
return req("get", baseurl + "/order/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 }; export { req };

View File

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

View File

@ -271,25 +271,34 @@ const UseKeyList = () => {
return item.key; return item.key;
}); });
let formdata = { let param = { keys: keys };
keys: keys, try {
}; commonSearchOrder(param, 2).then((res) => {
keyBatchCancel(formdata).then((res) => { if (res === 1 || res === 2) {
handelResponse( let formdata = {
res, keys: keys,
(req, msg) => { };
Notify.success("批量作废成功"); keyBatchCancel(formdata).then((res) => {
clearSelectTableBtn(); handelResponse(
setState({ res,
multipleDisabledBtn: true, (req, msg) => {
isQuery: !state.isQuery, 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()} onClick={() => multipleCancel()}
disabled={state.multipleDisabledBtn} disabled={state.multipleDisabledBtn}
> >
批量作废 批量作废2
</Button> </Button>
<Button <Button
onClick={() => multipleUse()} 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"; import { Sweetalert } from "zent";
// === 公用接口函数 === // === 公用接口函数 ===
@ -8,37 +12,43 @@ import { Sweetalert } from "zent";
* type值: 1key批次 2兑换码批次 3优惠券批次 4key码 * type值: 1key批次 2兑换码批次 3优惠券批次 4key码
* object_value:兑换id * object_value:兑换id
* } data * } data
* @param {1批量作废--文件上传, 2批量作废--列表选中 3普通查询(默认)} apiType
* @returns 0用户取消作废1订单下面没有待领取订单直接作废 2订单下面有待领取订单弹窗告知用户是否继续 * @returns 0用户取消作废1订单下面没有待领取订单直接作废 2订单下面有待领取订单弹窗告知用户是否继续
*/ */
const commonSearchOrder = (data) => { const commonSearchOrder = (data, apiType = 3) => {
return new Promise((res, rej) => { return new Promise(async (res, rej) => {
searchPendingOrderByObject(data).then((searchRes) => { let searchRes = null;
console.log("searchRes =>", searchRes); if (apiType === 1) {
if (searchRes.code === 200) { searchRes = await searchPendingOrderByHash(data);
if (searchRes.data.have === true) { } else if (apiType === 2) {
Sweetalert.confirm({ searchRes = await searchPendingOrderByKeys(data);
type: "warning", } else {
closeBtn: true, searchRes = await searchPendingOrderByObject(data);
title: "确认操作", }
content: ( if (searchRes.code === 200) {
<p>该key批次(key兑换码)下面有待领取订单是否继续作废 </p> if (searchRes.data.have === true) {
), Sweetalert.confirm({
onConfirm() { type: "warning",
res(2); closeBtn: true,
}, title: "确认操作",
onCancel() { content: (
res(0); <p>该key批次(key兑换码)下面有待领取订单是否继续作废 </p>
}, ),
className: "questModal", onConfirm() {
parentComponent: this, res(2);
}); },
} else { onCancel() {
res(1); res(0);
} },
className: "questModal",
parentComponent: this,
});
} else { } else {
rej(searchRes); res(1);
} }
}); } else {
rej(searchRes);
}
}); });
}; };