detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <!-- 任务详情 -->
  3. <view class="container">
  4. <!-- 详情内容 -->
  5. <view class="detail-container">
  6. <!-- 对接信息 -->
  7. <view class="section">
  8. <view class="section-title">
  9. <image class="title-icon" src="/static/images/person.png" mode="aspectFit"></image>
  10. <view class="title">
  11. 对接信息
  12. </view>
  13. </view>
  14. <view class="info-item">
  15. <text class="label">所属部门</text>
  16. <text class="value">{{visitDetail.department}}</text>
  17. </view>
  18. <view class="info-item">
  19. <text class="label">员工姓名</text>
  20. <text class="value">{{visitDetail.employeeName}}</text>
  21. </view>
  22. </view>
  23. <!-- 访问信息 -->
  24. <view class="section">
  25. <view class="section-title">
  26. <image class="title-icon" src="/static/images/calendar.png" mode="aspectFit"></image>
  27. <view class="title">
  28. 访问信息
  29. </view>
  30. </view>
  31. <view class="info-item">
  32. <text class="label">访问事由</text>
  33. <text class="value">{{visitDetail.visitReason}}</text>
  34. </view>
  35. <view class="info-item">
  36. <text class="label">到访时间</text>
  37. <text class="value">{{visitDetail.visitTime}}</text>
  38. </view>
  39. <view class="info-item">
  40. <text class="label">访客姓名</text>
  41. <text class="value">{{visitDetail.visitorName}}</text>
  42. </view>
  43. <view class="info-item">
  44. <text class="label">访客单位</text>
  45. <text class="value">{{visitDetail.visitorCompany}}</text>
  46. </view>
  47. <view class="info-item">
  48. <text class="label">手机号</text>
  49. <text class="value">{{visitDetail.visitorPhone}}</text>
  50. </view>
  51. </view>
  52. <!-- 随行人员 -->
  53. <view class="section" v-if="visitDetail.accompanyPersons && visitDetail.accompanyPersons.length > 0">
  54. <view class="section-title">
  55. <image class="title-icon" src="/static/images/person.png" mode="aspectFit"></image>
  56. <view class="title">
  57. 随行人员
  58. </view>
  59. </view>
  60. <view class="accompany-list">
  61. <view class="info-item" v-for="(person, index) in visitDetail.accompanyPersons" :key="index">
  62. <text class="label">随行人员{{index + 1}}</text>
  63. <view class="accompany-info">
  64. <text class="value">{{person.name}}</text>
  65. <text class="phone">{{person.phone}}</text>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 使用车辆 -->
  71. <view class="section" v-if="visitDetail.useVehicle">
  72. <view class="section-title">
  73. <image class="title-icon" src="/static/images/cart.png" mode="aspectFit"></image>
  74. <view class="title">
  75. 车辆信息
  76. </view>
  77. <text class="vehicle-number">{{visitDetail.vehicleNumber}}</text>
  78. </view>
  79. <view class="info-item">
  80. <text class="label">接客时间</text>
  81. <text class="value">{{visitDetail.pickupTime}}</text>
  82. </view>
  83. <view class="info-item">
  84. <text class="label">接客地点</text>
  85. <text class="value">{{visitDetail.pickupLocation}}</text>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 操作按钮 - 仅待审核状态显示 -->
  90. <view class="action-container" v-if="visitDetail.status === '待审核'">
  91. <button class="reject-btn" @click="handleReject">拒绝</button>
  92. <button class="approve-btn" @click="handleApprove">通过</button>
  93. </view>
  94. <!-- 确认弹框 -->
  95. <uni-popup ref="confirmPopup" type="center">
  96. <view class="confirm-popup">
  97. <view class="popup-content">
  98. <view class="popup-title">{{confirmAction === 'approve' ? '确认通过' : '确认拒绝'}}</view>
  99. <view class="popup-message">
  100. {{confirmAction === 'approve' ? '确定要通过这个访问申请吗?' : '确定要拒绝这个访问申请吗?'}}
  101. </view>
  102. <view class="popup-buttons">
  103. <button class="cancel-btn" @click="cancelAction">取消</button>
  104. <button class="confirm-btn"
  105. @click="confirmAction === 'approve' ? approveVisit() : rejectVisit()">
  106. 确定
  107. </button>
  108. </view>
  109. </view>
  110. </view>
  111. </uni-popup>
  112. <!-- 结果提示弹框 -->
  113. <uni-popup ref="resultPopup" type="center">
  114. <view class="result-popup">
  115. <view class="popup-content">
  116. <view class="result-icon" :class="resultType">
  117. <uni-icons :type="resultType === 'success' ? 'checkmarkempty' : 'closeempty'" size="60"
  118. :color="resultType === 'success' ? '#52c41a' : '#ff4757'"></uni-icons>
  119. </view>
  120. <view class="popup-title">{{resultTitle}}</view>
  121. <view class="popup-message">{{resultMessage}}</view>
  122. <button class="close-btn" @click="closeResultPopup">确定</button>
  123. </view>
  124. </view>
  125. </uni-popup>
  126. </view>
  127. </template>
  128. <script>
  129. import {
  130. updateVisitInfo
  131. } from '@/config/api.js';
  132. export default {
  133. data() {
  134. return {
  135. visitId: '',
  136. visitDetail: {
  137. id: '',
  138. department: '',
  139. employeeName: '',
  140. visitReason: '',
  141. visitTime: '',
  142. visitorName: '',
  143. visitorCompany: '',
  144. visitorPhone: '',
  145. status: '',
  146. useVehicle: false,
  147. vehicleNumber: '',
  148. pickupTime: '',
  149. pickupLocation: '',
  150. accompanyPersons: []
  151. },
  152. confirmAction: '', // 'approve' 或 'reject'
  153. resultType: '', // 'success' 或 'error'
  154. resultTitle: '',
  155. resultMessage: ''
  156. }
  157. },
  158. onLoad(options) {
  159. if (options.id) {
  160. this.visitId = options.id;
  161. this.getVisitDetail();
  162. }
  163. },
  164. methods: {
  165. // 获取访问详情
  166. getVisitDetail() {
  167. // 从缓存中获取数据
  168. const visitData = uni.getStorageSync('visitDetailData');
  169. if (visitData) {
  170. // 解析随行人员数据
  171. let accompanyPersons = [];
  172. if (visitData.accPerson) {
  173. try {
  174. const accPersonData = typeof visitData.accPerson === 'string' ? JSON.parse(visitData.accPerson) : visitData.accPerson;
  175. if (Array.isArray(accPersonData)) {
  176. accompanyPersons = accPersonData.map(person => ({
  177. name: person.name || person.accName || '',
  178. phone: person.phone || person.accTel || ''
  179. }));
  180. }
  181. } catch (error) {
  182. console.error('解析随行人员数据失败:', error);
  183. }
  184. }
  185. // 设置详情数据
  186. this.visitDetail = {
  187. id: visitData.id,
  188. department: visitData.visDept || '', // 访客单位作为部门
  189. employeeName: visitData.employeeName,
  190. visitReason: visitData.visitReason,
  191. visitTime: visitData.visitDate,
  192. visitorName: visitData.visitorName,
  193. visitorCompany: visitData.visitorCompany,
  194. visitorPhone: visitData.visitorPhone,
  195. status: visitData.status,
  196. useVehicle: visitData.useVehicle || false,
  197. vehicleNumber: visitData.vehicleNumber || '',
  198. pickupTime: visitData.pickupTime || '',
  199. pickupLocation: visitData.pickupLocation || '',
  200. accompanyPersons: accompanyPersons
  201. };
  202. // 清除缓存
  203. uni.removeStorageSync('visitDetailData');
  204. }
  205. },
  206. // 处理拒绝
  207. handleReject() {
  208. this.confirmAction = 'reject';
  209. this.$refs.confirmPopup.open();
  210. },
  211. // 处理通过
  212. handleApprove() {
  213. this.confirmAction = 'approve';
  214. this.$refs.confirmPopup.open();
  215. },
  216. // 取消操作
  217. cancelAction() {
  218. this.$refs.confirmPopup.close();
  219. this.confirmAction = '';
  220. },
  221. // 确认通过
  222. async approveVisit() {
  223. this.$refs.confirmPopup.close();
  224. uni.showLoading({
  225. title: '处理中...'
  226. });
  227. try {
  228. // 调用接口,状态改为 1=已访问(通过)
  229. const response = await updateVisitInfo({
  230. id: this.visitDetail.id,
  231. visitStatus: '1'
  232. });
  233. uni.hideLoading();
  234. if (response && response.code === 200) {
  235. // 更新本地状态
  236. this.visitDetail.status = '已访问';
  237. // 显示成功提示
  238. this.resultType = 'success';
  239. this.resultTitle = '审核通过';
  240. this.resultMessage = '访问申请已通过,访客将收到通知';
  241. this.$refs.resultPopup.open();
  242. } else {
  243. uni.showToast({
  244. title: response.msg || '操作失败',
  245. icon: 'none'
  246. });
  247. }
  248. } catch (error) {
  249. uni.hideLoading();
  250. console.error('审核通过失败:', error);
  251. uni.showToast({
  252. title: '操作失败,请重试',
  253. icon: 'none'
  254. });
  255. }
  256. },
  257. // 确认拒绝
  258. async rejectVisit() {
  259. this.$refs.confirmPopup.close();
  260. uni.showLoading({
  261. title: '处理中...'
  262. });
  263. try {
  264. // 调用接口,状态改为 3=已拒绝
  265. const response = await updateVisitInfo({
  266. id: this.visitDetail.id,
  267. visitStatus: '3'
  268. });
  269. uni.hideLoading();
  270. if (response && response.code === 200) {
  271. // 更新本地状态
  272. this.visitDetail.status = '已拒绝';
  273. // 显示成功提示
  274. this.resultType = 'success';
  275. this.resultTitle = '审核完成';
  276. this.resultMessage = '访问申请已拒绝,访客将收到通知';
  277. this.$refs.resultPopup.open();
  278. } else {
  279. uni.showToast({
  280. title: response.msg || '操作失败',
  281. icon: 'none'
  282. });
  283. }
  284. } catch (error) {
  285. uni.hideLoading();
  286. console.error('拒绝访问失败:', error);
  287. uni.showToast({
  288. title: '操作失败,请重试',
  289. icon: 'none'
  290. });
  291. }
  292. },
  293. // 关闭结果弹框
  294. closeResultPopup() {
  295. this.$refs.resultPopup.close();
  296. // 返回上一页
  297. uni.navigateBack();
  298. }
  299. }
  300. }
  301. </script>
  302. <style lang="scss" scoped>
  303. .container {
  304. min-height: 100vh;
  305. background-color: #f5f5f5;
  306. padding-bottom: 140rpx;
  307. }
  308. .detail-container {
  309. padding: 20rpx;
  310. }
  311. .section {
  312. background-color: #fff;
  313. border-radius: 16rpx;
  314. margin-bottom: 20rpx;
  315. padding: 30rpx;
  316. }
  317. .section-title {
  318. margin-bottom: 30rpx;
  319. display: flex;
  320. align-items: center;
  321. }
  322. .title {
  323. font-size: 32rpx;
  324. font-weight: 600;
  325. color: #333;
  326. }
  327. .title-icon {
  328. width: 40rpx;
  329. height: 40rpx;
  330. margin-right: 15rpx;
  331. }
  332. .vehicle-number {
  333. font-size: 28rpx;
  334. color: #666;
  335. font-weight: normal;
  336. margin-left: auto;
  337. }
  338. .info-item {
  339. display: flex;
  340. align-items: flex-start;
  341. margin-bottom: 24rpx;
  342. &:last-child {
  343. margin-bottom: 0;
  344. }
  345. }
  346. .label {
  347. width: 160rpx;
  348. font-size: 28rpx;
  349. color: #666;
  350. flex-shrink: 0;
  351. line-height: 1.5;
  352. }
  353. .value {
  354. flex: 1;
  355. font-size: 28rpx;
  356. color: #333;
  357. line-height: 1.5;
  358. word-break: break-all;
  359. }
  360. .accompany-info {
  361. flex: 1;
  362. display: flex;
  363. flex-direction: column;
  364. gap: 8rpx;
  365. .value {
  366. font-size: 28rpx;
  367. color: #333;
  368. }
  369. .phone {
  370. font-size: 24rpx;
  371. color: #666;
  372. }
  373. }
  374. .action-container {
  375. position: fixed;
  376. bottom: 0;
  377. left: 0;
  378. right: 0;
  379. padding: 20rpx;
  380. background-color: #fff;
  381. box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.1);
  382. display: flex;
  383. gap: 20rpx;
  384. }
  385. .reject-btn,
  386. .approve-btn {
  387. flex: 1;
  388. height: 88rpx;
  389. border-radius: 44rpx;
  390. border: none;
  391. font-size: 32rpx;
  392. font-weight: 600;
  393. }
  394. .reject-btn {
  395. background-color: #fff;
  396. color: #ff4757;
  397. border: 2rpx solid #ff4757;
  398. }
  399. .approve-btn {
  400. background: #39833b;
  401. color: #fff;
  402. }
  403. // 弹框样式
  404. .confirm-popup,
  405. .result-popup {
  406. .popup-content {
  407. background-color: #fff;
  408. border-radius: 20rpx;
  409. padding: 60rpx 40rpx 40rpx;
  410. width: 560rpx;
  411. text-align: center;
  412. }
  413. .popup-title {
  414. font-size: 36rpx;
  415. font-weight: 600;
  416. color: #333;
  417. margin-bottom: 20rpx;
  418. }
  419. .popup-message {
  420. font-size: 28rpx;
  421. color: #666;
  422. line-height: 1.6;
  423. margin-bottom: 40rpx;
  424. }
  425. }
  426. .popup-buttons {
  427. display: flex;
  428. gap: 20rpx;
  429. .cancel-btn,
  430. .confirm-btn {
  431. flex: 1;
  432. height: 80rpx;
  433. border-radius: 40rpx;
  434. font-size: 28rpx;
  435. border: none;
  436. }
  437. .cancel-btn {
  438. background-color: #f5f5f5;
  439. color: #666;
  440. }
  441. .confirm-btn {
  442. background: linear-gradient(135deg, #ff6b35 0%, #ff9500 100%);
  443. color: #fff;
  444. }
  445. }
  446. .result-icon {
  447. margin-bottom: 30rpx;
  448. &.success {
  449. // success icon styling handled by uni-icons color
  450. }
  451. &.error {
  452. // error icon styling handled by uni-icons color
  453. }
  454. }
  455. .close-btn {
  456. width: 100%;
  457. height: 80rpx;
  458. background: linear-gradient(135deg, #ff6b35 0%, #ff9500 100%);
  459. border-radius: 40rpx;
  460. color: #fff;
  461. font-size: 28rpx;
  462. border: none;
  463. }
  464. </style>