|
@@ -19,6 +19,7 @@
|
|
|
<el-button v-if="hasPermission('sys:project:add')" type="primary" size="small" icon="el-icon-plus" @click="add()">新建</el-button>
|
|
|
<!-- <el-button v-if="hasPermission('sys:post:edit')" type="warning" size="small" icon="el-icon-edit-outline" @click="edit()" :disabled="$refs.projectTable && $refs.projectTable.getCheckboxRecords().length !== 1" plain>修改</el-button>-->
|
|
|
<el-button v-if="hasPermission('sys:project:del')" type="danger" size="small" icon="el-icon-delete" @click="del()" :disabled="$refs.projectTable && $refs.projectTable.getCheckboxRecords().length === 0" plain>删除</el-button>
|
|
|
+ <el-button v-if="hasPermission('sys:project:import')" type="default" @click="downloadTpl()" size="small">下载模板</el-button>
|
|
|
</template>
|
|
|
</vxe-toolbar>
|
|
|
<div style="height: calc(100% - 80px);">
|
|
@@ -35,7 +36,14 @@
|
|
|
highlight-hover-row
|
|
|
:menu-config="{}"
|
|
|
:print-config="{}"
|
|
|
- :export-config="{}"
|
|
|
+ :export-config="{
|
|
|
+ remote: true,
|
|
|
+ filename: `评估项目数据${moment(new Date()).format('YYYY-MM-DD')}`,
|
|
|
+ sheetName: '评估项目数据',
|
|
|
+ exportMethod: exportMethod,
|
|
|
+ types: ['xlsx'],
|
|
|
+ modes: ['current', 'all']
|
|
|
+ }"
|
|
|
@sort-change="sortChangeHandle"
|
|
|
:sort-config="{remote:true}"
|
|
|
:data="dataList"
|
|
@@ -227,6 +235,47 @@
|
|
|
resetSearch () {
|
|
|
this.$refs.searchForm.resetFields()
|
|
|
this.refreshList()
|
|
|
+ },
|
|
|
+ // 下载模板
|
|
|
+ downloadTpl () {
|
|
|
+ // this.$utils.downloadExcel('/sys/project/import/template')
|
|
|
+ this.loading = true
|
|
|
+ this.projectService.exportTemplate().then((res) => {
|
|
|
+ // 将二进制流文件写入excel表,以下为重要步骤
|
|
|
+ this.$utils.downloadExcel(res.data, '项目导入模板')
|
|
|
+ this.loading = false
|
|
|
+ }).catch(function (err) {
|
|
|
+ this.loading = false
|
|
|
+ if (err.response) {
|
|
|
+ console.log(err.response)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 自定义服务端导出
|
|
|
+ exportMethod ({ options }) {
|
|
|
+ // 传给服务端的参数
|
|
|
+ const params = {
|
|
|
+ 'current': this.tablePage.currentPage,
|
|
|
+ 'size': this.tablePage.pageSize,
|
|
|
+ 'orders': this.tablePage.orders,
|
|
|
+ 'itemType': '1',
|
|
|
+ ...this.searchForm,
|
|
|
+ filename: options.filename,
|
|
|
+ sheetName: options.sheetName,
|
|
|
+ isHeader: options.isHeader,
|
|
|
+ original: options.original,
|
|
|
+ mode: options.mode,
|
|
|
+ selectIds: options.mode === 'selected' ? options.data.map(item => item.id) : [],
|
|
|
+ exportFields: options.columns.map(column => column.property)
|
|
|
+ }
|
|
|
+ return this.projectService.exportExcel(params).then((res) => {
|
|
|
+ // 将二进制流文件写入excel表,以下为重要步骤
|
|
|
+ this.$utils.downloadExcel(res.data, options.filename)
|
|
|
+ }).catch(function (err) {
|
|
|
+ if (err.response) {
|
|
|
+ console.log(err.response)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|