publicContent.jsx 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  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.uais = 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 startTimeD = dayjs(
  464. dayjs(v.detail.startTime)
  465. .second(0)
  466. .format("YYYY-MM-DD HH:mm:ss")
  467. );
  468. let endTimeD = dayjs(
  469. dayjs(v.detail.endTime)
  470. .second(0)
  471. .format("YYYY-MM-DD HH:mm:ss")
  472. );
  473. let currTimeD = dayjs(dayjs().second(0).format("YYYY-MM-DD HH:mm:ss"));
  474. if (!startTimeD.isAfter(currTimeD)) {
  475. Taro.showToast({
  476. title: "开始时间不能小于当前时间",
  477. icon: "none",
  478. });
  479. v.detail.setLv(false);
  480. } else if (!endTimeD.isAfter(startTimeD)) {
  481. Taro.showToast({
  482. title: "结束时间不能小于开始时间",
  483. icon: "none",
  484. });
  485. v.detail.setLv(false);
  486. }
  487. }}
  488. onhidepicker={() => {
  489. this.onPickerHide();
  490. }}
  491. onsetpickertime={(v) => {
  492. this.onSetPickerTime(v);
  493. }}
  494. />
  495. </View>
  496. </View>
  497. <View className="formItem">
  498. <View className="formName">总时长:</View>
  499. <View className="formValue">{this.state.totalDuration}小时</View>
  500. </View>
  501. {this.state.validDates.length !== 0 ? (
  502. <View
  503. className="formItem"
  504. style={{ display: "block", paddingTop: "15px" }}
  505. >
  506. <View className="formName">
  507. <View>去除放假时间:</View>
  508. </View>
  509. <View className="tips">
  510. 绿色方块为公出时间,长按即可去除放假时间
  511. </View>
  512. <AtCalendar
  513. currentDate={this.state.rangeStartVal}
  514. minDate={this.state.rangeStartVal}
  515. maxDate={this.state.rangeEndVal}
  516. isSwiper={false}
  517. validDates={this.state.validDates}
  518. onDayLongClick={(item) => {
  519. if (
  520. !(
  521. dayjs(item.value).isSame(this.state.rangeStartVal) ||
  522. dayjs(item.value).isSame(this.state.rangeEndVal)
  523. )
  524. ) {
  525. if (
  526. !(
  527. dayjs(item.value).isAfter(this.state.rangeStartVal) &&
  528. dayjs(item.value).isBefore(this.state.rangeEndVal)
  529. )
  530. ) {
  531. return;
  532. }
  533. } else {
  534. Taro.showToast({
  535. title: "开始结束时间不能取消",
  536. icon: "none",
  537. });
  538. return;
  539. }
  540. let index = this.state.validDates.findIndex((v) => {
  541. let lv = dayjs(v.value).isSame(item.value);
  542. return lv;
  543. });
  544. const { start, end } = getUserWordTimes();
  545. let totalDuration = getHours(
  546. dayjs().format("YYYY-MM-DD") + start,
  547. dayjs(dayjs().format("YYYY-MM-DD") + end)
  548. ); //一天工作时长
  549. if (index < 0) {
  550. let arr = item.value.split("-");
  551. this.state.validDates.push({ value: arr.join("-") });
  552. this.setState({
  553. validDates: this.state.validDates,
  554. totalDuration: this.state.totalDuration + totalDuration,
  555. });
  556. } else {
  557. this.state.validDates.splice(index, 1);
  558. this.setState({
  559. validDates: this.state.validDates,
  560. totalDuration: this.state.totalDuration - totalDuration,
  561. });
  562. }
  563. }}
  564. />
  565. </View>
  566. ) : null}
  567. <View className="formItem" style={{ paddingBottom: 0 }}>
  568. <View className="formName">公出地点:</View>
  569. <View className="formValue" onClick={this.selectArrder}>
  570. <Text className="formValueText">
  571. {this.props.selectArrderLocation.name}
  572. </Text>
  573. <AtIcon value="chevron-right" size="30" color="#bbbbbb" />
  574. </View>
  575. </View>
  576. <View className="tips">
  577. 以地图为中心100米范围为可打卡区域,移动红标只需要拖动地图即可
  578. </View>
  579. {
  580. this.props.enterpriseInfor.type === 0 &&
  581. <View className="formItems" style={{ alignItems: "center", paddingBottom: 0, marginTop: 10 }}>
  582. <View className="formNames">技术协单: </View>
  583. <View className="formValues" style={{ alignItems: "center" }}>
  584. {
  585. cList.length == 0
  586. ? <Text>无</Text>
  587. : cList.map((item, index) =>
  588. <View className="fitems" key={index}>
  589. {item.name}
  590. <View className="fclose"
  591. onClick={() => {
  592. coorderList.includes(item.id) &&
  593. (
  594. cList.splice(coorderList.indexOf(item.id), 1),
  595. coorderList.splice(coorderList.indexOf(item.id), 1)
  596. )
  597. this.setState({
  598. cList,
  599. coorderList,
  600. })
  601. }}
  602. ><AtIcon value="close-circle" size="15" color="#bbbbbb" /></View>
  603. </View>
  604. )
  605. }
  606. {cList.length < 5 && <Button className="addbuttom" type='primary' onClick={this.popupClick.bind(this)}>新增技术协单</Button>}
  607. </View>
  608. </View>
  609. }
  610. {
  611. this.props.enterpriseInfor.type === 0 &&
  612. <View className="tips">
  613. 请与技术协商后,再发起协单,协单将统计公出成本等
  614. </View>
  615. }
  616. {
  617. cList.length >= 1 &&
  618. <View
  619. className="formItem"
  620. style={{ paddingBottom: 0, marginTop: 10 }}
  621. >
  622. <View className="formName">
  623. <Text>本人公出:</Text>
  624. </View>
  625. <View>
  626. <RadioGroup
  627. onChange={e => {
  628. this.setState({
  629. alone: e.detail.value
  630. })
  631. }}
  632. >
  633. {[{ text: "是,一同公出", value: 1 },
  634. { text: "否,本人不公出", value: 2 }].map((item, i) => {
  635. return (
  636. <Radio
  637. style={{ marginLeft: 10 }}
  638. key={i}
  639. value={item.value}
  640. checked={item.value == this.state.alone}>
  641. {item.text}
  642. </Radio>
  643. )
  644. })}
  645. </RadioGroup>
  646. </View>
  647. </View>
  648. }
  649. <View
  650. className="formItem"
  651. style={{ display: "block", paddingTop: "10px" }}
  652. >
  653. {/* 公出目标 */}
  654. {[1, 2].indexOf(this.props.enterpriseInfor.type) > -1 && (
  655. <View className="formName">
  656. <Text><Text style={{ color: "red" }}>*</Text>公出目标:</Text>
  657. <View
  658. className="formValue"
  659. style={{ paddingTop: "10px", textAlign: "left" }}
  660. >
  661. <AtTextarea
  662. height={46}
  663. value={this.state.reason}
  664. onChange={(v) => {
  665. this.setState({
  666. reason: v,
  667. });
  668. }}
  669. maxLength={200}
  670. placeholder={
  671. this.props.enterpriseInfor.type == 2
  672. ? "详细说明本次公出的内容,预计完成的内容"
  673. : "本次公出目标,谈的思路与步骤?"
  674. }
  675. />
  676. </View>
  677. </View>
  678. )}
  679. {/* 公出计划 */}
  680. {this.props.enterpriseInfor.type == 1 && (
  681. <View className="formName">
  682. <Text><Text style={{ color: "red" }}>*</Text>公出计划:</Text>
  683. <View
  684. className="formValue"
  685. style={{ paddingTop: "10px", textAlign: "left" }}
  686. >
  687. <AtTextarea
  688. height={46}
  689. value={this.state.plan}
  690. onChange={(v) => {
  691. this.setState({
  692. plan: v,
  693. });
  694. }}
  695. maxLength={200}
  696. placeholder="本次公出准备工作"
  697. />
  698. </View>
  699. </View>
  700. )}
  701. {/* 预计效果 */}
  702. {this.props.enterpriseInfor.type == 1 && (
  703. <View className="formName">
  704. <Text><Text style={{ color: "red" }}>*</Text>预计效果:</Text>
  705. <View
  706. className="formValue"
  707. style={{ paddingTop: "10px", textAlign: "left" }}
  708. >
  709. <AtTextarea
  710. height={46}
  711. value={this.state.expectedEffect}
  712. onChange={(v) => {
  713. this.setState({
  714. expectedEffect: v,
  715. });
  716. }}
  717. maxLength={200}
  718. placeholder="预计本次公出效果"
  719. />
  720. </View>
  721. </View>
  722. )}
  723. </View>
  724. {/* */}
  725. <View className="formItem" style={{ display: "block", paddingBottom: 0 }}>
  726. <View className="formName">
  727. {this.state.totalDuration > info.workTimeInfor.minHours && <Text style={{ color: "red" }}>*</Text>}
  728. 附件:
  729. </View>
  730. {this.state.totalDuration > info.workTimeInfor.minHours &&
  731. <View className="tips">
  732. 请上传公出事由的凭证截图,如您与企业的对话截图等
  733. </View>}
  734. <View
  735. className="formValue"
  736. style={{ paddingTop: "10px", textAlign: "left" }}
  737. >
  738. <ImagePicker
  739. showAddBtn
  740. ref={(ref) => (this.imagePickerRef = ref)}
  741. url="/api/admin/release/upload"
  742. onChange={this.onChange}
  743. />
  744. </View>
  745. </View>
  746. <View className="operation">
  747. <AtButton
  748. disabled={this.state.loading}
  749. type="secondary"
  750. circle
  751. onClick={() => {
  752. Taro.eventCenter.trigger("enterpriseBack");
  753. }}
  754. >
  755. 上一步
  756. </AtButton>
  757. <AtButton
  758. type="primary"
  759. loading={this.state.loading}
  760. circle
  761. onClick={() => {
  762. if (this.state.loading) {
  763. return;
  764. }
  765. if (!this.state.rangeStartMinuteVal) {
  766. Taro.showToast({ title: "请选择公出时间", icon: "none" });
  767. return;
  768. }
  769. if (!this.state.rangeEndMinuteVal) {
  770. Taro.showToast({ title: "请选择公出时间", icon: "none" });
  771. return;
  772. }
  773. if (
  774. !(
  775. this.props.selectArrderLocation.longitude &&
  776. this.props.selectArrderLocation.latitude
  777. )
  778. ) {
  779. Taro.showToast({ title: "请选择公出地点", icon: "none" });
  780. return;
  781. }
  782. if (this.props.enterpriseInfor.type !=0 && !this.state.reason) {
  783. Taro.showToast({ title: "请输入公出目标", icon: "none" });
  784. return;
  785. }
  786. if (this.props.enterpriseInfor.type == 1 && !this.state.plan) {
  787. Taro.showToast({ title: "请输入公出计划", icon: "none" });
  788. return;
  789. }
  790. if (this.props.enterpriseInfor.type == 1 && !this.state.expectedEffect) {
  791. Taro.showToast({ title: "请输入预计效果", icon: "none" });
  792. return;
  793. }
  794. if (this.state.totalDuration === 0) {
  795. Taro.showToast({
  796. title: "请选择公出时间,目前设置公出时间不足0.5小时",
  797. icon: "none",
  798. });
  799. return;
  800. }
  801. let info = Taro.getStorageSync("userInfor");
  802. if (this.state.totalDuration > info.workTimeInfor.minHours && this.state.imgs.length == 0) {
  803. Taro.showToast({ title: "请上传附件", icon: "none" });
  804. return
  805. }
  806. this.props.enterpriseInfor.type == 1
  807. ? this.checkOrderNoDuration()
  808. : this.props.enterpriseInfor.type == 0
  809. ? this.getRestrictProjectUser()
  810. : this.setState({
  811. isInquiryOpened: true,
  812. inquiryTitle: "提醒",
  813. inquiryContent: "您确定要提交此申请吗?",
  814. inquiryFn: () => {
  815. this.onSubmit();
  816. },
  817. });
  818. }}
  819. >
  820. 提交申请
  821. </AtButton>
  822. </View>
  823. <InquiryModal
  824. isOpened={this.state.isInquiryOpened}
  825. title={this.state.inquiryTitle}
  826. content={this.state.inquiryContent}
  827. onClose={() => {
  828. this.setState({
  829. isInquiryOpened: false,
  830. inquiryTitle: "",
  831. inquiryContent: "",
  832. });
  833. }}
  834. onDetermine={() => {
  835. this.state.inquiryFn();
  836. this.setState({
  837. isInquiryOpened: false,
  838. inquiryTitle: "",
  839. inquiryContent: "",
  840. inquiryFn: () => { },
  841. });
  842. }}
  843. />
  844. {
  845. popup &&
  846. <UserQuery
  847. isOpened={popup}
  848. onDesc={this.popupClick.bind(this)}
  849. cList={cList}
  850. selList={[]}
  851. coorderList={coorderList}
  852. setList={this.setList.bind(this)}
  853. />
  854. }
  855. </View >
  856. );
  857. }
  858. }
  859. export default PublicContent;