From a25e842c0347943e6344863cfa435c9d2f2fead0 Mon Sep 17 00:00:00 2001 From: zhangds Date: Thu, 15 Jun 2023 17:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=20fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E5=BC=B9=E7=AA=97=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/coupon/list/index.jsx | 78 +++++++------- src/pages/exchangecode/list/list.js | 80 +++++++------- src/pages/plan/key/detail/list.js | 63 +++++++---- src/pages/plan/key/list.js | 54 +++++----- src/pages/plan/keyList/index.jsx | 156 ++++++++++++++++++---------- 5 files changed, 260 insertions(+), 171 deletions(-) diff --git a/src/pages/coupon/list/index.jsx b/src/pages/coupon/list/index.jsx index de2532ec..fd983a87 100644 --- a/src/pages/coupon/list/index.jsx +++ b/src/pages/coupon/list/index.jsx @@ -310,6 +310,24 @@ const UseCouponList = () => { history.push("/home/coupon-add-edit"); }; + const delCouponFun = (id) => { + delCoupon(id) + .then((res) => { + handelResponse( + res, + (response, msg) => { + Notify.clear(); + Notify.success(msg); + setState({ isQuery: !state.isQuery }); + }, + (err) => { + Notify.error(err); + } + ); + }) + .catch((err) => {}); + }; + // 作废 const delFn = (e, row) => { console.log("row =>", row); @@ -317,44 +335,32 @@ const UseCouponList = () => { Notify.error("审核中的数据不允许作废"); return; } - Sweetalert.confirm({ - type: "warning", - closeBtn: true, - title: "确认操作", - content:

确定作废{row.title}?

, - onConfirm() { - let param = { - type: 3, - object_value: row.id, - }; - try { - commonSearchOrder(param).then((res) => { - if (res === 1 || res === 2) { - delCoupon(row.id) - .then((res) => { - handelResponse( - res, - (response, msg) => { - Notify.clear(); - Notify.success(msg); - setState({ isQuery: !state.isQuery }); - }, - (err) => { - Notify.error(err); - } - ); - }) - .catch((err) => {}); - } + let param = { + type: 3, + object_value: row.id, + }; + try { + commonSearchOrder(param).then((res) => { + if (res === 2) { + delCouponFun(row.id); + } else if (res === 1) { + Sweetalert.confirm({ + type: "warning", + closeBtn: true, + title: "确认操作", + content:

确定作废{row.title}?

, + onConfirm() { + delCouponFun(row.id); + }, + onCancel() {}, + className: "questModal", + parentComponent: this, }); - } catch (err) { - console.log("pages/coupon/list/index.jsx =>", err); } - }, - onCancel() {}, - className: "questModal", - parentComponent: this, - }); + }); + } catch (err) { + console.log("pages/coupon/list/index.jsx =>", err); + } }; // 删除 diff --git a/src/pages/exchangecode/list/list.js b/src/pages/exchangecode/list/list.js index a239b876..6b56ada8 100644 --- a/src/pages/exchangecode/list/list.js +++ b/src/pages/exchangecode/list/list.js @@ -218,6 +218,26 @@ export default class acclist extends React.Component { }); } + // 作废接口 + delCodeFun(id) { + let self = this; + delCode(id) + .then((res) => { + handelResponse( + res, + (response, msg) => { + Notify.clear(); + Notify.success(msg); + self.getCodeListFn(); + }, + (err) => { + Notify.error(err); + } + ); + }) + .catch((err) => {}); + } + //作废 delFn(e, row) { if (row.status == 6) { @@ -225,44 +245,32 @@ export default class acclist extends React.Component { return; } let self = this; - Sweetalert.confirm({ - type: "warning", - closeBtn: true, - title: "确认操作", - content:

确定作废{row.title}?

