|
@@ -48,7 +48,7 @@
|
|
|
<el-button type="primary" size="small" plain icon="el-icon-edit-outline" >发布</el-button>
|
|
|
<el-button type="primary" size="small" plain icon="el-icon-scissors" >废止</el-button>
|
|
|
<el-button type="primary" size="small" plain icon="el-icon-delete" >删除</el-button> -->
|
|
|
- <el-button type="primary" size="small" plain icon="el-icon-download">导出</el-button>
|
|
|
+ <el-button type="primary" size="small" plain icon="el-icon-download" @click="exportData">导出Excel</el-button>
|
|
|
</div>
|
|
|
</el-row>
|
|
|
<!-- 表格数据区域-->
|
|
@@ -102,6 +102,42 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+const qee = require('qf-export-excel')
|
|
|
+const HeadersList = [{
|
|
|
+ title: '任务名称',
|
|
|
+ key: 'task_name',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '年度',
|
|
|
+ key: 'year',
|
|
|
+ }, {
|
|
|
+ title: '文件号',
|
|
|
+ key: 'filenum',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '开始时间',
|
|
|
+ key: 'starttime',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '结束时间',
|
|
|
+ key: 'endtime',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建者',
|
|
|
+ key: 'releaser',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建时间',
|
|
|
+ key: 'createtime',
|
|
|
+ },{
|
|
|
+ title: '任务状态',
|
|
|
+ key: 'ispublic'
|
|
|
+ },{
|
|
|
+ title: '任务优先级',
|
|
|
+ key: 'level'
|
|
|
+ }
|
|
|
+
|
|
|
+ ]
|
|
|
export default {
|
|
|
name: '',
|
|
|
data() {
|
|
@@ -273,6 +309,64 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 导出Excel
|
|
|
+ async exportData() {
|
|
|
+
|
|
|
+ // for (var key in this.exportInfo) {
|
|
|
+ // if (this.exportInfo[key] == '') {
|
|
|
+ // delete this.exportInfo[key]
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ console.log(this.tableData)
|
|
|
+ let exportList = []
|
|
|
+ exportList = this.tableData
|
|
|
+
|
|
|
+ for (let i = 0; i < exportList.length; i++) {
|
|
|
+ if (exportList[i].level == '0') {
|
|
|
+ exportList[i].level = '一般'
|
|
|
+ } else if (exportList[i].level == '1') {
|
|
|
+ exportList[i].level = '紧急'
|
|
|
+ }else{
|
|
|
+ exportList[i].level = '特急'
|
|
|
+ }
|
|
|
+ if (exportList[i].ispublic == '1') {
|
|
|
+ exportList[i].ispublic = '已发布'
|
|
|
+ } else if(exportList[i].ispublic == '2') {
|
|
|
+ exportList[i].ispublic = '废止'
|
|
|
+ }else if(exportList[i].ispublic == '3') {
|
|
|
+ exportList[i].ispublic = '已结束,未完成'
|
|
|
+ }else if(exportList[i].ispublic == '4') {
|
|
|
+ exportList[i].ispublic = '已结束,已完成'
|
|
|
+ }else if(exportList[i].ispublic == '5') {
|
|
|
+ exportList[i].ispublic = '执行中'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 导出表格的表头设置
|
|
|
+ // let allColumns = exportList
|
|
|
+ var columnNames = []
|
|
|
+ var columnValues = []
|
|
|
+ // var columns = []
|
|
|
+ require.ensure([], () => {
|
|
|
+ const {
|
|
|
+ export_json_to_excel
|
|
|
+ } = require('@/vendor/Export2Excel.js')
|
|
|
+
|
|
|
+ for (var i = 0; i < HeadersList.length; i++) {
|
|
|
+ columnNames[i] = HeadersList[i].title
|
|
|
+ columnValues[i] = HeadersList[i].key
|
|
|
+ }
|
|
|
+ const tHeader = columnNames
|
|
|
+ const filterVal = columnValues
|
|
|
+ // console.log(columns)
|
|
|
+ const list = exportList
|
|
|
+ const data = this.formatJson(filterVal, list)
|
|
|
+ export_json_to_excel(tHeader, data, '例行监测任务')
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ formatJson(filterVal, jsonData) {
|
|
|
+ return jsonData.map(v => filterVal.map(j => v[j]))
|
|
|
+ },
|
|
|
|
|
|
},
|
|
|
}
|