index.vue 17 KB

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