| | |
| | | <template> |
| | | <el-dialog :visible.sync="dialogPush" append-to-body :close-on-click-modal="false" @close="recoverPage" title="导出"> |
| | | <div style="margin-bottom: 10px"> |
| | | <el-radio-group v-model="radio"> |
| | | <el-radio :label="0">选择</el-radio> |
| | | <el-radio :label="1">全部</el-radio> |
| | | <el-radio :label="2">页码</el-radio> |
| | | </el-radio-group> |
| | | <el-dialog :visible.sync="dialogPush" append-to-body :close-on-click-modal="false" @close="escHandler" title="导出" style="width: 1550px; margin: auto"> |
| | | <div style="margin-bottom: 20px;"> |
| | | <div> |
| | | <span>导出方式:</span> |
| | | <el-radio-group v-model="radio"> |
| | | <el-radio :label="0">选择</el-radio> |
| | | <el-radio :label="1">全部</el-radio> |
| | | <el-radio :label="2">页码</el-radio> |
| | | </el-radio-group> |
| | | <span v-if="radio === 2" style="margin-left: 20px;"><el-input style="width: 150px" v-model="pageExport"></el-input> (输入页码或者页面范围,如:1-10))</span> |
| | | </div> |
| | | </div> |
| | | <div style="text-align: center"> |
| | | <el-transfer |
| | |
| | | </div> |
| | | <div style="display: flex;justify-content: flex-end;"> |
| | | <el-button size="small" plain type="success" @click="handleExcel">确定</el-button> |
| | | <el-button size="small" plain >取消</el-button> |
| | | <el-button size="small" plain @click="escHandler">取消</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | import {exportCode} from '@/api/GetItem' |
| | | import {exportCode,FindData} from '@/api/GetItem' |
| | | import func from "@/util/func"; |
| | | export default { |
| | | name: "MasterTransfer", |
| | | props:['visible','tableHeadData','codeClassifyOid','tableData','selectRow'], |
| | | props:['visible','tableHeadData','codeClassifyOid','tableData','selectRow','templateOid','limit'], |
| | | data(){ |
| | | return { |
| | | pageExport:"", |
| | | data: [], |
| | | value: [], |
| | | filterMethod(query, item) { |
| | |
| | | children: [] |
| | | }], |
| | | data: [] |
| | | } |
| | | }, |
| | | exportArr:{}, |
| | | ids:"" |
| | | }; |
| | | }, |
| | | watch:{ |
| | |
| | | mounted() { |
| | | }, |
| | | methods:{ |
| | | escHandler(){ |
| | | this.$emit('update:visible', false); |
| | | this.value=[]; |
| | | }, |
| | | //关闭页面 |
| | | recoverPage(){ |
| | | this.$emit('update:visible', false); |
| | | }, |
| | | handleExcel(){ |
| | | // this.$Export.excel({ |
| | | // title: this.option.title, |
| | | // columns: this.option.column, |
| | | // data: this.option.data |
| | | // }); |
| | | if(this.radio === 0){ |
| | | if(this.selectRow.length<=0){ |
| | | this.$message.warning('请选择要导出的模板') |
| | | }else { |
| | | //已选择多选 |
| | | const selectList=[] |
| | | //已选择属性 |
| | | let exportArr={} |
| | | const ids = this.selectRow.map(item => item.oid).join(',') |
| | | this.selectRow.forEach(item=>{ |
| | | selectList.push( |
| | | item.oid |
| | | ) |
| | | }) |
| | | this.value.map(index => this.tableHeadData[index].prop).forEach((item, index) => { |
| | | exportArr[`attrIdIndexMap[${index}]`] = item |
| | | }) |
| | | exportCode({codeClassifyOid:this.codeClassifyOid,'conditionMap[oid]':ids,...exportArr}).then(res=>{ |
| | | if(this.value <= 0){ |
| | | this.$message.warning('请选择属性') |
| | | }else { |
| | | this.value.map(index => this.tableHeadData[index].prop).forEach((item, index) => { |
| | | this.exportArr[`attrIdIndexMap[${index}]`] = item |
| | | }) |
| | | if(this.radio === 0){ |
| | | if(this.selectRow.length<=0){ |
| | | this.$message.warning('请选择要导出的模板') |
| | | }else { |
| | | //已选择多选 |
| | | const selectList=[] |
| | | //已选择属性 |
| | | let exportArr={} |
| | | const ids = this.selectRow.map(item => item.oid).join(',') |
| | | this.selectRow.forEach(item=>{ |
| | | selectList.push( |
| | | item.oid |
| | | ) |
| | | }) |
| | | exportCode({codeClassifyOid:this.codeClassifyOid,'conditionMap[oid]':this.ids,...this.exportArr}).then(res=>{ |
| | | // console.log('res',res) |
| | | if(res){ |
| | | func.downloadFileByBlob(res); |
| | | this.escHandler() |
| | | } |
| | | }) |
| | | |
| | | } |
| | | }else if(this.radio === 1){ |
| | | this.ids=this.tableData.map(item => item.oid).join(',') |
| | | exportCode({codeClassifyOid:this.codeClassifyOid,...this.exportArr,limit:-1}).then(res=>{ |
| | | // console.log('res',res) |
| | | if(res){ |
| | | func.downloadFileByBlob(res); |
| | | this.escHandler() |
| | | } |
| | | }) |
| | | |
| | | }else if(this.radio === 2){ |
| | | const input = this.pageExport.trim(); |
| | | let start, end; |
| | | if (input.includes('-')) { |
| | | if (input.indexOf('-') !== input.lastIndexOf('-')) { |
| | | this.$message.warning('输入格式错误:只能输入一个 - 号隔开'); |
| | | return; |
| | | } |
| | | //包含-解析 |
| | | const range = input.split('-'); |
| | | start = Number(range[0]); |
| | | end = Number(range[1]); |
| | | if (isNaN(start) || isNaN(end)) { |
| | | this.$message.warning('输入格式错误'); |
| | | return; |
| | | } |
| | | } else { |
| | | //不包含-解析 |
| | | start = Number(input); |
| | | end = start; |
| | | if (isNaN(start)) { |
| | | this.$message.warning('输入格式错误'); |
| | | return; |
| | | } |
| | | } |
| | | exportCode({ codeClassifyOid: this.codeClassifyOid, ...this.exportArr, limit: this.limit, page: start, endPage: end }).then((res) => { |
| | | // console.log('res',res) |
| | | if (res) { |
| | | func.downloadFileByBlob(res); |
| | | this.escHandler() |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | } |
| | | |
| | | }, |
| | | } |
| | | } |