detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar
  6. :command-list="commandList"
  7. :refresh-prev="refreshPrevPage"
  8. :title="title"
  9. @command="handleCommand" />
  10. <view v-if="!$isEmpty(detailData)" class="container">
  11. <view class="user-info section">
  12. <wk-avatar
  13. :name="detailData.createUser.realname"
  14. :avatar="detailData.createUser.img"
  15. :size="14"
  16. class="avatar" />
  17. <view class="info">
  18. <view class="info-name">
  19. {{ detailData.createUser.realname }}
  20. </view>
  21. <view class="info-time">
  22. {{ detailData.createTime }}
  23. </view>
  24. </view>
  25. <view class="status">
  26. <view
  27. :style="{
  28. backgroundColor: statusObj.color
  29. }"
  30. class="dot" />
  31. <view class="text">
  32. {{ statusObj.label }}
  33. </view>
  34. </view>
  35. </view>
  36. <view class="fields-info section">
  37. <template v-for="(item, index) in fieldList">
  38. <view
  39. v-if="item.formType !== 'desc_text'"
  40. :key="index"
  41. class="fields-info-item">
  42. <view v-if="item.formType === 'file'" class="item-box">
  43. <text class="item-box-label">
  44. {{ item.name }}:
  45. </text>
  46. <view class="item-box-value">
  47. <text
  48. v-for="(file, childIndex) in item.value"
  49. :key="childIndex"
  50. class="file"
  51. @click="downloadFile(file)">
  52. {{ file.name }}
  53. </text>
  54. </view>
  55. </view>
  56. <view
  57. v-else-if="isWebSite(item)"
  58. class="item-box">
  59. <text class="item-box-label">
  60. {{ item.name }}:
  61. </text>
  62. <view
  63. style="color: #3C80F7"
  64. class="item-box-value"
  65. @click="handlerWebsite(item)">
  66. {{ getFieldValue(item) || '' }}
  67. </view>
  68. </view>
  69. <view
  70. v-else-if="isTel(item)"
  71. class="item-box">
  72. <text class="item-box-label">
  73. {{ item.name }}:
  74. </text>
  75. <view
  76. style="color: #3C80F7"
  77. class="item-box-value"
  78. @click="handlerCall(item)">
  79. {{ getFieldValue(item) || '' }}
  80. </view>
  81. </view>
  82. <view
  83. v-else-if="item.formType === 'handwriting_sign'"
  84. class="handwriting-sign">
  85. <view class="handwriting-sign-label">
  86. {{ item.name }}:
  87. </view>
  88. <view class="handwriting-sign-value">
  89. <wk-signature-view :batch-id="item.value" />
  90. </view>
  91. </view>
  92. <view
  93. v-else-if="item.fieldName !== 'cause'"
  94. class="item-box">
  95. <text class="item-box-label">
  96. {{ item.name }}:
  97. </text>
  98. <view class="item-box-value">
  99. {{ getFieldValue(item) }}
  100. </view>
  101. </view>
  102. </view>
  103. <template v-else-if="item.formType === 'desc_text' && item.value">
  104. <view :key="index" class="desc_text">
  105. <rich-text :nodes="item.value" />
  106. </view>
  107. </template>
  108. </template>
  109. </view>
  110. <template v-if="detailTableList.length > 0">
  111. <detail-table-item
  112. v-for="(item, index) in detailTableList"
  113. :key="index"
  114. :field="item" />
  115. </template>
  116. <travel-item
  117. v-if="!$isEmpty(causeData)"
  118. :item="causeData"
  119. class="section" />
  120. <view class="attachment-conent section">
  121. <wk-image-content
  122. v-if="detailData.img && detailData.img.length > 0"
  123. :list="detailData.img"
  124. class="image-content" />
  125. <template v-if="detailData.file && detailData.file.length > 0">
  126. <view class="base-file-title">
  127. 附件
  128. </view>
  129. <wk-file-content :list="detailData.file" />
  130. </template>
  131. <relevance-section v-if="showRelevance" :relevance-data="relevanceData" />
  132. </view>
  133. <view class="empty" />
  134. <!--审核流程-->
  135. <view
  136. v-if="auditInfo.examineFlowList"
  137. class="examine-flow-container section">
  138. <view
  139. v-for="(item, index) in auditInfo.examineFlowList"
  140. :key="index"
  141. class="flow-item">
  142. <wk-audit-flow-item
  143. :item-data="item"
  144. :audit-info="auditInfo" />
  145. </view>
  146. </view>
  147. </view>
  148. <view
  149. v-if="auditInfo.isCheck === 1 || auditInfo.isRecheck === 1"
  150. class="footer-region">
  151. <view class="footer-box">
  152. <view
  153. v-if="auditInfo.isRecheck === 1"
  154. class="footer-button recall"
  155. @click="handleAuditAction('cancel')">
  156. 撤回
  157. </view>
  158. <template v-if="auditInfo.isCheck === 1">
  159. <view class="footer-button refuse" @click="handleAuditAction('refuse')">
  160. 拒绝
  161. </view>
  162. <view class="footer-button pass" @click="handleAuditAction('pass')">
  163. 通过
  164. </view>
  165. </template>
  166. </view>
  167. </view>
  168. </view>
  169. <uni-popup ref="popup" type="dialog">
  170. <uni-popup-dialog
  171. :content="dialogMsg"
  172. type="warning"
  173. @confirm="handleDialogConfirm" />
  174. </uni-popup>
  175. </view>
  176. </template>
  177. <script>
  178. import {
  179. QueryExamineInfo,
  180. GetField,
  181. DeleteOaExamine
  182. } from 'API/oa/examine'
  183. import { QueryExamineRecordList, AuditExamine } from 'API/examine'
  184. import TravelItem from './components/travelItem.vue'
  185. import RelevanceSection from '@/components/base/relevance-section.vue'
  186. import DetailTableItem from './components/detailTableItem.vue'
  187. import { downloadFile } from '@/utils/file.js'
  188. import fieldValueMixins from '@/mixins/fieldValueMixins.js'
  189. // 0待审、1审批中、2通过、3失败、4撤销
  190. export default {
  191. name: 'OaExamineDetail',
  192. components: {
  193. TravelItem,
  194. RelevanceSection,
  195. DetailTableItem
  196. },
  197. mixins: [fieldValueMixins],
  198. data() {
  199. return {
  200. title: '普通审批',
  201. id: null,
  202. routerQuery: {},
  203. auditType: '',
  204. fieldList: [], // 审批的自定义字段
  205. auditInfo: {}, // 审批流程信息
  206. stepList: [], // 审批人列表
  207. detailData: {}, // 页面数据
  208. detailTableList: [], // 明细表格字段
  209. dialogMsg: '',
  210. dialogType: '',
  211. webUrl: '',
  212. refreshPage: false,
  213. refreshPrevPage: false
  214. }
  215. },
  216. computed: {
  217. statusObj() {
  218. return this.calcStatus(this.detailData.examineStatus)
  219. },
  220. // 明细数据
  221. causeData() {
  222. const findRes = this.fieldList.find(v => v.fieldName === 'cause')
  223. if (findRes) return findRes
  224. return {}
  225. },
  226. // 显示关联数据
  227. showRelevance() {
  228. return !this.$isEmpty(this.detailData.customerList) ||
  229. !this.$isEmpty(this.detailData.contactsList) ||
  230. !this.$isEmpty(this.detailData.businessList) ||
  231. !this.$isEmpty(this.detailData.contractList)
  232. },
  233. // 关联业务数据
  234. relevanceData() {
  235. return {
  236. customerList: this.detailData.customerList || [],
  237. contactsList: this.detailData.contactsList || [],
  238. businessList: this.detailData.businessList || [],
  239. contractList: this.detailData.contractList || []
  240. }
  241. },
  242. commandList() {
  243. const arr = [
  244. { label: '审批记录', value: 'read', imgIcon: 'read', noCheck: true},
  245. { label: '编辑', value: 'edit', imgIcon: 'update', noCheck: true },
  246. { label: '删除', value: 'delete', imgIcon: 'delete', noCheck: true }
  247. ]
  248. if ([2, 4].includes(this.detailData.examineStatus)) {
  249. return arr
  250. } else {
  251. return arr.slice(0, 1)
  252. }
  253. }
  254. },
  255. onLoad(options) {
  256. this.routerQuery = options
  257. this.id = this.routerQuery.id
  258. this.examineId = this.routerQuery.examineId
  259. this.getData()
  260. },
  261. onShow() {
  262. if (this.refreshPage) {
  263. this.refreshPage = false
  264. this.refreshPrevPage = true
  265. this.getData()
  266. }
  267. },
  268. onBackPress(evt) {
  269. if (evt.from === 'backbutton' && this.refreshPrevPage) {
  270. this.$refreshAndToPrev(this)
  271. return true // 返回值为 true 时,表示不执行默认的返回
  272. }
  273. return false
  274. },
  275. methods: {
  276. /**
  277. * 审批详情
  278. */
  279. getData() {
  280. QueryExamineInfo({
  281. examineId: this.id
  282. }).then(response => {
  283. this.detailData = response
  284. this.title = response.categoryTitle
  285. this.getAuditInfo()
  286. this.getField()
  287. })
  288. },
  289. /**
  290. * 获取自定义字段
  291. */
  292. getField() {
  293. GetField({
  294. id: this.examineId,
  295. isDetail: 1,
  296. examineId: this.id,
  297. label: 10,
  298. type: 1
  299. }).then(response => {
  300. this.fieldList = response.filter(o => o.formType !== 'detail_table')
  301. this.detailTableList = response.filter(o => o.formType === 'detail_table')
  302. }).catch()
  303. },
  304. /**
  305. * 打电话
  306. * @param item
  307. */
  308. handlerCall(item) {
  309. let tel = this.getFieldValue(item)
  310. if (!tel) return
  311. uni.makePhoneCall({
  312. phoneNumber: tel
  313. })
  314. },
  315. /**
  316. * 打开网址
  317. * @param {Object} item
  318. */
  319. handlerWebsite(item) {
  320. this.webUrl = this.getFieldValue(item)
  321. if (!this.webUrl) return
  322. if (
  323. !this.webUrl.startsWith('http://') ||
  324. !this.webUrl.startsWith('https://')
  325. ) {
  326. this.webUrl = `http://${this.webUrl}`
  327. }
  328. this.dialogMsg = `使用浏览器打开 ${this.webUrl} ?`
  329. this.dialogType = 'url'
  330. this.$refs.popup.open()
  331. },
  332. /**
  333. * 获取审批步骤
  334. */
  335. getAuditInfo() {
  336. QueryExamineRecordList({
  337. recordId: this.detailData.examineRecordId
  338. }).then(response => {
  339. this.auditInfo = response
  340. this.stepList = response.steps
  341. console.log('res step list: ', response)
  342. }).catch()
  343. },
  344. handleCommand(command) {
  345. if (this.$isEmpty(this.detailData)) return
  346. if (command.value === 'edit') {
  347. this.$Router.navigateTo({
  348. url: '/pages_examine/add',
  349. query: {
  350. id: this.id,
  351. title: this.detailData.categoryTitle,
  352. examineId: this.detailData.categoryId
  353. }
  354. })
  355. } else if (command.value === 'delete') {
  356. this.dialogMsg = '您确定要删除这次审批吗?'
  357. this.dialogType = 'delete'
  358. this.$refs.popup.open()
  359. } else if (command.value === 'read') {
  360. this.$Router.navigateTo({
  361. url: '/pages_examine/record',
  362. query: {
  363. id: this.detailData.examineRecordId
  364. }
  365. })
  366. }
  367. },
  368. handleDialogConfirm(next) {
  369. next()
  370. if (this.dialogType === 'delete') {
  371. this.dialogType = ''
  372. DeleteOaExamine({examineId: this.id}).then(response => {
  373. this.$toast('删除成功')
  374. this.$refreshAndToPrev(this)
  375. }).catch()
  376. } else if (this.dialogType === 'url') {
  377. this.dialogType = ''
  378. // #ifdef APP-PLUS
  379. plus.runtime.openURL(this.webUrl)
  380. // #endif
  381. // #ifdef H5
  382. window.open(this.webUrl, '_blank')
  383. // #endif
  384. }
  385. },
  386. handleAuditAction(action) {
  387. // cancel 撤回 refuse 拒绝 pass 通过
  388. this.auditType = action
  389. getApp().globalData.auditInfo = this.auditInfo
  390. uni.$once('save-audit', this.handleAudit)
  391. this.$Router.navigateTo({
  392. url: '/pages_common/audit/index',
  393. query: {
  394. type: action
  395. }
  396. })
  397. },
  398. /**
  399. * 审核
  400. * @param form 审核信息
  401. */
  402. handleAudit(form) {
  403. let params = {
  404. typeId: this.id,
  405. recordId: this.detailData.examineRecordId,
  406. ...form
  407. }
  408. console.log('audit:', form)
  409. AuditExamine(params).then(() => {
  410. this.$toast(params.status === 4 ? '撤销成功' : '审核成功')
  411. this.getData()
  412. this.refreshPrevPage = true
  413. }).catch()
  414. },
  415. downloadFile(file) {
  416. downloadFile(file)
  417. }
  418. }
  419. }
  420. </script>
  421. <style scoped lang="scss">
  422. .main-container {
  423. .container {
  424. flex: 1;
  425. background-color: white;
  426. padding: 20rpx 0;
  427. overflow-y: scroll;
  428. .section {
  429. padding: 0 30rpx;
  430. }
  431. .user-info {
  432. margin-bottom: 20rpx;
  433. @include left;
  434. .avatar {
  435. width: 80rpx;
  436. height: 80rpx;
  437. margin-right: 15rpx;
  438. }
  439. .info {
  440. flex: 1;
  441. .info-name {
  442. color: $dark;
  443. font-size: $wk-font-medium;
  444. }
  445. .info-time {
  446. color: $light;
  447. font-size: $wk-font-sm;
  448. }
  449. }
  450. .status {
  451. color: $dark;
  452. font-size: $wk-font-base;
  453. @include left;
  454. .dot {
  455. width: 15rpx;
  456. height: 15rpx;
  457. border-radius: 50%;
  458. margin-right: 10rpx;
  459. }
  460. }
  461. }
  462. .fields-info {
  463. .fields-info-item {
  464. width: 100%;
  465. font-size: 26rpx;
  466. line-height: 50rpx;
  467. color: $dark;
  468. .item-box {
  469. display: flex;
  470. align-items: baseline;
  471. justify-content: flex-start;
  472. overflow: hidden;
  473. .item-box-label {
  474. max-width: 50%;
  475. color: $light;
  476. }
  477. .item-box-value {
  478. flex: 1;
  479. display: flex;
  480. flex-direction: column;
  481. overflow: hidden;
  482. .file {
  483. color: $theme-color;
  484. text-align: left;
  485. @include ellipsis;
  486. }
  487. }
  488. }
  489. .handwriting-sign {
  490. .handwriting-sign-label {
  491. color: $light;
  492. }
  493. .handwriting-sign-value {
  494. }
  495. }
  496. }
  497. .desc_text {
  498. font-size: $wk-font-base;
  499. margin: 10rpx 0;
  500. }
  501. }
  502. .attachment-conent {
  503. padding-top: 15rpx;
  504. padding-bottom: 15rpx;
  505. .base-file-title {
  506. font-size: 26rpx;
  507. margin-top: 20rpx;
  508. }
  509. }
  510. .empty {
  511. width: 100%;
  512. height: 15rpx;
  513. background-color: $main-bg;
  514. }
  515. .examine-flow-container {
  516. padding: 30rpx;
  517. .flow-item {
  518. position: relative;
  519. margin-bottom: 20rpx;
  520. &::after {
  521. content: '';
  522. position: relative;
  523. left: 52rpx;
  524. top: 10rpx;
  525. width: 1rpx;
  526. height: 60rpx;
  527. border-left: 1rpx dashed #ccc;
  528. display: block;
  529. }
  530. &:last-child::after {
  531. display: none;
  532. }
  533. }
  534. }
  535. }
  536. .footer-region {
  537. background-color: white;
  538. width: 100%;
  539. height: 120rpx;
  540. padding: 0 30rpx;
  541. border-top: 1rpx solid $border-color;
  542. .footer-box {
  543. width: 100%;
  544. height: 100%;
  545. @include center;
  546. .footer-button {
  547. width: 210rpx;
  548. height: 72rpx;
  549. font-size: $wk-font-base;
  550. border-radius: 6rpx;
  551. @include center;
  552. }
  553. .refuse {
  554. background-color: $error;
  555. color: white;
  556. margin-right: 30rpx;
  557. }
  558. .pass {
  559. background-color: $theme-color;
  560. color: white;
  561. }
  562. .recall {
  563. color: $gray;
  564. background-color: #F5F5F5;
  565. margin-right: 30rpx;
  566. }
  567. }
  568. }
  569. }
  570. </style>