aboutBusiness.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="section about-business">
  3. <view class="section-title">
  4. <image :src="$static('images/crm_about/business.png')" class="icon" />
  5. <text class="title">
  6. 商机
  7. </text>
  8. <view
  9. v-if="!config.isSeas"
  10. class="add-btn"
  11. @click="handleAdd">
  12. <text class="wk wk-plus icon-add" />
  13. <text>新建</text>
  14. </view>
  15. </view>
  16. <view class="section-body">
  17. <template v-if="list.length > 0">
  18. <view class="list">
  19. <view
  20. v-for="(item, index) in list"
  21. :key="index"
  22. class="list-item"
  23. @click="handleTo(item.businessId)">
  24. <view class="list-item-circle">
  25. <template v-if="item.businessStatusCount">
  26. <view
  27. v-if="calcProgress(item) === 'ok'"
  28. class="icon-box success">
  29. <text class="wk wk-check" />
  30. </view>
  31. <view
  32. v-else-if="calcProgress(item) === 'fail'"
  33. class="icon-box fail">
  34. <text class="wk wk-close" />
  35. </view>
  36. <view
  37. v-else-if="calcProgress(item) === 'invalid'"
  38. class="icon-box invalid">
  39. <text class="line" />
  40. </view>
  41. <view v-else class="progress">
  42. <cmd-progress
  43. :width="rpxToPx(66)"
  44. :stroke-width="10"
  45. :trail-width="10"
  46. :show-info="false"
  47. :percent="calcProgress(item)"
  48. stroke-color="#1f72ff"
  49. type="circle" />
  50. <text class="progress-text">
  51. {{ item.businessStatusCount.currentProgress }}/{{ item.businessStatusCount.totalProgress }}
  52. </text>
  53. </view>
  54. </template>
  55. </view>
  56. <view class="list-item-info">
  57. <view class="box">
  58. <text class="name">
  59. {{ item.businessName }}
  60. </text>
  61. <text class="num">
  62. ¥{{ splitNumber(item.money) }}
  63. </text>
  64. </view>
  65. <view class="box">
  66. <text class="customer">
  67. 预计成交时间:{{ item.dealDate | formatTime }}
  68. </text>
  69. <text class="status">
  70. {{ statusName(item) }}
  71. </text>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <template v-else>
  78. <view class="no-data">
  79. 暂无数据
  80. </view>
  81. </template>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import { splitNumber } from '@/utils/lib.js'
  87. import moment from 'moment'
  88. export default {
  89. name: 'AboutBusiness',
  90. filters: {
  91. formatTime(val) {
  92. if (!val) return '--'
  93. return moment(val).format('YYYY-MM-DD')
  94. }
  95. },
  96. props: {
  97. list: {
  98. type: Array,
  99. required: true
  100. },
  101. config: {
  102. type: Object,
  103. default: () => {}
  104. }
  105. },
  106. data() {
  107. return {}
  108. },
  109. methods: {
  110. rpxToPx(num) {
  111. return uni.upx2px(num)
  112. },
  113. splitNumber(num) {
  114. return splitNumber(num)
  115. },
  116. /**
  117. * 计算商机进度
  118. */
  119. calcProgress(item) {
  120. console.log('business item', item)
  121. if (item.isEnd === 0) {
  122. const count = item.businessStatusCount
  123. return count.currentProgress / count.totalProgress * 100
  124. }
  125. const arr = ['', 'ok', 'fail', 'invalid']
  126. return arr[item.isEnd]
  127. },
  128. statusName(item) {
  129. // if (item.isEnd === 0) {
  130. // return item.statusName
  131. // }
  132. let arr = ['', '赢单', '输单', '无效单']
  133. return arr[item.isEnd]
  134. },
  135. handleTo(id) {
  136. const checkRes = this.$auth('crm.business.read')
  137. if (!checkRes) {
  138. this.$toast('权限不足!')
  139. return
  140. }
  141. this.$Router.navigateTo({
  142. url: '/pages_crm/business/detail',
  143. query: {
  144. id: id
  145. }
  146. })
  147. },
  148. handleAdd() {
  149. const checkRes = this.$auth('crm.business.save')
  150. if (!checkRes) {
  151. this.$toast('权限不足!')
  152. return
  153. }
  154. if (!this.config.detail) return
  155. const bridgeData = {
  156. default: {
  157. customerId: [{
  158. customerId: this.config.detail.customerId,
  159. customerName: this.config.detail.customerName
  160. }]
  161. }
  162. }
  163. const crmType = this.config.type
  164. if (crmType === 'contacts') {
  165. bridgeData.assignForm = {
  166. contactsId: this.config.detail.contactsId
  167. }
  168. }
  169. getApp().globalData.formBridge = bridgeData
  170. this.$Router.navigateTo({
  171. url: '/pages_crm/business/create'
  172. })
  173. },
  174. }
  175. }
  176. </script>
  177. <style scoped lang="scss">
  178. @import './style.scss';
  179. .list {
  180. padding: 0 32rpx;
  181. &-item {
  182. @include left;
  183. &-circle {
  184. margin-right: 26rpx;
  185. .progress {
  186. position: relative;
  187. width: 66rpx;
  188. height: 66rpx;
  189. font-size: 22rpx;
  190. color: $gray;
  191. display: inline-block;
  192. .progress-text {
  193. position: absolute;
  194. top: 50%;
  195. left: 50%;
  196. transform: translate(-50%, -50%);
  197. }
  198. }
  199. .icon-box {
  200. width: 66rpx;
  201. height: 66rpx;
  202. border-radius: 50%;
  203. border-width: 6rpx;
  204. border-style: solid;
  205. @include center;
  206. &.success {
  207. color: #00c75c;
  208. border-color: #00c75c;
  209. }
  210. &.fail {
  211. color: #ff575d;
  212. border-color: #ff575d;
  213. }
  214. &.invalid {
  215. color: #cfcfcf;
  216. border-color: #cfcfcf;
  217. font-weight: blod;
  218. .line {
  219. width: 70rpx;
  220. height: 6rpx;
  221. transform: rotate(-45deg);
  222. background-color: #cfcfcf;
  223. vertical-align: middle;
  224. display: inline-block;
  225. }
  226. }
  227. .wk {
  228. font-size: 38rpx;
  229. font-weight: bold;
  230. margin-left: 2rpx;
  231. margin-top: 2rpx;
  232. }
  233. }
  234. .invalid-icon {
  235. width: 76rpx;
  236. height: 76rpx;
  237. color: #aaaaaa;
  238. line-height: 1;
  239. font-size: 76rpx;
  240. font-weight: 400;
  241. }
  242. }
  243. &-info {
  244. flex: 1;
  245. border-bottom: 1rpx solid $border-color;
  246. @include padding;
  247. .box {
  248. @include left;
  249. .name {
  250. flex: 1;
  251. font-size: $wk-font-medium;
  252. font-weight: 500;
  253. color: $dark;
  254. }
  255. .num {
  256. font-size: $wk-font-sm;
  257. font-weight: bold;
  258. color: $warning;
  259. }
  260. .customer {
  261. flex: 1;
  262. font-size: $wk-font-sm;
  263. color: $gray;
  264. }
  265. .status {
  266. font-size: $wk-font-mini;
  267. color: $gray;
  268. }
  269. }
  270. }
  271. }
  272. .list-item:last-child {
  273. .list-item-info {
  274. border-bottom: 0 none;
  275. }
  276. }
  277. }
  278. </style>