publicContent.jsx 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. import React, { Component } from "react";
  2. import Taro from "@tarojs/taro";
  3. import { Button, Text, View, Radio, RadioGroup, Label } from "@tarojs/components";
  4. import dayjs from "dayjs";
  5. import "./index.less";
  6. import ImagePicker from "../../components/common/imagePicker";
  7. import { AtButton, AtTextarea, AtIcon, AtCalendar } from "taro-ui";
  8. import {
  9. addPublicRelease,
  10. getWorkingHoursList,
  11. checkOrderNoDuration,
  12. getRestrictProjectUser,
  13. } from "../../utils/servers/servers";
  14. import {
  15. getHours,
  16. getNumHourse,
  17. getUserWordTimes,
  18. getNameList,
  19. isPublicity,
  20. } from "../../utils/tools";
  21. import "taro-ui/dist/style/components/form.scss";
  22. import "taro-ui/dist/style/components/button.scss";
  23. import "taro-ui/dist/style/components/loading.scss";
  24. import "taro-ui/dist/style/components/icon.scss";
  25. import "taro-ui/dist/style/components/icon.scss";
  26. import "taro-ui/dist/style/components/textarea.scss";
  27. import "taro-ui/dist/style/components/calendar.scss";
  28. import "./publicContent.less";
  29. import InquiryModal from "../../components/common/inquiryModal"; //提示弹窗
  30. import UserQuery from "../../components/common/userquery"; //选择协单人弹窗
  31. class PublicContent extends Component {
  32. constructor(props) {
  33. super(props);
  34. this.state = {
  35. rangeStartVal: "",
  36. rangeEndVal: "",
  37. rangeEndMinuteVal: "",
  38. rangeStartMinuteVal: "",
  39. reason: "",
  40. plan: "",
  41. expectedEffect: "",
  42. imgs: [],
  43. validDates: [],
  44. totalDuration: 0,
  45. loading: false,
  46. workTypeList: [],
  47. workType: 0,
  48. isPickerRender: false,
  49. coorderList: [],
  50. cList: [],
  51. popup: false,
  52. isNewshow: false,
  53. alone: 1, // 0非协单 1协单一起 2技术单独协单
  54. };
  55. this.onSubmit = this.onSubmit.bind(this);
  56. this.selectArrder = this.selectArrder.bind(this);
  57. this.onChange = this.onChange.bind(this);
  58. this.getWorkingHoursList = this.getWorkingHoursList.bind(this);
  59. this.onPickerHide = this.onPickerHide.bind(this);
  60. this.onSetPickerTime = this.onSetPickerTime.bind(this);
  61. this.getNumHourse = this.getNumHourse.bind(this);
  62. }
  63. componentDidMount() {
  64. Taro.eventCenter.on("result", () => {
  65. this.imagePickerRef && this.imagePickerRef.clear();
  66. this.setState({
  67. rangeStartVal: "",
  68. rangeEndVal: "",
  69. rangeEndMinuteVal: "",
  70. rangeStartMinuteVal: "",
  71. reason: "",
  72. plan: "",
  73. expectedEffect: "",
  74. imgs: [],
  75. validDates: [],
  76. totalDuration: 0,
  77. loading: false,
  78. });
  79. });
  80. this.getWorkingHoursList();
  81. }
  82. getNumHourse(startTime, endTime) {
  83. this.setState({
  84. totalDuration: getNumHourse(
  85. startTime,
  86. endTime,
  87. this.state.validDates.length
  88. ),
  89. });
  90. }
  91. // 增加 省 市 区拼接,地址带区域的则把区域去掉
  92. getArea() {
  93. const { selectArrderLocation } = this.props
  94. let address = selectArrderLocation.name;
  95. let defaultProvince = selectArrderLocation.province || "";
  96. let defaultCity = selectArrderLocation.city || "";
  97. let defaultDistrict = selectArrderLocation.district || "";
  98. // 假设省市区的关键字有 "省", "市", "区"
  99. const provinceKeyword = '省';
  100. const cityKeyword = '市';
  101. const districtKeyword = '区';
  102. // 判断是否包含省市区关键字,如果不包含则进行补全
  103. if (address.indexOf(provinceKeyword) === -1) {
  104. address = `${defaultProvince}${address}`;
  105. }
  106. if (address.indexOf(cityKeyword) === -1) {
  107. address = address.replace(provinceKeyword, `${provinceKeyword}${defaultCity}`);
  108. }
  109. if (address.indexOf(districtKeyword) !== -1 && address.indexOf("小区") !== -1) {
  110. address = address.replace(cityKeyword, `${cityKeyword}${defaultDistrict}`);
  111. } else if (address.indexOf(districtKeyword) === -1) {
  112. address = address.replace(cityKeyword, `${cityKeyword}${defaultDistrict}`);
  113. }
  114. return address;
  115. }
  116. onSubmit() {
  117. let objectType = this.props.enterpriseInfor.id.indexOf(',') > -1 ? 1 : 0
  118. this.setState({
  119. loading: true,
  120. });
  121. let datas = {
  122. objectType,
  123. uids: this.props.enterpriseInfor.id,
  124. releaseStarts: this.state.rangeStartMinuteVal,
  125. releaseEnds: this.state.rangeEndMinuteVal,
  126. districtName: this.getArea(),
  127. addressName: this.props.selectArrderLocation.province + this.props.selectArrderLocation.city + this.props.selectArrderLocation.district,
  128. longitude: this.props.selectArrderLocation.longitude,
  129. latitude: this.props.selectArrderLocation.latitude,
  130. annexUrl: this.state.imgs.length === 0 ? "" : this.state.imgs.join(","),
  131. duration: this.state.totalDuration,
  132. type: this.props.enterpriseInfor.type,
  133. validDate: JSON.stringify(this.state.validDates),
  134. alone: this.state.coorderList.length === 0 ? 0 : this.state.alone,
  135. assist: this.state.coorderList.length === 0 ? 0 : 1,
  136. assistAid: this.state.coorderList.length === 0 ? "" : this.state.coorderList.join(","),
  137. assistAidName: this.state.coorderList.length === 0 ? "" : getNameList(this.state.coorderList, this.state.cList).join(","),
  138. };
  139. if (this.props.enterpriseInfor.type == 0 && this.props.uaiIdList.length) {
  140. datas.uaiId = this.props.uaiIdList.join(',');
  141. } else if (this.props.enterpriseInfor.type == 2) {
  142. datas = datas;
  143. datas = { ...datas, remarks: this.state.reason };
  144. } else {
  145. datas = {
  146. ...datas,
  147. ...{
  148. remarks: this.state.reason,
  149. plan: this.state.plan,
  150. expectedEffect: this.state.expectedEffect,
  151. orderNo: this.props.enterpriseInfor.orderNo,
  152. }
  153. };
  154. }
  155. addPublicRelease(datas)
  156. .then((v) => {
  157. this.setState({
  158. loading: false,
  159. });
  160. let newData = {
  161. ...v.data,
  162. ...{
  163. isShow: this.props.enterpriseInfor.type == 0
  164. ? isPublicity(this.props.enterpriseInfor.userList, 0) : this.props.enterpriseInfor.type == 1
  165. ? this.state.isNewshow : false,
  166. list: isPublicity(this.props.enterpriseInfor.userList, 1)
  167. }
  168. }
  169. if (v.error.length === 0) {
  170. Taro.eventCenter.trigger("publicContent", newData);
  171. } else {
  172. Taro.showToast({
  173. title: v.error[0].message,
  174. icon: "none",
  175. });
  176. }
  177. })
  178. .catch(() => {
  179. this.setState({
  180. loading: false,
  181. });
  182. });
  183. }
  184. selectArrder() {
  185. const key = "AWBBZ-GRAC2-JFYUO-CLA7I-JAHXK-YFFGT"; //使用在腾讯位置服务申请的key
  186. const referer = "科德打卡定位"; //调用插件的app的名称
  187. const category = "公司企业,房产小区";
  188. Taro.navigateTo({
  189. url:
  190. "plugin://chooseLocation/index?key=" +
  191. key +
  192. "&referer=" +
  193. referer +
  194. "&category=" +
  195. category,
  196. });
  197. }
  198. onChange(value, type) {
  199. let arr = this.state.imgs.concat([]);
  200. if (type === "add") {
  201. arr.push(value);
  202. } else if (type === "remove") {
  203. arr.splice(value, 1);
  204. }
  205. this.setState({
  206. imgs: arr,
  207. });
  208. }
  209. getWorkingHoursList() {
  210. getWorkingHoursList({})
  211. .then((v) => {
  212. if (v.error.length === 0) {
  213. let obj = Taro.getStorageSync("userInfor");
  214. let index = v.data.findIndex(
  215. (value) => value.type === obj.workTimeInfor.type
  216. );
  217. this.setState({
  218. workType: index !== -1 ? index : 0,
  219. });
  220. this.setState({
  221. workTypeList: v.data,
  222. });
  223. } else {
  224. Taro.showToast({
  225. title: v.error[0].message,
  226. icon: "none",
  227. });
  228. }
  229. })
  230. .catch((err) => {
  231. //console.log(err);
  232. });
  233. }
  234. onPickerHide() {
  235. this.setState({
  236. isPickerRender: false,
  237. });
  238. }
  239. onSetPickerTime(val) {
  240. let data = val.detail;
  241. this.setState({
  242. rangeStartMinuteVal: data.selectStartTime,
  243. rangeEndMinuteVal: data.selectEndTime,
  244. });
  245. let arr = [];
  246. if (data.startTime && data.endTime) {
  247. let a = dayjs(data.startTime);
  248. let b = dayjs(data.endTime);
  249. let num;
  250. if (a.hour() <= b.hour()) {
  251. num = b.diff(a, "day") + 1;
  252. } else {
  253. num = b.diff(a, "day") + 2;
  254. }
  255. let strAdd = data.startTime;
  256. for (let i = 0; i < num; i++) {
  257. let time = dayjs(strAdd).add(i, "days").format("YYYY-MM-DD");
  258. arr.push({ value: time });
  259. }
  260. }
  261. this.setState({
  262. rangeEndVal: dayjs(data.endTime).format("YYYY-MM-DD"),
  263. rangeStartVal: dayjs(data.startTime).format("YYYY-MM-DD"),
  264. validDates: arr,
  265. }, () => {
  266. let a1 = dayjs(dayjs(data.endTime).format("YYYY-MM-DD HH:mm:ss"));
  267. let b1 = dayjs(dayjs(data.startTime).format("YYYY-MM-DD HH:mm:ss"));
  268. this.getNumHourse(b1, a1);
  269. });
  270. }
  271. // 新增技术协单
  272. setList(list, arr) {
  273. this.setState({
  274. cList: list,
  275. coorderList: arr
  276. })
  277. }
  278. // 弹窗开关
  279. popupClick() {
  280. this.setState({
  281. popup: !this.state.popup
  282. })
  283. }
  284. // 技术公出逻辑判断
  285. checkOrderNoDuration() {
  286. const _this = this
  287. if (this.state.totalDuration == 0) {
  288. Taro.showToast({ title: "请选择公出时间", icon: "none" });
  289. return
  290. }
  291. checkOrderNoDuration({
  292. duration: this.state.totalDuration,
  293. orderNo: this.props.enterpriseInfor.orderNo,
  294. })
  295. .then((v) => {
  296. if (v.error.length == 0) {
  297. if (!v.data.code) {
  298. let obj = v.data.data
  299. _this.setState({
  300. isNewshow: true,
  301. isInquiryOpened: true,
  302. inquiryTitle: "提醒",
  303. inquiryContent: <View style={{ padding: "10px 15px" }}>
  304. <View>您准备公出<Text style={{ color: 'red' }}>{obj.userName}({obj.contractNo})</Text>,</View>
  305. <View>总计公出:<Text style={{ color: 'red' }}>{obj.peopleCount}人,{obj.timesCount}次,{obj.durationCount}时</Text>。</View>
  306. <View>
  307. <Text style={{ color: 'red' }}>
  308. {obj.amountName},{obj.amountType}
  309. </Text>。
  310. </View>
  311. <View>如需公出,需<Text style={{ color: 'red' }}>{obj.adminName}</Text>审核。</View>
  312. <View>请确定,是否发起公出申请!</View>
  313. </View>,
  314. inquiryFn: () => {
  315. _this.onSubmit();
  316. },
  317. })
  318. } else {
  319. _this.setState({
  320. isNewshow: false,
  321. isInquiryOpened: true,
  322. inquiryTitle: "提醒",
  323. inquiryContent: "您确定要提交此申请吗?",
  324. inquiryFn: () => {
  325. _this.onSubmit();
  326. },
  327. })
  328. }
  329. } else {
  330. Taro.showToast({
  331. title: v.error[0].message,
  332. icon: "none",
  333. });
  334. }
  335. })
  336. .catch(() => {
  337. this.setState({
  338. loading: false,
  339. });
  340. });
  341. }
  342. // 业务公出限定项目
  343. getRestrictProjectUser() {
  344. const _this = this
  345. getRestrictProjectUser({
  346. ids: this.props.enterpriseInfor.id,
  347. })
  348. .then((v) => {
  349. if (v.error.length === 0) {
  350. let arr = []
  351. if (v.data && v.data.length > 0) {
  352. v.data.forEach(e => {
  353. e.type == 1 && arr.push(e["userName"])
  354. })
  355. }
  356. this.setState({
  357. isInquiryOpened: true,
  358. inquiryTitle: "提醒",
  359. inquiryContent: arr.length > 0
  360. ? <View style={{ color: 'red' }}>您公出的{arr.toString()},为限定项目的企业,建议您由经理协助公出恰谈!</View>
  361. : "您确定要提交此申请吗?",
  362. inquiryFn: () => {
  363. _this.onSubmit();
  364. },
  365. });
  366. } else {
  367. Taro.showToast({
  368. title: v.error[0].message,
  369. icon: "none",
  370. });
  371. }
  372. })
  373. .catch((err) => {
  374. });
  375. }
  376. render() {
  377. const { cList, coorderList, popup } = this.state
  378. const info = Taro.getStorageSync("userInfor");
  379. return (
  380. <View className="publicContent">
  381. <View className="formItem">
  382. <View className="formName">公出企业:</View>
  383. <View className="formValue" style={{ flexDirection: "column", alignItems: "flex-end" }}>
  384. {
  385. !!this.props.enterpriseInfor.name && this.props.enterpriseInfor.name.indexOf(',') > -1
  386. ? this.props.enterpriseInfor.name.split(',')?.map((item, index) => <View key={index}>{item}</View>)
  387. : this.props.enterpriseInfor.name
  388. }
  389. </View>
  390. </View>
  391. {
  392. (this.props.enterpriseInfor.type == 0 && isPublicity(this.props.enterpriseInfor.userList, 0)) &&
  393. <View className="othersTips">您正在申请公出他人企业:需跟单员“
  394. {isPublicity(this.props.enterpriseInfor.userList, 1).toString()}
  395. ”审核同意,您才可公出!</View>
  396. }
  397. <View className="formItem">
  398. <View className="formName">公出类型:</View>
  399. <View className="formValue">
  400. {this.props.enterpriseInfor.type == 0
  401. ? "业务公出" : this.props.enterpriseInfor.type == 1
  402. ? "技术公出" : this.props.enterpriseInfor.type == 2
  403. ? "行政公出" : this.props.enterpriseInfor.type == 3
  404. ? "技术协单" : ""}
  405. </View>
  406. </View>
  407. {this.props.enterpriseInfor.contractNo ? (
  408. <View className="formItem">
  409. <View className="formName">合同编号:</View>
  410. <View className="formValue">
  411. {this.props.enterpriseInfor.contractNo}
  412. </View>
  413. </View>
  414. ) : (
  415. ""
  416. )}
  417. <View className="formItem">
  418. <View className="formName">作息时间类型:</View>
  419. <View className="formValue">
  420. {this.state.workTypeList[this.state.workType]
  421. ? this.state.workTypeList[this.state.workType].name
  422. : ""}
  423. </View>
  424. </View>
  425. <View className="formItem">
  426. <View className="formName">公出时间:</View>
  427. <View className="formValue">
  428. <View
  429. className="time"
  430. onClick={() => {
  431. this.setState({
  432. isPickerRender: true,
  433. });
  434. }}
  435. >
  436. {this.state.rangeStartMinuteVal &&
  437. this.state.rangeEndMinuteVal ? (
  438. <View className="timeContent">
  439. <View>开始时间:{this.state.rangeStartMinuteVal}</View>
  440. <View>结束时间:{this.state.rangeEndMinuteVal}</View>
  441. </View>
  442. ) : (
  443. "请选择公出时间"
  444. )}
  445. </View>
  446. <timePicker
  447. config={{
  448. endDate: true,
  449. column: "minute",
  450. dateLimit: false,
  451. // initStartTime: "2019-01-01 12:32:44", //默认开始时间
  452. // initEndTime: "2019-12-01 12:32:44", //默认结束时间
  453. limitStartTime: dayjs()
  454. .subtract(3, "year")
  455. .format("YYYY-MM-DD HH:mm:ss"),
  456. limitEndTime: dayjs()
  457. .add(3, "year")
  458. .format("YYYY-MM-DD HH:mm:ss"),
  459. }}
  460. isPartition
  461. pickerShow={this.state.isPickerRender}
  462. onconditionaljudgment={(v) => {
  463. let a = dayjs(
  464. dayjs(v.detail.endTime)
  465. .second(0)
  466. .format("YYYY-MM-DD HH:mm:ss")
  467. );
  468. let b = dayjs(dayjs().second(0).format("YYYY-MM-DD HH:mm:ss"));
  469. if (a.isBefore(b)) {
  470. Taro.showToast({
  471. title: "结束时间不能小于当前时间",
  472. icon: "none",
  473. });
  474. v.detail.setLv(false);
  475. }
  476. }}
  477. onhidepicker={() => {
  478. this.onPickerHide();
  479. }}
  480. onsetpickertime={(v) => {
  481. this.onSetPickerTime(v);
  482. }}
  483. />
  484. </View>
  485. </View>
  486. <View className="formItem">
  487. <View className="formName">总时长:</View>
  488. <View className="formValue">{this.state.totalDuration}小时</View>
  489. </View>
  490. {this.state.validDates.length !== 0 ? (
  491. <View
  492. className="formItem"
  493. style={{ display: "block", paddingTop: "15px" }}
  494. >
  495. <View className="formName">
  496. <View>去除放假时间:</View>
  497. </View>
  498. <View className="tips">
  499. 绿色方块为公出时间,长按即可去除放假时间
  500. </View>
  501. <AtCalendar
  502. currentDate={this.state.rangeStartVal}
  503. minDate={this.state.rangeStartVal}
  504. maxDate={this.state.rangeEndVal}
  505. isSwiper={false}
  506. validDates={this.state.validDates}
  507. onDayLongClick={(item) => {
  508. if (
  509. !(
  510. dayjs(item.value).isSame(this.state.rangeStartVal) ||
  511. dayjs(item.value).isSame(this.state.rangeEndVal)
  512. )
  513. ) {
  514. if (
  515. !(
  516. dayjs(item.value).isAfter(this.state.rangeStartVal) &&
  517. dayjs(item.value).isBefore(this.state.rangeEndVal)
  518. )
  519. ) {
  520. return;
  521. }
  522. } else {
  523. Taro.showToast({
  524. title: "开始结束时间不能取消",
  525. icon: "none",
  526. });
  527. return;
  528. }
  529. let index = this.state.validDates.findIndex((v) => {
  530. let lv = dayjs(v.value).isSame(item.value);
  531. return lv;
  532. });
  533. const { start, end } = getUserWordTimes();
  534. let totalDuration = getHours(
  535. dayjs().format("YYYY-MM-DD") + start,
  536. dayjs(dayjs().format("YYYY-MM-DD") + end)
  537. ); //一天工作时长
  538. if (index < 0) {
  539. let arr = item.value.split("-");
  540. this.state.validDates.push({ value: arr.join("-") });
  541. this.setState({
  542. validDates: this.state.validDates,
  543. totalDuration: this.state.totalDuration + totalDuration,
  544. });
  545. } else {
  546. this.state.validDates.splice(index, 1);
  547. this.setState({
  548. validDates: this.state.validDates,
  549. totalDuration: this.state.totalDuration - totalDuration,
  550. });
  551. }
  552. }}
  553. />
  554. </View>
  555. ) : null}
  556. <View className="formItem" style={{ paddingBottom: 0 }}>
  557. <View className="formName">公出地点:</View>
  558. <View className="formValue" onClick={this.selectArrder}>
  559. <Text className="formValueText">
  560. {this.props.selectArrderLocation.name}
  561. </Text>
  562. <AtIcon value="chevron-right" size="30" color="#bbbbbb" />
  563. </View>
  564. </View>
  565. <View className="tips">
  566. 以地图为中心100米范围为可打卡区域,移动红标只需要拖动地图即可
  567. </View>
  568. {
  569. this.props.enterpriseInfor.type === 0 &&
  570. <View className="formItems" style={{ alignItems: "center", paddingBottom: 0, marginTop: 10 }}>
  571. <View className="formNames">技术协单: </View>
  572. <View className="formValues" style={{ alignItems: "center" }}>
  573. {
  574. cList.length == 0
  575. ? <Text>无</Text>
  576. : cList.map((item, index) =>
  577. <View className="fitems" key={index}>
  578. {item.name}
  579. <View className="fclose"
  580. onClick={() => {
  581. coorderList.includes(item.id) &&
  582. (
  583. cList.splice(coorderList.indexOf(item.id), 1),
  584. coorderList.splice(coorderList.indexOf(item.id), 1)
  585. )
  586. this.setState({
  587. cList,
  588. coorderList,
  589. })
  590. }}
  591. ><AtIcon value="close-circle" size="15" color="#bbbbbb" /></View>
  592. </View>
  593. )
  594. }
  595. {cList.length < 5 && <Button className="addbuttom" type='primary' onClick={this.popupClick.bind(this)}>新增技术协单</Button>}
  596. </View>
  597. </View>
  598. }
  599. {
  600. this.props.enterpriseInfor.type === 0 &&
  601. <View className="tips">
  602. 请与技术协商后,再发起协单,协单将统计公出成本等
  603. </View>
  604. }
  605. {
  606. cList.length >= 1 &&
  607. <View
  608. className="formItem"
  609. style={{ paddingBottom: 0, marginTop: 10 }}
  610. >
  611. <View className="formName">
  612. <Text>本人公出:</Text>
  613. </View>
  614. <View>
  615. <RadioGroup
  616. onChange={e => {
  617. this.setState({
  618. alone: e.detail.value
  619. })
  620. }}
  621. >
  622. {[{ text: "是,一同公出", value: 1 },
  623. { text: "否,本人不公出", value: 2 }].map((item, i) => {
  624. return (
  625. <Radio
  626. style={{ marginLeft: 10 }}
  627. key={i}
  628. value={item.value}
  629. checked={item.value == this.state.alone}>
  630. {item.text}
  631. </Radio>
  632. )
  633. })}
  634. </RadioGroup>
  635. </View>
  636. </View>
  637. }
  638. <View
  639. className="formItem"
  640. style={{ display: "block", paddingTop: "10px" }}
  641. >
  642. {/* 公出目标 */}
  643. {[2, 3].indexOf(this.props.enterpriseInfor.type) > -1 && (
  644. <View className="formName">
  645. <Text><Text style={{ color: "red" }}>*</Text>公出目标:</Text>
  646. <View
  647. className="formValue"
  648. style={{ paddingTop: "10px", textAlign: "left" }}
  649. >
  650. <AtTextarea
  651. height={46}
  652. value={this.state.reason}
  653. onChange={(v) => {
  654. this.setState({
  655. reason: v,
  656. });
  657. }}
  658. maxLength={200}
  659. placeholder={
  660. this.props.enterpriseInfor.type == 2
  661. ? "详细说明本次公出的内容,预计完成的内容"
  662. : "本次公出目标,谈的思路与步骤?"
  663. }
  664. />
  665. </View>
  666. </View>
  667. )}
  668. {/* 公出计划 */}
  669. {this.props.enterpriseInfor.type == 1 && (
  670. <View className="formName">
  671. <Text><Text style={{ color: "red" }}>*</Text>公出计划:</Text>
  672. <View
  673. className="formValue"
  674. style={{ paddingTop: "10px", textAlign: "left" }}
  675. >
  676. <AtTextarea
  677. height={46}
  678. value={this.state.plan}
  679. onChange={(v) => {
  680. this.setState({
  681. plan: v,
  682. });
  683. }}
  684. maxLength={200}
  685. placeholder="本次公出准备工作"
  686. />
  687. </View>
  688. </View>
  689. )}
  690. {/* 预计效果 */}
  691. {this.props.enterpriseInfor.type == 1 && (
  692. <View className="formName">
  693. <Text><Text style={{ color: "red" }}>*</Text>预计效果:</Text>
  694. <View
  695. className="formValue"
  696. style={{ paddingTop: "10px", textAlign: "left" }}
  697. >
  698. <AtTextarea
  699. height={46}
  700. value={this.state.expectedEffect}
  701. onChange={(v) => {
  702. this.setState({
  703. expectedEffect: v,
  704. });
  705. }}
  706. maxLength={200}
  707. placeholder="预计本次公出效果"
  708. />
  709. </View>
  710. </View>
  711. )}
  712. </View>
  713. {/* */}
  714. <View className="formItem" style={{ display: "block", paddingBottom: 0 }}>
  715. <View className="formName">
  716. {this.state.totalDuration > info.workTimeInfor.minHours && <Text style={{ color: "red" }}>*</Text>}
  717. 附件:
  718. </View>
  719. {this.state.totalDuration > info.workTimeInfor.minHours &&
  720. <View className="tips">
  721. 请上传公出事由的凭证截图,如您与企业的对话截图等
  722. </View>}
  723. <View
  724. className="formValue"
  725. style={{ paddingTop: "10px", textAlign: "left" }}
  726. >
  727. <ImagePicker
  728. showAddBtn
  729. ref={(ref) => (this.imagePickerRef = ref)}
  730. url="/api/admin/release/upload"
  731. onChange={this.onChange}
  732. />
  733. </View>
  734. </View>
  735. <View className="operation">
  736. <AtButton
  737. disabled={this.state.loading}
  738. type="secondary"
  739. circle
  740. onClick={() => {
  741. Taro.eventCenter.trigger("enterpriseBack");
  742. }}
  743. >
  744. 上一步
  745. </AtButton>
  746. <AtButton
  747. type="primary"
  748. loading={this.state.loading}
  749. circle
  750. onClick={() => {
  751. if (this.state.loading) {
  752. return;
  753. }
  754. if (!this.state.rangeStartMinuteVal) {
  755. Taro.showToast({ title: "请选择公出时间", icon: "none" });
  756. return;
  757. }
  758. if (!this.state.rangeEndMinuteVal) {
  759. Taro.showToast({ title: "请选择公出时间", icon: "none" });
  760. return;
  761. }
  762. if (
  763. !(
  764. this.props.selectArrderLocation.longitude &&
  765. this.props.selectArrderLocation.latitude
  766. )
  767. ) {
  768. Taro.showToast({ title: "请选择公出地点", icon: "none" });
  769. return;
  770. }
  771. if (this.props.enterpriseInfor.type !=0 && !this.state.reason) {
  772. Taro.showToast({ title: "请输入公出目标", icon: "none" });
  773. return;
  774. }
  775. if (this.props.enterpriseInfor.type == 1 && !this.state.plan) {
  776. Taro.showToast({ title: "请输入公出计划", icon: "none" });
  777. return;
  778. }
  779. if (this.props.enterpriseInfor.type == 1 && !this.state.expectedEffect) {
  780. Taro.showToast({ title: "请输入预计效果", icon: "none" });
  781. return;
  782. }
  783. if (this.state.totalDuration === 0) {
  784. Taro.showToast({
  785. title: "请选择公出时间,目前设置公出时间不足0.5小时",
  786. icon: "none",
  787. });
  788. return;
  789. }
  790. let info = Taro.getStorageSync("userInfor");
  791. if (this.state.totalDuration > info.workTimeInfor.minHours && this.state.imgs.length == 0) {
  792. Taro.showToast({ title: "请上传附件", icon: "none" });
  793. return
  794. }
  795. this.props.enterpriseInfor.type == 1
  796. ? this.checkOrderNoDuration()
  797. : this.props.enterpriseInfor.type == 0
  798. ? this.getRestrictProjectUser()
  799. : this.setState({
  800. isInquiryOpened: true,
  801. inquiryTitle: "提醒",
  802. inquiryContent: "您确定要提交此申请吗?",
  803. inquiryFn: () => {
  804. this.onSubmit();
  805. },
  806. });
  807. }}
  808. >
  809. 提交申请
  810. </AtButton>
  811. </View>
  812. <InquiryModal
  813. isOpened={this.state.isInquiryOpened}
  814. title={this.state.inquiryTitle}
  815. content={this.state.inquiryContent}
  816. onClose={() => {
  817. this.setState({
  818. isInquiryOpened: false,
  819. inquiryTitle: "",
  820. inquiryContent: "",
  821. });
  822. }}
  823. onDetermine={() => {
  824. this.state.inquiryFn();
  825. this.setState({
  826. isInquiryOpened: false,
  827. inquiryTitle: "",
  828. inquiryContent: "",
  829. inquiryFn: () => { },
  830. });
  831. }}
  832. />
  833. {
  834. popup &&
  835. <UserQuery
  836. isOpened={popup}
  837. onDesc={this.popupClick.bind(this)}
  838. cList={cList}
  839. selList={[]}
  840. coorderList={coorderList}
  841. setList={this.setList.bind(this)}
  842. />
  843. }
  844. </View >
  845. );
  846. }
  847. }
  848. export default PublicContent;