1
0
mirror of synced 2025-11-06 11:20:40 +08:00

增加 quarter 类型、修复数据校验问题

This commit is contained in:
xuliangzhan
2021-04-28 10:35:21 +08:00
parent 86a3d01760
commit cbb4a689ae
11 changed files with 62 additions and 51 deletions

View File

@@ -76,6 +76,9 @@ export default defineComponent({
sex2: [
{ required: true, message: '性别必须填写' }
],
age: [
{ type: 'number', min: 10, max: 100000, message: '输入 10 ~ 100000 范围' }
],
date: [
{ required: true, message: '日期必须填写' }
]
@@ -258,6 +261,9 @@ export default defineComponent({
sex2: [
{ required: true, message: '性别必须填写' }
],
age: [
{ type: 'number', min: 10, max: 100000, message: '输入 10 ~ 100000 范围' }
],
date: [
{ required: true, message: '日期必须填写' }
]

View File

@@ -240,7 +240,6 @@ gulp.task('move_docs_root', () => {
gulp.task('clear_docs_temp', () => {
return del([
'docs/static',
'../branches/docs/vxe-table/docs'
], { force: true })
})

View File

@@ -273,7 +273,7 @@
},
"vxe-table/empty-render": {
"type": "any",
"description": "空内容渲染配置项"
"description": "空内容渲染配置项empty-render 的优先级大于 empty-text"
},
"vxe-table/custom-config": {
"type": "any",
@@ -961,7 +961,7 @@
},
"vxe-grid/empty-render": {
"type": "any",
"description": "空内容渲染配置项"
"description": "空内容渲染配置项empty-render 的优先级大于 empty-text"
},
"vxe-grid/custom-config": {
"type": "any",
@@ -1329,11 +1329,11 @@
},
"vxe-input/min-date": {
"type": "number | string | date",
"description": "只对 type=date|datetime|week|month|year 有效,设置日期可选范围的最小值"
"description": "只对 type=date|datetime|week|month|quarter|year 有效,设置日期可选范围的最小值"
},
"vxe-input/max-date": {
"type": "number | string | date",
"description": "只对 type=date|datetime|week|month|year 有效,设置日期可选范围的最大值"
"description": "只对 type=date|datetime|week|month|quarter|year 有效,设置日期可选范围的最大值"
},
"vxe-input/start-week": {
"type": "number | string",
@@ -1341,27 +1341,27 @@
},
"vxe-input/label-format": {
"type": "string",
"description": "只对 type=date|datetime|week|month|year 有效,输入框中显示的日期格式"
"description": "只对 type=date|datetime|week|month|quarter|year 有效,输入框中显示的日期格式"
},
"vxe-input/value-format": {
"type": "string",
"description": "只对 type=date|datetime|week|month|year 有效,绑定值的返回格式,默认返回 Date 类型,如果指定格式则返回字符串"
"description": "只对 type=date|datetime|week|month|quarter|year 有效,绑定值的返回格式,默认返回 Date 类型,如果指定格式则返回字符串"
},
"vxe-input/editable": {
"type": "boolean",
"description": "只对 type=date|time|datetime|week|month|year 有效,文本框是否允许输入"
"description": "只对 type=date|time|datetime|week|month|quarter|year 有效,文本框是否允许输入"
},
"vxe-input/disabled-method": {
"type": "({ date, viewtype }) => boolean",
"description": "只对 type=date|datetime|week|month|year 有效,该方法的返回值用来决定该日期是否允许选中"
"description": "只对 type=date|datetime|week|month|quarter|year 有效,该方法的返回值用来决定该日期是否允许选中"
},
"vxe-input/festival-method": {
"type": "({ date, viewtype }) => any",
"description": "只对 type=date|datetime|week|month|year 有效,该方法用于返回对应日期显示的节日"
"description": "只对 type=date|datetime|week|month|quarter|year 有效,该方法用于返回对应日期显示的节日"
},
"vxe-input/transfer": {
"type": "boolean",
"description": "只对 type=date|time|datetime|week|month|year 有效,是否将弹框容器插入于 body 内(对于嵌入到表格或者弹窗中被遮挡时需要设置为 true"
"description": "只对 type=date|time|datetime|week|month|quarter|year 有效,是否将弹框容器插入于 body 内(对于嵌入到表格或者弹窗中被遮挡时需要设置为 true"
},
"vxe-select/model-value": {
"type": "any",
@@ -1643,6 +1643,10 @@
"type": "boolean",
"description": "标题是否标显示最大化与还原按钮"
},
"vxe-modal/show-close": {
"type": "boolean",
"description": "是否显示关闭按钮"
},
"vxe-modal/resize": {
"type": "boolean",
"description": "是否允许窗口边缘拖动调整窗口大小"

View File

@@ -538,6 +538,7 @@
"mask-closable",
"esc-closable",
"show-zoom",
"show-close",
"resize",
"duration",
"width",

View File

@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "4.0.15-beta.0",
"version": "4.0.15-beta.2",
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟滚动、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、虚拟列表、模态窗口、自定义模板、渲染器、贼灵活的配置项、扩展接口等...",
"scripts": {
"serve": "vue-cli-service serve",

View File

@@ -35,20 +35,20 @@ const validErrorRuleValue = (rule: VxeFormDefines.FormRule, val: any) => {
const isNumType = type === 'number'
const numVal = isNumType ? XEUtils.toNumber(val) : XEUtils.getSize(val)
// 判断数值
if (isNumType) {
return isNaN(val)
if (isNumType && isNaN(val)) {
return true
}
// 如果存在 min判断最小值
if (!XEUtils.eqNull(min)) {
return numVal < XEUtils.toNumber(min)
if (!XEUtils.eqNull(min) && numVal < XEUtils.toNumber(min)) {
return true
}
// 如果存在 max判断最大值
if (!XEUtils.eqNull(max)) {
return numVal > XEUtils.toNumber(max)
if (!XEUtils.eqNull(max) && numVal > XEUtils.toNumber(max)) {
return true
}
// 如果存在 pattern正则校验
if (pattern) {
return !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val)
if (pattern && !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val)) {
return true
}
return false
}

View File

@@ -50,7 +50,7 @@ interface DateHourMinuteSecondItem {
const yearSize = 20
const monthSize = 20
const quarterSize = 12
const quarterSize = 8
function toStringTimeDate (str: VxeInputPropTypes.ModelValue) {
if (str) {
@@ -417,7 +417,7 @@ export default defineComponent({
const currQuarter = getDateQuarter(currentDate)
const firstYear = XEUtils.getWhatYear(selectMonth, 0, 'first')
const selFullYear = firstYear.getFullYear()
for (let index = -4; index < quarterSize - 4; index++) {
for (let index = -2; index < quarterSize - 2; index++) {
const date = XEUtils.getWhatQuarter(firstYear, index)
const itemFullYear = date.getFullYear()
const itemQuarter = getDateQuarter(date)

View File

@@ -230,20 +230,20 @@ const validatorHook: VxeGlobalHooksHandles.HookOptions = {
const isNumType = type === 'number'
const numVal = isNumType ? XEUtils.toNumber(val) : XEUtils.getSize(val)
// 判断数值
if (isNumType) {
return isNaN(val)
if (isNumType && isNaN(val)) {
return true
}
// 如果存在 min判断最小值
if (!XEUtils.eqNull(min)) {
return numVal < XEUtils.toNumber(min)
if (!XEUtils.eqNull(min) && numVal < XEUtils.toNumber(min)) {
return true
}
// 如果存在 max判断最大值
if (!XEUtils.eqNull(max)) {
return numVal > XEUtils.toNumber(max)
if (!XEUtils.eqNull(max) && numVal > XEUtils.toNumber(max)) {
return true
}
// 如果存在 pattern正则校验
if (pattern) {
return !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val)
if (pattern && !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val)) {
return true
}
return false
}

View File

@@ -24,44 +24,44 @@
<body>
<p>两步快速演示问题:</p>
<div>
<div>1.将代码示例放到以下任意一个在线链接中,运行起来(点击 fork确保能复现问题最后点击保存将链接发群里即可</div>
<div style="color:red">(注提供可复现问题简化demo即可不需要提供其他无关的代码)</div>
<div>1.将代码示例放到以下任意一个公开的在线链接中,运行起来(点击 fork确保能复现问题最后点击保存将链接发群里即可</div>
<ul>
<li>
<a href="https://codesandbox.io/s/vxe-table-wentiyanshi-forked-54v2j" target="_blank">v4 codesandbox支持jsx</a>
<a href="https://codesandbox.io/s/vxe-table-wentiyanshi-forked-54v2j" target="_blank">v4.x codesandbox支持jsx</a>
</li>
<li>
<a href="https://jsrun.net/K5IKp/edit" target="_blank">v4 jsrun</a>
<a href="https://jsrun.net/K5IKp/edit" target="_blank">v4.x jsrun</a>
</li>
<li>
<a href="https://jsrun.net/CT3Kp/edit" target="_blank">v4 jsrun集成 element-plus</a>
<a href="https://jsrun.net/CT3Kp/edit" target="_blank">v4.x jsrun集成 element-plus</a>
</li>
<li>
<a href="https://jsrun.net/nT3Kp/edit" target="_blank">v4 jsrun集成 ant-design-vue</a>
<a href="https://jsrun.net/nT3Kp/edit" target="_blank">v4.x jsrun集成 ant-design-vue</a>
</li>
<li>
<a href="https://jsfiddle.net/9qoghkbj/" target="_blank">v4 jsfiddle</a>
<a href="https://jsfiddle.net/9qoghkbj/" target="_blank">v4.x jsfiddle</a>
</li>
</ul>
<div style="color:red;font-size: 22px;font-weight: bold;">(注:只需提供复现问题简单 Demo不能放其他无关的代码</div>
<ul>
<li>
<a href="https://codesandbox.io/s/vue-template-916h0" target="_blank">v3 codesandbox支持jsx</a>
<a href="https://codesandbox.io/s/vue-template-916h0" target="_blank">v3.x codesandbox支持jsx</a>
</li>
<li>
<a href="https://jsrun.pro/vIyKp/edit" target="_blank">v3 jsrun</a>
<a href="https://jsrun.pro/vIyKp/edit" target="_blank">v3.x jsrun</a>
</li>
<li>
<a href="https://jsrun.net/4BLKp/edit" target="_blank">v3 jsrun集成 element-ui</a>
<a href="https://jsrun.net/4BLKp/edit" target="_blank">v3.x jsrun集成 element-ui</a>
</li>
<li>
<a href="https://jsrun.net/KRLKp/edit" target="_blank">v3 jsrun集成 iview</a>
<a href="https://jsrun.net/KRLKp/edit" target="_blank">v3.x jsrun集成 iview</a>
</li>
<li>
<a href="https://jsrun.net/pRLKp/edit" target="_blank">v3 jsrun集成 ant-design-vue</a>
<a href="https://jsrun.net/pRLKp/edit" target="_blank">v3.x jsrun集成 ant-design-vue</a>
</li>
<li>
<a href="https://jsfiddle.net/qsmtja6x/" target="_blank">v3 jsfiddle</a>
<a href="https://jsfiddle.net/qsmtja6x/" target="_blank">v3.x jsfiddle</a>
</li>
</ul>
<div>2.将问题步骤与浏览器环境描述清楚即可</div>

View File

@@ -93,10 +93,13 @@
border-radius: $vxe-border-radius;
box-shadow: 0 1px 6px rgba(0,0,0,.2);
.vxe-custom--header {
padding: 0.28em 0;
font-weight: 700;
border-bottom: 1px solid $vxe-table-popup-border-color;
}
.vxe-custom--body {
padding: 0.2em 0;
max-height: 17.6em;
.vxe-custom--option {
&:hover {
background-color: $vxe-table-row-hover-background-color;
@@ -105,11 +108,9 @@
}
.vxe-custom--header,
.vxe-custom--body {
padding: 0.2em 0;
max-height: 17.6em;
& > li {
max-width: 16em;
min-width: 10em;
min-width: 12.5em;
padding: 0.2em 1em 0.2em 2.3em;
@for $i from 2 through 8 {
$interval: $i - 1 + 0.2;
@@ -124,11 +125,11 @@
}
.vxe-custom--footer {
border-top: 1px solid $vxe-table-popup-border-color;
padding: 0.45em 0.4em;
text-align: right;
button {
background-color: transparent;
width: 50%;
height: 2.5em;
border: 0;
color: $vxe-font-color;
text-align: center;

View File

@@ -194,10 +194,10 @@ $vxe-input-date-month-year-row-height-default: 48px;
$vxe-input-date-month-year-row-height-medium: 46px;
$vxe-input-date-month-year-row-height-small: 44px;
$vxe-input-date-month-year-row-height-mini: 42px;
$vxe-input-date-quarter-row-height-default: 38px;
$vxe-input-date-quarter-row-height-medium: 36px;
$vxe-input-date-quarter-row-height-small: 34px;
$vxe-input-date-quarter-row-height-mini: 32px;
$vxe-input-date-quarter-row-height-default: 60px;
$vxe-input-date-quarter-row-height-medium: 58px;
$vxe-input-date-quarter-row-height-small: 56px;
$vxe-input-date-quarter-row-height-mini: 54px;
$vxe-input-height-default: $vxe-button-height-default;
$vxe-input-height-medium: $vxe-button-height-medium;
$vxe-input-height-small: $vxe-button-height-small;