index.vue 13 KB

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