detail.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <view v-if="!refreshPage && !$isEmpty(detailData)" class="uni-app">
  3. <view class="status-bar" />
  4. <wk-nav-bar
  5. :command-list="commandList"
  6. :refresh-prev="refreshPrevPage"
  7. title="回款详情"
  8. theme="white"
  9. class="nav-bar"
  10. @command="handleCommand" />
  11. <scroll-view
  12. :scroll-y="true"
  13. class="main-container scroll-view-hook">
  14. <view class="header-top">
  15. <view class="bg linear-gradient" />
  16. <view class="card">
  17. <view class="title-cell">
  18. <image :src="$static('images/crm/gray_receivables.png')" class="type-icon" />
  19. <view class="title-text">
  20. {{ detailData.number || '' }}
  21. </view>
  22. <view
  23. v-if="showCheckStatus"
  24. :style="{
  25. backgroundColor: statusObj.bg,
  26. color: statusObj.color
  27. }"
  28. class="title-status">
  29. <text
  30. :class="statusObj.icon"
  31. class="wk" />
  32. <text>{{ statusObj.label }}</text>
  33. </view>
  34. </view>
  35. <view class="main-info">
  36. <view class="info-item">
  37. <text class="label">
  38. 回款金额:
  39. </text>
  40. <text class="value">
  41. {{ detailData.money ? splitNumber(detailData.money) : '&#45;&#45;' }}
  42. </text>
  43. </view>
  44. <view class="info-item">
  45. <text class="label">
  46. 回款方式:
  47. </text>
  48. <text class="value">
  49. {{ detailData.returnType || '&#45;&#45;' }}
  50. </text>
  51. </view>
  52. <view class="info-item">
  53. <text class="label">
  54. 回款时间:
  55. </text>
  56. <text class="value">
  57. {{ detailData.returnTime || '&#45;&#45;' }}
  58. </text>
  59. </view>
  60. </view>
  61. <view class="main-info">
  62. <flow-progress
  63. v-if="detailData"
  64. :type="comType"
  65. :detail-id="id"
  66. :detail-data="detailData" />
  67. </view>
  68. <view
  69. class="relevance-cell"
  70. @click="handleToCustomer">
  71. <image :src="$static('images/application/customer.png')" class="cell-icon" />
  72. <text class="cell-body">
  73. {{ detailData.customerName }}
  74. </text>
  75. <text class="cell-link wk wk-arrow-right" />
  76. </view>
  77. <view
  78. v-if="auditInfo && auditInfo.isCheck === 1"
  79. class="check-box">
  80. <view class="btn success" @click="handleAuditAction('pass')">
  81. <text class="wk wk-check-fill icon" />
  82. <text>通过</text>
  83. </view>
  84. <view class="btn error" @click="handleAuditAction('refuse')">
  85. <text class="wk wk-close-fill icon" />
  86. <text>拒绝</text>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <detail-base-info
  92. v-if="id"
  93. :detail-id="id"
  94. :detail-data="detailData"
  95. :type="comType"
  96. class="detail-container" />
  97. </scroll-view>
  98. <uni-popup ref="popup" type="dialog">
  99. <uni-popup-dialog
  100. :content="dialogMsg"
  101. type="warning"
  102. @confirm="handleDialogConfirm" />
  103. </uni-popup>
  104. </view>
  105. </template>
  106. <script>
  107. import { QueryById, DeleteByIds } from 'API/crm/received'
  108. import { QueryExamineRecordList, AuditExamine } from 'API/examine'
  109. import DetailBaseInfo from '../components/detailSection/baseInfo'
  110. import FlowProgress from '../components/customFlow/flowProgress'
  111. import { mapGetters } from 'vuex'
  112. import { splitNumber } from '@/utils/lib.js'
  113. import detailMixins from '../mixins/detail.js'
  114. export default {
  115. name: 'ReceivedDetail',
  116. components: {
  117. DetailBaseInfo,
  118. FlowProgress
  119. },
  120. mixins: [detailMixins],
  121. data() {
  122. return {
  123. id: null,
  124. routerQuery: {},
  125. comType: 'crm_receivables',
  126. detailData: {},
  127. commandList: [],
  128. auditInfo: null
  129. }
  130. },
  131. computed: {
  132. ...mapGetters({
  133. calcStatus: 'base/calcStatus',
  134. userInfo: 'user/userInfo'
  135. }),
  136. showCheckStatus() {
  137. return this.detailData.hasOwnProperty('checkStatus') && this.detailData.examineRecordId
  138. },
  139. statusObj() {
  140. if (!this.showCheckStatus) return {}
  141. return this.calcStatus(this.detailData.checkStatus) || {}
  142. }
  143. },
  144. methods: {
  145. splitNumber(num) {
  146. return splitNumber(num)
  147. },
  148. /**
  149. * 获取详情
  150. */
  151. getDetail() {
  152. QueryById({receivablesId: this.id}).then(response => {
  153. this.detailData = response
  154. this.getAuditInfo()
  155. }).catch(() => {
  156. this.goBack()
  157. })
  158. },
  159. /**
  160. * 获取审批流
  161. */
  162. getAuditInfo() {
  163. if (!this.detailData.examineRecordId) {
  164. this.auditInfo = null
  165. this.renderCommands()
  166. return
  167. }
  168. QueryExamineRecordList({
  169. recordId: this.detailData.examineRecordId,
  170. ownerUserId: this.detailData.ownerUserId
  171. }).then(res => {
  172. this.auditInfo = res || null
  173. this.renderCommands()
  174. }).catch()
  175. },
  176. /**
  177. * 渲染更多操作选项
  178. */
  179. renderCommands() {
  180. this.commandList = [
  181. {label: '查看审批流', imgIcon: 'read', noCheck: true, value: 'read'},
  182. {label: '编辑', imgIcon: 'update', auth: 'crm.receivables.update', value: 'update'},
  183. {label: '删除', imgIcon: 'delete', auth: 'crm.receivables.delete', value: 'delete'},
  184. ]
  185. // 判断是否能够撤回审批
  186. let index = this.commandList.findIndex(item => item.label === '撤回审批')
  187. if (this.auditInfo && this.auditInfo.isRecheck === 1 && index === -1) {
  188. this.commandList.splice(1, 0, {
  189. label: '撤回审批',
  190. imgIcon: 'reset',
  191. noCheck: true,
  192. value: 'reset'
  193. })
  194. } else if (this.auditInfo && this.auditInfo.isRecheck !== 1 && index !== -1) {
  195. this.commandList.splice(index, 1)
  196. }
  197. index = null
  198. // 如果没有审批流则删除查看审批流
  199. index = this.commandList.findIndex(item => item.value === 'read')
  200. if (index !== -1 && !this.detailData.examineRecordId) {
  201. this.commandList.splice(index, 1)
  202. }
  203. index = null
  204. const checkStatus = this.detailData.checkStatus
  205. // 判断是否能编辑
  206. index = this.commandList.findIndex(item => item.value === 'update')
  207. if (index !== -1) {
  208. // 审核拒绝 审核撤回 未提交 才能编辑
  209. // if (
  210. // this.userInfo.userId !== this.detailData.createUserId ||
  211. // (![2, 4, 5].includes(checkStatus) && this.detailData.examineRecordId)) {
  212. // this.commandList.splice(index, 1)
  213. // }
  214. if (![2, 4, 5].includes(checkStatus) && this.detailData.examineRecordId) {
  215. this.commandList.splice(index, 1)
  216. }
  217. }
  218. index = null
  219. // 判断是否能删除
  220. index = this.commandList.findIndex(item => item.value === 'delete')
  221. if (index !== -1) {
  222. // 已撤回 未提交 作废
  223. // if (![4, 5, 8].includes(checkStatus)) {
  224. if (![4, 5, 8].includes(checkStatus) && this.detailData.examineRecordId) {
  225. this.commandList.splice(index, 1)
  226. }
  227. }
  228. },
  229. /**
  230. * 跳转到客户
  231. */
  232. handleToCustomer() {
  233. this.$Router.navigateTo({
  234. url: '/pages_crm/customer/detail',
  235. query: {
  236. id: this.detailData.customerId
  237. }
  238. })
  239. },
  240. handleCommand(command) {
  241. this.commandValue = command.value
  242. switch (command.value) {
  243. case 'read':
  244. this.$Router.navigateTo({
  245. url: '/pages_crm/auditList',
  246. query: {
  247. id: this.detailData.examineRecordId,
  248. u_id: this.detailData.ownerUserId
  249. }
  250. })
  251. break
  252. case 'reset':
  253. this.handleAuditAction('cancel')
  254. break
  255. case 'update':
  256. this.handleEdit()
  257. break
  258. case 'delete':
  259. this.dialogMsg = '您确定要删除该回款吗?'
  260. this.$refs.popup.open()
  261. break
  262. }
  263. },
  264. handleDialogConfirm(next) {
  265. switch (this.commandValue) {
  266. case 'delete':
  267. this.handleDelete()
  268. break
  269. }
  270. next()
  271. },
  272. /**
  273. * 审核操作
  274. * @param action 审核动作
  275. */
  276. handleAuditAction(action) {
  277. getApp().globalData.auditInfo = this.auditInfo
  278. uni.$once('save-audit', this.handleAudit)
  279. this.$Router.navigateTo({
  280. url: '/pages_common/audit/index',
  281. query: {
  282. type: action
  283. }
  284. })
  285. },
  286. /**
  287. * 审核
  288. * @param form 审核信息
  289. */
  290. handleAudit(form) {
  291. let params = {
  292. typeId: this.id,
  293. recordId: this.detailData.examineRecordId,
  294. ...form
  295. }
  296. // console.log('audit', params)
  297. AuditExamine(params).then(() => {
  298. this.$toast(params.status === 4 ? '撤回成功' : '审核成功')
  299. this.refreshPrevPage = true
  300. this.$refreshAndToPrev(this)
  301. }).catch()
  302. },
  303. /**
  304. * 删除
  305. */
  306. handleDelete() {
  307. DeleteByIds([this.id]).then(() => {
  308. this.$toast('删除成功')
  309. this.$refreshAndToPrev(this)
  310. }).catch()
  311. }
  312. }
  313. }
  314. </script>
  315. <style scoped lang="scss">
  316. @import "../style/detail.scss";
  317. </style>