index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-02-15 09:43:14
  6. * @Description: file content
  7. * @FilePath: \oms\pages\customer\index.vue
  8. -->
  9. <template>
  10. <view class="home">
  11. <view class="nav">
  12. <view :style="{ paddingTop }">
  13. <view class="title" :style="[{ height }, { lineHeight: height }]">
  14. <view class="back" @click="goBack()">
  15. <u-icon name="arrow-left" color="#ffffff" size="22"></u-icon>
  16. </view>
  17. <text>储备客户</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="main">
  22. <view class="query-wrap">
  23. <view class="search-container">
  24. <view class="search-input">
  25. <u-input
  26. clearable
  27. placeholderStyle="font-size:26rpx"
  28. :customStyle="{ height: '66rpx' }"
  29. v-model="custName"
  30. prefixIcon="search"
  31. prefixIconStyle="font-size: 22px;color: #909399"
  32. placeholder="请输入客户名称"
  33. shape="circle"
  34. border="surround"></u-input>
  35. </view>
  36. <view class="search-btn" @click="openFilter">筛选</view>
  37. <view class="search-btn" @click="searchList">搜索</view>
  38. </view>
  39. <!-- 筛选 -->
  40. <view class="filter-popup" v-if="filterVisible">
  41. <view class="filter-wrap">
  42. <view class="filter-item">
  43. <view class="tit">客户行业</view>
  44. <view class="menu-list">
  45. <view class="menu-item" v-for="(item, index) in industryOptions" :key="index">
  46. <u-tag
  47. shape="circle"
  48. :text="item.value"
  49. :plain="industryChecked != item.key"
  50. :name="item.key"
  51. @click="radioClick(item, 'industryChecked')"></u-tag>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="filter-item">
  56. <view class="tit">最后跟进时间</view>
  57. <view class="menu-list">
  58. <u-button v-if="!followUpDate" type="primary" text="选择时间" @click="$refs.calendar.open()"></u-button>
  59. <view style="width: 100%" v-else @click="$refs.calendar.open()">
  60. {{ followUpDate }}
  61. </view>
  62. </view>
  63. </view>
  64. <view class="btn-box">
  65. <view class="reset" @click="reset()">重置</view>
  66. <view class="submit" @click="confirmFilter()">确定</view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <u-empty v-if="customerData.length == 0" mode="list" text="暂无数据"></u-empty>
  72. <scroll-view :scroll-y="true" class="data-list" @scrolltolower="lower" v-else>
  73. <view>
  74. <view class="data-item" v-for="(v, i) in customerData" :key="i" @click="toDetails(v)">
  75. <view class="customer-name flex">
  76. <text class="name">{{ v.custName }}</text>
  77. <view class="user-code">
  78. <text>{{ v.custCode }}</text>
  79. </view>
  80. </view>
  81. <view class="customer-info flex">
  82. <view class="info-left flex_1">
  83. <view class="info-row flex_l">
  84. <text class="info-label">所在省市:</text>
  85. <u-text color="#323232" size="24rpx" :text="v.custProvince + '' + v.custCity"></u-text>
  86. </view>
  87. <view class="info-row flex_l">
  88. <text class="info-label">客户类别:</text>
  89. <u-text color="#323232" size="24rpx" :text="v.custIndustry"></u-text>
  90. </view>
  91. <view class="info-row flex_l">
  92. <text class="info-label">最后跟进时间:</text>
  93. <u-text color="#323232" size="24rpx" :text="v.followUpDate || '-'"></u-text>
  94. </view>
  95. <view class="flex_l">
  96. <view class="transfer-btn mr20" @click.stop="linkToTransfer(v.id)">
  97. <u-button type="primary" size="small" text="转移客户"></u-button>
  98. </view>
  99. <view class="transfer-btn mr20" @click.stop="$refs.moveCust.open(v.id)">
  100. <u-button type="primary" size="small" text="移入公海"></u-button>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="info-right flex_l flex-column">
  105. <!-- <image class="user-img" src="@/static/images/user.jpg" mode="scaleToFill" /> -->
  106. <u-text color="#646464" size="20rpx" :text="v.salesName"></u-text>
  107. </view>
  108. </view>
  109. </view>
  110. <u-loadmore :status="loadStatus" />
  111. </view>
  112. </scroll-view>
  113. </view>
  114. <!-- 新增按钮 -->
  115. <view class="fixed-btn center" @click="openAdd()">
  116. <u-icon name="plus" color="#fff" size="20"></u-icon>
  117. </view>
  118. <!-- 选择最后跟进日期 -->
  119. <uni-calendar ref="calendar" :insert="false" @confirm="pickDate" :clearDate="true" />
  120. <!-- 消息提示 -->
  121. <u-toast ref="uToast"></u-toast>
  122. <!-- 移入公海 -->
  123. <move-in-open-sea ref="moveCust" @fetchList="searchList()"></move-in-open-sea>
  124. </view>
  125. </template>
  126. <script>
  127. import customerApi from '../../api/customer'
  128. import to from 'await-to-js'
  129. import MoveInOpenSea from './components/moveInOpenSea'
  130. export default {
  131. name: 'omsIndex',
  132. components: { MoveInOpenSea },
  133. data() {
  134. return {
  135. custStatus: {
  136. 10: '正常',
  137. 20: '异常',
  138. },
  139. height: '',
  140. paddingTop: '',
  141. pageNum: 0,
  142. pageSize: 10,
  143. customerData: [], //客户列表
  144. customerDataTotal: 0, //列表元素数量
  145. loadStatus: '', //加载状态
  146. filterVisible: false, //筛选组件状态
  147. custName: '', //客户名称
  148. followUpDate: '', //最后跟进时间
  149. industryChecked: 0, //选择的行业id
  150. industryOptions: [],
  151. // levelChecked: 0, //选择的级别id
  152. // levelOptions: [],
  153. }
  154. },
  155. created() {
  156. const navData = uni.getMenuButtonBoundingClientRect()
  157. this.height = navData.height + 'px'
  158. this.paddingTop = navData.top + 'px'
  159. },
  160. onShow() {
  161. this.getOptions()
  162. this.searchList()
  163. },
  164. methods: {
  165. getOptions() {
  166. Promise.all([this.getDicts('cust_idy')])
  167. .then(([industry]) => {
  168. // this.levelOptions = level.data.values || []
  169. this.industryOptions = industry.data.values || []
  170. })
  171. .catch((err) => console.log(err))
  172. },
  173. // 筛选下的单选
  174. radioClick(item, target) {
  175. console.log(item.key, target)
  176. this[target] = item.key
  177. },
  178. // 选择日期
  179. async pickDate(e) {
  180. console.log(e)
  181. this.followUpDate = e.fulldate
  182. },
  183. // 重置
  184. reset() {
  185. this.followUpDate = ''
  186. this.industryChecked = 0
  187. // this.levelChecked = 0
  188. },
  189. // 确认
  190. confirmFilter() {
  191. this.filterVisible = false
  192. this.searchList()
  193. },
  194. // 上拉滚动
  195. lower() {
  196. console.log(this.customerData.length)
  197. console.log(this.customerDataTotal)
  198. console.log(this.loadStatus)
  199. if (this.customerData.length < this.customerDataTotal && this.loadStatus != 'loading') {
  200. this.$u.throttle(this.getCustomerData(), 2000, false)
  201. }
  202. },
  203. // 查询列表
  204. searchList() {
  205. this.pageNum = 0
  206. this.getCustomerData(true)
  207. },
  208. async getCustomerData(reset) {
  209. this.loadStatus = 'loading'
  210. this.pageNum++
  211. let params = {
  212. custName: this.custName,
  213. followUpDate: this.followUpDate,
  214. indusTry: this.industryChecked,
  215. isPublic: false,
  216. pageNum: this.pageNum,
  217. pageSize: this.pageSize,
  218. }
  219. const [err, res] = await to(customerApi.getList(params))
  220. if (err) {
  221. this.loadStatus = 'nomore'
  222. return
  223. }
  224. if (res && res.code == 200) {
  225. if (reset) {
  226. this.customerData = res.data.list || []
  227. } else {
  228. this.customerData = [...this.customerData, ...(res.data.list || [])]
  229. }
  230. this.customerDataTotal = res.data.total
  231. this.loadStatus = this.customerData.length == this.customerDataTotal ? 'nomore' : 'loadmore'
  232. console.log(this.loadStatus)
  233. } else {
  234. this.loadStatus = 'nomore'
  235. }
  236. },
  237. openFilter() {
  238. if (this.filterVisible) {
  239. this.reset()
  240. this.filterVisible = false
  241. } else {
  242. this.filterVisible = true
  243. }
  244. },
  245. // 移入公海
  246. moveInOpenSea(item) {
  247. console.log(item)
  248. this.openSeaObj.ids = [item.id]
  249. this.showMoveInModel = true
  250. },
  251. // 跳转到转移客户
  252. linkToTransfer(id) {
  253. uni.navigateTo({
  254. //保留当前页面,跳转到应用内的某个页面
  255. url: '/pages/customer/transfer?id=' + id,
  256. })
  257. },
  258. goBack() {
  259. uni.navigateBack({
  260. //关闭当前页面,返回上一页面或多级页面。
  261. delta: 1,
  262. })
  263. },
  264. openAdd() {
  265. uni.navigateTo({
  266. //保留当前页面,跳转到应用内的某个页面
  267. url: '/pages/customer/add',
  268. })
  269. },
  270. toDetails(v) {
  271. uni.navigateTo({
  272. //保留当前页面,跳转到应用内的某个页面
  273. url: '/pages/customer/details?id=' + v.id + '&type=private',
  274. })
  275. },
  276. },
  277. }
  278. </script>
  279. <style>
  280. page {
  281. background: #f2f3f5;
  282. }
  283. </style>
  284. <style lang="scss" scoped>
  285. .home {
  286. padding-top: 188rpx;
  287. .nav {
  288. position: absolute;
  289. left: 0;
  290. top: 0;
  291. width: 100%;
  292. height: 284rpx;
  293. background: #3e7ef8;
  294. .title {
  295. position: relative;
  296. text-align: center;
  297. font-size: 32rpx;
  298. font-weight: bold;
  299. color: #ffffff;
  300. .back {
  301. position: absolute;
  302. top: 0;
  303. bottom: 0;
  304. margin: auto;
  305. left: 70rpx;
  306. display: flex;
  307. }
  308. }
  309. }
  310. .main {
  311. position: absolute;
  312. width: 100%;
  313. height: calc(100vh - 188rpx);
  314. background: #ffffff;
  315. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  316. border-radius: 31rpx 31rpx 0 0;
  317. padding: 0 32rpx;
  318. overflow: auto;
  319. padding-bottom: 64rpx;
  320. .query-wrap {
  321. padding-top: 20rpx;
  322. .search-container {
  323. display: flex;
  324. align-items: center;
  325. .search-input {
  326. flex: 1;
  327. }
  328. .search-btn {
  329. text-align: center;
  330. line-height: 60rpx;
  331. border-radius: 12rpx;
  332. width: 100rpx;
  333. height: 60rpx;
  334. font-size: 26rpx;
  335. margin: 0 0 0 12rpx;
  336. background: $u-primary;
  337. color: #ffffff;
  338. }
  339. }
  340. }
  341. .data-list {
  342. width: 100%;
  343. height: calc(100vh - 372rpx);
  344. overflow: auto;
  345. .data-item {
  346. background: rgba(242, 243, 245, 0.5);
  347. border-radius: 15rpx;
  348. padding: 28rpx 40rpx 28rpx 38rpx;
  349. margin-top: 32rpx;
  350. .customer-name {
  351. .name {
  352. flex: 1;
  353. color: #323232;
  354. font-weight: bold;
  355. font-size: 28rpx;
  356. margin-right: 12rpx;
  357. }
  358. .user-code {
  359. width: 180rpx;
  360. height: 32rpx;
  361. font-size: 24rpx;
  362. color: #323232;
  363. line-height: 32rpx;
  364. }
  365. }
  366. .customer-info {
  367. .info-left {
  368. .transfer-btn {
  369. margin-top: 20rpx;
  370. width: 150rpx;
  371. }
  372. .info-row {
  373. margin-top: 12rpx;
  374. .info-label {
  375. color: #646464;
  376. font-size: 24rpx;
  377. }
  378. }
  379. }
  380. .info-right {
  381. padding-top: 30rpx;
  382. .user-img {
  383. border-radius: 50%;
  384. width: 46rpx;
  385. height: 46rpx;
  386. }
  387. }
  388. }
  389. }
  390. }
  391. }
  392. .filter-popup {
  393. background: rgba(0, 0, 0, 0.8);
  394. position: fixed;
  395. width: 100%;
  396. height: 100%;
  397. left: 0;
  398. z-index: 1;
  399. .filter-wrap {
  400. width: 100%;
  401. padding: 20rpx;
  402. background: #ffffff;
  403. .filter-item {
  404. padding-bottom: 30rpx;
  405. .tit {
  406. font-size: 26rpx;
  407. color: #323232;
  408. font-weight: bold;
  409. padding-bottom: 20rpx;
  410. }
  411. .menu-list {
  412. display: flex;
  413. flex-wrap: wrap;
  414. .menu-item {
  415. margin-right: 40rpx;
  416. margin-bottom: 20rpx;
  417. }
  418. }
  419. }
  420. }
  421. .btn-box {
  422. width: 698rpx;
  423. height: 75px;
  424. display: flex;
  425. align-items: center;
  426. justify-content: space-between;
  427. > view {
  428. width: 320rpx;
  429. height: 40px;
  430. border-radius: 40px;
  431. border: solid 1rpx #ec652b;
  432. align-items: center;
  433. justify-content: center;
  434. text-align: center;
  435. line-height: 40px;
  436. }
  437. .reset {
  438. color: #ec652b;
  439. }
  440. .submit {
  441. color: #fff;
  442. background-color: #ec652b;
  443. }
  444. }
  445. }
  446. }
  447. </style>