Merge branch 'dev'

This commit is contained in:
北海一刀 2021-11-10 16:11:34 +08:00
commit 82144187a8
11 changed files with 555 additions and 170 deletions

View File

@ -0,0 +1,43 @@
import React from 'react'
import "./main.less"
import { Icon } from 'zent';
import _ from "lodash";
import Menu from "../menu/main.js"
export default class filterSelect extends React.Component {
constructor(props) {
super(props);
this.state = {
children :props.children
}
}
componentDidUpdate(prevProps,prevState){
if(prevState.children!=this.state.children)
{
console.log("更新")
}
}
render() {
const {labelname,prop} = this.props
return (
<div className ="form-Item">
<div className="form-label" style={{width:"180px"}}>
{labelname}
</div>
<div className="form-compontent">
{this.state.children}
</div>
</div>
)
}
}

View File

197
src/components/form/main.js Normal file
View File

@ -0,0 +1,197 @@
import React from 'react'
import "./main.less"
import {
Icon
} from 'zent';
import _ from "lodash";
import Menu from "../menu/main.js"
export default class form extends React.Component {
constructor(props) {
super(props);
this.state = {
children: props.children,
model: props.model,
rules: props.rules
}
}
componentDidMount() {
let doms = document.getElementsByClassName("form-Item");
for (let i = 0; i < doms.length; i++) {
var com = doms[i].children;
console.log(com)
let item = com[com.length - 1]
let formItem = this.props.children[i];
let formItem_com = _.get(formItem, "props.children.props");
let self = this;
let input_compontent = com[1].children[0].getElementsByTagName("input")
let o = com[1].children[0];
let rules_item = _.get(self.state.rules, formItem.props.prop)
if (input_compontent.length > 0) {
input_compontent[0].oninput = function(e) {
let closebtn = input_compontent[0].parentNode.children[1];
if (closebtn) {
closebtn.onclick = function(e) {
self.isRequired(formItem_com.value, o.className, item, rules_item[i].message);
}
}
for (let i = 0; i < rules_item.length; i++) {
if (e.target.value == "") {
if (rules_item[i].type == "required") {
self.removeClasss(item);
self.isRequired(formItem_com.value, o.className, item, rules_item[i].message);
}
} else {
if (rules_item[i].type == "regExp") {
var regu = rules_item[i].reg;
var re = new RegExp(regu);
let s = e.target.value;
if (re.test(s)) {
console.log("满足")
self.removeClasss(item)
} else {
console.log("不满足")
self.isRequired(formItem_com.value, o.className, item, rules_item[i].message);
}
} else {
self.removeClasss(item)
}
}
}
}
input_compontent[0].onchange = function(e) {
if (e.target.value == "") {
self.isRequired(formItem_com.value, o.className, item, rules_item[i].message);
} else {
self.removeClasss(item)
}
}
input_compontent[0].onblur = function(e) {
if (e.target.value == "") {
self.isRequired(formItem_com.value, o.className, item, rules_item[i].message);
} else {
self.removeClasss(item)
}
}
}
}
}
removeClasss(compontent) {
var str = compontent.firstChild.className;
console.log(str)
let index = str.indexOf("error");
console.log(index)
if (index > -1) {
compontent.firstChild.className = str.replace(" error", "");
console.log(compontent.lastChild)
compontent.removeChild(compontent.lastChild);
}
}
isRequired(value, className, compontent, message) {
console.log(compontent.firstChild.className)
console.log(value)
if (compontent.firstChild.className.indexOf("error") < 0) {
console.log(className)
var error = document.createElement("div");
error.className = "error-msg"
error.innerHTML = "<span>" + message + "</span>"
compontent.firstChild.className += " error"
compontent.appendChild(error)
}
}
componentWillReceiveProps(newProps) {
}
componentDidUpdate(prevProps, prevState) {
let formItem = this.props.children[0];
let com = _.get(formItem, "props.children.props");
if (prevState.children != this.state.children) {
console.log("更新")
}
}
validator(){
console.log("表单验证")
let doms = document.getElementsByClassName("form-Item");
for (let i = 0; i < doms.length; i++) {
var com = doms[i].children;
let item = com[com.length - 1]
let formItem = this.props.children[i];
let o = com[1].children[0];
//formItem对象
let formItem_com = _.get(formItem, "props.children.props");
//对应的验证规则
let rules_item = _.get(this.state.rules, formItem.props.prop)
if(rules_item)
{
for(let j =0; j < rules_item.length ;j++)
{
if (formItem_com.value == "") {
if (rules_item[j].type == "required") {
this.removeClasss(item);
this.isRequired(formItem_com.value, o.className, item, rules_item[j].message);
}
} else {
console.log("规则验证")
if (rules_item[j].type == "regExp") {
var regu = rules_item[j].reg;
var re = new RegExp(regu);
let s = formItem_com.value;
console.log("验证条件")
console.log(s)
if (re.test(s)) {
console.log("满足")
this.removeClasss(item)
} else {
console.log("不满足")
this.isRequired(formItem_com.value, o.className, item, rules_item[j].message);
}
} else {
this.removeClasss(item)
}
}
}
}
}
}
render() {
return ( <
div className = "filterComponent" > {
this.state.children
} <
/div>
)
}
}