, - onConfirm() { - let param = { - type: 2, - object_value: row.id, - }; - try { - commonSearchOrder(param).then((res) => { - if (res === 1 || res === 2) { - delCode(row.id) - .then((res) => { - handelResponse( - res, - (response, msg) => { - Notify.clear(); - Notify.success(msg); - self.getCodeListFn(); - }, - (err) => { - Notify.error(err); - } - ); - }) - .catch((err) => {}); - } + let param = { + type: 2, + object_value: row.id, + }; + try { + commonSearchOrder(param).then((res) => { + if (res === 2) { + self.delCodeFun(row.id); + } else if (res === 1) { + Sweetalert.confirm({ + type: "warning", + closeBtn: true, + title: "确认操作", + content:

确定作废{row.title}?

, + onConfirm() { + self.delCodeFun(row.id); + }, + onCancel() {}, + className: "questModal", + parentComponent: this, }); - } catch (err) { - console.log("exchangecode/list =>", err); } - }, - onCancel() {}, - className: "questModal", - parentComponent: this, - }); + }); + } catch (err) { + console.log("exchangecode/list =>", err); + } } //点击启用/禁用 diff --git a/src/pages/plan/key/detail/list.js b/src/pages/plan/key/detail/list.js index a3ced856..e8d78e95 100644 --- a/src/pages/plan/key/detail/list.js +++ b/src/pages/plan/key/detail/list.js @@ -16,6 +16,7 @@ import { MenuItem, DropdownContent, Menu, + Sweetalert, } from "zent"; import Ipt from "@/components/input/main"; import Grid from "@/components/gird/main.js"; @@ -242,12 +243,34 @@ export default class acclist extends React.Component { }; this.getKeyCodeList(params); } + keyCancelFun(rowData) { + let formdata = { + key: rowData.key, + }; + keyCancel(formdata).then((res) => { + handelResponse( + res, + (req, msg) => { + let data = { + page: 1, + limit: 10, + }; + this.setState({ page: 1, limit: 10 }); + this.getKeyCodeList(data); + Notify.success("作废成功"); + }, + (err) => { + Notify.error(err); + } + ); + }); + } menuItemClick(e, key, rowData) { + let self = this; if (key == 1) { let formdata = { key: rowData.key, }; - keyUsage(formdata).then((res) => { handelResponse( res, @@ -273,26 +296,24 @@ export default class acclist extends React.Component { }; try { commonSearchOrder(param).then((res) => { - if (res === 1 || res === 2) { - let formdata = { - key: rowData.key, - }; - keyCancel(formdata).then((res) => { - handelResponse( - res, - (req, msg) => { - let data = { - page: 1, - limit: 10, - }; - this.setState({ page: 1, limit: 10 }); - this.getKeyCodeList(data); - Notify.success("作废成功"); - }, - (err) => { - Notify.error(err); - } - ); + if (res === 2) { + self.keyCancelFun(rowData); + } else if (res === 1) { + Sweetalert.confirm({ + type: "warning", + closeBtn: true, + title: "确认操作", + content: ( +

+ 是否作废key批次ID[{rowData.key}]? +

+ ), + onConfirm: () => { + self.keyCancelFun(rowData); + }, + onCancel: this.onCancel, + className: "questModal", + parentComponent: this, }); } }); diff --git a/src/pages/plan/key/list.js b/src/pages/plan/key/list.js index 1e23444f..bb022164 100644 --- a/src/pages/plan/key/list.js +++ b/src/pages/plan/key/list.js @@ -640,35 +640,37 @@ export default class acclist extends React.Component { return; } - Sweetalert.confirm({ - type: "warning", - closeBtn: true, - title: "确认操作", - content: ( -

- 是否作废key批次ID[{row.id}]? -

- ), - onConfirm: () => { - // 查询作废 - let param = { - type: 1, - object_value: row.id, - }; - try { - commonSearchOrder(param).then((res) => { - if (res === 1 || res === 2) { + // 查询作废 + let param = { + type: 1, + object_value: row.id, + }; + try { + commonSearchOrder(param).then((res) => { + if (res === 2) { + self.cancelKeyFn(row); + } else if (res === 1) { + Sweetalert.confirm({ + type: "warning", + closeBtn: true, + title: "确认操作", + content: ( +

+ 是否作废key批次ID[{row.id}]? +

+ ), + onConfirm: () => { self.cancelKeyFn(row); - } + }, + onCancel: this.onCancel, + className: "questModal", + parentComponent: this, }); - } catch (err) { - console.log("pages/plan/key/list.js =>", err); } - }, - onCancel: this.onCancel, - className: "questModal", - parentComponent: this, - }); + }); + } catch (err) { + console.log("pages/plan/key/list.js =>", err); + } } } //limit diff --git a/src/pages/plan/keyList/index.jsx b/src/pages/plan/keyList/index.jsx index e0c08455..2a5cbdad 100644 --- a/src/pages/plan/keyList/index.jsx +++ b/src/pages/plan/keyList/index.jsx @@ -18,6 +18,7 @@ import { MenuItem, DropdownContent, Menu, + Sweetalert, } from "zent"; import { keyCancel, @@ -263,6 +264,28 @@ const UseKeyList = () => { setState({ selectTable: [] }); }; + const keyBatchCancelFun = (keys) => { + 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); + } + ); + }); + }; + /** * 作废 */ @@ -274,25 +297,20 @@ const UseKeyList = () => { 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); - } - ); + if (res === 2) { + keyBatchCancelFun(keys); + } else if (res === 1) { + Sweetalert.confirm({ + type: "warning", + closeBtn: true, + title: "确认操作", + content:

