创建于2024-02-15更新于 2024-04-09
常用写法
TXS 写法
export function createSimpleTransition(name: string, origin = 'top center 0', mode?: Mode) {
return defineComponent({
name,
props: {
group: {
type: Boolean as PropType<boolean>,
default: false,
},
mode: {
type: String as PropType<Mode>,
default: mode,
},
origin: {
type: String as PropType<string>,
default: origin,
},
},
setup(props, { slots, attrs }) {
const onBeforeEnter = (el: HTMLElement) => {
el.style.transformOrigin = props.origin;
};
return () => {
const Tag = !props.group ? Transition : TransitionGroup;
return (
<Tag name={name} mode={props.mode} {...attrs} onBeforeEnter={onBeforeEnter}>
{() => getSlot(slots)}
</Tag>
);
};
},
});
}查询字典
import { initDictOptions } from '/@/utils/dict';
const dictOptions = ref<any>([]);
async function initDictConfig() {
dictOptions.value['target'] = await initDictOptions('offi_msg_target');
}缓存的设置与读取
import { MINI_ALIAS } from '/@/enums/cacheEnum';
import { createLocalStorage } from '/@/utils/cache';
const ls = createLocalStorage();
ls.set(MINI_ALIAS, '值');
ls.get(MINI_ALIAS);小程序与公众号是否授权, 未授权跳转授权页
import { useMiniAppid, useOffiAppid } from '/@/hooks/auth/useAppid';
* 小程序
useMiniAppid()
* 公众号
useOffiAppid()字典加 where
<j-search-select
v-model:value="model.templateId"
dict="cdp.mess_send_template where plat_code = 'wxgzh',title,id"
placeholder="请选择模板"
:disabled="disabledShow"
@change="handleSelectTemplate"
/>唯一值校验
import { duplicateValidate } from '/@/utils/helper/validator';
const validatorRules = {
code: [{ required: false }, { validator: codeDuplicatevalidate }],
};
async function codeDuplicatevalidate(_r, value) {
return duplicateValidate('cdp.mess_task', 'code', value, formData.id || '');
}弹框选择 api 选择字典
import { SelectorApi } from '/@/components/SelectorApi';
<SelectorApi
api="/cdptag/cdpTag/list"
rowKey="id"
:searchList="searchList"
:columns="personnelColumns"
v-model:value="value"
placeholder="请选择标签" >
</SelectorApi>
const value = ref<string>('')
const searchList = ref<any>([
{
type: 'input',
label: '标签名称',
value: 'name',
dictCode: '',
},
])
const personnelColumns = ref<any>([
{
title: '员工ID',
dataIndex: 'userId',
align: 'center',
},
])
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| api | 接口地址 post | string | |
| rowKey | 表格选中的键名 (也是返回的字段) | string | |
| rowName | input 中显示的内容 (一般做翻译使用) | string | |
| columns | 表格的表头与 ant 保持一致 | any[] | |
| searchList | 搜索框渲染 (searchListConfig) | Array | |
| v-model:value | 根据 rowKey 的字段返回,多个以逗号分割 | string | |
| placeholder | input 提示内容 | string | |
| title | 弹框标题 | string | |
| disabled | input 禁用 | boolean | |
| width | 弹窗宽度 | string | |
| btnName | 按钮名称 | string | 选择 |
| isMultiple | 是否支持选中多个 | boolean | true |
searchListConfig
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| type | 组件类型 | string | |
| label | FormItem 名字 | string | |
| value | 搜索的字段 | string | |
| dictCode | 字典 code | string |
页面信息›
已优化否