1004749546@qq.com 4 jaren geleden
bovenliggende
commit
9a9d37e682

+ 8 - 0
src/api/luckyDraw.js

@@ -34,3 +34,11 @@ export const enableLuckyDraw = (params) => {
     method: 'post'
   })
 }
+// 删除
+export const deleteLuckyDraw = (params) => {
+  return axios({
+    url: `luckyDraw/delete/${params.id}`,
+    data: {},
+    method: 'get'
+  })
+}

+ 5 - 0
src/components/UploadFile/index.vue

@@ -4,6 +4,7 @@
       :action="action"
       :listType="listType"
       :fileList="fileList"
+      :disabled="disabled"
       @preview="handlePreview"
       @change="handleChange"
       :beforeUpload="beforeUpload"
@@ -68,6 +69,10 @@ export default {
           savePathType: 'web' // 存储类型 local 服务器本地,ali 阿里云, web
         }
       }
+    },
+    disabled: {
+      type: Boolean,
+      default: false
     }
   },
   watch: {

+ 73 - 18
src/views/market/addlotterySetModal.vue

@@ -41,18 +41,26 @@
         <h3 class="form-titles">基础设置</h3>
         <a-row :gutter="48">
           <a-col :span="6">
+            <!-- participantsNum>0 有参与人数时不可编辑 -->
             <a-form-model-item ref="activeName" label="活动名称" prop="activeName">
-              <a-input id="addLottery-time" v-model="form.activeName" allowClear :maxLength="15" placeholder="15个字以内"/>
+              <a-input
+                id="addLottery-time"
+                :disabled="participantsNum>0||state==1"
+                v-model="form.activeName"
+                allowClear
+                :maxLength="15"
+                placeholder="15个字以内"/>
             </a-form-model-item>
           </a-col>
           <a-col :span="6">
             <a-form-model-item ref="time" label="活动时间" prop="time">
               <a-range-picker
+                :disabled="participantsNum>0||state==1"
                 id="addLottery-time"
                 v-model="form.time"
                 :disabledDate="disabledDate"
                 allowClear
-                format="YYYY-MM-DD hh:mm:ss"
+                format="YYYY-MM-DD"
                 :placeholder="['开始时间','结束时间']"
               />
             </a-form-model-item>
@@ -73,13 +81,13 @@
                 id="addLottery-cjRc"
                 style="width: 50%;margin-right: 20px;"
                 v-model="form.peopleLimitCount"
-                :disabled="form.isPeopleLimit==1"
+                :disabled="form.isPeopleLimit==1||state==1"
                 :min="0"
                 :max="999999"
                 :precision="0"
                 placeholder="请输入抽奖人次(0~999999)"
                 allowClear />
-              <a-checkbox @change="bxCjRcChange" v-model="form.isPeopleLimit">
+              <a-checkbox :disabled="state==1" @change="bxCjRcChange" v-model="form.isPeopleLimit">
                 不限
               </a-checkbox>
             </a-form-model-item>
@@ -89,6 +97,7 @@
               每次抽奖需要支付
               <a-input-number
                 id="addLottery-cjgz"
+                :disabled="state==1"
                 style="width: 30%;margin-right: 5px;"
                 v-model="form.purchaseTimesGold"
                 :min="0"
@@ -104,17 +113,35 @@
         <a-row :gutter="48">
           <a-col :span="8">
             <a-form-model-item ref="prizeDesc" label="奖品说明" prop="prizeDesc">
-              <a-input v-model="form.prizeDesc" allowClear :maxLength="100" placeholder="请输入奖品说明,100字以内" type="textarea" />
+              <a-input
+                :disabled="state==1"
+                v-model="form.prizeDesc"
+                allowClear
+                :maxLength="100"
+                placeholder="请输入奖品说明,100字以内"
+                type="textarea" />
             </a-form-model-item>
           </a-col>
           <a-col :span="8">
             <a-form-model-item ref="activeLimitDesc" label="抽奖条件" prop="activeLimitDesc">
-              <a-input v-model="form.activeLimitDesc" allowClear :maxLength="100" placeholder="请输入抽奖条件,100字以内" type="textarea" />
+              <a-input
+                :disabled="state==1"
+                v-model="form.activeLimitDesc"
+                allowClear
+                :maxLength="100"
+                placeholder="请输入抽奖条件,100字以内"
+                type="textarea" />
             </a-form-model-item>
           </a-col>
           <a-col :span="8">
             <a-form-model-item ref="activeDesc" label="抽奖说明" prop="activeDesc">
-              <a-input v-model="form.activeDesc" allowClear :maxLength="100" placeholder="请输入抽奖说明,100字以内" type="textarea" />
+              <a-input
+                :disabled="state==1"
+                v-model="form.activeDesc"
+                allowClear
+                :maxLength="100"
+                placeholder="请输入抽奖说明,100字以内"
+                type="textarea" />
             </a-form-model-item>
           </a-col>
         </a-row>
@@ -122,8 +149,8 @@
         <h3 class="form-titles">奖品设置</h3>
         <div class="form-item">
           <a-form-model-item style="margin: 0;" ref="prizeClsNum" label="请选择转盘类型" prop="prizeClsNum">
-            <a-select style="width: 300px;" @change="zpTypeChange" v-model="form.prizeClsNum" placeholder="请选择转盘类型">
-              <a-select-option :key="3" :value="3">
+            <a-select style="width: 300px;" :disabled="participantsNum>0||state==1" @change="zpTypeChange" v-model="form.prizeClsNum" placeholder="请选择转盘类型">
+              <a-select-option :key="6" :value="6">
                 六等分
               </a-select-option>
             </a-select>
@@ -157,6 +184,7 @@
               }"
             >
               <a-select
