新增下载功能

This commit is contained in:
aoli.qu 2022-02-25 18:03:51 +08:00
parent ed9d4d96d1
commit 50cb5c3688
3 changed files with 36 additions and 13 deletions

View File

@ -19,6 +19,11 @@
<div v-html="model.content"></div>
</div>
</div>
<div class="table-operator" v-if="path">
<a-button type="primary" icon="arrow-down" @click="download" class="down">
附件下载
</a-button>
</div>
</div>
</a-card>
@ -70,6 +75,7 @@ export default {
data () {
return {
model: {},
path: '',
queryParam: { noticeId: this.$route.query.id, isRead: 1 },
readCount: 0,
unreadCount: 0,
@ -105,14 +111,12 @@ export default {
// Promise
loadData1: parameter => {
return noticePagePerson(Object.assign(parameter, { noticeId: this.$route.query.id, isRead: 1 })).then((res) => {
console.log(res)
this.readCount = res.total
return res
})
},
loadData2: parameter => {
return noticePagePerson(Object.assign(parameter, { noticeId: this.$route.query.id, isRead: 0 })).then((res) => {
console.log(res)
this.unreadCount = res.total
return res
})
@ -137,6 +141,10 @@ export default {
getDetail (id) {
noticeGet({ id: id }).then(res => {
this.model = res.data
const fileArr = JSON.parse(res.data.file)
if (fileArr.length > 0) {
this.path = fileArr[0].url
}
})
},
readNotice (id) {
@ -155,6 +163,9 @@ export default {
this.$refs.table2.refresh(true)
})
}
},
download () {
window.location.href = this.path //
}
}
}

View File

@ -55,7 +55,8 @@
<a-button @click="quit" type="primary" v-if="hasPerm('person:quit')">离职</a-button>
<a-button @click="setAdmin" type="primary" v-if="hasPerm('person:setAdmin')">设置管理员</a-button>
<a-button @click="personExport" type="primary" v-if="hasPerm('person:export')">导出</a-button>
<a-button @click="personBatch" type="primary" v-if="hasPerm('person:import')">批量导入</a-button>
<a-button @click="personBatch" type="primary" v-if="hasPerm('person:import')">导入</a-button>
<a-button @click="downloadDemo" type="primary" v-if="hasPerm('person:import')">导入模板下载</a-button>
<input ref="inputFile" type="file" style="display: none" @change="personImport" />
</template>
@ -63,7 +64,7 @@
<div class="table-operator">
<div class="person-type">
<a-radio-group v-model="queryParam.isAdmin" @change="onRadioChange">
<a-radio-group v-model="isAdmin" @change="onRadioChange">
<a-radio :value="2">学员</a-radio>
<a-radio :value="1">管理员</a-radio>
</a-radio-group>
@ -144,7 +145,7 @@ export default {
data () {
return {
//
queryParam: { isAdmin: 2 },
queryParam: { },
//
columns: [
{
@ -176,7 +177,9 @@ export default {
// Promise
loadData: parameter => {
if (!this.orgId) return []
return personPage(Object.assign(parameter, this.queryParam)).then((res) => {
return personPage(Object.assign(parameter, this.queryParam,
{ isAdmin: this.isAdmin, orgType: this.orgType, orgId: this.orgId }
)).then((res) => {
return res
})
},
@ -193,6 +196,7 @@ export default {
key: 'id',
value: 'id'
},
isAdmin: 2,
orgId: '',
orgType: 1,
spinning: false
@ -231,6 +235,7 @@ export default {
this.selectedKeys = []
if (!res.code === 200 || !res.data.length) {
this.orgTree = []
this.$refs.table.refresh(true)
return
}
this.orgTree = listToTree(res.data, [], rootParentId)
@ -384,7 +389,9 @@ export default {
}
},
personExport () {
personExport(this.queryParam).then(res => {
personExport(Object.assign(this.queryParam,
{ isAdmin: this.isAdmin, orgType: this.orgType, orgId: this.orgId }
)).then(res => {
downloadExportFile(res.data)
})
},
@ -414,6 +421,8 @@ export default {
this.$message.success('导入成功!')
this.$refs.table.refresh()
this.spinning = false
}).catch(() => {
this.spinning = false
})
} else {
this.$message.error(res.data.msg)
@ -423,6 +432,7 @@ export default {
.catch((err) => {
this.$refs.inputFile.value = ''
this.$message.error(err)
this.spinning = false
})
},
@ -430,21 +440,23 @@ export default {
* 点击左侧机构树查询列表
*/
handleClick (e) {
this.queryParam.orgId = e.toString()
this.orgId = e.toString()
this.queryParam.orgType = this.orgType
this.$refs.table.refresh(true)
},
handleOk () {
this.$refs.table.refresh()
},
onRadioChange (e) {
this.queryParam.isAdmin = e.target.value
this.isAdmin = e.target.value
this.$refs.table.refresh(true)
},
onSelectChange (selectedRowKeys, selectedRows) {
this.selectedRowKeys = selectedRowKeys
this.selectedRows = selectedRows
},
//
downloadDemo () {
window.location.href = '/dawa/sys/oss/show?id=3'
}
}
}

View File

@ -28,8 +28,8 @@
</div>
<div class="table-operator">
<a-button type="primary" icon="plus" v-if="hasPerm('sys:user:add')" @click="$refs.userForm.add()">新增用户</a-button>
<a-button type="danger" :disabled="selectedRowKeys.length < 1" v-if="hasPerm('sys:user:delete')" @click="batchDelete">
<!-- <a-button type="primary" icon="plus" v-if="hasPerm('sys:user:add')" @click="$refs.userForm.add()">新增用户</a-button> -->
<a-button type="danger" :disabled="selectedRowKeys.length < 1" v-if="hasPerm('sys:user:del')" @click="batchDelete">
<a-icon type="delete"/>批量删除
</a-button>
</div>