HelpRule.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div>
  3. <el-dialog
  4. v-loading="loading"
  5. :show-close="false"
  6. :close-on-click-modal="false"
  7. :visible.sync="isShow"
  8. :title="tagObj.id ? `编辑(${curObj.estate_name})团购助力规则` : `新增(${curObj.estate_name})团购助力规则`"
  9. :fullscreen="false"
  10. width="700px"
  11. custom-class="xl-dialog"
  12. center
  13. >
  14. <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px">
  15. <div slot="footer" style="padding-top: 20px;">
  16. <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
  17. <el-button class="xl-form-btn t1" @click="close('confirm')">保存</el-button>
  18. <el-button class="xl-form-btn t4" @click="delHandle">清空规则</el-button>
  19. </div>
  20. </base-form>
  21. </el-dialog>
  22. </div>
  23. </template>
  24. <script>
  25. import { arrToObj } from '@/utils'
  26. import baseTable from '_m/baseTable.js'
  27. export default {
  28. components: { },
  29. props: {
  30. isShow: Boolean,
  31. curObj: Object
  32. },
  33. mixins: [...mixins, baseTable],
  34. inject: ['parentData'],
  35. data() {
  36. return {
  37. formData: [],
  38. loading: true,
  39. tagObj: {},
  40. }
  41. },
  42. watch: {
  43. isShow: function(val) {
  44. if (val) {
  45. this.getDtl()
  46. }
  47. },
  48. },
  49. mounted() {},
  50. methods: {
  51. getDtl () {
  52. this.listLoading = true
  53. this.$api.other.admactivityruledetail({estate_id: this.curObj.id}).then(res => {
  54. this.tagObj = res.rule || {}
  55. this.getDef()
  56. this.listLoading = false
  57. })
  58. },
  59. delHandle() {
  60. this.$msg(`您确定要清空改规则吗?`, 'confirm', () => {
  61. this.$api.other.admactivityruledel({
  62. estate_id: this.curObj.id,
  63. }).then(data => {
  64. this.tagObj = {}
  65. this.$msgs(`已清空!`)
  66. this.close()
  67. })
  68. }, null, true)
  69. },
  70. getDef() {
  71. const params = {...this.tagObj}
  72. this.formData = [
  73. { label: '是否开启', key: 'is_open', class: 'c-2', rules: 1, type: 'select', options: this.$dictData.sys_yesno },
  74. { label: '截止时间', key: 'end_at', class: 'c-2', rules: 1, type: 'datePicker', type2: 'date' },
  75. { label: '规则简述', key: 'rule', type: 'textarea', rules: 1 },
  76. { label: '助力人数', key: 'option_req', type: 'inputFont', appendFont: '人', rules:
  77. [
  78. {
  79. validator: (rule, value, callback) => {
  80. if (Number(value) < 0 || isNaN(Number(value))) {
  81. callback(new Error('请输入数字'))
  82. } else {
  83. callback()
  84. }
  85. }, trigger: 'blur'
  86. }
  87. ]
  88. },
  89. { label: '规则700*1248', key: 'rule_img', class: 'c-2', type: 'uploads', rules: 1 },
  90. { label: '活动660*880', key: 'poster_img', class: 'c-2', type: 'uploads', rules: 1 },
  91. ]
  92. this.setDefaultValue(params)
  93. },
  94. close(str) {
  95. if (str === 'confirm') {
  96. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  97. if (valid) {
  98. const oldform = this.$refs.ruleForm.baseForm
  99. const newForm = { ...oldform }
  100. newForm.estate_id = this.curObj.id
  101. let apiStr = 'admactivityruleadd'
  102. if (this.tagObj.id) apiStr = 'admactivityruleedit'
  103. this.$api.other[apiStr](newForm).then(data => {
  104. this.$msgs(this.tagObj.id ? '编辑成功' : '新增成功')
  105. this.$emit('close', newForm)
  106. })
  107. }
  108. })
  109. } else {
  110. this.$emit('close')
  111. this.setDefaultValue()
  112. }
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. @import '../../../../styles/libEdit.scss';
  119. .lib-edit {
  120. padding-top: 0;
  121. ::v-deep .el-form-item {
  122. margin-bottom: 10px;
  123. }
  124. ::v-deep .el-date-editor.el-input {
  125. width: 100%;
  126. }
  127. }
  128. .scoped-ed {
  129. .se-op {
  130. display: inline-block;
  131. vertical-align: middle;
  132. border: 1px solid #dcdcdc;
  133. margin-bottom: 10px;
  134. margin-right: 10px;
  135. .t {
  136. display: inline-block;
  137. vertical-align: middle;
  138. height: 30px;
  139. line-height: 30px;
  140. width: 150px;
  141. padding: 0 20px;
  142. font-weight: bold;
  143. }
  144. .s {
  145. display: inline-block;
  146. vertical-align: middle;
  147. color: #fff;
  148. background: #ff875c;
  149. height: 30px;
  150. line-height: 30px;
  151. padding: 0 10px;
  152. cursor: pointer;
  153. }
  154. }
  155. }
  156. </style>