index.vue 16 KB

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