From d5bd8e1244807b4f23b28bbf3afddc05fdeb4512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=A3=9A?= <849005670@qq.com> Date: Mon, 29 Nov 2021 21:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/gird/main.js | 25 +++++-- src/pages/exchangecode/add/add.js | 1 + src/pages/plan/add/add.js | 2 +- src/pages/plan/add/add.less | 7 +- src/pages/plan/add/step1.js | 12 ++-- src/pages/plan/add/step2.js | 107 ++++++++++++++++++++++++++++-- 6 files changed, 134 insertions(+), 20 deletions(-) diff --git a/src/components/gird/main.js b/src/components/gird/main.js index abf24ea1..e05239f2 100644 --- a/src/components/gird/main.js +++ b/src/components/gird/main.js @@ -1,4 +1,5 @@ import React from 'react' +import ReactDom from 'react-dom'; import "./main.css" import { Icon, @@ -160,7 +161,9 @@ export default class menu extends React.Component { } + componentDidMount() { + } //多选 AllCheckChange = (e) => { @@ -257,10 +260,14 @@ export default class menu extends React.Component { } componentWillReceiveProps(nextProps) { - this.setState({tableData: nextProps.tableData}); + + if(this.state.tableData != nextProps.tableData) + { + console.log("") + this.setState({tableData: nextProps.tableData}); this.setState({page: nextProps.page}); - - this.setState( {dataCount:nextProps.dataCount}) + this.setState( {dataCount:nextProps.dataCount}) + } } onConfirm = () => { @@ -325,8 +332,14 @@ export default class menu extends React.Component { } = this.props; var column_width = 0; - const auto_column_width = this.state.Column.length > 12 ? "100px" : 100 / (this.state.Column.length - 2) + "%"; - return (
+ let auto_column_width = this.state.Column.length > 12 ? "100px" : 100 / (this.state.Column.length - 2) + "%"; + + + + + return (
{ this.props.isMultiple ? ( < div className = "th-td" style = { @@ -496,7 +509,7 @@ export default class menu extends React.Component { key = { c_index } > { - ComponentHandler(child.prop, item) + ComponentHandler(child.prop, item,index) }
) ) diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index e108f571..47c414f2 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -424,6 +424,7 @@ export default class acclist extends React.Component{ window.history.back() },1000); },(err)=>{ + Notify.success(err); }) }) diff --git a/src/pages/plan/add/add.js b/src/pages/plan/add/add.js index a62147d7..c1d7bbad 100644 --- a/src/pages/plan/add/add.js +++ b/src/pages/plan/add/add.js @@ -20,7 +20,7 @@ export default class add extends React.Component{ curstep:1, menuList:[ {id:1,title:"营销计划",child:[{step:1,title:"新建计划"}]}, - {id:2,title:"key",child:[{step:1,title:"生产key"},{step:2,title:"绑定卡券"}]}, + {id:2,title:"key",child:[{step:1,title:"生成key"},{step:2,title:"绑定卡券"}]}, {id:3,title:"落地页",child:[{step:1,title:"绑定落地页"}]}, ], phone_list:[], diff --git a/src/pages/plan/add/add.less b/src/pages/plan/add/add.less index cc4b5644..fb16971c 100644 --- a/src/pages/plan/add/add.less +++ b/src/pages/plan/add/add.less @@ -22,7 +22,7 @@ overflow-y: auto; } .action-panel{ - width: 80%; + width: 88%; margin: 0 auto; height: auto; margin-bottom: 60px; @@ -244,4 +244,7 @@ width: 50px !important; height: 50px !important; } -} \ No newline at end of file +} +// .zent-datepicker-trigger{ +// width: 280px !important; +// } \ No newline at end of file diff --git a/src/pages/plan/add/step1.js b/src/pages/plan/add/step1.js index 78e5cee1..bea6e5e9 100644 --- a/src/pages/plan/add/step1.js +++ b/src/pages/plan/add/step1.js @@ -20,7 +20,7 @@ export default class acclist extends React.Component{ type:2, reseller:null, return_id:"1", - date_time:"" + date_time:[ moment().add(30, 'minutes').format("YYYY-MM-DD HH:mm:ss"),""] }, reseller_option:[], @@ -95,10 +95,11 @@ export default class acclist extends React.Component{ let valide = false; if(this.refs.form1.validator()) { - - - - + if(this.state.model.date_time[1] == "") + { + Notify.error("结束日期不能为空") + return; + } let data = {}; data.title = this.state.model.title; data.type = parseInt(this.state.model.type); @@ -262,6 +263,7 @@ export default class acclist extends React.Component{ className="zent-datepicker-plan" showTime={{ format: 'HH:mm:ss', defaultTime: [moment().format("HH:mm:ss"), '23:59:59'], }} + format="YYYY-MM-DD HH:mm:ss" value={this.state.model.date_time} onChange={(e)=>{ diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js index 9a597ac6..0466111a 100644 --- a/src/pages/plan/add/step2.js +++ b/src/pages/plan/add/step2.js @@ -55,6 +55,7 @@ export default class acclist extends React.Component{ distdata:[], oldData:null, uploading:false, + rowIndex:-1, } } @@ -148,8 +149,10 @@ export default class acclist extends React.Component{ this.setState({codeInfo:codeInfo}) this.setState({tempdata:[]}) this.setState({drawerVisible:true}) + this.setState({rowIndex:-1}) } closeDraw(){ + this.setState({drawerVisible:false}) } addProduct(){ @@ -277,10 +280,20 @@ export default class acclist extends React.Component{ }) temp.product = arr; - let tempdata = this.state.distdata; - tempdata.push(temp) - console.log(tempdata) - this.setState({distdata:tempdata}) + + + if(this.state.rowIndex > -1) + { + console.log("编辑") + this.state.distdata[this.state.rowIndex] = temp; + this.setState({distdata:this.state.distdata}) + } + else{ + console.log("新增") + let tempdata = this.state.distdata; + tempdata.push(temp) + this.setState({distdata:tempdata}) + } } @@ -493,6 +506,75 @@ export default class acclist extends React.Component{ this.state.tempdata[rowIndex].contract_price = value; this.setState({tempdata:this.state.tempdata}) } + + + rowItemClick(row,rowIndex){ + console.log("编辑数据") + console.log(rowIndex) + console.log(row) + + + + + // begin_time: "2021-11-30 00:00:00" + // describe: "10" + // end_time: "2021-11-30 23:59:59" + // product: Array(1) + // 0: + // contract_price: "10" + // cost_price: "163.8000" + // describe_url: "https://lsxd-yunshanfu.oss-cn-hangzhou.aliyuncs.com/common_image/20211129/eb98efd2fee424466ffc1b29c83e9f0a.png" + // official_price: "218.0000" + // product_id: 22 + // product_name: "10" + // product_type: 1 + // quantity: "1000" + // show_url: "https://lsxd-yunshanfu.oss-cn-hangzhou.aliyuncs.com/common_image/20211129/0bfcda5e4dad7cb9bbae12787569c3cc.png" + // [[Prototype]]: Object + // length: 1 + // [[Prototype]]: Array(0) + // quantity: "1000" + // range: "10" + // title: "dasdas" + + + + + + + let codeInfo ={ //数据模型不可少 + code_name:row.title, + issued:row.quantity,//发放总量 + describe:row.describe, + date_time:[row.begin_time,row.end_time], + range:row.range + } + + let arr = _.map(row.product,(res)=>{ + let obj = {}; + obj.key = res.product_id; + obj.text= res.product_name; + return obj; + }) + this.setState({rankoptions:arr}) + + this.setState({rank:arr}) + this.setState({codeInfo:codeInfo}) + this.setState({rowIndex:rowIndex}) + let temp = _.map(row.product,(o)=>{ + + o.checked = true; + return o + }) + + + this.setState({tempdata:temp}) + this.setState({drawerVisible:true}) + + + + + } render(){ @@ -536,7 +618,14 @@ export default class acclist extends React.Component{ name: 'restrict', type: "slot", width:'auto', - } + }, + { + title: '操作', + prop: 'edit', + name: 'edit', + type: "slot", + width:'auto', + }, ]; //校验规则 const rules = { @@ -753,12 +842,18 @@ export default class acclist extends React.Component{ checkChange ={(selection)=>{ }} - ComponentHandler={(com,rowData)=>{ + ComponentHandler={(com,rowData,rowIndex)=>{ if(com == "restrict") { return {this.onRestrict(e,rowData)}} /> } + if(com == "edit") + { + return + } + + }} />