diff --git a/src/components/gird/main.js b/src/components/gird/main.js index 83f3b4f1..03581977 100644 --- a/src/components/gird/main.js +++ b/src/components/gird/main.js @@ -1,658 +1,581 @@ import React from 'react' -import ReactDom from 'react-dom'; -import "./main.css" -import { - Icon, - Menu, - Checkbox, - Switch, - Sweetalert, - Notify -} from 'zent'; -import _ from "lodash"; -import Pagination from "../pagination/main.js" -import GridEdit from "../gridEdit/main.js" -import Input from "../input/main.js" -import GridCheckBar from "../gridCheckBar/main.js" - - +import ReactDom from 'react-dom' +import './main.css' +import { Icon, Menu, Checkbox, Switch, Sweetalert, Notify } from 'zent' +import _ from 'lodash' +import Pagination from '../pagination/main.js' +import GridEdit from '../gridEdit/main.js' +import Input from '../input/main.js' +import GridCheckBar from '../gridCheckBar/main.js' //tabbar组件机构{title:"",index:""} //props {} // type : normal slot -//tableColumn 表格列属性结构 type width,label,background,textAlign - +//tableColumn 表格列属性结构 type width,label,background,textAlign export default class menu extends React.Component { + static defaultProps = { + isShowPageBar: true, //是否显示页码 + isMultiple: true, + isSwitch: true, + page: '', + headBackgroud: '', + spliteColor: '#f9fafc', + countbarVisible: true, + maxheight: 400, + isBorder: false, + Column: [ + { + title: '推广计划名称', + prop: 'name', + width: '300px', + textAlign: 'flex-start', + type: 'normal', + sort: false, + total: false, + valueType: 'text' + }, + { + title: '操作', + prop: 'edit', + width: '220px', + textAlign: 'flex-start', + type: 'slot', + sort: false, + total: false, + valueType: 'text' + }, + { + title: '曝光量', + prop: 'num1', + width: 'auto', + textAlign: 'left', + type: 'normal', + sort: true, + total: true, + valueType: 'number' + }, + { + title: '点击量', + prop: 'num2', + width: 'auto', + textAlign: 'left', + type: 'normal', + sort: true, + total: true, + valueType: 'number' + }, + { + title: '点击率', + prop: 'num3', + width: 'auto', + textAlign: 'left', + type: 'normal', + sort: true, + total: true, + valueType: 'percentage' + }, + { + title: '点击均价', + prop: 'price', + width: 'auto', + textAlign: 'left', + type: 'normal', + sort: true, + total: true, + valueType: 'price' + }, + { + title: '花费', + prop: 'totalprice', + width: 'auto', + textAlign: 'left', + type: 'normal', + sort: true, + total: true, + valueType: 'price' + } + ], + tableData: [ + { + id: 0, + name: '推广计划-2021-10-19 17:43', + num1: 0, + num2: 0, + num3: 0, + price: 0, + totalprice: 0 + } + ], + emptyText: '抱歉,暂无相关数据记录', + dataCount: 0, + curIndex: 0 + } - static defaultProps = { - isShowPageBar:true, //是否显示页码 - isMultiple: true, - isSwitch: true, - page:'', - headBackgroud: "", - spliteColor: "#f9fafc", - countbarVisible:true, - maxheight:400, - isBorder:false, - Column: [{ - title: "推广计划名称", - prop: "name", - width: "300px", - textAlign: "flex-start", - type: "normal", - sort: false, - total: false, - valueType: "text" - }, - { - title: "操作", - prop: "edit", - width: "220px", - textAlign: "flex-start", - type: "slot", - sort: false, - total: false, - valueType: "text" - }, - { - title: "曝光量", - prop: "num1", - width: "auto", - textAlign: "left", - type: "normal", - sort: true, - total: true, - valueType: "number" - }, - { - title: "点击量", - prop: "num2", - width: "auto", - textAlign: "left", - type: "normal", - sort: true, - total: true, - valueType: "number" - }, - { - title: "点击率", - prop: "num3", - width: "auto", - textAlign: "left", - type: "normal", - sort: true, - total: true, - valueType: "percentage" - }, - { - title: "点击均价", - prop: "price", - width: "auto", - textAlign: "left", - type: "normal", - sort: true, - total: true, - valueType: "price" - }, - { - title: "花费", - prop: "totalprice", - width: "auto", - textAlign: "left", - type: "normal", - sort: true, - total: true, - valueType: "price" - }, - ], - tableData: [{ - id: 0, - name: "推广计划-2021-10-19 17:43", - num1: 0, - num2: 0, - num3: 0, - price: 0, - totalprice: 0 - } - ], - emptyText: "抱歉,暂无相关数据记录", - dataCount:0, - curIndex:0, - - } + constructor(props) { + super(props) + let tableData = [] + // 如果是多选 + // if (props.isMultiple) { + // tableData = _.map(props.tableData, (item) => { + // return item.checked = false; + // }) + // } + // if (props.isSwitch) { + // tableData = _.map(props.tableData, (item) => { + // return item.switched = false; + // }) + // } - constructor(props) { - super(props); - let tableData = []; - // 如果是多选 - // if (props.isMultiple) { - // tableData = _.map(props.tableData, (item) => { - // return item.checked = false; - // }) - // } + this.state = { + switchLoading: false, + allChecked: false, + tableData: props.tableData, + Column: props.Column, + dataTotal: props.dataTotal, + indeterminate: false, + pageNum: 0, + pageCount: props.dataCount, + pageLoading: false, + editShow: false, + postion: null, + historyrow_id: null, + curRow: null, + emptyText: props.emptyText || '抱歉,暂无相关数据记录', + edit_title: '', + edit_column: '' + } + } - // if (props.isSwitch) { - // tableData = _.map(props.tableData, (item) => { - // return item.switched = false; - // }) - // } + scrollFunc = function (e) {} + componentDidMount() { + const dom = ReactDom.findDOMNode(this) + if (dom.attachEvent) { + dom.attachEvent('onmousewheel', this.scrollFunc) + } + //Firefox使用addEventListener添加滚轮事件 + if (dom.addEventListener) { + //firefox + dom.addEventListener('DOMMouseScroll', this.scrollFunc, false) + } + //Safari与Chrome属于同一类型 + dom.onmousewheel = this.scrollFunc + } + //多选 + AllCheckChange = (e) => { + if (this.state.tableData.length == 0) { + return + } - this.state = { - switchLoading: false, - allChecked: false, - tableData: props.tableData, - Column: props.Column, - dataTotal:props.dataTotal, - indeterminate: false, - pageNum:0, - pageCount:props.dataCount, - pageLoading:false, - editShow:false, - postion:null, - historyrow_id:null, - curRow:null, - emptyText: "抱歉,暂无相关数据记录", - edit_title:"", - edit_column:"" - } - } - - - scrollFunc = function (e) { + this.setState({ + indeterminate: false + }) + this.setState({ + allChecked: e.target.checked + }) - } - - componentDidMount() { - const dom = ReactDom.findDOMNode(this); - if(dom.attachEvent){ - dom.attachEvent('onmousewheel',this.scrollFunc); - } - //Firefox使用addEventListener添加滚轮事件 - if (dom.addEventListener) {//firefox - dom.addEventListener('DOMMouseScroll', this.scrollFunc, false); - } - //Safari与Chrome属于同一类型 - dom.onmousewheel = this.scrollFunc; - } - - //多选 - AllCheckChange = (e) => { - - if(this.state.tableData.length == 0) - { - return; - } - - this.setState({ - indeterminate: false - }) - this.setState({ - allChecked: e.target.checked - }) + let tableData = _.map(this.state.tableData, (item) => { + return (item.checked = e.target.checked) + }) + this.setState({ + tableData: this.state.tableData + }) + let selection = _.filter(this.state.tableData, (item) => { + return item.checked == true + }) + this.props.checkChange(selection) + } - let tableData = _.map(this.state.tableData, (item) => { - return item.checked = e.target.checked; - }) - this.setState({ - tableData: this.state.tableData - }) - let selection = _.filter(this.state.tableData, (item) => { - return item.checked == true; - }) - this.props.checkChange(selection) - } - - - allChecked(status) - { + allChecked(status) { + this.setState({ allChecked: status }) + let tabledata = _.map(this.state.tableData, (item) => { + item.checked = false + return item + }) + this.setState({ + indeterminate: false + }) + this.setState({ tableData: tabledata }) + } - this.setState({allChecked:status}) - let tabledata = _.map(this.state.tableData,(item)=>{ - item.checked =false - return item - }) - this.setState({ - indeterminate: false - }) - this.setState({tableData:tabledata}) - - } - - - - - checkChange(index, e){ - this.state.tableData[index].checked = e.target.checked; - this.setState({ - tableData: this.state.tableData - }) - let selection = _.filter(this.state.tableData, (item) => { - return item.checked == true; - }) - this.props.checkChange(selection) - - if (selection.length == this.state.tableData.length ) { - this.setState({ - indeterminate: false - }) - this.setState({ - allChecked: true - }) - } - else if(selection.length == 0) - { - this.setState({ - indeterminate: false - }) - this.setState({ - allChecked: false - }) - } - else { - this.setState({ - indeterminate: true - }) - } + checkChange(index, e) { + this.state.tableData[index].checked = e.target.checked + this.setState({ + tableData: this.state.tableData + }) + let selection = _.filter(this.state.tableData, (item) => { + return item.checked == true + }) + this.props.checkChange(selection) - } - - getCellValue(column,rowData){ - let value = _.get(rowData,column) - return value||value==0 ? value : "-" - } - - switchChange(index,e) { + if (selection.length == this.state.tableData.length) { + this.setState({ + indeterminate: false + }) + this.setState({ + allChecked: true + }) + } else if (selection.length == 0) { + this.setState({ + indeterminate: false + }) + this.setState({ + allChecked: false + }) + } else { + this.setState({ + indeterminate: true + }) + } + } - this.state.tableData[index].switched = e; - this.setState({ - tableData: this.state.tableData - }) + getCellValue(column, rowData) { + let value = _.get(rowData, column) + return value || value == 0 ? value : '-' + } - - } + switchChange(index, e) { + this.state.tableData[index].switched = e + this.setState({ + tableData: this.state.tableData + }) + } - editRow(e,column, row) { - this.setState({edit_title:column.title}) - this.setState({edit_column:column.prop}) - - this.setState({curRow:row}) - - let pos = {} - pos.x = e.clientX; - pos.y = e.clientY; - - this.setState({postion:pos}); - - if(this.state.historyrow_id == row.id) - { - this.setState({editShow:!this.state.editShow}) - } - else{ - this.setState({editShow:true}) - this.setState({historyrow_id:row.id}) - } - + editRow(e, column, row) { + this.setState({ edit_title: column.title }) + this.setState({ edit_column: column.prop }) - } - - componentWillReceiveProps(nextProps) { - - if(this.state.tableData != nextProps.tableData) - { + this.setState({ curRow: row }) - this.setState({tableData: nextProps.tableData}); - this.setState({page: nextProps.page}); - this.setState( {dataCount:nextProps.dataCount}) - } - } + let pos = {} + pos.x = e.clientX + pos.y = e.clientY - onConfirm = () => { - - } + this.setState({ postion: pos }) - - onCancel = () => { - - } - total = (e) => { - let sum = 0 - if (e.total) { - for (let i = 0; i < this.state.tableData.length; i++) { + if (this.state.historyrow_id == row.id) { + this.setState({ editShow: !this.state.editShow }) + } else { + this.setState({ editShow: true }) + this.setState({ historyrow_id: row.id }) + } + } - let row = this.state.tableData[i] - let num = row[e.prop] == "" ? 0 : row[e.prop]; - sum += num; - } - if (e.valueType == "percentage") { - return sum <= 0 ? "0.00%" : sum.toFixed(2) + "%"; - } - if (e.valueType == "price") { - return sum <= 0 ? "0.00" : sum.toFixed(2); - } + componentWillReceiveProps(nextProps) { + if (this.state.tableData != nextProps.tableData) { + this.setState({ tableData: nextProps.tableData }) + this.setState({ page: nextProps.page }) + this.setState({ dataCount: nextProps.dataCount }) + } + } - } else { - return ""; - } - return sum; - } - //当前页码条数 - onCountChange(e){ - this.props.countChange(e) - this.setState({pageCount:e}) - } - gridPageLoad(){ - this.setState({pageLoading:true}) - setTimeout(()=>{ - this.setState({pageLoading:false}) - },500) - } - pageShow(e){ - - } - gridEditChange(e){ - - } - getSelectData(){ - - let selectList = this.state.tableData.filter((o)=>{return o.checked == true}) - selectList = _.map(selectList, o => _.omit(o, ['checked'])); - return selectList - - } - rowItemClick(index){ - console.log(index) - - this.setState({curIndex:index}) - } + onConfirm = () => {} - - render() { - const { - data, - ComponentHandler - } = this.props; - var column_width = 0; - - 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 = { - { - "width": "50px", - "textAlign": "left", - "background":this.props.headBackgroud, - } - } > - < /Checkbox> < / - div > ) : null - } { - this.props.isSwitch ? ( < div className = "th-td" - style = { - { - "width": "30px", - "textAlign": "left", - "visibility": "hidden", - "background":this.props.headBackgroud, - } - } > - { - this.switchChange() - } - } >
) : null - } + onCancel = () => {} + total = (e) => { + let sum = 0 + if (e.total) { + for (let i = 0; i < this.state.tableData.length; i++) { + let row = this.state.tableData[i] + let num = row[e.prop] == '' ? 0 : row[e.prop] + sum += num + } + if (e.valueType == 'percentage') { + return sum <= 0 ? '0.00%' : sum.toFixed(2) + '%' + } + if (e.valueType == 'price') { + return sum <= 0 ? '0.00' : sum.toFixed(2) + } + } else { + return '' + } + return sum + } + //当前页码条数 + onCountChange(e) { + this.props.countChange(e) + this.setState({ pageCount: e }) + } + gridPageLoad() { + this.setState({ pageLoading: true }) + setTimeout(() => { + this.setState({ pageLoading: false }) + }, 500) + } + pageShow(e) {} + gridEditChange(e) {} + getSelectData() { + let selectList = this.state.tableData.filter((o) => { + return o.checked == true + }) + selectList = _.map(selectList, (o) => _.omit(o, ['checked'])) + return selectList + } + rowItemClick(index) { + console.log(index) - { + this.setState({ curIndex: index }) + } - this.state.Column.map((item, index) => { - column_width = item.width == "auto" ? auto_column_width : item.width; - return (
{ - item.title - } + render() { + const { data, ComponentHandler } = this.props + var column_width = 0 - { - item.sort ? ( < - Icon type = "arrow-down" / > - ) : null - }
+ let auto_column_width = + this.state.Column.length > 12 + ? '100px' + : 100 / (this.state.Column.length - 2) + '%' - ) - }) - }
- - - -
-
-
数据加载中,请耐心等待
-
-
{ - this.state.tableData.length == 0 ? ( < div className = "empty-text" > { - this.state.emptyText - } < /div>): ( - this.state.tableData.map((item, index) => { - return (
{this.rowItemClick(index)}} - style = { - { - "background": index % 2 == 0 ? this.props.spliteColor : "#ffffff" - } - } - key = { - index - } > { - this.props.isMultiple ? ( < div className = "td" - style = { - { - "width": "50px", - "textAlign": "left" - } - } > - { - this.checkChange(index, e) - } + return ( +
+
+
+ {' '} + {this.props.isMultiple ? ( +
+ + {' '} + {' '} +
+ ) : null}{' '} + {this.props.isSwitch ? ( +
+ { + this.switchChange() + }}> + {' '} + {' '} +
+ ) : null} + {this.state.Column.map((item, index) => { + column_width = + item.width == 'auto' ? auto_column_width : item.width + return ( +
+ {' '} + {item.title} + {item.sort ? : null}{' '} +
+ ) + })}{' '} +
- } >
) : null - } - { - this.props.isSwitch ? ( < div className = "td" - style = { - { - "width": "30px", - "textAlign": "left" - } - } > - { - this.switchChange(index,e) - } - } - loading = { - this.state.switchLoading - } > < /Switch> < /div > ) : null - } - { - this.state.Column.map((child, c_index) => { - column_width = child.width == "auto" ? auto_column_width : child.width; - return ( - child.type == "normal" ? ( < - div className = "td" - style = { - { - "width": column_width, - "justifyContent": child.textAlign - } - } - key = { - c_index - } > { - this.getCellValue(child.prop,item) - } - -
- // this.editRow(e,child, item) - // } - // > - // - ) : (
{ - ComponentHandler(child.prop, item,index) - }
- ) - ) +
+
+
数据加载中,请耐心等待
+
+
+ {' '} + {this.state.tableData.length == 0 ? ( +
{this.state.emptyText}
+ ) : ( + this.state.tableData.map((item, index) => { + return ( +
{ + this.rowItemClick(index) + }} + style={{ + background: + index % 2 == 0 ? this.props.spliteColor : '#ffffff' + }} + key={index}> + {' '} + {this.props.isMultiple ? ( +
+ { + this.checkChange(index, e) + }}> + {' '} + {' '} +
+ ) : null} + {this.props.isSwitch ? ( +
+ { + this.switchChange(index, e) + }} + loading={this.state.switchLoading}> + {' '} + {' '} +
+ ) : null} + {this.state.Column.map((child, c_index) => { + column_width = + child.width == 'auto' ? auto_column_width : child.width + return child.type == 'normal' ? ( +
+ {' '} + {this.getCellValue(child.prop, item)} +
+ ) : ( + // this.editRow(e,child, item) + // } + // > + // +
+ {' '} + {ComponentHandler(child.prop, item, index)}{' '} +
+ ) + })}{' '} +
+ ) + }) + )} + {this.state.editShow ? ( + { + this.setState({ editShow: false }) + }} + onOk={(row) => { + this.setState({ editShow: false }) + console.log('当前数据行', row) + }} + row={this.state.curRow} + /> + ) : null} +
+
- }) +
+ {' '} +
+ 总计({this.state.tableData.length} + 条数据): +
+ {this.state.Column.map((child, c_index) => { + column_width = + child.width == 'auto' ? auto_column_width : child.width + return ( +
+ {' '} + {this.total(child)}{' '} +
+ ) + })}{' '} +
+
- }
- ) - }) - ) - } - { - this.state.editShow ? - ({ - this.setState({editShow:false}) } } onOk={(row)=>{ this.setState({editShow:false});console.log("当前数据行",row) }} row={this.state.curRow} - />) : null - } -
- - -
-
- -
- 总计({ - this.state.tableData.length - } - 条数据): -
- { - this.state.Column.map((child, c_index) => { - column_width = child.width == "auto" ? auto_column_width : child.width; - return (
{ - this.total(child) - }
- ) - }) - } < /div> - -
- - { - this.props.isShowPageBar ? ( -
- { - this.gridPageLoad() - this.props.pageChange(e); - } - } - page={this.props.page} - pageFn={(e)=>this.setState({page:e})} - onNextClick = { - (e) => { - - this.gridPageLoad() - this.props.pageChange(e); - } - } - onJumpPage={ - (e)=>{ - - this.gridPageLoad() - this.props.pageChange(e); - } - } - onCountChange ={ - (e)=>{ - this.onCountChange(e) - } - }> - - -
):null - - } - - - ) - } + {this.props.isShowPageBar ? ( +
+ { + this.gridPageLoad() + this.props.pageChange(e) + }} + page={this.props.page} + pageFn={(e) => this.setState({ page: e })} + onNextClick={(e) => { + this.gridPageLoad() + this.props.pageChange(e) + }} + onJumpPage={(e) => { + this.gridPageLoad() + this.props.pageChange(e) + }} + onCountChange={(e) => { + this.onCountChange(e) + }}> +
+ ) : null} + + ) + } } diff --git a/src/components/keysFind/index.jsx b/src/components/keysFind/index.jsx index 10381679..fbb104ef 100644 --- a/src/components/keysFind/index.jsx +++ b/src/components/keysFind/index.jsx @@ -2,13 +2,13 @@ * @Author: Wind * @Date: 2022-07-25 10:53:41 * @LastEditors: Wind - * @LastEditTime: 2022-08-10 15:12:44 + * @LastEditTime: 2022-08-10 15:52:01 * @Description:key列表查询组件 * @FilePath: \frontend\src\components\keysFind\index.jsx */ import './index.less' import { useState, useEffect } from 'react' -import { Button, Select, DateRangePicker } from 'zent' +import { Button, Select, DateRangePicker, Notify } from 'zent' import Ipt from '@/components/input/main' import Form from '@/components/form/main' import FormItem from '@/components/form-item/main' @@ -157,7 +157,19 @@ export default ({ onQuery }) => {
-
) } diff --git a/src/pages/plan/key/list.js b/src/pages/plan/key/list.js index 235a75ad..172e38a0 100644 --- a/src/pages/plan/key/list.js +++ b/src/pages/plan/key/list.js @@ -305,7 +305,13 @@ export default class acclist extends React.Component { handelResponse( res, (req, msg) => { - this.setState({ distdata: req.data }) + const newData = req.data.map((item) => { + if ([1, 2, 8, 7].includes(item.status)) { + item.disabled = true + } + return item + }) + this.setState({ distdata: newData }) this.setState({ planStatus: req.plan.status }) //计划状态 this.setState({ dataCount: req.total }) sessionStorage.setItem('key_plan_status', req.plan.status) @@ -586,7 +592,7 @@ export default class acclist extends React.Component { bulkSendFunction() { let isNotify = '' this.state.gridSelection.filter((item) => { - if (![4, 5, 6].includes(item.state)) { + if (![4, 5, 6].includes(item.status)) { return (isNotify = true) } }) @@ -594,7 +600,6 @@ export default class acclist extends React.Component { if (isNotify) { return Notify.warn('只有状态为进行中、暂停中、已完结的允许发送') } - this.getResellerInfoFunction(this.state.gridSelection[0].reseller_id) this.setState({ isBulkSend: true }) } diff --git a/src/pages/plan/keyList/index.jsx b/src/pages/plan/keyList/index.jsx index 0527a096..f203984e 100644 --- a/src/pages/plan/keyList/index.jsx +++ b/src/pages/plan/keyList/index.jsx @@ -25,7 +25,6 @@ import { keyBatchUsage, keyBatchCancel, handelResponse, - getkeyDetailList, getKeysList, batchUploadVoid, batchUploadUsed @@ -101,7 +100,7 @@ export default class acclist extends React.Component { } componentDidMount(e) { - this.iptsureFn() + // this.iptsureFn() } componentWillMount() { this.setState({ tableHeight: window.innerHeight - 430 }) @@ -604,6 +603,7 @@ export default class acclist extends React.Component { pageChange={(e) => { this.onPageChange(e) }} + emptyText='查询 请输入【分销商】或【计划名称】或【key】进行查询' countChange={(e) => { this.onCountChange(e) }}