modify-stockist-level.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="app-container">
  3. <div v-loading="loading" class="white-box">
  4. <el-form ref="form" :model="form" label-width="250px" :label-position="labelPosition">
  5. <el-form-item :label="$t('member.memberCode')">
  6. <el-input v-model.trim="form.userName" @change="handleChange"></el-input>
  7. <el-tag style="margin-top: 15px;" v-show="userInfo.REAL_NAME !== null">{{ $t('member.memberName') }}:{{ userInfo.REAL_NAME }} ({{ userInfo.country }})</el-tag>
  8. <el-tag v-show="userInfo.REAL_NAME !== null" style="margin-top: 5px;">{{ $t('member.currentLevel') }}:{{ allDecRole[userInfo.DEC_ROLE_ID] ? allDecRole[userInfo.DEC_ROLE_ID]['ROLE_NAME'] : '' }}</el-tag>
  9. </el-form-item>
  10. <el-form-item :label="$t('member.stockistLevel')">
  11. <el-select v-model="form.levelId" :placeholder="$t('member.pleaseSelectStockistLevel')">
  12. <el-option v-for="(item,key) in allDecRole" :label="item.ROLE_NAME" :value="item.ID" :key="key"></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item :label="$t('member.remark')">
  16. <el-input type="textarea" :rows="2" placeholder="" v-model="form.remark">
  17. </el-input>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button type="primary" :loading="submitButtonStat" @click="onSubmit">{{ $t('common.confirm') }}</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import waves from '@/directive/waves'
  28. import { getScreenWidth } from '@/utils'
  29. import {fetchMemberFullInfo, updateUserStockistLevel} from "@/api/member";
  30. import baseInfo from "@/utils/baseInfo";
  31. export default {
  32. name: 'modifyStockistLevel',
  33. directives: { waves },
  34. data() {
  35. return {
  36. form: {
  37. userName: null,
  38. levelId: null,
  39. remark: null,
  40. },
  41. loading: false,
  42. submitButtonStat: false,
  43. allDecRole: baseInfo.decRoles(),
  44. periodArr: [],
  45. userInfo: {
  46. REAL_NAME: null,
  47. DEC_ROLE_ID: null,
  48. country: null,
  49. },
  50. screenWidth: getScreenWidth() > 600 ? '500px' : getScreenWidth() + 'px',
  51. labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
  52. }
  53. },
  54. methods: {
  55. handleChange() {
  56. this.loading = true
  57. fetchMemberFullInfo({ userName: this.form.userName }).then(response => {
  58. this.userInfo = response.data
  59. setTimeout(() => {
  60. this.loading = false
  61. }, 0.5 * 1000)
  62. }).catch(error => {
  63. this.userInfo.REAL_NAME = null
  64. this.$message({
  65. message: error,
  66. type: 'warning'
  67. })
  68. this.loading = false
  69. })
  70. },
  71. onSubmit() {
  72. this.$confirm(this.$t('member.modifyEntryLevelHits'), this.$t('common.hint'), {
  73. confirmButtonText: this.$t('common.confirm'),
  74. cancelButtonText: this.$t('common.cancel'),
  75. type: 'warning'
  76. }).then(() => {
  77. this._handleSubmit()
  78. }).catch(error => {
  79. this.$message({
  80. message: error,
  81. type: 'warning'
  82. })
  83. })
  84. },
  85. _handleSubmit() {
  86. updateUserStockistLevel(this.form).then(response => {
  87. this.$message({
  88. message: response.data,
  89. type: 'success'
  90. })
  91. setTimeout(() => {
  92. this.submitButtonStat = false
  93. }, 0.5 * 1000)
  94. this.submitButtonStat = false
  95. }).catch(error => {
  96. this.$message({
  97. message: error,
  98. type: 'warning'
  99. })
  100. this.submitButtonStat = false
  101. })
  102. this._clearData()
  103. },
  104. _clearData(){
  105. this.form = {
  106. userName: null,
  107. levelId: null,
  108. remark: null,
  109. }
  110. this.userInfo= {
  111. REAL_NAME: null,
  112. DEC_ROLE_ID: null,
  113. }
  114. }
  115. }
  116. }
  117. </script>
  118. <style>
  119. .app-main {
  120. padding: 15px;
  121. }
  122. .app-container {
  123. padding: 0;
  124. }
  125. .white-box {
  126. padding: 15px;
  127. }
  128. .form-page {
  129. width: 100%;
  130. }
  131. </style>