AddUser.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <el-dialog title="新建" :visible.sync="dialogVisible" :before-close="handleClose" v-if="tool.checkAuth($route.name,'read')">
  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,index) in checkList"
  25. :key="index"
  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" v-if="tool.checkAuth($route.name,'update')">提交</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. let checkPhone = (rule,value,callback) => {
  47. if(!this.tool.checkPhoneFun(value)) {
  48. return callback(new Error('请填写正确的手机号'))
  49. } else {
  50. callback()
  51. }
  52. }
  53. return {
  54. param: {
  55. "classname": "sale.team.team",
  56. "method": "insertormodify_team",
  57. "content": {
  58. "sa_agent_hrid": 0,
  59. "name": "",
  60. "phonenumber": "",
  61. "position": "",
  62. "remarks": "备注",
  63. "roleids":[]
  64. }
  65. },
  66. dialogVisible: false,
  67. rules: {
  68. name: [
  69. { required: true, message: '请输入名称', trigger: 'blur' },
  70. ],
  71. phonenumber: [
  72. { required: true, message: '请输入手机号', trigger: 'blur' },
  73. { validator: checkPhone , trigger: 'blur' }
  74. ],
  75. },
  76. checkList: []
  77. };
  78. },
  79. props:['editTarget'],
  80. components: {
  81. },
  82. computed: {
  83. },
  84. watch: {
  85. editTarget: {
  86. handler(val) {
  87. this.param.content.name = val.name
  88. this.param.content.position = val.position
  89. this.param.content.phonenumber = val.phonenumber
  90. this.param.content.roleids = val.roleids ? val.roleids.map((item) => item) : []
  91. this.param.content.sa_agent_hrid = val.sa_agent_hrid
  92. }
  93. }
  94. },
  95. created() {
  96. this.getRoleList()
  97. },
  98. methods: {
  99. handleClose () {
  100. this.dialogVisible = false
  101. },
  102. getRoleList() {
  103. this.$api.requested({
  104. "accesstoken": "86cf5a6b5314094f4b412da2b0445ac1",
  105. "classname": "sale.team.team",
  106. "method": "queryRole",
  107. "content": {
  108. "sa_agent_hrid": 0
  109. }
  110. }).then( res => {
  111. this.checkList = res.data
  112. })
  113. },
  114. //提交
  115. submitTeam() {
  116. this.$refs.formInfo.validate((val) => {
  117. console.log(val);
  118. if(val) {
  119. console.log(this.param);
  120. this.$api.requested(this.param).then( res => {
  121. console.log(res);
  122. if(res.code == 1) {
  123. this.$notify({
  124. title:'提示',
  125. message:'操作成功',
  126. type:'success'
  127. })
  128. this.$refs.formInfo.resetFields()
  129. this.dialogVisible = false
  130. this.$parent.getTeamData()
  131. }
  132. })
  133. }
  134. })
  135. }
  136. },
  137. };
  138. </script>
  139. <style scoped>
  140. * {
  141. box-sizing: border-box;
  142. }
  143. /deep/ .el-dialog__title {
  144. font-size: 16px;
  145. font-weight: bold;
  146. color: #333333;
  147. }
  148. /deep/.el-dialog__body {
  149. padding: 30px 50px 50px 30px;
  150. }
  151. /* .el-form {
  152. display: flex;
  153. flex-wrap: wrap;
  154. justify-content: space-between;
  155. } */
  156. /* .el-form-item {
  157. margin-bottom: 30px;
  158. } */
  159. /deep/.el-dialog {
  160. width: 864px;
  161. background: #ffffff;
  162. }
  163. .el-input {
  164. width: 240px;
  165. }
  166. .footer {
  167. }
  168. .footer .el-button {
  169. width: 120px;
  170. }
  171. .el-select {
  172. width: 100%;
  173. }
  174. </style>