<template>
  <view class="page">
    <u-navbar
      title="请假申请"
      back-icon-color="#FFFFFF"
      title-color="#FFFFFF"
      leftText="返回"
      :autoBack="true"
      :placeholder="true"
    />
    <view class="view-forms">
      <uni-forms
        ref="valiForm"
        :rules="rules"
        :modelValue="valiFormData"
        label-position="top"
      >
        <uni-forms-item label="请假类型" name="">
          <uni-data-select
            v-model="value"
            :localdata="rangeSelect"
            @change="changeSelect"
            label="请假类型"
          />
        </uni-forms-item>
        <uni-forms-item label="开始时间" name="">
          <uni-data-select
            v-model="value"
            :localdata="rangeSelect"
            @change="changeSelect"
            label="开始时间"
          />
        </uni-forms-item>
        <uni-forms-item label="结束时间" name="">
          <uni-data-select
            v-model="value"
            :localdata="rangeSelect"
            @change="changeSelect"
            label="结束时间"
          />
        </uni-forms-item>
        <uni-forms-item label="时长(小时)" name="">
          <uni-easyinput
            v-model="valiFormData.age"
            placeholder="请输入时长(小时)"
          />
        </uni-forms-item>
        <uni-forms-item label="请假原因" name="">
          <uni-easyinput
            type="textarea"
            v-model="valiFormData.introduction"
            placeholder="请输入请假原因"
          />
        </uni-forms-item>
      </uni-forms>
    </view>

    <view class="footer">
      <button class="btn-add" @click="submit('valiForm')">提交</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      rangeSelect: [
        { value: 0, text: "一级" },
        { value: 1, text: "二级" },
        { value: 2, text: "三级" },
      ],
      // 校验表单数据
      valiFormData: {
        name: "",
        age: "",
        introduction: "",
      },
      // 校验规则
      rules: {},
    };
  },
  computed: {},
  onLoad() {},
  onReady() {},
  methods: {
    changeSelect(e) {},
    submit(ref) {
      this.$refs[ref]
        .validate()
        .then((res) => {
          console.log("success", res);
          uni.showToast({
            title: `校验通过`,
          });
        })
        .catch((err) => {
          console.log("err", err);
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.view-forms {
  padding: 30rpx 20rpx 240rpx 20rpx;

  /deep/.uni-forms-item__label {
    background-image: url("@/static/images/umale/icon_ind.png");
    background-size: 100%;
    background-position: bottom;
    background-repeat: no-repeat;
    height: auto;
    & > text {
      line-height: 0;
    }
    & > text {
      font-size: 30rpx;
      font-family: PingFang SC-Bold, PingFang SC;
      // font-weight: bold;
      color: #2e2f31;
    }

    & > .is-required {
      color: #dd524d;
      font-weight: bold;
    }
  }

  /deep/ .uni-easyinput {
    margin-top: 19rpx;
    background: #ffffff;
    box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
    border-radius: 16rpx;
  }

  /deep/ .uni-stat-box {
    margin-top: 19rpx;
    background: #ffffff;
    box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
    border-radius: 16rpx;
  }
}
.footer {
  position: fixed;
  bottom: 0;
  z-index: 1;
  width: 100%;
  background: #ffffff;
  border: 1px solid #dce3ec;
  padding: 18rpx 28rpx 60rpx 28rpx;
  .btn-add {
    font-size: 36rpx;
    font-family: PingFang SC-Medium, PingFang SC;
    height: 88rpx;
    background: linear-gradient(90deg, #3976f1 0%, #3ca0f6 100%);
    border-radius: 16rpx;
    color: #ffffff;
  }
}
</style>