+                :disabled="participantsNum>0||state==1"
                 :id="'jpList-prizeType'+index"
                 style="width: 100%;"
                 v-model="item.prizeType"
@@ -185,6 +213,7 @@
               }"
             >
               <a-input
+                :disabled="participantsNum>0||state==1"
                 v-if="item.prizeType !== 'GOLD'"
                 :id="'jpList-name'+index"
                 style="width: 100%;"
@@ -194,6 +223,7 @@
 
               <a-input-number
                 v-else
+                :disabled="participantsNum>0||state==1"
                 style="width: 100%;"
                 :id="'jpList-name'+index"
                 v-model="item.prizeDesc"
@@ -220,6 +250,7 @@
               <a-select
                 :id="'jpList-isPrizeLimit'+index"
                 style="width: 100%;"
+                :disabled="participantsNum>0||state==1"
                 v-model="item.isPrizeLimit"
                 @change="res => {
                   item.prizeRate = ''
@@ -250,6 +281,7 @@
             >
               <a-input-number
                 style="width: 100%;"
+                :disabled="participantsNum>0||state==1"
                 :id="'jpList-prizeRate'+index"
                 v-model="item.prizeRate"
                 :min="0"
@@ -274,6 +306,7 @@
             >
               <a-input-number
                 style="width: 100%;"
+                :disabled="participantsNum>0||state==1"
                 :id="'jpList-prizeNum'+index"
                 v-model="item.prizeNum"
                 :min="0"
@@ -291,6 +324,7 @@
               :prop="'luckyDrawPrizeList.' + index + '.prizeImage'"
             >
               <Upload
+                :disabled="participantsNum>0||state==1"
                 :id="'jpList-prizeImage'+index"
                 v-model="item.prizeImage"
                 :fileSize="0.25"
@@ -305,7 +339,13 @@
           <a-col :span="12">
             <div class="form-item">
               <div style="margin-right: 10px;"><span class="red">*</span>中奖限制:</div>
-              <a-select mode="multiple" style="width: 80%;" @change="zjxzChange" v-model="form.zjXz" placeholder="请选择中奖限制">
+              <a-select
+                mode="multiple"
+                :disabled="state==1"
+                style="width: 80%;"
+                @change="zjxzChange"
+                v-model="form.zjXz"
+                placeholder="请选择中奖限制">
                 <a-select-option
                   v-for="item in zjXz"
                   :key="item.code"
@@ -327,8 +367,9 @@
                 }"
               >
                 {{ index+1 }}.
-                <!-- {{ item.name.split('XXX')[0] }} -->
+                {{ item.winPrizeLimitCodeDictValue.split('XXX')[0] }}
                 <a-input-number
+                  :disabled="state==1"
                   style="width: 100px;"
                   :id="'luckyDrawWinPrizeLimitList-limitTimes'+index"
                   v-model="item.limitTimes"
@@ -337,14 +378,20 @@
                   :precision="0"
                   placeholder="请输入次数"
                   allowClear />
-                <!-- {{ item.name.split('XXX')[1] }} -->
+                {{ item.winPrizeLimitCodeDictValue.split('XXX')[1] }}
               </a-form-model-item>
             </div>
           </a-col>
           <a-col :span="12">
             <div class="form-item">
               <div style="margin-right: 10px;"><span class="red">*</span>赠送抽奖次数规则:</div>
