sopItem.vue 3.87 KB
<!--
 * @Author: yangming yangming@didihu.com.cn
 * @Date: 2023-12-25 14:31:26
 * @LastEditors: yangming yangming@didihu.com.cn
 * @LastEditTime: 2024-01-15 15:19:05
 * @FilePath: \scrm-micro-peregrination\src\views\journeyModel\components\sopItem.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AEVid
-->
<template>
  <el-drawer title="编辑" :visible.sync="drawerVisible" direction="rtl" :before-close="handleClose" size="720px">
    <div class="drawer-body">
      <div class="sop-item flex-column-center">
        <label>*</label>
        <span>请设置营销时间:</span>
        <el-input-number v-model="day" :min="1" :max="999" :size="size"></el-input-number>
        <span>天后,当日</span>
        <el-time-picker :picker-options="rangeStart" v-model="time" :size="size" format="HH:mm" value-format="HH:mm"></el-time-picker>
        <span>发送</span>
      </div>
      <div class="sop-item flex">
        <label>*</label>
        <span>请选择触达方式:</span>
        <div class="select-panel">
          <div class="select-item" v-for="item in modelList" :key="item.id">
            <div class="select-value">
              <el-radio v-model="nodeKey" :label="item.id">{{ item.nodeName }}</el-radio>
            </div>
            <div class="select-desc">
              {{ item.desc }}
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="demo-drawer__footer">
      <el-button @click="handleClose" :size="size">取消</el-button>
      <el-button type="primary" @click="saveForm" :size="size">保存</el-button>
    </div>
  </el-drawer>
</template>
<script>
export default {
  props: {
    drawerVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      rangeStart: {
        selectableRange: '09:00:00 - 22:00:00' // 09:00:00 - 22:00:00的时间才可以选择
      },
      nodeKey: '',
      day: 0,
      time: '09:00',
      list: [],
      modelList: []
    }
  },
  inject: ['app'],
  watch: {
    drawerVisible(val) {
      if (val) {
        this.time = '09:00'
        this.getModelList()
      }
    }
  },
  methods: {
    getModelList() {
      this.$apis.journeyModel.SopTplNodeProtosList({ dataTypeCode: this.app.dataTypeCode, groupCode: 'notify' }).then(res => {
        this.modelList = res
      })
    },
    showError(message) {
      this.$message({
        type: 'error',
        message
      })
    },
    saveForm() {
      if (!this.day) {
        return this.showError('请设置营销时间')
      }
      if (!this.time) {
        return this.showError('请设置营销时间')
      }
      if (!this.nodeKey) {
        return this.showError('请选择触达方式')
      }
      const model = {
        time: this.time,
        day: this.day,
        nodeProtoId: this.nodeKey
      }
      this.$emit('closeDrawer', model)
    },
    setForm(val) {
      const { day, time, taskType } = val
      this.day = day
      this.time = time
      this.nodeKey = taskType
    },
    handleClose() {
      this.$emit('closeDrawer')
    },
    SopTplNodeProtosList() {
      this.$apis.journeyModel.SopTplNodeProtosList({}).then(res => {
        this.list = res
      })
    }
  }
}
</script>
<style scoped lang="scss">
.drawer-body {
  padding: 30px;
  height: calc(100vh - 140px);
  .sop-item {
    font-size: 14px;
    color: #333333;
    margin-bottom: 20px;
    > label {
      color: #eb4e4e;
    }
    .select-item {
      margin-bottom: 20px;
      .select-value {
        font-size: 14px;
        color: #333333;
        span {
          margin-left: -35px;
        }
      }
      .select-desc {
        font-size: 12px;
        color: #999999;
        line-height: 24px;
        margin-left: 20px;
      }
    }
  }
}
.demo-drawer__footer {
  text-align: right;
  padding: 10px;
}
</style>