index.vue 17 KB

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