You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

366 lines
8.1 KiB

  1. <template>
  2. <view class="box">
  3. <!-- 顾问选择 -->
  4. <view class="nextcon">
  5. 下一位接待顾问:{{textcdhSKJ}}
  6. </view>
  7. <!-- 搜索筛选顾问 -->
  8. <view class="search-tag">
  9. <u-search v-model="keywords" @search="searchFunc" bgColor="#F8F8F8" shape="round" placeholder="顾问名称"
  10. :showAction="false" :clearabled="true"></u-search>
  11. <view class="tabs-box" v-if="list.length > 0">
  12. <u-tabs :list="list" :current="listCurrent" name="deptName" @change="change"></u-tabs>
  13. </view>
  14. </view>
  15. <view class="content">
  16. <radio-group @change="radioChange">
  17. <view v-for="(item,index) in freeList" :key="index" class="content-tips">
  18. <view class="left">
  19. <view class="img">
  20. {{item.name.slice(0,1)}}
  21. </view>
  22. <view class="text">
  23. <view class="name">
  24. {{item.name}}
  25. </view>
  26. <view class="num">
  27. 今日接待: {{item.todayNum}}
  28. </view>
  29. </view>
  30. </view>
  31. <view class="right">
  32. <radio :value="item.agentId" :checked="index == current" style="transform:scale(0.9)"
  33. color="#2671E2"></radio>
  34. </view>
  35. </view>
  36. </radio-group>
  37. <view class="empty" v-if="freeList.length == 0">
  38. <image class="image" src="@/static/images/customerEmpty.png" mode=""></image>
  39. <view class="tips">
  40. 暂无空闲顾问
  41. </view>
  42. </view>
  43. </view>
  44. <view v-if="freeList.length > 0" class="save" @click="save" :class="{active:chosedAgentId}">
  45. 保存
  46. </view>
  47. <u-modal v-model="show" :mask-close-able="true" :title="'代接待提醒'" :confirm-text="confirmtext"
  48. :cancel-text='canceltext' @cancel="confirmA" @confirm="confirmB" :show-cancel-button='true'
  49. :content="content"></u-modal>
  50. <!-- 加载组件 -->
  51. <loading v-model="LOADING"></loading>
  52. </view>
  53. </template>
  54. <script>
  55. import loading from "@/components/loading/index.vue"
  56. export default {
  57. components: {
  58. loading
  59. },
  60. data() {
  61. return {
  62. customerId: '',
  63. buildingID: '',
  64. freeList: [],
  65. current: null,
  66. chosedAgentId: '',
  67. textcdhSKJ: '',
  68. show: false,
  69. content: '',
  70. confirmtext: '1', //确认文字
  71. canceltext: '2', //取消文字
  72. daitiReceptionobj: {},
  73. replaceReception: 0,
  74. keywords: '', // 关键词
  75. list: [], // 部门列表
  76. listCurrent: 0, //选中分类下标
  77. from: '', // 来源页面需要通知的事件
  78. }
  79. },
  80. onLoad(option) {
  81. this.LOADING = true
  82. if (option.id) this.customerId = option.id;
  83. if (option.from) this.from = option.from
  84. },
  85. async onShow() {
  86. this.buildingID = uni.getStorageSync('buildingID').id;
  87. await this.iniPage()
  88. },
  89. methods: {
  90. change(e) {
  91. console.log(e)
  92. this.keywords = ''
  93. this.listCurrent = Number(e)
  94. this.getFreeList();
  95. },
  96. //
  97. searchFunc() {
  98. this.getFreeList();
  99. },
  100. async iniPage() {
  101. await this.getAllDeptName()
  102. await this.getFreeList();
  103. },
  104. // 获取顾问列表
  105. async getAllDeptName() {
  106. try {
  107. let res = await this.$u.get(`/zkAgentPool/getAllDeptName?itemId=${this.buildingID}`)
  108. console.log(res)
  109. if (res&&res.length>0) {
  110. res.unshift({
  111. id: '',
  112. deptName: '全部'
  113. })
  114. this.list = res
  115. }
  116. } catch(e) {
  117. console.log(e)
  118. }
  119. },
  120. // 获取空闲顾问
  121. async getFreeList() {
  122. try {
  123. let deptId = this.list.length > 0 ? this.list[this.listCurrent].id : ''
  124. // deptId 部门id
  125. // name 顾问名称
  126. let res = await this.$u.get(`/zkAgentPool/freeList?itemId=${this.buildingID}&name=${this.keywords||''}&deptId=${deptId}`)
  127. if (res.length == 0) {
  128. this.freeList = []
  129. } else {
  130. // 回显上次选中的顾问
  131. if (this.from != '' && this.id != '') {
  132. this.current = res.findIndex(item => item.agentId == this.customerId)
  133. }
  134. this.freeList = res;
  135. this.textcdhSKJ = res[0].name
  136. }
  137. this.LOADING = false
  138. } catch (e) {
  139. this.LOADING = false
  140. }
  141. },
  142. //取消
  143. confirmA() {
  144. if (this.daitiReceptionobj.assign != null) {
  145. this.baochunfun()
  146. } else {
  147. uni.showToast({
  148. icon: "none",
  149. title: "【" + this.daitiReceptionobj.owner.name + "】正在接待中"
  150. })
  151. return;
  152. }
  153. },
  154. // 确认
  155. confirmB() {
  156. this.replaceReception = 1;
  157. this.baochunfun()
  158. },
  159. save() {
  160. console.log(this.chosedAgentId)
  161. if (!this.chosedAgentId) {
  162. uni.showToast({
  163. icon: "none",
  164. title: "未选择指派顾问"
  165. })
  166. return
  167. }
  168. // 如果是从其他页面跳转过来的
  169. if (this.from) {
  170. uni.$emit(this.from, this.chosedAgentId)
  171. uni.navigateBack()
  172. return
  173. }
  174. const that = this;
  175. this.$u.post("customer/daitiReception", {
  176. agentId: that.chosedAgentId,
  177. id: that.customerId
  178. }).then(res => {
  179. if (res.unchecked == 0) {
  180. that.baochunfun()
  181. } else {
  182. if (res.zs == 0) {
  183. that.baochunfun()
  184. } else {
  185. if (res.assign == null && res.replacement == null) {
  186. that.baochunfun()
  187. } else {
  188. if (res.assign == null) {
  189. that.daitiReceptionobj = res;
  190. that.content = "此客户的顾问为【" + res.owner.name + "】,确认让【" + res.replacement.name +
  191. "】代接待吗?"
  192. that.confirmtext = res.replacement.name + "代接待", //确认文字
  193. that.canceltext = res.owner.name + '接待', //取消文字
  194. that.show = true;
  195. } else {
  196. that.daitiReceptionobj = res;
  197. that.content = "此客户的顾问为【" + res.owner.name + "】,确认让【" + res.replacement.name +
  198. "】代接待吗?"
  199. that.confirmtext = res.replacement.name + "代接待", //确认文字
  200. that.canceltext = res.assign.name + '接待', //取消文字
  201. that.show = true;
  202. }
  203. }
  204. }
  205. }
  206. });
  207. },
  208. baochunfun() {
  209. uni.showLoading({
  210. title: "保存中",
  211. mask: true
  212. })
  213. const that = this;
  214. this.$u.post("customer/assign", {
  215. agentId: that.chosedAgentId,
  216. id: that.customerId,
  217. replaceReception: this.replaceReception
  218. }).then(res => {
  219. uni.showToast({
  220. icon: "none",
  221. title: "分配成功"
  222. })
  223. uni.navigateBack();
  224. uni.hideLoading();
  225. });
  226. },
  227. radioChange(evt) {
  228. this.chosedAgentId = '';
  229. this.chosedAgentId = evt.detail.value;
  230. },
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .box {
  236. background: #F8F8F8;
  237. width: 100%;
  238. min-height: calc(100vh - var(--window-top));
  239. display: flex;
  240. flex-direction: column;
  241. font-size: 30rpx;
  242. font-weight: 400;
  243. .nextcon {
  244. flex-shrink: 0;
  245. height: 78rpx;
  246. background: #F4F8FD;
  247. color: #2671E2;
  248. text-align: center;
  249. line-height: 78rpx;
  250. }
  251. .search-tag {
  252. margin: 0 0 20rpx 0;
  253. padding: 30rpx 30rpx 0;
  254. background: #fff;
  255. .tabs-box {
  256. background: #fff;
  257. }
  258. }
  259. .content {
  260. flex-grow: 1;
  261. display: flex;
  262. flex-direction: column;
  263. .content-tips {
  264. display: flex;
  265. justify-content: space-between;
  266. background: #fff;
  267. padding: 0 30rpx;
  268. height: 148rpx;
  269. margin-bottom: 20rpx;
  270. .left {
  271. display: flex;
  272. margin-top: 30rpx;
  273. .img {
  274. width: 72rpx;
  275. height: 72rpx;
  276. background: #FFFFFF;
  277. border: 1px solid #C9C9C9;
  278. line-height: 64rpx;
  279. text-align: center;
  280. border-radius: 50%;
  281. margin-right: 20rpx;
  282. }
  283. .text {
  284. .name {
  285. margin-top: 4rpx;
  286. font-weight: 600;
  287. color: #333333;
  288. line-height: 30rpx;
  289. margin-bottom: 24rpx;
  290. }
  291. }
  292. }
  293. .right {
  294. margin: 54rpx 0;
  295. }
  296. }
  297. .empty {
  298. flex: 1;
  299. display: flex;
  300. flex-direction: column;
  301. justify-content: center;
  302. align-items: center;
  303. .image {
  304. width: 300rpx;
  305. height: 300rpx;
  306. }
  307. .tips {
  308. font-size: 36rpx;
  309. color: #242424;
  310. line-height: 1;
  311. margin-top: 50rpx;
  312. }
  313. }
  314. }
  315. .save {
  316. position: sticky;
  317. bottom: 50rpx;
  318. z-index: 10;
  319. flex-shrink: 0;
  320. margin: 50rpx auto;
  321. width: calc(100vw - 60rpx);
  322. color: #FFFFFF;
  323. font-size: 30rpx;
  324. height: 98rpx;
  325. border-radius: 8rpx;
  326. display: flex;
  327. justify-content: center;
  328. align-items: center;
  329. background: rgba(42, 111, 255, 1);
  330. }
  331. }
  332. </style>