create.vue 2.6 KB
Newer Older
sunhongwei's avatar
sunhongwei committed
1 2 3 4
<template>
  <div class="app-container">
    <!-- 对话框(添加 / 修改) -->
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
Marcus's avatar
Marcus committed
5 6
        <el-form-item :label="$t('开始时间')" prop="startTime">
          <el-date-picker clearable size="small" v-model="form.startTime" type="date" value-format="timestamp" :placeholder="$t('选择开始时间')" />
sunhongwei's avatar
sunhongwei committed
7
        </el-form-item>
Marcus's avatar
Marcus committed
8 9
        <el-form-item :label="$t('结束时间')" prop="endTime">
          <el-date-picker clearable size="small" v-model="form.endTime" type="date" value-format="timestamp" :placeholder="$t('选择结束时间')" />
sunhongwei's avatar
sunhongwei committed
10
        </el-form-item>
Marcus's avatar
Marcus committed
11 12
        <el-form-item :label="$t('请假类型')" prop="type">
          <el-select v-model="form.type" :placeholder="$t('请选择')">
sunhongwei's avatar
sunhongwei committed
13 14 15
            <el-option v-for="dict in typeDictData" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
          </el-select>
        </el-form-item>
Marcus's avatar
Marcus committed
16
        <el-form-item :label="$t('原因')" prop="reason">
sunhongwei's avatar
sunhongwei committed
17
          <el-col :span="10">
Marcus's avatar
Marcus committed
18
            <el-input type="textarea" :rows="3" v-model="form.reason" :placeholder="$t('请输入原因')" />
sunhongwei's avatar
sunhongwei committed
19 20 21
          </el-col>
        </el-form-item>
        <el-form-item>
Marcus's avatar
Marcus committed
22
          <el-button type="primary" @click="submitForm">{{ $t('提 交') }}</el-button>
sunhongwei's avatar
sunhongwei committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
        </el-form-item>
      </el-form>
  </div>
</template>

<script>
import { createLeave}  from "@/api/bpm/leave"
import { getDictDatas, DICT_TYPE } from '@/utils/dict'

export default {
  name: "LeaveCreate",
  components: {
  },
  data() {
    return {
      // 表单参数
      form: {
        startTime: undefined,
        endTime: undefined,
        type: undefined,
        reason: undefined,
      },
      // 表单校验
      rules: {
Marcus's avatar
Marcus committed
47 48 49 50
        startTime: [{ required: true, message: this.$t("开始时间不能为空"), trigger: "blur" }],
        endTime: [{ required: true, message: this.$t("结束时间不能为空"), trigger: "blur" }],
        type: [{ required: true, message: this.$t("请假类型不能为空"), trigger: "change" }],
        reason: [{ required: true, message: this.$t("请假原因不能为空"), trigger: "change" }],
sunhongwei's avatar
sunhongwei committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
      },

      typeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE),
    };
  },
  created() {
  },
  methods: {
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          return;
        }

        // 添加的提交
        createLeave(this.form).then(response => {
          this.$modal.msgSuccess("发起成功");
          this.$tab.closeOpenPage({ path: "/bpm/oa/leave" });
        });
      });
    }
  }
};
</script>