Merge branch 'couponV2.0' of https://codeup.aliyun.com/5f9118049cffa29cfdd3be1c/marketing/frontend into couponV2.0
This commit is contained in:
commit
aec6d19577
|
@ -89,13 +89,11 @@ export default class topNav extends React.Component {
|
|||
let breakflag =
|
||||
pathnamestr.includes("add") ||
|
||||
pathnamestr.includes("aid") ||
|
||||
// pathnamestr.includes("exchangecode-copyCode") ||
|
||||
pathnamestr.includes("exchangecode-exchangecodeAdd") ||
|
||||
pathnamestr.includes("distributor-edit") ||
|
||||
pathnamestr.includes("key-list") ||
|
||||
pathnamestr.includes("key-detail") ||
|
||||
pathnamestr.includes("key-edit") ||
|
||||
// pathnamestr.includes("exchangecode-edit") ||
|
||||
pathnamestr.includes("plan-edit") ||
|
||||
pathnamestr.includes("product-edit") ||
|
||||
pathnamestr.includes("coupon-commodity")
|
||||
|
@ -107,7 +105,6 @@ export default class topNav extends React.Component {
|
|||
pathnamestr.includes("role-add") ||
|
||||
pathnamestr.includes("distributor-add") ||
|
||||
pathnamestr.includes("subaccount-add") ||
|
||||
// pathnamestr.includes("exchangecode-edit") ||
|
||||
pathnamestr.includes("plan-edit") ||
|
||||
pathnamestr.includes("key-list") ||
|
||||
pathnamestr.includes("exchange-addcommodity")
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,39 +0,0 @@
|
|||
.addkey-btn-group {
|
||||
margin-left: 15px;
|
||||
margin-top: 15px;
|
||||
margin-bottom: 40px;
|
||||
|
||||
button {
|
||||
width: 100px;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-add {
|
||||
width: 50%;
|
||||
margin: 0 auto;
|
||||
height: 36px;
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
line-height: 36px;
|
||||
background-color: rgb(249, 250, 252);
|
||||
}
|
||||
|
||||
#addkey .zent-radio-button--disabled[data-zv="9.11.0"].zent-radio-button--checked {
|
||||
color: #8a96aa;
|
||||
background: #dfe8fc !important;
|
||||
border: 1px solid #8a96aa !important;
|
||||
}
|
||||
|
||||
.line-value {
|
||||
width: 508px;
|
||||
text-align: left;
|
||||
height: 36px;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.goods-boxs {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
export const Column2 = [
|
||||
{
|
||||
title: '商品ID',
|
||||
name: 'product_id',
|
||||
prop: 'product_id',
|
||||
width: 'auto',
|
||||
type: 'normal'
|
||||
},
|
||||
{
|
||||
title: '商品名称',
|
||||
width: 'auto',
|
||||
prop: 'product_name',
|
||||
name: 'product_name',
|
||||
type: 'normal'
|
||||
},
|
||||
{
|
||||
title: '立减金平台批次号',
|
||||
width: '250px',
|
||||
prop: 'channel_activity_id',
|
||||
name: 'channel_activity_id',
|
||||
type: 'normal'
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
width: 'auto',
|
||||
prop: 'type',
|
||||
name: 'type',
|
||||
type: 'slot'
|
||||
},
|
||||
{
|
||||
title: '上游平台',
|
||||
width: 'auto',
|
||||
prop: 'upstream',
|
||||
name: 'upstream',
|
||||
type: 'normal'
|
||||
},
|
||||
{
|
||||
title: '有效时间段',
|
||||
width: '575px',
|
||||
prop: 'effectDate',
|
||||
name: 'effectDate',
|
||||
type: 'normal'
|
||||
},
|
||||
{
|
||||
title: '当前成本价格',
|
||||
prop: 'cost_price',
|
||||
name: 'cost_price',
|
||||
width: '200px',
|
||||
type: 'slot'
|
||||
},
|
||||
{
|
||||
title: '合同价',
|
||||
name: 'contract_price',
|
||||
prop: 'contract_price',
|
||||
type: 'normal',
|
||||
width: 'auto'
|
||||
},
|
||||
{
|
||||
title: '商品官方价',
|
||||
type: 'normal',
|
||||
prop: 'official_price',
|
||||
width: 'auto'
|
||||
},
|
||||
{
|
||||
title: '库存',
|
||||
type: 'normal',
|
||||
prop: 'quantity',
|
||||
width: 'auto'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
prop: 'edit',
|
||||
name: 'edit',
|
||||
type: 'slot',
|
||||
width: 'auto'
|
||||
}
|
||||
]
|
||||
|
||||
export const Column = [
|
||||
{
|
||||
title: '兑换名称',
|
||||
name: 'title',
|
||||
prop: 'title',
|
||||
type: 'normal',
|
||||
width: 'auto'
|
||||
},
|
||||
{
|
||||
title: '兑换码范围',
|
||||
type: 'normal',
|
||||
prop: 'range',
|
||||
width: 'auto'
|
||||
},
|
||||
{
|
||||
title: '有效开始日期',
|
||||
prop: 'begin_time',
|
||||
name: 'begin_time',
|
||||
width: 'auto',
|
||||
type: 'normal'
|
||||
},
|
||||
{
|
||||
title: '有效结束日期',
|
||||
name: 'end_time',
|
||||
prop: 'end_time',
|
||||
type: 'normal',
|
||||
width: 'auto'
|
||||
},
|
||||
{
|
||||
title: '兑换码数量',
|
||||
name: 'quantity',
|
||||
type: 'normal',
|
||||
prop: 'quantity',
|
||||
defaultText: 'PM',
|
||||
width: 'auto'
|
||||
},
|
||||
{
|
||||
title: '绑定数',
|
||||
prop: 'restrict',
|
||||
name: 'restrict',
|
||||
type: 'slot',
|
||||
width: 'auto'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
prop: 'edit',
|
||||
name: 'edit',
|
||||
type: 'slot',
|
||||
width: 'auto'
|
||||
}
|
||||
]
|
||||
|
||||
export const rules = {
|
||||
bind_object: [{ type: 'required', message: '请选择绑定类型' }]
|
||||
}
|
||||
|
||||
//基本信息
|
||||
export const codeInfo = {
|
||||
code_name: [{ type: 'required', message: '请输入兑换码名称' }],
|
||||
issued: [
|
||||
{ type: 'required', message: '请输入发放总量' },
|
||||
{
|
||||
type: 'regExp',
|
||||
message: '请输入正整数',
|
||||
reg: '^([1-9][0-9]*){1,3}$'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
//基本规则
|
||||
export const rulesInfo = {
|
||||
date_time: [{ type: 'required', message: '请选择生效时间段' }],
|
||||
rank: [{ type: 'required', message: '请选择商品范围' }]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +0,0 @@
|
|||
.edit-btnList{
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
button{
|
||||
width: 100px;
|
||||
}
|
||||
.goods-boxs{
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
|
@ -127,134 +127,6 @@ export default class exchangeAdd extends React.Component {
|
|||
|
||||
/* 请求详情 */
|
||||
getDetailFunction() {
|
||||
// let approval_id = sessionStorage.getItem("approval_id")
|
||||
// let approval_status = sessionStorage.getItem("approval_status")
|
||||
/* 判断是否是在审批中、状态是否时编辑 */
|
||||
// if (false) {
|
||||
// //此处为审核中
|
||||
// getApprovalsInfo(approval_id)
|
||||
// .then((res) => {
|
||||
// handelResponse(
|
||||
// res,
|
||||
// (req, msg) => {
|
||||
// this.getResellerFunction(req.reseller_id)
|
||||
// req.update_product = [...this.transFormData1(req.update_product)]
|
||||
// req.new_product = [...this.transFormData1(req.new_product, true)]
|
||||
|
||||
// let codeInfo = {
|
||||
// code_name: req.title,
|
||||
// issued: req.quantity,
|
||||
// stock: req.stock,
|
||||
// describe: req.describe,
|
||||
// date_time: [req.begin_time, req.end_time],
|
||||
// range: req.update_product
|
||||
// }
|
||||
|
||||
// if (req.new_product.length > 0) {
|
||||
// req.new_product = _.map(req.new_product, (item) => {
|
||||
// item.checked = false
|
||||
// return item
|
||||
// })
|
||||
// codeInfo.range = codeInfo.range.concat(req.new_product)
|
||||
// }
|
||||
|
||||
// let new_ids = _.map(req.new_product, (o) => {
|
||||
// return o.only
|
||||
// })
|
||||
|
||||
// this.setState({ new_product: new_ids })
|
||||
// let delete_product = req.delete_product
|
||||
// let payment_direction = req.payment_direction
|
||||
// getCodesDetail(code_batch_id)
|
||||
// .then((res) => {
|
||||
// handelResponse(
|
||||
// res,
|
||||
// (req, msg) => {
|
||||
// codeInfo.stock = req.stock
|
||||
// this.setState({
|
||||
// plan_time: [req.plan.start_time, req.plan.end_time]
|
||||
// })
|
||||
// let reqCopy = _.cloneDeep(req)
|
||||
// const resData = this.transFormData(reqCopy)
|
||||
// this.setState({ oldTable: resData })
|
||||
// let deleteArr = []
|
||||
|
||||
// for (let i = 0; i < delete_product.length; i++) {
|
||||
// let deleteData = resData.find(
|
||||
// (o) => o.only == delete_product[i]
|
||||
// )
|
||||
// deleteData.checked = false
|
||||
// deleteArr.push(deleteData)
|
||||
// }
|
||||
// this.setState({ codeInfo: codeInfo })
|
||||
// this.setState({ isload: true })
|
||||
// codeInfo.range = codeInfo.range.concat(deleteArr)
|
||||
// let table = _.map(codeInfo.range, (res) => {
|
||||
// let obj = resData.find((o) => o.only == res.only)
|
||||
|
||||
// res.usage = obj ? obj.usage : 0
|
||||
// res.stock = obj ? obj.stock : res.quantity - res.usage
|
||||
// res.checked = res.hasOwnProperty("checked")
|
||||
// ? res.checked
|
||||
// : true
|
||||
// if (approval_status == 7 && obj) {
|
||||
// res.checked = true
|
||||
// }
|
||||
|
||||
// return res
|
||||
// })
|
||||
|
||||
// this.setState({ deleteProduct: [] })
|
||||
|
||||
// this.setState({ tempdata: codeInfo.range })
|
||||
|
||||
// let arr = []
|
||||
// let temp = []
|
||||
// _.map(codeInfo.range, (res) => {
|
||||
// let obj = {}
|
||||
// obj.key = res.only
|
||||
// obj.text = res.product_name
|
||||
// if (new_ids.indexOf(res.only) < 0) {
|
||||
// this.state.oldProduct.push(res.id)
|
||||
// }
|
||||
// if (
|
||||
// table.find((o) => o.only == res.only).checked == true
|
||||
// ) {
|
||||
// temp.push(obj)
|
||||
// }
|
||||
// arr.push(obj)
|
||||
// return obj
|
||||
// })
|
||||
|
||||
// this.setState({ rankoptions: arr })
|
||||
// this.setState({ rank: temp })
|
||||
|
||||
// if (payment_direction) {
|
||||
// let index =
|
||||
// this.state.payment_direction.indexOf(
|
||||
// payment_direction
|
||||
// )
|
||||
// this.setState({ payType: index + 1 })
|
||||
// }
|
||||
// sessionStorage.setItem(
|
||||
// "productData",
|
||||
// JSON.stringify(codeInfo.range)
|
||||
// )
|
||||
// sessionStorage.setItem(
|
||||
// "knockGoldData",
|
||||
// JSON.stringify(codeInfo.range)
|
||||
// )
|
||||
// },
|
||||
// (err) => {}
|
||||
// )
|
||||
// })
|
||||
// .catch((err) => {})
|
||||
// },
|
||||
// (err) => {}
|
||||
// )
|
||||
// })
|
||||
// .catch((err) => {})
|
||||
// } else {
|
||||
getCodesDetail(code_batch_id)
|
||||
.then((res) => {
|
||||
handelResponse(
|
||||
|
@ -438,60 +310,6 @@ export default class exchangeAdd extends React.Component {
|
|||
return newData
|
||||
}
|
||||
|
||||
/* 无审核转换数据 */
|
||||
// transFormData(reqCopy) {
|
||||
// const resData = []
|
||||
// reqCopy.goods.map((item) => {
|
||||
// /* type 1为商品 2为立减金 转译字符方便处理 */
|
||||
// /* 此处only 商品为product_id 立减金为channel_activity_id */
|
||||
// if (item.type === 1) {
|
||||
// item.entity.upstream = "直连天下"
|
||||
// item.entity.only = item.entity.product_id
|
||||
// item.entity.id = item.id
|
||||
// item.entity.type = item.type
|
||||
// item.entity.weight = item.weight
|
||||
// resData.push(item.entity)
|
||||
// } else if (item.type === 2) {
|
||||
// /* 复制状态下删除id */
|
||||
// if (this.state.isState === 1) delete item.entity.id
|
||||
// item.entity.weight = item.weight
|
||||
// resData.push({
|
||||
// origin: item.entity,
|
||||
// type: item.type,
|
||||
// product_id: item.entity.goods_id,
|
||||
// product_type_text: "立减金",
|
||||
// only: item.entity.channel_activity_id,
|
||||
// id: item.entity.goods_id,
|
||||
// upstream: String(item.entity.channel) === "1" ? "支付宝" : "微信",
|
||||
// code_batch_id: item.code_batch_id,
|
||||
// contract_price: item.entity.price,
|
||||
// create_time: item.create_time,
|
||||
// official_price: item.entity.reduce_amount,
|
||||
// channel_activity_id: item.entity.channel_activity_id,
|
||||
// product_name: item.entity.batch_goods_name,
|
||||
// quantity: item.entity.stock,
|
||||
// stock: parseInt(
|
||||
// divNum(item.entity.all_budget, item.entity.reduce_amount) -
|
||||
// divNum(item.entity.used_amount, item.entity.reduce_amount)
|
||||
// ),
|
||||
// usage: parseInt(
|
||||
// divNum(item.entity.all_budget, item.entity.reduce_amount) -
|
||||
// divNum(
|
||||
// item.entity.all_budget - item.entity.used_amount,
|
||||
// item.entity.reduce_amount
|
||||
// )
|
||||
// ),
|
||||
// effectDate:
|
||||
// item.entity.time_limit.effect_time.start_time +
|
||||
// " 至 " +
|
||||
// item.entity.time_limit.effect_time.end_time //有效时间
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
|
||||
// return resData
|
||||
// }
|
||||
|
||||
/* select事件 */
|
||||
onRankChange(e) {
|
||||
_.forEach(this.state.tempdata, (item) => {
|
||||
|
|
|
@ -1,701 +0,0 @@
|
|||
import ReactDOM from "react-dom"
|
||||
import React from "react"
|
||||
import "./add.less"
|
||||
import Ipt from "../../../components/input/main"
|
||||
import Form from "../../../components/form/main"
|
||||
import FormItem from "../../../components/form-item/main"
|
||||
import {
|
||||
Select,
|
||||
Button,
|
||||
ImageUpload,
|
||||
onUpload,
|
||||
Sweetalert,
|
||||
RadioButton,
|
||||
RadioGroup,
|
||||
Notify
|
||||
} from "zent"
|
||||
import Swiper from "swiper/dist/js/swiper.js"
|
||||
import "swiper/dist/css/swiper.min.css"
|
||||
import Bus from "../../../assets/eventBus.js"
|
||||
import {
|
||||
getProductInfoSelect,
|
||||
handelResponse,
|
||||
uploadImg
|
||||
} from "../../../assets/api.js"
|
||||
import _ from "lodash"
|
||||
|
||||
var mySwiper = null
|
||||
var timer = null
|
||||
export default class adduserinfo extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
model: {
|
||||
//数据模型不可少
|
||||
product_id: "",
|
||||
product_type: "1",
|
||||
contract_price: "",
|
||||
official_price: "",
|
||||
cost_price: "",
|
||||
quantity: "",
|
||||
product_name: "",
|
||||
weight: "0",
|
||||
show_url: "",
|
||||
describe_url: [],
|
||||
detail_url: "",
|
||||
stock: "",
|
||||
usage: "",
|
||||
detail_url: "",
|
||||
map_product_name: ""
|
||||
},
|
||||
cur_product: null,
|
||||
productOption: [],
|
||||
products: [],
|
||||
productpic: [],
|
||||
productsList: [],
|
||||
isSelectGoods: false
|
||||
}
|
||||
}
|
||||
componentDidMount() {
|
||||
mySwiper = new Swiper(".swiper-container", {
|
||||
slidesPerView: 1,
|
||||
centeredSlides: true,
|
||||
loop: true,
|
||||
autoplay: 3000,
|
||||
initialSlide: 0,
|
||||
observer: true, // 修改swiper自己或子元素时,自动初始化swiper
|
||||
observeParents: true, // 修改swiper的父元素时,自动初始化swiper
|
||||
pagination: ".swiper-pagination"
|
||||
})
|
||||
}
|
||||
|
||||
componentWillReceiveProps() {
|
||||
mySwiper.update()
|
||||
}
|
||||
|
||||
componentWillMount(e) {
|
||||
//获取商品信息
|
||||
if (this.props.data) {
|
||||
let model_temp = this.props.data
|
||||
|
||||
let model = this.state.model
|
||||
model.product_id = model_temp.product_id
|
||||
model.product_type = model_temp.product_type
|
||||
|
||||
model.contract_price = model_temp.contract_price
|
||||
model.official_price = model_temp.official_price
|
||||
model.cost_price = model_temp.cost_price
|
||||
model.quantity = model_temp.quantity
|
||||
model.product_name = model_temp.product_name
|
||||
model.weight = String(model_temp.weight)
|
||||
model.show_url = model_temp.show_url
|
||||
model.account_type = model_temp.account_type
|
||||
model.detail_url = model_temp.detail_url
|
||||
let defaultPic = []
|
||||
let arr = []
|
||||
|
||||
let temp_productpic = this.state.productpic
|
||||
let pics = ""
|
||||
if (Array.isArray(model_temp.describe_url)) {
|
||||
pics = model_temp.describe_url
|
||||
} else {
|
||||
if (
|
||||
model_temp.describe_url != "" &&
|
||||
model_temp.describe_url != undefined
|
||||
) {
|
||||
pics = model_temp.describe_url.split(",")
|
||||
} else {
|
||||
pics = []
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < pics.length; i++) {
|
||||
let obj = {}
|
||||
let nameArr = pics[i].split("/")
|
||||
obj.name = nameArr[5] + i || nameArr[2] + i
|
||||
obj.src = pics[i]
|
||||
defaultPic.push(obj)
|
||||
let obj2 = {
|
||||
name: nameArr[5] + i || nameArr[2] + i,
|
||||
url: pics[i]
|
||||
}
|
||||
temp_productpic.push(obj2)
|
||||
}
|
||||
|
||||
this.setState({ temp_productpic })
|
||||
model.describe_url = defaultPic
|
||||
model.stock = model_temp.stock
|
||||
model.usage = model_temp.usage
|
||||
model.map_product_name = model_temp.map_product_name
|
||||
this.setState({ model: model })
|
||||
}
|
||||
this.getProductInfo()
|
||||
}
|
||||
|
||||
//获取直连天下商品映射信息
|
||||
getProductInfo() {
|
||||
let productList = sessionStorage.getItem("productsList")
|
||||
productList = JSON.parse(productList)
|
||||
|
||||
let product_data = []
|
||||
if (sessionStorage.getItem("productData")) {
|
||||
product_data = JSON.parse(sessionStorage.getItem("productData"))
|
||||
}
|
||||
let checked_product = product_data ? product_data : []
|
||||
|
||||
let arr = []
|
||||
this.setState({ products: productList })
|
||||
|
||||
_.map(productList, (res) => {
|
||||
let index = checked_product.findIndex((item) => {
|
||||
return item.product_id == res.id
|
||||
})
|
||||
let obj = {}
|
||||
obj.key = res.id
|
||||
obj.text = res.title
|
||||
obj.disabled = index > -1 ? true : false
|
||||
if (obj.disabled) {
|
||||
}
|
||||
obj.in = index > -1 ? checked_product[index].in : false
|
||||
arr.push(obj)
|
||||
return obj
|
||||
})
|
||||
|
||||
this.setState({ productOption: arr })
|
||||
if (this.state.model.product_id) {
|
||||
let cur_product = arr.find((item) => {
|
||||
return item.key == this.state.model.product_id
|
||||
})
|
||||
|
||||
this.setState({ cur_product: cur_product })
|
||||
if (cur_product && cur_product.in) {
|
||||
this.setState({ isSelectGoods: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async submit() {
|
||||
if (this.refs.form1.validator()) {
|
||||
if (this.props.data) {
|
||||
let temp = []
|
||||
if (sessionStorage.getItem("productData")) {
|
||||
temp = JSON.parse(sessionStorage.getItem("productData"))
|
||||
|
||||
let index = temp.findIndex((item) => {
|
||||
return item.product_id == this.props.data.product_id
|
||||
})
|
||||
|
||||
temp[index].product_name = this.state.model.product_name
|
||||
temp[index].weight = this.state.model.weight
|
||||
temp[index].account_type = this.state.model.account_type
|
||||
temp[index].product_id = this.state.model.product_id
|
||||
temp[index].product_type = this.state.model.product_type
|
||||
temp[index].contract_price = this.state.model.contract_price
|
||||
temp[index].official_price = this.state.model.official_price
|
||||
temp[index].cost_price = this.state.model.cost_price
|
||||
temp[index].quantity = this.state.model.quantity
|
||||
temp[index].stock = this.state.model.quantity
|
||||
temp[index].usage = this.state.model.usage
|
||||
temp[index].show_url = this.state.model.show_url
|
||||
temp[index].detail_url = this.state.model.detail_url
|
||||
let urls = _.map(this.state.productpic, (o) => {
|
||||
return o.url
|
||||
})
|
||||
if (urls.length <= 0) {
|
||||
Notify.error(`商品图至少请上传一张`)
|
||||
return
|
||||
}
|
||||
|
||||
temp[index].describe_url = urls
|
||||
temp[index].map_product_name = this.state.model.map_product_name
|
||||
temp[index].account_type = this.state.model.account_type
|
||||
|
||||
sessionStorage.setItem("productData", JSON.stringify(temp))
|
||||
}
|
||||
} else {
|
||||
let model = this.state.model
|
||||
|
||||
let urls = _.map(this.state.productpic, (o) => {
|
||||
return o.url
|
||||
})
|
||||
|
||||
if (urls.length <= 0) {
|
||||
Notify.error(`商品图至少请上传一张`)
|
||||
return
|
||||
}
|
||||
|
||||
model.describe_url = urls
|
||||
|
||||
this.setState({ model: model })
|
||||
|
||||
if (this.state.model.show_url == "") {
|
||||
Notify.error(`请上传商品Logo`)
|
||||
return
|
||||
}
|
||||
let temp = []
|
||||
if (sessionStorage.getItem("productData")) {
|
||||
temp = JSON.parse(sessionStorage.getItem("productData"))
|
||||
}
|
||||
let data = temp ? temp : []
|
||||
data.push(this.state.model)
|
||||
sessionStorage.setItem("productData", JSON.stringify(data))
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
onProductChange(e) {
|
||||
this.setState({ cur_product: e })
|
||||
let cur_product = this.state.products.find((item) => {
|
||||
return item.id == e.key
|
||||
})
|
||||
let picItem = window.goods.find((item) => {
|
||||
return item.id == cur_product.product_category_id
|
||||
})
|
||||
|
||||
const productItem = picItem?.products.find(
|
||||
(item) => item.id == cur_product.id
|
||||
)
|
||||
|
||||
const obj1 = []
|
||||
const obj2 = []
|
||||
productItem?.pic.map((item, index) => {
|
||||
obj1.push({
|
||||
src: item,
|
||||
id: item + index,
|
||||
type: "add",
|
||||
name: productItem.title + index
|
||||
})
|
||||
obj2.push({
|
||||
url: item,
|
||||
id: item + index,
|
||||
type: "add",
|
||||
name: productItem.title + index
|
||||
})
|
||||
})
|
||||
|
||||
let quantity = this.state.model.quantity
|
||||
let model2 = {
|
||||
product_id: cur_product.id,
|
||||
product_type: cur_product.type,
|
||||
contract_price: this.state.model.contract_price,
|
||||
official_price: cur_product.official_price,
|
||||
cost_price: cur_product.cost_price,
|
||||
quantity: quantity,
|
||||
stock: quantity,
|
||||
usage: 0,
|
||||
weight: this.state.model.weight,
|
||||
product_name: cur_product.title,
|
||||
show_url: picItem ? picItem.pic : "",
|
||||
describe_url: obj1,
|
||||
detail_url: "",
|
||||
map_product_name: cur_product.title,
|
||||
account_type: cur_product.account_type
|
||||
}
|
||||
this.setState({ model: model2, productpic: obj2 })
|
||||
}
|
||||
onTypeChange(e) {
|
||||
let model2 = this.state.model
|
||||
model2.type = e.target.value
|
||||
this.setState({ model: model2 })
|
||||
}
|
||||
|
||||
onUpload = (file, report) => {
|
||||
return new Promise((resolve, reject) => {})
|
||||
}
|
||||
onUploadChange(files) {
|
||||
if (files.length > 0) {
|
||||
let formdata = new FormData()
|
||||
formdata.append("file", files[0].file)
|
||||
formdata.append("path", "common_image")
|
||||
uploadImg(formdata).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
let path = req.path
|
||||
let model = this.state.model
|
||||
model.show_url = path
|
||||
|
||||
this.setState({ model: model })
|
||||
},
|
||||
(err) => {}
|
||||
)
|
||||
})
|
||||
} else {
|
||||
let model = this.state.model
|
||||
model.show_url = ""
|
||||
this.setState({ model: model })
|
||||
}
|
||||
}
|
||||
onUploadChange1(files, e) {
|
||||
let arr = _.map(files, (o) => {
|
||||
return o.name
|
||||
})
|
||||
if (mySwiper !== 0) {
|
||||
mySwiper.destroy()
|
||||
}
|
||||
mySwiper = new Swiper(".swiper-container", {
|
||||
observer: true, //修改swiper自己或子元素时,自动初始化swiper
|
||||
observeParents: true, //修改swiper的父元素时,自动初始化swiper
|
||||
pagination: ".swiper-pagination",
|
||||
paginationClickable: true,
|
||||
autoplay: 3000
|
||||
})
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
if (arr.length > this.state.productpic.length) {
|
||||
//新增
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
let index = this.state.productpic.findIndex((o) => {
|
||||
return o.name == arr[i]
|
||||
})
|
||||
if (index < 0) {
|
||||
let path = ""
|
||||
let formdata = new FormData()
|
||||
formdata.append("file", files[i].file)
|
||||
formdata.append("path", "common_image")
|
||||
|
||||
uploadImg(formdata).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
path = req.path
|
||||
let obj = {
|
||||
id: files[i].id,
|
||||
name: files[i].name,
|
||||
url: path,
|
||||
type: "add"
|
||||
}
|
||||
let obj1 = {
|
||||
id: files[i].id,
|
||||
name: files[i].name,
|
||||
src: path,
|
||||
type: "add"
|
||||
}
|
||||
const model = this.state.model
|
||||
model.describe_url.push(obj1)
|
||||
let arr = this.state.productpic
|
||||
arr.push(obj)
|
||||
this.setState({ productpic: arr, model })
|
||||
},
|
||||
(err) => {}
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
if (arr.length < this.state.productpic.length) {
|
||||
let temp_arr = Object.assign([], this.state.productpic)
|
||||
this.setState({ productpic: [] })
|
||||
this.state.productpic = []
|
||||
let temp_arr2 = this.state.productpic
|
||||
for (let i = 0; i < temp_arr.length; i++) {
|
||||
let temp = temp_arr[i]
|
||||
if (arr.indexOf(temp.name) > -1) {
|
||||
temp_arr2.push(temp)
|
||||
}
|
||||
}
|
||||
this.setState({ temp_arr2 })
|
||||
}
|
||||
|
||||
// //调整位置
|
||||
if (arr.length == this.state.productpic.length) {
|
||||
let temp_arr = []
|
||||
let pic_arr = this.state.productpic
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
let temp = pic_arr.find((o) => {
|
||||
return o.name == arr[i]
|
||||
})
|
||||
temp_arr[i] = temp
|
||||
}
|
||||
this.setState({ productpic: temp_arr })
|
||||
|
||||
let left_temp_arr = files.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
url: item.src
|
||||
}
|
||||
})
|
||||
let models = this.state.model
|
||||
models.describe_url = left_temp_arr
|
||||
this.setState({ model: models })
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
onUploadError = (type, data) => {
|
||||
if (type === "overMaxAmount") {
|
||||
Notify.error(`最多可上传 ${data.maxAmount} 张图片`)
|
||||
} else if (type === "overMaxSize") {
|
||||
Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`)
|
||||
}
|
||||
}
|
||||
onUploadChange2(files) {
|
||||
if (files.length > 0) {
|
||||
let formdata = new FormData()
|
||||
formdata.append("file", files[0].file)
|
||||
formdata.append("path", "common_image")
|
||||
uploadImg(formdata).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
let path = req.path
|
||||
let model = this.state.model
|
||||
model.detail_url = path
|
||||
|
||||
this.setState({ model: model })
|
||||
},
|
||||
(err) => {}
|
||||
)
|
||||
})
|
||||
} else {
|
||||
let model = this.state.model
|
||||
model.detail_url = ""
|
||||
this.setState({ model: model })
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
//校验规则
|
||||
const rules = {
|
||||
product: [{ type: "required", message: "请选择映射商品" }],
|
||||
quantity: [
|
||||
{ type: "required", message: "请输入商品库存" },
|
||||
{
|
||||
type: "regExp",
|
||||
message: "请输入小于100万的整数",
|
||||
reg: "^(?!0)(?:[0-9]{1,6}|1000000)$"
|
||||
}
|
||||
],
|
||||
contract_price: [
|
||||
{ type: "required", message: "请输入合同价" },
|
||||
{
|
||||
type: "regExp",
|
||||
message: "最多保留4位小数",
|
||||
reg: "^[0-9]+(.[0-9]{1,4})?$"
|
||||
}
|
||||
],
|
||||
product_name: [{ type: "required", message: "请输入商品名称" }],
|
||||
/* 权重 */
|
||||
weight: [
|
||||
{ type: "required", message: "请输入权重" },
|
||||
{
|
||||
type: "regExp",
|
||||
message: "请输入0~100权重数字",
|
||||
reg: "^([0-9]{0,2}|100)$"
|
||||
}
|
||||
]
|
||||
}
|
||||
return (
|
||||
<div id='addproduct'>
|
||||
<Form model={this.state.model} rules={rules} ref='form1'>
|
||||
<FormItem labelname='映射商品' prop='product' id='product'>
|
||||
<Select
|
||||
options={this.state.productOption}
|
||||
width={520}
|
||||
placeholder='请选择商品'
|
||||
value={this.state.cur_product}
|
||||
disabled={this.state.isSelectGoods}
|
||||
onChange={(e) => {
|
||||
this.onProductChange(e)
|
||||
Bus.emit("change", "product", e)
|
||||
}}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname='商品类型' prop='type' id='type'>
|
||||
<RadioGroup
|
||||
onChange={(e) => {
|
||||
this.onTypeChange(e)
|
||||
}}
|
||||
value={this.state.model.product_type}>
|
||||
<RadioButton value={1}>直充</RadioButton>
|
||||
<RadioButton value={2}>卡密</RadioButton>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
<FormItem labelname='预估成本价' prop='cost_price' id='cost_price'>
|
||||
<div className='line-value'>{this.state.model.cost_price}</div>
|
||||
</FormItem>
|
||||
<FormItem labelname='商品权重' prop='weight' id='weight'>
|
||||
<Ipt
|
||||
onChange={(e) => {
|
||||
let model2 = this.state.model
|
||||
model2.weight = e
|
||||
|
||||
this.setState({ model: model2 })
|
||||
}}
|
||||
onClearItem={(e) => {
|
||||
let model2 = this.state.model
|
||||
model2.weight = ""
|
||||
this.setState({ model: model2 })
|
||||
}}
|
||||
value={this.state.model.weight}
|
||||
placeholder={"请输入"}
|
||||
labelWidth={"0px"}
|
||||
maxLength={3}
|
||||
height={"36px"}
|
||||
countShow={false}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname='库存总数量' prop='quantity' id='quantity'>
|
||||
<Ipt
|
||||
onChange={(e) => {
|
||||
let model2 = this.state.model
|
||||
model2.quantity = e
|
||||
model2.stock = e
|
||||
this.setState({ model: model2 })
|
||||
}}
|
||||
onClearItem={(e) => {
|
||||
let model2 = this.state.model
|
||||
model2.quantity = ""
|
||||
model2.stock = 0
|
||||
this.setState({ model: model2 })
|
||||
}}
|
||||
value={this.state.model.quantity}
|
||||
placeholder={"请输入"}
|
||||
labelWidth={"0px"}
|
||||
maxLength={7}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
id='contract_price'
|
||||
labelname='合同价'
|
||||
prop='contract_price'>
|
||||
<Ipt
|
||||
onChange={(e) => {
|
||||
let model2 = this.state.model
|
||||
model2.contract_price = e
|
||||
this.setState({ model: model2 })
|
||||
}}
|
||||
onClearItem={(e) => {
|
||||
let model2 = this.state.model
|
||||
model2.contract_price = ""
|
||||
this.setState({ model: model2 })
|
||||
}}
|
||||
value={this.state.model.contract_price}
|
||||
placeholder={"请输入"}
|
||||
labelWidth={"0px"}
|
||||
maxLength={16}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem id='product_name' labelname='商品名称' prop='product_name'>
|
||||
<Ipt
|
||||
onChange={(e) => {
|
||||
let model2 = this.state.model
|
||||
model2.product_name = e
|
||||
this.setState({ model: model2 })
|
||||
}}
|
||||
onClearItem={(e) => {
|
||||
let model2 = this.state.model
|
||||
model2.product_name = ""
|
||||
this.setState({ model: model2 })
|
||||
}}
|
||||
value={this.state.model.product_name}
|
||||
placeholder={"请输入"}
|
||||
labelWidth={"0px"}
|
||||
maxLength={20}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
id='official_price'
|
||||
labelname='商品官方价'
|
||||
prop='official_price'>
|
||||
<div className='line-value'>{this.state.model.official_price}</div>
|
||||
</FormItem>
|
||||
|
||||
<FormItem id='show_url' prop='show_url' labelname='商品Logo'>
|
||||
<ImageUpload
|
||||
className='zent-image-upload-demo'
|
||||
maxSize={2 * 1024 * 1024}
|
||||
tips='图片不超过 2M'
|
||||
maxAmount={1}
|
||||
onError={this.onUploadError}
|
||||
onChange={(e) => {
|
||||
this.onUploadChange(e)
|
||||
}}
|
||||
fileList={
|
||||
this.state.model.show_url
|
||||
? [{ src: this.state.model.show_url, id: 1 }]
|
||||
: null
|
||||
}
|
||||
value={this.state.model.show_url}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem prop='describe_url' labelname='商品图' id='describe_url'>
|
||||
<ImageUpload
|
||||
className='good-image-upload-demo'
|
||||
maxSize={2 * 1024 * 1024}
|
||||
tips='图片不超过 2M'
|
||||
maxAmount={9}
|
||||
sortable
|
||||
onError={this.onUploadError}
|
||||
fileList={this.state.model.describe_url}
|
||||
multiple
|
||||
onUpload={this.onUpload}
|
||||
onChange={(e) => {
|
||||
this.onUploadChange1(e)
|
||||
}}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
prop='detail_url'
|
||||
labelname='商品详情'
|
||||
id='detail_url'
|
||||
required={false}>
|
||||
<ImageUpload
|
||||
className='zent-image-upload-demo'
|
||||
maxSize={2 * 1024 * 1024}
|
||||
tips='图片不超过 2M'
|
||||
maxAmount={1}
|
||||
onError={this.onUploadError}
|
||||
fileList={
|
||||
this.state.model.detail_url
|
||||
? [{ src: this.state.model.detail_url }]
|
||||
: null
|
||||
}
|
||||
onUpload={this.onUpload}
|
||||
onChange={(e) => {
|
||||
this.onUploadChange2(e)
|
||||
}}
|
||||
/>
|
||||
</FormItem>
|
||||
</Form>
|
||||
|
||||
<div className='mobile'>
|
||||
<div className='mobile_top'>
|
||||
{this.state.productpic ? (
|
||||
<div className='swiper-container'>
|
||||
<div className='swiper-wrapper' ref='swiperwrapper'>
|
||||
{this.state.productpic.map((item, index) => {
|
||||
return (
|
||||
<div className='swiper-slide' key={index}>
|
||||
<img src={item.url} />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<div className='swiper-pagination'></div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className='mobile_center'></div>
|
||||
<div className='mobile_bottom'>
|
||||
{this.state.model.detail_url ? (
|
||||
<img src={this.state.model.detail_url} />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
.line-value {
|
||||
width: 508px;
|
||||
text-align: left;
|
||||
height: 36px;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.zent-image-upload-item-delete {
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
.mobile {
|
||||
width: 375px;
|
||||
height: 667px;
|
||||
max-height: 667px;
|
||||
background-color: #fafafa;
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
border-color: 1px solid #B4B6B9;
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.mobile_top {
|
||||
width: 100%;
|
||||
height: 373px;
|
||||
background-image: url(https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/detailtop.png);
|
||||
background-size: 100% 100%;
|
||||
|
||||
}
|
||||
|
||||
.mobile_center {
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
height: 158px;
|
||||
background-image: url(https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/img/detailipt.png);
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.mobile_bottom {
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
// background-image: url;
|
||||
|
||||
}
|
||||
|
||||
.swiper-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.swiper-slide {
|
||||
img {
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.swiper-mobile-simple {
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
.good-image-upload-demo {
|
||||
width: 300px !important;
|
||||
}
|
|
@ -3,7 +3,6 @@ import Overview from "@/pages/overview/main/main"
|
|||
import Distributor from "@/pages/distributor/main/main"
|
||||
import ExchangeCodeList from "@/pages/exchangecode/list/list"
|
||||
import ExchangeCodeAdd from "@/pages/exchangecode/add/add"
|
||||
// import ExchangeCodeEdit from "@/pages/exchangecode/edit/edit"
|
||||
import ExchangeCommodity from "@/pages/exchangecode/commodity/commodity"
|
||||
import ProductEdit from "@/pages/exchangecode/commodity/goodedit.js"
|
||||
import ExchangePage from "@/pages/exchangepage/main/main"
|
||||
|
@ -36,7 +35,6 @@ import DistriButorAdd from "@/pages/distributor/add/add"
|
|||
import DistriButorEdit from "@/pages/distributor/add/add"
|
||||
import MyTempMouldAdd from "@/pages/exchangepage/template/main.js"
|
||||
import MyExChangeTemplate from "@/pages/exchangepage/mytemplate/main.js"
|
||||
// import CopyCode from "@/pages/exchangecode/copyCode/index";
|
||||
import ExchangeCodeAdds from "@/pages/exchangecode/exchangecodeAdd"
|
||||
import CouponList from "@/pages/coupon/list"
|
||||
import CouponAddEdit from "@/pages/coupon/addEdit"
|
||||
|
@ -214,16 +212,6 @@ const router = [
|
|||
component: ExchangeCodeAdd,
|
||||
meta: { exact: true }
|
||||
},
|
||||
// {
|
||||
// path: "/home/exchangecode-edit",
|
||||
// component: ExchangeCodeEdit,
|
||||
// meta: { exact: true }
|
||||
// },
|
||||
// {
|
||||
// path: "/home/exchangecode-copyCode",
|
||||
// component: CopyCode,
|
||||
// meta: { exact: true }
|
||||
// },
|
||||
{
|
||||
path: "/home/exchange-addcommodity",
|
||||
component: ExchangeCommodity,
|
||||
|
|
Loading…
Reference in New Issue