addlotterySetModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div>
  3. <a-modal
  4. v-model="isShow"
  5. @cancle="isShow = false"
  6. :footer="null"
  7. width="80%"
  8. :centered="true"
  9. wrapClassName="addLottery-modal"
  10. :title="titleText">
  11. <a-form-model
  12. ref="ruleForm"
  13. :model="form"
  14. :layout="formLayout"
  15. :rules="rules"
  16. :label-col="labelCol"
  17. :wrapper-col="wrapperCol"
  18. >
  19. <h3 class="form-titles">基础设置</h3>
  20. <a-row :gutter="48">
  21. <a-col :span="6">
  22. <a-form-model-item ref="name" label="活动名称" prop="name">
  23. <a-input id="addLottery-time" v-model="form.name" placeholder="15个字以内"/>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :span="6">
  27. <a-form-model-item ref="time" label="活动时间" prop="time">
  28. <a-range-picker
  29. id="addLottery-time"
  30. v-model="form.time"
  31. format="YYYY-MM-DD"
  32. :placeholder="['开始时间','结束时间']"
  33. />
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :span="6">
  37. <a-form-model-item ref="name" label="抽奖人次" prop="name">
  38. <a-input-number
  39. id="addLottery-cjRc"
  40. style="width: 50%;margin-right: 20px;"
  41. v-model="form.nums"
  42. :min="0"
  43. :max="999999"
  44. :precision="0"
  45. placeholder="请输入抽奖人次(0~999999)"
  46. allowClear />
  47. <a-checkbox v-model="form.bxNums">
  48. 不限
  49. </a-checkbox>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :span="6">
  53. <a-form-model-item ref="name" label="付费抽奖规则" prop="name">
  54. 每次抽奖需要支付
  55. <a-input-number
  56. id="addLottery-cjgz"
  57. style="width: 30%;margin-right: 5px;"
  58. :min="0"
  59. :max="999999"
  60. :precision="0"
  61. placeholder="请输入乐豆数(0~999999)"
  62. allowClear />
  63. 乐豆
  64. </a-form-model-item>
  65. </a-col>
  66. </a-row>
  67. <a-row :gutter="48">
  68. <a-col :span="8">
  69. <a-form-model-item ref="name" label="奖品说明" prop="name">
  70. <a-input v-model="form.desc" type="textarea" />
  71. </a-form-model-item>
  72. </a-col>
  73. <a-col :span="8">
  74. <a-form-model-item ref="name" label="抽奖条件" prop="name">
  75. <a-input v-model="form.desc" type="textarea" />
  76. </a-form-model-item>
  77. </a-col>
  78. <a-col :span="8">
  79. <a-form-model-item ref="name" label="抽奖说明" prop="name">
  80. <a-input v-model="form.desc" type="textarea" />
  81. </a-form-model-item>
  82. </a-col>
  83. </a-row>
  84. <h3 class="form-titles">奖品设置</h3>
  85. <a-row :gutter="48">
  86. <a-col :span="24">
  87. <div class="form-item">
  88. <div style="margin-right: 10px;"><span class="red">*</span>请选择转盘类型</div>
  89. <a-select style="width: 300px;" v-model="form.region" placeholder="请选择类型">
  90. <a-select-option value="5">
  91. 五等分
  92. </a-select-option>
  93. <a-select-option value="6">
  94. 六等分
  95. </a-select-option>
  96. </a-select>
  97. </div>
  98. <div class="form-item" v-for="(item, index) in 6" :key="index">
  99. <div style="margin-right: 10px;"><span class="red">*</span> 奖品{{ index }}</div>
  100. <a-select style="width: 120px;margin-right: 5px;" placeholder="请选择类型">
  101. <a-select-option value="0">
  102. 送实物
  103. </a-select-option>
  104. <a-select-option value="1">
  105. 送乐豆
  106. </a-select-option>
  107. <a-select-option value="2">
  108. 未中奖
  109. </a-select-option>
  110. </a-select>
  111. <a-input style="width: 200px;margin-right: 5px;" placeholder="请输入奖品名称,10个字以内"/>
  112. <a-select style="width: 120px;margin-right: 5px;" placeholder="是否中奖">
  113. <a-select-option value="1">
  114. </a-select-option>
  115. <a-select-option value="0">
  116. </a-select-option>
  117. </a-select>
  118. <a-input-number
  119. style="width: 150px;margin-right: 5px;"
  120. :min="0"
  121. :max="100"
  122. :precision="2"
  123. placeholder="请输入中奖概率(%)"
  124. allowClear />
  125. <a-input-number
  126. style="width: 150px;margin-right: 5px;"
  127. :min="0"
  128. :max="999999"
  129. :precision="0"
  130. placeholder="请输入奖品数量"
  131. allowClear />
  132. <Upload
  133. class="upload"
  134. ref="homeImage"
  135. :fileSize="0.25"
  136. listType="picture-card">
  137. </Upload>
  138. <span class="upload-desc">请上传奖品图片,300*300px,0.25MB 以内。</span>
  139. </div>
  140. </a-col>
  141. </a-row>
  142. <a-row :gutter="48">
  143. <a-col :span="12">
  144. <div class="form-item">
  145. <div style="margin-right: 10px;"><span class="red">*</span>中奖限制:</div>
  146. <a-select mode="multiple" style="width: 300px;" v-model="form.region" placeholder="请选择">
  147. <a-select-option value="5">
  148. 中奖后抽奖XXX次内不能再次中奖
  149. </a-select-option>
  150. <a-select-option value="6">
  151. 每天最多可中奖XXX次
  152. </a-select-option>
  153. <a-select-option value="6">
  154. 每人最多可中奖XXX次
  155. </a-select-option>
  156. </a-select>
  157. </div>
  158. </a-col>
  159. <a-col :span="12">
  160. <div class="form-item">
  161. <div style="margin-right: 10px;"><span class="red">*</span>赠送抽奖次数规则:</div>
  162. <a-select mode="multiple" style="width: 300px;" v-model="form.region" placeholder="请选择">
  163. <a-select-option value="5">
  164. 新用户登录送抽奖
  165. </a-select-option>
  166. <a-select-option value="6">
  167. 用户首次投递送抽奖
  168. </a-select-option>
  169. <a-select-option value="6">
  170. 分享给好友或朋友圈送抽奖
  171. </a-select-option>
  172. <a-select-option value="6">
  173. 3个月内无投递记录送抽奖
  174. </a-select-option>
  175. </a-select>
  176. </div>
  177. </a-col>
  178. </a-row>
  179. <div class="form-item" style="justify-content:center;padding: 50px 20px 20px;">
  180. <a-button type="primary" @click="onSubmit">
  181. 保存
  182. </a-button>
  183. <a-button style="margin-left: 10px;" @click="resetForm">
  184. 重置
  185. </a-button>
  186. </div>
  187. </a-form-model>
  188. </a-modal>
  189. </div>
  190. </template>
  191. <script>
  192. import { VSelect, Upload } from '@/components'
  193. import { goodsClassDetails, saveGoodsClass } from '@/api/shopSetting.js'
  194. export default {
  195. name: 'AddlotterySetModal',
  196. components: {
  197. VSelect,
  198. Upload
  199. },
  200. props: {
  201. showEditModal: {
  202. type: Boolean,
  203. default: false
  204. },
  205. itemId: {
  206. type: String,
  207. default: ''
  208. },
  209. itemData: {
  210. type: Object,
  211. default: function () {
  212. return {}
  213. }
  214. }
  215. },
  216. data () {
  217. return {
  218. isShow: this.showEditModal,
  219. titleText: '新增活动',
  220. formLayout: 'vertical',
  221. labelCol: {},
  222. wrapperCol: {},
  223. form: {
  224. name: '',
  225. region: undefined,
  226. date1: undefined,
  227. delivery: false,
  228. type: [],
  229. resource: '',
  230. desc: ''
  231. },
  232. rules: {
  233. name: [
  234. { required: true, message: 'Please input Activity name', trigger: 'blur' },
  235. { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' }
  236. ],
  237. region: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
  238. date1: [{ required: true, message: 'Please pick a date', trigger: 'change' }],
  239. type: [
  240. {
  241. type: 'array',
  242. required: true,
  243. message: 'Please select at least one activity type',
  244. trigger: 'change'
  245. }
  246. ],
  247. resource: [
  248. { required: true, message: 'Please select activity resource', trigger: 'change' }
  249. ],
  250. desc: [{ required: true, message: 'Please input activity form', trigger: 'blur' }]
  251. }
  252. }
  253. },
  254. methods: {
  255. // 查看详情
  256. getPageInfo () {
  257. const _this = this
  258. goodsClassDetails({
  259. id: _this.itemId
  260. }).then(res => {
  261. if (res.status == 200) {
  262. this.form.setFieldsValue({ formData: res.data })
  263. }
  264. })
  265. },
  266. // 点击保存;
  267. handleSubmit (e) {
  268. e.preventDefault()
  269. const _this = this
  270. this.form.validateFields((err, values) => {
  271. if (!err) {
  272. const formData = Object.assign({}, this.itemData, this.formData, values.formData)
  273. formData.id = _this.itemId
  274. saveGoodsClass(formData).then(res => {
  275. if (res.status == 200) {
  276. _this.$message.success(res.message)
  277. _this.$emit('refresh')
  278. setTimeout(function () {
  279. _this.isShow = false
  280. }, 300)
  281. }
  282. })
  283. }
  284. })
  285. }
  286. },
  287. watch: {
  288. showEditModal (newValue, oldValue) {
  289. this.isShow = newValue
  290. },
  291. isShow (val) {
  292. if (!val) {
  293. this.$emit('close')
  294. } else {
  295. this.form.resetFields()
  296. }
  297. },
  298. itemId (newValue, oldValue) {
  299. if (newValue && this.isShow) {
  300. this.titleText = '编辑'
  301. this.getPageInfo(newValue)
  302. } else {
  303. this.titleText = '新增'
  304. }
  305. }
  306. }
  307. }
  308. </script>
  309. <style lang="less">
  310. .addLottery-modal{
  311. .form-titles{
  312. border-bottom: 1px solid #eee;
  313. padding-bottom: 10px;
  314. margin-bottom: 20px;
  315. }
  316. .form-item{
  317. display: flex;
  318. align-items: center;
  319. padding: 5px;
  320. }
  321. .upload-desc{
  322. font-size: 12px;
  323. margin-left: 10px;
  324. }
  325. .red{
  326. color: red;
  327. }
  328. }
  329. </style>