Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Feb 24, 2020
1 parent 5160bf6 commit 622aea8
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ VXETable.use(VXETablePluginAntd)

| 属性 | 描述 | 类型 | 可选值 | 默认值 |
|------|------|-----|-----|-----|
| name | 支持的渲染组件 | String | AInput, AAutocomplete, AInputNumber, ASwitch, ARate ||
| name | 支持的渲染组件 | String | AInput, AAutocomplete, AInputNumber, ASwitch, ARate, AButton, AButtons ||
| props | 渲染组件附加属性,参数请查看被渲染的 Component props | Object || {} |
| options | 只对 name=ASelect 有效,下拉组件选项列表 | Array || [] |
| optionProps | 只对 name=ASelect 有效,下拉组件选项属性参数配置 | Object || { value: 'value', label: 'label', disabled: 'disabled' } |
Expand All @@ -43,7 +43,7 @@ VXETable.use(VXETablePluginAntd)

| 属性 | 描述 | 类型 | 可选值 | 默认值 |
|------|------|-----|-----|-----|
| name | 支持的渲染组件 | String | AInput, AAutocomplete, AInputNumber, ASelect, ACascader, ADatePicker, AMonthPicker, ARangePicker, AWeekPicker, ATimePicker, ATreeSelect, ASwitch, ARate ||
| name | 支持的渲染组件 | String | AInput, AAutocomplete, AInputNumber, ASelect, ACascader, ADatePicker, AMonthPicker, ARangePicker, AWeekPicker, ATimePicker, ATreeSelect, ASwitch, ARate, AButton, AButtons ||
| props | 渲染组件附加属性,参数请查看被渲染的 Component props | Object || {} |
| options | 只对 name=ASelect 有效,下拉组件选项列表 | Array || [] |
| optionProps | 只对 name=ASelect 有效,下拉组件选项属性参数配置 | Object || { value: 'value', label: 'label', disabled: 'disabled' } |
Expand All @@ -67,7 +67,7 @@ VXETable.use(VXETablePluginAntd)

| 属性 | 描述 | 类型 | 可选值 | 默认值 |
|------|------|-----|-----|-----|
| name | 支持的渲染组件 | String | AInput, AAutocomplete, AInputNumber, ASelect, ASwitch, ARate, ARadio, ACheckbox ||
| name | 支持的渲染组件 | String | AInput, AAutocomplete, AInputNumber, ASelect, ASwitch, ARate, ARadio, ACheckbox, AButton, AButtons ||
| props | 渲染组件附加属性,参数请查看被渲染的 Component props | Object || {} |
| options | 只对 name=ASelect 有效,下拉组件选项列表 | Array || [] |
| optionProps | 只对 name=ASelect 有效,下拉组件选项属性参数配置 | Object || { value: 'value', label: 'label', disabled: 'disabled' } |
Expand Down
52 changes: 47 additions & 5 deletions dist/index.common.js

Large diffs are not rendered by default.

50 changes: 46 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,22 @@
};
}

function defaultButtonEditRender(h, renderOpts, params) {
var attrs = renderOpts.attrs;
var props = getProps(params, renderOpts);
return [h('a-button', {
attrs: attrs,
props: props,
on: getCellEvents(renderOpts, params)
}, cellText(h, renderOpts.content))];
}

function defaultButtonsEditRender(h, renderOpts, params) {
return renderOpts.children.map(function (childRenderOpts) {
return defaultButtonEditRender(h, childRenderOpts, params)[0];
});
}

function getFilterEvents(on, renderOpts, params) {
var events = renderOpts.events;

Expand Down Expand Up @@ -328,7 +344,7 @@
property = params.property;
var name = renderOpts.name;
var attrs = renderOpts.attrs;
var props = getFormProps(params, renderOpts, defaultProps);
var props = getFormItemProps(params, renderOpts, defaultProps);
return [h(name, {
attrs: attrs,
props: props,
Expand All @@ -343,7 +359,23 @@
};
}

function getFormProps(_ref4, _ref5, defaultProps) {
function defaultButtonItemRender(h, renderOpts, params) {
var attrs = renderOpts.attrs;
var props = getFormItemProps(params, renderOpts);
return [h('a-button', {
attrs: attrs,
props: props,
on: getFormEvents(renderOpts, params)
}, cellText(h, props.content))];
}

function defaultButtonsItemRender(h, renderOpts, params) {
return renderOpts.children.map(function (childRenderOpts) {
return defaultButtonItemRender(h, childRenderOpts, params)[0];
});
}

function getFormItemProps(_ref4, _ref5, defaultProps) {
var $form = _ref4.$form;
var props = _ref5.props;
return _xeUtils["default"].assign($form.vSize ? {
Expand Down Expand Up @@ -416,7 +448,7 @@
var data = params.data,
property = params.property;
var attrs = renderOpts.attrs;
var props = getFormProps(params, renderOpts);
var props = getFormItemProps(params, renderOpts);
var labelProp = optionProps.label || 'label';
var valueProp = optionProps.value || 'value';
var disabledProp = optionProps.disabled || 'disabled';
Expand Down Expand Up @@ -619,7 +651,7 @@
var data = params.data,
property = params.property;
var attrs = renderOpts.attrs;
var props = getFormProps(params, renderOpts);
var props = getFormItemProps(params, renderOpts);

if (optionGroups) {
var groupOptions = optionGroupProps.options || 'options';
Expand Down Expand Up @@ -732,6 +764,16 @@
},
ACheckbox: {
renderItem: createFormItemRadioAndCheckboxRender()
},
AButton: {
renderEdit: defaultButtonEditRender,
renderDefault: defaultButtonEditRender,
renderItem: defaultButtonItemRender
},
AButtons: {
renderEdit: defaultButtonsEditRender,
renderDefault: defaultButtonsEditRender,
renderItem: defaultButtonsItemRender
}
};
/**
Expand Down
2 changes: 1 addition & 1 deletion dist/index.min.js

Large diffs are not rendered by default.

50 changes: 46 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ function createEditRender (defaultProps?: any) {
}
}

function defaultButtonEditRender (h: Function, renderOpts: any, params: any) {
const { attrs } = renderOpts
const props: any = getProps(params, renderOpts)
return [
h('a-button', {
attrs,
props,
on: getCellEvents(renderOpts, params)
}, cellText(h, renderOpts.content))
]
}

function defaultButtonsEditRender (h: Function, renderOpts: any, params: any) {
return renderOpts.children.map((childRenderOpts: any) => defaultButtonEditRender(h, childRenderOpts, params)[0])
}

function getFilterEvents (on: any, renderOpts: any, params: any) {
let { events } = renderOpts
if (events) {
Expand Down Expand Up @@ -230,7 +246,7 @@ function createFormItemRender (defaultProps?: any) {
let { data, property } = params
let { name } = renderOpts
let { attrs }: any = renderOpts
let props: any = getFormProps(params, renderOpts, defaultProps)
let props: any = getFormItemProps(params, renderOpts, defaultProps)
return [
h(name, {
attrs,
Expand All @@ -247,7 +263,23 @@ function createFormItemRender (defaultProps?: any) {
}
}

function getFormProps ({ $form }: any, { props }: any, defaultProps?: any) {
function defaultButtonItemRender (h: Function, renderOpts: any, params: any) {
const { attrs } = renderOpts
const props: any = getFormItemProps(params, renderOpts)
return [
h('a-button', {
attrs,
props,
on: getFormEvents(renderOpts, params)
}, cellText(h, props.content))
]
}

function defaultButtonsItemRender (h: Function, renderOpts: any, params: any) {
return renderOpts.children.map((childRenderOpts: any) => defaultButtonItemRender(h, childRenderOpts, params)[0])
}

function getFormItemProps ({ $form }: any, { props }: any, defaultProps?: any) {
return XEUtils.assign($form.vSize ? { size: $form.vSize } : {}, defaultProps, props)
}

Expand Down Expand Up @@ -301,7 +333,7 @@ function createFormItemRadioAndCheckboxRender () {
let { name, options, optionProps = {} } = renderOpts
let { data, property } = params
let { attrs } = renderOpts
let props: any = getFormProps(params, renderOpts)
let props: any = getFormItemProps(params, renderOpts)
let labelProp: string = optionProps.label || 'label'
let valueProp: string = optionProps.value || 'value'
let disabledProp: string = optionProps.disabled || 'disabled'
Expand Down Expand Up @@ -485,7 +517,7 @@ const renderMap = {
let { options, optionGroups, optionProps = {}, optionGroupProps = {} } = renderOpts
let { data, property } = params
let { attrs } = renderOpts
let props: any = getFormProps(params, renderOpts)
let props: any = getFormItemProps(params, renderOpts)
if (optionGroups) {
let groupOptions: string = optionGroupProps.options || 'options'
let groupLabel: string = optionGroupProps.label || 'label'
Expand Down Expand Up @@ -604,6 +636,16 @@ const renderMap = {
},
ACheckbox: {
renderItem: createFormItemRadioAndCheckboxRender()
},
AButton: {
renderEdit: defaultButtonEditRender,
renderDefault: defaultButtonEditRender,
renderItem: defaultButtonItemRender
},
AButtons: {
renderEdit: defaultButtonsEditRender,
renderDefault: defaultButtonsEditRender,
renderItem: defaultButtonsItemRender
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table-plugin-antd",
"version": "1.6.5",
"version": "1.7.0",
"description": "基于 vxe-table 表格的适配插件,用于兼容 ant-design-vue 组件库",
"scripts": {
"lib": "gulp build"
Expand Down

0 comments on commit 622aea8

Please sign in to comment.