dec-level-config.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <!-- 会员等级 -->
  5. <el-table :data="tableData" stripe style="width: 100%;">
  6. <el-table-column prop="LEVEL_NAME" :label="$t('config.levelName')" min-width="100px">
  7. <template slot-scope="{row}">
  8. <el-tag type="warning" size="small" class="no-border">{{ row.LEVEL_NAME }}</el-tag>
  9. </template>
  10. </el-table-column>
  11. <el-table-column prop="PERF" :label="$t('config.needPerf')" min-width="120px">
  12. <template slot-scope="{row}">
  13. <el-tag type="danger" size="small" class="no-border">{{ row.PERF }}</el-tag>
  14. </template>
  15. </el-table-column>
  16. <el-table-column :label="$t('common.updatedAdmin')" prop="UPDATE_ADMIN" min-width="100px" />
  17. <el-table-column :label="$t('common.updatedAt')" min-width="100px">
  18. <template slot-scope="{row}">
  19. {{ row.UPDATED_AT | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}
  20. </template>
  21. </el-table-column>
  22. <el-table-column :label="$t('common.action')" min-width="90px">
  23. <template slot-scope="{row}">
  24. <el-button type="primary" plain size="small" @click="editHandle(row)">{{ $t('common.edit') }}</el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. <!-- 更新观察期 -->
  29. <el-form ref="form" :model="form" label-width="150px" :label-position="labelPosition" style="margin-top: 25px;">
  30. <el-form-item :label="form.monthLimitTITLE">
  31. <el-input v-model="form.monthLimitVALUE" />
  32. <div class="white-box-footer" style="line-height: 1.2;color: #999;">
  33. <p>{{ $t('config.pour') }}:</p>
  34. <p>(1) {{ $t('config.enterNumber') }};</p>
  35. <p>(2) {{ $t('config.enterZeroIsHoleSite') }};</p>
  36. </div>
  37. <div class="white-box-footer">
  38. <el-button type="primary" :loading="submitButtonStat" @click="onSubmit">{{ $t('config.updatePeriodUnderObservation') }}</el-button>
  39. </div>
  40. </el-form-item>
  41. </el-form>
  42. <!-- 开启会员升级单 -->
  43. <el-switch v-model="value1" :active-text="value1Text" @change="switchUpgrade" />
  44. </div>
  45. <!-- 编辑 -->
  46. <el-dialog v-loading="editLoading" :title="$t('common.edit')" :visible.sync="dialog" :width="screenWidth" style="margin-top: -80px">
  47. <el-form ref="editForm" :model="editForm" :label-position="labelPosition" label-width="150px" style="width: 100%; margin-top: -30px; margin-bottom: -15px;">
  48. <el-row :gutter="3">
  49. <el-col :xs="24" :sm="24" :lg="12">
  50. <el-input v-show="false" v-model="editForm.ID" size="small" type="text" />
  51. <el-form-item :label="$t('config.levelName')" prop="LEVEL_NAME" required style="margin-bottom: 10px; width: 100%;">
  52. <el-input v-model.trim="editForm.LEVEL_NAME" size="small" type="text" style="min-width: 300px;" readonly />
  53. </el-form-item>
  54. <el-form-item :label="$t('config.needPerf')" prop="PERF" required style="margin-bottom: 10px; width: 100%;">
  55. <el-input v-model="editForm.PERF" size="small" type="text" style="min-width: 300px;" />
  56. </el-form-item>
  57. </el-col>
  58. </el-row>
  59. <el-form-item style="margin-bottom: 15px;">
  60. <el-button type="warning" size="mini" @click="dialog = false">{{ $t('table.cancel') }}</el-button>
  61. <el-button type="primary" size="mini" @click="onSubmitDecLevel">{{ $t('table.confirm') }}</el-button>
  62. </el-form-item>
  63. </el-form>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. import {
  69. fetchDecLevelConfig,
  70. fetchMonthLimit, updateDecLevel,
  71. updateMonthLimit,
  72. updateOpenUpgradeConfig
  73. } from '@/api/config'
  74. import waves from '@/directive/waves'
  75. import { getScreenWidth } from '@/utils'
  76. export default {
  77. name: 'DecLevelConfig',
  78. directives: { waves },
  79. data() {
  80. return {
  81. value1: true,
  82. value1Text: '',
  83. submitButtonStat: false,
  84. form: {
  85. monthLimitTITLE: '',
  86. monthLimitVALUE: ''
  87. },
  88. tableData: null,
  89. loading: true,
  90. screenWidth: getScreenWidth() > 500 ? '500px' : getScreenWidth() + 'px',
  91. labelPosition: getScreenWidth() >= 500 ? 'right' : 'top',
  92. dialog: false,
  93. editLoading: false,
  94. editForm: {
  95. ID: '',
  96. LEVEL_NAME: '',
  97. PERF: '',
  98. isAdjustGift: false,
  99. isDec: false
  100. },
  101. }
  102. },
  103. mounted() {
  104. this.fetchDecLevelConfig()
  105. this.fetchMonthLimit()
  106. },
  107. methods: {
  108. fetchDecLevelConfig() {
  109. this.loading = true
  110. fetchDecLevelConfig().then(response => {
  111. this.tableData = Object.values(response.data.list)
  112. setTimeout(() => {
  113. this.loading = false
  114. }, 0.5 * 1000)
  115. })
  116. },
  117. fetchMonthLimit() {
  118. fetchMonthLimit().then(response => {
  119. this.form.monthLimitTITLE = response.data.observe.TITLE
  120. this.form.monthLimitVALUE = response.data.observe.VALUE
  121. this.value1 = response.data.isOpenUpgrade.VALUE > 0 // 是否开启会员升级功能
  122. this.value1Text = response.data.isOpenUpgrade.TITLE
  123. })
  124. },
  125. // 切换开关
  126. switchUpgrade() {
  127. const data = { isOpen: this.value1 === true ? 1 : 0 }
  128. this.submitButtonStat = true
  129. updateOpenUpgradeConfig(data).then(response => {
  130. this.$message({
  131. message: response.data,
  132. type: 'success'
  133. })
  134. setTimeout(() => {
  135. this.submitButtonStat = false
  136. this.getData()
  137. }, 0.5 * 1000)
  138. }).catch(error => {
  139. this.$message({
  140. message: error,
  141. type: 'warning'
  142. })
  143. this.submitButtonStat = false
  144. this.getData()
  145. })
  146. },
  147. onSubmit() {
  148. this.submitButtonStat = true
  149. const data = { month: this.form.monthLimitVALUE }
  150. updateMonthLimit(data).then(response => {
  151. this.$message({
  152. message: response.data,
  153. type: 'success'
  154. })
  155. setTimeout(() => {
  156. this.submitButtonStat = false
  157. this.getData()
  158. }, 0.5 * 1000)
  159. }).catch(error => {
  160. this.$message({
  161. message: error,
  162. type: 'warning'
  163. })
  164. this.submitButtonStat = false
  165. this.getData()
  166. })
  167. },
  168. editHandle(row) {
  169. this.editForm.ID = row.ID
  170. this.editForm.LEVEL_NAME = row.LEVEL_NAME
  171. this.editForm.PERF = row.PERF
  172. this.editForm.isAdjustGift = row.IS_ADJUST_GIFT === '1'
  173. this.editForm.isDec = row.IS_DEC === '1'
  174. this.dialog = true
  175. },
  176. onSubmitDecLevel() {
  177. this.editLoading = true
  178. const data = {
  179. levelName: this.editForm.LEVEL_NAME,
  180. perf: this.editForm.PERF,
  181. isAdjustGift: this.form.isAdjustGift ? 1 : 0,
  182. isDec: this.form.isDec ? 1 : 0
  183. }
  184. updateDecLevel(data, this.editForm.ID).then(response => {
  185. this.$message({
  186. message: response.data,
  187. type: 'success'
  188. })
  189. setTimeout(() => {
  190. this.editLoading = false
  191. this.dialog = false
  192. this.fetchDecLevelConfig()
  193. }, 0.5 * 1000)
  194. }).catch(error => {
  195. this.$message({
  196. message: error,
  197. type: 'warning'
  198. })
  199. this.editLoading = false
  200. this.fetchDecLevelConfig()
  201. })
  202. }
  203. }
  204. }
  205. </script>
  206. <style scoped>
  207. /deep/ .el-form-item__label {
  208. text-align: left !important;
  209. }
  210. .app-main {
  211. padding: 15px;
  212. }
  213. .app-container {
  214. padding: 0;
  215. }
  216. .white-box {
  217. padding: 15px;
  218. }
  219. .form-page {
  220. width: 100%;
  221. }
  222. </style>