|
@@ -0,0 +1,643 @@
|
|
|
+import React, { Component } from "react";
|
|
|
+import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
|
|
+import {
|
|
|
+ Tabs,
|
|
|
+ Button,
|
|
|
+ Switch,
|
|
|
+ Input,
|
|
|
+ Select,
|
|
|
+ DatePicker,
|
|
|
+ Icon,
|
|
|
+ message
|
|
|
+} from "antd";
|
|
|
+
|
|
|
+import { connect } from "dva";
|
|
|
+import PropTypes, { string } from 'prop-types'
|
|
|
+import styles from './index.less';
|
|
|
+import { deepClone, util } from "utils";
|
|
|
+import { Loader } from 'components';
|
|
|
+
|
|
|
+import moment from 'moment';
|
|
|
+import TimePicker from "../TimePicker/TimePicker";
|
|
|
+const { RangePicker } = DatePicker
|
|
|
+const dateFormat = 'MM/DD'
|
|
|
+
|
|
|
+import MsgComponent from "../msgComponent";
|
|
|
+import { error } from "jquery";
|
|
|
+const { TabPane } = Tabs;
|
|
|
+const { Search } = Input;
|
|
|
+const { TextArea } = Input;
|
|
|
+
|
|
|
+const textButtom = [
|
|
|
+ // "时间段(每天)",
|
|
|
+ "时间段(一)",
|
|
|
+ "时间段(二)",
|
|
|
+ "时间段(三)",
|
|
|
+ "时间段(四)",
|
|
|
+ "时间段(五)",
|
|
|
+ "时间段(六)",
|
|
|
+ "时间段(七)",
|
|
|
+]
|
|
|
+const week = [
|
|
|
+ {
|
|
|
+ name: "每天",
|
|
|
+ key: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "周一",
|
|
|
+ key: 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "周二",
|
|
|
+ key: 2
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "周三",
|
|
|
+ key: 3
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "周四",
|
|
|
+ key: 4
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "周五",
|
|
|
+ key: 5
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "周六",
|
|
|
+ key: 6
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "周日",
|
|
|
+ key: 7
|
|
|
+ },
|
|
|
+
|
|
|
+]
|
|
|
+
|
|
|
+
|
|
|
+class PushMessage extends React.Component {
|
|
|
+ constructor(props) {
|
|
|
+ super(props)
|
|
|
+ this.state = {
|
|
|
+ open: false,
|
|
|
+ conTrollerChecked: false,
|
|
|
+ selectKey: 0,
|
|
|
+ buttonState: 0,
|
|
|
+ currentState: 0,
|
|
|
+ newarr: [],
|
|
|
+ arrList: [
|
|
|
+ {}
|
|
|
+ ],
|
|
|
+ selectIndex: 'text',
|
|
|
+ disabled: false,
|
|
|
+ contentValueItem: "",
|
|
|
+ typeText: "text",
|
|
|
+ TimePicker: [
|
|
|
+ {
|
|
|
+ value: [],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ msgComponent: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ conTroller = (checked, key) => {
|
|
|
+ var initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ var items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ? this.props.pushMessage.initData.items : undefined
|
|
|
+ // if (items) {
|
|
|
+ // if (!items[key])
|
|
|
+ // items[key] = {};
|
|
|
+ // items[key].disable = checked ? 0 : 1;
|
|
|
+
|
|
|
+ // }
|
|
|
+ // initData.items = items;
|
|
|
+
|
|
|
+ const updateFromItm = this.state.msgComponent[key]
|
|
|
+ var content = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('content') : ""
|
|
|
+ var miniAppTitle = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniAppTitle') : ""
|
|
|
+ var title = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('title') : ""
|
|
|
+ var url = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('url') : ""
|
|
|
+ var description = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('description') : ""
|
|
|
+ var miniProgramAppId = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniProgramAppId') : ""
|
|
|
+ var pagepath = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('pagepath') : ""
|
|
|
+
|
|
|
+
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+ items[key].disable = checked ? 0 : 1;
|
|
|
+ var chooseKey
|
|
|
+ let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
|
|
|
+ chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
|
|
|
+ let messageItem = {}
|
|
|
+ messageItem.content = content;
|
|
|
+ messageItem.miniAppTitle = miniAppTitle;
|
|
|
+ messageItem.msgType = chooseKey;
|
|
|
+ messageItem.title = title;
|
|
|
+ messageItem.url = url;
|
|
|
+ messageItem.description = description;
|
|
|
+ messageItem.miniProgramAppId = miniProgramAppId;
|
|
|
+ messageItem.pagepath = pagepath;
|
|
|
+ items[key].message = messageItem;
|
|
|
+ initData.items = items;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.props.dispatch({ type: 'pushMessage/updateState', payload: { initData: initData } });
|
|
|
+ }
|
|
|
+
|
|
|
+ handleChange = (value, key) => {
|
|
|
+ var initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ var items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ? this.props.pushMessage.initData.items : undefined
|
|
|
+ // if (items) {
|
|
|
+ // if (!items[key])
|
|
|
+ // items[key] = {};
|
|
|
+ // items[key].week = value;
|
|
|
+ // }
|
|
|
+ // initData.items = items;
|
|
|
+
|
|
|
+ const updateFromItm = this.state.msgComponent[key]
|
|
|
+ var content = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('content') : ""
|
|
|
+ var miniAppTitle = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniAppTitle') : ""
|
|
|
+ var title = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('title') : ""
|
|
|
+ var url = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('url') : ""
|
|
|
+ var description = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('description') : ""
|
|
|
+ var miniProgramAppId = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniProgramAppId') : ""
|
|
|
+ var pagepath = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('pagepath') : ""
|
|
|
+
|
|
|
+
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+ items[key].week = value;
|
|
|
+ var chooseKey
|
|
|
+ let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
|
|
|
+ chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
|
|
|
+ let messageItem = {}
|
|
|
+ messageItem.content = content;
|
|
|
+ messageItem.miniAppTitle = miniAppTitle;
|
|
|
+ messageItem.msgType = chooseKey;
|
|
|
+ messageItem.title = title;
|
|
|
+ messageItem.url = url;
|
|
|
+ messageItem.description = description;
|
|
|
+ messageItem.miniProgramAppId = miniProgramAppId;
|
|
|
+ messageItem.pagepath = pagepath;
|
|
|
+ items[key].message = messageItem;
|
|
|
+ initData.items = items;
|
|
|
+ }
|
|
|
+ this.props.dispatch({ type: 'pushMessage/updateState', payload: { initData: initData } });
|
|
|
+ }
|
|
|
+ timeReversal = val => {
|
|
|
+ let timeArr = []
|
|
|
+ for (let i = 0; i < val.length; i++) {
|
|
|
+ let timeList = {};
|
|
|
+ timeList.beginTime = val[i].value.length > 0 ? moment(val[i].value[0], 'HH:mm:ss').format('HH:mm:ss') : null
|
|
|
+ timeList.endTime = val[i].value.length > 0 ? moment(val[i].value[1], 'HH:mm:ss').format('HH:mm:ss') : null
|
|
|
+ timeArr.push(timeList);
|
|
|
+ }
|
|
|
+ return timeArr
|
|
|
+ }
|
|
|
+ add = key => {
|
|
|
+ var listData = this.props.pushMessage.times ? this.props.pushMessage.times : { key: [] }
|
|
|
+ var initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ var items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ?
|
|
|
+ this.props.pushMessage.initData.items : undefined
|
|
|
+
|
|
|
+ if (!listData[key])
|
|
|
+ listData[key] = []
|
|
|
+
|
|
|
+ if (listData && listData[key] && listData[key].length < 7) {
|
|
|
+ let obj = {
|
|
|
+ value: []
|
|
|
+ }
|
|
|
+ listData[key].push(obj);
|
|
|
+
|
|
|
+ // if (items) {
|
|
|
+ // if (!items[key])
|
|
|
+ // items[key] = {};
|
|
|
+ // initData.items = items;
|
|
|
+ // }
|
|
|
+
|
|
|
+ const updateFromItm = this.state.msgComponent[key]
|
|
|
+ var content = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('content') : ""
|
|
|
+ var miniAppTitle = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniAppTitle') : ""
|
|
|
+ var title = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('title') : ""
|
|
|
+ var url = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('url') : ""
|
|
|
+ var description = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('description') : ""
|
|
|
+ var miniProgramAppId = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniProgramAppId') : ""
|
|
|
+ var pagepath = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('pagepath') : ""
|
|
|
+
|
|
|
+
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+ var chooseKey
|
|
|
+ let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
|
|
|
+ chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
|
|
|
+ let messageItem = {}
|
|
|
+ messageItem.content = content;
|
|
|
+ messageItem.miniAppTitle = miniAppTitle;
|
|
|
+ messageItem.msgType = chooseKey;
|
|
|
+ messageItem.title = title;
|
|
|
+ messageItem.url = url;
|
|
|
+ messageItem.description = description;
|
|
|
+ messageItem.miniProgramAppId = miniProgramAppId;
|
|
|
+ messageItem.pagepath = pagepath;
|
|
|
+ items[key].message = messageItem;
|
|
|
+ initData.items = items;
|
|
|
+ }
|
|
|
+ this.props.dispatch({ type: 'pushMessage/updateState', payload: { times: listData, initData: initData } });
|
|
|
+ } else {
|
|
|
+ message.info('最多添加七个时间段');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ remove = (key, key1) => {
|
|
|
+ var listData = this.props.pushMessage && this.props.pushMessage.times ? this.props.pushMessage.times : { key: [] }
|
|
|
+ var initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ var items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ?
|
|
|
+ this.props.pushMessage.initData.items : undefined
|
|
|
+ if (listData && listData[key] && listData[key].length > 1) {
|
|
|
+ let obj = {
|
|
|
+ value: []
|
|
|
+ }
|
|
|
+ listData[key].splice(key1, 1);
|
|
|
+
|
|
|
+ // if (items) {
|
|
|
+ // if (!items[key])
|
|
|
+ // items[key] = {};
|
|
|
+ // initData.items = items;
|
|
|
+ // }
|
|
|
+
|
|
|
+ const updateFromItm = this.state.msgComponent[key]
|
|
|
+ var content = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('content') : ""
|
|
|
+ var miniAppTitle = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniAppTitle') : ""
|
|
|
+ var title = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('title') : ""
|
|
|
+ var url = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('url') : ""
|
|
|
+ var description = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('description') : ""
|
|
|
+ var miniProgramAppId = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniProgramAppId') : ""
|
|
|
+ var pagepath = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('pagepath') : ""
|
|
|
+
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+ var chooseKey
|
|
|
+ let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
|
|
|
+ chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
|
|
|
+ let messageItem = {}
|
|
|
+ messageItem.content = content;
|
|
|
+ messageItem.miniAppTitle = miniAppTitle;
|
|
|
+ messageItem.msgType = chooseKey;
|
|
|
+ messageItem.title = title;
|
|
|
+ messageItem.url = url;
|
|
|
+ messageItem.description = description;
|
|
|
+ messageItem.miniProgramAppId = miniProgramAppId;
|
|
|
+ messageItem.pagepath = pagepath;
|
|
|
+ items[key].message = messageItem;
|
|
|
+ initData.items = items;
|
|
|
+ }
|
|
|
+ this.props.dispatch({ type: 'pushMessage/updateState', payload: { times: listData, initData: initData } });
|
|
|
+ } else {
|
|
|
+ message.info('最少保留一个时间段');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ handleSubmit = key => {
|
|
|
+ var initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ var appId = this.props.wxAppIdValue
|
|
|
+ var items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ? this.props.pushMessage.initData.items : undefined
|
|
|
+
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+
|
|
|
+ var message1 = { msgType: this.state.typeText };
|
|
|
+ if (this.props.pushMessage.initData.items[key] && this.props.pushMessage.initData.items[key].message) {
|
|
|
+ message1 = this.props.pushMessage.initData.items[key].message;
|
|
|
+ message1.msgType = this.props.pushMessage.initData.items[key].message.msgType ? this.props.pushMessage.initData.items[key].message.msgType : 'text'
|
|
|
+ message1.msgId = this.props.pushMessage.initData.items[key].message.msgId ? this.props.pushMessage.initData.items[key].message.msgId : null
|
|
|
+ message1.thumbMediaId = this.props.pushMessage.initData.items[key].message.mediaId ? this.props.pushMessage.initData.items[key].message.mediaId : null
|
|
|
+ }
|
|
|
+ // thumbMediaId
|
|
|
+ message1.content = this.state.msgComponent[key].props.form.getFieldValue('content')
|
|
|
+ message1.title = this.state.msgComponent[key].props.form.getFieldValue('title')
|
|
|
+ message1.description = this.state.msgComponent[key].props.form.getFieldValue('description')
|
|
|
+ message1.url = this.state.msgComponent[key].props.form.getFieldValue('url')
|
|
|
+ message1.miniAppTitle = this.state.msgComponent[key].props.form.getFieldValue('miniAppTitle')
|
|
|
+ message1.miniProgramAppId = this.state.msgComponent[key].props.form.getFieldValue('miniProgramAppId')
|
|
|
+ message1.pagepath = this.state.msgComponent[key].props.form.getFieldValue('pagepath')
|
|
|
+ items[key].message = message1;
|
|
|
+ initData.items = items;
|
|
|
+ }
|
|
|
+ var data = initData.items[key];
|
|
|
+ if (typeof (data.disable) === 'undefined')
|
|
|
+ data.disable = 0;
|
|
|
+
|
|
|
+ if (typeof (data.week) === 'undefined')
|
|
|
+ data.week = 1;
|
|
|
+
|
|
|
+ if (typeof (data.tableNo) === 'undefined')
|
|
|
+ data.tableNo = key;
|
|
|
+
|
|
|
+ this.props.dispatch({ type: 'pushMessage/submit', payload: { data } });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取 mediaId
|
|
|
+ cb_mediaId = (mediaId, key, imgUrl) => {
|
|
|
+ console.log(mediaId, imgUrl);
|
|
|
+ var initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ var items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ? this.props.pushMessage.initData.items : undefined
|
|
|
+
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+
|
|
|
+ let week1 = items.week;
|
|
|
+
|
|
|
+ var message1 = { msgType: this.state.typeText }
|
|
|
+ if (this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[key]
|
|
|
+ && this.props.pushMessage.initData.items[key].message) {
|
|
|
+
|
|
|
+ message1 = this.props.pushMessage.initData.items[key].message
|
|
|
+ }
|
|
|
+
|
|
|
+ let check = 'text';
|
|
|
+ if (this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[key]
|
|
|
+ && this.props.pushMessage.initData.items[key].message
|
|
|
+ && this.props.pushMessage.initData.items[key].message.chooseKey) {
|
|
|
+ check = this.props.pushMessage.initData.items[key].message.chooseKey;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (check) {
|
|
|
+ case 'text':
|
|
|
+ message1.mediaId = mediaId;
|
|
|
+ break;
|
|
|
+ case 'news':
|
|
|
+ message1.mediaId = mediaId;
|
|
|
+ message1.thumbUrl = imgUrl;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'miniprogrampage':
|
|
|
+ message1.thumbMediaId = mediaId;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ items[key].message = message1;
|
|
|
+ initData.items = items;
|
|
|
+ }
|
|
|
+ this.props.dispatch({ type: 'pushMessage/updateState', payload: { initData: initData } });
|
|
|
+ }
|
|
|
+ updateFromMessage = (value, key) => {
|
|
|
+ const initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ const items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ? this.props.pushMessage.initData.items : undefined
|
|
|
+ const updateFromItm = this.state.msgComponent[key]
|
|
|
+ var content = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('content') : ""
|
|
|
+ var miniAppTitle = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniAppTitle') : ""
|
|
|
+ var title = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('title') : ""
|
|
|
+ var url = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('url') : ""
|
|
|
+ var description = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('description') : ""
|
|
|
+ var miniProgramAppId = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniProgramAppId') : ""
|
|
|
+ var pagepath = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('pagepath') : ""
|
|
|
+
|
|
|
+
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+ var chooseKey
|
|
|
+ let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
|
|
|
+ chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
|
|
|
+ let messageItem = {}
|
|
|
+ messageItem.content = content;
|
|
|
+ messageItem.miniAppTitle = miniAppTitle;
|
|
|
+ messageItem.msgType = chooseKey;
|
|
|
+ messageItem.title = title;
|
|
|
+ messageItem.url = url;
|
|
|
+ messageItem.description = description;
|
|
|
+ messageItem.miniProgramAppId = miniProgramAppId;
|
|
|
+ messageItem.pagepath = pagepath;
|
|
|
+ items[key].message = messageItem;
|
|
|
+ initData.items = items;
|
|
|
+ }
|
|
|
+ this.props.dispatch({ type: 'pushMessage/updateState', payload: { initData: initData } });
|
|
|
+ }
|
|
|
+ // text 发送消息 图文 news 小程序 miniprogrampage
|
|
|
+ cb_chooseKey = (chooseKey, key) => {
|
|
|
+ var initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ var items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ? this.props.pushMessage.initData.items : undefined
|
|
|
+ // console.log(chooseKey,'chooseKey');
|
|
|
+ this.setState({
|
|
|
+ typeText: chooseKey,
|
|
|
+ })
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+ var message1 = { msgType: this.state.typeText }
|
|
|
+ if (this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[key]
|
|
|
+ && this.props.pushMessage.initData.items[key].message) {
|
|
|
+ message1 = this.props.pushMessage.initData.items[key].message
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chooseKey)
|
|
|
+ message1.chooseKey = chooseKey;
|
|
|
+ message1.msgType = chooseKey;
|
|
|
+ items[key].message = message1;
|
|
|
+ initData.items = items;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.props.dispatch({ type: 'pushMessage/updateState', payload: { initData: initData } });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取表单即文本内容
|
|
|
+ cb_formChange = (formdata, allData, key) => {
|
|
|
+
|
|
|
+ }
|
|
|
+ handleClick = (value, key1, key) => {
|
|
|
+ var listData = this.props.pushMessage.times ? this.props.pushMessage.times : { key: [] }
|
|
|
+ var initData = this.props.pushMessage && this.props.pushMessage.initData ? this.props.pushMessage.initData : undefined;
|
|
|
+ var items = this.props.pushMessage && this.props.pushMessage.initData && this.props.pushMessage.initData.items ?
|
|
|
+ this.props.pushMessage.initData.items : undefined
|
|
|
+
|
|
|
+ let selectTime = [];
|
|
|
+ if (!listData[key])
|
|
|
+ listData[key] = []
|
|
|
+
|
|
|
+ if (listData && listData[key] && listData[key].length > 0) {
|
|
|
+ for (var i in listData[key]) {
|
|
|
+ var seleDate = {};
|
|
|
+ seleDate.beginTime = moment(listData[key][i].value[0]).format('HH:mm:ss')
|
|
|
+ seleDate.endTime = moment(listData[key][i].value[1]).format('HH:mm:ss')
|
|
|
+ selectTime[i] = seleDate;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var obj = {
|
|
|
+ value: []
|
|
|
+ }
|
|
|
+
|
|
|
+ var seleDate = {};
|
|
|
+ if (value[0]) {
|
|
|
+ obj.value[0] = moment(value[0], 'HH:mm:ss');
|
|
|
+ seleDate.beginTime = moment(value[0], 'HH:mm:ss').format('HH:mm:ss')
|
|
|
+ }
|
|
|
+ if (value[1]) {
|
|
|
+ obj.value[1] = moment(value[1], 'HH:mm:ss');
|
|
|
+ seleDate.endTime = moment(value[1], 'HH:mm:ss').format('HH:mm:ss')
|
|
|
+ }
|
|
|
+
|
|
|
+ selectTime[key1] = seleDate;
|
|
|
+ listData[key][key1] = obj;
|
|
|
+
|
|
|
+
|
|
|
+ // if (items) {
|
|
|
+ // if (!items[key])
|
|
|
+ // items[key] = {};
|
|
|
+ // items[key].timesList = selectTime;
|
|
|
+ // }
|
|
|
+
|
|
|
+ const updateFromItm = this.state.msgComponent[key]
|
|
|
+ var content = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('content') : ""
|
|
|
+ var miniAppTitle = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniAppTitle') : ""
|
|
|
+ var title = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('title') : ""
|
|
|
+ var url = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('url') : ""
|
|
|
+ var description = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('description') : ""
|
|
|
+ var miniProgramAppId = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('miniProgramAppId') : ""
|
|
|
+ var pagepath = updateFromItm && updateFromItm.props.form ? updateFromItm.props.form.getFieldValue('pagepath') : ""
|
|
|
+
|
|
|
+
|
|
|
+ if (items) {
|
|
|
+ if (!items[key])
|
|
|
+ items[key] = {};
|
|
|
+ var chooseKey
|
|
|
+ let keys = this.props.pushMessage.initData && this.props.pushMessage.initData.items && this.props.pushMessage.initData.items[this.state.currentState]
|
|
|
+ chooseKey = keys && keys.message && keys.message.msgType ? keys.message.msgType : 'text';
|
|
|
+ let messageItem = {}
|
|
|
+ messageItem.content = content;
|
|
|
+ messageItem.miniAppTitle = miniAppTitle;
|
|
|
+ messageItem.msgType = chooseKey;
|
|
|
+ messageItem.title = title;
|
|
|
+ messageItem.url = url;
|
|
|
+ messageItem.description = description;
|
|
|
+ messageItem.miniProgramAppId = miniProgramAppId;
|
|
|
+ messageItem.pagepath = pagepath;
|
|
|
+ items[key].message = messageItem;
|
|
|
+ initData.items = items;
|
|
|
+ items[key].timesList = selectTime;
|
|
|
+ }
|
|
|
+ this.props.dispatch({ type: 'pushMessage/updateState', payload: { times: listData, initData: initData } });
|
|
|
+ }
|
|
|
+
|
|
|
+ onSelect = (index) => {
|
|
|
+ this.setState({
|
|
|
+ currentState: index,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ let self = this;
|
|
|
+ let i = 0;
|
|
|
+ const { Option } = Select;
|
|
|
+ const format = 'HH:mm:ss';
|
|
|
+ return (
|
|
|
+ <div className={styles.segmentAutoReeply}>
|
|
|
+ <div className={styles.header}>
|
|
|
+ {
|
|
|
+ textButtom.map((item, key) => {
|
|
|
+ return <Button className={styles.buttonWidth} size="large" type={key === this.state.currentState ? "primary" : "Default"} block key={key} onClick={() => { self.onSelect(key) }}> {item}</Button>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </div>
|
|
|
+ {
|
|
|
+ textButtom.map((item, key) => {
|
|
|
+ var data = [];
|
|
|
+ var disable = false;
|
|
|
+ var weekItem = 0; //'全天'
|
|
|
+
|
|
|
+ let TimeRangePicker = [];
|
|
|
+ if (self.props.pushMessage && self.props.pushMessage.times && self.props.pushMessage.times[key]
|
|
|
+ && self.props.pushMessage.times[key].length > 0)
|
|
|
+ TimeRangePicker = self.props.pushMessage.times[key];
|
|
|
+
|
|
|
+ else
|
|
|
+ TimeRangePicker = [{ value: [] }]
|
|
|
+
|
|
|
+ if (self.props.pushMessage.initData) {
|
|
|
+ data = self.props.pushMessage.initData;
|
|
|
+ disable = data.items && data.items[key] && data.items[key].disable ? false : true;
|
|
|
+ weekItem = data.items && data.items[key] && typeof (data.items[key].week) !== 'undefined' ? data.items[key].week : 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ var chooseKey = 'text';
|
|
|
+ var cutextKey = "text"
|
|
|
+ var message1 = {};
|
|
|
+ if (self.props.pushMessage && self.props.pushMessage.initData && self.props.pushMessage.initData.items[self.state.currentState]
|
|
|
+ && self.props.pushMessage.initData.items[self.state.currentState].message
|
|
|
+ ) {
|
|
|
+ let keys = self.props.pushMessage.initData.items[self.state.currentState]
|
|
|
+ keys ? chooseKey = keys.message && keys.message.msgType : chooseKey = "text"
|
|
|
+ let item = self.props.pushMessage.selectKesData.items[self.state.currentState]
|
|
|
+ item ? cutextKey = item.message && item.message.msgType : cutextKey = "text"
|
|
|
+ message1 = self.props.pushMessage.initData.items[self.state.currentState].message;
|
|
|
+ message1.content = self.props.pushMessage.initData.items[self.state.currentState].message.content ?
|
|
|
+ self.props.pushMessage.initData.items[self.state.currentState].message.content : this.state.contentValueItem
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className={styles.connect} style={{ display: (key === self.state.currentState) ? "block" : "none" }}>
|
|
|
+ <div className={styles.Munstate}>
|
|
|
+ <div>状态:</div>
|
|
|
+ <Switch checked={disable} defaultChecked onChange={(v) => { self.conTroller(v, key) }} />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className={styles.TimePickers}>
|
|
|
+ 时间段:
|
|
|
+ <Select value={weekItem} style={{ width: 120 }} className={styles.Select} onChange={(v) => { self.handleChange(v, key) }}>
|
|
|
+ {
|
|
|
+ week.map((item, key) => {
|
|
|
+ return <Option value={item.key} key={item.key}>{item.name}</Option>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </Select>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ {TimeRangePicker && TimeRangePicker.map((item, key1) => {
|
|
|
+ return <div style={{ marginBottom: "10px" }}>
|
|
|
+ <TimePicker value={item.value} onChange={e => self.handleClick(e, key1, key)} format={format} style={{ marginTop: "10px" }} />
|
|
|
+ <Icon type="minus-circle" size="30px" style={{ marginLeft: '30px', fontSize: '30px' }} onClick={() => { self.remove(key, key1) }}></Icon>
|
|
|
+ </div>
|
|
|
+ })}
|
|
|
+ <Button type="dashed" size="30px" style={{ marginLeft: '30px' }} onClick={() => { self.add(key) }}>添加时间段</Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className={styles.contentList}>
|
|
|
+ <MsgComponent tabIndex={key}
|
|
|
+ {...message1}
|
|
|
+ chooseKey={chooseKey}
|
|
|
+ cutextKey={cutextKey}
|
|
|
+ selectKeys={self.state.currentState}
|
|
|
+ bottomFriom={(key) => { self.handleSubmit(key) }}
|
|
|
+ mediaIdChange={(v) => { self.cb_mediaId(v, key) }}
|
|
|
+ onChange={(v, av) => { self.cb_formChange(v, av, key) }}
|
|
|
+ chooseKeyChange={(v) => { self.cb_chooseKey(v, key) }}
|
|
|
+ updateFrom={(v) => { self.updateFromMessage(v, key) }}
|
|
|
+ className={styles.from}
|
|
|
+ wrappedComponentRef={ref => { (self.state.msgComponent[key]) = ref }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <Button className={styles.bthRight} size="large" type="primary" onClick={() => { self.handleSubmit(key) }}>保存</Button>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+PushMessage.propTypes = {
|
|
|
+ dispatch: PropTypes.func,
|
|
|
+ loading: PropTypes.object,
|
|
|
+ state: PropTypes.string
|
|
|
+}
|
|
|
+export default connect(({ loading, dispatch, sellmanage: { wxAppIdValue }, pushMessage }) => ({ wxAppIdValue, loading, dispatch, pushMessage }))(PushMessage)
|