IntegralRule.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <div
  5. style="padding: 40px;"
  6. v-loading="loading"
  7. :element-loading-text="loadingText"
  8. element-loading-spinner="el-icon-loading"
  9. element-loading-background="rgba(0, 0, 0, 0.8)"
  10. >
  11. <el-form :model="form" ref="form" size="small" :rules="rules" label-width="120px">
  12. <el-form-item label="积分功能" prop="status">
  13. <el-radio-group v-model="form.status">
  14. <el-radio :label="1">关闭</el-radio>
  15. <el-radio :label="2">开启</el-radio>
  16. </el-radio-group>
  17. </el-form-item>
  18. <el-form-item label="积分抵现" prop="isDischarge">
  19. <el-radio-group v-model="form.isDischarge">
  20. <el-radio :label="1">关闭</el-radio>
  21. <el-radio :label="2">开启</el-radio>
  22. </el-radio-group>
  23. </el-form-item>
  24. <div style="display: flex;align-items: center;">
  25. <el-form-item v-if="form.isDischarge==2" label="积分抵现系数" prop="dischargeRate">
  26. <el-input-number style="width: 300px" v-model="form.dischargeRate" placeholder="请输积分抵现系数" controls-position="right"></el-input-number>
  27. </el-form-item>
  28. <span style="margin-left: 15px; padding-bottom:15px; font-size: 12px;color: #ccc;"></span>
  29. </div>
  30. <div v-if="form.status==2" style="display: flex;align-items: center;">
  31. <el-form-item label="积分奖励系数" prop="exchangeRate">
  32. <el-input-number style="width: 300px" v-model="form.exchangeRate" placeholder="请输积分奖励系数" controls-position="right"></el-input-number>
  33. </el-form-item>
  34. <span style="margin-left: 15px; padding-bottom:15px; font-size: 12px;color: #ccc;">(会员下单获取积分值=实付金额*积分规则基础系数奖励系数越大,获得成长值越多,建议数值设置不要过大)</span>
  35. </div>
  36. <div style="display: flex;align-items: center;">
  37. <el-form-item label="积分自动清零" prop="isClean">
  38. <el-radio-group v-model="form.isClean">
  39. <el-radio :label="1">关闭</el-radio>
  40. <el-radio :label="2">开启</el-radio>
  41. </el-radio-group>
  42. </el-form-item>
  43. <el-form-item v-if="form.isClean==2" label="每年固定" prop="cleanTime">
  44. <el-date-picker
  45. style="width: 300px"
  46. v-model="form.cleanTime"
  47. type="datetime"
  48. format="MM-dd"
  49. value-format="MM-dd"
  50. placeholder="请选择每年固定自动清零时间">
  51. </el-date-picker>
  52. </el-form-item>
  53. <span v-if="form.isClean==2" style="margin-left: 15px; padding-bottom:15px; font-size: 12px;color: #ccc;">自动清零</span>
  54. </div>
  55. <el-form-item style="margin-top: 15px;">
  56. <el-button :loading="loading" @click="initData()">取消</el-button>
  57. <el-button
  58. v-hasPermi="configPermi.seva"
  59. type="primary"
  60. @click="submitForm"
  61. :loading="loading"
  62. element-loading-text="提交中..."
  63. element-loading-spinner="el-icon-loading"
  64. element-loading-background="rgba(0, 0, 0, 0.8)"
  65. >
  66. {{ loading ? '提交中...' : '保存' }}
  67. </el-button>
  68. </el-form-item>
  69. </el-form>
  70. </div>
  71. </el-row>
  72. </div>
  73. </template>
  74. <script>
  75. import {
  76. getTableDeatilsByIdApi,
  77. addTableApi,
  78. } from '@/api/CURD'
  79. export default {
  80. name: "IntegralRule",
  81. dicts: [],
  82. data() {
  83. return {
  84. title: "积分规则",// 通用标题
  85. loading: false,
  86. loadingText: "拼命加载数据中...",
  87. configPermi: {
  88. add: [''], // 新增权限
  89. details: [''], // 详情权限
  90. delect: [''], // 删除权限
  91. edit: [''], // 编辑权限http://localhost/scenicAreaManagement/contentManagement/scenicAreaManagement/contentManagement/questions
  92. upload: [''],// 导入权限
  93. export: [''],// 导出权限http://localhost/scenicAreaManagement/contentManagement/scenicAreaManagement/contentManagement/suggestions
  94. release: [''],
  95. seva: ['pointsManagement:IntegralRecord:seva'] // 保存
  96. },
  97. configUrl: {
  98. details: '/merchant/creditConfig/getCreditConfig', // 详情地址
  99. edit: '/merchant/creditConfig/insertOrUpdate', // 编辑地址
  100. },
  101. form: {},
  102. rules: {
  103. status: [{ required: true, message: "请选择积分功能", trigger: ["change","blur"] }],
  104. isDischarge: [{ required: true, message: "请选择积分抵现", trigger: ["change","blur"] }],
  105. isClean: [{ required: true, message: "请选择积分自动清零", trigger: ["change","blur"] }],
  106. cleanTime: [{ required: true, message: "请选择每年固定自动清零时间", trigger: ["change","blur"] }],
  107. dischargeRate: [{ required: true, message: "请输积分抵现系数", trigger: ["change","blur"] }],
  108. exchangeRate: [{ required: true, message: "请输入积分奖励系数", trigger: ["change","blur"] }],
  109. },
  110. };
  111. },
  112. created() {
  113. this.initData()
  114. },
  115. methods: {
  116. /** 初始化 */
  117. initData() {
  118. this.loadingText = "拼命加载数据中..."
  119. this.loading = true
  120. this.getTableDeatilsFun()
  121. },
  122. /** 获取详情 */
  123. async getTableDeatilsFun(row) {
  124. this.loading = true
  125. try {
  126. let res = await getTableDeatilsByIdApi(this.configUrl.details,{})
  127. if(res.code == 200) {
  128. let obj = {
  129. ...res.data
  130. }
  131. this.$set(this,'form',JSON.parse(JSON.stringify(obj)))
  132. this.formStatus = 1
  133. this.$nextTick(()=>{
  134. if(this.form.longitude&&this.form.latitude){
  135. console.log("dsfasfdasdfasdfadsfads")
  136. this.$refs.qqMapBox.setMakerLayer({
  137. height: 0,
  138. lat: this.form.latitude,
  139. lng: this.form.longitude,
  140. },true)
  141. }
  142. })
  143. }else {
  144. this.$message.error('获取详情失败!!!');
  145. this.formStatus = 2
  146. this.loading = false
  147. this.open = false;
  148. }
  149. this.$nextTick(()=>{
  150. this.reset()
  151. })
  152. this.loading = false
  153. } catch (error) {
  154. console.error('获取详情失败!!!!',error)
  155. this.formStatus = 2
  156. this.loading = false
  157. this.open = false;
  158. }
  159. },
  160. /**
  161. * 保存
  162. * @date 2023-11-22
  163. * @returns {any}
  164. */
  165. submitForm() {
  166. this.$refs["form"].validate(valid => {
  167. if (valid) {
  168. this.loadingText = "提交数据中..."
  169. this.loading = true
  170. addTableApi(
  171. this.configUrl.edit,{
  172. ...this.form
  173. }).then(response => {
  174. this.$modal.msgSuccess("修改成功");
  175. this.loading = false
  176. this.initData()
  177. }).catch(()=>{
  178. this.$message.error("修改失败!!!");
  179. this.loading = false
  180. })
  181. }
  182. });
  183. },
  184. /**
  185. * 重置
  186. * @date 2023-11-22
  187. * @returns {any}
  188. */
  189. reset() {
  190. if(this.$refs["form"]) {
  191. this.$refs["form"].clearValidate();
  192. }
  193. },
  194. setDot(params){
  195. this.$set(this.form,'longitude',params.lng)
  196. this.$set(this.form,'latitude',params.lat)
  197. }
  198. }
  199. };
  200. </script>