crmSearch.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar :title="searchTitle" />
  6. <view class="search-box">
  7. <text class="wk wk-search" />
  8. <input
  9. v-model="keyword"
  10. type="text"
  11. :maxlength="50"
  12. :placeholder="placeholder"
  13. placeholder-class="wk-placeholder"
  14. class="input-core">
  15. <image
  16. :src="$static('images/icon/delete_fill.png')"
  17. alt=""
  18. class="delete-icon"
  19. @click="handleClear" />
  20. </view>
  21. <view class="list-view">
  22. <wk-scroll-view
  23. :status="listStatus"
  24. :refresh="false"
  25. :show-empty="showEmpty"
  26. class="list-scroll"
  27. @loadmore="getList()">
  28. <template v-for="(item, index) in listData">
  29. <leads-item
  30. v-if="crmType === 'leads'"
  31. :key="index"
  32. :item-data="item" />
  33. <customer-item
  34. v-else-if="crmType === 'customer'"
  35. :key="index"
  36. :item-data="item" />
  37. <customer-item
  38. v-else-if="crmType === 'pool'"
  39. :key="index"
  40. :item-data="item"
  41. :pool-id="poolId"
  42. is-seas />
  43. <contacts-item
  44. v-else-if="crmType === 'contacts'"
  45. :key="index"
  46. :item-data="item" />
  47. <business-item
  48. v-else-if="crmType === 'business'"
  49. :key="index"
  50. :item-data="item" />
  51. <contract-item
  52. v-else-if="crmType === 'contract'"
  53. :key="index"
  54. :item-data="item" />
  55. <received-item
  56. v-else-if="crmType === 'receivables'"
  57. :key="index"
  58. :item-data="item" />
  59. <product-item
  60. v-else-if="crmType === 'product'"
  61. :key="index"
  62. :item-data="item" />
  63. <invoice-item
  64. v-else-if="crmType === 'invoice'"
  65. :key="index"
  66. :item-data="item" />
  67. </template>
  68. </wk-scroll-view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import { GetList as GetLeadsList } from 'API/crm/leads'
  75. import { GetList as GetCustomerList } from 'API/crm/customer'
  76. import { PoolList as GetPoolList } from 'API/crm/pool'
  77. import { GetList as GetContactsList } from 'API/crm/concat'
  78. import { GetList as GetBusinessLeadsList } from 'API/crm/business'
  79. import { GetList as GetContractList } from 'API/crm/contract'
  80. import { GetList as GetReceivablesList } from 'API/crm/received'
  81. import { GetList as GetProductList } from 'API/crm/product'
  82. import { GetList as GetInvoiceList } from 'API/crm/invoice'
  83. import LeadsItem from './leads/components/leadsItem.vue'
  84. import CustomerItem from './customer/components/customerItem.vue'
  85. import ContactsItem from './contacts/components/contactsItem.vue'
  86. import BusinessItem from './business/components/businessItem.vue'
  87. import ContractItem from './contract/components/contractItem.vue'
  88. import ReceivedItem from './receivables/components/receivedItem.vue'
  89. import ProductItem from './product/components/productItem.vue'
  90. import InvoiceItem from './invoice/components/invoiceItem.vue'
  91. export default {
  92. name: 'CrmSearch',
  93. components: {
  94. LeadsItem,
  95. CustomerItem,
  96. ContactsItem,
  97. BusinessItem,
  98. ContractItem,
  99. ReceivedItem,
  100. ProductItem,
  101. InvoiceItem
  102. },
  103. data() {
  104. return {
  105. crmType: null,
  106. poolId: null,
  107. keyword: '',
  108. timer: null,
  109. params: {
  110. page: 0,
  111. limit: 15,
  112. search: ''
  113. },
  114. listStatus: 'more',
  115. listData: [],
  116. showEmpty: false,
  117. apiMap: {
  118. leads: {
  119. func: GetLeadsList,
  120. type: 1,
  121. typeName: '线索',
  122. placeholder: '请输入线索名称/手机/电话',
  123. },
  124. customer: {
  125. func: GetCustomerList,
  126. type: 2,
  127. typeName: '客户',
  128. placeholder: '请输入客户名称/手机/电话'
  129. },
  130. contacts: {
  131. func: GetContactsList,
  132. type: 3,
  133. typeName: '联系人',
  134. placeholder: '请输入联系人姓名/手机/电话'
  135. },
  136. business: {
  137. func: GetBusinessLeadsList,
  138. type: 5,
  139. typeName: '商机',
  140. placeholder: '请输入商机名称'
  141. },
  142. contract: {
  143. func: GetContractList,
  144. type: 6,
  145. typeName: '合同',
  146. placeholder: '请输入客户名称/合同编号/合同名称'
  147. },
  148. receivables: {
  149. func: GetReceivablesList,
  150. type: 7,
  151. typeName: '回款',
  152. placeholder: '请输入客户名称/回款编号'
  153. },
  154. product: {
  155. func: GetProductList,
  156. type: 4,
  157. typeName: '产品',
  158. placeholder: '请输入产品名称'
  159. },
  160. pool: {
  161. func: GetPoolList,
  162. type: 8,
  163. typeName: '公海',
  164. placeholder: '请输入客户名称/手机/电话'
  165. },
  166. invoice: {
  167. func: GetInvoiceList,
  168. type: 18,
  169. typeName: '发票',
  170. placeholder: '请输入发票号码/客户名称/合同编号'
  171. }
  172. }
  173. }
  174. },
  175. computed: {
  176. apiObj() {
  177. return this.apiMap[this.crmType] || {}
  178. },
  179. searchTitle() {
  180. return this.apiObj.typeName || ''
  181. },
  182. placeholder() {
  183. return this.apiObj.placeholder || '请输入关键字'
  184. }
  185. },
  186. watch: {
  187. keyword(val) {
  188. // 禁止输入 emoji
  189. const regStr = /[\ud800-\udbff]|[\udc00-\udfff]/g;
  190. if (regStr.test(val)) {
  191. val = val.replace(regStr, '');
  192. }
  193. this.keyword = val
  194. this.params.page = 0
  195. if (this.timer) {
  196. clearTimeout(this.timer)
  197. this.timer = null
  198. }
  199. this.timer = setTimeout(() => {
  200. clearTimeout(this.timer)
  201. this.timer = null
  202. this.params.search = this.keyword
  203. this.getList()
  204. }, 800)
  205. },
  206. },
  207. onLoad(options) {
  208. this.crmType = options.type
  209. this.poolId = options.poolId
  210. },
  211. methods: {
  212. /**
  213. * 获取选项列表
  214. */
  215. getList() {
  216. this.params.page++
  217. this.listStatus = 'loading'
  218. if (this.crmType === 'pool') {
  219. this.params.poolId = this.poolId
  220. }
  221. this.apiObj.func({
  222. ...this.params,
  223. type: this.apiObj.type
  224. }).then(res => {
  225. this.showEmpty = true
  226. if (this.params.page === 1) {
  227. this.listData = []
  228. }
  229. console.log(res.list)
  230. this.listData = this.listData.concat(res.list)
  231. this.listStatus = res.lastPage ? 'noMore' : 'more'
  232. }).catch(() => {
  233. this.listStatus = 'more'
  234. })
  235. },
  236. handleClear() {
  237. this.keyword = ''
  238. }
  239. }
  240. }
  241. </script>
  242. <style scoped lang="scss">
  243. .main-container {
  244. .search-box {
  245. background-color: white;
  246. padding: 10rpx 30rpx;
  247. @include left;
  248. .wk-search {
  249. font-size: 38rpx;
  250. color: $light;
  251. }
  252. .input-core {
  253. flex: 1;
  254. height: 76rpx;
  255. font-size: 28rpx;
  256. padding: 0 20rpx;
  257. display: block;
  258. }
  259. .delete-icon {
  260. width: 32rpx;
  261. height: 32rpx;
  262. }
  263. }
  264. .list-view {
  265. flex: 1;
  266. overflow: hidden;
  267. background-color: white;
  268. // padding: 0 34rpx;
  269. margin-top: 15rpx;
  270. .list-scroll {
  271. width: 100%;
  272. height: 100%;
  273. overflow: hidden;
  274. .cell {
  275. border-bottom: 1rpx solid $border-color;
  276. padding: 20rpx 0;
  277. .cell-title {
  278. font-size: 30rpx;
  279. }
  280. .cell-desc {
  281. font-size: 24rpx;
  282. color: $gray;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. </style>