Browse Source

no message

DESKTOP-SVI9JE1\muzen 1 year ago
parent
commit
2bb6198495

+ 0 - 1
src/views/content/insert/detail.vue

@@ -367,7 +367,6 @@ function handleDeleteDate(index) {
 // 校验时间
 const handleChangeDate = (e, index) => {
   if (e !== null) {
-    data.listDate = []
     data.form.listDate = []
     const start = new Date(e[0]).getTime()
     const end = new Date(e[1]).getTime()

+ 1 - 2
src/views/content/scene/detail.vue

@@ -10,7 +10,7 @@
       </el-form-item>
       <el-form-item label="播放时间:" prop="listDate">
         <div class="date" v-for="(item, index) in data.dateList">
-          <el-time-picker ref="picker" v-model="data.dateList[index]" is-range format="HH:mm:ss" value-format="HH:mm:ss"
+          <el-time-picker v-model="data.dateList[index]" is-range format="HH:mm:ss" value-format="HH:mm:ss"
             start-placeholder="开始时间" end-placeholder="结束时间" @change="handleChangeDate($event, index)" />
           <el-link v-show="data.dateList.length > 1" icon="CircleClose" :underline="false"
             @click="handleDeleteDate(index)" />
@@ -207,7 +207,6 @@ function handleDeleteDate(index) {
 // 校验时间
 const handleChangeDate = (e, index) => {
   if (e !== null) {
-    data.listDate = []
     data.form.listDate = []
     const start = proxy.hoursToSeconds(e[0])
     const end = proxy.hoursToSeconds(e[1])

+ 0 - 1
src/views/content/setting/detail.vue

@@ -367,7 +367,6 @@ function handleDeleteDate(index) {
 // 校验时间
 const handleChangeDate = (e, index) => {
   if (e !== null) {
-    data.listDate = []
     data.form.listDate = []
     const start = new Date(e[0]).getTime()
     const end = new Date(e[1]).getTime()

+ 81 - 2
src/views/store/list/index.vue

@@ -75,6 +75,16 @@
               :label="data.dialogForm.groupName ? data.dialogForm.groupName : '无'" :value="data.dialogForm.groupId" />
           </el-select>
         </el-form-item>
+        <el-form-item label="休眠时间:" prop="timeRestList">
+          <div class="time_list" v-for="(item, index) in data.timeList">
+            <el-time-picker v-model="data.timeList[index]" is-range format="HH:mm:ss" value-format="HH:mm:ss"
+              start-placeholder="开始时间" end-placeholder="结束时间" @change="handleChangeTime($event, index)" />
+            <el-link v-show="data.timeList.length > 1" icon="CircleClose" :underline="false"
+              @click="handleDeleteDate(index)" />
+            <el-link v-show="data.timeList.length - 1 === index" icon="CirclePlus" :underline="false"
+              @click="handlePushDate" />
+          </div>
+        </el-form-item>
       </el-form>
       <template #footer>
         <el-button @click="getClose">取消</el-button>
@@ -112,7 +122,11 @@ const data = reactive({
   // 列表
   tableData: [],
   // 弹窗表单
-  dialogForm: {},
+  dialogForm: {
+    timeRestList: []
+  },
+  // 休眠时间
+  timeList: [[]],
   // 地区
   areaList: [],
   // 校验
@@ -134,6 +148,9 @@ const data = reactive({
     }],
     groupId: [{
       required: true, message: '请选择门店分组', trigger: 'change'
+    }],
+    timeRestList: [{
+      type: 'array', required: true, message: '请选择休眠时间', trigger: 'change'
     }]
   }
 })
@@ -189,10 +206,53 @@ const getDetail = (id) => {
     if (res.code === 0) {
       data.dialogForm = res.data
       data.areaList = [res.data.provinceId, res.data.cityId, res.data.areaId]
+      data.timeList = []
+      res.data.timeRestList.map(i => {
+        data.timeList.push([i.startTime, i.endTime])
+      })
     }
   })
 }
 
+// 增加时间
+const handlePushDate = () => {
+  let boolean = false
+  data.timeList.map(i => boolean = i.length === 0 ? true : false)
+  if (boolean) {
+    proxy.$modal.msgError('有时间段未填')
+  } else {
+    data.timeList.push([])
+  }
+}
+
+// 删除时间
+const handleDeleteDate = (index) => {
+  data.timeList.splice(index, 1)
+}
+
+const handleChangeTime = (e, index) => {
+  if (e !== null) {
+    data.dialogForm.timeRestList = []
+    const start = proxy.hoursToSeconds(e[0])
+    const end = proxy.hoursToSeconds(e[1])
+    for (let i = 0; i < data.timeList.length; i++) {
+      if (i !== index) {
+        let st = proxy.hoursToSeconds(data.timeList[i][0])
+        let en = proxy.hoursToSeconds(data.timeList[i][1])
+        if (start >= st && start <= en || end >= st && end <= en || start <= st && end >= en) {
+          data.timeList.splice(index, 1)
+          proxy.$modal.msgError("该时间段已设置!")
+          return false
+        }
+      }
+      data.dialogForm.timeRestList.push({
+        startTime: data.timeList[i][0],
+        endTime: data.timeList[i][1]
+      })
+    }
+  }
+}
+
 // 删除
 const getDelete = (row) => {
   proxy.$modal.confirm(`是否删除门店名称为:${row.name}的数据?`).then(() => {
@@ -236,6 +296,7 @@ const getSubmit = () => {
 const getClose = () => {
   dialogVisible.value = false
   data.dialogForm = {}
+  data.timeList = [[]]
   data.areaList = []
   proxy.$refs.dialogForm.resetFields()
 }
@@ -247,4 +308,22 @@ watch(() => data.areaList, (val) => {
     data.dialogForm.areaId = val[2]
   }
 })
-</script>
+</script>
+
+<style lang="scss" scoped>
+.time_list {
+  display: flex;
+  align-items: center;
+  width: 100%;
+  margin-top: 18px;
+
+  .el-link {
+    margin-left: 10px;
+    font-size: 16px;
+  }
+}
+
+.time_list:first-child {
+  margin: 0;
+}
+</style>