新增下载功能

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 v-html="model.content"></div>
</div> </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> </div>
</a-card> </a-card>
@ -70,6 +75,7 @@ export default {
data () { data () {
return { return {
model: {}, model: {},
path: '',
queryParam: { noticeId: this.$route.query.id, isRead: 1 }, queryParam: { noticeId: this.$route.query.id, isRead: 1 },
readCount: 0, readCount: 0,
unreadCount: 0, unreadCount: 0,
@ -105,14 +111,12 @@ export default {
// Promise // Promise
loadData1: parameter => { loadData1: parameter => {
return noticePagePerson(Object.assign(parameter, { noticeId: this.$route.query.id, isRead: 1 })).then((res) => { return noticePagePerson(Object.assign(parameter, { noticeId: this.$route.query.id, isRead: 1 })).then((res) => {
console.log(res)
this.readCount = res.total this.readCount = res.total
return res return res
}) })
}, },
loadData2: parameter => { loadData2: parameter => {
return noticePagePerson(Object.assign(parameter, { noticeId: this.$route.query.id, isRead: 0 })).then((res) => { return noticePagePerson(Object.assign(parameter, { noticeId: this.$route.query.id, isRead: 0 })).then((res) => {
console.log(res)
this.unreadCount = res.total this.unreadCount = res.total
return res return res
}) })
@ -137,6 +141,10 @@ export default {
getDetail (id) { getDetail (id) {
noticeGet({ id: id }).then(res => { noticeGet({ id: id }).then(res => {
this.model = res.data this.model = res.data
const fileArr = JSON.parse(res.data.file)
if (fileArr.length > 0) {
this.path = fileArr[0].url
}
}) })
}, },
readNotice (id) { readNotice (id) {
@ -155,6 +163,9 @@ export default {
this.$refs.table2.refresh(true) 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="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="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="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" /> <input ref="inputFile" type="file" style="display: none" @change="personImport" />
</template> </template>
@ -63,7 +64,7 @@
<div class="table-operator"> <div class="table-operator">
<div class="person-type"> <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="2">学员</a-radio>
<a-radio :value="1">管理员</a-radio> <a-radio :value="1">管理员</a-radio>
</a-radio-group> </a-radio-group>
@ -144,7 +145,7 @@ export default {
data () { data () {
return { return {
// //
queryParam: { isAdmin: 2 }, queryParam: { },
// //
columns: [ columns: [
{ {
@ -176,7 +177,9 @@ export default {
// Promise // Promise
loadData: parameter => { loadData: parameter => {
if (!this.orgId) return [] 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 return res
}) })
}, },
@ -193,6 +196,7 @@ export default {
key: 'id', key: 'id',
value: 'id' value: 'id'
}, },
isAdmin: 2,
orgId: '', orgId: '',
orgType: 1, orgType: 1,
spinning: false spinning: false
@ -231,6 +235,7 @@ export default {
this.selectedKeys = [] this.selectedKeys = []
if (!res.code === 200 || !res.data.length) { if (!res.code === 200 || !res.data.length) {
this.orgTree = [] this.orgTree = []
this.$refs.table.refresh(true)
return return
} }
this.orgTree = listToTree(res.data, [], rootParentId) this.orgTree = listToTree(res.data, [], rootParentId)
@ -384,7 +389,9 @@ export default {
} }
}, },
personExport () { 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) downloadExportFile(res.data)
}) })
}, },
@ -414,6 +421,8 @@ export default {
this.$message.success('导入成功!') this.$message.success('导入成功!')
this.$refs.table.refresh() this.$refs.table.refresh()
this.spinning = false this.spinning = false
}).catch(() => {
this.spinning = false
}) })
} else { } else {
this.$message.error(res.data.msg) this.$message.error(res.data.msg)
@ -423,6 +432,7 @@ export default {
.catch((err) => { .catch((err) => {
this.$refs.inputFile.value = '' this.$refs.inputFile.value = ''
this.$message.error(err) this.$message.error(err)
this.spinning = false
}) })
}, },
@ -430,21 +440,23 @@ export default {
* 点击左侧机构树查询列表 * 点击左侧机构树查询列表
*/ */
handleClick (e) { handleClick (e) {
this.queryParam.orgId = e.toString()
this.orgId = e.toString() this.orgId = e.toString()
this.queryParam.orgType = this.orgType
this.$refs.table.refresh(true) this.$refs.table.refresh(true)
}, },
handleOk () { handleOk () {
this.$refs.table.refresh() this.$refs.table.refresh()
}, },
onRadioChange (e) { onRadioChange (e) {
this.queryParam.isAdmin = e.target.value this.isAdmin = e.target.value
this.$refs.table.refresh(true) this.$refs.table.refresh(true)
}, },
onSelectChange (selectedRowKeys, selectedRows) { onSelectChange (selectedRowKeys, selectedRows) {
this.selectedRowKeys = selectedRowKeys this.selectedRowKeys = selectedRowKeys
this.selectedRows = selectedRows this.selectedRows = selectedRows
},
//
downloadDemo () {
window.location.href = '/dawa/sys/oss/show?id=3'
} }
} }
} }

View File

@ -28,8 +28,8 @@
</div> </div>
<div class="table-operator"> <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="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="danger" :disabled="selectedRowKeys.length < 1" v-if="hasPerm('sys:user:del')" @click="batchDelete">
<a-icon type="delete"/>批量删除 <a-icon type="delete"/>批量删除
</a-button> </a-button>
</div> </div>