This commit is contained in:
姜棚 2021-12-02 18:23:27 +08:00
parent 0eeae4b376
commit 55b2cda665
5 changed files with 84 additions and 31 deletions

View File

@ -42,8 +42,17 @@ export default class adduserinfo extends React.Component{
} }
//获取直连天下商品映射信息 //获取直连天下商品映射信息
getProductInfo(){ getProductInfo(){
getProductInfoSelect().then((res)=>{ // getProductInfoSelect().then((res)=>{
handelResponse(res,(req,msg)=>{ // handelResponse(res,(req,msg)=>{
let productList = sessionStorage.getItem("productsList")
console.log(productList)
productList = JSON.parse(productList);
let product_data = [] let product_data = []
if(sessionStorage.getItem("productData")) if(sessionStorage.getItem("productData"))
{ {
@ -53,8 +62,8 @@ export default class adduserinfo extends React.Component{
let checked_product= product_data ? product_data : []; let checked_product= product_data ? product_data : [];
let arr = []; let arr = [];
this.setState({products:req.data}) this.setState({products:productList})
_.map(req.data,(res)=>{ _.map(productList,(res)=>{
let obj = {}; let obj = {};
obj.key = res.id; obj.key = res.id;
obj.text= res.title; obj.text= res.title;
@ -108,9 +117,9 @@ export default class adduserinfo extends React.Component{
},(err)=>{ // },(err)=>{
}) // })
}) // })
} }
cancel(){ cancel(){

View File

@ -7,6 +7,7 @@ import FormItem from "../../../components/form-item/main"
import {Select,Button,ImageUpload ,onUpload,Sweetalert,RadioButton,RadioGroup,Notify} from "zent" import {Select,Button,ImageUpload ,onUpload,Sweetalert,RadioButton,RadioGroup,Notify} from "zent"
import Bus from "../../../assets/eventBus.js" import Bus from "../../../assets/eventBus.js"
import {getProductInfoSelect,handelResponse,uploadImg} from "../../../assets/api.js" import {getProductInfoSelect,handelResponse,uploadImg} from "../../../assets/api.js"
import { FixedSizeList } from 'react-window';
import _ from "lodash"; import _ from "lodash";
@ -36,17 +37,25 @@ export default class adduserinfo extends React.Component{
componentDidMount(e){ componentWillMount(e){
//获取商品信息 //获取商品信息
this.getProductInfo() this.getProductInfo()
} }
//获取直连天下商品映射信息 //获取直连天下商品映射信息
getProductInfo(){ getProductInfo(){
getProductInfoSelect().then((res)=>{ // getProductInfoSelect().then((res)=>{
handelResponse(res,(req,msg)=>{ // handelResponse(res,(req,msg)=>{
let productList = sessionStorage.getItem("productsList")
productList = JSON.parse(productList);
console.log("测试数据商品",productList)
let product_data = [] let product_data = []
if(sessionStorage.getItem("productData")) if(sessionStorage.getItem("productData"))
{ {
@ -56,8 +65,8 @@ export default class adduserinfo extends React.Component{
let checked_product= product_data ? product_data : []; let checked_product= product_data ? product_data : [];
let arr = []; let arr = [];
this.setState({products:req.data}) this.setState({products:productList})
_.map(req.data,(res)=>{ _.map(productList,(res)=>{
let obj = {}; let obj = {};
obj.key = res.id; obj.key = res.id;
obj.text= res.title; obj.text= res.title;
@ -74,9 +83,9 @@ export default class adduserinfo extends React.Component{
this.setState({"productOption":arr}) this.setState({"productOption":arr})
},(err)=>{ // },(err)=>{
}) // })
}) // })
} }
async submit(){ async submit(){
@ -238,7 +247,7 @@ export default class adduserinfo extends React.Component{
<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 options={this.state.productOption} width={500} placeholder="请选择商品" value={this.state.cur_product} onChange={(e)=>{
this.onProductChange(e) this.onProductChange(e)
Bus.emit('change',"product" ,e); Bus.emit('change',"product" ,e);
}} }}

View File

@ -3,7 +3,8 @@ import React, { Component,useEffect,useState, useRef } from 'react';
import "./login.less" import "./login.less"
import { Route, withRouter } from "react-router-dom"; import { Route, withRouter } from "react-router-dom";
import "../../assets/comm.css" import "../../assets/comm.css"
import {postLogin,getAllEnum,handelResponse,getVerify} from "../../assets/api.js" import _ from "lodash";
import {postLogin,getAllEnum,handelResponse,getVerify,getProductInfoSelect,} from "../../assets/api.js"
import { import {
FormInputField, FormInputField,
Form, Form,
@ -34,6 +35,16 @@ function FormDom(props) {
sessionStorage.setItem("authorization",response.authorization) sessionStorage.setItem("authorization",response.authorization)
Notify.clear(); Notify.clear();
Notify.success(msg); Notify.success(msg);
getProductList();
sessionStorage.setItem('showflag',true); sessionStorage.setItem('showflag',true);
let menuList=response.menu; let menuList=response.menu;
if(response.menu&&response.menu.length>0){ if(response.menu&&response.menu.length>0){
@ -79,6 +90,10 @@ function FormDom(props) {
}); });
}, []); }, []);
const forgetFn =()=>{ const forgetFn =()=>{
Notify.clear(); Notify.clear();
Notify.warn('请联系管理员') Notify.warn('请联系管理员')
@ -115,6 +130,20 @@ function FormDom(props) {
} }
xhr.send() xhr.send()
} }
const getProductList=()=>{
getProductInfoSelect().then((res)=>{
handelResponse(res,(req,msg)=>{
console.log()
sessionStorage.setItem("productsList",JSON.stringify( req.data) )
},(err)=>{
})
})
}
return ( return (
<> <>

View File

@ -45,8 +45,11 @@ export default class adduserinfo extends React.Component{
//获取直连天下商品映射信息 //获取直连天下商品映射信息
getProductInfo(){ getProductInfo(){
getProductInfoSelect().then((res)=>{ // getProductInfoSelect().then((res)=>{
handelResponse(res,(req,msg)=>{ // handelResponse(res,(req,msg)=>{
let productList = sessionStorage.getItem("productsList")
productList = JSON.parse(productList);
let product_data = [] let product_data = []
if(sessionStorage.getItem("productData")) if(sessionStorage.getItem("productData"))
{ {
@ -56,8 +59,8 @@ export default class adduserinfo extends React.Component{
let checked_product= product_data ? product_data : []; let checked_product= product_data ? product_data : [];
let arr = []; let arr = [];
this.setState({products:req.data}) this.setState({products:productList})
_.map(req.data,(res)=>{ _.map(productList,(res)=>{
let obj = {}; let obj = {};
obj.key = res.id; obj.key = res.id;
obj.text= res.title; obj.text= res.title;
@ -74,9 +77,9 @@ export default class adduserinfo extends React.Component{
this.setState({"productOption":arr}) this.setState({"productOption":arr})
},(err)=>{ // },(err)=>{
}) // })
}) // })
} }
async submit(){ async submit(){

View File

@ -45,9 +45,12 @@ export default class adduserinfo extends React.Component{
//获取直连天下商品映射信息 //获取直连天下商品映射信息
getProductInfo(){ getProductInfo(){
getProductInfoSelect().then((res)=>{ // getProductInfoSelect().then((res)=>{
handelResponse(res,(req,msg)=>{ // handelResponse(res,(req,msg)=>{
let product_data = [] let product_data = []
let productList = sessionStorage.getItem("productsList")
productList = JSON.parse(productList);
if(sessionStorage.getItem("productData")) if(sessionStorage.getItem("productData"))
{ {
product_data = JSON.parse( sessionStorage.getItem("productData")) ; product_data = JSON.parse( sessionStorage.getItem("productData")) ;
@ -56,8 +59,8 @@ export default class adduserinfo extends React.Component{
let checked_product= product_data ? product_data : []; let checked_product= product_data ? product_data : [];
let arr = []; let arr = [];
this.setState({products:req.data}) this.setState({products:productList})
_.map(req.data,(res)=>{ _.map(productList,(res)=>{
let obj = {}; let obj = {};
obj.key = res.id; obj.key = res.id;
obj.text= res.title; obj.text= res.title;
@ -74,9 +77,9 @@ export default class adduserinfo extends React.Component{
this.setState({"productOption":arr}) this.setState({"productOption":arr})
},(err)=>{ // },(err)=>{
}) // })
}) // })
} }
async submit(){ async submit(){