-              <a-select mode="multiple" style="width: 70%;" @change="cjGzChange" v-model="form.cjGz" placeholder="请选择">
+              <a-select
+                mode="multiple"
+                :disabled="state==1"
+                style="width: 70%;"
+                @change="cjGzChange"
+                v-model="form.cjGz"
+                placeholder="请选择">
                 <a-select-option
                   v-for="item in cjGz"
                   :key="item.code"
@@ -366,8 +413,9 @@
                 }"
               >
                 {{ index+1 }}.
-                {{ item.name }}, 赠送
+                {{ item.taskCodeDictValue }}, 赠送
                 <a-input-number
+                  :disabled="state==1"
                   style="width: 100px;"
                   :id="'luckyDrawTaskList-giveTimes'+index"
                   v-model="item.giveTimes"
@@ -423,6 +471,8 @@ export default {
       formLayout: 'vertical',
       labelCol: {},
       wrapperCol: {},
+	  state: 0, // 活动状态
+      participantsNum: 0, // 抽奖参与人数
       form: {
         activeName: '', // 活动名称
         time: [],
@@ -491,7 +541,7 @@ export default {
         const row = this.zjXz.find(k => k.code == item)
         this.form.luckyDrawWinPrizeLimitList.push({
           winPrizeLimitCode: item,
-          name: row.dispName,
+          winPrizeLimitCodeDictValue: row.dispName,
           limitTimes: ''
         })
       })
@@ -504,7 +554,7 @@ export default {
         const row = this.cjGz.find(k => k.code == item)
         this.form.luckyDrawTaskList.push({
           taskCode: item,
-          name: row.dispName,
+          taskCodeDictValue: row.dispName,
           giveTimes: ''
         })
       })
@@ -523,8 +573,8 @@ export default {
             return false
           }
           const formData = JSON.parse(JSON.stringify(this.form))
-          formData.activeStartTime = moment(this.form.time[0]).format('YYYY-MM-DD hh:mm:ss')
-          formData.activeEndTime = moment(this.form.time[1]).format('YYYY-MM-DD hh:mm:ss')
+          formData.activeStartTime = moment(this.form.time[0]).format('YYYY-MM-DD') + ' 00:00:00'
+          formData.activeEndTime = moment(this.form.time[1]).format('YYYY-MM-DD') + ' 00:00:00'
           formData.isPeopleLimit = this.form.isPeopleLimit ? 1 : 0
           // 提交数据
           this.submitFormData(formData)
@@ -551,6 +601,8 @@ export default {
     getDetail (id) {
       getLuckyDrawDetail({ id: id }).then(res => {
         if (res.status == 200) {
+          this.participantsNum = res.data.participantsNum
+		  this.state = res.data.state
           this.form = Object.assign({}, this.form, res.data)
           this.form.isPeopleLimit = this.form.isPeopleLimit == 1
           this.form.time = [moment(this.form.activeStartTime), moment(this.form.activeEndTime)]
@@ -577,6 +629,9 @@ export default {
     // 取消
     cansel () {
       this.isShow = false
+	  this.participantsNum = 0
+	  this.state = 0
+	  this.form.isPeopleLimit = false
       this.form.luckyDrawPrizeList = []
       this.form.luckyDrawTaskList = []
       this.form.luckyDrawWinPrizeLimitList = []

+ 19 - 2
src/views/market/lotterySettings.vue

@@ -56,6 +56,7 @@
           class="actionBtn icon-blues"
           @click="handleEdit(record)" />
         <a-icon
+          v-if="record.participantsNum===0 && record.state==0"
           type="delete"
           id="lotterySet-handleDel"
           title="删除"
@@ -92,7 +93,7 @@ import {
 } from '@/components'
 import addlotterySetModal from './addlotterySetModal.vue'
 import {
-  getLuckyDrawList, enableLuckyDraw
+  getLuckyDrawList, enableLuckyDraw, deleteLuckyDraw
 } from '@/api/luckyDraw.js'
 
 export default {
@@ -188,7 +189,23 @@ export default {
     },
     // 删除
     handleDel (record) {
-
+      this.$confirm({
+		  title: '警告',
+		  centered: true,
+		  content: '删除后无法恢复,确认删除?',
+		  okText: '确定',
+		  cancelText: '取消',
+		  onOk: () => {
+		    deleteLuckyDraw({
+		      id: record.id
+		    }).then(res => {
+		      if (res.status == 200) {
+		        this.$message.success(res.message)
+		        this.$refs.table.refresh()
+		      }
+		    })
+		  }
+      })
     },
     // 查看
     handleView (record) {