diff --git a/src/api/login.js b/src/api/login.js deleted file mode 100644 index 461d7628..00000000 --- a/src/api/login.js +++ /dev/null @@ -1,17 +0,0 @@ -import server from '@/utils/request' - -export const config = () => server.get(`/authorize/captcha/config`) - -export const code = () => server.get(`/authorize/captcha/image?width=130&height=30`) - -export const authLogin = (data) => server.post(`/authorize/login`, data) - -export const getInitSet = () => server.get(`/user/settings/init`) - -export const postInitSet = (data) => server.post(`/user/settings/init`, data) - -export const systemVersion = () => server.get(`/system/version`) - -export const bindInfo = () => server.get(`/application/sso/_all`) - -export const settingDetail = (scopes) => server.get(`/system/config/${scopes}`) \ No newline at end of file diff --git a/src/api/login.ts b/src/api/login.ts new file mode 100644 index 00000000..33684901 --- /dev/null +++ b/src/api/login.ts @@ -0,0 +1,49 @@ +import server from '@/utils/request' + +/** + * 获取验证码配置 + * @returns + */ +export const config = () => server.get(`/authorize/captcha/config`) + +/** + * 获取验证码图片 + * @returns + */ +export const code = () => server.get(`/authorize/captcha/image?width=130&height=30`) + +/** + * 登录 + * @returns + */ +export const authLogin = (data: any) => server.post(`/authorize/login`, data) + +/** + * 查询初始化配置信息 + * @returns + */ +export const getInitSet = () => server.get(`/user/settings/init`) + +/** + * 创建初始化配置信息 + * @returns + */ +export const postInitSet = (data: any) => server.post(`/user/settings/init`, data) + +/** + * 查询系统版本信息 + * @returns + */ +export const systemVersion = () => server.get(`/system/version`) + +/** + * 获取支持的SSO的应用 + * @returns + */ +export const bindInfo = () => server.get(`/application/sso/_all`) + +/** + * 查询配置信息 + * @returns + */ +export const settingDetail = (scopes: string) => server.get(`/system/config/${scopes}`) \ No newline at end of file diff --git a/src/api/notice/config.ts b/src/api/notice/config.ts index 9ed55cf8..d6e29cc5 100644 --- a/src/api/notice/config.ts +++ b/src/api/notice/config.ts @@ -1,4 +1,4 @@ -import { patch, post, get } from '@/utils/request' +import { patch, post, get, remove } from '@/utils/request' export default { // 列表 @@ -8,5 +8,30 @@ export default { // 新增 save: (data: any) => post(`/notifier/config`, data), // 修改 - update: (data: any) => patch(`/notifier/config`, data) + update: (data: any) => patch(`/notifier/config`, data), + del: (id: string) => remove(`/notifier/config/${id}`), + getTemplate: (data: any, id: string) => post(`/notifier/template/${id}/_query`, data), + getTemplateDetail: (id: string) => get(`/notifier/template/${id}/detail`), + debug: (data: any, configId: string, templateId: string) => post(`/notifier/${configId}/${templateId}/_send`, data), + getHistory: (data: any, id: string) => post(`/notify/history/config/${id}/_query`, data), + // 获取所有平台用户 + getPlatformUsers: () => post(`/user/_query/no-paging`, { paging: false }), + // 钉钉部门 + dingTalkDept: (id: string) => get(`/notifier/dingtalk/corp/${id}/departments/tree`), + // 钉钉部门人员 + getDingTalkUsers: (configId: string, deptId: string) => get(`/notifier/dingtalk/corp/${configId}/${deptId}/users`), + // 钉钉已经绑定的人员 + getDingTalkBindUsers: (id: string) => get(`/user/third-party/dingTalk_dingTalkMessage/${id}`), + // 钉钉绑定用户 + dingTalkBindUser: (data: any, id: string) => patch(`/user/third-party/dingTalk_dingTalkMessage/${id}`, data), + // 微信部门 + weChatDept: (id: string) => get(`/notifier/wechat/corp/${id}/departments`), + // 微信部门人员 + getWeChatUsers: (configId: string, deptId: string) => get(`/notifier/wechat/corp/${configId}/${deptId}/users`), + // 微信已经绑定的人员 + getWeChatBindUsers: (id: string) => get(`/user/third-party/weixin_corpMessage/${id}`), + // 微信绑定用户 + weChatBindUser: (data: any, id: string) => patch(`/user/third-party/weixin_corpMessage/${id}`, data), + // 解绑 + unBindUser: (data: any, id: string) => post(`/user/third-party/${id}/_unbind`, data) } \ No newline at end of file diff --git a/src/api/notice/template.ts b/src/api/notice/template.ts index b49dbd8b..7281501f 100644 --- a/src/api/notice/template.ts +++ b/src/api/notice/template.ts @@ -1,4 +1,5 @@ -import { patch, post, get } from '@/utils/request' +import { patch, post, get, remove } from '@/utils/request' +import { BindConfig } from '@/views/notice/Template/types' export default { // 列表 @@ -8,5 +9,19 @@ export default { // 新增 save: (data: any) => post(`/notifier/template`, data), // 修改 - update: (data: any) => patch(`/notifier/template`, data) + update: (data: any) => patch(`/notifier/template`, data), + del: (id: any) => remove(`/notifier/template/${id}`), + getConfig: (data: any) => post(`/notifier/config/_query/no-paging?paging=false`, data), + getTemplateDetail: (id: string) => get(`/notifier/template/${id}/detail`), + debug: (data: any, configId: string, templateId: string) => post(`/notifier/${configId}/${templateId}/_send`, data), + getHistory: (data: any, id: string) => post(`/notify/history/template/${id}/_query`, data), + // 钉钉/微信, 根据配置获取部门和用户 + getDept: (type: string, id: string) => get(`/notifier/${type}/corp/${id}/departments`), + getUser: (type: string, id: string) => get(`/notifier/${type}/corp/${id}/users`), + // 微信获取标签推送 + getTags: (id: string) => get(`/notifier/wechat/corp/${id}/tags`), + // 语音/短信获取阿里云模板 + getAliTemplate: (id: string) => get(`/notifier/sms/aliyun/${id}/templates`), + // 短信获取签名 + getSigns: (id: string) => get(`/notifier/sms/aliyun/${id}/signs`) } \ No newline at end of file diff --git a/src/components/AIcon/index.tsx b/src/components/AIcon/index.tsx index 5f359a30..7d51d1ba 100644 --- a/src/components/AIcon/index.tsx +++ b/src/components/AIcon/index.tsx @@ -28,7 +28,8 @@ const iconKeys = [ 'ExclamationCircleOutlined', 'UploadOutlined', 'MenuUnfoldOutlined', - 'MenuFoldOutlined' + 'MenuFoldOutlined', + 'QuestionCircleOutlined' ] const Icon = (props: {type: string}) => { diff --git a/src/components/RadioCard/index.vue b/src/components/RadioCard/index.vue index 2d27ba0b..152ae840 100644 --- a/src/components/RadioCard/index.vue +++ b/src/components/RadioCard/index.vue @@ -25,6 +25,7 @@ interface IOption { type Emits = { (e: 'update:modelValue', data: string): void; + (e: 'change') :void }; const emit = defineEmits(); @@ -41,7 +42,10 @@ const props = defineProps({ const myValue = computed({ get: () => props.modelValue, - set: (val) => emit('update:modelValue', val), + set: (val) => { + emit('update:modelValue', val) + emit('change') + }, }); diff --git a/src/views/notice/Template/Detail/components/Attachments.vue b/src/views/notice/Template/Detail/components/Attachments.vue index a3dbe211..25dafe88 100644 --- a/src/views/notice/Template/Detail/components/Attachments.vue +++ b/src/views/notice/Template/Detail/components/Attachments.vue @@ -1,4 +1,4 @@ - + - + { - if (info.file.status === 'done') { - const result = info.file.response?.result; - console.log('result: ', result); - } -}; +// const fileList = computed({ +// get: () => props.attachments.map((m) => ({ id: fileId(), ...m })), +// set: (val) => +// emit( +// 'update:attachments', +// val.map(({ name, location }) => ({ name, location })), +// ), +// }); const fileList = ref([]); + watch( () => props.attachments, (val) => { - fileList.value = val; + fileList.value = val.map((m) => ({ + id: fileId(), + ...m, + })); }, { deep: true }, ); -const handleDelete = (id: number) => { - const idx = fileList.value.findIndex((f) => f.id === id); - fileList.value.splice(idx, 1); - emit('update:attachments', fileList.value); +const handleChange = (info: UploadChangeParam, id: string | undefined) => { + if (info.file.status === 'done') { + const targetFileIdx = fileList.value.findIndex((f) => f.id === id); + fileList.value[targetFileIdx].name = info.file.name; + fileList.value[targetFileIdx].location = info.file.response?.result; + emit( + 'update:attachments', + fileList.value.map(({ name, location }) => ({ name, location })), + ); + } }; + +/** + * 删除附件 + * @param id + */ +const handleDelete = (id: string | undefined) => { + const idx = fileList.value.findIndex((f) => f.id === id); + + fileList.value.splice(idx, 1); +}; + +/** + * 添加附件 + */ const handleAdd = () => { fileList.value.push({ - id: fileList.value.length, + id: fileId(), name: '', location: '', }); - emit('update:attachments', fileList.value); }; + +/** + * 附件标识 + */ +const fileId = () => String(new Date().getTime() + Math.random() * 9); diff --git a/src/views/notice/Template/Detail/index.vue b/src/views/notice/Template/Detail/index.vue index b281c75b..4db6e5ec 100644 --- a/src/views/notice/Template/Detail/index.vue +++ b/src/views/notice/Template/Detail/index.vue @@ -39,6 +39,7 @@ - {{ item.label }} + {{ item.name }} @@ -120,8 +121,7 @@ > @@ -246,17 +246,11 @@ - - {{ item.label }} - - + /> + + + + + + { - console.log('formData.value.type: ', formData.value.type); + // console.log('formData.value.type: ', formData.value.type); Object.assign( formData.value.template, TEMPLATE_FIELD_MAP[formData.value.type][formData.value.provider], @@ -547,11 +572,42 @@ const { resetFields, validate, validateInfos, clearValidate } = useForm( watch( () => formData.value.type, () => { + formData.value.variableDefinitions = []; clearValidate(); }, { deep: true }, ); +watch( + () => formData.value.template.message, + (val) => { + if (!val) return; + // 已经存在的变量 + const oldKey = formData.value.variableDefinitions?.map((m) => m.id); + // 正则提取${}里面的值 + const pattern = /(?<=\$\{).*?(?=\})/g; + const titleList = val.match(pattern)?.filter((f) => f); + const newKey = [...new Set(titleList)]; + const result = newKey?.map((m) => + oldKey.includes(m) + ? formData.value.variableDefinitions.find( + (item) => item.id === m, + ) + : { + id: m, + name: '', + type: 'string', + format: '%s', + }, + ); + formData.value.variableDefinitions = result; + }, + { deep: true }, +); + +/** + * 获取详情 + */ const getDetail = async () => { const res = await templateApi.detail(route.params.id as string); // console.log('res: ', res); @@ -560,6 +616,20 @@ const getDetail = async () => { }; // getDetail(); +/** + * 获取绑定配置 + */ +const configList = ref(); +const getConfigList = async () => { + const terms = [ + { column: 'type$IN', value: formData.value.type }, + { column: 'provider', value: formData.value.provider }, + ]; + const { result } = await templateApi.getConfig({ terms }); + configList.value = result; +}; +getConfigList(); + /** * 表单提交 */ @@ -567,25 +637,35 @@ const btnLoading = ref(false); const handleSubmit = () => { validate() .then(async () => { - console.log('formData.value: ', formData.value); + // console.log('formData.value: ', formData.value); btnLoading.value = true; - // let res; - // if (!formData.value.id) { - // res = await templateApi.save(formData.value); - // } else { - // res = await templateApi.update(formData.value); - // } - // // console.log('res: ', res); - // if (res?.success) { - // message.success('保存成功'); - // router.back(); - // } - btnLoading.value = false; + let res; + if (!formData.value.id) { + res = await templateApi.save(formData.value); + } else { + res = await templateApi.update(formData.value); + } + // console.log('res: ', res); + if (res?.success) { + message.success('保存成功'); + router.back(); + } }) .catch((err) => { console.log('err: ', err); + btnLoading.value = false; }); }; + +// test +watch( + () => formData.value, + (val) => { + console.log('formData.value: ', val); + }, + { deep: true }, +); +// test