customFlowList.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar :title="navTitle" :refresh-prev="refreshPrevPage" />
  6. <view class="container">
  7. <view class="flow-list">
  8. <view
  9. v-for="(item, index) in flowList"
  10. :key="index"
  11. class="flow-list-item">
  12. <view
  13. :class="{active: item.isOver}"
  14. class="icon-box" />
  15. <view class="content">
  16. <view class="content-title">
  17. <text class="content-title-text">
  18. {{ item.flowName }}
  19. </text>
  20. <text v-if="item.rate" class="content-title-desc">
  21. (赢单率10%)
  22. </text>
  23. </view>
  24. <view
  25. class="content-body"
  26. @click="handleToStageDetail(item)">
  27. <template v-if="!item.flowType">
  28. <image :src="$static('images/icon/money_active.png')" class="icon" />
  29. <text class="text">
  30. 阶段信息
  31. </text>
  32. </template>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view
  39. v-if="flowData.finalStatus === 0"
  40. class="footer-btn-group">
  41. <button
  42. class="button choose-product-btn"
  43. @click="handleToChangeFlow">
  44. 推进阶段流程
  45. </button>
  46. </view>
  47. </view>
  48. <uni-popup
  49. ref="popup"
  50. type="bottom"
  51. radius="20rpx 20rpx 0 0">
  52. <view class="popup">
  53. <view class="header">
  54. <view class="back-icon" @click="handlePopupClose">
  55. <text class="wk wk-close icon" />
  56. </view>
  57. <view class="title" />
  58. <view class="save-btn" @click="handlePopupConfirm">
  59. 确定
  60. </view>
  61. </view>
  62. <view class="options-group">
  63. <view
  64. v-for="(item, index) in flowList"
  65. :key="index"
  66. :class="{active: index === activeIndex}"
  67. class="options-group-item"
  68. @click="handleOptionClick(index, item)">
  69. <text class="text">
  70. {{ item.flowName }}
  71. </text>
  72. <text v-if="activeIndex === index" class="wk wk-check icon" />
  73. </view>
  74. </view>
  75. </view>
  76. </uni-popup>
  77. <uni-popup ref="popupDialog" type="dialog">
  78. <uni-popup-dialog
  79. :content="dialogMsg"
  80. type="warning"
  81. @confirm="handleDialogConfirm" />
  82. </uni-popup>
  83. </view>
  84. </template>
  85. <script>
  86. import {
  87. QueryFlowSettingList,
  88. UpdateFlowDataStatusAPI
  89. } from '@/api/crm/flow.js'
  90. import { crmEnum } from './enum.js'
  91. import { deepCopy } from '@/utils/lib.js'
  92. export default {
  93. name: 'CustomFlowList',
  94. data() {
  95. return {
  96. routerQuery: {},
  97. flowData: {},
  98. flowList: [],
  99. activeIndex: null,
  100. dialogMsg: '',
  101. refreshPrevPage: false,
  102. refreshPage: false
  103. }
  104. },
  105. computed: {
  106. crmType() {
  107. return (this.routerQuery.type || '').replace('crm_', '')
  108. },
  109. navTitle() {
  110. return `${crmEnum[this.crmType].label}流程详情`
  111. }
  112. },
  113. onLoad(options) {
  114. this.routerQuery = options || {}
  115. this.getFlowList()
  116. },
  117. onShow() {
  118. this.refreshNowPage()
  119. },
  120. onBackPress(evt) {
  121. if (evt.from === 'backbutton' && this.refreshPrevPage) {
  122. this.$refreshAndToPrev(this)
  123. return true // 返回值为 true 时,表示不执行默认的返回
  124. }
  125. return false
  126. },
  127. methods: {
  128. refreshNowPage() {
  129. console.log('refresh now page: ', this.refreshPage)
  130. if (this.refreshPage) {
  131. this.$nextTick(function() {
  132. console.log('refresh')
  133. this.refreshPage = false
  134. this.refreshPrevPage = true
  135. this.getFlowList()
  136. })
  137. }
  138. },
  139. /**
  140. * 获取流程信息
  141. */
  142. getFlowList() {
  143. const type = crmEnum[this.crmType].type
  144. QueryFlowSettingList({
  145. label: type,
  146. typeId: this.routerQuery.typeId
  147. }).then(res => {
  148. this.flowData = res
  149. this.formatList()
  150. }).catch(() => {})
  151. },
  152. /**
  153. * 格式化流程数据
  154. */
  155. formatList() {
  156. const list = deepCopy(this.flowData.settingList)
  157. let flag = false
  158. list.forEach(item => {
  159. item.isOver = !flag
  160. if (item.id === this.flowData.dataId) {
  161. flag = true
  162. }
  163. })
  164. const temp = {
  165. examineRecordId: null,
  166. examineStatus: null,
  167. flowName: null,
  168. id: null,
  169. rate: null,
  170. status: 0,
  171. isOver: false
  172. }
  173. const successText = this.crmType === 'business' ? '赢单' : this.flowData.successName
  174. const failText = this.crmType === 'business' ? '输单' : this.flowData.failedName
  175. list.push({
  176. ...temp,
  177. id: 1,
  178. isOver: this.flowData.finalStatus === 1,
  179. flowName: successText,
  180. flowType: 'success'
  181. })
  182. list.push({
  183. ...temp,
  184. id: 2,
  185. isOver: this.flowData.finalStatus > 1,
  186. flowName: failText,
  187. flowType: 'fail'
  188. })
  189. this.flowList = list
  190. },
  191. /**
  192. * 查看阶段详情
  193. */
  194. handleToStageDetail(item) {
  195. // 选择的阶段Id等于当前阶段、有审批当前阶段审核状态为未通过、无审批当前状态为未完成允许编辑修改
  196. const editAuth = item.id === this.flowData.dataId &&
  197. [0, 2, 4].includes(item.examineStatus) &&
  198. item.status === 0
  199. const url = editAuth ? '/pages_crm/customFlowUpdate' : '/pages_crm/customFlowDetail'
  200. this.$Router.navigateTo({
  201. url,
  202. query: {
  203. ...this.routerQuery,
  204. id: item.id
  205. }
  206. })
  207. },
  208. handleToChangeFlow() {
  209. this.activeIndex = null
  210. this.$refs.popup.open()
  211. },
  212. /**
  213. * 选择阶段
  214. * @param {Object} index
  215. */
  216. handleOptionClick(index) {
  217. this.activeIndex = index
  218. },
  219. /**
  220. * 关闭阶段选择
  221. */
  222. handlePopupClose() {
  223. this.$refs.popup.close()
  224. },
  225. /**
  226. * 确定选择阶段
  227. */
  228. handlePopupConfirm() {
  229. this.dialogMsg = '确定要推进至' + this.flowList[this.activeIndex].flowName + '?'
  230. this.$refs.popupDialog.open()
  231. },
  232. /**
  233. * 推进阶段
  234. */
  235. handleDialogConfirm() {
  236. const item = this.flowList[this.activeIndex]
  237. const flag = ['success', 'fail'].includes(item.flowType)
  238. // console.log('推进阶段: ', {
  239. // dataId: flag ? this.flowData.dataId : item.id,
  240. // finalStatus: flag ? item.id : ''
  241. // })
  242. UpdateFlowDataStatusAPI({
  243. dataId: flag ? this.flowData.dataId : item.id,
  244. finalStatus: flag ? item.id : ''
  245. }).then(res => {
  246. this.activeIndex = null
  247. this.refreshPrevPage = true
  248. this.getFlowList()
  249. this.handlePopupClose()
  250. }).catch(() => {})
  251. this.$refs.popupDialog.close()
  252. }
  253. }
  254. }
  255. </script>
  256. <style lang="scss" scoped>
  257. .container {
  258. flex: 1;
  259. background-color: white;
  260. overflow: auto;
  261. padding: 40rpx 30rpx;
  262. .flow-list {
  263. .flow-list-item {
  264. position: relative;
  265. padding: 10rpx 0;
  266. display: flex;
  267. align-items: flex-start;
  268. justify-content: flex-start;
  269. &::before {
  270. position: absolute;
  271. top: 38rpx;
  272. left: 17rpx;
  273. content: '';
  274. width: 1rpx;
  275. height: 100%;
  276. border-left: 1rpx dashed $light;
  277. display: block;
  278. }
  279. &:last-child::before {
  280. display: none;
  281. }
  282. .icon-box {
  283. position: relative;
  284. z-index: 1;
  285. width: 35rpx;
  286. height: 35rpx;
  287. background-color: white;
  288. border: 1rpx solid $light;
  289. border-radius: 50%;
  290. @include center;
  291. &::before {
  292. content: '';
  293. width: 18rpx;
  294. height: 18rpx;
  295. background-color: white;
  296. border-radius: 50%;
  297. display: block;
  298. }
  299. &.active {
  300. border-color: $warning;
  301. background-color: $warning;
  302. }
  303. }
  304. .content {
  305. width: 100%;
  306. height: 136rpx;
  307. border-bottom: 1rpx solid $border-color;
  308. margin-left: 30rpx;
  309. .content-title {
  310. width: 100%;
  311. .content-title-text {
  312. font-weight: 500;
  313. font-size: $wk-font-base;
  314. }
  315. .content-title-desc {
  316. font-size: $wk-font-mini;
  317. color: $light;
  318. }
  319. }
  320. .content-body {
  321. color: $theme-color;
  322. font-size: $wk-font-base;
  323. margin-top: 15rpx;
  324. .icon {
  325. width: 28rpx;
  326. height: 28rpx;
  327. vertical-align: middle;
  328. margin-right: 15rpx;
  329. }
  330. .text {
  331. vertical-align: middle;
  332. }
  333. }
  334. }
  335. }
  336. }
  337. }
  338. .popup {
  339. padding-bottom: 36rpx;
  340. .header {
  341. position: relative;
  342. width: 100%;
  343. height: 80rpx;
  344. @include center;
  345. .back-icon, .save-btn {
  346. position: absolute;
  347. top: 0;
  348. height: 100%;
  349. font-size: $wk-font-medium;
  350. color: $gray;
  351. padding: 20rpx;
  352. @include center;
  353. }
  354. .back-icon {
  355. left: 16rpx;
  356. transform: rotate(180deg);
  357. .icon {
  358. font-size: inherit;
  359. }
  360. }
  361. .save-btn {
  362. right: 16rpx;
  363. color: $theme-color;
  364. font-size: $wk-font-base;
  365. }
  366. }
  367. .options-group {
  368. width: 100%;
  369. padding: 0 36rpx;
  370. .options-group-item {
  371. color: $dark;
  372. font-size: $wk-font-base;
  373. border-bottom: 1rpx solid $border-color;
  374. padding: 22rpx 0;
  375. @include left;
  376. .text {
  377. flex: 1;
  378. }
  379. .icon {
  380. font-size: $wk-font-medium;
  381. color: inherit;
  382. line-height: 1;
  383. }
  384. &.active {
  385. color: $theme-color;
  386. }
  387. }
  388. }
  389. }
  390. </style>