collectionCustomer.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view>
  3. <!-- 领取客户 -->
  4. <u-modal
  5. :show="showCollectionModel"
  6. :showCancelButton="true"
  7. @confirm="confirmCollection()"
  8. @cancel="closeMoveInModel()"
  9. title="领取客户">
  10. <view class="slot-content" style="width: 100%">
  11. <view class="flex">
  12. <text>申请说明:</text>
  13. <u-textarea
  14. v-model="openSeaObj.applyRemark"
  15. placeholder="请输入申请说明"
  16. height="180"
  17. :count="true"
  18. maxlength="500"></u-textarea>
  19. </view>
  20. </view>
  21. </u-modal>
  22. <u-notify ref="uNotify"></u-notify>
  23. </view>
  24. </template>
  25. <script>
  26. import { mapGetters } from 'vuex'
  27. import customerApi from '../../../api/customer'
  28. import to from 'await-to-js'
  29. export default {
  30. props: {
  31. position: {
  32. default: () => {},
  33. required: true,
  34. },
  35. },
  36. data() {
  37. return {
  38. flag: true,
  39. showCollectionModel: false,
  40. openSeaObj: {
  41. applyRemark: '',
  42. receive: '1',
  43. ids: [],
  44. },
  45. }
  46. },
  47. computed: {
  48. ...mapGetters(['userId', 'username']),
  49. },
  50. methods: {
  51. open(id) {
  52. this.openSeaObj.ids = [id]
  53. this.showCollectionModel = true
  54. },
  55. // 领用
  56. async confirmCollection() {
  57. // this.openSeaObj.salesId = this.userId
  58. // this.openSeaObj.salesName = this.username
  59. if (!this.flag) return
  60. if (!this.openSeaObj.applyRemark) {
  61. this.$refs.uNotify.show({
  62. top: this.position.height + this.position.paddingTop + 10,
  63. type: 'warning',
  64. message: '请输入领用原因',
  65. duration: 1000 * 3,
  66. })
  67. return
  68. }
  69. let params = {
  70. ...this.openSeaObj,
  71. salesId: this.userId,
  72. salesName: this.username,
  73. }
  74. this.flag = false
  75. const [err, res] = await to(customerApi.collection(params))
  76. this.flag = true
  77. if (err) return this.closeMoveInModel()
  78. if (res.code == 200) {
  79. this.$refs.uToast.show({
  80. type: 'loading',
  81. message: '客户领用成功',
  82. complete: () => {
  83. this.showCollectionModel = false
  84. this.$emit('fetchList')
  85. },
  86. })
  87. } else {
  88. this.closeMoveInModel()
  89. }
  90. },
  91. // 关闭移入公海模块
  92. closeMoveInModel() {
  93. this.openSeaObj.ids = []
  94. this.openSeaObj.applyRemark = ''
  95. this.showCollectionModel = false
  96. },
  97. },
  98. }
  99. </script>
  100. <style></style>