index.vue 17 KB

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