Transfer.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!--
  2. * @Author: liuzl 461480418@qq.com
  3. * @Date: 2023-01-07 15:44:08
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-01-07 16:11:45
  6. * @Description: file content
  7. * @FilePath: \订单全流程管理系统\src\views\contract\components\Transfer.vue
  8. -->
  9. <template>
  10. <el-dialog append-to-body title="选择转移销售工程师" :visible.sync="innerVisible" width="40%" @close="handleClose">
  11. <el-form ref="userForm" :model="userForm" :rules="userRules">
  12. <el-row :gutter="20">
  13. <el-col :span="24">
  14. <el-form-item label="销售工程师" prop="inchargeName">
  15. <el-select
  16. v-model="userForm.inchargeName"
  17. placeholder="请选择销售工程师"
  18. readonly
  19. style="width: 100%"
  20. @focus="openUser(false, 'inchargeId', 'inchargeName')" />
  21. </el-form-item>
  22. </el-col>
  23. </el-row>
  24. </el-form>
  25. <span slot="footer">
  26. <el-button size="mini" type="primary" @click="save">确认</el-button>
  27. <el-button size="mini" @click="handleClose">取消</el-button>
  28. </span>
  29. <!-- 选择用户 -->
  30. <select-user ref="user" :label="label" :multiple="multiple" :property="property" @save="getUser" />
  31. </el-dialog>
  32. </template>
  33. <script>
  34. import to from 'await-to-js'
  35. import contractApi from '@/api/contract'
  36. import SelectUser from '@/components/select/SelectUser'
  37. export default {
  38. components: {
  39. SelectUser,
  40. },
  41. props: {
  42. contractId: {
  43. type: Number,
  44. default: 0,
  45. },
  46. usersList: {
  47. type: Array,
  48. default: () => [],
  49. },
  50. },
  51. data() {
  52. return {
  53. userForm: {
  54. inchargeId: 0,
  55. inchargeName: '',
  56. },
  57. innerVisible: false,
  58. userRules: {
  59. inchargeId: [{ required: true, trigger: 'change', message: '请选择销售工程师' }],
  60. },
  61. multiple: false,
  62. property: '',
  63. label: '',
  64. }
  65. },
  66. mounted() {},
  67. methods: {
  68. // 打开选择公司签约人
  69. openUser(multiple, property, label) {
  70. this.multiple = multiple
  71. this.property = property
  72. this.label = label
  73. if (this.userForm[property].length) {
  74. this.$refs.user.ids = this.userForm[property]
  75. } else if (this.userForm[property]) {
  76. this.$refs.user.ids = [this.userForm[property]]
  77. } else {
  78. this.$refs.user.ids = []
  79. }
  80. this.$refs.user.open()
  81. },
  82. // 获取签约人信息
  83. getUser(userList, property, label) {
  84. this.userForm[label] = userList.map((item) => item.nickName).join()
  85. if (this.multiple) {
  86. this.userForm[property] = userList.map((item) => item.id)
  87. } else {
  88. this.userForm[property] = userList[0] ? userList[0].id : ''
  89. }
  90. this.$forceUpdate()
  91. },
  92. open() {
  93. this.innerVisible = true
  94. },
  95. async save() {
  96. let params = { ...this.userForm, id: this.contractId }
  97. const [valid] = await to(this.$refs.userForm.validate())
  98. if (valid == false) return
  99. const [err, res] = await to(contractApi.transferContract(params))
  100. if (err) return
  101. if (res.code == 200) this.$message.success(res.msg)
  102. else return
  103. this.handleClose()
  104. },
  105. handleClose() {
  106. this.innerVisible = false
  107. this.$emit('transferSave')
  108. this.userForm = {
  109. inchargeId: 0,
  110. inchargeName: '',
  111. }
  112. this.$refs.userForm.resetFields()
  113. },
  114. },
  115. }
  116. </script>
  117. <style lang="scss" scoped></style>