<template>
  <el-dialog title="发工资延期" :visible.sync="dialogVisible" append-to-body @closed="handleClose">
    <avue-form ref="form" v-model="form" :option="option" @submit="submit"></avue-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="confirm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import { delay } from "@/api/manage/mission";

  export default {
    props: {},
    data() {
      return {
        form: {},
        id: null,
        dialogVisible: false,
        option: {
          menuBtn: false,
          column: [
            {
              type: "date",
              label: "延期到",
              span: 24,
              display: true,
              format: "yyyy-MM-dd",
              valueFormat: "yyyy-MM-dd",
              size: "small",
              prop: "expiryTime",
              pickerOptions: {
                disabledDate(time) {
                  const now = new Date().getTime();
                  return time.getTime() < now
                }
              },
              rules: [
                {
                  required: true,
                  message: "延期到必须填写",
                },
              ],
              
            },
            {
              type: "textarea",
              label: "备注",
              span: 24,
              display: true,
              size: "small",
              prop: "remarks",
            },
          ],
        },
      };
    },
    methods: {
      confirm() {
        this.$refs.form.submit();
      },
      submit(row, done) {
        delay(this.id, `${row.expiryTime} 23:59:59`, row.remarks)
          .then(() => {
            done();
            this.$message({ type: "success", message: "操作成功" });
            this.dialogVisible = false;
            this.$emit("success");
          })
          .catch(() => {
            done();
          });
      },
      handleClose() {
        this.$refs.form.resetForm();
        this.dialogVisible = false;
      },
      open(id) {
        this.id = id;
        this.dialogVisible = true;
      },
    },
    computed: {},
  };
</script>

<style>
</style>