diff --git a/src/pages/exchangecode/commodity/goodedit.less b/src/pages/exchangecode/commodity/goodedit.less
new file mode 100644
index 00000000..fc4c1b0f
--- /dev/null
+++ b/src/pages/exchangecode/commodity/goodedit.less
@@ -0,0 +1,56 @@
+.zent-image-upload-item-delete{
+ display: inline-block !important;
+}
+.mobile{
+ width: 375px;
+ height: 667px;
+ max-height: 667px;
+ background-color: #fafafa;
+ position: absolute;
+ top: 80px;
+ right: 60px;
+ 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;
+}
\ No newline at end of file
diff --git a/src/pages/exchangecode/commodity/goodscreate.js b/src/pages/exchangecode/commodity/goodscreate.js
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/pages/exchangecode/product/add.js b/src/pages/exchangecode/product/add.js
index 99d0db81..4b83a173 100644
--- a/src/pages/exchangecode/product/add.js
+++ b/src/pages/exchangecode/product/add.js
@@ -63,6 +63,8 @@ export default class adduserinfo extends React.Component{
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
@@ -76,7 +78,7 @@ export default class adduserinfo extends React.Component{
let defaultPic = []
let arr = []
- console.log("描述图",model_temp.describe_url)
+
let temp_productpic = this.state.productpic
for(let i = 0;i < model_temp.describe_url.length;i++)
{
@@ -168,26 +170,28 @@ export default class adduserinfo extends React.Component{
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
})
-
-
- console.log("提交数据url",urls)
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
-
- console.log("临时存储",temp)
-
sessionStorage.setItem('productData', JSON.stringify(temp));
}
}
else{
+ console.log("模型")
+ let model = this.state.model;
+
+
+ let urls = _.map(this.state.productpic,(o)=>{
+ return o.url
+ })
+ model.describe_url = urls
+
+ this.setState({model:model})
+
if(this.state.model.show_url == "")
{
@@ -223,6 +227,7 @@ export default class adduserinfo extends React.Component{
product_name:cur_product.title,
show_url:picItem ? picItem.pic : "",
describe_url: "",
+ detail_url:'',
map_product_name:cur_product.title,
account_type:cur_product.account_type
}
@@ -347,26 +352,6 @@ export default class adduserinfo extends React.Component{
}
this.setState({productpic:temp_arr})
}
- // console.log("swiperwrapper",this.refs.swiperwrapper)
- // this.refs.swiperwrapper.innerHTML=""
-
-
- // this.mySwiper.destroy();
-
- // this.mySwiper = new Swiper('.swiper-container', {
- // slidesPerView: 1,
- // centeredSlides: true,
- // loop : true,
- // autoplay : 3000,
- // observer: true, // 修改swiper自己或子元素时,自动初始化swiper
- // observeParents: true, // 修改swiper的父元素时,自动初始化swiper
- // pagination: '.swiper-pagination',
- // watchSlidesVisibility: true,
-
- // })
- // this.mySwiper.update();
- // let swiperBox = this.refs.swiperwrapper
-
};
onUploadError = (type, data) => {
if (type === 'overMaxAmount') {
diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js
index de6f7733..f47df116 100644
--- a/src/pages/plan/add/step2.js
+++ b/src/pages/plan/add/step2.js
@@ -56,6 +56,7 @@ export default class acclist extends React.Component{
uploading:false,
rowIndex:-1,
isload:props.isload ? props.isload : false,
+ product_title:"新建商品"
}
}
@@ -155,6 +156,7 @@ export default class acclist extends React.Component{
}
addProduct(){
this.setState({drawerVisible2:true})
+ this.setState({productData:null})
}
async productSubmit(){
let visible = await this.refs.product.submit()
@@ -269,7 +271,8 @@ export default class acclist extends React.Component{
obj.official_price= item.official_price;
obj.quantity = item.quantity;
obj.show_url = item.show_url;
- obj.describe_url = item.describe_url;
+ obj.describe_url = item.describe_url.toString();
+ obj.detail_url = item.detail_url;
obj.account_type = item.account_type;
obj.map_product_name = item.map_product_name;
return obj
@@ -528,6 +531,12 @@ export default class acclist extends React.Component{
}
+ productEditShow(rowData){
+ this.setState({drawerVisible2:true})
+ this.setState({productData:rowData})
+ this.setState({product_title:"编辑商品"})
+ }
+
render(){
@@ -640,20 +649,13 @@ export default class acclist extends React.Component{
type: "slot",
width:'auto',
},
- {
- title: '商品Logo',
- prop: 'show_url',
- name: 'show_url',
- type: "slot",
- width:'auto',
- },
- {
- title: '商品图',
- prop: 'describe_url',
- name: 'describe_url',
- type: "slot",
- width:'auto',
- },
+ {
+ title: '操作',
+ prop: 'edit',
+ name: 'edit',
+ type: "slot",
+ width:'auto',
+ }
];
@@ -963,33 +965,15 @@ export default class acclist extends React.Component{
return
{this.onPriceChange(e,rowData,rowIndex)}} />
}
- if(com == "show_url")
+ if(com == "edit")
{
- return
{this.onUploadChange1(e,rowData)}}
- onUpload={this.onUpload}
- defaultFileList={[{'src':rowData.show_url}]}
- value={rowData.show_url}
- />
+ return {
+ this.productEditShow(rowData)
+
+ }} >编辑
}
- if(com == "describe_url")
- {
- return {this.onUploadChange2(e,rowData)}}
- onUpload={this.onUpload}
- defaultFileList={ rowData.describe_url ? [{'src':rowData.describe_url}] : null}
- value={rowData.describe_url}
- />
- }
+
}}
@@ -1002,8 +986,8 @@ export default class acclist extends React.Component{
@@ -1017,7 +1001,7 @@ export default class acclist extends React.Component{
diff --git a/src/pages/plan/product/add.js b/src/pages/plan/product/add.js
index e2cedfb4..170f7a44 100644
--- a/src/pages/plan/product/add.js
+++ b/src/pages/plan/product/add.js
@@ -8,9 +8,11 @@ import {Select,Button,ImageUpload ,onUpload,Sweetalert,RadioButton,RadioGroup,No
import Bus from "../../../assets/eventBus.js"
import {getProductInfoSelect,handelResponse,uploadImg} from "../../../assets/api.js"
import _ from "lodash";
-
+import Swiper from 'swiper/dist/js/swiper.js'
+import 'swiper/dist/css/swiper.min.css'
export default class adduserinfo extends React.Component{
+ mySwiper = null
constructor(props){
super(props)
this.state={
@@ -25,6 +27,7 @@ export default class adduserinfo extends React.Component{
show_url:"",
describe_url:"",
map_product_name:"",
+ detail_url:""
},
cur_product:null,
productOption:[],
@@ -32,63 +35,189 @@ export default class adduserinfo extends React.Component{
show_url:"",
describe_url:"",
loadshow:false,
+ productpic:[],
}
}
+ componentDidMount() {
+ this.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',
+
+ })
+
+ }
+ 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.show_url = model_temp.show_url
+ 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 !="")
+ {
+ pics = model_temp.describe_url.split(',')
+ }
+ else{
+ pics = []
+ }
+
+ }
+ console.log("默认图",pics)
+ for(let i = 0;i < pics.length;i++)
+ {
+ let obj = {}
+ let nameArr = pics[i].split('/');
+ obj.name = nameArr[5]
+ obj.src = pics[i];
+ defaultPic.push(obj)
+ let obj2={
+ name:nameArr[5],
+ url:pics[i]
+ }
+ temp_productpic.push(obj2)
+ }
+ this.setState({temp_productpic})
+
+ model.describe_url = defaultPic == [] ? "" : defaultPic
+ model.stock = model_temp.stock
+ model.usage = model_temp.usage
+ model.map_product_name = model_temp.map_product_name
+ model.account_type = model_temp.account_type
+ this.setState({model:model})
+
+ }
+ this.getProductInfo()
+ }
+
+ componentWillReceiveProps() {
+
+ this.mySwiper.update();
+ }
-
- componentDidMount(e){
- //获取商品信息
-
- this.getProductInfo()
-
- }
//获取直连天下商品映射信息
getProductInfo(){
- // getProductInfoSelect().then((res)=>{
- // handelResponse(res,(req,msg)=>{
- let product_data = []
- let productList = sessionStorage.getItem("productsList")
-
- productList = JSON.parse(productList);
- 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 obj = {};
- obj.key = res.id;
- obj.text= res.title;
- obj.disabled = checked_product.findIndex((item)=>{return item.product_id == res.id}) > -1;
- if(obj.disabled)
- {
-
- }
-
- arr.push(obj)
-
- return obj;
- })
-
+ let product_data = []
+ let productList = sessionStorage.getItem("productsList")
+
+ productList = JSON.parse(productList);
+ 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 obj = {};
+ obj.key = res.id;
+ obj.text= res.title;
+ obj.disabled = checked_product.findIndex((item)=>{return item.product_id == res.id}) > -1;
+ if(obj.disabled)
+ {
+
+ }
+
+ arr.push(obj)
+
+ return obj;
+ })
+
this.setState({"productOption":arr})
-
- // },(err)=>{
- // })
- // })
+
+ 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})
+ }
}
async submit(){
if(this.refs.form1.validator())
{
+
+
+ console.log("提交新增数据",this.props.data)
+
+ if(this.props.data)
+ { let temp = []
+
+ console.log("编辑",this.state.model)
+ if(sessionStorage.getItem("productData"))
+ {
+
+ temp = JSON.parse(sessionStorage.getItem("productData"));
+
+ let index = temp.findIndex((item)=>{return item.product_id ==this.props.data.product_id})
+
+ console.log("账号类型",this.state.model.account_type)
+
+ temp[index].product_name = this.state.model.product_name
+ 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
+ console.log(77777)
+ let urls = _.map(this.state.productpic,(o)=>{
+ return o.url
+ })
+ console.log(8888)
+ temp[index].describe_url = urls
+ temp[index].map_product_name = this.state.model.map_product_name
+
+ sessionStorage.setItem('productData', JSON.stringify(temp));
+ return true;
+ }
+ }
+ else{
+
+ let model = this.state.model;
+
+ console.log("商品",this.state.model)
+ let urls = _.map(this.state.productpic,(o)=>{
+ return o.url
+ })
+ model.describe_url = urls
+
+ this.setState({model:model})
if(this.state.model.show_url == "")
{
Notify.error(`请上传商品Logo`);
@@ -104,18 +233,16 @@ export default class adduserinfo extends React.Component{
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})
- console.log(window.goods)
- console.log(cur_product.product_category_id)
+ console.log("当前商品",cur_product)
let picItem = window.goods.find((item)=>{return item.id == cur_product.product_category_id})
-
- console.log(picItem)
-
let model2 = {...this.state.model}
model2.product_id = cur_product.id;
model2.product_type=cur_product.type;
@@ -128,7 +255,7 @@ export default class adduserinfo extends React.Component{
model2.show_url=picItem ? picItem.pic : "";
model2.describe_url= "";
model2.map_product_name= cur_product.title;
-
+ model2.detail_url = "";
// let model2 = {
// product_id:cur_product.id,
// product_type:cur_product.type,
@@ -152,28 +279,14 @@ export default class adduserinfo extends React.Component{
onUpload = (file, report) => {
return new Promise((resolve, reject) => {
-
- console.log(file)
- console.log(report)
- // let count = file.size;
- // const update = () => {
- // console.log(count)
- // if(count < 0)
- // {
- // resolve();
- // }
- // else{
- // count -= 10000;
- // report(10);
- // setTimeout(update, 100);
- // }
- // };
- // setTimeout(update, 100);
+
});
};
-
+
+
+
onUploadChange(files){
console.log(files)
if(files.length > 0 )
@@ -183,19 +296,19 @@ export default class adduserinfo extends React.Component{
Notify.error(`图片大小不能超过 20KB`);
return;
}
- 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)=>{
-
- })
- });
+ 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;
@@ -240,6 +353,109 @@ export default class adduserinfo extends React.Component{
Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`);
}
};
+
+
+ onUploadChange3(files,e){
+ let arr =_.map(files,(o)=>{
+ return o.name
+ })
+ 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={
+ name:files[i].name,
+ url:path
+ }
+ let arr = this.state.productpic;
+ arr.push(obj)
+ this.setState({arr})
+ },(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
+ console.log(temp_arr)
+ console.log("删除前的数据",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)
+ }
+ }
+ console.log("删除过后的数组",this.state.productpic)
+ 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})
+ }
+
+ this.mySwiper.update();
+ };
+
+ 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(){
//校验规则
@@ -359,19 +575,70 @@ export default class adduserinfo extends React.Component{
className="zent-image-upload-demo"
maxSize={5 * 1024 * 1024}
tips="建议尺寸 30*30,图片不超过 20KB"
- maxAmount={1}
- onChange={(e)=>{this.onUploadChange1(e)}}
-
- fileList={this.state.model.describe_url ? [{'src':this.state.model.describe_url}] : null}
- value={this.state.model.describe_url}
+ maxAmount={9}
+ onChange={(e)=>{this.onUploadChange3(e)}}
+ sortable
+ defaultFileList={this.state.model.describe_url }
+ multiple
/>
-
+
+ {this.onUploadChange2(e)}}
+ />
+
+
+
+
+
+ {
+ this.state.productpic ?
+ (
+
+
+
+ {
+ this.state.productpic.map((item, index) => {
+
+
+ return (
+
+
+
+
)
+
+ })
+ }
+
+
+
+
+
+
+ ) : null
+
+ }
+
+
+
+
+ {
+ this.state.model.detail_url ? (
) : null
+ }
+
+
+
)