settingCoupon.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="panel">
  3. <div class="panel-header">
  4. <h3 class="header-title">{{ data.name }}设置</h3>
  5. <a class="el-icon-close close-btn" @click="closeRightTemplateHandle"></a>
  6. </div>
  7. <div>
  8. <el-form label-position="top" ref="form" label-width="80px">
  9. <el-form-item style="margin-bottom: 0;" label="输入标题">
  10. <el-input size="mini" @input="handleDate" v-model="content.value.couponTitle"></el-input>
  11. </el-form-item>
  12. <el-form-item style="margin-bottom: 0;" label="选择优惠券">
  13. <el-select
  14. @change="couponChange"
  15. v-model="selectList"
  16. multiple
  17. collapse-tags
  18. placeholder="选择优惠券">
  19. <el-option
  20. v-for="item in couponList"
  21. :key="item.id"
  22. :label="item.title"
  23. :value="item.id">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item style="margin-bottom: 0;" label="输入按钮名称">
  28. <el-input size="mini" @input="handleDate" v-model="content.value.buttonName"></el-input>
  29. </el-form-item>
  30. <el-form-item style="margin-bottom: 0;" label="按钮背景色(可只选一个,两个皆选为过渡色)">
  31. <el-color-picker @change="changeBgColor" v-model="btnBackground[0]"></el-color-picker>
  32. <el-color-picker style="margin-left: 20px;" @change="changeBgColor" v-model="btnBackground[1]"></el-color-picker>
  33. </el-form-item>
  34. </el-form>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. export default {
  40. name: 'settingCoupon',
  41. props: ['data', 'className'],
  42. data() {
  43. return {
  44. content: JSON.parse(JSON.stringify(this.data)),
  45. selectList:'',
  46. couponList:[{
  47. id:101,
  48. title:'xxx优惠券'
  49. },{
  50. id:220,
  51. title:'xxx2优惠券'
  52. }],
  53. btnBackground:['','']
  54. }
  55. },
  56. created() {
  57. this.getCouponList()
  58. this.selectList = this.content.value.couponList.length>0?this.content.value.couponList:[]
  59. if(this.content.value.btnBackground[0]){
  60. this.btnBackground[0] = this.content.value.btnBackground[0]
  61. }
  62. if(this.content.value.btnBackground[1]){
  63. this.btnBackground[1] = this.content.value.btnBackground[1]
  64. }
  65. },
  66. methods: {
  67. // 获取优惠券列表
  68. getCouponList() {
  69. // service.get("/custom/form/column/list?formId=" + formId).then((res) => {
  70. // if (res.data.code != 0) {
  71. // return that.$message.error(res.data.data.msg);
  72. // }
  73. // this.formColumnList = res.data.data;
  74. // }).catch(function () {
  75. // });
  76. },
  77. couponChange(val){
  78. console.log('val',val)
  79. let list = []
  80. this.couponList.map(item=>{
  81. if(val.indexOf(item.id)>-1)
  82. list.push(item)
  83. })
  84. this.content.value.couponList = list
  85. this.handleDate()
  86. },
  87. changeBgColor(val){
  88. console.log(val)
  89. this.content.value.btnBackground = this.btnBackground.filter(item=>{return item})
  90. console.log(this.content.value.btnBackground)
  91. this.handleDate()
  92. },
  93. handleDate() {
  94. this.$emit('updataContent', this.content)
  95. },
  96. closeRightTemplateHandle() {
  97. this.$emit('closeRightTemplateHandle', false)
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped>
  103. .panel {
  104. padding: 0 10px;
  105. }
  106. .panel .panel-header {
  107. position: relative;
  108. height: 40px;
  109. line-height: 40px;
  110. margin-left: 8px;
  111. margin-right: 8px;
  112. vertical-align: middle;
  113. border-bottom: 1px solid #dcdcdc;
  114. box-sizing: border-box;
  115. z-index: 10;
  116. }
  117. .panel .panel-header .header-title {
  118. padding-left: 5px;
  119. font-size: 14px;
  120. color: #29304e;
  121. position: relative;
  122. }
  123. .panel .panel-header .header-title:before {
  124. content: "";
  125. position: absolute;
  126. top: 50%;
  127. left: 0;
  128. transform: translateY(-50%);
  129. width: 3px;
  130. height: 18px;
  131. background: #1890ff;
  132. opacity: 1;
  133. border-radius: 2px;
  134. }
  135. .panel .panel-header .close-btn {
  136. position: absolute;
  137. top: 12px;
  138. right: 0;
  139. border: none;
  140. outline: none;
  141. cursor: pointer;
  142. color: #999;
  143. font-weight: 700;
  144. }
  145. .panel .panel-body {
  146. position: absolute;
  147. top: 40px;
  148. bottom: 0;
  149. width: 100%;
  150. overflow-y: auto;
  151. }
  152. .text-setting {
  153. display: flex;
  154. justify-content: space-between;
  155. margin: 10px 0;
  156. }
  157. </style>