detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view class="detail-page" v-if="info">
  3. <view class="section">
  4. <image :src="statusImg" mode="aspectFill" class="status-img"></image>
  5. <!-- <view class="info-item" v-for="item in infoOpts" :key="item.key">
  6. <view class="label">{{item.name}}</view>
  7. <view class="content">
  8. <text v-if="item.key=='place'">{{info.Province}}{{info.City}}</text>
  9. <text>{{info[item.key]}}</text>
  10. </view>
  11. </view> -->
  12. <view class="info-item">
  13. <view class="label">申请人</view>
  14. <view class="content">
  15. <text>{{info.ApplyRealName}}</text>
  16. </view>
  17. </view>
  18. <view class="info-item">
  19. <view class="label">到达日期</view>
  20. <view class="content">
  21. <text>{{info.ArriveDate}}</text>
  22. </view>
  23. </view>
  24. <view class="info-item">
  25. <view class="label">返程日期</view>
  26. <view class="content">
  27. <text>{{info.ReturnDate}}</text>
  28. </view>
  29. </view>
  30. <view class="info-item">
  31. <view class="label">目的地</view>
  32. <view class="content">
  33. <text>{{info.Province}}{{info.City}}</text>
  34. </view>
  35. </view>
  36. <view class="info-item">
  37. <view class="label">出差事由</view>
  38. <view class="content">
  39. <text>{{info.Reason}}</text>
  40. </view>
  41. </view>
  42. <view class="info-item">
  43. <view class="label">交通工具</view>
  44. <view class="content">
  45. <text>{{info.Transportation.indexOf('其他')!=-1?info.Transportation.split('-')[1]:info.Transportation}}</text>
  46. </view>
  47. </view>
  48. <view class="info-item">
  49. <view class="label">行程说明</view>
  50. <view class="content">
  51. <text>{{info.Itinerary}}</text>
  52. </view>
  53. </view>
  54. <view class="info-item" v-if="info.PeerPeopleName">
  55. <view class="label">同行人</view>
  56. <view class="content">
  57. <text>{{info.PeerPeopleName}}</text>
  58. </view>
  59. </view>
  60. <view class="info-item">
  61. <view class="label">提交时间</view>
  62. <view class="content">
  63. <text>{{info.CreateTime}}</text>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="section" v-if="info.Status!=='待审批'&&(info.ApproveTime||info.RefuseTime)">
  68. <view class="info-item">
  69. <view class="label">审批时间</view>
  70. <view class="content">{{info.ApproveTime||info.RefuseTime}}</view>
  71. </view>
  72. <view class="info-item" style="color:#C54322" v-if="info.Status==='已驳回'">
  73. <view class="label">驳回理由</view>
  74. <view class="content">{{info.RefuseReason}}</view>
  75. </view>
  76. </view>
  77. <view class="section" v-if="info.Status==='已关闭'">
  78. <view class="info-item">
  79. <view class="label">关闭时间</view>
  80. <view class="content">{{info.CloseTime}}</view>
  81. </view>
  82. <view class="info-item" style="color:#C54322">
  83. <view class="label">关闭理由</view>
  84. <view class="content">{{info.CloseReason}}</view>
  85. </view>
  86. </view>
  87. <view class="fix-bottom-wrap btns-wrap flex" v-if="info.ApplyAdminId==adminId&&info.Status=='待审批'">
  88. <button class="pass-btn" @click="handleRecall">撤回</button>
  89. </view>
  90. <view class="fix-bottom-wrap btns-wrap flex" v-if="info.ApplyAdminId==adminId&&info.Status=='已驳回'">
  91. <button class="pass-btn" @click="handleEdit">重新申请</button>
  92. </view>
  93. <view class="fix-bottom-wrap btns-wrap flex" v-if="info.ApplyAdminId==adminId&&info.Status=='已撤回'">
  94. <button class="refuse-btn" @click="handleDel">删除</button>
  95. <button class="pass-btn" @click="handleEdit">重新申请</button>
  96. </view>
  97. <view class="fix-bottom-wrap btns-wrap flex" v-if="info.IsApprove&&info.Status=='待审批'">
  98. <button class="pass-btn" @click="handlePass">通过</button>
  99. <button class="refuse-btn" @click="handleRefuse">驳回</button>
  100. </view>
  101. <view class="fix-bottom-wrap btns-wrap flex" v-if="info.IsClose&&info.Status=='已通过'&&!NowBigReturnDate">
  102. <button class="refuse-btn" @click="handleClose">关闭</button>
  103. </view>
  104. <van-dialog id="van-dialog" />
  105. </view>
  106. </template>
  107. <script>
  108. import {apiBusinessTripDetail,apiBusinessTripRecall,apiBusinessApplyApprove,apiDelApply} from '@/api/businessTrip/index'
  109. export default {
  110. computed:{
  111. adminId(){
  112. const userInfo=uni.getStorageSync('userInfo');
  113. return userInfo?JSON.parse(userInfo).AdminId:0
  114. },
  115. // 当前时间是否大于等于返回时间
  116. NowBigReturnDate(){
  117. if(!this.info) return
  118. const now=new Date().getTime()
  119. const temt=this.info.ArriveDate.replace('-','/')
  120. const rtime=new Date(temt).getTime()
  121. console.log(now,rtime);
  122. return now>rtime
  123. }
  124. },
  125. data() {
  126. return {
  127. // infoOpts:[
  128. // {name:'申请人',key:'ApplyRealName'},
  129. // {name:'到达日期',key:'ArriveDate'},
  130. // {name:'返程日期',key:'ReturnDate'},
  131. // {name:'目的地',key:'place'},
  132. // {name:'出差事由',key:'Reason'},
  133. // {name:'交通工具',key:'Transportation'},
  134. // {name:'同行人',key:'PeerPeopleName'},
  135. // {name:'提交时间',key:'CreateTime'},
  136. // ],
  137. id:0,
  138. info:null,
  139. statusImg:'',
  140. }
  141. },
  142. onLoad(opt){
  143. this.id=opt.id
  144. },
  145. onShow(){
  146. this.getDetail()
  147. },
  148. methods: {
  149. getDetail(){
  150. this.info=null
  151. this.statusImg=''
  152. apiBusinessTripDetail({BusinessApplyId:this.id}).then(res=>{
  153. if(res.code===200){
  154. this.info=res.data
  155. if(this.info.Status==='已通过'){
  156. this.statusImg= require('../static/pass-icon.png')
  157. }else if(this.info.Status==='已驳回'){
  158. this.statusImg= require('../static/fail-icon.png')
  159. }else if(this.info.Status==='已过期'){
  160. this.statusImg= require('../static/cancel-icon.png')
  161. }else if(this.info.Status==='已撤回'){
  162. this.statusImg= require('../static/recall-icon.png')
  163. }else if(this.info.Status==='已关闭'){
  164. this.statusImg= require('../static/close-icon.png')
  165. }
  166. }
  167. })
  168. },
  169. // 撤回
  170. handleRecall(){
  171. const that=this
  172. uni.showModal({
  173. title: '',
  174. content: '确定要撤回该出差申请吗?',
  175. success: function (res) {
  176. if (res.confirm) {
  177. console.log('用户点击确定');
  178. apiBusinessTripRecall({BusinessApplyId:Number(that.id)}).then(res=>{
  179. if(res.code===200){
  180. uni.$emit('businessApproveListUpdate')
  181. uni.navigateBack({
  182. delta: 1,
  183. fail:()=>{
  184. uni.switchTab({
  185. url: '/pages/index/index'
  186. })
  187. }
  188. });
  189. }
  190. })
  191. } else if (res.cancel) {
  192. console.log('用户点击取消');
  193. }
  194. }
  195. });
  196. },
  197. // 重新申请
  198. handleEdit(){
  199. uni.navigateTo({
  200. url:"/pages-approve/businessTrip/add?id="+this.id
  201. })
  202. },
  203. // 删除
  204. handleDel(){
  205. const that=this
  206. uni.showModal({
  207. title: '',
  208. content: '确定要删除该出差申请吗?',
  209. success: function (res) {
  210. if (res.confirm) {
  211. console.log('用户点击确定');
  212. apiDelApply({BusinessApplyId:Number(that.id)}).then(res=>{
  213. if(res.code===200){
  214. uni.$emit('businessApproveListUpdate')
  215. uni.showToast({
  216. title:"删除成功",
  217. icon:'success'
  218. })
  219. setTimeout(() => {
  220. uni.navigateBack({
  221. delta: 1,
  222. fail:()=>{
  223. uni.switchTab({
  224. url: '/pages/index/index'
  225. })
  226. }
  227. });
  228. }, 1500);
  229. }
  230. })
  231. } else if (res.cancel) {
  232. console.log('用户点击取消');
  233. }
  234. }
  235. });
  236. },
  237. //审批驳回
  238. handleRefuse(){
  239. uni.navigateTo({
  240. url:"./reason?id="+this.id
  241. })
  242. },
  243. // 审批关闭
  244. handleClose(){
  245. const url = `./closeReason?id=${this.id}&shouldCheck=${this.adminId===this.info.ApplyAdminId}`
  246. uni.navigateTo({
  247. url:url
  248. })
  249. },
  250. //审批通过
  251. async handlePass(){
  252. const res=await apiBusinessApplyApprove({
  253. BusinessApplyId:Number(this.id),
  254. ApproveStatus:1,
  255. Remark:''
  256. })
  257. if(res.code===200){
  258. this.$dialog.alert({
  259. title: "处理成功",
  260. confirmButtonColor: "#5890FB",
  261. }).then(() => {
  262. // on close
  263. this.getDetail()
  264. // 更新列表
  265. uni.$emit('businessApproveListUpdate')
  266. });
  267. }
  268. },
  269. },
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. .detail-page{
  274. padding-bottom: calc(150rpx + constant(safe-area-inset-bottom));
  275. padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
  276. }
  277. .section{
  278. margin-top: 20rpx;
  279. background-color: #fff;
  280. padding: 30rpx 34rpx;
  281. position: relative;
  282. .status-img{
  283. position: absolute;
  284. width: 222rpx;
  285. height: 222rpx;
  286. right: 0;
  287. top: 150rpx;
  288. z-index: 10;
  289. }
  290. }
  291. .info-item{
  292. font-size: 32rpx;
  293. display: flex;
  294. margin-bottom: 20rpx;
  295. .label{
  296. width: 150rpx;
  297. flex-shrink: 0;
  298. margin-right: 30rpx;
  299. text-align: right;
  300. }
  301. .content{
  302. flex: 1;
  303. }
  304. }
  305. .btns-wrap {
  306. justify-content: center;
  307. button {
  308. width: 260rpx;
  309. height: 70rpx;
  310. border-radius: 28px;
  311. border: none;
  312. margin: 0 15px;
  313. font-size: 15px;
  314. color: #fff;
  315. line-height: 70rpx;
  316. }
  317. .pass-btn {
  318. background-color: #3385FF;
  319. }
  320. .refuse-btn {
  321. background-color: #f55768;
  322. }
  323. }
  324. </style>