MoveUser.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <script setup>
  2. import { apiCustomerUser } from '@/api/customer'
  3. const show = defineModel('show', { type: Boolean, default: false })
  4. const props = defineProps({
  5. userId: { type: Number, default: 0 },
  6. })
  7. const emits = defineEmits(["success"])
  8. const formRef = ref(null)
  9. const formData = ref({
  10. CompanyId: null,
  11. UserId: null,
  12. })
  13. const formRules = {
  14. CompanyId: [
  15. { required: true, message: '请选择投资者机构', trigger: 'change' },
  16. ],
  17. }
  18. // 获取部门数据
  19. const departArr = ref([])
  20. async function getDepartList() {
  21. const res = await apiCustomerUser.companySearch()
  22. if (res.Ret !== 200) return
  23. const list = res.Data || []
  24. departArr.value = list
  25. }
  26. watch(() => show.value, (newval) => {
  27. if (newval) {
  28. formData.value.UserId = props.userId
  29. formRef.value ? formRef.value.clearValidate() : '';
  30. getDepartList()
  31. }
  32. })
  33. async function handleSubmitForm() {
  34. await formRef.value.validate()
  35. const { CompanyId, UserId } = formData.value
  36. const res=await apiCustomerUser.usersMove({
  37. CompanyId,
  38. UserId,
  39. })
  40. if(res.Ret!==200) return
  41. ElMessage.success('操作成功')
  42. show.value=false
  43. emits("success")
  44. }
  45. </script>
  46. <template>
  47. <el-dialog
  48. v-model="show"
  49. :close-on-click-modal="false"
  50. :modal-append-to-body="false"
  51. width="30%"
  52. title="移动"
  53. >
  54. <div class="dialog-content">
  55. <el-form
  56. label-width="80px"
  57. :rules="formRules"
  58. ref="formRef"
  59. :model="formData"
  60. >
  61. <el-form-item label="移动到" prop="CompanyId">
  62. <el-select
  63. v-model="formData.CompanyId"
  64. placeholder="请选择投资者机构"
  65. size="large"
  66. style="width: 100%"
  67. filterable
  68. no-match-text="暂无该机构,请前往客户列表添加投资者机构!"
  69. >
  70. <el-option
  71. v-for="item in departArr"
  72. :key="item.CompanyId"
  73. :label="item.CompanyName"
  74. :value="item.CompanyId"
  75. />
  76. </el-select>
  77. </el-form-item>
  78. </el-form>
  79. </div>
  80. <template #footer>
  81. <div class="btn-content">
  82. <el-button
  83. type="primary"
  84. style="width: 80px; margin-right: 24px"
  85. @click="handleSubmitForm"
  86. >保存</el-button
  87. >
  88. <el-button style="width: 80px" @click="show = false">取消</el-button>
  89. </div>
  90. </template>
  91. </el-dialog>
  92. </template>
  93. <style scoped lang="scss">
  94. .dialog-content {
  95. padding: 0 50px;
  96. }
  97. .btn-content {
  98. text-align: center;
  99. padding-bottom: 20px;
  100. }
  101. </style>