|
|
@@ -1,7 +1,10 @@
|
|
|
import { VxeUI } from 'vxe-pc-ui';
|
|
|
import dayjs from 'dayjs';
|
|
|
-import { get, isEmpty } from 'lodash';
|
|
|
+import { get, has, isEmpty, isFunction } from 'lodash';
|
|
|
import { formatMoney, formatPercentage } from '/@/components/BsUi/uitl.js';
|
|
|
+import { DISPLAY_STATE } from '/@/components/BsUi/constant.js';
|
|
|
+import { DeleteOutlined, EditOutlined, EyeOutlined, PlusOutlined } from '@ant-design/icons-vue';
|
|
|
+import { h } from 'vue';
|
|
|
|
|
|
const getValue = (params) => {
|
|
|
const { column, row } = params;
|
|
|
@@ -29,7 +32,7 @@ VxeUI.renderer.add('CellDate', {
|
|
|
// 默认显示模板
|
|
|
renderTableDefault(renderOpts, params) {
|
|
|
if (isEmpty(getValue(params))) return <></>;
|
|
|
- return <>{ dayjs(getValue(params)).format('YYYY-MM-DD') }</>
|
|
|
+ return <>{dayjs(getValue(params)).format('YYYY-MM-DD')}</>;
|
|
|
},
|
|
|
});
|
|
|
|
|
|
@@ -37,17 +40,61 @@ VxeUI.renderer.add('CellDate', {
|
|
|
VxeUI.renderer.add('CellDateTime', {
|
|
|
// 默认显示模板
|
|
|
renderTableDefault(renderOpts, params) {
|
|
|
- if (isEmpty(getValue(params))) return <></>;
|
|
|
- return <>{ dayjs(getValue(params)).format('YYYY-MM-DD HH:mm:ss') }</>
|
|
|
+ if (isEmpty(getValue(params))) return <></>;
|
|
|
+ return <>{dayjs(getValue(params)).format('YYYY-MM-DD HH:mm:ss')}</>;
|
|
|
},
|
|
|
});
|
|
|
|
|
|
-
|
|
|
// 字典渲染
|
|
|
VxeUI.renderer.add('CellDict', {
|
|
|
// 默认显示模板
|
|
|
renderTableDefault(renderOpts, params) {
|
|
|
if (isEmpty(getValue(params))) return <></>;
|
|
|
- return <>{ getValue(params)[0].valueName || '' }</>
|
|
|
+ return <>{getValue(params)[0].valueName || ''}</>;
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+// 字典渲染
|
|
|
+VxeUI.renderer.add('CellOption', {
|
|
|
+ // 默认显示模板
|
|
|
+ renderTableDefault(renderOpts, params) {
|
|
|
+ const { extraProps } = renderOpts;
|
|
|
+ const { row, column } = params;
|
|
|
+
|
|
|
+ const { buttons } = extraProps;
|
|
|
+ const visibleBtn = buttons.filter(
|
|
|
+ (v) => !has(v, 'display') || (isFunction(v.display) && v.display(params) === DISPLAY_STATE.VISIBLE) || v.display === DISPLAY_STATE.VISIBLE
|
|
|
+ );
|
|
|
+ column.title = '操作';
|
|
|
+ column.width = 'auto';
|
|
|
+
|
|
|
+ const iconMap = {
|
|
|
+ add: h(PlusOutlined),
|
|
|
+ edit: h(EditOutlined),
|
|
|
+ delete: h(DeleteOutlined),
|
|
|
+ view: h(EyeOutlined),
|
|
|
+ };
|
|
|
+
|
|
|
+ return (
|
|
|
+ <a-space>
|
|
|
+ {visibleBtn.map((v) => {
|
|
|
+ const disabled = has(v, 'disabled') && isFunction(v.disabled) ? v.disabled(params) : v.props?.disabled;
|
|
|
+ return (
|
|
|
+ <a-button
|
|
|
+ style={{ padding: '0' }}
|
|
|
+ type='link'
|
|
|
+ onClick={() => {
|
|
|
+ v?.onClick(params);
|
|
|
+ }}
|
|
|
+ disabled={disabled}
|
|
|
+ icon={iconMap[v?.code]}
|
|
|
+ {...v.extraProps}
|
|
|
+ >
|
|
|
+ {v.title}
|
|
|
+ </a-button>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </a-space>
|
|
|
+ );
|
|
|
},
|
|
|
});
|