vue+ant-design小结

在项目中遇到的一些常规操作,此处总结一些

(因为用到xueyi,可能部分更适用于xueyi)

1.table相关的

1.1 columns
export const columns: BasicColumn[] = [{
		title: '使用对象',
		dataIndex: 'applyType',
		customRender: ({
			record
		}) => {
			const data = record
			return dictConversion(dict.applyType, data.applyType)
		},
	},

	{
		title: '发起时间',
		dataIndex: 'startTime',
		width: 200,
		ellipsis: true,
		customRender: ({
			record
		}) => {
			const data: any = record
			if (data.startTime) {
				return formatToDate(data.startTime, 'YYYY-MM-DD HH:mm:ss')
			} else {
				return ''
			}
		},
	},
	{
      title: '查看详情',
      width: 100,
      dataIndex: 'b',
      customRender: ({ text, record, index, column }) => {
      		return h('a', { onClick: () => viewImage(record) }, '查看')
  		},
    },
]
可编辑
  {
    title: '功能名称',
    dataIndex: 'funcUrl',
    editRow: true,
    editComponent:'Select',
    editComponentProps:{
      options:dict.CUSTOM_HOME
    }
  },
{
  title: '资源名称',
  dataIndex: 'resourceName',
  editRow: true,
  width: 200,
  editComponent: 'Input',
  editComponentProps: (record) => {
    return {
      suffix: h(SearchOutlined, {
        onClick() {
          QEclick()
        },
      }),
      onClick() {
        QEclick()
      },
      readonly: true,
    }
  },
},

1.2查询条件
/** 查询条件 */
export const searchFormSchema: FormSchema[] = [{
		label: '使用对象',
		field: 'applyType',
		component: 'Select',
		componentProps: {
			options: dict.applyType,
			optionFilterProp: 'label',
		},
		colProps: {
			span: 6
		},
	},
	{
		label: '数据日期',
		field: 'targetDate',
		component: 'DatePicker',
		colProps: {
			span: 6
		},
		componentProps: () => {
			return {
				valueFormat: 'YYYY-MM-DD',
			}
		},
		rules: [{
			required: true,
			message: '数据日期为必填项',
		}, ],
	},
	{
		label: '查询范围',
		field: 'queryRangeOrg',
		component: 'RadioGroup',
		colProps: {
			span: 6
		},
		componentProps: ({
			formModel,
			formActionType
		}) => {
			return {
				options: [{
					label: '本机构归属',
					value: '12',
				}],
			}
		},
	},
	{
		label: '机构',
		field: 'orgNames',
		component: 'Input',
		colProps: {
			span: 6
		},
		componentProps: () => {
			return {
				onClick: () => {
					openModalOrg(true, {})
				},
				onChange: (e) => {
					if (e.target.value == '' && e.type == 'click') {
						orgNos.value = ''
					}
				},
				readOnly: true,
			}
		},
		renderComponentContent: ({
			model,
			field
		}) => {
			return {
				suffix: () =>
					h(
						SearchOutlined, {
							value: model[field],
							onclick: () => {
								openModalOrg(true, {})
							},
						},
						'',
					),
			}
		},
	},
]

查询条件使用插槽

配置模块 
{
	label: '得分区间',
	field: 'paramStart',
	component: 'Input',
	colProps: {
		span: 6
	},
	slot: 'inputRange'
}
页面模块
<template #form - inputRange = "{ model }" >
	<a - input v - model: value = "model.paramStart"style = "width: 40%": disabled = "isUpdate" > < /a-input> 
        <span style = "width: 20%" > - < /span>
	<a - input v - model: value = "model.paramEnd"style = "width: 40%": disabled = "isUpdate" > < /a-input> 
</template>

2.Form相关

2.1description修改
{
	label: '客户英文名',
	field: 'cer',
	labelStyle: {
		textAlign: 'right'
	},
	render: (val, data) => {
		return !type.value ?
			val :
			h(Input, {
				placeholder: '请输入',
				value: val,
				onChange: (e: ChangeEvent) => {
					info.value.area = e.target.value
				},
			})
	},
}, {
	label: '是否',
	field: 'whe',
	labelStyle: {
		textAlign: 'right'
	},
	render: (val, data) => {
		return h(Checkbox, {
				checked: true,
				disabled: true,
			})
	},
}, {
	label: '主营业务',
	field: 'indu',
	labelStyle: {
		textAlign: 'right'
	},
	span: 2,
	render: (val, data) => {
		return h(Textarea, {
				value: val,
			})
	},
},

2.2 配置使用插槽
<template #assetsBal="{ model }">
   <a-input
     v-model:value="model.assetsBalStart"
     style="width: 45%"
   ></a-input>
   <span style="display: inline-block; width: 10%; text-align: center"
     >-</span
   >
   <a-input
     v-model:value="model.assetsBalEnd"
     style="width: 45%"
   ></a-input>
</template>


配置模块
 {
   label: '资产余额',
   field: 'assetsBal',
   component: 'Input',
   colProps: { span: 12 },
   slot: 'assetsBal',
},
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要在Vue3中使用Ant Design Vue的样式,可以按照以下步骤进行操作: 1. 首先,在你的项目中安装Ant Design Vue组件库。你可以通过npm或者yarn进行安装,具体的安装命令可以在Ant Design Vue的官方文档中找到。 2. 在你的Vue组件中引入Ant Design Vue的样式文件。你可以在组件所在的Vue文件中使用import语句引入Ant Design Vue的样式文件。 例如,在你的Vue文件中添加以下代码: ```javascript <style lang="less" scoped> @import '~ant-design-vue/dist/antd.less'; </style> ``` 这将会导入Ant Design Vue的样式文件,并使它只在当前组件中生效。 3. 接下来,你可以根据需要自定义你的组件样式。你可以在style标签中使用普通的CSS语法来定义和修改组件的样式。 例如,你可以在style标签中添加以下代码来自定义一个按钮组件的样式: ```javascript <style lang="less" scoped> .my-button { border-radius: 10px; } </style> ``` 这将会给按钮组件添加一个圆角为10px的边框样式。 通过以上步骤,你就可以在Vue3中使用Ant Design Vue的样式了。记得按照官方文档中的指引导入需要的组件,并在模板中使用它们。如果你需要更多示例和帮助,可以参考官方文档或者Ant Design Vue的开源项目。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [vue3+ant design vue+ts实战【ant-design-vue组件库引入】](https://blog.csdn.net/XSL_HR/article/details/127396384)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [vue3+ant-design-vue按需加载组件](https://blog.csdn.net/qq_42263570/article/details/130143934)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [vue3+element-plus的后台管理系统模板 和 vue3+ant-design-vue的后台管理系统模板](https://blog.csdn.net/qq_61233877/article/details/131008600)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值