absenteeism-rule-table.vue 4.36 KB
<template>
  <el-card class="setting-card" shadow="never">
    <div slot="header" class="card-header">
      <span>旷工规则设置</span>
      <el-button type="primary" size="mini" icon="el-icon-plus" @click="addRow">新增规则</el-button>
    </div>
    <NCC-table :data="value" border size="mini" height="340">
      <el-table-column label="最小天数(含)" min-width="120" align="left">
        <template slot-scope="scope">
          <el-input-number v-model="scope.row.minDays" :min="0" :precision="2" :step="0.5" controls-position="right" style="width: 100%" />
        </template>
      </el-table-column>
      <el-table-column label="最大天数(不含)" min-width="130" align="left">
        <template slot-scope="scope">
          <el-input-number v-model="scope.row.maxDays" :min="0" :precision="2" :step="0.5" controls-position="right" style="width: 100%" />
        </template>
      </el-table-column>
      <el-table-column label="处理方式" min-width="130" align="left">
        <template slot-scope="scope">
          <el-select v-model="scope.row.actionType" placeholder="请选择" style="width: 100%">
            <el-option v-for="item in actionTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="扣款方式" min-width="140" align="left">
        <template slot-scope="scope">
          <el-select v-model="scope.row.deductMode" :disabled="scope.row.actionType === 2" placeholder="请选择" style="width: 100%">
            <el-option v-for="item in deductModeOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="扣款值" min-width="110" align="left">
        <template slot-scope="scope">
          <el-input-number v-model="scope.row.deductValue" :disabled="scope.row.actionType === 2" :min="0" :precision="2" controls-position="right" style="width: 100%" />
        </template>
      </el-table-column>
      <el-table-column label="展示说明" min-width="220" align="left">
        <template slot-scope="scope">
          <el-input v-model="scope.row.actionText" placeholder="例如:超过3天视为自离" />
        </template>
      </el-table-column>
      <el-table-column label="备注" min-width="180" align="left">
        <template slot-scope="scope">
          <el-input v-model="scope.row.remark" placeholder="无" />
        </template>
      </el-table-column>
      <el-table-column label="操作" width="110" align="left">
        <template slot-scope="scope">
          <el-popconfirm
            title="确认删除当前配置吗?"
            confirm-button-text="确认删除"
            cancel-button-text="取消"
            @confirm="removeRow(scope.$index)"
          >
            <el-button slot="reference" type="text" class="danger-text">删除</el-button>
          </el-popconfirm>
        </template>
      </el-table-column>
    </NCC-table>
    <div class="table-tip">提示:最大天数留空表示无上限;若处理方式为“视为自离”,扣款方式和扣款值可留空。</div>
    <el-empty v-if="!value.length" :image-size="56" description="暂无旷工规则配置" />
  </el-card>
</template>

<script>
export default {
  name: 'AbsenteeismRuleTable',
  props: {
    value: {
      type: Array,
      default: () => []
    },
    deductModeOptions: {
      type: Array,
      default: () => []
    },
    actionTypeOptions: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    addRow() {
      this.$emit('input', [
        ...this.value,
        {
          minDays: 0.5,
          maxDays: null,
          actionType: 1,
          deductMode: 2,
          deductValue: 1,
          actionText: '',
          remark: ''
        }
      ])
    },
    removeRow(index) {
      const list = this.value.slice()
      list.splice(index, 1)
      this.$emit('input', list)
    }
  }
}
</script>

<style lang="scss" scoped>
.setting-card {
  border-radius: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.table-tip {
  margin-top: 8px;
  color: #909399;
  font-size: 12px;
}

.danger-text {
  color: #f56c6c;
}

::v-deep .el-card__header {
  padding: 12px 16px;
}

::v-deep .el-card__body {
  padding: 12px 14px;
}
</style>