progress.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar title="商机阶段详情" :refresh-prev="refreshPrevPage" />
  6. <view class="container">
  7. <view class="list">
  8. <view
  9. v-for="(item, index) in statusList"
  10. :key="index"
  11. :class="{now: item.status === 1}"
  12. class="list-item">
  13. <view
  14. class="icon-box"
  15. :class="{failed: item.status === 3, success: item.status === 2, wait: item.status === 1}">
  16. <view class="icon">
  17. {{ item.is_end ? '终' : index + 1 }}
  18. </view>
  19. </view>
  20. <view class="content">
  21. <view class="info">
  22. <text class="label">
  23. {{ item.name }}
  24. </text>
  25. <text class="value">
  26. 赢单率{{ item.rate }}%
  27. </text>
  28. </view>
  29. <view v-if="item.status !== 0" class="status">
  30. <template v-if="item.status === 1">
  31. <image :src="$static('images/crmBusiness/business-wait.png')" alt="" class="status-icon" />
  32. <text style="color: #FF7842" class="status-text">
  33. 进行中
  34. </text>
  35. </template>
  36. <template v-if="item.status === 2">
  37. <image :src="$static('images/crmBusiness/business-success.png')" alt="" class="status-icon" />
  38. <text style="color: #46CDCF" class="status-text">
  39. 已完成
  40. </text>
  41. </template>
  42. <template v-if="item.status === 3">
  43. <image :src="$static('images/crmBusiness/business-failed-large.png')" alt="" class="status-icon" />
  44. <text style="color: #ff6767" class="status-text">
  45. 输单
  46. </text>
  47. </template>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view
  54. v-if="statusList.length > 0 && isEnd === 0"
  55. class="footer"
  56. @click="handlePopup">
  57. 阶段变更
  58. </view>
  59. </view>
  60. <uni-popup ref="popup">
  61. <uni-popup-dialog
  62. v-if="showEditPop"
  63. :title="editPopTitle"
  64. placeholder="请输入内容"
  65. mode="input"
  66. @confirm="handleDialogConfirm" />
  67. <view v-else class="pop-wrapper">
  68. <view
  69. v-for="(item, index) in popOptions"
  70. :key="index"
  71. class="pop-item"
  72. @click.stop="handleSelectOptions(item)">
  73. {{ item.name }}
  74. </view>
  75. </view>
  76. </uni-popup>
  77. </view>
  78. </template>
  79. <script>
  80. import {QueryBusinessStatus, BoostBusinessStatus} from 'API/crm/business'
  81. import sortMixins from '@/mixins/listSort'
  82. export default {
  83. name: 'BusinessProgress',
  84. mixins: [sortMixins],
  85. data() {
  86. return {
  87. statusList: [],
  88. isEnd: null,
  89. params: {},
  90. editPopTitle: '',
  91. showEditPop: false,
  92. refreshPrevPage: false
  93. }
  94. },
  95. computed: {
  96. popOptions() {
  97. let arr = []
  98. if (this.isEnd === 0) {
  99. // this.statusList.forEach(item => {
  100. // if (item.status === 0) {
  101. // arr.push(item)
  102. // }
  103. // })
  104. // return arr
  105. return this.statusList
  106. }
  107. return []
  108. }
  109. },
  110. onLoad(options) {
  111. this.id = options.id || null
  112. this.getDetail()
  113. },
  114. onBackPress(evt) {
  115. if (evt.from === 'backbutton' && this.refreshPrevPage) {
  116. this.$refreshAndToPrev(this)
  117. return true // 返回值为 true 时,表示不执行默认的返回
  118. }
  119. return false
  120. },
  121. methods: {
  122. getDetail() {
  123. // is_end 0 未结束 1 赢单 2 输 3 无效
  124. this.statusList = []
  125. QueryBusinessStatus({id: this.id}).then(response => {
  126. let list = this.mixinsSort(response.statusList, 'orderNum')
  127. console.log(list)
  128. this.isEnd = response.isEnd;
  129. let currentStatusId = response.statusId
  130. let arr = [
  131. {name: '赢单', rate: 100, status: 0, is_end: 1},
  132. {name: '输单', rate: 0, status: 0, is_end: 2},
  133. {name: '无效单', rate: 0, status: 0, is_end: 3}
  134. ]
  135. if (this.isEnd === 1) {
  136. // 赢单
  137. arr[0].status = 2
  138. list.forEach(item => {
  139. item.status = 2
  140. })
  141. } else if (this.isEnd === 2) {
  142. // 输单
  143. arr[1].status = 3
  144. list.forEach(item => {
  145. item.status = 2
  146. })
  147. } else if (this.isEnd === 0) {
  148. // 进行中
  149. let stepIndex = list.findIndex(status => {
  150. return status.statusId == currentStatusId
  151. }) || 0
  152. list.forEach((item, index) => {
  153. if (index < stepIndex) {
  154. item.status = 2
  155. } else if (index === stepIndex) {
  156. item.status = 1
  157. } else {
  158. item.status = 0
  159. }
  160. })
  161. }
  162. list = list.concat(arr)
  163. this.statusList = list
  164. }).catch()
  165. },
  166. handlePopup() {
  167. this.showEditPop = false
  168. this.$refs.popup.open()
  169. },
  170. handleSelectOptions(item) {
  171. let params = {
  172. businessId: this.id,
  173. }
  174. if (item.is_end) {
  175. params.isEnd = item.is_end
  176. } else {
  177. params.statusId = item.statusId
  178. }
  179. this.params = params
  180. if (params.isEnd === 2) {
  181. // 输单
  182. this.editPopTitle = '输单原因'
  183. this.showEditPop = true
  184. } else if (params.isEnd === 3) {
  185. // 无效单
  186. this.editPopTitle = '无效原因'
  187. this.showEditPop = true
  188. } else {
  189. this.bootBusiness()
  190. }
  191. },
  192. handleDialogConfirm(next, value) {
  193. this.params.statusRemark = value
  194. this.bootBusiness()
  195. },
  196. bootBusiness() {
  197. console.log('save: ', this.params)
  198. this.$refs.popup.close()
  199. BoostBusinessStatus(this.params).then(response => {
  200. this.$toast('商机推进成功')
  201. this.refreshPrevPage = true
  202. this.getDetail()
  203. }).catch(() => {})
  204. }
  205. }
  206. }
  207. </script>
  208. <style scoped lang="scss">
  209. .container {
  210. flex: 1;
  211. background-color: white;
  212. overflow: auto;
  213. padding: 40rpx 30rpx;
  214. .list {
  215. .list-item {
  216. display: flex;
  217. .icon-box {
  218. position: relative;
  219. @include center;
  220. .icon {
  221. width: 48rpx;
  222. height: 48rpx;
  223. color: $light;
  224. font-size: 26rpx;
  225. text-align: center;
  226. line-height: 48rpx;
  227. background-color: $main-bg;
  228. border-radius: 50%;
  229. border: 1rpx solid #ccc;
  230. }
  231. &.failed .icon {
  232. color: white;
  233. background-color: #ff6767;
  234. border-color: transparent;
  235. }
  236. &.success .icon {
  237. color: white;
  238. background-color: #46CDCF;
  239. border-color: transparent;
  240. }
  241. &.wait .icon {
  242. color: white;
  243. background-color: $warning;
  244. border-color: transparent;
  245. }
  246. &:before {
  247. position: absolute;
  248. top: calc(50% + 24rpx);
  249. left: 50%;
  250. transform: translateX(-50%);
  251. content: '';
  252. width: 2rpx;
  253. height: 100%;
  254. background: 0 none;
  255. border-left: 1rpx dotted #ccc;
  256. display: block;
  257. }
  258. &.success:before {
  259. border: 0 none;
  260. background-color: #46CDCF;
  261. }
  262. }
  263. .content {
  264. flex: 1;
  265. margin-left: 30rpx;
  266. @include left;
  267. .info {
  268. flex: 1;
  269. flex-direction: column;
  270. display: flex;
  271. padding: 25rpx 0;
  272. .label {
  273. font-size: 32rpx;
  274. color: $dark;
  275. }
  276. .value {
  277. font-size: 26rpx;
  278. color: $light;
  279. margin-top: 16rpx;
  280. }
  281. }
  282. .status {
  283. flex-direction: column;
  284. margin-right: 40rpx;
  285. @include center;
  286. .status-icon {
  287. width: 50rpx;
  288. height: 50rpx;
  289. }
  290. .status-text {
  291. font-size: 20rpx;
  292. }
  293. }
  294. }
  295. &.now {
  296. .content {
  297. box-shadow: 0 1rpx 16rpx #E3E6E9;
  298. padding-left: 30rpx;
  299. }
  300. }
  301. &:last-child {
  302. .icon-box:before {
  303. display: none;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. .footer {
  310. position: fixed;
  311. bottom: 0;
  312. bottom: constant(safe-area-inset-bottom);
  313. bottom: env(safe-area-inset-bottom);
  314. left: 0;
  315. width: 100%;
  316. height: 100rpx;
  317. font-size: 32rpx;
  318. text-align: center;
  319. line-height: 100rpx;
  320. color: $theme-color;
  321. border-top: 1rpx solid $border-color;
  322. background-color: white;
  323. }
  324. </style>