flowProgress.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view
  3. v-if="showFlow"
  4. class="flow-progress">
  5. <!-- <view class="progress-box">
  6. <cmd-progress
  7. :width="rpxToPx(80)"
  8. :stroke-width="10"
  9. :trail-width="10"
  10. :show-info="false"
  11. :percent="progressPercent"
  12. stroke-color="#1f72ff"
  13. type="circle" />
  14. <text class="progress-box__content">
  15. {{ stepIndex }}/{{ listLength }}
  16. </text>
  17. </view> -->
  18. <view class="progress-info">
  19. <view class="status">
  20. {{ currentFlow.flowName || '--' }}
  21. </view>
  22. <view class="label">
  23. 阶段信息
  24. </view>
  25. </view>
  26. <view
  27. class="progress-status"
  28. @click="handleToProgress">
  29. <text class="wk wk-edit icon" />
  30. 更改
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import { QueryFlowSettingList } from '@/api/crm/flow.js'
  36. import { divideOperation, multiOperation } from '@/utils/lib.js'
  37. import { crmEnum } from '../../enum.js'
  38. /**
  39. * 自定义流程进度
  40. */
  41. export default {
  42. name: 'FlowProgress',
  43. props: {
  44. type: {
  45. type: String,
  46. required: true
  47. },
  48. detailId: {
  49. type: [String, Number],
  50. required: true
  51. },
  52. detailData: {
  53. type: Object,
  54. required: true
  55. }
  56. },
  57. data() {
  58. return {
  59. keyMap: {
  60. type: 'customer',
  61. field: 'customerId'
  62. },
  63. flowData: null
  64. }
  65. },
  66. computed: {
  67. showFlow() {
  68. return this.flowData &&
  69. this.flowData.settingList &&
  70. this.flowData.settingList.length
  71. },
  72. stepIndex() {
  73. if (!this.flowData) return 0
  74. const list = this.flowData.settingList || []
  75. if (list.length === 0) return 0
  76. const currentId = this.flowData.dataId
  77. const findIndex = this.flowData.settingList.findIndex(o => o.id === currentId)
  78. if (findIndex === -1) return 0
  79. return findIndex + 1
  80. },
  81. listLength() {
  82. if (!this.flowData) return 0
  83. const list = this.flowData.settingList || []
  84. return list.length + 1
  85. },
  86. // 进度百分比
  87. progressPercent() {
  88. if (this.stepIndex === 0) return 0
  89. if (this.listLength === 0) return 100
  90. let res = divideOperation(this.stepIndex, this.listLength)
  91. res = multiOperation(res, 100)
  92. return Number(res.toFixed(2))
  93. },
  94. // 当前所在的流程
  95. currentFlow() {
  96. if (!this.flowData) return null
  97. const list = this.flowData.settingList || []
  98. const findRes = list.find(o => o.id === this.flowData.dataId)
  99. return findRes || null
  100. }
  101. },
  102. watch: {
  103. detailData: {
  104. handler() {
  105. if (this.detailData) {
  106. this.getData()
  107. }
  108. },
  109. deep: true,
  110. immediate: true
  111. }
  112. },
  113. methods: {
  114. rpxToPx(num) {
  115. return uni.upx2px(num)
  116. },
  117. getData() {
  118. const key = this.type.replace('crm_', '')
  119. const obj = crmEnum[key] || {}
  120. if (!this.detailData || !this.detailData[obj.primaryKey]) return
  121. QueryFlowSettingList({
  122. label: obj.type,
  123. typeId: this.detailData[obj.primaryKey]
  124. }).then(res => {
  125. console.log('QueryFlowSettingList: ', res)
  126. this.flowData = res
  127. }).catch(() => {
  128. })
  129. },
  130. /**
  131. * 切换阶段
  132. */
  133. handleToProgress() {
  134. this.$Router.navigateTo({
  135. url: '/pages_crm/customFlowList',
  136. query: {
  137. type: this.type,
  138. typeId: this.detailId
  139. }
  140. })
  141. }
  142. }
  143. }
  144. </script>
  145. <style scoped lang="scss">
  146. .flow-progress {
  147. font-size: 24rpx;
  148. color: $gray;
  149. @include left;
  150. .progress-box {
  151. position: relative;
  152. width: 80rpx;
  153. height: 80rpx;
  154. margin-right: 25rpx;
  155. .progress-box__content {
  156. position: absolute;
  157. top: 50%;
  158. left: 50%;
  159. transform: translate(-50%, -50%);
  160. }
  161. }
  162. .progress-info {
  163. flex: 1;
  164. .status {
  165. font-size: $wk-font-base;
  166. color: $dark;
  167. font-weight: 500;
  168. }
  169. .label {
  170. font-size: $wk-font-mini;
  171. color: $theme-color;
  172. }
  173. }
  174. .progress-status {
  175. color: $theme-color;
  176. font-size: $wk-font-mini;
  177. .icon {
  178. font-size: inherit;
  179. font-weight: bold;
  180. margin-right: 10rpx;
  181. }
  182. }
  183. }
  184. </style>