1) 分销商兼容
This commit is contained in:
parent
3656836f44
commit
94badd7687
|
@ -372,6 +372,15 @@ export default class adduserinfo extends React.Component {
|
||||||
this.getPersonnelFn();
|
this.getPersonnelFn();
|
||||||
this.getCompanyFn();
|
this.getCompanyFn();
|
||||||
let formInfo = JSON.parse(sessionStorage.getItem("dataInfo"));
|
let formInfo = JSON.parse(sessionStorage.getItem("dataInfo"));
|
||||||
|
let direct_reseller_ids =
|
||||||
|
formInfo.direct_reseller_id === 0
|
||||||
|
? ""
|
||||||
|
: {
|
||||||
|
key: formInfo.direct_reseller_id,
|
||||||
|
text: formInfo.direct_reseller_name,
|
||||||
|
};
|
||||||
|
let isSelectDirects = formInfo.direct_reseller_id === 0 ? false : true;
|
||||||
|
console.log("formInfo ==>", formInfo);
|
||||||
if (this.props.enumer == 1) {
|
if (this.props.enumer == 1) {
|
||||||
let reselData = _.cloneDeep(formInfo); //表单的信息
|
let reselData = _.cloneDeep(formInfo); //表单的信息
|
||||||
let data = {
|
let data = {
|
||||||
|
@ -389,10 +398,7 @@ export default class adduserinfo extends React.Component {
|
||||||
text: reselData.salesman_name,
|
text: reselData.salesman_name,
|
||||||
},
|
},
|
||||||
subject: reselData.subject,
|
subject: reselData.subject,
|
||||||
direct_reseller_id: {
|
direct_reseller_id: direct_reseller_ids,
|
||||||
key: formInfo.direct_reseller_id,
|
|
||||||
text: formInfo.direct_reseller_name,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
let phoneTo = reselData.contact_phone;
|
let phoneTo = reselData.contact_phone;
|
||||||
|
|
||||||
|
@ -427,7 +433,7 @@ export default class adduserinfo extends React.Component {
|
||||||
email_nums: emailTo.length,
|
email_nums: emailTo.length,
|
||||||
model: data,
|
model: data,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
isSelectDirect: true,
|
isSelectDirect: isSelectDirects,
|
||||||
defaultFileList: [img],
|
defaultFileList: [img],
|
||||||
id: reselData.id,
|
id: reselData.id,
|
||||||
headImg: reselData.head_img,
|
headImg: reselData.head_img,
|
||||||
|
|
|
@ -325,6 +325,8 @@ export default class acclist extends React.Component {
|
||||||
case 2:
|
case 2:
|
||||||
this.setState({ draw_title: "新建立减金" });
|
this.setState({ draw_title: "新建立减金" });
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
this.setState({ drawerVisible: false });
|
this.setState({ drawerVisible: false });
|
||||||
this.state.codeInfo = {
|
this.state.codeInfo = {
|
||||||
|
@ -418,7 +420,7 @@ export default class acclist extends React.Component {
|
||||||
Notify.error("所选商品库存总数小于发放量");
|
Notify.error("所选商品库存总数小于发放量");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let productList = JSON.parse(sessionStorage.getItem("productsList"));
|
// let productList = JSON.parse(sessionStorage.getItem("productsList"));
|
||||||
|
|
||||||
this.setState({ drawerVisible: false });
|
this.setState({ drawerVisible: false });
|
||||||
let rank = _.map(this.state.rank, (item) => {
|
let rank = _.map(this.state.rank, (item) => {
|
||||||
|
|
|
@ -1,24 +1,37 @@
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from "react-dom";
|
||||||
import React from "react"
|
import React from "react";
|
||||||
import "./add.less"
|
import "./add.less";
|
||||||
import Ipt from "../../../components/input/main"
|
import Ipt from "../../../components/input/main";
|
||||||
import Form from "../../../components/form/main"
|
import Form from "../../../components/form/main";
|
||||||
import FormItem from "../../../components/form-item/main"
|
import FormItem from "../../../components/form-item/main";
|
||||||
import {Select,Button,ImageUpload ,onUpload,Sweetalert,RadioButton,RadioGroup,Notify} from "zent"
|
import {
|
||||||
import Swiper from 'swiper/dist/js/swiper.js'
|
Select,
|
||||||
import 'swiper/dist/css/swiper.min.css'
|
Button,
|
||||||
import Bus from "../../../assets/eventBus.js"
|
ImageUpload,
|
||||||
import {getProductInfoSelect,handelResponse,uploadImg} from "../../../assets/api.js"
|
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";
|
import _ from "lodash";
|
||||||
|
|
||||||
var mySwiper = null;
|
var mySwiper = null;
|
||||||
var timer = null
|
var timer = null;
|
||||||
export default class adduserinfo extends React.Component {
|
export default class adduserinfo extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
model:{ //数据模型不可少
|
model: {
|
||||||
|
//数据模型不可少
|
||||||
product_id: "",
|
product_id: "",
|
||||||
product_type: "1",
|
product_type: "1",
|
||||||
contract_price: "",
|
contract_price: "",
|
||||||
|
@ -32,19 +45,16 @@ export default class adduserinfo extends React.Component{
|
||||||
stock: "",
|
stock: "",
|
||||||
usage: "",
|
usage: "",
|
||||||
detail_url: "",
|
detail_url: "",
|
||||||
map_product_name:""
|
map_product_name: "",
|
||||||
},
|
},
|
||||||
cur_product: null,
|
cur_product: null,
|
||||||
productOption: [],
|
productOption: [],
|
||||||
products: [],
|
products: [],
|
||||||
productpic: [],
|
productpic: [],
|
||||||
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
mySwiper = new Swiper(".swiper-container", {
|
||||||
mySwiper = new Swiper('.swiper-container', {
|
|
||||||
slidesPerView: 1,
|
slidesPerView: 1,
|
||||||
centeredSlides: true,
|
centeredSlides: true,
|
||||||
loop: true,
|
loop: true,
|
||||||
|
@ -52,202 +62,183 @@ export default class adduserinfo extends React.Component{
|
||||||
initialSlide: 0,
|
initialSlide: 0,
|
||||||
observer: true, // 修改swiper自己或子元素时,自动初始化swiper
|
observer: true, // 修改swiper自己或子元素时,自动初始化swiper
|
||||||
observeParents: true, // 修改swiper的父元素时,自动初始化swiper
|
observeParents: true, // 修改swiper的父元素时,自动初始化swiper
|
||||||
pagination: '.swiper-pagination',
|
pagination: ".swiper-pagination",
|
||||||
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
componentWillReceiveProps() {
|
componentWillReceiveProps() {
|
||||||
mySwiper.update();
|
mySwiper.update();
|
||||||
}
|
}
|
||||||
componentWillMount(e) {
|
componentWillMount(e) {
|
||||||
|
|
||||||
//获取商品信息
|
//获取商品信息
|
||||||
if(this.props.data)
|
if (this.props.data) {
|
||||||
{
|
|
||||||
|
|
||||||
let model_temp = this.props.data;
|
let model_temp = this.props.data;
|
||||||
|
|
||||||
|
|
||||||
let model = this.state.model;
|
let model = this.state.model;
|
||||||
model.product_id = model_temp.product_id;
|
model.product_id = model_temp.product_id;
|
||||||
model.product_type = model_temp.product_type
|
model.product_type = model_temp.product_type;
|
||||||
|
|
||||||
model.contract_price = model_temp.contract_price
|
model.contract_price = model_temp.contract_price;
|
||||||
model.official_price = model_temp.official_price
|
model.official_price = model_temp.official_price;
|
||||||
model.cost_price = model_temp.cost_price
|
model.cost_price = model_temp.cost_price;
|
||||||
model.quantity = model_temp.quantity
|
model.quantity = model_temp.quantity;
|
||||||
model.product_name = model_temp.product_name
|
model.product_name = model_temp.product_name;
|
||||||
model.show_url = model_temp.show_url
|
model.show_url = model_temp.show_url;
|
||||||
model.account_type = model_temp.account_type
|
model.account_type = model_temp.account_type;
|
||||||
model.detail_url = model_temp.detail_url
|
model.detail_url = model_temp.detail_url;
|
||||||
let defaultPic = []
|
let defaultPic = [];
|
||||||
let arr = []
|
let arr = [];
|
||||||
|
|
||||||
|
let temp_productpic = this.state.productpic;
|
||||||
let temp_productpic = this.state.productpic
|
let pics = "";
|
||||||
let pics = ""
|
if (Array.isArray(model_temp.describe_url)) {
|
||||||
if(Array.isArray(model_temp.describe_url))
|
pics = model_temp.describe_url;
|
||||||
{
|
} else {
|
||||||
pics = model_temp.describe_url
|
if (
|
||||||
|
model_temp.describe_url != "" &&
|
||||||
|
model_temp.describe_url != undefined
|
||||||
|
) {
|
||||||
|
pics = model_temp.describe_url.split(",");
|
||||||
|
} else {
|
||||||
|
pics = [];
|
||||||
}
|
}
|
||||||
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];
|
||||||
for(let i = 0;i < pics.length;i++)
|
|
||||||
{
|
|
||||||
let obj = {}
|
|
||||||
let nameArr = pics[i].split('/');
|
|
||||||
obj.name = nameArr[5]
|
|
||||||
obj.src = pics[i];
|
obj.src = pics[i];
|
||||||
defaultPic.push(obj)
|
defaultPic.push(obj);
|
||||||
let obj2 = {
|
let obj2 = {
|
||||||
name: nameArr[5],
|
name: nameArr[5],
|
||||||
url:pics[i]
|
url: pics[i],
|
||||||
|
};
|
||||||
|
temp_productpic.push(obj2);
|
||||||
}
|
}
|
||||||
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.setState({temp_productpic})
|
this.getProductInfo();
|
||||||
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() {
|
getProductInfo() {
|
||||||
let productList = sessionStorage.getItem("productsList")
|
let productList = sessionStorage.getItem("productsList");
|
||||||
|
|
||||||
productList = JSON.parse(productList);
|
productList = JSON.parse(productList);
|
||||||
let product_data = []
|
let product_data = [];
|
||||||
if(sessionStorage.getItem("productData"))
|
if (sessionStorage.getItem("productData")) {
|
||||||
{
|
|
||||||
product_data = JSON.parse(sessionStorage.getItem("productData"));
|
product_data = JSON.parse(sessionStorage.getItem("productData"));
|
||||||
}
|
}
|
||||||
let checked_product = product_data ? product_data : [];
|
let checked_product = product_data ? product_data : [];
|
||||||
|
|
||||||
let arr = [];
|
let arr = [];
|
||||||
this.setState({products:productList})
|
this.setState({ products: productList });
|
||||||
_.map(productList, (res) => {
|
_.map(productList, (res) => {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
obj.key = res.id;
|
obj.key = res.id;
|
||||||
obj.text = res.title;
|
obj.text = res.title;
|
||||||
obj.disabled = checked_product.findIndex((item)=>{return item.product_id == res.id}) > -1;
|
obj.disabled =
|
||||||
if(obj.disabled)
|
checked_product.findIndex((item) => {
|
||||||
{
|
return item.product_id == res.id;
|
||||||
|
}) > -1;
|
||||||
|
if (obj.disabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
arr.push(obj)
|
arr.push(obj);
|
||||||
return obj;
|
return obj;
|
||||||
})
|
});
|
||||||
|
|
||||||
this.setState({"productOption":arr})
|
this.setState({ productOption: arr });
|
||||||
|
|
||||||
|
if (this.state.model.product_id) {
|
||||||
if(this.state.model.product_id)
|
let cur_product = arr.find((item) => {
|
||||||
{
|
return item.key == 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})
|
this.setState({ cur_product: cur_product });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
if(this.refs.form1.validator())
|
if (this.refs.form1.validator()) {
|
||||||
{
|
if (this.props.data) {
|
||||||
|
let temp = [];
|
||||||
if(this.props.data)
|
if (sessionStorage.getItem("productData")) {
|
||||||
{ let temp = []
|
|
||||||
if(sessionStorage.getItem("productData"))
|
|
||||||
{
|
|
||||||
|
|
||||||
temp = JSON.parse(sessionStorage.getItem("productData"));
|
temp = JSON.parse(sessionStorage.getItem("productData"));
|
||||||
|
|
||||||
let index = temp.findIndex((item)=>{return item.product_id ==this.props.data.product_id})
|
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].product_name = this.state.model.product_name;
|
||||||
temp[index].account_type = this.state.model.account_type
|
temp[index].account_type = this.state.model.account_type;
|
||||||
temp[index].product_id = this.state.model.product_id
|
temp[index].product_id = this.state.model.product_id;
|
||||||
temp[index].product_type = this.state.model.product_type
|
temp[index].product_type = this.state.model.product_type;
|
||||||
temp[index].contract_price = this.state.model.contract_price
|
temp[index].contract_price = this.state.model.contract_price;
|
||||||
temp[index].official_price = this.state.model.official_price
|
temp[index].official_price = this.state.model.official_price;
|
||||||
temp[index].cost_price = this.state.model.cost_price
|
temp[index].cost_price = this.state.model.cost_price;
|
||||||
temp[index].quantity = this.state.model.quantity
|
temp[index].quantity = this.state.model.quantity;
|
||||||
temp[index].stock = this.state.model.quantity
|
temp[index].stock = this.state.model.quantity;
|
||||||
temp[index].usage = this.state.model.usage
|
temp[index].usage = this.state.model.usage;
|
||||||
temp[index].show_url = this.state.model.show_url
|
temp[index].show_url = this.state.model.show_url;
|
||||||
temp[index].detail_url = this.state.model.detail_url
|
temp[index].detail_url = this.state.model.detail_url;
|
||||||
let urls = _.map(this.state.productpic, (o) => {
|
let urls = _.map(this.state.productpic, (o) => {
|
||||||
return o.url
|
return o.url;
|
||||||
})
|
});
|
||||||
if(urls.length <= 0)
|
if (urls.length <= 0) {
|
||||||
{
|
|
||||||
Notify.error(`商品图至少请上传一张`);
|
Notify.error(`商品图至少请上传一张`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp[index].describe_url = urls
|
temp[index].describe_url = urls;
|
||||||
temp[index].map_product_name = this.state.model.map_product_name
|
temp[index].map_product_name = this.state.model.map_product_name;
|
||||||
temp[index].account_type = this.state.model.account_type
|
temp[index].account_type = this.state.model.account_type;
|
||||||
|
|
||||||
sessionStorage.setItem('productData', JSON.stringify(temp));
|
sessionStorage.setItem("productData", JSON.stringify(temp));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
let model = this.state.model;
|
let model = this.state.model;
|
||||||
|
|
||||||
|
|
||||||
let urls = _.map(this.state.productpic, (o) => {
|
let urls = _.map(this.state.productpic, (o) => {
|
||||||
return o.url
|
return o.url;
|
||||||
})
|
});
|
||||||
|
|
||||||
if(urls.length <= 0)
|
if (urls.length <= 0) {
|
||||||
{
|
|
||||||
Notify.error(`商品图至少请上传一张`);
|
Notify.error(`商品图至少请上传一张`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
model.describe_url = urls
|
model.describe_url = urls;
|
||||||
|
|
||||||
this.setState({model:model})
|
this.setState({ model: model });
|
||||||
|
|
||||||
|
if (this.state.model.show_url == "") {
|
||||||
if(this.state.model.show_url == "")
|
|
||||||
{
|
|
||||||
Notify.error(`请上传商品Logo`);
|
Notify.error(`请上传商品Logo`);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let temp = []
|
let temp = [];
|
||||||
if(sessionStorage.getItem("productData"))
|
if (sessionStorage.getItem("productData")) {
|
||||||
{
|
|
||||||
temp = JSON.parse(sessionStorage.getItem("productData"));
|
temp = JSON.parse(sessionStorage.getItem("productData"));
|
||||||
}
|
}
|
||||||
let data = temp ? temp : [];
|
let data = temp ? temp : [];
|
||||||
data.push(this.state.model)
|
data.push(this.state.model);
|
||||||
sessionStorage.setItem('productData', JSON.stringify(data));
|
sessionStorage.setItem("productData", JSON.stringify(data));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onProductChange(e) {
|
onProductChange(e) {
|
||||||
this.setState({cur_product:e})
|
this.setState({ cur_product: e });
|
||||||
let cur_product = this.state.products.find((item)=>{return item.id == e.key})
|
let cur_product = this.state.products.find((item) => {
|
||||||
let picItem = window.goods.find((item)=>{return item.id == cur_product.product_category_id})
|
return item.id == e.key;
|
||||||
|
});
|
||||||
|
let picItem = window.goods.find((item) => {
|
||||||
|
return item.id == cur_product.product_category_id;
|
||||||
|
});
|
||||||
let quantity = this.state.model.quantity;
|
let quantity = this.state.model.quantity;
|
||||||
let model2 = {
|
let model2 = {
|
||||||
product_id: cur_product.id,
|
product_id: cur_product.id,
|
||||||
|
@ -261,204 +252,196 @@ export default class adduserinfo extends React.Component{
|
||||||
product_name: cur_product.title,
|
product_name: cur_product.title,
|
||||||
show_url: picItem ? picItem.pic : "",
|
show_url: picItem ? picItem.pic : "",
|
||||||
describe_url: "",
|
describe_url: "",
|
||||||
detail_url:'',
|
detail_url: "",
|
||||||
map_product_name: cur_product.title,
|
map_product_name: cur_product.title,
|
||||||
account_type:cur_product.account_type
|
account_type: cur_product.account_type,
|
||||||
}
|
};
|
||||||
this.setState({model:model2})
|
this.setState({ model: model2 });
|
||||||
}
|
}
|
||||||
onTypeChange(e) {
|
onTypeChange(e) {
|
||||||
let model2 = this.state.model;
|
let model2 = this.state.model;
|
||||||
model2.type = e.target.value;
|
model2.type = e.target.value;
|
||||||
this.setState({model:model2})
|
this.setState({ model: model2 });
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpload = (file, report) => {
|
onUpload = (file, report) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {});
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
onUploadChange(files) {
|
onUploadChange(files) {
|
||||||
if(files.length > 0 )
|
if (files.length > 0) {
|
||||||
{
|
|
||||||
|
|
||||||
let formdata = new FormData();
|
let formdata = new FormData();
|
||||||
formdata.append("file",files[0].file)
|
formdata.append("file", files[0].file);
|
||||||
formdata.append("path","common_image")
|
formdata.append("path", "common_image");
|
||||||
uploadImg(formdata).then((res) => {
|
uploadImg(formdata).then((res) => {
|
||||||
handelResponse(res,(req,msg)=>{
|
handelResponse(
|
||||||
|
res,
|
||||||
|
(req, msg) => {
|
||||||
let path = req.path;
|
let path = req.path;
|
||||||
let model = this.state.model;
|
let model = this.state.model;
|
||||||
model.show_url = path;
|
model.show_url = path;
|
||||||
|
|
||||||
this.setState({model:model})
|
this.setState({ model: model });
|
||||||
},(err)=>{
|
},
|
||||||
|
(err) => {}
|
||||||
})
|
);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
let model = this.state.model;
|
let model = this.state.model;
|
||||||
model.show_url = "";
|
model.show_url = "";
|
||||||
this.setState({model:model})
|
this.setState({ model: model });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
onUploadChange1(files, e) {
|
onUploadChange1(files, e) {
|
||||||
|
|
||||||
|
|
||||||
let arr = _.map(files, (o) => {
|
let arr = _.map(files, (o) => {
|
||||||
return o.name
|
return o.name;
|
||||||
})
|
});
|
||||||
if(mySwiper !==0)
|
if (mySwiper !== 0) {
|
||||||
{
|
|
||||||
mySwiper.destroy();
|
mySwiper.destroy();
|
||||||
}
|
}
|
||||||
mySwiper = new Swiper('.swiper-container', {
|
mySwiper = new Swiper(".swiper-container", {
|
||||||
observer: true, //修改swiper自己或子元素时,自动初始化swiper
|
observer: true, //修改swiper自己或子元素时,自动初始化swiper
|
||||||
observeParents: true, //修改swiper的父元素时,自动初始化swiper
|
observeParents: true, //修改swiper的父元素时,自动初始化swiper
|
||||||
pagination: '.swiper-pagination',
|
pagination: ".swiper-pagination",
|
||||||
paginationClickable: true,
|
paginationClickable: true,
|
||||||
autoplay: 3000,
|
autoplay: 3000,
|
||||||
})
|
});
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
if(arr.length > this.state.productpic.length)
|
if (arr.length > this.state.productpic.length) {
|
||||||
{
|
|
||||||
//新增
|
//新增
|
||||||
for(let i = 0;i < arr.length;i++)
|
for (let i = 0; i < arr.length; i++) {
|
||||||
{
|
|
||||||
|
|
||||||
let index = this.state.productpic.findIndex((o) => {
|
let index = this.state.productpic.findIndex((o) => {
|
||||||
return o.name == arr[i]
|
return o.name == arr[i];
|
||||||
})
|
});
|
||||||
if(index < 0)
|
if (index < 0) {
|
||||||
{
|
let path = "";
|
||||||
let path = ""
|
|
||||||
let formdata = new FormData();
|
let formdata = new FormData();
|
||||||
formdata.append("file",files[i].file)
|
formdata.append("file", files[i].file);
|
||||||
formdata.append("path","common_image")
|
formdata.append("path", "common_image");
|
||||||
|
|
||||||
uploadImg(formdata).then((res) => {
|
uploadImg(formdata).then((res) => {
|
||||||
handelResponse(res,(req,msg)=>{
|
handelResponse(
|
||||||
|
res,
|
||||||
|
(req, msg) => {
|
||||||
path = req.path;
|
path = req.path;
|
||||||
let obj = {
|
let obj = {
|
||||||
name: files[i].name,
|
name: files[i].name,
|
||||||
url:path
|
url: path,
|
||||||
}
|
};
|
||||||
let arr = this.state.productpic;
|
let arr = this.state.productpic;
|
||||||
arr.push(obj)
|
arr.push(obj);
|
||||||
this.setState({arr})
|
this.setState({ arr });
|
||||||
},(err)=>{
|
},
|
||||||
|
(err) => {}
|
||||||
})
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(arr.length < this.state.productpic.length)
|
if (arr.length < this.state.productpic.length) {
|
||||||
{
|
|
||||||
let temp_arr = Object.assign([], this.state.productpic);
|
let temp_arr = Object.assign([], this.state.productpic);
|
||||||
this.setState({productpic:[]})
|
this.setState({ productpic: [] });
|
||||||
this.state.productpic = []
|
this.state.productpic = [];
|
||||||
let temp_arr2 = this.state.productpic
|
let temp_arr2 = this.state.productpic;
|
||||||
for(let i = 0;i < temp_arr.length;i++ )
|
for (let i = 0; i < temp_arr.length; i++) {
|
||||||
{
|
let temp = temp_arr[i];
|
||||||
let temp =temp_arr[i]
|
if (arr.indexOf(temp.name) > -1) {
|
||||||
if(arr.indexOf(temp.name) > -1)
|
temp_arr2.push(temp);
|
||||||
{
|
|
||||||
temp_arr2.push(temp)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setState({temp_arr2})
|
this.setState({ temp_arr2 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// //调整位置
|
// //调整位置
|
||||||
if(arr.length == this.state.productpic.length)
|
if (arr.length == this.state.productpic.length) {
|
||||||
{
|
let temp_arr = [];
|
||||||
let temp_arr = []
|
let pic_arr = this.state.productpic;
|
||||||
let pic_arr = this.state.productpic
|
for (let i = 0; i < arr.length; i++) {
|
||||||
for(let i = 0;i < arr.length;i++ )
|
let temp = pic_arr.find((o) => {
|
||||||
{
|
return o.name == arr[i];
|
||||||
let temp = pic_arr.find((o)=>{return o.name == arr[i]})
|
});
|
||||||
temp_arr[i] = temp
|
temp_arr[i] = temp;
|
||||||
}
|
}
|
||||||
this.setState({productpic:temp_arr})
|
this.setState({ productpic: temp_arr });
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
},500)
|
|
||||||
|
|
||||||
};
|
|
||||||
onUploadError = (type, data) => {
|
onUploadError = (type, data) => {
|
||||||
if (type === 'overMaxAmount') {
|
if (type === "overMaxAmount") {
|
||||||
Notify.error(`最多可上传 ${data.maxAmount} 张图片`);
|
Notify.error(`最多可上传 ${data.maxAmount} 张图片`);
|
||||||
} else if (type === 'overMaxSize') {
|
} else if (type === "overMaxSize") {
|
||||||
Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`);
|
Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
onUploadChange2(files) {
|
onUploadChange2(files) {
|
||||||
if(files.length > 0 )
|
if (files.length > 0) {
|
||||||
{
|
|
||||||
let formdata = new FormData();
|
let formdata = new FormData();
|
||||||
formdata.append("file",files[0].file)
|
formdata.append("file", files[0].file);
|
||||||
formdata.append("path","common_image")
|
formdata.append("path", "common_image");
|
||||||
uploadImg(formdata).then((res) => {
|
uploadImg(formdata).then((res) => {
|
||||||
handelResponse(res,(req,msg)=>{
|
handelResponse(
|
||||||
|
res,
|
||||||
|
(req, msg) => {
|
||||||
let path = req.path;
|
let path = req.path;
|
||||||
let model = this.state.model;
|
let model = this.state.model;
|
||||||
model.detail_url = path;
|
model.detail_url = path;
|
||||||
|
|
||||||
this.setState({model:model})
|
this.setState({ model: model });
|
||||||
},(err)=>{
|
},
|
||||||
|
(err) => {}
|
||||||
})
|
);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
let model = this.state.model;
|
let model = this.state.model;
|
||||||
model.detail_url = "";
|
model.detail_url = "";
|
||||||
this.setState({model:model})
|
this.setState({ model: model });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
//校验规则
|
//校验规则
|
||||||
const rules = {
|
const rules = {
|
||||||
product: [
|
product: [{ type: "required", message: "请选择映射商品" }],
|
||||||
{ type: "required", message: "请选择映射商品"},
|
|
||||||
|
|
||||||
],
|
|
||||||
quantity: [
|
quantity: [
|
||||||
{ type: "required", message: "请输入商品库存" },
|
{ type: "required", message: "请输入商品库存" },
|
||||||
{ type: "regExp", message: "请输入小于100万的整数",reg:"^(?!0)(?:[0-9]{1,6}|1000000)$"},
|
{
|
||||||
|
type: "regExp",
|
||||||
|
message: "请输入小于100万的整数",
|
||||||
|
reg: "^(?!0)(?:[0-9]{1,6}|1000000)$",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
contract_price: [
|
contract_price: [
|
||||||
{ type: "required", message: "请输入合同价" },
|
{ type: "required", message: "请输入合同价" },
|
||||||
{ type: "regExp", message: "最多保留4位小数",reg:"^[0-9]+(.[0-9]{1,4})?$"},
|
{
|
||||||
|
type: "regExp",
|
||||||
|
message: "最多保留4位小数",
|
||||||
|
reg: "^[0-9]+(.[0-9]{1,4})?$",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
product_name:[
|
product_name: [{ type: "required", message: "请输入商品名称" }],
|
||||||
{ type: "required", message: "请输入商品名称"},
|
};
|
||||||
],
|
|
||||||
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div id="addproduct">
|
<div id="addproduct">
|
||||||
<Form model={this.state.model} rules={rules} ref="form1">
|
<Form model={this.state.model} rules={rules} ref="form1">
|
||||||
<FormItem labelname="映射商品" prop="product" id="product">
|
<FormItem labelname="映射商品" prop="product" id="product">
|
||||||
<Select options={this.state.productOption} width={500} placeholder="请选择商品" value={this.state.cur_product} onChange={(e)=>{
|
<Select
|
||||||
this.onProductChange(e)
|
options={this.state.productOption}
|
||||||
Bus.emit('change',"product" ,e);
|
width={500}
|
||||||
|
placeholder="请选择商品"
|
||||||
|
value={this.state.cur_product}
|
||||||
|
onChange={(e) => {
|
||||||
|
this.onProductChange(e);
|
||||||
|
Bus.emit("change", "product", e);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="商品类型" prop="type" id="type">
|
<FormItem labelname="商品类型" prop="type" id="type">
|
||||||
<RadioGroup onChange={(e)=>{this.onTypeChange(e)}} value={this.state.model.product_type}>
|
<RadioGroup
|
||||||
|
onChange={(e) => {
|
||||||
|
this.onTypeChange(e);
|
||||||
|
}}
|
||||||
|
value={this.state.model.product_type}
|
||||||
|
>
|
||||||
<RadioButton value={1}>直充</RadioButton>
|
<RadioButton value={1}>直充</RadioButton>
|
||||||
<RadioButton value={2}>卡密</RadioButton>
|
<RadioButton value={2}>卡密</RadioButton>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
@ -467,61 +450,84 @@ export default class adduserinfo extends React.Component{
|
||||||
<div className="line-value">{this.state.model.cost_price}</div>
|
<div className="line-value">{this.state.model.cost_price}</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="库存总数量" prop="quantity" id="quantity">
|
<FormItem labelname="库存总数量" prop="quantity" id="quantity">
|
||||||
<Ipt onChange={(e)=>{
|
<Ipt
|
||||||
|
onChange={(e) => {
|
||||||
let model2 = this.state.model;
|
let model2 = this.state.model;
|
||||||
model2.quantity = e;
|
model2.quantity = e;
|
||||||
model2.stock = e;
|
model2.stock = e;
|
||||||
this.setState({model:model2})
|
this.setState({ model: model2 });
|
||||||
}}
|
}}
|
||||||
|
|
||||||
onClearItem={(e) => {
|
onClearItem={(e) => {
|
||||||
let model2 = this.state.model;
|
let model2 = this.state.model;
|
||||||
model2.quantity = "";
|
model2.quantity = "";
|
||||||
model2.stock = 0;
|
model2.stock = 0;
|
||||||
this.setState({model:model2})
|
this.setState({ model: model2 });
|
||||||
}}
|
}}
|
||||||
|
value={this.state.model.quantity}
|
||||||
value={this.state.model.quantity} placeholder={"请输入"} labelWidth={'0px'} maxLength={7} height={'36px'} width={'520px'} alignment={'left'}/>
|
placeholder={"请输入"}
|
||||||
|
labelWidth={"0px"}
|
||||||
|
maxLength={7}
|
||||||
|
height={"36px"}
|
||||||
|
width={"520px"}
|
||||||
|
alignment={"left"}
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
|
<FormItem
|
||||||
<FormItem id="contract_price" labelname="合同价" prop="contract_price">
|
id="contract_price"
|
||||||
<Ipt onChange={(e)=>{
|
labelname="合同价"
|
||||||
|
prop="contract_price"
|
||||||
|
>
|
||||||
|
<Ipt
|
||||||
|
onChange={(e) => {
|
||||||
let model2 = this.state.model;
|
let model2 = this.state.model;
|
||||||
model2.contract_price = e;
|
model2.contract_price = e;
|
||||||
this.setState({model:model2})
|
this.setState({ model: model2 });
|
||||||
}}
|
}}
|
||||||
|
|
||||||
onClearItem={(e) => {
|
onClearItem={(e) => {
|
||||||
let model2 = this.state.model;
|
let model2 = this.state.model;
|
||||||
model2.contract_price = "";
|
model2.contract_price = "";
|
||||||
this.setState({model:model2})
|
this.setState({ model: model2 });
|
||||||
}}
|
}}
|
||||||
|
value={this.state.model.contract_price}
|
||||||
value={this.state.model.contract_price} placeholder={"请输入"} labelWidth={'0px'} maxLength={16} height={'36px'} width={'520px'} alignment={'left'}/>
|
placeholder={"请输入"}
|
||||||
|
labelWidth={"0px"}
|
||||||
|
maxLength={16}
|
||||||
|
height={"36px"}
|
||||||
|
width={"520px"}
|
||||||
|
alignment={"left"}
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem id="product_name" labelname="商品名称" prop="product_name">
|
<FormItem id="product_name" labelname="商品名称" prop="product_name">
|
||||||
<Ipt onChange={(e)=>{
|
<Ipt
|
||||||
|
onChange={(e) => {
|
||||||
let model2 = this.state.model;
|
let model2 = this.state.model;
|
||||||
model2.product_name = e;
|
model2.product_name = e;
|
||||||
this.setState({model:model2})
|
this.setState({ model: model2 });
|
||||||
}}
|
}}
|
||||||
onClearItem={(e) => {
|
onClearItem={(e) => {
|
||||||
let model2 = this.state.model;
|
let model2 = this.state.model;
|
||||||
model2.product_name = "";
|
model2.product_name = "";
|
||||||
this.setState({model:model2})
|
this.setState({ model: model2 });
|
||||||
}}
|
}}
|
||||||
value={this.state.model.product_name} placeholder={"请输入"} labelWidth={'0px'} maxLength={16} height={'36px'} width={'520px'} alignment={'left'}/>
|
value={this.state.model.product_name}
|
||||||
|
placeholder={"请输入"}
|
||||||
|
labelWidth={"0px"}
|
||||||
|
maxLength={16}
|
||||||
|
height={"36px"}
|
||||||
|
width={"520px"}
|
||||||
|
alignment={"left"}
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
|
<FormItem
|
||||||
<FormItem id="official_price" labelname="商品官方价" prop="official_price">
|
id="official_price"
|
||||||
|
labelname="商品官方价"
|
||||||
|
prop="official_price"
|
||||||
|
>
|
||||||
<div className="line-value">{this.state.model.official_price}</div>
|
<div className="line-value">{this.state.model.official_price}</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
|
|
||||||
<FormItem id="show_url" prop="show_url" labelname="商品Logo">
|
<FormItem id="show_url" prop="show_url" labelname="商品Logo">
|
||||||
<ImageUpload
|
<ImageUpload
|
||||||
className="zent-image-upload-demo"
|
className="zent-image-upload-demo"
|
||||||
|
@ -529,8 +535,14 @@ export default class adduserinfo extends React.Component{
|
||||||
tips="图片不超过 2M"
|
tips="图片不超过 2M"
|
||||||
maxAmount={1}
|
maxAmount={1}
|
||||||
onError={this.onUploadError}
|
onError={this.onUploadError}
|
||||||
onChange={(e)=>{this.onUploadChange(e)}}
|
onChange={(e) => {
|
||||||
fileList={this.state.model.show_url ? [{'src':this.state.model.show_url}] : null}
|
this.onUploadChange(e);
|
||||||
|
}}
|
||||||
|
fileList={
|
||||||
|
this.state.model.show_url
|
||||||
|
? [{ src: this.state.model.show_url }]
|
||||||
|
: null
|
||||||
|
}
|
||||||
value={this.state.model.show_url}
|
value={this.state.model.show_url}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
@ -544,70 +556,62 @@ export default class adduserinfo extends React.Component{
|
||||||
onError={this.onUploadError}
|
onError={this.onUploadError}
|
||||||
defaultFileList={this.state.model.describe_url}
|
defaultFileList={this.state.model.describe_url}
|
||||||
multiple
|
multiple
|
||||||
onUpload={
|
onUpload={this.onUpload}
|
||||||
this.onUpload
|
onChange={(e) => {
|
||||||
}
|
this.onUploadChange1(e);
|
||||||
onChange={(e)=>{this.onUploadChange1(e)}}
|
}}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem prop="detail_url" labelname="商品详情" id="detail_url" required={false}>
|
<FormItem
|
||||||
|
prop="detail_url"
|
||||||
|
labelname="商品详情"
|
||||||
|
id="detail_url"
|
||||||
|
required={false}
|
||||||
|
>
|
||||||
<ImageUpload
|
<ImageUpload
|
||||||
className="zent-image-upload-demo"
|
className="zent-image-upload-demo"
|
||||||
maxSize={2 * 1024 * 1024}
|
maxSize={2 * 1024 * 1024}
|
||||||
tips="图片不超过 2M"
|
tips="图片不超过 2M"
|
||||||
maxAmount={1}
|
maxAmount={1}
|
||||||
onError={this.onUploadError}
|
onError={this.onUploadError}
|
||||||
fileList={this.state.model.detail_url ? [{'src':this.state.model.detail_url}] : null}
|
fileList={
|
||||||
|
this.state.model.detail_url
|
||||||
|
? [{ src: this.state.model.detail_url }]
|
||||||
|
: null
|
||||||
|
}
|
||||||
onUpload={this.onUpload}
|
onUpload={this.onUpload}
|
||||||
onChange={(e)=>{this.onUploadChange2(e)}}
|
onChange={(e) => {
|
||||||
|
this.onUploadChange2(e);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<div className="mobile">
|
<div className="mobile">
|
||||||
<div className="mobile_top">
|
<div className="mobile_top">
|
||||||
{
|
{this.state.productpic ? (
|
||||||
this.state.productpic ?
|
|
||||||
(
|
|
||||||
<div className="swiper-container">
|
<div className="swiper-container">
|
||||||
<div className="swiper-wrapper" ref="swiperwrapper">
|
<div className="swiper-wrapper" ref="swiperwrapper">
|
||||||
|
{this.state.productpic.map((item, index) => {
|
||||||
{
|
return (
|
||||||
this.state.productpic.map((item, index) => {
|
<div className="swiper-slide">
|
||||||
|
|
||||||
|
|
||||||
return (<div className="swiper-slide" >
|
|
||||||
|
|
||||||
<img src={item.url} />
|
<img src={item.url} />
|
||||||
|
</div>
|
||||||
</div>)
|
);
|
||||||
|
})}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className="swiper-pagination"></div>
|
<div className="swiper-pagination"></div>
|
||||||
</div>
|
</div>
|
||||||
|
) : null}
|
||||||
) : null
|
|
||||||
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div className="mobile_center">
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mobile_center"></div>
|
||||||
<div className="mobile_bottom">
|
<div className="mobile_bottom">
|
||||||
{
|
{this.state.model.detail_url ? (
|
||||||
this.state.model.detail_url ? (<img src={this.state.model.detail_url} />) : null
|
<img src={this.state.model.detail_url} />
|
||||||
}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue