Administrator 7 ヶ月 前
コミット
fd4b98266f
2 ファイル変更26 行追加4 行削除
  1. 18 3
      src/views/activity/rule/index.vue
  2. 8 1
      src/views/activity/template/index.vue

+ 18 - 3
src/views/activity/rule/index.vue

@@ -96,7 +96,7 @@
           <el-col :span="11">
             <el-form-item prop="startTime">
               <el-date-picker v-model="ruleForm.startTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
-                placeholder="选择开启时间" style="width: 100%" />
+                placeholder="选择开启时间" style="width: 100%" :change="onStartTimeChange(ruleForm.startTime)"/>
             </el-form-item>
           </el-col>
           <el-col class="text-center" :span="2" style="text-align: center">
@@ -251,8 +251,8 @@ const loadActivityTemplateInfo = () => {
   activityTemplateApi.all().then(res => {
     templateData.value = res.data.result;
     for (var i=0; i < templateData.value.length; i++) {
-      templateOptionData.value[i].value = templateData.value[i].id;
-      templateOptionData.value[i].label = templateData.value[i].id +"-"+templateData.value[i].name;
+      templateOptionData.value[i].value = templateData.value[i].id
+      templateOptionData.value[i].label = templateData.value[i].id +"-"+templateData.value[i].name
     }
     console.log(templateData)
     console.log(templateOptionData)
@@ -354,6 +354,21 @@ const onTypeChange = (val) => {
   }
 }
 
+const onStartTimeChange = (val) => {
+  if (val != null && val != "") {
+    let startDate = new Date(val)
+    for (var i=0; i < templateData.value.length; i++) {
+      if (templateData.value[i].id == ruleForm.actTemId) {
+        const dayOfMs = 24 * 60 * 60 * 1000;
+        let endTimeMs = startDate.getTime() + templateData.value[i].keepDay * dayOfMs
+        ruleForm.endTime = dateUtils.getDate(endTimeMs)
+        ruleForm.tipsTime = templateData.value[i].tipsDay == null ? val : dateUtils.getDate(startDate.getTime() - templateData.value[i].tipsDay * dayOfMs)
+        ruleForm.stayTime = templateData.value[i].stayDay == null ? ruleForm.endTime : dateUtils.getDate(endTimeMs + templateData.value[i].stayDay * dayOfMs)
+      }
+    }
+  }
+}
+
 const list = ref(data)
 
 const formSize = ref('default')

+ 8 - 1
src/views/activity/template/index.vue

@@ -44,6 +44,9 @@
         <el-form-item label="模版备注" prop="remark">
           <el-input v-model="ruleForm.remark" />
         </el-form-item>
+        <el-form-item label="预告天数" prop="tipsDay">
+          <el-input v-model="ruleForm.tipsDay" type="number"/>
+        </el-form-item>
         <el-form-item label="持续天数" prop="keepDay">
           <el-input v-model="ruleForm.keepDay" type="number"/>
         </el-form-item>
@@ -110,7 +113,7 @@ const tableData = ref([])
 const tableHeader = ref([])
 const upload = ref<UploadInstance>()
 
-const tableColumn = ["id","name","des","reward","remark","keepDay","stayDay","isOpenSvr"]
+const tableColumn = ["id","name","des","reward","remark","tipsDay","keepDay","stayDay","isOpenSvr"]
 const beforeUploadAction = (file, fileLi) => {
   return new Promise((resolve, reject) => {
     const reader = new FileReader()
@@ -197,6 +200,7 @@ const column = [
   { name: 'des', label: '模版描述'},
   { name: 'reward', label: '模版奖励'},
   { name: 'remark', label: '模版备注'},
+  { name: 'tipsDay', label: '预告天数'},
   { name: 'keepDay', label: '持续天数'},
   { name: 'stayDay', label: '停留天数'},
   { name: 'isOpenSvr', label: '开服活动', slot: true },
@@ -222,6 +226,7 @@ const ruleForm = reactive({
     des: null,
     reward: null,
     remark: null,
+    tipsDay: null,
     keepDay: null,
     stayDay: null,
     isOpenSvr:0
@@ -274,6 +279,7 @@ const add = () => {
   ruleForm.des = null
   ruleForm.reward = null
   ruleForm.remark = null
+  ruleForm.tipsDay = null
   ruleForm.keepDay = null
   ruleForm.stayDay = null
   ruleForm.isOpenSvr = 0
@@ -378,6 +384,7 @@ const edit = (row) => {
   ruleForm.des = row.des
   ruleForm.reward = row.reward
   ruleForm.remark = row.remark
+  ruleForm.tipsDay = row.tipsDay == null ? row.tipsDay :row.tipsDay.toString()
   ruleForm.keepDay = row.keepDay.toString()
   ruleForm.stayDay = row.stayDay == null ? row.stayDay : row.stayDay.toString()
   ruleForm.isOpenSvr = row.isOpenSvr