<template>
  <div class="select-overspread repair-bg auto" style="padding-bottom:5px;">
    <input type="text" class="form-control" maxlength="100" v-model="f_item_value"  @change="f_item_value=replaceStr(f_item_value)" :readonly="row.readonly">
    {{getNowDate("06  1 2021 12:00AM")}}
  </div>
</template>

<script>
  import {HttpResetClass} from 'vue-client'
  import Vue from 'vue'
  export default {
    title: 'test',
    props: ['msg'],
    data () {
      return {
        f_items:[
          {"type":"string","f_item_name":"有无燃气险","checkmust":true,"f_is_defect":"","multiple":false,"isshow":true,"readonly":false,"remark":"","f_path":"","f_second_path":"","tooltip":"","f_live_dispose":"","f_else":"","index":52,"correlation":true,"correlationnum":4},
          {"type":"date","f_item_name":"切断阀购买年份","checkmust":true,"f_item_value":"","f_is_defect":"","multiple":false,"isshow":true,"readonly":false,"remark":"","f_path":"","f_second_path":"","tooltip":"","f_live_dispose":"","f_else":"","index":35,"correlation":false,"correlationnum":0}
        ],
        model: {},
        f_item_value:"",
        f_time:""
      }
    },
    ready(){
      let mydate = new Date("06  1 2021 12:00AM")
      console.log(this.getNowDate(mydate))
    },
    methods: {
      replaceStr(value){
        if(value){
          if(value.indexOf(".")==0 || ((value.split('.')).length-1)>1 || value.lastIndexOf(".")==(value.length-1)){
            return ''
          }
          return value.replace(/[^\d\.]/g,'')
        }
      },
      getNowDate (f_time) {
        let year = ''
        let month = ''
        let day = ''
        let hour = ''
        let minutes = ''
        let seconds = ''
        let mydate = new Date(f_time)
        let mymonth = mydate.getMonth() + 1
        let myday = mydate.getDate()
        let myyear = mydate.getYear()
        let myhour = mydate.getHours()
        let myminutes = mydate.getMinutes()
        let myseconds = mydate.getSeconds()
        year = (myyear > 200) ? myyear : 1900 + myyear
        month = (mymonth > 9) ? mymonth : '0' + mymonth
        day = (myday > 9) ? myday : '0' + myday
        hour = (myhour > 9) ? myhour : '0' + myhour
        minutes = (myminutes > 9) ? myminutes : '0' + myminutes
        seconds = (myseconds > 9) ? myseconds : '0' + myseconds
        // document.write("<font color=#ffffff>今天是 "+year+"年"+mymonth+"月"+myday+"日 "+weekday+"</font>");
        return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds
      },
      modify () {
        let mydate = new Date("06  1 2021 12:00AM")
        console.log(mydate)
      }
    }
  }
</script>
