{"remainingRequest":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\artfess-module\\src\\components\\datetime\\HtDate.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\artfess-module\\src\\components\\datetime\\HtDate.vue","mtime":1675232038652},{"path":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\r\nimport utils from \"@/utils.js\";\r\nimport HtFieldTail from \"@/components/HtFieldTail.vue\";\r\nexport default {\r\n  name: \"ht-date\",\r\n  props: {\r\n    currentDate:String,//当前时间\r\n    validate: [String, Object],\r\n    value: String,\r\n    name: String,\r\n    defaultTime: {\r\n      type: String,\r\n      default: \"00:00:00\",\r\n    },\r\n    permission: {\r\n      type: String,\r\n      default: \"w\",\r\n      validator: function (value) {\r\n        return [\"b\", \"w\", \"r\", \"n\"].indexOf(value) !== -1;\r\n      },\r\n    },\r\n    size: {\r\n      type: String,\r\n      default: \"small\",\r\n    },\r\n    showDate: {\r\n      type: Boolean,\r\n      default: false,\r\n    },\r\n    day: Number,\r\n    format: {\r\n      type: String,\r\n      default: \"yyyy-MM-dd HH:mm:ss\",\r\n    },\r\n    valueFormat: {\r\n      type: String,\r\n      default: \"\",\r\n    },\r\n    placeholder: String,\r\n    readonly: {\r\n      type: Boolean,\r\n      default: false,\r\n    },\r\n    clearable: {\r\n      type: Boolean,\r\n      default: true\r\n    },\r\n    disabled: {\r\n      type: Boolean,\r\n      default: false,\r\n    },\r\n    modelExpression: {\r\n      type: String,\r\n      default: \"\",\r\n    },\r\n  },\r\n  components: {\r\n    HtFieldTail,\r\n  },\r\n  watch:{\r\n    currentDate: function(newVal, oldVal) {\r\n      this.getDate(true);\r\n    }\r\n  },\r\n  data() {\r\n    return {\r\n      type: \"datetime\",\r\n      inputName: null,\r\n\t    writeable: true,\r\n      valFormat: \"\",\r\n    };\r\n  },\r\n  computed: {\r\n    dateFormat: function () {\r\n      // 通过日期格式来判断控件类型：日期、日期时间\r\n      if (/^\\w{4}-\\w{1,2}-\\w{1,2}$/.test(this.format)) {\r\n        this.type = \"date\";\r\n      }\r\n      return this.format ? this.format : this.valueFormat;\r\n    },\r\n    dateValueFormat: function () {\r\n      // 通过日期格式来判断控件类型：日期、日期时间\r\n      if (/^\\w{4}-\\w{1,2}-\\w{1,2}$/.test(this.format)) {\r\n        this.type = \"date\";\r\n      }\r\n      return this.valueFormat ? this.valueFormat : this.format;\r\n    },\r\n    inputVal: {\r\n      get: function () {\r\n        // 只读情况\r\n        if (!this.inputWriteable) {\r\n          let date = this.value;\r\n          if (this.value && this.value.constructor == String) {\r\n            let showV = this.value.replace(/\\-/g, \"/\");\r\n            return new Date(showV).format(this.dateFormat);\r\n          }\r\n          return date && date.constructor == Date\r\n            ? date.format(this.dateFormat)\r\n            : date;\r\n        }\r\n        return this.value;\r\n      },\r\n      set: function (val) {\r\n        if (val && val.constructor == Date) {\r\n          this.$emit(\"input\", val.format(this.valFormat));\r\n        } else {\r\n          this.$emit(\"input\", val);\r\n        }\r\n      },\r\n    },\r\n    inputWriteable: function () {\r\n      return this.writeable ? utils.getWriteable(this.permission):this.writeable;\r\n    },\r\n    inputValidate: function () {\r\n      return utils.addRequiredOrNot(this.permission, this.validate, this);\r\n    },\r\n  },\r\n  methods:{\r\n    getDate(flag){\r\n      this.valFormat = this.valueFormat ? this.valueFormat : this.format;\r\n      this.valFormat = this.valFormat\r\n        ? this.valFormat.replace(\"HH\", \"hh\")\r\n        : \"yyyy-MM-dd hh:mm:ss\";\r\n      //是否显示当前日期\r\n      if ((!this.value || flag) && this.showDate ) {\r\n        let curDate = null;\r\n        //判断是否传入当前时间\r\n        if(this.currentDate){\r\n          curDate = new Date(this.currentDate);\r\n        }else{\r\n          curDate = new Date();\r\n        }\r\n        if (this.day) {\r\n          //是否指定了相隔的天数\r\n          curDate = new Date(curDate.getTime() + this.day * 24 * 60 * 60 * 1000);\r\n        }\r\n        this.inputVal = curDate.format(this.valFormat);\r\n      }\r\n    }\r\n  },\r\n  created() {\r\n    this.inputName = this.name ? this.name : utils.getName();\r\n    this.$validator = this.$root.$validator;\r\n    this.getDate(false);\r\n  },\r\n};\r\n",null]}