增加uuid字段

This commit is contained in:
XaoLi717 2024-10-18 14:38:44 +08:00
parent 17a200e70d
commit 6160591210
2 changed files with 33 additions and 31 deletions

View File

@ -136,6 +136,7 @@ const emit = defineEmits(['update:modelValue','update:fileStatus'])
const props = defineProps({
fileId:propTypes.number,//id
fileStatus: propTypes.arrayOf(Number).def([]),//
uuid: propTypes.string.def(""),//
modelValue: propTypes.oneOfType<string | string[]>([String, Array<String>]).isRequired,
fileType: propTypes.array.def(['doc', 'xls', 'ppt', 'txt', 'pdf', 'wps']), // , ['png', 'jpg', 'jpeg']
fileSize: propTypes.number.def(5), // (MB)
@ -154,24 +155,6 @@ const MysqlUrl = ref<UploadUserFile[]>([])
const uploadNumber = ref<number>(0)
const { uploadUrl, httpRequest } = useUpload()
//
const upload = async (myFile:any) => {
// const iid = fileNid.value.toString()//id
const formData = new FormData();
const token = getAccessToken();
//
const configs = {
headers: { 'Authorization': `Bearer ${token}`,'Content-Type': 'multipart/form-data' }
}
formData.append('file', myFile);//form
try {
// console.log("ok")
const response = await axios.post(`${config.only_url}/admin-api/only/onlyof/update`, formData, configs);
console.log("ok",response)
} catch (error) {
console.error('Upload failed:', error);
}
};
const lod = ref(true)
const upDing = ref(false)
//
@ -248,7 +231,6 @@ const SyncFiles = async () => {
txt: 'add_texts',
html: 'add_html',
};
console.log("66")
await delay(100);
fName.page = 70;
fName.lodTxt="70%"
@ -256,15 +238,13 @@ const SyncFiles = async () => {
fName.page = 90;
fName.lodTxt="90%"
const response = await axios.post(`${config.ai_url}/${add}?path=${filePath}`);
console.log("response",response)
// console.log("response",response)
if (response.data.response.indexOf("added")==-1){
throw new Error("同步错误");
}
upDing.value=false
await delay(100);
fName.page = 100;
console.log("77")
fName.lodTxt="完成"
} catch (error) {
upDing.value=false
@ -327,13 +307,26 @@ const getList = async () => {
GotoFile.value=true
}
}
//id
const fileNid = ref(integer)
//
const upload = async (myFile:any) => {
const formData = new FormData();
const token = getAccessToken();
//
const configs = {
headers: { 'Authorization': `Bearer ${token}`,'Content-Type': 'multipart/form-data' }
}
formData.append('file', myFile);//form
formData.append('uuid', props.uuid);//form
try {
// console.log("ok")
const response = await axios.post(`${config.only_url}/admin-api/only/onlyof/update`, formData, configs);
// console.log("ok",response)
} catch (error) {
console.error('Upload failed:', error);
}
};
//
const edit = async (row) => {
//id
// const iid = fileNid.value.toString()
// let name = fileNid.value+row.file.name.trim()
let name = row.file.name.trim()
queryParamsOnly.pageNo = 1
queryParamsOnly.fileName=name
@ -343,8 +336,7 @@ const edit = async (row) => {
return;
}
const token = getAccessToken();
// window.open(`http://192.168.1.15:48080/admin-api/only/onlyof/edit?name=${name}&userName=admin&userId=1&id=${iid}&token=${token}`);
window.open(`${config.only_url}/admin-api/only/onlyof/edit?name=${name}&userName=admin&userId=1&token=${token}`);
window.open(`${config.only_url}/admin-api/only/onlyof/edit?name=${name}&userName=admin&userId=1&uuid=${props.uuid}&token=${token}`);
};
//
@ -361,11 +353,11 @@ const download = async (row) => {
if (response.data.error === 0) {
alert('文档正在编辑5秒后开始下载最新版');
setTimeout(() => {
window.location.href = `${config.only_url}/admin-api/only/onlyof/download?name=v1${name}&token=${token}`;
window.location.href = `${config.only_url}/admin-api/only/onlyof/download?name=v1${name}&uuid=${props.uuid}&token=${token}`;
}, 5000);
} else {
message.success('正在下载文件! ')
window.location.href = `${config.only_url}/admin-api/only/onlyof/download?name=${name}&token=${token}`;
window.location.href = `${config.only_url}/admin-api/only/onlyof/download?name=${name}&uuid=${props.uuid}&token=${token}`;
}
} catch (error) {
console.error('Download failed:', error);

View File

@ -89,6 +89,7 @@
v-model="formData.filePath"
:file-id="formData.id"
v-model:file-status="formData.fileStatus"
:uuid="cmUui"
/>
</el-form-item>
</el-form>
@ -118,6 +119,7 @@ import tbYesIcon from "../../../../assets/imgs/Knowledge/Tbup_yes.svg";
import tbNoIcon from "../../../../assets/imgs/Knowledge/Tbup_no.svg";
import {Star2Api} from "@/api/bpm/star2";
import { TbupApi } from '@/api/bpm/tbup';
import { v4 as uuidv4 } from 'uuid';
/** 知识发布 表单 */
defineOptions({ name: 'KnowledgeForm' })
@ -125,11 +127,16 @@ defineOptions({ name: 'KnowledgeForm' })
const ys = ref(false)//
const tb = ref(false)//
const { t } = useI18n() //
const uui = ref<undefined|string>("")
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const cmUui = computed(() => {
return formData.value.uuid? formData.value.uuid : uui.value;
})
const formData = ref({
id: undefined,
typeId: undefined,
@ -138,6 +145,7 @@ const formData = ref({
userName:'',
content: '',
status: undefined,
uuid: "",
fileStatus: [] as number[],
filePath: [] as string[]
})
@ -184,6 +192,7 @@ const getUserInfo = async () => {
}
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
uui.value = uuidv4()
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
@ -333,6 +342,7 @@ const submitForm = async () => {
data.comments = commentFormRef.value.getData()
if (formType.value === 'create') {
data.uuid = uui.value
await KnowledgeApi.createKnowledge(data)
message.success(t('common.createSuccess'))
} else {