setting.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-rich-text');
  4. ?>
  5. <div id="app" v-cloak>
  6. <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1500px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  7. <div slot="header">
  8. <div>
  9. <span>基础设置</span>
  10. </div>
  11. </div>
  12. <div class="form_box">
  13. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="150px">
  14. <el-card shadow="never">
  15. <div slot="header">
  16. <div>
  17. <span>打卡设置</span>
  18. </div>
  19. </div>
  20. <div>
  21. <el-row>
  22. <el-col :span="16">
  23. <el-form-item label="启用设置">
  24. <el-switch v-model="ruleForm.is_enable" :active-value="1" :inactive-value="0"></el-switch>
  25. <div class="tips-text" style="line-height: 24px;">关闭后将无法使用此功能</div>
  26. </el-form-item>
  27. <el-form-item label="按等级解锁">
  28. <el-switch v-model="ruleForm.is_seniority" :active-value="1" :inactive-value="0"></el-switch>
  29. <div class="tips-text" style="line-height: 24px;">关闭后将不再限制等级参与</div>
  30. </el-form-item>
  31. <el-form-item label="参与资格" v-if="ruleForm.is_seniority == 1">
  32. <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
  33. <div style="margin: 15px 0;"></div>
  34. <el-checkbox-group v-model="ruleForm.seniority" @change="handleCheckedChange">
  35. <el-checkbox v-for="item in levels" :label="item.level" :key="item.level">{{ item.name }}</el-checkbox>
  36. </el-checkbox-group>
  37. <div class="tips-text" style="line-height: 24px;">只有勾选到的会员等级才有资格参与任务打卡</div>
  38. </el-form-item>
  39. <el-form-item label="是否奖励">
  40. <el-switch v-model="ruleForm.is_reward" :active-value="1" :inactive-value="0"></el-switch>
  41. <div class="tips-text" style="line-height: 24px;">关闭后参与打卡的会员也不再赠送奖励</div>
  42. </el-form-item>
  43. <el-form-item label="默认额度设置">
  44. <div v-for="(reward_score, key) in ruleForm.default_score" :key="key">
  45. <el-input v-model="ruleForm.default_score[key]" style="width: 200px;" onInput="value=toNumber(value,2)"><template slot="append">积分</template></el-input>
  46. <el-button type="text" @click="handle('delete',key)" style="margin-left: 10px;">删除</el-button>
  47. </div>
  48. <el-button type="text" @click="handle('add')">+添加积分额度</el-button>
  49. <div class="tips-text" style="line-height: 24px;">审核通过时显示的默认奖励积分,作用仅用于方便后台审核</div>
  50. </el-form-item>
  51. <el-form-item label="积分奖励上限">
  52. <el-input v-model="ruleForm.reward_limit" style="width: 200px;">
  53. <template slot="append">积分</template>
  54. </el-input>
  55. <div class="tips-text" style="line-height: 24px;">会员打卡累计奖励积分达到此值的时候将不再奖励积分</div>
  56. </el-form-item>
  57. <el-form-item label="显示积分奖励上限">
  58. <el-switch v-model="ruleForm.is_show_reward_limit" :active-value="1" :inactive-value="0"></el-switch>
  59. <div class="tips-text" style="line-height: 24px;">关闭后前端不显示积分奖励上限</div>
  60. </el-form-item>
  61. <el-form-item label="上传图片数量限制">
  62. <el-input-number v-model="ruleForm.upload_limit" :min="1" :max="9" label="图片数量"></el-input-number>
  63. <div class="tips-text" style="line-height: 24px;">会员可上传的最大截图数量</div>
  64. </el-form-item>
  65. <el-form-item label="活动详情">
  66. <com-rich-text style="width: 750px" v-model="ruleForm.explain"></com-rich-text>
  67. </el-form-item>
  68. </el-col>
  69. </el-row>
  70. </div>
  71. </el-card>
  72. </el-form>
  73. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;" @click="store('ruleForm')" size="small">保存
  74. </el-button>
  75. </div>
  76. </el-card>
  77. </div>
  78. <script>
  79. const app = new Vue({
  80. el: '#app',
  81. data() {
  82. return {
  83. checkAll: false,
  84. isIndeterminate: false,
  85. loading: false,
  86. btnLoading: false,
  87. ruleForm: {
  88. is_enable: 0,// 是否启用
  89. is_seniority: 0,// 是否启用打卡资格
  90. seniority: [],// 打卡资格
  91. is_reward: 0,// 是否奖励奖励积分
  92. is_show_reward_limit: 1,// 是否显示积分奖励上限
  93. default_score: ['100', '200', '300', '400', '500'],// 默认积分额度设置
  94. reward_limit: 100, //积分奖励上限
  95. upload_limit: 1, //图片上传限制
  96. explain: '', // 活动详情
  97. },
  98. levels: {},
  99. levelOptions: [],
  100. }
  101. },
  102. mounted: function() {
  103. this.loadData();
  104. },
  105. methods: {
  106. loadData() {
  107. this.loading = true;
  108. request({
  109. params: {
  110. r: 'clockin/default/setting',
  111. },
  112. method: 'get'
  113. }).then(e => {
  114. this.loading = false;
  115. if (e.data.code == 0 && !isEmpty(e.data.data)) {
  116. this.ruleForm = Object.assign(this.ruleForm, e.data.data.config);
  117. this.levels = e.data.data.levels
  118. var options = []
  119. this.levels.forEach(function (item, index) {
  120. options.push(item.level)
  121. })
  122. this.levelOptions = options
  123. // 全选状态
  124. if (this.ruleForm.seniority.length === this.levelOptions.length) {
  125. this.checkAll = true
  126. }
  127. }
  128. }).catch(e => {
  129. this.loading = false;
  130. })
  131. },
  132. handle(type, data = null) {
  133. switch (type) {
  134. case 'add':// 添加规格
  135. this.ruleForm.default_score.push(0);
  136. break;
  137. case 'delete':// 删除规格
  138. this.ruleForm.default_score.splice(data,1);
  139. break;
  140. }
  141. },
  142. store(formName) {
  143. this.$refs[formName].validate((valid) => {
  144. if (valid) {
  145. this.btnLoading = true;
  146. request({
  147. params: {
  148. r: 'clockin/default/setting-submit',
  149. },
  150. method: 'post',
  151. data: this.ruleForm
  152. }).then(e => {
  153. this.btnLoading = false;
  154. if (e.data.code == 0) {
  155. this.$message.success(e.data.msg);
  156. } else {
  157. this.$message.error(e.data.msg);
  158. }
  159. }).catch(e => {
  160. this.$message.error(e);
  161. this.btnLoading = false;
  162. })
  163. } else {
  164. this.btnLoading = false;
  165. console.log('error submit!!');
  166. return false;
  167. }
  168. });
  169. },
  170. handleCheckAllChange(val) {
  171. this.ruleForm.seniority = val ? this.levelOptions : [];
  172. this.isIndeterminate = false;
  173. },
  174. handleCheckedChange(value) {
  175. let checkedCount = value.length;
  176. this.checkAll = checkedCount === this.levelOptions.length;
  177. this.isIndeterminate = checkedCount > 0 && checkedCount < this.levelOptions.length;
  178. }
  179. }
  180. });
  181. </script>