Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Sep 24, 2022
1 parent e00ab34 commit a47297a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.history
node_modules
/dist
package-lock.json
Expand Down
6 changes: 4 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const rename = require('gulp-rename')
const replace = require('gulp-replace')
const sass = require('gulp-sass')
const dartSass = require('sass')
const gulpSass = require('gulp-sass')
const sass = gulpSass(dartSass)
const cleanCSS = require('gulp-clean-css')
const prefixer = require('gulp-autoprefixer')
const sourcemaps = require('gulp-sourcemaps')
Expand All @@ -16,7 +18,7 @@ const exportModuleName = 'VXETablePluginAntd'

gulp.task('build_style', function () {
return gulp.src('style.scss')
.pipe(sass())
.pipe(sass(dartSass))
.pipe(prefixer({
borwsers: ['last 1 version', '> 1%', 'not ie <= 8'],
cascade: true,
Expand Down
60 changes: 27 additions & 33 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function getEditOns (renderOpts: VxeGlobalRendererHandles.RenderOptions, params:
const { $table, row, column } = params
return getOns(renderOpts, params, (value: any) => {
// 处理 model 值双向绑定
XEUtils.set(row, column.property, value)
XEUtils.set(row, column.field, value)
}, () => {
// 处理 change 事件相关逻辑
$table.updateStatus(params)
Expand All @@ -113,10 +113,10 @@ function getFilterOns (renderOpts: VxeGlobalRendererHandles.RenderOptions, param
}

function getItemOns (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: FormItemContentRenderParams) {
const { $form, data, property } = params
const { $form, data, field } = params
return getOns(renderOpts, params, (value: any) => {
// 处理 model 值双向绑定
XEUtils.set(data, property, value)
XEUtils.set(data, field, value)
}, () => {
// 处理 change 事件相关逻辑
$form.updateStatus(params)
Expand Down Expand Up @@ -147,7 +147,7 @@ function getSelectCellValue (renderOpts: VxeColumnPropTypes.EditRender, params:
const labelProp = optionProps.label || 'label'
const valueProp = optionProps.value || 'value'
const groupOptions = optionGroupProps.options || 'options'
const cellValue = XEUtils.get(row, column.property)
const cellValue = XEUtils.get(row, column.field)
if (!isEmptyValue(cellValue)) {
return XEUtils.map(props.mode === 'multiple' ? cellValue : [cellValue], optionGroups
? (value) => {
Expand All @@ -171,7 +171,7 @@ function getSelectCellValue (renderOpts: VxeColumnPropTypes.EditRender, params:
function getCascaderCellValue (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.ExportMethodParams) {
const { props = {} } = renderOpts
const { row, column } = params
const cellValue = XEUtils.get(row, column.property)
const cellValue = XEUtils.get(row, column.field)
const values = cellValue || []
const labels: Array<any> = []
matchCascaderData(0, props.options, values, labels)
Expand All @@ -181,7 +181,7 @@ function getCascaderCellValue (renderOpts: VxeGlobalRendererHandles.RenderOption
function getRangePickerCellValue (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.RenderEditParams) {
const { props = {} } = renderOpts
const { row, column } = params
let cellValue = XEUtils.get(row, column.property)
let cellValue = XEUtils.get(row, column.field)
if (cellValue) {
cellValue = XEUtils.map(cellValue, (date: any) => date.format(props.format || 'YYYY-MM-DD')).join(' ~ ')
}
Expand All @@ -192,7 +192,7 @@ function getTreeSelectCellValue (renderOpts: VxeGlobalRendererHandles.RenderOpti
const { props = {} } = renderOpts
const { treeData, treeCheckable } = props
const { row, column } = params
const cellValue = XEUtils.get(row, column.property)
const cellValue = XEUtils.get(row, column.field)
if (!isEmptyValue(cellValue)) {
return XEUtils.map(treeCheckable ? cellValue : [cellValue], (value) => {
const matchObj = XEUtils.findTree(treeData, (item: any) => item.value === value, { children: 'children' })
Expand All @@ -205,18 +205,18 @@ function getTreeSelectCellValue (renderOpts: VxeGlobalRendererHandles.RenderOpti
function getDatePickerCellValue (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.ExportMethodParams, defaultFormat: string) {
const { props = {} } = renderOpts
const { row, column } = params
let cellValue = XEUtils.get(row, column.property)
let cellValue = XEUtils.get(row, column.field)
if (cellValue) {
cellValue = cellValue.format(props.format || defaultFormat)
}
return cellValue
}

function createEditRender (defaultProps?: { [key: string]: any }) {
return function (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderEditParams) {
return function (renderOpts: VxeColumnPropTypes.EditRender & { name: string }, params: VxeGlobalRendererHandles.RenderEditParams) {
const { row, column } = params
const { name, attrs } = renderOpts
const cellValue = XEUtils.get(row, column.property)
const cellValue = XEUtils.get(row, column.field)
return [
h(resolveComponent(name), {
...attrs,
Expand Down Expand Up @@ -247,7 +247,7 @@ function defaultButtonsEditRender (renderOpts: VxeColumnPropTypes.EditRender, pa
}

function createFilterRender (defaultProps?: { [key: string]: any }) {
return function (renderOpts: VxeColumnPropTypes.FilterRender, params: VxeGlobalRendererHandles.RenderFilterParams) {
return function (renderOpts: VxeColumnPropTypes.FilterRender & { name: string }, params: VxeGlobalRendererHandles.RenderFilterParams) {
const { column } = params
const { name, attrs } = renderOpts
return [
Expand Down Expand Up @@ -281,7 +281,7 @@ function handleConfirmFilter (params: VxeGlobalRendererHandles.RenderFilterParam
function defaultFuzzyFilterMethod (params: VxeGlobalRendererHandles.FilterMethodParams) {
const { option, row, column } = params
const { data } = option
const cellValue = XEUtils.get(row, column.property)
const cellValue = XEUtils.get(row, column.field)
return XEUtils.toValueString(cellValue).indexOf(data) > -1
}

Expand All @@ -292,7 +292,7 @@ function defaultFuzzyFilterMethod (params: VxeGlobalRendererHandles.FilterMethod
function defaultExactFilterMethod (params: VxeGlobalRendererHandles.FilterMethodParams) {
const { option, row, column } = params
const { data } = option
const cellValue = XEUtils.get(row, column.property)
const cellValue = XEUtils.get(row, column.field)
/* eslint-disable eqeqeq */
return cellValue === data
}
Expand All @@ -316,11 +316,11 @@ function renderOptions (options: any[], optionProps: VxeGlobalRendererHandles.Re
}

function createFormItemRender (defaultProps?: { [key: string]: any }) {
return function (renderOpts: FormItemRenderOptions, params: FormItemContentRenderParams) {
const { data, property } = params
return function (renderOpts: FormItemRenderOptions & { name: string }, params: FormItemContentRenderParams) {
const { data, field } = params
const { name } = renderOpts
const { attrs } = renderOpts
const itemValue = XEUtils.get(data, property)
const itemValue = XEUtils.get(data, field)
return [
h(resolveComponent(name), {
...attrs,
Expand Down Expand Up @@ -356,25 +356,25 @@ function defaultButtonsItemRender (renderOpts: FormItemRenderOptions, params: Fo
function createDatePickerExportMethod (defaultFormat: string) {
return function (params: VxeGlobalRendererHandles.ExportMethodParams) {
const { row, column, options } = params
return options && options.original ? XEUtils.get(row, column.property) : getDatePickerCellValue(column.editRender || column.cellRender, params, defaultFormat)
return options && options.original ? XEUtils.get(row, column.field) : getDatePickerCellValue(column.editRender || column.cellRender, params, defaultFormat)
}
}

function createExportMethod (getExportCellValue: Function) {
return function (params: VxeGlobalRendererHandles.ExportMethodParams) {
const { row, column, options } = params
return options && options.original ? XEUtils.get(row, column.property) : getExportCellValue(column.editRender || column.cellRender, params)
return options && options.original ? XEUtils.get(row, column.field) : getExportCellValue(column.editRender || column.cellRender, params)
}
}

function createFormItemRadioAndCheckboxRender () {
return function (renderOpts: FormItemRenderOptions, params: FormItemContentRenderParams) {
return function (renderOpts: FormItemRenderOptions & { name: string }, params: FormItemContentRenderParams) {
const { name, options = [], optionProps = {} } = renderOpts
const { data, property } = params
const { data, field } = params
const { attrs } = renderOpts
const labelProp = optionProps.label || 'label'
const valueProp = optionProps.value || 'value'
const itemValue = XEUtils.get(data, property)
const itemValue = XEUtils.get(data, field)
return [
h(resolveComponent(`${name}Group`) as ComponentOptions, {
...attrs,
Expand Down Expand Up @@ -434,12 +434,6 @@ function handleClearEvent (params: VxeGlobalInterceptorHandles.InterceptorClearF
}
}

declare module 'vxe-table' {
interface DefineRendererOption<T> {
defaultFilterMethod?(params: VxeGlobalRendererHandles.FilterMethodParams): boolean;
}
}

/**
* 基于 vxe-table 表格的适配插件,用于兼容 ant-design-vue 组件库
*/
Expand Down Expand Up @@ -477,7 +471,7 @@ export const VXETablePluginAntd = {
const { options = [], optionGroups, optionProps = {}, optionGroupProps = {} } = renderOpts
const { row, column } = params
const { attrs } = renderOpts
const cellValue = XEUtils.get(row, column.property)
const cellValue = XEUtils.get(row, column.field)
const props = getCellEditFilterProps(renderOpts, params, cellValue)
const ons = getEditOns(renderOpts, params)
if (optionGroups) {
Expand Down Expand Up @@ -573,9 +567,9 @@ export const VXETablePluginAntd = {
defaultFilterMethod (params) {
const { option, row, column } = params
const { data } = option
const { property, filterRender: renderOpts } = column
const { field, filterRender: renderOpts } = column
const { props = {} } = renderOpts
const cellValue = XEUtils.get(row, property)
const cellValue = XEUtils.get(row, field)
if (props.mode === 'multiple') {
if (XEUtils.isArray(cellValue)) {
return XEUtils.includeArrays(cellValue, data)
Expand All @@ -587,9 +581,9 @@ export const VXETablePluginAntd = {
},
renderItemContent (renderOpts, params) {
const { options = [], optionGroups, optionProps = {}, optionGroupProps = {} } = renderOpts
const { data, property } = params
const { data, field } = params
const { attrs } = renderOpts
const itemValue = XEUtils.get(data, property)
const itemValue = XEUtils.get(data, field)
const props = getItemProps(renderOpts, params, itemValue)
const ons = getItemOns(renderOpts, params)
if (optionGroups) {
Expand Down Expand Up @@ -694,7 +688,7 @@ export const VXETablePluginAntd = {
class: 'vxe-table--filter-antd-wrapper'
}, column.filters.map((option, oIndex) => {
const optionValue = option.data
return h(name, {
return h(name as string, {
key: oIndex,
...attrs,
...getCellEditFilterProps(renderOpts, params, optionValue),
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table-plugin-antd",
"version": "3.0.5",
"version": "3.0.6",
"description": "基于 vxe-table 表格的适配插件,用于兼容 ant-design-vue 组件库",
"scripts": {
"lib": "gulp build"
Expand Down Expand Up @@ -48,12 +48,12 @@
"markdown-doctest": "^1.1.0",
"prettier": "^2.1.2",
"typescript": "^4.0.5",
"vue": "^3.2.14",
"vxe-table": "^4.0.30",
"xe-utils": "^3.4.0"
"vue": "^3.2.37",
"vxe-table": "^4.3.5",
"xe-utils": "^3.5.6"
},
"peerDependencies": {
"vxe-table": "^4.0.30"
"vxe-table": "^4.2.0"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit a47297a

Please sign in to comment.