licp
2024-07-24 fb32a170f337d0e3be35cc6c1b0b5aee11d67259
修改班次设置
已修改1个文件
53 ■■■■ 文件已修改
src/components/view/b3-classes.vue 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/view/b3-classes.vue
@@ -151,20 +151,12 @@
    <div v-loading="configTimeVisibleLoading" ></div>
    <div v-if="!configTimeVisibleLoading">
      <div v-for="(item, index) in timeQuery">
        <div class="form_title">
          <span>{{`班次${transFromNumber(index + 1)}`}}</span>
          <span style="margin-right: 10px">
          <i class="el-icon-circle-check" v-if="item.isEdit" style="margin-left: 10px; color: #4b79f2" @click="saveEdit(item, index)"></i>
          <i class="el-icon-edit" v-if="!item.isEdit" style="margin-left: 10px; color: #4b79f2" @click="item.isEdit = true"></i>
          <i class="el-icon-delete" v-if="!item.isEdit && timeQuery.length > 1" style="margin-left: 10px; color: #FF4902" @click="deleteTime(item, index)"></i>
        </span>
        </div>
        <div class="form">
          <div style="margin-bottom: 12px">
        <div class="form" style="display: flex;justify-content: space-between">
          <div style="margin-bottom: 12px;width: 200px;">
            <span class="form_label">班次:</span>
            <span v-if="!item.isEdit"> {{item.type}} </span>
            <span class="form_input" v-if="item.isEdit">
            <el-select v-model="item.shift" placeholder="请选择" style="width: 70%;" clearable size="small">
            <el-select v-model="item.shift" placeholder="请选择" style="width: 70%;margin-right: 8px;" clearable size="small">
              <el-option v-for="obj in timeTypeList"
                         :key="obj.value"
                         :label="obj.label"
@@ -173,12 +165,12 @@
            </el-select>
          </span>
          </div>
          <div>
          <div style="width: calc(100% - 260px);">
            <span class="form_label">时间:</span>
            <span v-if="!item.isEdit"> {{item.time === null ? '' : item.time[0] + '~' + item.time[1]}} </span>
            <span class="form_input" v-if="item.isEdit">
            <el-time-picker
              style="width: 70%;"
              style="width: 200px;"
              is-range
              size="small"
              v-model="item.time"
@@ -191,9 +183,14 @@
            </el-time-picker>
          </span>
          </div>
          <el-divider></el-divider>
          <span>
            <i class="el-icon-circle-check" v-if="item.isEdit" style="margin-left: 10px; color: #4b79f2;cursor: pointer;" @click="saveEdit(item, index)"></i>
            <i class="el-icon-edit" v-if="!item.isEdit" style="margin-left: 10px; color: #4b79f2;cursor: pointer;" @click="item.isEdit = true"></i>
            <i class="el-icon-delete" v-if=" timeQuery.length > 1" style="margin-left: 10px; color: #FF4902;cursor: pointer;" @click="deleteTime(item, index)"></i>
          </span>
        </div>
        <div @click="addTimeForm" style="color: #4b79f2" v-if="index === timeQuery.length - 1">添加时间配置</div>
        <el-divider></el-divider>
        <div @click="addTimeForm" style="color: #4b79f2;cursor: pointer;" v-if="index === timeQuery.length - 1">添加时间配置</div>
      </div>
      <div @click="addTimeForm" style="color: #4b79f2" v-if="timeQuery.length === 0">添加时间配置</div>
    </div>
@@ -624,6 +621,7 @@
        if (res.data.length > 0) {
          res.data.forEach(item => {
            item.isEdit = false
            item.time = []
            item.time.push(item.startTime)
            item.time.push(item.endTime)
            const index = this.timeTypeList.findIndex(val => val.value === item.shift)
@@ -654,6 +652,7 @@
          item.type = this.timeTypeList[index].label
        }
      }
      delete item.orderBy
      const isEmpty = this.isObjectEmpty(item)
      if (isEmpty) {
        this.$message.error('请填写完整')
@@ -677,21 +676,21 @@
      }).then(res => {
        if (res.code == 201) return
        this.$message.success('操作成功')
        this.getTimeList()
      })
      this.getTimeList()
    },
    deleteTime (item, index) {
      this.$axios.post(this.$api.performanceShift.shiftRemove, {
        id: item.id
      },{
        headers: {
          'Content-Type': 'application/json'
        }
      }).then(res => {
        if (res.code == 201) return
        this.$message.success('操作成功')
      })
      this.getTimeList()
      if(item.id){
          this.$axios.post(this.$api.performanceShift.shiftRemove, {
          id: item.id
        }).then(res => {
          if (res.code == 201) return
          this.$message.success('操作成功')
          this.getTimeList()
        })
      }else{
        this.timeQuery.splice(index, 1)
      }
    },
    isObjectEmpty(obj) {
      return Object.keys(obj).some(key => !obj[key]);