View File

@ -0,0 +1,34 @@
.form-label{
width: 180px;
height: 100%;
display: flex;
align-items: center;
}
.form-Item{
width: 100%;
display: flex;
height: 60px;
flex-wrap: nowrap;
margin-bottom: 5px;
align-items: center;
}
.form-compontent{
width: 80%;
height: 100%;
padding-top: 20px;
}
.error{
border-color: #ed3b3b !important;
}
.error input{
border-color: #ed3b3b !important;
}
.error-msg{
font-size: 14px;
display: block;
padding-top: 1PX;
color: #ed3b3b;
}

View File

@ -136,16 +136,22 @@ import classNames from 'classnames'
})
// 按钮形状类型
return (<div className="iptfillself">
{
this.props.labelWidth == "0px" ? null :(
<div className="label" style={{width:labelWidth,textAlign:alignment}}>
<span className="labeltip">{labelText}</span>
{required?<font className="warning">*</font>:null}
</div>
)
}
<div className="iptlabel">
<div className="iptright">
{icon? <Icon type="search" className="iconType"/>:null}
<input type={kind} onBlur={this.losefofn} onFocus={this.focusFn} style={{resize:'none'}} value={this.state.iptVal} maxLength={maxLength} onChange={this.clearContent} onInput={this.handleInputChange} style={{height:height,lineHeight:height,width:width,textOverflow:'ellipsis'}} className={classes} placeholder={placeholder?placeholder:'请输入'}/>
<input name={this.props.name} type={kind} onBlur={this.losefofn} onFocus={this.focusFn} style={{resize:'none'}} value={this.state.iptVal} maxLength={maxLength} onChange={this.clearContent} onInput={this.handleInputChange} style={{height:height,lineHeight:height,width:width,textOverflow:'ellipsis'}} className={classes} placeholder={placeholder?placeholder:'请输入'}/>
<div className="ipticonR">
{kind=='password'?<span className="showpwd" onClick={()=>this.showpwd(this)}>-</span>:null}
{clearShow==true&&this.state.iptVal?<svg onClick={this.clearItem.bind(this)} viewBox="0 0 16 16" width="16px" height="16px"><circle fill="#AAAFBA" fill-rule="evenodd" cx="8" cy="8" r="8"></circle><path d="M5.333 5.333l5.334 5.334M10.667 5.333l-5.334 5.334" stroke="#FFF" stroke-linecap="square"></path></svg>:null}

View File

@ -48,8 +48,10 @@ export default class add extends React.Component{
<div className="plan-title">营销计划</div>
<div id="step1" className="step1">
<Card style={{ width:'100%' }} title={this.state.step1_pagetitle}>
<Step1/>
<Step1/>
</Card>
</div>
</div>

View File

@ -58,3 +58,21 @@
.iptfillself{
margin-bottom: 0px;
}
.zent-datepicker-plan{
}
.zent-datepicker-plan .zent-datepicker-trigger{
width: 520px !important;
border: none !important;
border-bottom: 1px solid #e0e0e0 !important;
}

View File

@ -0,0 +1,137 @@
import ReactDOM from 'react-dom';
import React, { Component } from 'react';
import { HashRouter as Router, Route, Link } from "react-router-dom";
import { Button ,Tabs, CombinedDateRangePicker,Select,Input} from 'zent';
import Ipt from "../../../components/input/main"
import validateFramework from 'validate-framework';
const TabPanel = Tabs.TabPanel;
export default class acclist extends React.Component{
constructor(props){
super(props)
this.state={
combinedValue:null,
}
}
componentDidMount(e){
const validator = new validateFramework({
formName: 'basicForm',
fields: {
email: {
rules: 'required | isEmail | maxLength(32)',
messages: "不能为空 | 请输入合法邮箱 | 不能超过 {{param}} 个字符"
},
phone: {
rules: 'isPhone',
messages: "手机号: {{value}} 不合法"
}
},
callback: function (result, error) {
// 阻止表单提交
validator.preventSubmit();
// do something...
}
});
validator.validate();
}
render(){
const type = [
<TabPanel key="1" tab="活动" id="1" >
</TabPanel>,
<TabPanel key="2" tab="仅兑换" id="2">
</TabPanel>,
];
const return_val = [
<TabPanel key="1" tab="直接返回" id="1" >
</TabPanel>,
<TabPanel key="2" tab="卡单" id="2">
</TabPanel>,
];
const options = [
{
key: '1',
text: 'Option 1',
},
{
key: '2',
text: 'Option 2',
},
{
key: '3',
text: 'Option 3',
disabled: true,
},
{
key: '4',
text: `君不见,黄河之水天上来,奔流到海不复回`,
},
];
return(
<div id="step1">
<form name="basicForm">
<div className="form-Item">
<div className="form-compontent">
<Input placeholder="请输入名字" name="email" />
</div>
</div>
<div className="form-Item">
<div className="form-label" style={{width:"180px"}}>
计划类型
</div>
<div className="form-compontent">
<Tabs
type="button">
{type}
</Tabs>
</div>
</div>
<div className="form-Item">
<div className="form-label" style={{width:"180px"}}>
计划类型
</div>
<div className="form-compontent">
<Select options={options} placeholder="选择一项" width={515} />
</div>
</div>
<div className="form-Item">
<div className="form-label" style={{width:"180px"}}>
计划充值返回
</div>
<div className="form-compontent">
<Tabs type="button">
{return_val}
</Tabs>
</div>
</div>
<div className="form-Item">
<div className="form-label" style={{width:"180px"}}>
开始~结束时间
</div>
<div className="form-compontent">
<CombinedDateRangePicker
className="zent-datepicker-plan"
value={this.state.combinedValue}
showTime={{
format: 'HH:mm:ss',
defaultTime: ['12:00:00', '23:59:59'],
}}
format="YYYY-MM-DD HH:mm:ss"
onChange={this.onChangeCombinedDate}
/>
</div>
</div>
</form>
</div>
)
}
}

View File

@ -1,162 +1,121 @@
import React from "react"
import "./add.less"
import ReactDOM from 'react-dom';
import React, { Component } from 'react';
import { HashRouter as Router, Route, Link } from "react-router-dom";
import { Button ,Tabs, CombinedDateRangePicker,Select,Input} from 'zent';
import Ipt from "../../../components/input/main"
import {
Form,
FormStrategy,
Radio,
Checkbox,
Notify,
ImageUpload,
Validators,
FormSelectField,
FormUploadField,
FormImageUploadField,
Button,
FormRadioGroupField,
FormInputField,
RadioGroup,
FormSingleUploadField,
RadioButton,
FieldUtils,
FieldSet
} from 'zent';
import validateFramework from 'validate-framework';
import Form from "../../../components/form/main"
import FormItem from "../../../components/form-item/main"
const TabPanel = Tabs.TabPanel;
function Step1(){
let fomadd ={
val1:""
export default class acclist extends React.Component{
constructor(props){
super(props)
this.state={
combinedValue:null,
model:{
name:"",
type:"",
reseller:"",
return_id:"",
date_time:""
}
}
}
const form = Form.useForm(FormStrategy.View);
const onSubmit = React.useCallback(form => {
const value = form.getValue();
console.log(value)
}, []);
function sectionValidator(values) {
componentDidMount(e){
}
console.log(values)
if(values.account == "")
{
return {
name: 'error',
message: '请输入账号',
};
}
else if(values.tel == "")
{
return {
name: 'error',
message: '清输入电话',
};
submit(){
this.refs.form1.validator()
}
else if(values.password == "")
{
return {
name: 'error',
message: '清输入电话',
};
}
}
function Tel(){
const tel = Form.useField('tel', "");
return (
<Ipt onChange={FieldUtils.makeChangeHandler(
tel,
)} placeholder={"请输入电话"} labelWidth={'90px'} maxLength={10} height={'36px'} width={'520px'} labelText={'电话:'} alignment={'left'}/>
);
}
function Password(){
const password = Form.useField('password', "");
return (
<Ipt onChange={FieldUtils.makeChangeHandler(
password,
)} placeholder={"请输入密码"} labelWidth={'90px'} maxLength={10} height={'36px'} width={'520px'} labelText={'密码:'} alignment={'left'}/>
);
}
function PlanName() {
const account = Form.useField('account', "");
return (
<Ipt onChange={FieldUtils.makeChangeHandler(
account,
)} placeholder={"请输入营销计划名称"} labelWidth={'120px'} maxLength={10} height={'36px'} width={'520px'} labelText={'营销计划名称'} alignment={'left'}/>
);
}
function ReSeller() {
const realname = Form.useField('realname', "");
return (
<Ipt onChange={FieldUtils.makeChangeHandler(
realname,
)} placeholder={"请选择分销商"} labelWidth={'90px'} maxLength={10} height={'36px'} width={'520px'} labelText={'分销商'} alignment={'left'}/>
);
}
return (
<div className="addaccinfo">
<Form
className="addform"
form={form}
layout="horizontal"
scrollToError
onSubmit={onSubmit}
>
<FieldSet name="account" validators={[sectionValidator]}>
<PlanName/>
</FieldSet>
<FormSelectField
name="resller"
label="分销商:"
required
validators={[Validators.required('请选择分销商')]}
props={{
placeholder:"请选择分销商",
options: [
{ key: 1, text: '分销商1' },
{ key: 2, text: '分销商2' },
],
}}
/>
<div className="zent-form-actions">
<Button type="primary" htmlType="submit">
提交
</Button>
<Button type="normal" htmlType="reset" onClick={() => form.model.clearError()}>
取消
</Button>
render(){
const rules = {
name: [
{ type: "required", message: "请输入变更主题"},
{ type: "regExp", message: "格式不对",reg:"^[1][3,5,7,8][0-9]\\d{8}$"},
],
reseller: [
{ type: "required", message: "请选择分销商"},
],
date_time: [
{ type: "required", message: "请选择时间"},
],
}
const type = [
<TabPanel key="1" tab="活动" id="1" >
</TabPanel>,
<TabPanel key="2" tab="仅兑换" id="2">
</TabPanel>,
];
const return_val = [
<TabPanel key="1" tab="直接返回" id="1" >
</TabPanel>,
<TabPanel key="2" tab="卡单" id="2">
</TabPanel>,
];
const options = [
{
key: '1',
text: 'Option 1',
},
{
key: '2',
text: 'Option 2',
},
{
key: '3',
text: 'Option 3',
disabled: true,
},
{
key: '4',
text: `君不见,黄河之水天上来,奔流到海不复回`,
},
];
return(
<div id="step1">
<Form model={this.state.model} rules={rules} ref="form1">
<FormItem labelname="营销计划名称" prop="name" >
<Ipt onChange={(e)=>{
let model2 = this.state.model;
model2.name = e;
this.setState({model:model2})
}} value={this.state.model.name} placeholder={"请输入"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/>
</FormItem>
<FormItem labelname=" 计划类型" prop="type">
<Tabs
type="button">
{type}
</Tabs>
</FormItem>
<FormItem labelname="分销商" prop="reseller">
<Select options={options} placeholder="选择一项" width={515} value={this.state.model.reseller} />
</FormItem>
<FormItem labelname=" 计划充值返回" prop="return_id">
<Tabs type="button">
{return_val}
</Tabs>
</FormItem>
<FormItem labelname="开始~结束时间" prop="date_time">
<CombinedDateRangePicker
className="zent-datepicker-plan"
value={this.state.model.date_time}
showTime={{
format: 'HH:mm:ss',
defaultTime: ['12:00:00', '23:59:59'],
}}
format="YYYY-MM-DD HH:mm:ss"
onChange={this.onChangeCombinedDate}
/>
</FormItem>
</Form>
</div>
</Form>
</div>
);
}
export default Step1;
)
}
}

View File

@ -117,20 +117,6 @@ export default class acclist extends React.Component{
}
}
clickFn(){
// this.props.history.push('/plan-add');
// sessionStorage.setItem('pathname2','/plan-add')
// let activerou=[{items:[
// {
// "path": "/plan-list",
// "name": "营销计划管理"
// },
// {
// "path": "/plan-add",
// "name": "新建营销计划"
// }
// ]}]
// sessionStorage.setItem('breaknav',JSON.stringify(activerou));
let link = window.location.href.replace(window.location.hash,"#/plan-create");
window.open(link, "_blank")

View File

@ -0,0 +1,3 @@
.zent-tabs{
margin-top: 15px;
}