更新分销商

This commit is contained in:
red-deng-deng 2021-11-19 09:39:24 +08:00
parent c739d8704f
commit b5e164562f
5 changed files with 215 additions and 102 deletions

View File

@ -158,10 +158,25 @@ export const getExistName = (name) => {
export const getExistAccount = (name) => {
return req('get', baseurl + "/reseller/exist_account/"+name)
}
//新建分销商-销售人员
export const getPersonnel = () => {
return req('get', baseurl + "/auth/admin/all")
}
//新建分销商-签约公司
export const getCompany = () => {
return req('get', baseurl + "/auth/company/all")
}
//删除分销商
export const delReseller = (id) => {
return req('delete', baseurl + "/reseller/"+id)
}
//修改分销商状态
export const putResellerStatus = (id) => {
return req('put', baseurl + "/reseller/status/"+id)
}
//登录
export const postLogin = (data) => {

View File

@ -30,9 +30,6 @@ export default class form extends React.Component {
let formCompontent = dom.getElementsByClassName("form-compontent")
let rules_item = _.get(this.state.rules, prop)
let item = formCompontent[0].firstChild;
console.log("下拉")
console.log(formCompontent[0])
console.log(item)
if(e)
{
this.removeClass(formCompontent[0])
@ -67,10 +64,7 @@ export default class form extends React.Component {
let doms = dom.getElementsByClassName("form-Item");
for (let i = 0; i < doms.length; i++) {
var com = doms[i].children;
let item = com[com.length - 1]
console.log("item")
console.log(item)
let item = com[com.length - 1]
let formItem = this.props.children[i];
let formItem_com = _.get(formItem, "props.children.props");
let self = this;
@ -172,7 +166,7 @@ export default class form extends React.Component {
}
}
removeClass(compontent) {
console.log(7674646)
// console.log(7674646)
var str = compontent.firstChild.className;
let errors = compontent.getElementsByClassName("error-msg");
@ -181,7 +175,7 @@ export default class form extends React.Component {
errors[0].remove();
}
console.log(errors)
// console.log(errors)
let index = str.indexOf("error");
if (index > -1) {
@ -191,12 +185,12 @@ export default class form extends React.Component {
}
isRequired(value, className, compontent, message) {
console.log("必须")
// console.log("必须")
if (compontent.firstChild.className.indexOf("error") < 0 && compontent.lastChild.className.indexOf("error-msg") < 0) {
var error = document.createElement("div");
error.className = "error-msg"
error.innerHTML = "<span>" + message + "</span>"
console.log(compontent.firstChild)
// console.log(compontent.firstChild)
compontent.firstChild.className += " error"
compontent.appendChild(error)
}
@ -240,7 +234,7 @@ export default class form extends React.Component {
}
validator() {
console.log("表单验证")
// console.log("表单验证")
const dom = ReactDom.findDOMNode(this);
let doms = dom.getElementsByClassName("form-Item");
let self = this;
@ -255,8 +249,8 @@ export default class form extends React.Component {
let o = com[1].children[0];
//formItem对象
let formItem_com = _.get(formItem, "props.children.props");
console.log("测试")
console.log(formItem)
// console.log("测试")
// console.log(formItem)
//对应的验证规则
let rules_item = _.get(this.state.rules, formItem.props.prop)

View File

@ -5,22 +5,44 @@ import Ipt from "../../../components/input/main"
import Form from "../../../components/form/main"
import FormItem from "../../../components/form-item/main"
import "../../../assets/comm.css"
import {Select,Button,ImageUpload ,onUpload,Notify} from "zent"
import {Select,Dialog,Button,ImageUpload ,onUpload,FormInputField,Notify,CopyButton } from "zent"
import Bus from "../../../assets/eventBus.js"
import {getExistName,handelResponse,getExistAccount} from "../../../assets/api.js"
import {getExistName,getCompany,getPersonnel,handelResponse,getExistAccount} from "../../../assets/api.js"
export default class adduserinfo extends React.Component{
constructor(props){
super(props)
this.state={
model:{ //数据模型不可少
fullname:'',
name:'',
account:'',
contacts:'',
contacts_phone:'',
contacts_email:''
},
}
password:'',
contact_name:'',
contact_phone:'',
contact_email:'',
salesman_id:'',
company_id:'',
company_name:'',
identity_type:'',
head_img:''
},
companyList:[],
personnelList:[],
logVisible:false,
fieldArr:[{val:'',prop:''}],//添加项目
fieldTitle:'',
addfield:{},//添加
identityType:[{
key:1,
text:'直客'
},
{
key:2,
text:'友商'
}] //身份类型
}
this.addfieldFn=this.addfieldFn.bind(this);
}
componentDidMount(e){
@ -30,6 +52,7 @@ export default class adduserinfo extends React.Component{
submit(){
this.refs.form1.validator()
console.log(this.state.model);
}
onUploadChange(files){
@ -39,7 +62,7 @@ export default class adduserinfo extends React.Component{
//选择销售人员
onsaleChange(e){
let model2 = this.state.model
model2.sale = e;
model2.salesman_id = e;
this.setState({
model:model2
});
@ -47,7 +70,7 @@ export default class adduserinfo extends React.Component{
//身份类型
onidentityChange(e){
let model2 = this.state.model
model2.identity = e;
model2.identity_type = e;
this.setState({
model:model2
});
@ -56,7 +79,7 @@ export default class adduserinfo extends React.Component{
onsignChange(e)
{
let model2 = this.state.model
model2.sign = e;
model2.company_id = e;
this.setState({
model:model2
});
@ -73,7 +96,7 @@ export default class adduserinfo extends React.Component{
return false;
});
}).catch(err=>{
console.log(err);
});
}
//校验登陆账号名称
@ -92,36 +115,64 @@ export default class adduserinfo extends React.Component{
});
}
cancel(){
let model2 = { //数据模型不可少
fullname:'',
account:'',
contacts:'',
contacts_phone:'',
contacts_email:''
}
let model2 = {}
this.setState({model:model2});
this.refs.form1.cancel();
this.refs.form1.cancel();
}
componentWillMount(){
this.getPersonnelFn();
this.getCompanyFn();
}
//销售人员
getPersonnelFn(){
let _self=this;
getPersonnel().then(res=>{
handelResponse(res,(response,msg)=>{
let personnelList=response.map(item=>{
return {key:item.id,text:item.user_name}
});
_self.setState({personnelList});
},(err)=>{
})
}).catch(err=>{
});
}
setLogVisible(e){
this.setState({logVisible:false})
}
//添加号码或者邮箱
addfieldFn(field){
this.setState({'fieldTitle':field,logVisible:true});
}
//签约公司
getCompanyFn(){
let _self=this;
getCompany().then(res=>{
handelResponse(res,(response,msg)=>{
let companyList=response.map(item=>{
return {key:item.id,text:item.company_name}
});
_self.setState({companyList});
},(err)=>{
})
}).catch(err=>{
});
}
//添加号码
addfieldArr(){
let arr=this.state.fieldArr;
if(arr.length>4){
Notify.clear();
Notify.error('添加的手机号码数量已经达到上限!');
}else{
arr.push({val:'',prop:''});
this.setState({fieldArr:arr});
}
}
render(){
const options = [
{
key: '1',
text: 'Option 1',
},
{
key: '2',
text: 'Option 2',
},
{
key: '3',
text: 'Option 3',
disabled: true,
},
{
key: '4',
text: `君不见,黄河之水天上来,奔流到海不复回`,
},
];
const companyOptions =this.state.companyList;
//校验规则
const rules = {
fullname: [
@ -135,15 +186,16 @@ export default class adduserinfo extends React.Component{
{ type: "regExp", message: "6-16位字符,数字+字母组成,(字母区分大小写)",reg:"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$"}
],
contacts: [
{ type: "required", message: "请输入联系人"},
{ type: "required", message: "请输入联系人"},
{ type: "regExp", message: "2-16字汉字/字母组成",reg:"^([\u4e00-\u9fa5]|[a-zA-Z]){2,16}$"}
],
contacts_phone:[
{ type: "required", message: "请输入联系人手机号"},
{ type: "regExp", message: "格式不对",reg:"^[1][3,5,7,8][0-9]\\d{8}$"}
{ type: "regExp", message: "手机号格式不对",reg:"^[1][3,5,7,8][0-9]\\d{8}$"}
],
contacts_email:[
{ type: "required", message: "请输入联系人邮箱"},
{ type: "regExp", message: "格式不对",reg:"^[1][3,5,7,8][0-9]\\d{8}$"}
{ type: "regExp", message: "联系人邮箱格式不对",reg:"^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$"}
],
sale: [
{ type: "required", message: "请选择销售人员"},
@ -157,91 +209,123 @@ export default class adduserinfo extends React.Component{
{ type: "required", message: "请选择签约公司"},
]
}
//销售人员
return(
<div id="addaccinfo">
<div id="addaccinfo" className="addreseller">
<Form model={this.state.model} rules={rules} ref="form1" className="addform">
<FormItem labelname="分销商全称" prop="fullname" >
<Ipt onChange={(e)=>{
let model2 = this.state.model;
model2.fullname = e;
model2.name = e;
this.setState({model:model2})
}}
onClearItem={(e)=>{
let model2 = this.state.model;
model2.fullname = "";
model2.name = "";
this.setState({model:model2})
}}
onblurFn={(e)=>{this.NameblurFn(e)}}
countShow= {false}
value={this.state.model.fullname} placeholder={"请输入分销商全称"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
value={this.state.model.name} placeholder={"请输入分销商全称"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
</FormItem>
<FormItem labelname="登录账号" prop="account">
<div className="phonet">
<Ipt onChange={(e)=>{
let model2 = this.state.model;
model2.account = e;
this.setState({model:model2})
}}
onblurFn={(e)=>{this.AccountblurFn(e)}}
onClearItem={(e)=>{
let model2 = this.state.model;
model2.account = e;
model2.account = "";
this.setState({model:model2})
}}
countShow= {false}
value={this.state.model.account} placeholder={"请输入登录账号"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
<CopyButton text="customize usage" onCopySuccess={()=>{Notify.clear();Notify.success('复制成功!');}}>
<Button type="primary">复制账号密码</Button>
</CopyButton>
</div>
</FormItem>
<FormItem labelname="密码" prop="pwd">
<Ipt onChange={(e)=>{
let model2 = this.state.model;
model2.pwd = e;
model2.password = e;
this.setState({model:model2})
}}
countShow= {false}
countShow= {true}
onClearItem={(e)=>{
let model2 = this.state.model;
model2.pwd = e;
model2.password = '';
this.setState({model:model2})
}}
value={this.state.model.pwd} placeholder={"请输入密码"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
value={this.state.model.password} placeholder={"请输入密码"}
labelWidth={'0px'} maxLength={16} height={'36px'} width={'520px'} alignment={'left'}/>
</FormItem>
<FormItem labelname="联系人" prop="contacts">
<Ipt onChange={(e)=>{
let model2 = this.state.model;
model2.contacts = e;
model2.contact_name = e;
this.setState({model:model2})
}}
onClearItem={(e)=>{
let model2 = this.state.model;
model2.contacts = e;
model2.contact_name = '';
this.setState({model:model2})
}}
countShow= {false}
value={this.state.model.contacts} placeholder={"请输入联系人"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
countShow= {true}
value={this.state.model.contact_name} placeholder={"请输入联系人"} labelWidth={'0px'} maxLength={16} height={'36px'} width={'520px'} alignment={'left'}/>
</FormItem>
<FormItem labelname="联系人手机号" prop="contacts_phone">
<div className="phonet">
<Ipt onChange={(e)=>{
let model2 = this.state.model;
model2.contacts_phone = e;
model2.contact_phone = e;
this.setState({model:model2})
}}
onClearItem={(e)=>{
let model2 = this.state.model;
model2.contacts_phone = e;
model2.contact_phone = '';
this.setState({model:model2})
}}
countShow= {false}
value={this.state.model.contacts_phone} placeholder={"请输入联系人手机号"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
<Button >添加号码</Button>
value={this.state.model.contact_phone} placeholder={"请输入联系人手机号"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
<Button onClick={()=>this.addfieldArr()} >添加号码</Button>
</div>
</FormItem>
{
this.state.fieldArr.map((item,i)=>{
return(
<FormItem labelname="分销商全称" prop={item.id} id={item.id}>
<Ipt onChange={(e)=>{
let model2 = this.state.model;
model2.name = e;
this.setState({model:model2})
}}
onClearItem={(e)=>{
let model2 = this.state.model;
model2.name = "";
this.setState({model:model2})
}}
onblurFn={(e)=>{this.NameblurFn(e)}}
countShow= {false}
value={this.state.model.name} placeholder={"请输入分销商全称"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
</FormItem>
)
})
}
<FormItem labelname="联系人邮箱" prop="contacts_email">
<div className="phonet">
<Ipt onChange={(e)=>{
@ -253,33 +337,33 @@ export default class adduserinfo extends React.Component{
onClearItem={(e)=>{
let model2 = this.state.model;
model2.contacts_email = e;
model2.contacts_email = '';
this.setState({model:model2})
}}
countShow= {false}
value={this.state.model.contacts_email} placeholder={"请输入联系人邮箱"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
<Button>添加邮箱</Button>
value={this.state.model.contacts_email} placeholder={"请输入联系人邮箱"} labelWidth={'0px'} maxLength={50} height={'36px'} width={'520px'} alignment={'left'}/>
<Button onClick={()=>this.addfieldFn('添加邮箱')}>添加邮箱</Button>
</div>
</FormItem>
<FormItem prop="sale" labelname="销售人员" id="sale" >
<Select options={options} clearable placeholder="请选择销售人员" value={this.state.model.sale} onChange={(e)=>{
<Select options={this.state.personnelList} clearable placeholder="请选择销售人员" value={this.state.model.salesman_id} onChange={(e)=>{
this.onsaleChange(e)
Bus.emit('change',"sale" ,e);
}} popupWidth="360px" width="520px"/>
</FormItem>
<FormItem prop="identity" labelname="身份类型" id="identity" >
<Select options={options} clearable placeholder="请选择身份类型" value={this.state.model.identity} onChange={(e)=>{
<Select options={this.state.identityType} clearable placeholder="请选择身份类型" value={this.state.model.identity_type} onChange={(e)=>{
this.onidentityChange(e)
Bus.emit('change',"identity" ,e);
}} popupWidth="360px" width="520px"/>
</FormItem>
<FormItem prop="sign" labelname="签约公司" id="sign" >
<Select options={options} clearable placeholder="请选择签约公司" value={this.state.model.sign} onChange={(e)=>{
<Select options={this.state.companyList} clearable placeholder="请选择签约公司" value={this.state.model.company_id} onChange={(e)=>{
this.onsignChange(e)
Bus.emit('change',"sign" ,e);
}} popupWidth="360px" width="520px"/>
}} popupWidth="520px" width="520px"/>
</FormItem>
</Form>
@ -296,7 +380,7 @@ export default class adduserinfo extends React.Component{
/>
<Button className="putImage">上传头像</Button>
</div>
</div>
</div>
</div>
)
}

View File

@ -10,4 +10,13 @@
}
.zent-select-v2-popup{
width: 250px !important;
}
.addreseller .zent-btn-primary[data-zv="9.11.0"]{
width: 120px;
background: #fff!important;
color: #ccc!important;
border: none;
}
.zent-dialog-r-anchor .zent-dialog-r[data-zv="9.11.0"]{
margin-top: -180px;
}

View File

@ -5,7 +5,7 @@ import _ from "lodash";
import "./list.less"
import { Button ,Dialog,Notify,Sweetalert,Switch ,Dropdown,DropdownPosition,DropdownClickTrigger,Icon,MenuItem,DropdownContent,Menu } from 'zent';
import "../../../assets/comm.css"
import {getResellerList,handelResponse,delReseller} from "../../../assets/api.js"
import {getResellerList,handelResponse,delReseller,putResellerStatus} from "../../../assets/api.js"
import Ipt from "../../../components/input/main"
import Grid from "../../../components/gird/main.js"
import TabPage from "../../../components/tabPage/main.js"
@ -165,27 +165,30 @@ export default class acclist extends React.Component{
sessionStorage.setItem('breaknav',JSON.stringify(activerou));
}
onSwitchChange(status,row){
let self = this;
console.log(status)
let _self = this;
Sweetalert.confirm({
type:'warning',
closeBtn:true,
title:'确认操作',
content: <p>是否改变当前数据状态</p>,
onConfirm:()=>{ this.changeState(status,row)},
content: <p>是否{row.status==1?'启用':'停用'}{row.name}</p>,
onConfirm:()=>{
putResellerStatus(row.id).then(res=>{
handelResponse(res,(response,msg)=>{
Notify.clear();
Notify.success(msg);
_self.getReseller();
},(err)=>{
})
}).catch(err=>{
});
},
onCancel: this.onCancel,
className:'questModal',
parentComponent: this
});
}
changeState(status,row){
let self = this;
let id = _.findIndex(self.state.distdata,(o)=>{return o.id == row.id});
self.state.distdata[id].status = status;
self.setState({distdata:self.state.distdata})
}
pageChange(){
@ -220,8 +223,10 @@ export default class acclist extends React.Component{
getReseller(){
let _self=this;
let {page,limit,key_word}=_self.state;
let data={page,limit,key_word}
let data={page,limit}
if(key_word){
data.key_word=key_word;
}
getResellerList(data).then(res=>{
handelResponse(res,(response,msg)=>{
const reseller_data=response.data;
@ -238,7 +243,13 @@ export default class acclist extends React.Component{
componentWillMount(){
this.getReseller();
}
// 监听组件内部状态的变化:
componentDidUpdate(prevProps,prevState){
// 参数分别为改变之前的数据状态对象
if(prevState.key_word!=this.state.key_word &&!this.state.key_word){
this.getReseller();
}
}
render(){
const { current, pageSize } = this.state;
return(
@ -247,8 +258,8 @@ export default class acclist extends React.Component{
<p className="distable dflexj">
<Button type="primary" icon="plus" onClick={this.clickFn.bind(this)}>新建分销商</Button>
{/* <Button type="info">批量操作</Button> */}
<Ipt wordSearch={this.sureFn.bind(this)} onChange={(e)=>this.setState({key_word:e})} icon="search" placeholder={"请输入分销商名称、分销商编号、手机号、联系人进行搜索"} countShow={false} height={'36px'} width={'260px'} alignment={'left'}/>
</p>
<Ipt onClearItem={(e)=>{this.setState({key_word:''})}} wordSearch={this.sureFn.bind(this)} onChange={(e)=>this.setState({key_word:e})} value={this.state.key_word} icon="search" placeholder={"请输入充值账号、key、分销商等关键字进行搜索"} countShow={false} height={'36px'} width={'260px'} alignment={'left'}/>
</p>
<Filterbar filterList={this.state.filterList} menuList={this.state.menuList}></Filterbar>
<div>
@ -274,7 +285,7 @@ export default class acclist extends React.Component{
ComponentHandler={(com,rowData)=>{
if(com == "name")
{
return <Switch size="small" checked={rowData.status} onChange={(e)=>{this.onSwitchChange(e,rowData)}} ></Switch>;
return <Switch size="small" checked={rowData.status==2?false:true} onChange={(e)=>{this.onSwitchChange(e,rowData)}} ></Switch>;
}
if(com == "opearo")
{