index.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. import React,{Component} from "react";
  2. import { View,Image,Button } from '@tarojs/components'
  3. import Taro, { getCurrentInstance } from "@tarojs/taro";
  4. import {AtButton, AtCalendar, AtIcon, AtTextarea,AtModal, AtModalContent, AtModalAction} from 'taro-ui'
  5. import Skeleton from 'taro-skeleton'
  6. import InquiryModal from '../../components/common/inquiryModal';
  7. import Modify from './modify';
  8. import {examinePublicRelease,getReleasetDails,updatePublicRelease} from '../../utils/servers/servers';
  9. import {resourceAddress} from '../../utils/config';
  10. import './index.less';
  11. import 'taro-ui/dist/style/components/icon.scss';
  12. import 'taro-ui/dist/style/components/textarea.scss'
  13. import 'taro-ui/dist/style/components/modal.scss';
  14. import 'taro-ui/dist/style/components/timeline.scss';
  15. import 'taro-ui/dist/style/components/icon.scss';
  16. import 'taro-ui/dist/style/components/calendar.scss';
  17. import Rejected from '../../image/rejected.png';
  18. import Passed from '../../image/passed.png';
  19. import Reviewed from '../../image/reviewed.png';
  20. import Wx from '../../image/wx.png';
  21. import Revoke from '../../image/revoke.png';
  22. import ImagePicker from "../../components/common/imagePicker";
  23. import MessageNoticebar from "../../components/common/messageNoticebar";
  24. import {getClockState} from "../../utils/tools";
  25. import HistoricalClock from "../../components/historicalClock";
  26. class EgressDetails extends Component{
  27. $instance = getCurrentInstance()
  28. constructor(props) {
  29. super(props);
  30. this.state={
  31. dtails:{},
  32. opinion:'',
  33. publicReleaseLog:[],
  34. isDetailedOpened:false,
  35. isModifyOpened:false,
  36. selectArrderLocation:{}
  37. }
  38. this.examinePublicRelease= this.examinePublicRelease.bind(this);
  39. this.getReleasetDails= this.getReleasetDails.bind(this);
  40. this.oidApplication= this.oidApplication.bind(this);
  41. }
  42. componentDidMount() {
  43. this.getReleasetDails();
  44. }
  45. componentDidShow() {
  46. //获取地区选定数据
  47. const chooseLocation = requirePlugin('chooseLocation');
  48. const location = chooseLocation.getLocation();
  49. if(location){
  50. this.setState({
  51. selectArrderLocation: location
  52. })
  53. }
  54. }
  55. getReleasetDails(){
  56. getReleasetDails({
  57. id:this.$instance.router.params.id
  58. }).then(v=>{
  59. if(v.error.length === 0){
  60. if(v.data){
  61. let list = [];
  62. for(let i of v.data.annexUrl.split(',')){
  63. if(i){
  64. list.push({'url':resourceAddress + i})
  65. }
  66. }
  67. v.data.annexUrl = list;
  68. this.setState({
  69. dtails:v.data,
  70. selectArrderLocation:{
  71. longitude:parseFloat(v.data.longitude),
  72. latitude:parseFloat(v.data.latitude),
  73. name:v.data.userName
  74. }
  75. })
  76. }else{
  77. setTimeout(()=>{
  78. Taro.switchTab({
  79. url: '/pages/punchClock/index',
  80. })
  81. },1800)
  82. Taro.showToast({
  83. title:'您没有权限查看此公出详情',
  84. icon:'none',
  85. duration:1800,
  86. })
  87. }
  88. }else{
  89. Taro.showToast({title:v.error[0].message,icon:'none'})
  90. }
  91. }).catch(err=>{
  92. Taro.showToast({title:'系统错误,请稍后再试',icon:'none'});
  93. console.log(err)
  94. })
  95. }
  96. examinePublicRelease(status){
  97. if(!this.state.opinion){
  98. Taro.showToast({title:'请填写审批意见',icon:'none'})
  99. return;
  100. }
  101. Taro.showLoading({title:'加载中...'})
  102. examinePublicRelease({
  103. status,
  104. remarks:this.state.opinion,
  105. id:this.state.dtails.id
  106. }).then(v=>{
  107. Taro.hideLoading();
  108. if(v.error.length === 0){
  109. Taro.showToast({title:status===0?'驳回成功':'通过成功',icon:'none'});
  110. this.state.dtails.status=status;
  111. this.setState({
  112. dtails:this.state.dtails
  113. })
  114. Taro.eventCenter.trigger('listOperation',{
  115. type:this.state.dtails.permission,
  116. index:this.$instance.router.params.index,
  117. status:status===0?0:2
  118. })
  119. }else{
  120. Taro.showToast({title:v.error[0].message,icon:'none'})
  121. }
  122. }).catch(()=>{
  123. Taro.hideLoading();
  124. Taro.showToast({title:'系统错误,请稍后再试',icon:'none'})
  125. })
  126. }
  127. onShareAppMessage(){
  128. return {
  129. title: this.state.dtails.status === 3 ? this.state.dtails.aname+ '撤销了前往' + this.state.dtails.userName + '的公出' : this.state.dtails.aname+ '将要去' + this.state.dtails.userName,
  130. path: 'pages/egressDetails/index?id='+this.$instance.router.params.id
  131. }
  132. }
  133. oidApplication(){
  134. if(!this.state.reasonsInvalidation){
  135. Taro.showToast({title:'请填写撤销原因',icon:'none'})
  136. return;
  137. }
  138. this.setState({
  139. loading:true
  140. })
  141. updatePublicRelease({
  142. id:this.$instance.router.params.id,
  143. status:3,
  144. reason:this.state.reasonsInvalidation,
  145. }).then(v=>{
  146. this.setState({
  147. loading:false
  148. })
  149. if(v.error.length === 0){
  150. Taro.showToast({
  151. title:'修改成功',
  152. })
  153. this.setState({
  154. isInquiryOpened:false,
  155. inquiryTitle:'',
  156. inquiryContent:'',
  157. },()=>{
  158. this.getReleasetDails();
  159. })
  160. Taro.eventCenter.trigger('listOperation',{
  161. type:this.state.dtails.permission,
  162. index:this.$instance.router.params.index,
  163. status: 3,
  164. })
  165. }else{
  166. Taro.showToast({
  167. title:v.error[0].message,
  168. icon:'none'
  169. })
  170. }
  171. }).catch(()=>{
  172. this.setState({
  173. loading:false
  174. })
  175. });
  176. }
  177. render() {
  178. const {dtails} = this.state;
  179. return (
  180. <View className='egressDetails'>
  181. <MessageNoticebar/>
  182. <View className='titleContent' style={{
  183. padding:Object.keys(dtails).length === 0? '0 30px' : '20px 30px'
  184. }}>
  185. {Object.keys(dtails).length === 0?
  186. <Skeleton title row={3} animateName='elastic' avatarShape='square' loading/>:
  187. <View>
  188. <View className='title'>{dtails.aname}提交的公出申请</View>
  189. <View className='address'>
  190. 申请时间: {dtails.createTimes}
  191. </View>
  192. <View className='state' style={{
  193. color:getClockState(dtails.status).color
  194. }}>
  195. {
  196. getClockState(dtails.status).title
  197. }
  198. </View>
  199. <Image src={
  200. dtails.status === 0 ? Rejected :
  201. dtails.status === 1 ? Reviewed :
  202. dtails.status === 2 ? Passed :
  203. dtails.status === 3 ? Revoke :''} className='startIcon'/>
  204. </View>
  205. }
  206. </View>
  207. {Object.keys(dtails).length === 0?
  208. <View style={{margin: '20px'}}>
  209. <Skeleton title row={3} avatarShape='square' loading/>
  210. </View>:
  211. <View className='valueContent'>
  212. <View className='item'>
  213. <View className='title'>
  214. 公出地点:
  215. {dtails.permission === 0 && dtails.status === 0 ?
  216. <View className='edit' onClick={()=>{
  217. this.setState({
  218. isModifyOpened:true,
  219. })
  220. }}>
  221. <AtIcon value='edit' size='18' color='#3864ef'/>
  222. </View> : null}
  223. </View>
  224. <View className='value'>{dtails.userName}</View>
  225. <View className='timeContent'>
  226. <View className='time'>
  227. <View className='num'>公出{dtails.duration}小时</View>
  228. <View className='journal' onClick={(e)=>{
  229. e.stopPropagation();
  230. this.setState({
  231. isDetailedOpened:true
  232. })
  233. }}>明细</View>
  234. </View>
  235. <View className='timeAxis'>
  236. <View className='startTime'>
  237. <View className='circle'/>
  238. {dtails.releaseStarts}
  239. </View>
  240. <View className='axis'/>
  241. <View className='endTime'>
  242. <View className='circle'/>
  243. {dtails.releaseEnds}
  244. </View>
  245. </View>
  246. </View>
  247. </View>
  248. <AtModal onClose={()=>{
  249. this.setState({
  250. isDetailedOpened:false
  251. })
  252. }} isOpened={this.state.isDetailedOpened}>
  253. <AtModalContent>
  254. {dtails.validDate ? <AtCalendar
  255. currentDate={JSON.parse(dtails.validDate)[0]['value']}
  256. isSwiper={false}
  257. validDates={JSON.parse(dtails.validDate)}
  258. /> : null
  259. }
  260. </AtModalContent>
  261. <AtModalAction>
  262. <Button onClick={()=>{
  263. this.setState({
  264. isDetailedOpened:false
  265. })
  266. }}>确定</Button>
  267. </AtModalAction>
  268. </AtModal>
  269. <View className='item'>
  270. <View className='title'>
  271. 公出企业
  272. </View>
  273. <View className='value'>
  274. {dtails.nickname}
  275. </View>
  276. </View>
  277. <View className='item'>
  278. <View className='title'>公出原因</View>
  279. <View className='value'>
  280. {dtails.remarks}
  281. </View>
  282. </View>
  283. {dtails.annexUrl && dtails.annexUrl.length > 0 ? <View className='item'>
  284. <View className='title'>附件</View>
  285. <View className='value'>
  286. <ImagePicker
  287. files={dtails.annexUrl}
  288. showAddBtn={false} />
  289. </View>
  290. </View> : null}
  291. {
  292. dtails.permission === 1 && dtails.status === 1 ?
  293. <View className='item'>
  294. <View className='title'>填写审批意见<View className='titleTips'>根据公出申请记录指导怎么沟通?并提出详细指导建议</View></View>
  295. <AtTextarea
  296. value={this.state.opinion}
  297. onChange={(value)=>{
  298. this.setState({
  299. opinion:value
  300. })
  301. }}
  302. maxLength={20}
  303. placeholder='请填写审批意见'
  304. />
  305. </View> : null
  306. }
  307. {
  308. dtails.permission === 1 && dtails.status === 1 ?
  309. <View className='operation'>
  310. <AtButton type='secondary' circle loading={this.state.loading} onClick={()=>{
  311. this.setState({
  312. isInquiryOpened:true,
  313. inquiryTitle:'提醒',
  314. inquiryContent:'您确定要驳回此申请吗?',
  315. inquiryFn:()=>{
  316. this.examinePublicRelease(0);
  317. }
  318. })
  319. }}>
  320. 驳回
  321. </AtButton>
  322. <AtButton type='primary' loading={this.state.loading} circle onClick={()=>{
  323. if(this.state.loading){return;}
  324. this.setState({
  325. isInquiryOpened:true,
  326. inquiryTitle:'提醒',
  327. inquiryContent:'您确定要同意此申请吗?',
  328. inquiryFn:()=>{
  329. this.examinePublicRelease(2);
  330. }
  331. })
  332. }}>
  333. 同意
  334. </AtButton>
  335. </View> : null
  336. }
  337. {
  338. dtails.permission === 0 && dtails.status !== 3 ?
  339. <View className='item'>
  340. <View className='title'>撤销申请</View>
  341. <AtTextarea
  342. value={this.state.reasonsInvalidation}
  343. onChange={(value)=>{
  344. this.setState({
  345. reasonsInvalidation:value
  346. })
  347. }}
  348. maxLength={20}
  349. placeholder='请填写撤销申请原因'
  350. />
  351. </View> : null
  352. }
  353. {
  354. dtails.permission === 0 && dtails.status !== 3 ?
  355. <View className='operation'>
  356. <Button type='warn' loading={this.state.loading} onClick={()=>{
  357. if(this.state.loading){return;}
  358. this.setState({
  359. isInquiryOpened:true,
  360. inquiryTitle:'提醒',
  361. inquiryContent:'您确定要撤销此申请吗?',
  362. inquiryFn:()=>{
  363. this.oidApplication();
  364. }
  365. })
  366. }}>
  367. 撤销申请
  368. </Button>
  369. </View> : null
  370. }
  371. </View>}
  372. {Object.keys(dtails).length === 0?
  373. <View style={{margin: '20px'}}>
  374. <Skeleton title row={3} avatarShape='square' loading/>
  375. </View>:
  376. <View className='valueContent history' onClick={(e)=>{
  377. e.stopPropagation();
  378. this.setState({
  379. historicalIsOpened:true
  380. })
  381. }}>
  382. 查看公出申请日志
  383. <AtIcon value='chevron-right' size='20' color='#767272'/>
  384. </View>}
  385. {Object.keys(dtails).length === 0?
  386. <View style={{margin: '20px'}}>
  387. <Skeleton title row={3} avatarShape='square' loading/>
  388. </View>:
  389. <View className='valueContent history'>
  390. <View className='shareContent'>
  391. <Button open-type='share' className='share'>
  392. <Image src={Wx} className='shareIcon'/>
  393. </Button>
  394. <View className='shareTitle'>微信分享</View>
  395. </View>
  396. </View>}
  397. {this.state.isModifyOpened ? <Modify
  398. permission={dtails.permission}
  399. index={this.$instance.router.params.index}
  400. dtails={dtails}
  401. locationInfor={this.state.selectArrderLocation}
  402. id={this.$instance.router.params.id}
  403. isOpened={this.state.isModifyOpened}
  404. onModalClose={()=>{
  405. this.setState({
  406. isModifyOpened:false,
  407. })
  408. }}
  409. onClose={()=>{
  410. this.setState({
  411. isModifyOpened:false,
  412. dtails:{}
  413. },()=>{
  414. this.getReleasetDails();
  415. })
  416. }}/> : null}
  417. <InquiryModal
  418. isOpened={this.state.isInquiryOpened}
  419. title={this.state.inquiryTitle}
  420. content={this.state.inquiryContent}
  421. onClose={()=>{
  422. this.setState({
  423. isInquiryOpened:false,
  424. inquiryTitle:'',
  425. inquiryContent:'',
  426. })
  427. }}
  428. onDetermine={()=>{
  429. this.state.inquiryFn();
  430. this.setState({
  431. isInquiryOpened:false,
  432. inquiryTitle:'',
  433. inquiryContent:'',
  434. inquiryFn:()=>{}
  435. })
  436. }}
  437. />
  438. {this.state.historicalIsOpened ? <HistoricalClock
  439. id={this.$instance.router.params.id}
  440. isOpened={this.state.historicalIsOpened}
  441. onClose={()=>{
  442. this.setState({
  443. historicalIsOpened:false
  444. })
  445. }}
  446. /> : null}
  447. </View>
  448. )
  449. }
  450. }
  451. export default EgressDetails;