index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <div class="modal-wrapper-bg">
  3. <div class="mobile-customer-btob" style="background: #f1f3f6" id="mobile-customer-btob">
  4. <div class="switch-head" style="border:0">
  5. <div class="com-switch-head clearfix" style="line-height: 0.78rem">
  6. <div style="width: 50%" class="pull-left">
  7. <span style="margin: 0" class="com-switch-item inline-block active" >客户资料</span>
  8. </div>
  9. <div style="width:50%" class="pull-left">
  10. <router-link to="/mobile/center/vendor/customer/vendorPerformanceAssess" tag="span" style="margin: 0" class="com-switch-item inline-block">绩效考核</router-link>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="search-content mi-search-content">
  15. <input type="text" v-model="filterParams.keyword" @keyup.13="onFilter" placeholder="请输入企业名称搜索">
  16. <span @click="onFilter"><i class="iconfont icon-sousuo"></i></span>
  17. </div>
  18. <div class="customer-btob-wrapper">
  19. <div v-if="resourceList.content && resourceList.content.length > 0">
  20. <div class="customer-btob-wrapper-list" v-for="(item, index) in resourceList.content">
  21. <div class="customer-btob-wrapper-content">
  22. <!--<div class="list-item"><span>UU:</span>{{item.myEnterprise.uu}}</div>-->
  23. <div class="list-item"><span>客户名称:</span><a>{{item.myEnterprise.enName}}</a></div>
  24. <div class="address clearfix"><span class="fl">地址:</span><div class="fl" style="width:5.6rem">{{item.myEnterprise.enAddress}}</div></div>
  25. <div class="list-item"><span>客户联系人:</span>{{item.myUser.userName}}</div>
  26. <div class="list-item"><span>客户电话:</span>{{item.myUser.userTel}}</div>
  27. <div class="list-item"><span>业务对接人:</span>
  28. <span v-for="(names, key) in item.myContacts">{{names.userName}}{{item.myContacts.length - 1 > key ? ',' : ''}}</span>
  29. </div>
  30. </div>
  31. <div class="customer-btob-wrapper-bottom clearfix">
  32. <div @click="addUserInfo(item)"><i class="iconfont icon-allocation"></i>分配</div>
  33. <div @click="transferUserInfo(item)"><i class="iconfont icon-zhuanyi"></i>转移</div>
  34. </div>
  35. </div>
  36. </div>
  37. <empty-status
  38. v-else
  39. :text="'暂无对应的单据'"
  40. :showLink="false"
  41. ></empty-status>
  42. </div>
  43. </div>
  44. <div class="mobile-modal" v-if="modalObj.showModal" @click="closeModal()">
  45. <div class="mobile-modal-box mobile-modal-wrapper" @click="stopPropagation($event)">
  46. <div class="mobile-modal-header">{{modalObj.type === 'add' ? '客户分配' : '权限转移'}}<i @click="closeModal()" class="icon-guanbi iconfont"></i></div>
  47. <div ref="mobileModalBox" class="mobile-scroll-wrap">
  48. <div>
  49. <div class="customer-modal-wrapper">
  50. <div class="search-content mi-search-content">
  51. <input type="text" v-model="modalObj.keyword" @input="modalObjonFilter" placeholder="输入用户UU">
  52. <span @click="modalObjonFilter"><i class="iconfont icon-sousuo"></i></span>
  53. </div>
  54. <div class="customer-modal-content">
  55. <div class="customer-modal-content-title">
  56. <span class="item inline-block" style="width: 28%;" @click="chooseAll()" v-if="modalObj.type === 'add'">
  57. <label class="mobile-cart-check" :class="{'active': !Allcheck}"></label>
  58. 全选
  59. </span>
  60. <span class="item inline-block" style="width: 28%;height:2px" v-else>
  61. </span>
  62. <span class="item inline-block" style="width: 32%;">用户UU</span>
  63. <span class="item inline-block" style="width: 40%;text-align: center">用户名称</span>
  64. </div>
  65. <div class="customer-modal-content-list" v-for="item in modalObj.showModalList" v-if="item.userUU !== thisUser.userUU">
  66. <span class="item inline-block" style="width: 28%;" @click="checkItem(item)">
  67. <label class="mobile-cart-check" :class="{'active': item.distribute}" v-if="modalObj.type === 'add'"></label>
  68. <label class="mobile-cart-check" :class="{'active': item.transfer}" v-else></label>
  69. <!--<label class="mobile-cart-check" :class="{'active': item.distribute}"></label>-->
  70. </span>
  71. <span class="item inline-block" style="width: 32%;">{{item.userUU}}</span>
  72. <span class="item inline-block" style="width: 40%;text-align: center;">{{item.userName}}</span>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="customer-modal-bottom clearfix">
  78. <div class="fl" @click="answerModal()">确定</div>
  79. <div class="fr" @click="closeModal()">取消</div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  85. <pull-up :fixId="'mobile-customer-btob'" :allPage="allPage" :page="filterParams.page" @pullUpAction="onPullUpAction"></pull-up>
  86. </div>
  87. </template>
  88. <script>
  89. import { ModalWrapper } from '~components/mobile/base'
  90. import { PullUp, EmptyStatus, RemindBox } from '~components/mobile/common'
  91. export default {
  92. name: 'customer-index',
  93. layout: 'mobile',
  94. middleware: 'authenticated',
  95. data() {
  96. return {
  97. filterParams: {
  98. keyword: '',
  99. count: 10,
  100. page: 1
  101. },
  102. collectResult: '',
  103. timeoutCount: 0,
  104. resourceList: {
  105. content: []
  106. },
  107. enabled: '',
  108. modalObj: {
  109. customer: {},
  110. showModal: false,
  111. showModalList: [], // 筛选完的数据
  112. type: 'add', // chance
  113. originList: [] // 原数据
  114. },
  115. transfer: false,
  116. thisUser: {}
  117. }
  118. },
  119. created() {
  120. this.$http.get('/account/role/currentRole').then(res => {
  121. this.thisUser = this.$store.state.option.user.data
  122. this.enabled = res.data.count > 0 || this.thisUser.sys
  123. })
  124. this.setSelect()
  125. },
  126. methods: {
  127. async answerModal() {
  128. if (this.modalObj.type !== 'add') {
  129. if (this.modalObj.customer.myEnterprise.uu) {
  130. // 当前用户是管理员时
  131. if (this.thisUser.sys) {
  132. this.$http.post(`/account/user/transferUserToVendor/${this.modalObj.customer.myEnterprise.uu}`, this.modalObj.originList).then(data => {
  133. this.onMind('转移成功!')
  134. this.closeModal()
  135. }, err => {
  136. this.onMind(err.data)
  137. this.closeModal()
  138. })
  139. // } else {
  140. // this.onMind('您未勾选任何记录!')
  141. // this.closeModal()
  142. // }
  143. } else {
  144. // 非管理员转移自己的权限时
  145. this.modalObj.originList.forEach(item => {
  146. if (item.transfer && item.userUU !== this.thisUser.userUU) {
  147. this.target = item
  148. }
  149. })
  150. if (!this.target) {
  151. this.onMind('您未选择权限转移对象!')
  152. this.closeModal()
  153. } else {
  154. this.$http.post(`/account/user/transferMyDistribute`, {
  155. custUU: this.modalObj.customer.myEnterprise.uu,
  156. userUU: this.target.userUU
  157. }).then(data => {
  158. this.onMind('转移成功!')
  159. this.closeModal()
  160. }, err => {
  161. this.onMind(err.data)
  162. this.closeModal()
  163. })
  164. }
  165. }
  166. } else {
  167. this.closeModal()
  168. }
  169. } else {
  170. this.$http.post(`/account/user/bindUserToVendor/${this.modalObj.customer.myEnterprise.uu}`, this.modalObj.originList).then(res => {
  171. this.onMind('分配成功!')
  172. this.closeModal()
  173. }).catch(err => {
  174. this.onMind('保存失败!')
  175. this.closeModal()
  176. })
  177. }
  178. },
  179. chooseAll() {
  180. let _str = 'distribute'
  181. if (this.modalObj.type !== 'add') {
  182. _str = 'transfer'
  183. }
  184. if (!this.Allcheck) {
  185. this.modalObj.showModalList.forEach(item => {
  186. item[_str] = false
  187. })
  188. return
  189. }
  190. this.modalObj.showModalList.forEach(item => {
  191. item[_str] = true
  192. })
  193. },
  194. checkItem(item) {
  195. if (this.modalObj.type !== 'add') {
  196. if (this.$store.state.option.user.data.sys) { // 管理员操作
  197. item.transfer = !item.transfer
  198. this.modalObj.originList.forEach(userInfo => {
  199. if (this.$store.state.option.user.data.userUU === item.userUU && item.transfer) {
  200. this.transfer = true
  201. }
  202. if (item.userUU !== userInfo.userUU) {
  203. userInfo.transfer = false
  204. }
  205. })
  206. } else if (this.transfer) { // 被管理员转移权限的非管理员操作
  207. item.transfer = !item.transfer
  208. this.modalObj.originList.forEach(userInfo => {
  209. if (item.userUU !== userInfo.userUU) {
  210. userInfo.transfer = false
  211. } else {
  212. userInfo.transfer = true
  213. }
  214. })
  215. } else { // 被分配客户的用户
  216. item.transfer = !item.transfer
  217. this.modalObj.originList.forEach(userInfo => {
  218. if (item.userUU !== userInfo.userUU) {
  219. userInfo.transfer = false
  220. } else {
  221. userInfo.transfer = true
  222. }
  223. })
  224. }
  225. } else {
  226. item.distribute = !item.distribute
  227. }
  228. },
  229. closeModal() {
  230. this.modalObj.showModal = false
  231. this.initScroll.destroy()
  232. this.initScroll = null
  233. },
  234. init () {
  235. this.$nextTick(() => {
  236. this._initscroll()
  237. })
  238. },
  239. modalObjonFilter() {
  240. let _arr = []
  241. this.modalObj.originList.forEach(item => {
  242. if (item.userUU.toString().indexOf(this.modalObj.keyword) > -1) {
  243. _arr.push(item)
  244. }
  245. })
  246. this.modalObj.showModalList = _arr
  247. },
  248. // 分配
  249. async addUserInfo(customer) {
  250. this.modalObj.type = 'add'
  251. this.modalObj.customer = customer
  252. this.$http.get(`/account/user/getEnTransfer/${customer.myEnterprise.uu}`).then(res => {
  253. customer.enTransfer = res.data.result
  254. if (this.enabled || customer.enTransfer) {
  255. this.$http.post(`/account/user/customer/${customer.myEnterprise.uu}`).then(data => {
  256. customer.userinfos = data.data
  257. this.modalObj.showModal = true
  258. this.modalObj.showModalList = customer.userinfos
  259. this.modalObj.originList = customer.userinfos
  260. this.init()
  261. })
  262. } else {
  263. this.onMind('您没有为当前客户分配用户的权限!')
  264. }
  265. })
  266. },
  267. // 转移
  268. transferUserInfo(customer) {
  269. this.modalObj.type = 'chance'
  270. this.modalObj.customer = customer
  271. this.$http.get(`/account/user/getDistribute/${customer.myEnterprise.uu}`).then(res => {
  272. customer.enTransfer = res.data.result
  273. if (this.enabled || customer.enTransfer) {
  274. this.$http.get('/authentication').then(res => {
  275. this.thisUser = res.data
  276. })
  277. this.$http.post(`/account/user/customer/${customer.myEnterprise.uu}`).then(data => {
  278. customer.userinfos = data.data
  279. customer.userinfos.forEach(user => {
  280. if (this.$store.state.option.user.data.userUU === user.userUU && user.transfer) {
  281. this.transfer = true
  282. }
  283. })
  284. this.modalObj.showModal = true
  285. this.modalObj.showModalList = customer.userinfos
  286. this.modalObj.originList = customer.userinfos
  287. this.init()
  288. })
  289. } else {
  290. this.onMind('您没有为当前客户分配用户的权限!')
  291. }
  292. })
  293. },
  294. onFilter() {
  295. this.setSelect(true)
  296. },
  297. onMind(str) {
  298. this.collectResult = str
  299. this.timeoutCount++
  300. },
  301. onPullUpAction() {
  302. this.filterParams.page++
  303. this.setSelect()
  304. },
  305. async setSelect(reset) {
  306. let { data } = await this.$http.get('/vendor/customer/info/search', {
  307. params: {
  308. count: this.filterParams.count,
  309. page: this.filterParams.page,
  310. keyword: this.filterParams.keyword
  311. }})
  312. if (!this.resourceList.content) {
  313. this.resourceList.content = []
  314. }
  315. if (reset) {
  316. this.resourceList.content = []
  317. this.resourceList = data
  318. } else {
  319. this.resourceList.content.push(...data.content)
  320. data.content = this.resourceList.content
  321. }
  322. this.resourceList = data
  323. data = null
  324. }
  325. },
  326. computed: {
  327. allPage() {
  328. return this.resourceList.totalPage
  329. },
  330. Allcheck() {
  331. let _str = 'distribute'
  332. if (this.modalObj.type !== 'add') {
  333. _str = 'transfer'
  334. }
  335. return this.modalObj.showModalList.some(item => {
  336. return item[_str] === false
  337. })
  338. }
  339. },
  340. components: {
  341. ModalWrapper,
  342. PullUp,
  343. EmptyStatus,
  344. RemindBox
  345. }
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. @import '~assets/scss/mobileInvoice';
  350. @mixin overFlowHidden {
  351. overflow: hidden;
  352. text-overflow: ellipsis;
  353. white-space: nowrap;
  354. }
  355. .com-switch-head .com-switch-item.active {
  356. border-bottom: 0.04rem solid #3f84f6;
  357. }
  358. .com-switch-head {
  359. height: .82rem;
  360. line-height: .82rem;
  361. text-align: center;
  362. background: #fff;
  363. }
  364. .com-switch-head .com-switch-item {
  365. font-size: .28rem;
  366. text-align: center;
  367. background: #fff;
  368. }
  369. .mobile-customer-btob{
  370. background: #f1f3f6;
  371. margin: 1.26rem 0 0.98rem 0;
  372. height: calc(100vh - 1.26rem - 0.98rem);
  373. overflow-y: auto;
  374. .search-content {
  375. padding: .24rem 0;
  376. text-align: center;
  377. background: #f1f3f6;
  378. input {
  379. width: 6.48rem;
  380. height: .58rem;
  381. line-height: .58rem;
  382. border-radius: .14rem;
  383. margin: 0 0 0 .11rem;
  384. font-size: .26rem;
  385. padding: 0 .71rem 0 .21rem;
  386. border: 1px solid #3f84f6;
  387. }
  388. }
  389. }
  390. .modal-wrapper-bg {
  391. .mobile-modal .mobile-modal-wrapper {
  392. top: 1.6rem;
  393. bottom: 1.6rem;
  394. left: 5%;
  395. right: 5%;
  396. }
  397. .mobile-scroll-wrap {
  398. overflow: hidden;
  399. height: 80%;
  400. background: #fff;
  401. border-bottom-left-radius: .07rem;
  402. border-bottom-right-radius: .07rem;
  403. }
  404. }
  405. .customer-btob-wrapper {
  406. .customer-btob-wrapper-list {
  407. width: 7.1rem;
  408. margin: 0 auto 0.2rem;
  409. background: #FFFFFF;
  410. border-radius: 0.05rem;
  411. padding: 0.16rem 0.24rem 0;
  412. .customer-btob-wrapper-content {
  413. div {
  414. font-size: 0.28rem;
  415. color: #151515;
  416. line-height: 0.5rem;
  417. &.list-item {
  418. @include overFlowHidden();
  419. }
  420. span {
  421. color: #666666;
  422. }
  423. }
  424. }
  425. .customer-btob-wrapper-bottom{
  426. border-top: 1px solid #D9D9D9;
  427. height: 0.8rem;
  428. line-height: 0.8rem;
  429. margin: 0.16rem -0.24rem 0;
  430. padding:0 0.24rem 0.16rem;
  431. div {
  432. text-align: center;
  433. width: 50%;
  434. float: left;
  435. font-size: 0.26rem;
  436. color: #333333;
  437. &:first-child {
  438. border-right: 1px solid #D9D9D9;
  439. }
  440. i {
  441. font-size: 0.36rem;
  442. vertical-align: middle;
  443. margin-right: 0.05rem
  444. }
  445. }
  446. }
  447. }
  448. }
  449. .customer-modal-wrapper {
  450. padding-bottom: 0.5rem;
  451. input {
  452. border: 1px solid #3f84f6;
  453. }
  454. }
  455. .customer-modal-content {
  456. border-radius: 0.06rem 0.06rem 0 0;
  457. font-size: 0.28rem;
  458. margin: 0.24rem auto 0;
  459. width: 90%;
  460. overflow: hidden;
  461. .customer-modal-content-title {
  462. height: 0.76rem;
  463. line-height: 0.76rem;
  464. background: #89AEFA;
  465. border: 1px solid #89AEFA;
  466. color: #FFFFFF;
  467. padding: 0 0.2rem;
  468. }
  469. .customer-modal-content-list {
  470. padding: 0 0.2rem;
  471. height: 0.76rem;
  472. line-height: 0.76rem;
  473. border: 1px solid #7E7E7E;
  474. background: #FFFFFF;
  475. color: #666666;
  476. border-bottom: 0;
  477. &:nth-last-child(1){
  478. border-bottom: 1px solid #7E7E7E
  479. }
  480. span:nth-last-child(1) {
  481. @include overFlowHidden()
  482. }
  483. }
  484. }
  485. .customer-modal-bottom {
  486. position: absolute;
  487. bottom :0rem;
  488. width: 90%;
  489. left: 0;
  490. right: 0;
  491. margin: 0 auto;
  492. div {
  493. background: #3F84F6;
  494. border-radius: 8px;
  495. width: 48%;
  496. height: 0.74rem;
  497. line-height: 0.74rem;
  498. font-size: 0.28rem;
  499. color: #FFFFFF;
  500. text-align: center;
  501. &:last-child {
  502. background: #fff;
  503. color: #3F84F6;
  504. }
  505. }
  506. }
  507. </style>