Update edit.js
This commit is contained in:
parent
f3724d40f7
commit
f04a6717f9
|
@ -3,7 +3,7 @@ import React from "react"
|
||||||
import Ipt from "../../../components/input/main"
|
import Ipt from "../../../components/input/main"
|
||||||
import Form from "../../../components/form/main"
|
import Form from "../../../components/form/main"
|
||||||
import FormItem from "../../../components/form-item/main"
|
import FormItem from "../../../components/form-item/main"
|
||||||
import {Card, Drawer, Select,Button,ImageUpload ,onUpload,Sweetalert,RadioButton,RadioGroup,Notify,Input,CombinedDateRangePicker} from "zent"
|
import {Card, Drawer, Select,Button,ImageUpload ,DateRangePicker,onUpload,Sweetalert,RadioButton,RadioGroup,Notify,Input,CombinedDateRangePicker} from "zent"
|
||||||
import Bus from "../../../assets/eventBus.js"
|
import Bus from "../../../assets/eventBus.js"
|
||||||
import {getProductInfoSelect,handelResponse,uploadImg,getCodeProduct,putCodeProduct,getCodesDetail,putCodes,putCodesBatch} from "../../../assets/api.js"
|
import {getProductInfoSelect,handelResponse,uploadImg,getCodeProduct,putCodeProduct,getCodesDetail,putCodes,putCodesBatch} from "../../../assets/api.js"
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
@ -11,8 +11,26 @@ import Productform from "../product/add"
|
||||||
import "./edit.less"
|
import "./edit.less"
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import Grid from "../../../components/gird/main.js"
|
import Grid from "../../../components/gird/main.js"
|
||||||
const data = [{"id":21,"title":"爱奇艺周卡组合商品测试专用","type":1,"official_price":"13.0000","cost_price":"78.8400","account_type":5},{"id":22,"title":"喜马拉雅18月卡组合卡","type":1,"official_price":"218.0000","cost_price":"163.8000","account_type":1},{"id":23,"title":"爱奇艺月卡与美团外卖会员月卡组合","type":1,"official_price":"25.0000","cost_price":"33.3000","account_type":3},{"id":24,"title":"腾讯视频月卡和Q绿钻月卡组合","type":1,"official_price":"20.0000","cost_price":"247.2000","account_type":1},{"id":25,"title":"优酷月卡和百度文库3天卡组合","type":1,"official_price":"20.0000","cost_price":"144.5400","account_type":5},{"id":26,"title":"爱奇艺年卡和饿了么年卡组合","type":1,"official_price":"248.0000","cost_price":"10.0000","account_type":4},{"id":27,"title":"优酷年卡和网易云音乐年卡组合","type":1,"official_price":"198.0000","cost_price":"33.6400","account_type":4},{"id":28,"title":"芒果PC年卡和喜马拉雅季卡组合","type":1,"official_price":"198.0000","cost_price":"40.9500","account_type":1},{"id":88,"title":"测试商品-爱艺奇周卡-石竹","type":1,"official_price":"13.0000","cost_price":"7.5000","account_type":1},{"id":101,"title":"优酷周卡","type":1,"official_price":"9.0000","cost_price":"4.8150","account_type":1},{"id":102,"title":"优酷月卡","type":1,"official_price":"20.0000","cost_price":"12.0000","account_type":1},{"id":103,"title":"优酷季卡","type":1,"official_price":"56.0000","cost_price":"33.6000","account_type":1},{"id":104,"title":"优酷年卡","type":1,"official_price":"198.0000","cost_price":"118.8000","account_type":1},{"id":105,"title":"爱奇艺黄金会员天卡","type":1,"official_price":"8.0000","cost_price":"2.3400","account_type":1},{"id":106,"title":"爱奇艺黄金会员周卡","type":1,"official_price":"13.0000","cost_price":"4.0000","account_type":1},{"id":107,"title":"爱奇艺黄金会员月卡","type":1,"official_price":"25.0000","cost_price":"12.8700","account_type":1},{"id":108,"title":"爱奇艺黄金会员季卡","type":1,"official_price":"68.0000","cost_price":"37.7000","account_type":1},{"id":109,"title":"爱奇艺黄金会员半年卡","type":1,"official_price":"130.0000","cost_price":"70.2000","account_type":1},{"id":110,"title":"爱奇艺黄金会员年卡","type":1,"official_price":"248.0000","cost_price":"128.7000","account_type":1},{"id":111,"title":"爱奇艺钻石月卡","type":1,"official_price":"60.0000","cost_price":"27.0000","account_type":1},{"id":112,"title":"爱奇艺钻石季卡","type":1,"official_price":"168.0000","cost_price":"65.5200","account_type":1},{"id":113,"title":"爱奇艺钻石半年卡","type":1,"official_price":"328.0000","cost_price":"127.9200","account_type":1},{"id":114,"title":"爱奇艺钻石年卡","type":1,"official_price":"618.0000","cost_price":"247.2000","account_type":1},{"id":115,"title":"腾讯视频会员月卡","type":1,"official_price":"20.0000","cost_price":"11.2000","account_type":5},{"id":116,"title":"腾讯视频会员季卡","type":1,"official_price":"58.0000","cost_price":"34.8000","account_type":5},{"id":117,"title":"腾讯视频会员年卡","type":1,"official_price":"198.0000","cost_price":"118.8000","account_type":5},{"id":118,"title":"腾讯视频会员月卡微信","type":1,"official_price":"20.0000","cost_price":"13.0000","account_type":5},{"id":119,"title":"腾讯视频会员季卡微信","type":1,"official_price":"58.0000","cost_price":"37.7000","account_type":5},{"id":120,"title":"腾讯视频会员年卡微信","type":1,"official_price":"198.0000","cost_price":"110.0000","account_type":5},{"id":121,"title":"腾讯视频会员周卡","type":1,"official_price":"9.0000","cost_price":"5.0000","account_type":13}]
|
import { isSameDay, addDays, parse } from 'date-fns';
|
||||||
|
const initArray = targetNum => {
|
||||||
|
return Array.from({ length: targetNum }, (_, index) => index);
|
||||||
|
};
|
||||||
|
|
||||||
|
// <CombinedDateRangePicker canClear={false}
|
||||||
|
// className="zent-datepicker-plan"
|
||||||
|
// value={this.state.codeInfo.date_time}
|
||||||
|
// disabledDate={this.onDisabledCombinedDate}
|
||||||
|
// showTime={{
|
||||||
|
// format: 'HH:mm:ss',
|
||||||
|
// defaultTime: ['12:00:00', '23:59:59'],
|
||||||
|
// }}
|
||||||
|
// format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
// onChange={(e)=>{
|
||||||
|
|
||||||
|
// Bus.emit('change',"date_time" ,e);
|
||||||
|
// this.onChangeCombinedDate(e)}
|
||||||
|
// }
|
||||||
|
// />
|
||||||
|
|
||||||
|
|
||||||
export default class exchangedit extends React.Component{
|
export default class exchangedit extends React.Component{
|
||||||
|
@ -104,7 +122,7 @@ export default class exchangedit extends React.Component{
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.getProductInfo()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
onRankChange(e){
|
onRankChange(e){
|
||||||
|
@ -114,37 +132,6 @@ export default class exchangedit extends React.Component{
|
||||||
this.setState({tempdata:this.state.tempdata})
|
this.setState({tempdata:this.state.tempdata})
|
||||||
this.setState({rank:e})
|
this.setState({rank:e})
|
||||||
}
|
}
|
||||||
//获取直连天下商品映射信息
|
|
||||||
getProductInfo(){
|
|
||||||
// getProductInfoSelect().then((res)=>{
|
|
||||||
// handelResponse(res,(req,msg)=>{
|
|
||||||
let productData = sessionStorage.getItem("productData");
|
|
||||||
if(productData){
|
|
||||||
let product_data = JSON.parse( productData) ;
|
|
||||||
let checked_product= product_data ? product_data : [];
|
|
||||||
|
|
||||||
let arr = [];
|
|
||||||
_.map(data,(res)=>{
|
|
||||||
let obj = {};
|
|
||||||
obj.key = res.id;
|
|
||||||
obj.text= res.title;
|
|
||||||
obj.disabled = checked_product.findIndex((item)=>{return item.id == res.id}) > -1;
|
|
||||||
if(obj.disabled)
|
|
||||||
{
|
|
||||||
console.log(obj.text)
|
|
||||||
}
|
|
||||||
|
|
||||||
arr.push(obj)
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
})
|
|
||||||
console.log(arr)
|
|
||||||
this.setState({"productOption":arr})
|
|
||||||
}
|
|
||||||
// },(err)=>{
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel(){
|
cancel(){
|
||||||
//取消二次弹出框
|
//取消二次弹出框
|
||||||
|
@ -258,25 +245,7 @@ export default class exchangedit extends React.Component{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onProductChange(e){
|
|
||||||
this.setState({cur_product:e})
|
|
||||||
let cur_product = data.find((item)=>{return item.id == e.key})
|
|
||||||
|
|
||||||
let model2 = {
|
|
||||||
id:cur_product.id,
|
|
||||||
type:cur_product.type,
|
|
||||||
contract_price:this.state.model.contract_price,
|
|
||||||
official_price:cur_product.official_price,
|
|
||||||
cost_price:cur_product.cost_price,
|
|
||||||
stock:this.state.model.stock,
|
|
||||||
name:this.state.model.name,
|
|
||||||
show_url:this.state.show_url ,
|
|
||||||
describe_url:this.state.describe_url ,
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({model:model2})
|
|
||||||
console.log(cur_product)
|
|
||||||
}
|
|
||||||
onTypeChange(e){
|
onTypeChange(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
|
|
||||||
|
@ -308,6 +277,7 @@ export default class exchangedit extends React.Component{
|
||||||
console.log(this.state.codeInfo)
|
console.log(this.state.codeInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async productSubmit(){
|
async productSubmit(){
|
||||||
let visible = await this.refs.product.submit()
|
let visible = await this.refs.product.submit()
|
||||||
if(visible)
|
if(visible)
|
||||||
|
@ -348,11 +318,7 @@ export default class exchangedit extends React.Component{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDisabledCombinedDate = (val)=>{
|
|
||||||
let str = moment(val).format("YYYY-MM-DD HH:mm:ss")
|
|
||||||
let isBetween = moment(str).isBetween(this.state.codeInfo.date_time[0],this.state.codeInfo.date_time[1],null,'(]');
|
|
||||||
return !isBetween
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -454,6 +420,57 @@ export default class exchangedit extends React.Component{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
onDisabledCombinedDate = (val)=>{
|
||||||
|
let str = moment(val).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
let isBetween = moment(str).isBetween(this.state.codeInfo.date_time[0],this.state.codeInfo.date_time[1],null,'(]');
|
||||||
|
return !isBetween
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
onDisabledTime= (date, type) => {
|
||||||
|
|
||||||
|
const min = new Date();
|
||||||
|
const hour = min.getHours();
|
||||||
|
const minute = min.getMinutes();
|
||||||
|
const second = min.getSeconds();
|
||||||
|
const isSame = isSameDay(date, min);
|
||||||
|
|
||||||
|
|
||||||
|
return isSame ? {
|
||||||
|
disabledHours: () => initArray(hour),
|
||||||
|
disabledMinutes: hourValue =>
|
||||||
|
hourValue === hour ? initArray(minute) : [],
|
||||||
|
disabledSeconds: (hourValue, minuteValue) =>
|
||||||
|
hourValue === hour && minuteValue === minute
|
||||||
|
? initArray(second)
|
||||||
|
: [],
|
||||||
|
}
|
||||||
|
: {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
onDisabledRange = (date, type)=>{
|
||||||
|
let step1 = JSON.parse (sessionStorage.getItem("step1"));
|
||||||
|
// let str = moment(date).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
// let isBetween = moment(str).isBetween(step1.begin_time,step1.end_time,null,'(]');
|
||||||
|
let isdisabled = false;
|
||||||
|
let str = moment(date).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
|
||||||
|
|
||||||
|
if( type == "end" )
|
||||||
|
{
|
||||||
|
isdisabled = moment(str).isAfter(this.state.codeInfo.date_time[1])
|
||||||
|
}
|
||||||
|
return isdisabled
|
||||||
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
|
|
||||||
|
|
||||||
|
@ -590,21 +607,23 @@ export default class exchangedit extends React.Component{
|
||||||
<p>
|
<p>
|
||||||
<Form model={this.state.codeInfo} rules={rulesInfo} ref="code_rule" className="addform">
|
<Form model={this.state.codeInfo} rules={rulesInfo} ref="code_rule" className="addform">
|
||||||
<FormItem labelname="生效时间段" prop="date_time" id="date_time">
|
<FormItem labelname="生效时间段" prop="date_time" id="date_time">
|
||||||
<CombinedDateRangePicker canClear={false}
|
|
||||||
className="zent-datepicker-plan"
|
|
||||||
value={this.state.codeInfo.date_time}
|
|
||||||
disabledDate={this.onDisabledCombinedDate}
|
|
||||||
showTime={{
|
|
||||||
format: 'HH:mm:ss',
|
|
||||||
defaultTime: ['12:00:00', '23:59:59'],
|
|
||||||
}}
|
|
||||||
format="YYYY-MM-DD HH:mm:ss"
|
|
||||||
onChange={(e)=>{
|
|
||||||
|
|
||||||
Bus.emit('change',"date_time" ,e);
|
|
||||||
this.onChangeCombinedDate(e)}
|
<DateRangePicker
|
||||||
}
|
disabled={[true, false]}
|
||||||
/>
|
className="zent-datepicker-plan"
|
||||||
|
showTime={{ format: 'HH:mm:ss', defaultTime: ["00:00:00", '23:59:59'],
|
||||||
|
}}
|
||||||
|
format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
value={this.state.codeInfo.date_time}
|
||||||
|
onChange={(e)=>{
|
||||||
|
Bus.emit('change',"date_time" ,e);
|
||||||
|
this.onChangeCombinedDate(e)}
|
||||||
|
|
||||||
|
}
|
||||||
|
disabledTime={this.onDisabledTime}
|
||||||
|
disabledDate={this.onDisabledRange }
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem labelname="商品范围" prop="rank" id="rank" >
|
<FormItem labelname="商品范围" prop="rank" id="rank" >
|
||||||
<Select options={this.state.rankoptions} multiple value={this.state.rank} placeholder="选择一项" width={405} onChange={(e)=>{this.onRankChange(e)}} />
|
<Select options={this.state.rankoptions} multiple value={this.state.rank} placeholder="选择一项" width={405} onChange={(e)=>{this.onRankChange(e)}} />
|
||||||
|
|
Loading…
Reference in New Issue