base.jsx 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. import React, { useState, useEffect } from 'react';
  2. import {
  3. Form,
  4. Input,
  5. Button,
  6. Icon,
  7. Select,
  8. Tabs,
  9. Radio,
  10. DatePicker,
  11. message,
  12. Switch,
  13. InputNumber,
  14. } from 'antd';
  15. import moment from 'moment';
  16. import router from 'umi/router';
  17. import Navigate from '@/components/Navigate';
  18. import XForm, { FieldTypes, createForm } from '@/components/XForm';
  19. import apis from '@/services/apis';
  20. import BuildSelect2 from '@/components/SelectButton/BuildSelect2';
  21. import LivePlatSelect from '@/components/SelectButton/LivePlatSelect';
  22. import CitySelect3 from '@/components/SelectButton/CitySelect3';
  23. import ImageUpload from '@/components/XForm/ImageUpload';
  24. import request from '@/utils/request';
  25. import WxWorkLivingRoom from '@/components/LivingRoom/WxWork';
  26. import AuthButton from '@/components/AuthButton';
  27. const { Option } = Select;
  28. let cityId = '';
  29. const header = props => {
  30. console.log(props);
  31. const liveActivityId = props.liveActivityId.liveId;
  32. console.log(liveActivityId);
  33. const [liveActivityData, setLiveActivityData] = useState({});
  34. const [showHelp, setShowHelp] = useState(false);
  35. useEffect(() => {
  36. if (liveActivityId) {
  37. getLiveActivityData(liveActivityId);
  38. }
  39. }, []);
  40. // 查询列表
  41. const getLiveActivityData = liveActivityId => {
  42. request({ ...apis.taliveActivity.getTaLiveActivity, urlData: { id: liveActivityId } }).then(
  43. data => {
  44. console.log(data, 'getLiveActivityData');
  45. setLiveActivityData(data.data);
  46. // if(data.qrCode == 'null'){
  47. // message.error("暂时无法获取二维码")
  48. // }
  49. },
  50. );
  51. };
  52. const cancelPage = () => {
  53. router.go('-1');
  54. };
  55. //打开新页面
  56. const openIndexImg = () => {
  57. const newWin = window.open('about:blank');
  58. newWin.location.href = 'http://njcj.oss-cn-shanghai.aliyuncs.com/%E6%95%99%E7%A8%8B.png';
  59. };
  60. function highlightsTypeChange(e) {
  61. console.log(e.target.value, 'ee');
  62. setTypeState(e.target.value);
  63. }
  64. function disabledDate(current) {
  65. // Can not select days before today and today
  66. return current && current < moment().endOf('day');
  67. }
  68. function handleSubmit(e) {
  69. e.preventDefault();
  70. props.form.validateFields((err, values) => {
  71. console.log(values, 'values');
  72. if (!err) {
  73. let { liveTime, ...submitValue } = values;
  74. if (submitValue.status == '已发布' || submitValue.status == '1') {
  75. submitValue.status = 1;
  76. } else {
  77. submitValue.status = 0;
  78. }
  79. if (values.liveStartDate > values.liveEndDate) {
  80. message.info('直播结束时间大于开始时间');
  81. return;
  82. }
  83. submitValue.liveStartDate = moment(submitValue.liveStartDate._d).format(
  84. 'YYYY-MM-DD HH:mm:ss',
  85. );
  86. submitValue.liveEndDate = moment(submitValue.liveEndDate._d).format('YYYY-MM-DD HH:mm:ss');
  87. console.log(submitValue);
  88. request({
  89. ...apis.taliveActivity.updateTaLiveActivity,
  90. urlData: { id: liveActivityId },
  91. data: submitValue,
  92. })
  93. .then(data => {
  94. message.info('保存成功');
  95. cancelPage();
  96. })
  97. .catch(err => {
  98. message.info(err.msg || err.message);
  99. });
  100. }
  101. });
  102. }
  103. const { getFieldDecorator } = props.form;
  104. return (
  105. <>
  106. <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
  107. <Form.Item label="所属城市">
  108. {getFieldDecorator('cityId', {
  109. initialValue: liveActivityData.cityId,
  110. rules: [{ required: true, message: ' 请选择所属城市' }],
  111. })(<CitySelect3 buildingId={props.form.getFieldValue('buildingId')} />)}
  112. </Form.Item>
  113. <Form.Item label="所属楼盘">
  114. {getFieldDecorator('buildingId', {
  115. initialValue: liveActivityData.buildingId,
  116. rules: [{ required: true, message: ' 请选择所属楼盘' }],
  117. })(<BuildSelect2 cityId={props.form.getFieldValue('cityId')} />)}
  118. </Form.Item>
  119. <Form.Item label="直播活动标题">
  120. {getFieldDecorator('liveActivityTitle', {
  121. initialValue: liveActivityData.liveActivityTitle,
  122. rules: [{ required: true, message: '请输入直播活动标题' }],
  123. })(<Input maxLength={20} placeholder="给直播活动起个名字" />)}
  124. </Form.Item>
  125. <Form.Item label="直播开始时间">
  126. {getFieldDecorator('liveStartDate', {
  127. initialValue: liveActivityData.liveStartDate
  128. ? moment(liveActivityData.liveStartDate, 'YYYY-MM-DD HH:mm:ss')
  129. : null,
  130. rules: [
  131. {
  132. required: true,
  133. message: '请选择直播开始时间',
  134. },
  135. ],
  136. })(
  137. <DatePicker
  138. placeholder="预计开始时间"
  139. style={{ width: '500px' }}
  140. format="YYYY-MM-DD HH:mm:ss"
  141. showTime={{ format: 'HH:mm:ss' }}
  142. />,
  143. )}
  144. </Form.Item>
  145. <Form.Item label="直播结束时间">
  146. {getFieldDecorator('liveEndDate', {
  147. initialValue: liveActivityData.liveEndDate
  148. ? moment(liveActivityData.liveEndDate, 'YYYY-MM-DD HH:mm:ss')
  149. : null,
  150. rules: [
  151. {
  152. required: true,
  153. message: '请选择直播结束时间',
  154. },
  155. ],
  156. })(
  157. <DatePicker
  158. placeholder="预计结束时间"
  159. disabledDate={disabledDate}
  160. style={{ width: '500px' }}
  161. format="YYYY-MM-DD HH:mm:ss"
  162. showTime={{ format: 'HH:mm:ss' }}
  163. />,
  164. )}
  165. </Form.Item>
  166. <Form.Item label="是否新房">
  167. {getFieldDecorator('isNewHouse', {
  168. valuePropName: 'checked',
  169. initialValue: liveActivityData.isNewHouse || false,
  170. })(<Switch />)}
  171. </Form.Item>
  172. {/* <Form.Item label="直播小程序">
  173. {getFieldDecorator('liveApp', {
  174. initialValue: liveActivityData.liveApp,
  175. rules: [{ required: true, message: '请选择直播小程序' }],
  176. })(<LivePlatSelect />)}
  177. </Form.Item> */}
  178. {/* <Form.Item label="房间参数">
  179. {getFieldDecorator('liveRoomParam', {
  180. initialValue: liveActivityData.liveRoomParam,
  181. rules: [{ required: true, message: '请输入房间参数' }],
  182. })(
  183. <Input
  184. maxLength={1000}
  185. placeholder="点击右侧按钮查看如何获取房间参数"
  186. style={{ width: '680px' }}
  187. />,
  188. )}
  189. <Navigate onClick={openIndexImg}>不知道怎么填?查看说明</Navigate>
  190. </Form.Item> */}
  191. <Form.Item label="选择直播间">
  192. {getFieldDecorator('liveRoomParam', {
  193. initialValue: liveActivityData.liveRoomParam,
  194. rules: [{ required: true, message: '请选择直播间' }],
  195. })(<WxWorkLivingRoom placeholder="请选择直播间" />)}
  196. </Form.Item>
  197. <Form.Item label="封面图" help="建议尺寸:335px*201px,比例5:3,格式:jpg,用于:活动列表">
  198. {getFieldDecorator('listImg', {
  199. initialValue: liveActivityData.listImg,
  200. rules: [{ required: true, message: '请上传封面图1' }],
  201. })(<ImageUpload />)}
  202. </Form.Item>
  203. {/* <Form.Item label="封面图2" help="建议尺寸:750*250px,比例3:1,格式:jpg,用于:项目详情页">
  204. {getFieldDecorator('detailImg', {
  205. initialValue: liveActivityData.detailImg,
  206. rules: [{ required: true, message: '请上传封面图2' }],
  207. })(<ImageUpload />)}
  208. </Form.Item> */}
  209. <Form.Item
  210. label="详情图"
  211. help="建议尺寸:750*1456px以上,格式:jpg,用于:直播活动详情页,点击可跳转到直播间"
  212. >
  213. {getFieldDecorator('detailTypeImg', {
  214. initialValue: liveActivityData.detailTypeImg,
  215. rules: [{ required: true, message: '请上传详情图' }],
  216. })(<ImageUpload style={{ width: '300px', height: '600px' }} />)}
  217. </Form.Item>
  218. <Form.Item label="权重">
  219. {getFieldDecorator('weight', {
  220. initialValue: liveActivityData.weight,
  221. })(<InputNumber placeholder="权重越大越靠前" style={{ width: '150px' }} />)}
  222. </Form.Item>
  223. {/* <Form.Item label="发布状态">
  224. {getFieldDecorator('status', {
  225. initialValue: liveActivityData.status == 1 ? '已发布' : '未发布',
  226. rules: [{ required: true, message: '请选择发布状态' }],
  227. })(
  228. <Select placeholder="发布状态" style={{ width: '300px' }}>
  229. <Option value="0">未发布</Option>
  230. <Option value="1">已发布</Option>
  231. </Select>,
  232. )}
  233. </Form.Item> */}
  234. <Form.Item wrapperCol={{ span: 15, offset: 7 }}>
  235. <AuthButton name="live.edit.submit" noRight={null}>
  236. <Button type="primary" htmlType="submit" style={{ marginRight: '20px' }}>
  237. 确定
  238. </Button>
  239. </AuthButton>
  240. <Button onClick={() => router.go(-1)}>取消</Button>
  241. </Form.Item>
  242. </Form>
  243. </>
  244. );
  245. };
  246. const Base = Form.create({ name: 'header' })(header);
  247. export default Base;