detail.vue 12 KB

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