| | |
| | | <ttable |
| | | :table="table" |
| | | :resultData="resultData" |
| | | @change ="costPlannedAmountChange" |
| | | @handleSelectionChange="handleSelectionChange" |
| | | :prelang="prelang" |
| | | :options="options" |
| | | :ajaxFun="ajaxFun" |
| | | @queryParam="getQueryParam($event)" |
| | | ref="rawMaterialTable"> |
| | | <template #toolbar></template> |
| | | <template #toolbar> |
| | | <el-button @click="exportRawMaterial" type="primary" >导出</el-button> |
| | | </template> |
| | | </ttable> |
| | | </basic-container> |
| | | <!-- 弹窗, 新增 / 修改 --> |
| | |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import ExportMaterial from './ExportMaterial.vue' |
| | | import ttable from '@/views/common/ztt-table.vue' |
| | | import { getRawInspectList,delObj } from '@/api/quality/rawMaterial' |
| | | import { getRawInspectList,delObj,exportRawMaterial } from '@/api/quality/rawMaterial' |
| | | import RawMaterialForm from './rawMaterial-form' |
| | | import * as fecha from 'element-ui/lib/utils/date' |
| | | import { mapGetters } from 'vuex' |
| | | export default { |
| | | data() { |
| | | return { |
| | | queryParam: {}, |
| | | resultData:[], |
| | | addOrUpdateVisible: false, |
| | | type: [1], |
| | |
| | | isRefresh: true, // 是否显示刷新按钮 |
| | | isShowHide: true, // 是否显示显影按钮H |
| | | isSearch: true, // 高级查询按钮 |
| | | defaultOrderBy: { column: 'formTime', direction: 'desc' }, |
| | | defaultOrderBy: { column: 'createTime', direction: 'desc' }, |
| | | }, |
| | | table: { |
| | | total: 0, |
| | | currentPage: 1, |
| | | pageSize: 20, |
| | | data: [], |
| | | isExport:true, |
| | | // 标题 |
| | | column: [ |
| | | { |
| | |
| | | prop: 'createTime', |
| | | label: '报检日期', |
| | | isTrue: true, |
| | | sort: true, |
| | | isSearch: true, |
| | | searchInfoType: 'text', |
| | | formatter: this.formatDateTime, |
| | |
| | | text: '新增', |
| | | type: 'primary', |
| | | fun: this.addOrUpdateHandle |
| | | }, |
| | | { |
| | | text: '导出', |
| | | type: 'primary', |
| | | fun: this.handleExcel |
| | | } |
| | | ], |
| | | }], |
| | | operator: [{ |
| | | text: '作废', |
| | | type: 'text', |
| | |
| | | StateList: [{label:'全部',value:''},{label:'已合格',value:'1'},{label:'不合格',value:'0'}], |
| | | } |
| | | }, |
| | | // props:{ |
| | | // queryParam:{ |
| | | // type: Object, |
| | | // default: ()=>{ |
| | | // return {} |
| | | // } |
| | | // } |
| | | // }, |
| | | components: { |
| | | ttable, |
| | | RawMaterialForm, |
| | | ExportMaterial, |
| | | }, |
| | | created() { |
| | | |
| | |
| | | ...mapGetters(['permissions']) |
| | | }, |
| | | methods:{ |
| | | async costPlannedAmountChange(value){ |
| | | this.resultData= value |
| | | getQueryParam(data){ |
| | | this.queryParam = data |
| | | }, |
| | | |
| | | handleExcel() { |
| | | console.log(this.resultData); |
| | | console.log(this.table.column); |
| | | let arr = this.table.column.filter(item => item.isTrue == true).map(item => { |
| | | return{ |
| | | prop:item.prop, |
| | | label:item.label |
| | | } |
| | | exportRawMaterial(){ |
| | | exportRawMaterial(this.queryParam).then(res=>{ |
| | | console.log(res) |
| | | this.downloadFun(res) |
| | | }).catch(error=>{ |
| | | console.log(error); |
| | | }) |
| | | let opt = { |
| | | title: '文档标题', |
| | | column: [{ |
| | | label:'', |
| | | prop:'header', |
| | | children:arr |
| | | }], |
| | | data: this.resultData |
| | | } |
| | | this.$Export.excel({ |
| | | title: opt.title, |
| | | columns: opt.column, |
| | | data: opt.data |
| | | }); |
| | | }, |
| | | }, |
| | | downloadFun(result){ |
| | | if(result == null || result == undefined){ |
| | | return; |
| | | } |
| | | var nameList = result.headers['content-disposition']; |
| | | nameList = decodeURI(nameList); |
| | | var fileName = nameList.split('=')[1]; |
| | | const blob = new Blob([result.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) |
| | | const downloadElement = document.createElement('a') // 新建一个DOM节点 |
| | | const href = window.URL.createObjectURL(blob) // 创建下载的链接 |
| | | downloadElement.href = href |
| | | downloadElement.download = fileName // 下载后文件名 |
| | | document.body.appendChild(downloadElement) // 将新增的节点挂载到页面上 |
| | | downloadElement.click() // 点击下载 |
| | | document.body.removeChild(downloadElement) // 下载完成移除元素 |
| | | window.URL.revokeObjectURL(href) |
| | | }, |
| | | // 删除 |
| | | deleteHandle(row) { |
| | | this.$confirm('是否确认删除该数据:' + row.code , '提示', { |