publicContent.jsx 33 KB

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