workSetDialog.vue 9.19 KB
<template>
  <div>
    <GLDialog bigTitle="工位设置"
              :visible.sync="dialogShow"
              class="detail-content-warn"
              width="600px"
              mode="big"
              :close-on-click-modal="false"
              :before-close="handleClose"
              @onOk="handleAddConfirm"
              @onCancel="dialogShow = false">
      <div v-loading="loading">
        <div class="form_div">
          <el-form label-width="200px"
                   :model="infoForm"
                   ref="editRef"
                   :rules="formRules"
                   :inline="true">
            <el-form-item label="选择园区店:"
                          prop="yqMerchantId">
              <el-select v-model="infoForm.yqMerchantId"
                         filterable
                         placeholder="请选择"
                         class="default-width"
                         @change="inviteStationSetGet">
                <el-option v-for="(item, key) in baseData.yqMerchantList"
                           :key="key"
                           :label="item.yqMerchantName"
                           :value="item.yqMerchantId"></el-option>
              </el-select>
            </el-form-item>
            <div v-for="(item, key) in infoForm.workItem"
                 :key="key">
              <el-form-item :label="item.label"
                            :prop="'workItem.' + key + '.maxCount'"
                            :rules="formRules.maxCount">
                <el-input-number v-model="item.maxCount"
                                 placeholder="输入数值"
                                 :precision="0"
                                 :step="1"
                                 :min="0"
                                 :max="10000"
                                 class="numInput"></el-input-number>
                <span class="unit">个</span>
              </el-form-item>
            </div>
            <el-form-item label="周六施工">
              <el-switch v-model="infoForm.saturdayFlag"
                         active-value="Y"
                         inactive-value="N"></el-switch>
            </el-form-item>
            <el-form-item label="周日施工">
              <el-switch v-model="infoForm.sundayFlag"
                         active-value="Y"
                         inactive-value="N"></el-switch>
            </el-form-item>
          </el-form>
          <div class="tipsDiv">
            <div class="tipsText">
              设置门店每日每个时段可接待的客户人数, 施工时段以1个半小时为准,请合理安排施工进度
            </div>
          </div>
        </div>
      </div>
    </GLDialog>
  </div>
</template>

