feat: 新增卡密商品可选择发放方式

This commit is contained in:
wangsongsole 2023-08-18 09:07:21 +08:00
parent e013f5f131
commit 4f61181409
4 changed files with 63 additions and 18 deletions

View File

@ -997,4 +997,9 @@ export const keyBatchExport = (data) => {
return derives("post", baseurl + "/keybatch/export", data)
}
/* 发送短信 */
export const resendCardCode = (data) => {
return req("post", baseurl + "/order/resendCardCode", data)
}
export { req }

View File

@ -25,7 +25,7 @@ const initArray = (targetNum) => {
//
const formRules = {
product: [{ type: "required", message: "请选择映射商品" }],
product_id: [{ type: "required", message: "请选择映射商品" }],
quantity: [
{ type: "required", message: "请输入商品库存" },
{
@ -52,7 +52,8 @@ const formRules = {
reg: "^([0-9]{0,2}|100)$"
}
],
end_time: [{ type: "required", message: "请选择兑换结束时间" }]
end_time: [{ type: "required", message: "请选择兑换结束时间" }],
card_show: [{ type: "required", message: "请选择卡密发放类型" }]
}
const UseProductPop = forwardRef((props, ref) => {
@ -74,7 +75,7 @@ const UseProductPop = forwardRef((props, ref) => {
loading: true
})
const [model, setModel] = useSetState({
cur_product: {},
cur_product: undefined,
code_batch_id: "",
product_type: Number(productType),
cost_price: "",
@ -89,7 +90,8 @@ const UseProductPop = forwardRef((props, ref) => {
product_id: "",
account_type: "",
map_product_name: "",
end_time: ""
end_time: "",
card_show: 2
})
useEffect(() => {
@ -186,6 +188,7 @@ const UseProductPop = forwardRef((props, ref) => {
account_type: productData.account_type,
map_product_name: productData.map_product_name,
product_type: model.product_type,
card_show: Number(productData.card_show),
code_batch_id: productData.code_batch_id,
end_time: productData.end_time,
show_url: [
@ -225,7 +228,7 @@ const UseProductPop = forwardRef((props, ref) => {
const clearForm = () => {
setModel({
cur_product: {},
cur_product: undefined,
code_batch_id: "",
cost_price: "",
weight: "0",
@ -240,7 +243,8 @@ const UseProductPop = forwardRef((props, ref) => {
detail_url: [],
account_type: "",
map_product_name: "",
end_time: ""
end_time: "",
card_show: 2
})
setTimeout(() => {
setState({ isUpdatePic: !state.isUpdatePic })
@ -263,7 +267,8 @@ const UseProductPop = forwardRef((props, ref) => {
account_type: model.account_type,
map_product_name: model.product_name,
goods_id: model.goods_id,
end_time: model.end_time
end_time: model.end_time,
card_show: model.card_show
}
}
@ -290,19 +295,17 @@ const UseProductPop = forwardRef((props, ref) => {
setModel({ cur_product: e })
//
let cur_product = state.productDataAll.find((item) => {
return item.id === e.key
})
let cur_product = e ? state.productDataAll.find((item) => item.id === e.key) : {}
// logo
let picItem = window.goods.find((item) => {
return Number(item.id) === Number(cur_product.product_category_id)
})
setModel({
product_id: cur_product.id,
official_price: cur_product.official_price,
cost_price: cur_product.cost_price,
product_name: cur_product.title,
account_type: cur_product.account_type,
product_id: cur_product.id || "",
official_price: cur_product.official_price || "",
cost_price: cur_product.cost_price || "",
product_name: cur_product.title || "",
account_type: cur_product.account_type || "",
quantity: "",
contract_price: ""
})
@ -346,6 +349,7 @@ const UseProductPop = forwardRef((props, ref) => {
clearForm()
setModel({ product_type: e.target.value })
}
const onUploadError = (type, data) => {
if (type === "overMaxAmount") {
Notify.error(`最多可上传 ${data.maxAmount} 张图片`)
@ -507,7 +511,22 @@ const UseProductPop = forwardRef((props, ref) => {
<RadioButton value={2}>卡密</RadioButton>
</RadioGroup>
</FormItem>
<FormItem labelname="映射商品" prop="product" id="product">
{model.product_type === 2 ? (
<FormItem labelname="发放类型" prop="card_show" id="type">
<RadioGroup
onChange={(e) => {
setModel({ card_show: e.target.value })
}}
value={model.card_show}
disabled={!!model.code_batch_id}
>
<RadioButton value={2}>平台查看</RadioButton>
<RadioButton value={1}>短信下发</RadioButton>
</RadioGroup>
</FormItem>
) : null}
<FormItem labelname="映射商品" prop="product_id" id="product">
<Select
clearable
width={520}

View File

@ -19,7 +19,8 @@ import {
putOrderSuccess,
putOrderCancel,
refund,
handlerRefund
handlerRefund,
resendCardCode
} from "@/assets/api.js"
var moment = require("moment")
let day = moment(nowDay()).format("YYYY-MM-DD")
@ -493,6 +494,18 @@ export default class orderList extends React.Component {
}
}
/* 发送短信 */
sendSms({ order_number }) {
resendCardCode({ order_number }).then(({ code, message }) => {
Notify.clear()
if (code === 200) {
Notify.success(message)
} else {
Notify.error(message)
}
})
}
// 监听组件内部状态的变化:
componentDidUpdate(prevProps, prevState) {
// 参数分别为改变之前的数据状态对象
@ -759,6 +772,14 @@ export default class orderList extends React.Component {
</span>
</>
) : null}
{rowData.type == 1 &&
rowData.product_type == 2 &&
rowData.product.card_show == 1 &&
rowData.status == 2 && (
<span className="grid-link" onClick={(e) => this.sendSms(rowData)}>
发送卡密短信
</span>
)}
</div>
)
}

View File

@ -81,7 +81,7 @@ export const Column = [
prop: "opearo",
name: "opearo",
type: "slot",
width: "160px"
width: "220px"
},
{
title: "批次号",