index.jsx 14 KB

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