Explorar el Código

1、HTML格式字符串解析与展示
2、【我发起的】【已审批】切换下一条

RaoMeng hace 6 años
padre
commit
17b6272210

+ 1 - 0
uas-office-web/wxuasapproval/src/components/approvalAdd/FormInput.jsx

@@ -97,6 +97,7 @@ export default class FormInput extends Component {
     } else if (type === 'HTML') {
       valueItem =
         <div className='form-input-value'
+             style={{ minHeight: '32px' }}
              dangerouslySetInnerHTML={{ __html: billModel.getValue() }}></div>
     } else {
       valueItem = <TextareaItem className='form-input-value' autoHeight

+ 136 - 177
uas-office-web/wxuasapproval/src/model/ApprovalBean.js

@@ -1,177 +1,136 @@
-import {isObjNull} from "../utils/common";
-
-String.prototype.endWith = function (s) {
-    if (s == null || s == "" || this.length == 0 || s.length > this.length)
-        return false;
-    if (this.substring(this.length - s.length) == s)
-        return true;
-    else
-        return false;
-    return true;
-}
-
-//yyyy-MM-dd h:m:s
-Date.prototype.format = function (fmt) {
-    let o = {
-        "M+": this.getMonth() + 1,                 //月份
-        "d+": this.getDate(),                    //日
-        "h+": this.getHours(),                   //小时
-        "m+": this.getMinutes(),                 //分
-        "s+": this.getSeconds(),                 //秒
-        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
-        "S": this.getMilliseconds()             //毫秒
-    };
-    if (/(y+)/.test(fmt))
-        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
-    for (var k in o)
-        if (new RegExp("(" + k + ")").test(fmt))
-            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
-    return fmt;
-}
-
-
-String.prototype.startWith = function (s) {
-    if (s == null || s == "" || this.length == 0 || s.length > this.length)
-        return false;
-    if (this.substr(0, s.length) == s)
-        return true;
-    else
-        return false;
-    return true;
-}
-
-
-export default function ApprovalBean(type) {
-    this.neerInput = false//是否需要输入
-    this.mustInput = false//是否是必填字段
-    this.id = -1
-    this.type = type
-    this.idKey = ''
-    this.caller = ''
-    this.gCaller = ''
-    this.coreKey = ''
-    this.dfType = ''//返回的字段类型
-    this.dbFind = ''//是否dbfind的判断
-    this.caption = '';//字幕,表示备注
-    this.values = '';//字幕对应的值显示
-    this.oldValues = '';//变更前的值
-    this.valuesKey = '';//字幕对应的值显示的key值
-    this.datas = [];
-
-    this.data2Values = function () {
-        switch (this.dfType) {
-            case 'D':
-                this.data2DType()
-                break
-            case 'B':
-                if (this.values == 1) {
-                    this.values = ApprovalBean.VALUES_YES
-                } else {
-                    this.values = ApprovalBean.VALUES_NO
-                }
-                this.setOldSelectValues()
-                break
-            case 'YN':
-                if (this.values == '-1') {
-                    this.values = ApprovalBean.VALUES_YES
-                } else if (this.values == 1 && this.type == ApprovalBean.DETAIL && this.neerInput) {
-                    this.values = ApprovalBean.VALUES_UNKNOWN
-                } else {
-                    this.values = ApprovalBean.VALUES_NO
-                }
-                this.setOldSelectValues()
-                break
-            case 'C':
-                if (this.values == '-1') {
-                    this.values = ApprovalBean.VALUES_YES
-                } else if (this.values == '1' && this.type == ApprovalBean.DETAIL && this.neerInput) {
-                    this.values = ApprovalBean.VALUES_UNKNOWN
-                } else if (this.values == '0') {
-                    this.values = ApprovalBean.VALUES_NO
-                }
-                this.setOldSelectValues()
-                break
-        }
-    }
-
-    this.isDBFind = function () {
-        return (this.dbFind == 'T' || this.dbFind == 'AT' || this.dbFind == 'M' || this.dbFind == 'DF')
-    }
-
-    this.setOldSelectValues = function () {
-        if (!isObjNull(this.oldValues)) {
-            if (this.oldValues == '0') {
-                this.oldValues = ApprovalBean.VALUES_NO
-            } else if (this.oldValues == '-1' || this.oldValues == '1') {
-                this.oldValues = ApprovalBean.VALUES_YES
-            }
-        }
-    }
-
-    this.data2DType = function () {
-        if (this.values.endWith('00:00:00')) {
-            let time = Date.parse(new Date(this.values))
-            if (time > 0) {
-                let newDate = new Date()
-                newDate.setTime(time)
-                this.values = newDate.format('yyyy-MM-dd')
-            }
-        }
-
-        if (!isObjNull(this.oldValues) && this.oldValues.endWith('00:00:00')) {
-            let time = Date.parse(new Date(this.oldValues))
-            if (time > 0) {
-                let newDate = new Date()
-                newDate.setTime(time)
-                this.oldValues = newDate.format('yyyy-MM-dd')
-            }
-        }
-    }
-
-    this.isNumber = function () {
-        return this.dfType == 'N' || this.dfType == 'floatcolumn8' || this.dfType == 'SN'
-    }
-
-    this.isSelect = function () {
-        return this.dfType == 'C' || this.dfType == 'D' || this.dfType == 'DT'
-            || this.dfType == 'C' || this.dfType == 'YN' || this.dfType == 'B'
-    }
-
-    /**
-     * 输入类型:0字符输入  1.数字输入  2.日期输入选择  3.下拉选择  4.dbfind
-     */
-    this.inputType = function () {
-        if (this.isNumber()) {
-            return 1;
-        } else if (this.dfType == "DT" || this.dfType == "D") {
-            return 2;
-        } else if (this.dfType == "C") {
-            return 3;
-        } else if (this.isDBFind()) {
-            return 4;
-        } else if (this.dfType == "B" || this.dfType == "YN") {
-            return 5;
-        }
-        return 0;
-    }
-
-}
-
-ApprovalBean.Data = function (value, display) {
-    this.value = value
-    this.display = display
-}
-
-ApprovalBean.VALUES_YES = '是'
-ApprovalBean.VALUES_NO = '否'
-ApprovalBean.VALUES_UNKNOWN = '未选择'
-
-ApprovalBean.TITLE = 11//标题
-ApprovalBean.MAIN = 12  //主表
-ApprovalBean.DETAIL = 13//从表
-ApprovalBean.SETUPTASK = 14//历史审批要点
-ApprovalBean.ENCLOSURE = 16//附件
-ApprovalBean.POINTS = 17//要点
-ApprovalBean.NODES_TAG = 18//审批节点标记
-ApprovalBean.NODES = 19//审批节点
-ApprovalBean.TAG = 20//标题
+import {isObjNull} from "../utils/common";
+
+export default function ApprovalBean(type) {
+    this.neerInput = false//是否需要输入
+    this.mustInput = false//是否是必填字段
+    this.id = -1
+    this.type = type
+    this.idKey = ''
+    this.caller = ''
+    this.gCaller = ''
+    this.coreKey = ''
+    this.dfType = ''//返回的字段类型
+    this.dbFind = ''//是否dbfind的判断
+    this.caption = '';//字幕,表示备注
+    this.values = '';//字幕对应的值显示
+    this.oldValues = '';//变更前的值
+    this.valuesKey = '';//字幕对应的值显示的key值
+    this.datas = [];
+
+    this.data2Values = function () {
+        switch (this.dfType) {
+            case 'D':
+                this.data2DType()
+                break
+            case 'B':
+                if (this.values == 1) {
+                    this.values = ApprovalBean.VALUES_YES
+                } else {
+                    this.values = ApprovalBean.VALUES_NO
+                }
+                this.setOldSelectValues()
+                break
+            case 'YN':
+                if (this.values == '-1') {
+                    this.values = ApprovalBean.VALUES_YES
+                } else if (this.values == 1 && this.type == ApprovalBean.DETAIL && this.neerInput) {
+                    this.values = ApprovalBean.VALUES_UNKNOWN
+                } else {
+                    this.values = ApprovalBean.VALUES_NO
+                }
+                this.setOldSelectValues()
+                break
+            case 'C':
+                if (this.values == '-1') {
+                    this.values = ApprovalBean.VALUES_YES
+                } else if (this.values == '1' && this.type == ApprovalBean.DETAIL && this.neerInput) {
+                    this.values = ApprovalBean.VALUES_UNKNOWN
+                } else if (this.values == '0') {
+                    this.values = ApprovalBean.VALUES_NO
+                }
+                this.setOldSelectValues()
+                break
+        }
+    }
+
+    this.isDBFind = function () {
+        return (this.dbFind == 'T' || this.dbFind == 'AT' || this.dbFind == 'M' || this.dbFind == 'DF')
+    }
+
+    this.setOldSelectValues = function () {
+        if (!isObjNull(this.oldValues)) {
+            if (this.oldValues == '0') {
+                this.oldValues = ApprovalBean.VALUES_NO
+            } else if (this.oldValues == '-1' || this.oldValues == '1') {
+                this.oldValues = ApprovalBean.VALUES_YES
+            }
+        }
+    }
+
+    this.data2DType = function () {
+        if (this.values.endWith('00:00:00')) {
+            let time = Date.parse(new Date(this.values))
+            if (time > 0) {
+                let newDate = new Date()
+                newDate.setTime(time)
+                this.values = newDate.format('yyyy-MM-dd')
+            }
+        }
+
+        if (!isObjNull(this.oldValues) && this.oldValues.endWith('00:00:00')) {
+            let time = Date.parse(new Date(this.oldValues))
+            if (time > 0) {
+                let newDate = new Date()
+                newDate.setTime(time)
+                this.oldValues = newDate.format('yyyy-MM-dd')
+            }
+        }
+    }
+
+    this.isNumber = function () {
+        return this.dfType == 'N' || this.dfType == 'floatcolumn8' || this.dfType == 'SN'
+    }
+
+    this.isSelect = function () {
+        return this.dfType == 'C' || this.dfType == 'D' || this.dfType == 'DT'
+            || this.dfType == 'C' || this.dfType == 'YN' || this.dfType == 'B'
+    }
+
+    /**
+     * 输入类型:0字符输入  1.数字输入  2.日期输入选择  3.下拉选择  4.dbfind
+     */
+    this.inputType = function () {
+        if (this.isNumber()) {
+            return 1;
+        } else if (this.dfType == "DT" || this.dfType == "D") {
+            return 2;
+        } else if (this.dfType == "C") {
+            return 3;
+        } else if (this.isDBFind()) {
+            return 4;
+        } else if (this.dfType == "B" || this.dfType == "YN") {
+            return 5;
+        }
+        return 0;
+    }
+
+}
+
+ApprovalBean.Data = function (value, display) {
+    this.value = value
+    this.display = display
+}
+
+ApprovalBean.VALUES_YES = '是'
+ApprovalBean.VALUES_NO = '否'
+ApprovalBean.VALUES_UNKNOWN = '未选择'
+
+ApprovalBean.TITLE = 11//标题
+ApprovalBean.MAIN = 12  //主表
+ApprovalBean.DETAIL = 13//从表
+ApprovalBean.SETUPTASK = 14//历史审批要点
+ApprovalBean.ENCLOSURE = 16//附件
+ApprovalBean.POINTS = 17//要点
+ApprovalBean.NODES_TAG = 18//审批节点标记
+ApprovalBean.NODES = 19//审批节点
+ApprovalBean.TAG = 20//标题

+ 284 - 242
uas-office-web/wxuasapproval/src/utils/common.js

@@ -1,242 +1,284 @@
-export function isObjNull (obj) {
-  return (obj == null || obj == undefined)
-}
-
-export function isObjEmpty (obj) {
-  return isObjNull(obj) || obj.length == 0
-}
-
-export function isEmptyObject (obj) {
-  if (isObjNull(obj)) {
-    return false
-  }
-  if (obj.length == 0) {
-    return false
-  }
-  for (var n in obj) {
-    return false
-  }
-  return true
-}
-
-export function strContain (parent, child) {
-  if (isObjEmpty(parent)) {
-    return false
-  }
-  return (parent.indexOf(child) != -1)
-}
-
-export function getStrValue (object, key) {
-  if (isObjNull(object)) {
-    return ''
-  }
-  if (isObjNull(object[key])) {
-    return ''
-  }
-  return object[key]
-}
-
-export function getIntValue (object, key) {
-  if (isObjNull(object)) {
-    return 0
-  }
-  if (isObjNull(object[key])) {
-    return 0
-  }
-  return object[key]
-}
-
-export function getTimeValue (object, key) {
-  if (isObjNull(object)) {
-    return 0
-  }
-  if (isObjNull(object[key])) {
-    return 0
-  }
-  let result = object[key]
-  if (typeof result == 'string') {
-    try {
-      let time = Date.parse(new Date(result))
-      return time
-    } catch (e) {
-      return result
-    }
-  } else {
-    return result
-  }
-}
-
-export function getArrayValue (object, key) {
-  if (isObjNull(object)) {
-    return []
-  }
-  if (isObjNull(object[key])) {
-    return []
-  }
-  return object[key]
-}
-
-export function getObjValue (object, key) {
-  if (isObjNull(object)) {
-    return {}
-  }
-  if (isObjNull(object[key])) {
-    return {}
-  }
-  return object[key]
-}
-
-/**
- * 取出中括号内的内容
- * @param text
- * @returns {string}
- */
-export function getBracketStr (text) {
-  let result = ''
-  if (isObjEmpty(text))
-    return result
-  let regex = /\[(.+?)\]/g
-  let options = text.match(regex)
-  if (!isObjEmpty(options)) {
-    let option = options[0]
-    if (!isObjEmpty(option)) {
-      result = option.substring(1, option.length - 1)
-    }
-  }
-  return result
-}
-
-/**
- * 取出小括号内的内容
- * @param text
- * @returns {string}
- */
-export function getParenthesesStr (text) {
-  let result = ''
-  if (isObjEmpty(text))
-    return result
-  let regex = /\((.+?)\)/g
-  let options = text.match(regex)
-  if (!isObjEmpty(options)) {
-    let option = options[0]
-    if (!isObjEmpty(option)) {
-      result = option.substring(1, option.length - 1)
-    }
-  }
-  return result
-}
-
-String.prototype.replaceAll = function (reg, s) {
-  if (isObjEmpty(this)) {
-    return ''
-  }
-  return this.replace(new RegExp(reg, 'gm'), s)
-}
-
-/**
- * Map转json
- * @param m
- * @returns String
- */
-export function MapToJson (m) {
-  if (isObjEmpty(m)) {
-    return ''
-  }
-  var str = '{'
-  var i = 1
-  m.forEach(function (item, key, mapObj) {
-    if (mapObj.size == i) {
-      str += '"' + key + '":"' + item + '"'
-    } else {
-      str += '"' + key + '":"' + item + '",'
-    }
-    i++
-  })
-  str += '}'
-  return str
-}
-
-/**
- * require.context(directory, useSubdirectories = false, regExp = /^\.\//);
- * 获取目标目录下符合条件的所有文件
- * @param directory 目标文件夹
- * @param useSubdirectories 是否查找子级目录
- * @param regExp 匹配文件的正则表达式
- */
-export function getDirFiles (directory, useSubdirectories, regExp) {
-  const context = require.context(directory, useSubdirectories, regExp)
-
-  return context.keys().map(context)
-}
-
-/**
- * 获取当前操作系统
- * @returns {string}
- */
-export function getOS () {
-  let os, navigator = window.navigator
-  if (navigator.userAgent.indexOf('Android') > -1 ||
-    navigator.userAgent.indexOf('Linux') > -1) {
-    os = 'Android'
-  } else if (navigator.userAgent.indexOf('iPhone') > -1 ||
-    navigator.userAgent.indexOf('iPad') > -1) {
-    os = 'iOS'
-  } else if (navigator.userAgent.indexOf('Windows Phone') > -1) {
-    os = 'WP'
-  } else {
-    os = 'Others'
-  }
-  return os
-}
-
-/**
- * 网页是否运行在移动端
- * @returns {boolean}
- */
-export function isMobile () {
-  if ((navigator.userAgent.match(
-    /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
-    return true
-  } else {
-    return false
-  }
-}
-
-/**
- * 获取sessionId
- * @returns {string}
- */
-export function getSessionId () {
-  let c_name = 'JSESSIONID'
-  if (document.cookie.length > 0) {
-    let c_start = document.cookie.indexOf(c_name + '=')
-    if (c_start != -1) {
-      let c_start = c_start + c_name.length + 1
-      let c_end = document.cookie.indexOf(';', c_start)
-      if (c_end == -1) c_end = document.cookie.length
-      return unescape(document.cookie.substring(c_start, c_end))
-    }
-  }
-}
-
-//yyyy-MM-dd hh:mm:ss
-Date.prototype.format = function (fmt) {
-  let o = {
-    'M+': this.getMonth() + 1,                 //月份
-    'd+': this.getDate(),                    //日
-    'h+': this.getHours(),                   //小时
-    'm+': this.getMinutes(),                 //分
-    's+': this.getSeconds(),                 //秒
-    'q+': Math.floor((this.getMonth() + 3) / 3), //季度
-    'S': this.getMilliseconds(),             //毫秒
-  }
-  if (/(y+)/.test(fmt))
-    fmt = fmt.replace(RegExp.$1,
-      (this.getFullYear() + '').substr(4 - RegExp.$1.length))
-  for (var k in o)
-    if (new RegExp('(' + k + ')').test(fmt))
-      fmt = fmt.replace(RegExp.$1,
-        (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(
-          ('' + o[k]).length)))
-  return fmt
-}
+export function isObjNull (obj) {
+  return (obj == null || obj == undefined)
+}
+
+export function isObjEmpty (obj) {
+  return isObjNull(obj) || obj.length == 0
+}
+
+export function isEmptyObject (obj) {
+  if (isObjNull(obj)) {
+    return false
+  }
+  if (obj.length == 0) {
+    return false
+  }
+  for (var n in obj) {
+    return false
+  }
+  return true
+}
+
+export function strContain (parent, child) {
+  if (isObjEmpty(parent)) {
+    return false
+  }
+  return (parent.indexOf(child) != -1)
+}
+
+export function getStrValue (object, key) {
+  if (isObjNull(object)) {
+    return ''
+  }
+  if (isObjNull(object[key])) {
+    return ''
+  }
+  return object[key]
+}
+
+export function getIntValue (object, key) {
+  if (isObjNull(object)) {
+    return 0
+  }
+  if (isObjNull(object[key])) {
+    return 0
+  }
+  return object[key]
+}
+
+export function getTimeValue (object, key) {
+  if (isObjNull(object)) {
+    return 0
+  }
+  if (isObjNull(object[key])) {
+    return 0
+  }
+  let result = object[key]
+  if (typeof result == 'string') {
+    try {
+      let time = Date.parse(new Date(result))
+      return time
+    } catch (e) {
+      return result
+    }
+  } else {
+    return result
+  }
+}
+
+export function getArrayValue (object, key) {
+  if (isObjNull(object)) {
+    return []
+  }
+  if (isObjNull(object[key])) {
+    return []
+  }
+  return object[key]
+}
+
+export function getObjValue (object, key) {
+  if (isObjNull(object)) {
+    return {}
+  }
+  if (isObjNull(object[key])) {
+    return {}
+  }
+  return object[key]
+}
+
+/**
+ * 取出中括号内的内容
+ * @param text
+ * @returns {string}
+ */
+export function getBracketStr (text) {
+  let result = ''
+  if (isObjEmpty(text))
+    return result
+  let regex = /\[(.+?)\]/g
+  let options = text.match(regex)
+  if (!isObjEmpty(options)) {
+    let option = options[0]
+    if (!isObjEmpty(option)) {
+      result = option.substring(1, option.length - 1)
+    }
+  }
+  return result
+}
+
+/**
+ * 取出小括号内的内容
+ * @param text
+ * @returns {string}
+ */
+export function getParenthesesStr (text) {
+  let result = ''
+  if (isObjEmpty(text))
+    return result
+  let regex = /\((.+?)\)/g
+  let options = text.match(regex)
+  if (!isObjEmpty(options)) {
+    let option = options[0]
+    if (!isObjEmpty(option)) {
+      result = option.substring(1, option.length - 1)
+    }
+  }
+  return result
+}
+
+String.prototype.replaceAll = function (reg, s) {
+  if (isObjEmpty(this)) {
+    return ''
+  }
+  return this.replace(new RegExp(reg, 'gm'), s)
+}
+
+/**
+ * Map转json
+ * @param m
+ * @returns String
+ */
+export function MapToJson (m) {
+  if (isObjEmpty(m)) {
+    return ''
+  }
+  var str = '{'
+  var i = 1
+  m.forEach(function (item, key, mapObj) {
+    if (mapObj.size == i) {
+      str += '"' + key + '":"' + item + '"'
+    } else {
+      str += '"' + key + '":"' + item + '",'
+    }
+    i++
+  })
+  str += '}'
+  return str
+}
+
+/**
+ * require.context(directory, useSubdirectories = false, regExp = /^\.\//);
+ * 获取目标目录下符合条件的所有文件
+ * @param directory 目标文件夹
+ * @param useSubdirectories 是否查找子级目录
+ * @param regExp 匹配文件的正则表达式
+ */
+export function getDirFiles (directory, useSubdirectories, regExp) {
+  const context = require.context(directory, useSubdirectories, regExp)
+
+  return context.keys().map(context)
+}
+
+/**
+ * 获取当前操作系统
+ * @returns {string}
+ */
+export function getOS () {
+  let os, navigator = window.navigator
+  if (navigator.userAgent.indexOf('Android') > -1 ||
+    navigator.userAgent.indexOf('Linux') > -1) {
+    os = 'Android'
+  } else if (navigator.userAgent.indexOf('iPhone') > -1 ||
+    navigator.userAgent.indexOf('iPad') > -1) {
+    os = 'iOS'
+  } else if (navigator.userAgent.indexOf('Windows Phone') > -1) {
+    os = 'WP'
+  } else {
+    os = 'Others'
+  }
+  return os
+}
+
+/**
+ * 网页是否运行在移动端
+ * @returns {boolean}
+ */
+export function isMobile () {
+  if ((navigator.userAgent.match(
+    /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
+    return true
+  } else {
+    return false
+  }
+}
+
+/**
+ * 获取sessionId
+ * @returns {string}
+ */
+export function getSessionId () {
+  let c_name = 'JSESSIONID'
+  if (document.cookie.length > 0) {
+    let c_start = document.cookie.indexOf(c_name + '=')
+    if (c_start != -1) {
+      let c_start = c_start + c_name.length + 1
+      let c_end = document.cookie.indexOf(';', c_start)
+      if (c_end == -1) c_end = document.cookie.length
+      return unescape(document.cookie.substring(c_start, c_end))
+    }
+  }
+}
+
+//yyyy-MM-dd hh:mm:ss
+Date.prototype.format = function (fmt) {
+  let o = {
+    'M+': this.getMonth() + 1,                 //月份
+    'd+': this.getDate(),                    //日
+    'h+': this.getHours(),                   //小时
+    'm+': this.getMinutes(),                 //分
+    's+': this.getSeconds(),                 //秒
+    'q+': Math.floor((this.getMonth() + 3) / 3), //季度
+    'S': this.getMilliseconds(),             //毫秒
+  }
+  if (/(y+)/.test(fmt))
+    fmt = fmt.replace(RegExp.$1,
+      (this.getFullYear() + '').substr(4 - RegExp.$1.length))
+  for (var k in o)
+    if (new RegExp('(' + k + ')').test(fmt))
+      fmt = fmt.replace(RegExp.$1,
+        (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(
+          ('' + o[k]).length)))
+  return fmt
+}
+
+String.prototype.endWith = function (s) {
+  if (s == null || s == '' || this.length == 0 || s.length > this.length)
+    return false
+  if (this.substring(this.length - s.length) == s)
+    return true
+  else
+    return false
+  return true
+}
+
+String.prototype.startWith = function (s) {
+  if (s == null || s == '' || this.length == 0 || s.length > this.length)
+    return false
+  if (this.substr(0, s.length) == s)
+    return true
+  else
+    return false
+  return true
+}
+
+//yyyy-MM-dd h:m:s
+Date.prototype.format = function (fmt) {
+  let o = {
+    'M+': this.getMonth() + 1,                 //月份
+    'd+': this.getDate(),                    //日
+    'h+': this.getHours(),                   //小时
+    'm+': this.getMinutes(),                 //分
+    's+': this.getSeconds(),                 //秒
+    'q+': Math.floor((this.getMonth() + 3) / 3), //季度
+    'S': this.getMilliseconds(),             //毫秒
+  }
+  if (/(y+)/.test(fmt))
+    fmt = fmt.replace(RegExp.$1,
+      (this.getFullYear() + '').substr(4 - RegExp.$1.length))
+  for (var k in o)
+    if (new RegExp('(' + k + ')').test(fmt))
+      fmt = fmt.replace(RegExp.$1,
+        (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(
+          ('' + o[k]).length)))
+  return fmt
+}