Browse Source

feat: 一些调整

main
betaqi 1 month ago
parent
commit
243e6764c8
  1. 1
      global.types/components.d.ts
  2. 26
      src/views/engineering/config/index.vue
  3. 43
      src/views/engineering/index.vue

1
global.types/components.d.ts vendored

@ -53,5 +53,6 @@ declare module 'vue' {
} }
export interface GlobalDirectives { export interface GlobalDirectives {
vInfiniteScroll: typeof import('element-plus/es')['ElInfiniteScroll'] vInfiniteScroll: typeof import('element-plus/es')['ElInfiniteScroll']
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
} }
} }

26
src/views/engineering/config/index.vue

@ -43,7 +43,12 @@
<el-button v-if="activeStep > 0" @click="prevStep" :icon="ArrowLeft" <el-button v-if="activeStep > 0" @click="prevStep" :icon="ArrowLeft"
>上一步</el-button >上一步</el-button
> >
<el-button v-if="activeStep < 2" type="primary" @click="nextStep"> <el-button
v-if="activeStep < 2"
type="primary"
@click="nextStep"
:loading="nextStepLoading"
>
下一步<el-icon class="el-icon--right"><ArrowRight /></el-icon> 下一步<el-icon class="el-icon--right"><ArrowRight /></el-icon>
</el-button> </el-button>
<el-button <el-button
@ -52,14 +57,18 @@
@click="handleFinish" @click="handleFinish"
:icon="Check" :icon="Check"
:loading="loading" :loading="loading"
>完成</el-button >保存配置</el-button
> >
</div> </div>
</div> </div>
</div> </div>
<div class="flex-1 overflow-hidden flex flex-col"> <div class="flex-1 overflow-hidden flex flex-col">
<div class="flex-1 overflow-hidden p-6"> <div
class="flex-1 overflow-hidden p-6"
v-loading="pageLoading"
loading-text="加载中..."
>
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<keep-alive> <keep-alive>
<component <component
@ -199,7 +208,10 @@ const prevStep = async () => {
} }
} }
const nextStepLoading = ref(false)
const nextStep = async () => { const nextStep = async () => {
nextStepLoading.value = true
const index = steps.indexOf(currentStep.value) const index = steps.indexOf(currentStep.value)
if (currentStep.value === 'channel') { if (currentStep.value === 'channel') {
await saveChannelList() await saveChannelList()
@ -207,12 +219,16 @@ const nextStep = async () => {
if (currentComponentRef.value?.checkBeforeLeave) { if (currentComponentRef.value?.checkBeforeLeave) {
const canLeave = await currentComponentRef.value.checkBeforeLeave() const canLeave = await currentComponentRef.value.checkBeforeLeave()
if (!canLeave) return if (!canLeave) {
nextStepLoading.value = false
return
}
} }
if (index < steps.length - 1) { if (index < steps.length - 1) {
currentStep.value = steps[index + 1] currentStep.value = steps[index + 1]
} }
nextStepLoading.value = false
} }
/* /*
@ -288,11 +304,13 @@ async function loadDeviceList() {
if (isObject(res.data)) devices.value = res.data if (isObject(res.data)) devices.value = res.data
} }
const pageLoading = ref(true)
onMounted(async () => { onMounted(async () => {
if (!isCreate.value) { if (!isCreate.value) {
await loadChannelList() await loadChannelList()
await loadDeviceList() await loadDeviceList()
await loadCategoryList() await loadCategoryList()
pageLoading.value = false
} }
}) })
</script> </script>

43
src/views/engineering/index.vue

@ -82,18 +82,43 @@ function enterEngineering(item: IEngineeringOV) {
}) })
} }
function handleDownload(item: IEngineeringOV) { // function handleDownload(item: IEngineeringOV) {
// if (!item.downloadPath) {
// ElMessage.warning('')
// return
// }
// const link = document.createElement('a')
// link.style.display = 'none'
// link.href = item.downloadPath
// link.setAttribute('download', item.name)
// document.body.appendChild(link)
// link.click()
// document.body.removeChild(link)
// }
async function handleDownload(item: IEngineeringOV) {
if (!item.downloadPath) { if (!item.downloadPath) {
ElMessage.warning('下载地址为空') ElMessage.warning('请完成工程配置!')
return return
} }
const link = document.createElement('a') try {
link.style.display = 'none' const res = await fetch(item.downloadPath)
link.href = item.downloadPath if (!res.ok) {
link.setAttribute('download', item.name) throw new Error('Network response was not ok')
document.body.appendChild(link) }
link.click() const blob = await res.blob()
document.body.removeChild(link) const link = document.createElement('a')
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
link.download = item.name
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
URL.revokeObjectURL(link.href)
} catch (error) {
ElMessage.error('下载失败,请检查网络或联系管理员')
console.error('Download failed:', error)
}
} }
</script> </script>

Loading…
Cancel
Save