AddUser.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <el-dialog title="新建" :visible.sync="dialogVisible" :before-close="handleClose">
  3. <el-row :gutter="30">
  4. <el-form ref="formInfo" :model="param.content" :rules="rules" label-width="102px" label-position="left">
  5. <el-col :span="12">
  6. <el-form-item label="姓名:" prop="name">
  7. <el-input v-model="param.content.name" placeholder="请输入" size="small"></el-input>
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="12">
  11. <el-form-item label="职位:" prop="position">
  12. <el-input v-model="param.content.position" placeholder="请输入" size="small"></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="12">
  16. <el-form-item label="手机号:" prop="phonenumber">
  17. <el-input v-model="param.content.phonenumber" placeholder="请输入" size="small"></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="24">
  21. <el-form-item label="角色配置:" label-width="102px" prop="roleids">
  22. <el-select v-model="param.content.roleids" multiple placeholder="请选择" size="small">
  23. <el-option
  24. v-for="item in checkList"
  25. :key="item.rolename"
  26. :label="item.rolename"
  27. :value="item.roleid">
  28. </el-option>
  29. </el-select>
  30. </el-form-item>
  31. </el-col>
  32. </el-form>
  33. <el-col :span="24">
  34. <div class="footer" style="margin-left:50%;transform: translateX(-40%);">
  35. <el-button @click="dialogVisible=false" size="small">取消</el-button>
  36. <el-button type="primary" @click="submitTeam()" size="small">提交</el-button>
  37. </div>
  38. </el-col>
  39. </el-row>
  40. </el-dialog>
  41. </template>
  42. <script>
  43. export default {
  44. name: 'AddUser',
  45. data () {
  46. return {
  47. param: {
  48. "classname": "sale.team.team",
  49. "method": "insertormodify_team",
  50. "content": {
  51. "sa_agent_hrid": 0,
  52. "name": "",
  53. "phonenumber": "",
  54. "position": "",
  55. "remarks": "备注",
  56. "roleids":[]
  57. }
  58. },
  59. dialogVisible: false,
  60. rules: {
  61. name: [
  62. { required: true, message: '请输入名称', trigger: 'blur' },
  63. ],
  64. phonenumber: [
  65. { min: 11, max: 11, message: '请输入正确的电话号', trigger: 'blur' }
  66. ],
  67. },
  68. checkList: []
  69. };
  70. },
  71. props:['editTarget'],
  72. components: {
  73. },
  74. computed: {
  75. },
  76. watch: {
  77. editTarget: {
  78. handler(val) {
  79. this.param.content.name = val.name
  80. this.param.content.position = val.position
  81. this.param.content.phonenumber = val.phonenumber
  82. this.param.content.roleids = val.roleids ? val.roleids.map((item) => item) : []
  83. this.param.content.sa_agent_hrid = val.sa_agent_hrid
  84. }
  85. }
  86. },
  87. created() {
  88. this.getRoleList()
  89. },
  90. methods: {
  91. handleClose () {
  92. this.dialogVisible = false
  93. },
  94. getRoleList() {
  95. this.$api.requested({
  96. "accesstoken": "86cf5a6b5314094f4b412da2b0445ac1",
  97. "classname": "sale.team.team",
  98. "method": "queryRole",
  99. "content": {
  100. "sa_agent_hrid": 0
  101. }
  102. }).then( res => {
  103. console.log(res);
  104. this.checkList = res.data
  105. console.log(this.checkList);
  106. })
  107. },
  108. //提交
  109. submitTeam() {
  110. this.$refs.formInfo.validate((val) => {
  111. if(val) {
  112. console.log(this.param);
  113. this.$api.requested(this.param).then( res => {
  114. console.log(res);
  115. if(res.code == 1) {
  116. this.$notify({
  117. title:'提示',
  118. message:'创建成功',
  119. type:'success'
  120. })
  121. this.$refs.formInfo.resetFields()
  122. this.dialogVisible = false
  123. this.$parent.getTeamData()
  124. }
  125. })
  126. }
  127. })
  128. }
  129. },
  130. };
  131. </script>
  132. <style scoped>
  133. * {
  134. box-sizing: border-box;
  135. }
  136. /deep/ .el-dialog__title {
  137. font-size: 16px;
  138. font-weight: bold;
  139. color: #333333;
  140. }
  141. /deep/.el-dialog__body {
  142. padding: 30px 50px 50px 30px;
  143. }
  144. /* .el-form {
  145. display: flex;
  146. flex-wrap: wrap;
  147. justify-content: space-between;
  148. } */
  149. /* .el-form-item {
  150. margin-bottom: 30px;
  151. } */
  152. /deep/.el-dialog {
  153. width: 864px;
  154. background: #ffffff;
  155. }
  156. .el-input {
  157. width: 240px;
  158. }
  159. .footer {
  160. }
  161. .footer .el-button {
  162. width: 120px;
  163. }
  164. .el-select {
  165. width: 100%;
  166. }
  167. </style>