确定批量作废?

, + onConfirm() { + keyBatchCancelFun(keys); + }, + onCancel() {}, + className: "questModal", + parentComponent: this, }); } }); @@ -429,6 +447,24 @@ const UseKeyList = () => { }); }; + const keyCancelFun = (rowData) => { + let formdata = { + key: rowData.key, + }; + keyCancel(formdata).then((res) => { + handelResponse( + res, + (req, msg) => { + setState({ page: 1, limit: 10, isQuery: !state.isQuery }); + Notify.success("作废成功"); + }, + (err) => { + Notify.error(err); + } + ); + }); + }; + const menuItemClick = (e, key, rowData) => { if (Number(key) === 1) { let formdata = { @@ -455,21 +491,20 @@ const UseKeyList = () => { }; try { commonSearchOrder(param).then((res) => { - if (res === 1 || res === 2) { - let formdata = { - key: rowData.key, - }; - keyCancel(formdata).then((res) => { - handelResponse( - res, - (req, msg) => { - setState({ page: 1, limit: 10, isQuery: !state.isQuery }); - Notify.success("作废成功"); - }, - (err) => { - Notify.error(err); - } - ); + if (res === 2) { + keyCancelFun(rowData); + } else if (res === 1) { + Sweetalert.confirm({ + type: "warning", + closeBtn: true, + title: "确认操作", + content:

确定作废{rowData.title}?

, + onConfirm() { + keyCancelFun(rowData); + }, + onCancel() {}, + className: "questModal", + parentComponent: this, }); } }); @@ -525,6 +560,27 @@ const UseKeyList = () => { setState({ bachVisible: false }); }; + const batchUploadVoidFun = (hash) => { + batchUploadVoid({ hash: hash }).then((res) => { + handelResponse( + res, + (req, msg) => { + Notify.success("批量上传标记为作废"); + key_query_el.current.clearData(); // 重置 + setState({ + page: 1, + limit: 10, + hash: hash, + isQuery: !state.isQuery, + }); + }, + (err) => { + Notify.error(err); + } + ); + }); + }; + const bachImportBtn = (data) => { // 批量上传查询 if (state.bachApiType === 1) { @@ -535,24 +591,20 @@ const UseKeyList = () => { // 批量上传作废 if (state.bachApiType === 2) { commonSearchOrder({ hash: data }, 1).then((res) => { - if (res === 1 || res === 2) { - batchUploadVoid({ hash: data }).then((res) => { - handelResponse( - res, - (req, msg) => { - Notify.success("批量上传标记为作废"); - key_query_el.current.clearData(); // 重置 - setState({ - page: 1, - limit: 10, - hash: data, - isQuery: !state.isQuery, - }); - }, - (err) => { - Notify.error(err); - } - ); + if (res === 2) { + batchUploadVoidFun(data); + } else if (res === 1) { + Sweetalert.confirm({ + type: "warning", + closeBtn: true, + title: "确认操作", + content:

确定要批量作废?

, + onConfirm() { + batchUploadVoidFun(data); + }, + onCancel() {}, + className: "questModal", + parentComponent: this, }); } });