From 884c686980f794715014f2a26ec033e68cde1dca Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Mon, 24 Oct 2022 15:29:55 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=95=86=E5=93=81=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E5=88=97=E8=A1=A8=E7=AB=8B=E5=87=8F=E9=87=91=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=95=86=E5=93=81=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangecode/commodity/commodity.js | 254 +++++++++--------- 1 file changed, 125 insertions(+), 129 deletions(-) diff --git a/src/pages/exchangecode/commodity/commodity.js b/src/pages/exchangecode/commodity/commodity.js index 1453480c..2deecbff 100644 --- a/src/pages/exchangecode/commodity/commodity.js +++ b/src/pages/exchangecode/commodity/commodity.js @@ -1,4 +1,4 @@ -import React from "react"; +import React from "react" import { Button, Tag, @@ -7,20 +7,20 @@ import { Notify, Sweetalert, Drawer, - Card, -} from "zent"; -import "./commodity.less"; -import "../../../assets/comm.css"; -import Ipt from "../../../components/input/main"; -import Grid from "../../../components/gird/main.js"; -import TabPage from "../../../components/tabPage/main.js"; + Card +} from "zent" +import "./commodity.less" +import "../../../assets/comm.css" +import Ipt from "../../../components/input/main" +import Grid from "../../../components/gird/main.js" +import TabPage from "../../../components/tabPage/main.js" import { getCodeProductList, handelResponse, - delCodeProduct, -} from "../../../assets/api.js"; -import Productform from "@/pages/plan/product/add"; /* 商品 */ -import _ from "lodash"; + delCodeProduct +} from "../../../assets/api.js" +import Productform from "@/pages/plan/product/add" /* 商品 */ +import _ from "lodash" const Column = [ { @@ -29,83 +29,83 @@ const Column = [ prop: "product_id", className: "name", type: "normal", - width: "auto", + width: "auto" }, { title: "商品名称", prop: "product_name", name: "product_name", width: "200px", - type: "normal", + type: "normal" }, { title: "立减金平台批次号", width: "200px", prop: "channel_activity_id", name: "channel_activity_id", - type: "normal", + type: "normal" }, { title: "上游平台", width: "auto", prop: "upstream", name: "upstream", - type: "normal", + type: "normal" }, { title: "商品权重", width: "auto", prop: "weight", name: "weight", - type: "normal", + type: "normal" }, { title: "有效时间段", width: "500px", prop: "effectDate", name: "effectDate", - type: "normal", + type: "normal" }, { title: "官方价格", name: "official_price", prop: "official_price", type: "normal", - width: "auto", + width: "auto" }, { title: "合同价", name: "contract_price", type: "normal", prop: "contract_price", - width: "auto", + width: "auto" }, { title: "创建时间", name: "create_time", type: "normal", prop: "create_time", - width: "250px", + width: "250px" }, { title: "类型", name: "product_type_text", type: "normal", prop: "product_type_text", - width: "auto", + width: "auto" }, { title: "操作", prop: "opearo", name: "opearo", type: "slot", - width: "200px", - }, -]; + width: "200px" + } +] // this.editinfo(e,rowData)}>编辑 export default class commoditylist extends React.Component { constructor(props) { - super(props); + super(props) this.state = { dataCount: 0, page: 1, @@ -120,33 +120,33 @@ export default class commoditylist extends React.Component { label: "商品类型", menuList: [ { id: 2, name: "卡密" }, - { id: 1, name: "直充" }, - ], - }, + { id: 1, name: "直充" } + ] + } ], menuList: [{ id: 0, name: "商品类型", check: false }], drawerVisible: false, contractprice: 0, - totalprice: 0, - }; + totalprice: 0 + } } //分页 onPageChange(e) { let data = { code_batch_id: sessionStorage.getItem("code_id"), page: e, - limit: this.state.limit, - }; + limit: this.state.limit + } - this.getTableList(data); + this.getTableList(data) } componentDidMount(e) { let data = { code_batch_id: sessionStorage.getItem("code_id"), page: 1, - limit: 10, - }; - this.getTableList(data); + limit: 10 + } + this.getTableList(data) } getTableList(data) { @@ -155,18 +155,19 @@ export default class commoditylist extends React.Component { handelResponse( res, (req, msg) => { - const resData = []; + const resData = [] req.data.map((item) => { /* type 1为商品 2为立减金 转译字符方便处理 */ /* 此处only 商品为product_id 立减金为channel_activity_id */ if (item.type === 1) { - item.entity.upstream = "直连天下"; - item.entity.only = item.entity.product_id; - item.entity.id = item.id; - item.entity.weight = item.weight; - resData.push(item.entity); + item.entity.upstream = "直连天下" + item.entity.only = item.entity.product_id + item.entity.id = item.id + item.entity.weight = item.weight + resData.push(item.entity) } else if (item.type === 2) { resData.push({ + product_id: item.entity.goods_id, product_type_text: "立减金", only: item.entity.channel_activity_id, id: item.id, @@ -183,46 +184,46 @@ export default class commoditylist extends React.Component { effectDate: item.entity.time_limit.effect_time.start_time + " 至 " + - item.entity.time_limit.effect_time.end_time, //有效时间 - }); + item.entity.time_limit.effect_time.end_time //有效时间 + }) } - }); - this.setState({ distdata: resData }); - this.setState({ dataCount: req.total }); + }) + this.setState({ distdata: resData }) + this.setState({ dataCount: req.total }) }, (err) => {} - ); + ) }) - .catch((err) => {}); + .catch((err) => {}) } async productSubmit() { - let success = await this.refs.product.submit(); + let success = await this.refs.product.submit() if (success) { - let productData = sessionStorage.getItem("product_item"); + let productData = sessionStorage.getItem("product_item") } } clickFn() { - this.setState({ drawerVisible: true }); + this.setState({ drawerVisible: true }) } aboutFn(e, row) { - this.props.history.push("/exchange-commodity"); + this.props.history.push("/exchange-commodity") } selection(selection) { - this.setState({ selectiondata: selection }); - let contractprice = 0; - let totalprice = 0; + this.setState({ selectiondata: selection }) + let contractprice = 0 + let totalprice = 0 selection.forEach((item) => { - contractprice += Number(item.official_price); - totalprice += Number(item.contract_price); - }); - this.setState({ contractprice, totalprice }); + contractprice += Number(item.official_price) + totalprice += Number(item.contract_price) + }) + this.setState({ contractprice, totalprice }) } batchdelFn() { if (this.state.selectiondata < 1) { - Notify.clear(); - Notify.warn("请先勾选需删除的选项"); + Notify.clear() + Notify.warn("请先勾选需删除的选项") } else { Sweetalert.confirm({ type: "warning", @@ -232,13 +233,13 @@ export default class commoditylist extends React.Component { onConfirm() {}, onCancel() {}, className: "questModal", - parentComponent: this, - }); + parentComponent: this + }) } } //删除 deleteFn(e, row) { - let _self = this; + let _self = this Sweetalert.confirm({ type: "warning", closeBtn: true, @@ -250,49 +251,49 @@ export default class commoditylist extends React.Component { handelResponse( res, (response, msg) => { - Notify.clear(); - Notify.success(msg); + Notify.clear() + Notify.success(msg) let data = { code_batch_id: sessionStorage.getItem("code_id"), page: _self.state.page, - limit: _self.state.limit, - }; + limit: _self.state.limit + } - _self.getTableList(data); //更新列表 + _self.getTableList(data) //更新列表 }, (err) => { - Notify.error(err); + Notify.error(err) } - ); + ) }) - .catch((err) => {}); + .catch((err) => {}) }, onCancel() {}, className: "questModal", - parentComponent: this, - }); + parentComponent: this + }) } editinfo(e, rowData) { - this.props.history.push("/home/product-edit"); - sessionStorage.setItem("pathname2", "/home/product-edit"); + this.props.history.push("/home/product-edit") + sessionStorage.setItem("pathname2", "/home/product-edit") let activerou = [ { pagetitle: "编辑", items: [ { path: "/home/exchangecode-list", - name: "商品范围列表", + name: "商品范围列表" }, { path: "/home/product-edit", - name: "编辑[ " + rowData.product_name + " ]商品", - }, - ], - }, - ]; + name: "编辑[ " + rowData.product_name + " ]商品" + } + ] + } + ] /* 此处only 商品为product_id 立减金为channel_activity_id */ - sessionStorage.setItem("dataInfo", rowData.only); - sessionStorage.setItem("breakchangenav", JSON.stringify(activerou)); + sessionStorage.setItem("dataInfo", rowData.only) + sessionStorage.setItem("breakchangenav", JSON.stringify(activerou)) } //敲回车查询 sureFn() { @@ -300,49 +301,49 @@ export default class commoditylist extends React.Component { code_batch_id: sessionStorage.getItem("code_id"), page: this.state.page, limit: this.state.limit, - key_word: this.state.key_word, - }; - this.getTableList(data); //更新列表 + key_word: this.state.key_word + } + this.getTableList(data) //更新列表 } componentWillMount() { - this.setState({ tableHeight: window.innerHeight - 430 }); + this.setState({ tableHeight: window.innerHeight - 430 }) } //状态筛选 selectedId(e) { - this.setState({ status: e }); + this.setState({ status: e }) let data = { code_batch_id: sessionStorage.getItem("code_id"), page: this.state.page, limit: this.state.limit, - product_type: e, - }; - this.getTableList(data); //更新列表 + product_type: e + } + this.getTableList(data) //更新列表 } /* 改变count */ onCountChange(e) { this.setState({ page: 1, - limit: e, - }); + limit: e + }) setTimeout(() => { - this.getTableList(); - }, 200); + this.getTableList() + }, 200) } render() { - const { current, pageSize } = this.state; + const { current, pageSize } = this.state return ( -
+
-
+
{/* */} {/* */} {this.state.selectiondata.length > 0 ? ( 清空} - > + type='info' + extraContent={}> 已选择 - + {this.state.selectiondata.length} 项,官方价格总计:{this.state.contractprice.toFixed(4)} ,合同价总计:{this.state.totalprice.toFixed(4)} ) : null} -
+
{ - this.onPageChange(e); + this.onPageChange(e) }} countChange={(e) => { - this.onCountChange(e); + this.onCountChange(e) }} checkChange={this.selection.bind(this)} ComponentHandler={(com, rowData) => { if (com == "status") { return ( - + {rowData.status} - ); + ) } if (com == "opearo") { return (
this.deleteFn(e, rowData)} - > + onClick={(e) => this.deleteFn(e, rowData)}> 删除
- ); + ) } }} />
} visible={this.state.drawerVisible} onClose={(e) => { - this.setState({ drawerVisible: false }); - }} - > -
+ this.setState({ drawerVisible: false }) + }}> +
- +
- ); + ) } }