给后台项目增加用户跟踪功能和备注
api
export interface UpdateProjectStateVO {
id?: number //自增id
remarks?: string //备注
}
//跟踪结果
export const updateProjectStateApi = async (data: UpdateProjectStateVO) => {
return await request.put({ url: '/zftec/user-project/updateProjectState', data })
}
<XButton
link
type="primary"
v-if="1 != row.state"//备注完成后删除追踪按钮
preIcon="ep:open"
:title="t('跟踪')"
v-hasPermi="['zftec:user-project:update-state']"//设置权限
@click="updateState(row.id)"
/>
const updateState = async (rowId: number) => {
tracerDialogVisible.value = true
const res = await UserProjectApi.getUserProjectApi(rowId)
let data = { id: rowId, remarks: res.remarks }
unref(trancerFormRef)?.setValues(data)
}
const submitTracerForm = async () => {
const elForm = unref(trancerFormRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
try {
const data = unref(trancerFormRef)?.formModel as UserProjectApi.UpdateProjectStateVO
await UserProjectApi.updateProjectStateApi(data)
ElMessage.success(t('common.tranceSuccess'))
tracerDialogVisible.value = false
await reload()
} finally {
actionLoading.value = false
}
}
})
}
<Dialog v-model="tracerDialogVisible" title="跟踪情况修改">
<Form :schema="tracerSchemas.formSchema" :rules="tracerRules" ref="trancerFormRef" />
<template #footer>
<XButton
:loading="actionLoading"
:title="t('action.save')"//保存
type="primary"
@click="submitTracerForm"
/>
<XButton
:loading="actionLoading"
:title="t('dialog.close')"//关闭
@click="tracerDialogVisible = false"
/>
</template>
</Dialog>