AllocHandle.vue 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :visible.sync="visible"
  5. :append-to-body="true"
  6. :close-on-click-modal="false"
  7. title="批量分配"
  8. width="400px"
  9. @close="handleCancel">
  10. <div class="handle-box">
  11. <flexbox
  12. class="handle-item"
  13. align="stretch">
  14. <div
  15. class="handle-item-name"
  16. style="margin-top: 8px;">请选择:</div>
  17. <xh-user-cell
  18. :value="usersList"
  19. class="handle-item-content"
  20. @value-change="userChage"/>
  21. </flexbox>
  22. </div>
  23. <span
  24. slot="footer"
  25. class="dialog-footer">
  26. <el-button @click.native="handleCancel">取消</el-button>
  27. <el-button
  28. v-debounce="handleConfirm"
  29. type="primary">保存</el-button>
  30. </span>
  31. </el-dialog>
  32. </template>
  33. <script>
  34. import { XhUserCell } from '@/components/CreateCom'
  35. import { crmCustomerDistributeAPI } from '@/api/crm/customer'
  36. export default {
  37. /** 客户管理 的 勾选后的 公海分配 操作*/
  38. name: 'AllocHandle',
  39. components: {
  40. XhUserCell
  41. },
  42. mixins: [],
  43. props: {
  44. dialogVisible: {
  45. type: Boolean,
  46. required: true,
  47. default: false
  48. },
  49. /** 没有值就是全部类型 有值就是当个类型 */
  50. crmType: {
  51. type: String,
  52. default: ''
  53. },
  54. pool_id: [String, Number],
  55. /** 转移数据 */
  56. selectionList: {
  57. type: Array,
  58. default: () => {
  59. return []
  60. }
  61. }
  62. },
  63. data() {
  64. return {
  65. loading: true,
  66. visible: false,
  67. usersList: []
  68. }
  69. },
  70. computed: {},
  71. watch: {
  72. dialogVisible: {
  73. handler(val) {
  74. this.visible = val
  75. if (!val) {
  76. this.usersList = []
  77. }
  78. },
  79. deep: true,
  80. immediate: true
  81. }
  82. },
  83. mounted() {
  84. this.visible = this.dialogVisible
  85. },
  86. methods: {
  87. /**
  88. * 取消选择
  89. */
  90. handleCancel() {
  91. this.visible = false
  92. this.$emit('update:dialogVisible', false)
  93. },
  94. /** 负责人更改 */
  95. userChage(data) {
  96. this.usersList = data.value
  97. },
  98. handleConfirm() {
  99. // 移除操作不可移除客户负责人
  100. if (this.usersList.length === 0) {
  101. this.$message.error('请选择负责人')
  102. } else {
  103. const params = {
  104. user_id: this.usersList[0].id,
  105. pool_id: this.pool_id
  106. }
  107. params.customer_id = this.selectionList.map(item => item[this.crmType + '_id'])
  108. this.loading = true
  109. crmCustomerDistributeAPI(params)
  110. .then(res => {
  111. this.$message({
  112. type: 'success',
  113. message: '操作成功'
  114. })
  115. this.loading = false
  116. this.$emit('handle', {
  117. type: 'alloc'
  118. })
  119. this.handleCancel()
  120. })
  121. .catch(() => {
  122. this.loading = false
  123. })
  124. }
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .handle-box {
  131. color: #333;
  132. font-size: 12px;
  133. }
  134. .handle-item {
  135. padding-bottom: 15px;
  136. .handle-item-name {
  137. flex-shrink: 0;
  138. width: 90px;
  139. }
  140. .handle-item-content {
  141. flex: 1;
  142. }
  143. }
  144. .handle-bar {
  145. position: relative;
  146. margin-top: 10px;
  147. height: 30px;
  148. button {
  149. float: right;
  150. margin-right: 10px;
  151. }
  152. }
  153. </style>