backlogDetailFilter.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <!-- #ifdef MP-WEIXIN -->
  6. <wk-nav-bar
  7. :command-list="commandList"
  8. :title="title"
  9. @command="handleCommand" />
  10. <!-- #endif -->
  11. <!-- #ifndef MP-WEIXIN -->
  12. <wk-nav-bar :title="title">
  13. <!-- <text
  14. class="read-all"
  15. @click="handleReadAll">
  16. 全部已处理
  17. </text> -->
  18. </wk-nav-bar>
  19. <!-- #endif -->
  20. <view class="list-wrapper">
  21. <view class="filter-group">
  22. <wk-base-filter :tabs="filterOptions" @filter="handleFilter" />
  23. </view>
  24. <wk-scroll-view
  25. :status="listStatus"
  26. :refresh="false"
  27. class="list-scroll"
  28. @loadmore="getList()">
  29. <template v-for="(data, index) in listData">
  30. <detail-customer-item
  31. v-if="activeCom === 'DetailCustomerItem'"
  32. :key="index"
  33. :type="typeObj.type"
  34. :item-data="data"
  35. :open-slider="openSlider"
  36. @refresh="handleRefresh(index)" />
  37. <detail-receivables-item
  38. v-else-if="activeCom === 'DetailReceivablesItem'"
  39. :key="index"
  40. :type="typeObj.type"
  41. :item-data="data"
  42. :open-slider="openSlider"
  43. @refresh="handleRefresh(index)" />
  44. <detail-contract-item
  45. v-else-if="activeCom === 'DetailContractItem'"
  46. :key="index"
  47. :type="typeObj.type"
  48. :item-data="data"
  49. :open-slider="openSlider"
  50. @refresh="handleRefresh(index)" />
  51. <detail-leads-item
  52. v-else-if="activeCom === 'DetailLeadsItem'"
  53. :key="index"
  54. :type="typeObj.type"
  55. :item-data="data"
  56. :open-slider="openSlider"
  57. @refresh="handleRefresh(index)" />
  58. <detail-await-receivables-item
  59. v-else-if="activeCom === 'DetailAwaitReceivablesItem'"
  60. :key="index"
  61. :type="typeObj.type"
  62. :item-data="data"
  63. :open-slider="openSlider"
  64. @refresh="handleRefresh(index)" />
  65. <detail-examination-item
  66. v-else-if="activeCom === 'DetailExaminationItem'"
  67. :key="index"
  68. :type="typeObj.type"
  69. :item-data="data"
  70. :open-slider="openSlider"
  71. @refresh="handleRefresh(index)" />
  72. </template>
  73. </wk-scroll-view>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import * as API from 'API/crm/message'
  80. import { MyExamine } from 'API/oa/examine'
  81. import DetailCustomerItem from './backlog/detailCustomerItem'
  82. import DetailContractItem from './backlog/detailContractItem'
  83. import DetailLeadsItem from './backlog/detailLeadsItem'
  84. import DetailReceivablesItem from './backlog/detailReceivablesItem'
  85. import DetailAwaitReceivablesItem from './backlog/detailAwaitReceivablesItem'
  86. import DetailExaminationItem from './backlog/detailExaminationItem'
  87. import mainListMixins from '@/mixins/mainList.js'
  88. export default {
  89. name: 'BacklogDetilFilter',
  90. components: {
  91. DetailCustomerItem,
  92. DetailReceivablesItem,
  93. DetailContractItem,
  94. DetailLeadsItem,
  95. DetailAwaitReceivablesItem,
  96. DetailExaminationItem
  97. },
  98. mixins: [mainListMixins],
  99. data() {
  100. return {
  101. routerQuery: {},
  102. title: '',
  103. activeCom: '',
  104. typeObj: {},
  105. filterData: {
  106. isSub: 1,
  107. type: 1
  108. },
  109. loading: false,
  110. commandList: [
  111. {
  112. label: '全部已处理',
  113. imgIcon: 'dealStatus',
  114. value: 'readAll'
  115. }
  116. ],
  117. typeMap: [
  118. {
  119. label: '今日需联系客户',
  120. type: 1,
  121. component: 'DetailCustomerItem',
  122. fn: API.TodayCustomer,
  123. icon: 'wk-customer',
  124. color: '#2362fb',
  125. show: false,
  126. options: [
  127. {label: '今日需联系', value: 1},
  128. {label: '已逾期', value: 2},
  129. {label: '已联系', value: 3}
  130. ],
  131. field: 'todayCustomer'
  132. }, // 1
  133. {
  134. label: '分配给我的线索',
  135. type: 2,
  136. component: 'DetailLeadsItem',
  137. fn: API.FollowLeads,
  138. icon: 'wk-leads',
  139. color: '#704afd',
  140. show: false,
  141. options: [
  142. {label: '待跟进', value: 1},
  143. {label: '已跟进', value: 2},
  144. ],
  145. field: 'followLeads'
  146. }, // 2
  147. {
  148. label: '分配给我的客户',
  149. type: 3,
  150. component: 'DetailCustomerItem',
  151. fn: API.FollowCustomer,
  152. icon: 'wk-s-seas',
  153. color: '#19b5f6',
  154. show: false,
  155. options: [
  156. {label: '待跟进', value: 1},
  157. {label: '已跟进', value: 2},
  158. ],
  159. field: 'followCustomer'
  160. }, // 3
  161. {
  162. label: '待进入公海的客户',
  163. type: 4,
  164. component: 'DetailCustomerItem',
  165. fn: API.PutInPoolRemind,
  166. icon: 'wk-seas',
  167. color: '#26d4da',
  168. show: false,
  169. options: [],
  170. field: 'putInPoolRemind'
  171. }, // 4
  172. {
  173. label: '即将到期的合同',
  174. type: 8,
  175. component: 'DetailContractItem',
  176. fn: API.EndContract,
  177. icon: 'wk-contract',
  178. color: '#ff7a38',
  179. show: false,
  180. options: [
  181. {label: '即将到期', value: 1},
  182. {label: '已到期', value: 2}
  183. ],
  184. field: 'endContract'
  185. }, // 8
  186. {
  187. label: '待审核合同',
  188. type: 5,
  189. component: 'DetailContractItem',
  190. fn: API.CheckContract,
  191. icon: 'wk-contract',
  192. color: '#fd5b4a',
  193. show: false,
  194. options: [
  195. {label: '待审核', value: 1},
  196. {label: '已审核', value: 2}
  197. ],
  198. field: 'checkContract'
  199. }, // 5
  200. {
  201. label: '待审核回款',
  202. type: 6,
  203. component: 'DetailReceivablesItem',
  204. fn: API.CheckReceivables,
  205. icon: 'wk-receivables',
  206. color: '#ffb940',
  207. show: false,
  208. options: [
  209. {label: '待审核', value: 1},
  210. {label: '已审核', value: 2}
  211. ],
  212. field: 'checkReceivables'
  213. }, // 6
  214. {
  215. label: '待回款提醒',
  216. type: 7,
  217. component: 'DetailAwaitReceivablesItem',
  218. fn: API.RemindReceivablesPlan,
  219. icon: 'wk-bell',
  220. color: '#27ba4a',
  221. show: false,
  222. options: [
  223. {label: '待回款', value: 1},
  224. {label: '已回款', value: 2},
  225. {label: '已逾期', value: 3}
  226. ],
  227. field: 'remindReceivablesPlan'
  228. }, // 7
  229. {
  230. label: '待审核的办公',
  231. type: 100,
  232. component: 'DetailExaminationItem',
  233. fn: MyExamine,
  234. icon: 'wk-approve',
  235. color: '#9376ff',
  236. show: false,
  237. options: [],
  238. field: 'examineNum'
  239. }, // 100
  240. ],
  241. }
  242. },
  243. computed: {
  244. openSlider() {
  245. if (!this.typeObj) return false
  246. return [2, 3].includes(this.typeObj.type) && this.params.type === 1;
  247. },
  248. filterOptions() {
  249. if (!this.typeObj || this.typeObj.type === 9) return []
  250. const type = this.typeObj.type
  251. let arr = []
  252. if ([1, 4].includes(type)) {
  253. arr.push({
  254. label: '筛选场景',
  255. field: 'isSub',
  256. value: 1,
  257. valueData: 0,
  258. options: [
  259. {label: '我的', value: 1},
  260. {label: '我下属的', value: 2}
  261. ]
  262. })
  263. }
  264. if (this.typeObj.options && this.typeObj.options.length > 0) {
  265. arr.push({
  266. label: '状态',
  267. field: 'type',
  268. value: this.typeObj.options[0].value,
  269. valueData: 0,
  270. options: this.typeObj.options
  271. })
  272. }
  273. return arr
  274. },
  275. },
  276. onLoad(options) {
  277. this.routerQuery = options
  278. },
  279. onShow() {
  280. this.$nextTick(() => {
  281. this.initCom()
  282. })
  283. },
  284. methods: {
  285. /**
  286. * 初始化数据
  287. */
  288. initCom() {
  289. this.listData = []
  290. let type = this.routerQuery.type || null
  291. let findRes = this.typeMap.find(item => item.type === Number(type))
  292. if (findRes) {
  293. this.title = findRes.label
  294. this.activeCom = findRes.component
  295. this.typeObj = findRes
  296. this.getList(true)
  297. }
  298. },
  299. handleFilter(item) {
  300. this.filterData[item.field] = item.value
  301. this.getList(true)
  302. },
  303. /**
  304. * 获取请求筛选条件
  305. */
  306. getFilterData() {
  307. let filterData = Object.assign({}, this.filterData)
  308. let findRes = this.filterOptions.find(item => item.field === 'type')
  309. if (!findRes && filterData.hasOwnProperty('type')) delete filterData.type
  310. if (this.typeObj.type === 9) {
  311. filterData = {
  312. status: 1
  313. }
  314. }
  315. return filterData || {}
  316. },
  317. /**
  318. * 获取数据列表
  319. * @param refresh 是否为刷新重置数据
  320. */
  321. getList(refresh = false) {
  322. if (this.loading) return
  323. this.loading = true
  324. if (refresh) {
  325. this.listParams.page = 0
  326. }
  327. this.listParams.page++
  328. let filterVal = this.getFilterData()
  329. this.listStatus = 'loading'
  330. this.typeObj.fn({
  331. ...this.params,
  332. ...this.listParams,
  333. ...filterVal
  334. }).then(res => {
  335. this.loading = false
  336. if (this.listParams.page === 1) {
  337. this.listData = []
  338. }
  339. this.listData = this.listData.concat(res.list)
  340. if (res.hasOwnProperty('lastPage')) {
  341. this.listStatus = res.lastPage ? 'noMore' : 'more'
  342. } else {
  343. this.listStatus = res.list.length === 0 ? 'noMore' : 'more'
  344. }
  345. }).catch(() => {
  346. this.listStatus = 'more'
  347. this.loading = false
  348. })
  349. },
  350. /**
  351. * 跟进后刷新列表数据
  352. */
  353. handleRefresh() {
  354. this.getList(true)
  355. },
  356. handleCommand(command) {
  357. console.log('command: ', command)
  358. if (command.value === 'readAll') {
  359. this.handleReadAll()
  360. }
  361. },
  362. handleReadAll() {
  363. API.CrmBacklogAllDeal({
  364. model: this.typeObj.type
  365. }).then(res => {
  366. this.$toast('操作成功')
  367. this.initCom()
  368. }).catch(() => {})
  369. }
  370. }
  371. }
  372. </script>
  373. <style scoped lang="scss">
  374. .list-wrapper {
  375. width: 100%;
  376. height: 100%;
  377. display: flex;
  378. flex-direction: column;
  379. overflow: hidden;
  380. .list-scroll {
  381. flex: 1;
  382. overflow: hidden;
  383. }
  384. }
  385. .read-all {
  386. font-size: $wk-font-base;
  387. margin-right: 20rpx;
  388. }
  389. </style>