profit-setting.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <div id="app" v-cloak>
  2. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  3. <div slot="header">
  4. <div class="flex flex-x-between flex-y-center">
  5. <span>让利设置</span>
  6. </div>
  7. </div>
  8. </el-card>
  9. <div class="content">
  10. <el-form
  11. :model="formData"
  12. ref="elForm"
  13. label-width="180px"
  14. style="position: relative"
  15. size="small"
  16. :rules="rules"
  17. >
  18. <el-row>
  19. <el-col :span="24">
  20. <div class="form-body">
  21. <el-col :span="24">
  22. <!-- 商户编号 -->
  23. <el-form-item label="当前让利比例" prop="rate">
  24. <el-input v-model="formData.rate" disabled>
  25. <template #append>%</template>
  26. </el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="24">
  30. <el-form-item label="设置让利比例" prop="new_rate">
  31. <el-input :min="formData.min" :max="formData.max" :disabled="formData.is_enable == 0"
  32. v-model="formData.new_rate" onkeyup="value=value.replace(/[^\d]/g,'')">
  33. <template #append>%</template>
  34. </el-input>
  35. <span class="tip" v-if="formData.is_enable == 1">
  36. 请将让利比例控制在 {{formData.min}}% - {{formData.max}}% 之间
  37. </span>
  38. <span class="tip" v-else>
  39. 当前操作被禁用
  40. </span>
  41. </el-form-item>
  42. </el-col>
  43. <div></div>
  44. <el-col :span="24">
  45. <el-form-item size="large">
  46. <el-button type="primary" size="small" @click="submitForm" :disabled="formData.is_enable == 0">提交</el-button>
  47. <el-button size="small" @click="resetForm">重置</el-button>
  48. </el-form-item>
  49. </el-col>
  50. </div>
  51. </el-col>
  52. </el-row>
  53. </el-form>
  54. </div>
  55. </div>
  56. <script>
  57. const app = new Vue({
  58. el: '#app',
  59. data() {
  60. return {
  61. rules: {
  62. new_rate: [
  63. {
  64. required: true,
  65. message: '让利比例不能为空'
  66. }
  67. ],
  68. },
  69. formData: {
  70. new_rate: '',
  71. id: 0,
  72. is_enable: 0,
  73. min: 0,
  74. max: 0,
  75. },
  76. }
  77. },
  78. methods: {
  79. readConfig() {
  80. request({
  81. params: {
  82. r: 'store/client/merchant/profit-setting',
  83. },
  84. method: 'get',
  85. }).then(e => {
  86. this.submitLoading = false
  87. if (e.data.code === 0 && e.data.data) {
  88. this.formData = e.data.data
  89. }
  90. }).catch(e => {
  91. })
  92. },
  93. resetForm() {
  94. this.$refs['elForm'].resetFields()
  95. },
  96. submitForm() {
  97. if (this.formData.new_rate < this.formData.min || this.formData.new_rate > this.formData.max) {
  98. this.$message.error(`设置比例必须在 ${this.formData.min} - ${this.formData.max} 之间`)
  99. return false;
  100. }
  101. this.$refs['elForm'].validate(valid => {
  102. if (valid) {
  103. this.submitLoading = true;
  104. request({
  105. params: {
  106. r: 'store/client/merchant/profit-setting',
  107. },
  108. method: 'post',
  109. data: this.formData,
  110. }).then(e => {
  111. this.submitLoading = false
  112. if (e.data.code === 0) {
  113. this.$message.success(e.data.msg)
  114. } else {
  115. this.$message.error(e.data.msg)
  116. }
  117. }).catch(e => {
  118. })
  119. } else {
  120. this.$message.error('部分参数验证不通过')
  121. }
  122. })
  123. },
  124. },
  125. created() {
  126. this.readConfig()
  127. },
  128. })
  129. </script>
  130. <style>
  131. .form-body {
  132. padding-bottom: 5px;
  133. display: flex;
  134. flex-direction: column;
  135. }
  136. .title {
  137. display: flex;
  138. align-items: center;
  139. padding: 18px 20px;
  140. /* border-top: 1px solid #F3F3F3; */
  141. border-bottom: 1px solid #F3F3F3;
  142. background-color: #fff;
  143. }
  144. .title-line {
  145. width: 4px;
  146. height: 20px;
  147. background-color: #1479F0;
  148. margin-right: 10px;
  149. }
  150. .padding-top {
  151. margin-bottom: 10px;
  152. }
  153. .tip {
  154. color: #c72a29;
  155. }
  156. .link {
  157. display: flex;
  158. }
  159. .link span {
  160. cursor: pointer;
  161. color: #5eaae9;
  162. text-align: center;
  163. width: 100px;
  164. }
  165. </style>