bind-edit.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <el-form ref="form" :model="form" label-width="150px" style="width:500px;">
  5. <el-form-item label="Member Code">
  6. 是否主会员
  7. </el-form-item>
  8. <el-form-item v-for="(item,index) in userBinds" :key="index" :label="item.USER_NAME">
  9. <el-switch v-model="item.USER_ID==mainUid" active-color="#13ce66" @change="changeMainUid(item.USER_ID)">
  10. </el-switch>
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">保存</el-button>
  14. </el-form-item>
  15. </el-form>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import network from '@/utils/network'
  21. export default {
  22. name: 'user_bind-edit',
  23. mounted() {
  24. this.getData()
  25. },
  26. data() {
  27. return {
  28. form: {
  29. id: null,
  30. type: 1,
  31. userName: null,
  32. mainUserName: null,
  33. mainUid:null,
  34. },
  35. mainUid:null,
  36. userBinds:[],
  37. loading: true,
  38. submitButtonStat: false,
  39. }
  40. },
  41. methods: {
  42. getData() {
  43. this.form.id = this.$route.params.id
  44. network.getData(`user/bind-edit/${this.$route.params.id}`).then(response => {
  45. this.loading = false
  46. this.userBinds = response.userBinds
  47. this.form.mainUid = response.mainUid
  48. this.mainUid = response.mainUid
  49. }).catch(() => {
  50. })
  51. },
  52. changeMainUid(uid){
  53. this.mainUid=uid
  54. this.form.mainUid = uid
  55. },
  56. onSubmit() {
  57. this.submitButtonStat = true
  58. let path = `user/bind-edit/${this.$route.params.id}`
  59. network.postData(path, this.form).then(response => {
  60. this.$message({
  61. message: response,
  62. type: 'success'
  63. })
  64. this.submitButtonStat = false
  65. this.$router.go(-1)
  66. }).catch(response => {
  67. this.submitButtonStat = false
  68. })
  69. }
  70. }
  71. }
  72. </script>
  73. <style scoped>
  74. </style>