<script>
export default {
  name: 'WorkSetDialog',
  components: {},
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    paramsObj: {
      type: Object,
      default: null
    }
  },
  computed: {
    dialogShow: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('dialogClose', { flag: val })
      }
    }
  },
  mounted() {
    this.yqMerchantPage()
  },
  data() {
    return {
      dialogConfig: {
        config: {
          title: '工位设置',
          width: '600px'
        }
      },
      infoForm: {
        yqMerchantId: '',
        workItem: [
          {
            label: '上午 09:00-10:30',
            startTime: '09:00',
            endTime: '10:30',
            maxCount: 0
          },
          {
            label: '上午 10:30-12:00',
            startTime: '10:30',
            endTime: '12:00',
            maxCount: 0
          },
          {
            label: '下午 13:00-14:30',
            startTime: '13:00',
            endTime: '14:30',
            maxCount: 0
          },
          {
            label: '下午 14:30-16:00',
            startTime: '14:30',
            endTime: '16:00',
            maxCount: 0
          },
          {
            label: '下午 16:00-17:30',
            startTime: '16:00',
            endTime: '17:30',
            maxCount: 0
          }
        ],
        saturdayFlag: 'N',
        sundayFlag: 'N'
      },
      editChildRef: 'editChildRef',
      formRules: {
        yqMerchantId: [{ required: true, message: '请选择园区店', trigger: 'change' }],
        maxCount: [{ required: true, message: '请输入最大数量', trigger: 'blur' }]
      },
      loading: true,
      baseData: {
        yqMerchantList: []
      }
    }
  },
  methods: {
    inviteStationSetGet(yqMerchantId) {
      this.$apis.invitation.inviteStationSetGet({ yqMerchantId: yqMerchantId }).then(res => {
        console.log('res', res)
        if (res && res.length > 0) {
          res.forEach(item => {
            this.infoForm.workItem.forEach(workItem => {
              if (item.startTime === workItem.startTime && item.endTime === workItem.endTime) {
                workItem.maxCount = item.maxCount
              }
            })
            this.infoForm.saturdayFlag = item.saturdayFlag
            this.infoForm.sundayFlag = item.sundayFlag
          })
        } else {
          this.resetData() // 如果返回数据为空,则重置数据
        }
      })
    },

    resetData() {
      this.infoForm.saturdayFlag = 'N'
      this.infoForm.sundayFlag = 'N'
      this.infoForm.workItem.forEach(item => {
        item.maxCount = 0
      })
    },

    yqMerchantPage() {
      this.$apis.invitation.yqMerchantPage({ currentPage: 1, pageSize: 99999 }).then(res => {
        this.baseData.yqMerchantList = res.list
        this.loading = false
      })
    },

    handleAddConfirm() {
      this.$refs.editRef.validate(valid => {
        if (valid) {
          var params = this.$common.utils.deepClone(this.infoForm)
          params.setList = params.workItem.map(item => {
            const obj = {
              startTime: item.startTime,
              endTime: item.endTime,
              maxCount: item.maxCount,
              saturdayFlag: params.saturdayFlag,
              sundayFlag: params.sundayFlag
            }
            return obj
          })
          delete params.workItem
          delete params.saturdayFlag
          delete params.sundayFlag
          console.log('params', params)
          this.$apis.invitation.inviteStationSetUpdate(params).then(res => {
            this.$notify({
              type: 'success',
              title: '操作成功'
            })
            this.dialogShow = true
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.detail-content-warn {
  .div-title {
    width: 1040px;
    height: 30px;
    border-bottom: 1px solid #e5e5e5;
    font-size: 16px;
    font-weight: 600;
    color: #333333;
    margin: 10px 0 20px 0;
  }
  .el-icon-circle-close {
    color: #ffffff;
  }

  .form_div {
    color: #333333;
    .tipsDiv {
      display: flex;
      justify-content: center; /* 水平居中 */
      align-items: center; /* 垂直居中 */
      // flex-direction: column;
      // background: #f47f131a;
      height: 28px;
      margin-bottom: 25px;
      .tipsText {
        display: flex;
        align-items: center; /* 垂直居中 */
        // font-weight: 500;
        font-size: 13px;
        color: #888888;
      }
      .imgCla {
        margin-right: 8px;
        width: 20px;
        height: 20px;
      }
    }

    .el-form-item__content {
      display: inline-block;
      width: calc(100% - 150px);
      line-height: 24px;
    }

    .el-form-item__label {
      padding: 0;
      line-height: 24px;
    }
    .el-form-item {
      width: 100%;
      margin-bottom: 20px;
    }

    .edit-sub-block {
      // padding: 0 10px;

      .detail-txt {
        display: inline-block;
        width: 200px;
        vertical-align: bottom;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      ::v-deep .el-form-item__content {
        max-width: calc(100% - 110px);
        word-break: break-all;
      }
      .itemDiv {
        display: flex;
        .halfItem {
          width: 33%;
        }
      }
      .onLineItem {
        ::v-deep .el-form-item__content {
          max-width: 80%;
        }
      }
    }

    .edit-sub-block-two {
      .el-form-item__label {
        padding: 0;
      }
      .el-form-item {
        // width: 300px;
        margin: 0px;
      }
    }
    .busi-info {
      box-sizing: border-box;
      width: 890px;
      border-radius: 4px;
      border: 1px solid #e5e5e5;
      padding: 6px 0;
      color: #333333;
      font-size: 14px;
      margin-bottom: 14px;
      .info-row {
        height: 20px;
        line-height: 20px;
        margin-bottom: 16px;
      }
      .info-row:last-child {
        margin-bottom: 0;
      }
      .info-item {
        display: inline-block;
        width: 50%;
        height: 20px;
        line-height: 20px;
        margin-bottom: 6px;
        .item-label {
          display: inline-block;
          width: 150px;
          color: #666666;
          text-align: right;
        }
      }
    }
  }
  .receiptBtn {
    margin-left: 20px;
  }
  .imgCon {
    text-align: center;
    margin-bottom: 50px;
  }
  .imgSize {
    width: 1040px;
  }
  .default-width {
    width: 300px;
  }
  .numInput {
    width: 160px;
  }
  .unit {
    padding-left: 10px;
  }
}
</style>