Skip to content

Commit 8d9a14a

Browse files
fix: 修复非管理权限下的导出和状态改变
1 parent adad526 commit 8d9a14a

File tree

3 files changed

+49
-35
lines changed

3 files changed

+49
-35
lines changed

ui/src/request/index.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ export const exportExcel: (
225225
params: any,
226226
loading?: NProgress | Ref<boolean>
227227
) => {
228-
return promise(request({ url: url, method: 'get', params, responseType: 'blob' }), loading)
229-
.then((res: any) => {
228+
return promise(request({ url: url, method: 'get', params, responseType: 'blob' }), loading).then(
229+
(res: any) => {
230+
console.log(res)
230231
if (res) {
231232
const blob = new Blob([res], {
232233
type: 'application/vnd.ms-excel'
@@ -239,8 +240,8 @@ export const exportExcel: (
239240
window.URL.revokeObjectURL(link.href)
240241
}
241242
return true
242-
})
243-
.catch((e) => {})
243+
}
244+
)
244245
}
245246

246247
export const exportExcelPost: (
@@ -265,22 +266,20 @@ export const exportExcelPost: (
265266
responseType: 'blob'
266267
}),
267268
loading
268-
)
269-
.then((res: any) => {
270-
if (res) {
271-
const blob = new Blob([res], {
272-
type: 'application/vnd.ms-excel'
273-
})
274-
const link = document.createElement('a')
275-
link.href = window.URL.createObjectURL(blob)
276-
link.download = fileName
277-
link.click()
278-
// 释放内存
279-
window.URL.revokeObjectURL(link.href)
280-
}
281-
return true
282-
})
283-
.catch((e) => {})
269+
).then((res: any) => {
270+
if (res) {
271+
const blob = new Blob([res], {
272+
type: 'application/vnd.ms-excel'
273+
})
274+
const link = document.createElement('a')
275+
link.href = window.URL.createObjectURL(blob)
276+
link.download = fileName
277+
link.click()
278+
// 释放内存
279+
window.URL.revokeObjectURL(link.href)
280+
}
281+
return true
282+
})
284283
}
285284

286285
export const download: (

ui/src/views/document/index.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,10 @@
187187
<template #default="{ row }">
188188
<div @click.stop>
189189
<el-switch
190+
:loading="loading"
190191
size="small"
191192
v-model="row.is_active"
192-
@change="changeState($event, row)"
193+
:before-change="() => changeState(row)"
193194
/>
194195
</div>
195196
</template>
@@ -678,18 +679,24 @@ function deleteDocument(row: any) {
678679
更新名称或状态
679680
*/
680681
function updateData(documentId: string, data: any, msg: string) {
681-
documentApi.putDocument(id, documentId, data, loading).then((res) => {
682-
const index = documentData.value.findIndex((v) => v.id === documentId)
683-
documentData.value.splice(index, 1, res.data)
684-
MsgSuccess(msg)
685-
})
682+
documentApi
683+
.putDocument(id, documentId, data, loading)
684+
.then((res) => {
685+
const index = documentData.value.findIndex((v) => v.id === documentId)
686+
documentData.value.splice(index, 1, res.data)
687+
MsgSuccess(msg)
688+
return true
689+
})
690+
.catch(() => {
691+
return false
692+
})
686693
}
687694
688-
function changeState(bool: Boolean, row: any) {
695+
function changeState(row: any) {
689696
const obj = {
690-
is_active: bool
697+
is_active: !row.is_active
691698
}
692-
const str = bool ? '启用成功' : '禁用成功'
699+
const str = !row.is_active ? '启用成功' : '禁用成功'
693700
currentMouseId.value && updateData(row.id, obj, str)
694701
}
695702

ui/src/views/paragraph/index.vue

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@
104104
>
105105
<div class="active-button" @click.stop>
106106
<el-switch
107+
:loading="loading"
107108
v-model="item.is_active"
108-
@change="changeState($event, item)"
109+
:before-change="() => changeState(item)"
109110
size="small"
110111
/>
111112
</div>
@@ -162,7 +163,6 @@
162163
<ParagraphDialog ref="ParagraphDialogRef" :title="title" @refresh="refresh" />
163164
<SelectDocumentDialog ref="SelectDocumentDialogRef" @refresh="refreshMigrateParagraph" />
164165
<GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="refresh" />
165-
166166
</LayoutContainer>
167167
</template>
168168
<script setup lang="ts">
@@ -258,11 +258,20 @@ function searchHandle() {
258258
getParagraphList()
259259
}
260260
261-
function changeState(bool: Boolean, row: any) {
261+
function changeState(row: any) {
262262
const obj = {
263-
is_active: bool
263+
is_active: !row.is_active
264264
}
265-
paragraph.asyncPutParagraph(id, documentId, row.id, obj, changeStateloading).then((res) => {})
265+
paragraph
266+
.asyncPutParagraph(id, documentId, row.id, obj, changeStateloading)
267+
.then((res) => {
268+
const index = paragraphDetail.value.findIndex((v) => v.id === row.id)
269+
paragraphDetail.value[index].is_active = !paragraphDetail.value[index].is_active
270+
return true
271+
})
272+
.catch(() => {
273+
return false
274+
})
266275
}
267276
268277
function deleteParagraph(row: any) {
@@ -328,7 +337,6 @@ function refresh(data: any) {
328337
}
329338
}
330339
331-
332340
const GenerateRelatedDialogRef = ref()
333341
function openGenerateDialog(row?: any) {
334342
const arr: string[] = []

0 commit comments

Comments
 (0)