| | |
| | | <template> |
| | | <div class="mod-config"> |
| | | <basic-container> |
| | | <ttable |
| | | <ttable |
| | | :table="table" |
| | | :resultData="resultData" |
| | | @handleSelectionChange="handleSelectionChange" |
| | |
| | | @queryParam="getQueryParam($event)" |
| | | ref="rawMaterialTable"> |
| | | <template #toolbar> |
| | | <el-button @click="exportRawMaterial" type="primary" >导出</el-button> |
| | | <!-- <el-button @click="exportRawMaterial" type="primary" >导出</el-button> --> |
| | | </template> |
| | | </ttable> |
| | | </basic-container> |
| | |
| | | @refreshDataList="getData" |
| | | ></RawMaterialForm> |
| | | <el-dialog |
| | | top="10vh" |
| | | top="7vh" |
| | | title="打印预览" |
| | | :visible.sync="printDialogVisible" |
| | | width="60%"> |
| | | <div style="width:100%;height: 60vh;overflow-y: scroll;"> |
| | | width="70%"> |
| | | <div style="width:90%;margin-left:5%;height: 60vh;overflow-y: scroll;"> |
| | | <printTemplate id="printRaw" :formData="printFormData"></printTemplate> |
| | | </div> |
| | | <span slot="footer" class="dialog-footer"> |
| | |
| | | </template> |
| | | <script> |
| | | import ttable from '@/views/common/ztt-table.vue' |
| | | import { getRawInspectList,delObj,exportRawMaterial,getObj } from '@/api/quality/rawMaterial' |
| | | import { getRawInspectList,delObj,exportRawMaterial,getObj,downloadReport } from '@/api/quality/rawMaterial' |
| | | import RawMaterialForm from './rawMaterial-form' |
| | | import * as fecha from 'element-ui/lib/utils/date' |
| | | import { mapGetters } from 'vuex' |
| | | import PrintJS from 'print-js' |
| | | import printTemplate from './rawMaterial-print.vue' |
| | | import { transformZip } from '@/util/fileTransform' |
| | | import printTemplate from './rawMaterial-print' |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | resultData:[], |
| | | addOrUpdateVisible: false, |
| | | type: [1], |
| | | multipleSelection: [], |
| | | prelang: 'rawMaterial', |
| | | ajaxFun: getRawInspectList, |
| | | options: { |
| | |
| | | column: [ |
| | | { |
| | | minWidth: '120', |
| | | prop: 'code', |
| | | label: '原材料编码', |
| | | prop: 'rawInsNo', |
| | | label: '原材料检验编号', |
| | | isTrue: true, |
| | | isSearch: true, |
| | | searchInfoType: 'text', |
| | | render: { fun: this.addOrUpdateHandle } |
| | | }, |
| | | { |
| | | minWidth: '120', |
| | | prop: 'code', |
| | | label: '原材料编码', |
| | | isTrue: true, |
| | | isSearch: true, |
| | | searchInfoType: 'text' |
| | | }, |
| | | { |
| | | minWidth: '120', |
| | |
| | | } |
| | | }, |
| | | ], |
| | | toolbar: [ |
| | | { |
| | | text: '新增', |
| | | type: 'primary', |
| | | fun: this.addOrUpdateHandle |
| | | }], |
| | | operator: [{ |
| | | text: '打印', |
| | | type: 'text', |
| | | size: 'small', |
| | | fun: this.previewFun |
| | | }, |
| | | { |
| | | text: '作废', |
| | | type: 'text', |
| | | size: 'small', |
| | | fun: this.deleteHandle |
| | | }], |
| | | toolbar: [], |
| | | operator: null, |
| | | operatorConfig: { |
| | | fixed: 'right', |
| | | label: '操作', |
| | |
| | | printTemplate, |
| | | }, |
| | | created() { |
| | | |
| | | }, |
| | | if(this.permissions.quality_rawMaterial_add){ |
| | | this.table.toolbar.push({ |
| | | text: '新增', |
| | | type: 'primary', |
| | | fun: this.addOrUpdateHandle |
| | | }) |
| | | } |
| | | if(this.permissions.quality_rawMaterial_download){ |
| | | this.table.toolbar.push({ |
| | | text: '下载检验报告', |
| | | type: 'primary', |
| | | fun: this.downloadReport |
| | | }) |
| | | } |
| | | if(this.permissions.quality_rawMaterial_del){ |
| | | this.table.operator = [{ |
| | | text: '作废', |
| | | type: 'text', |
| | | size: 'small', |
| | | fun: this.deleteHandle |
| | | }] |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['permissions']) |
| | | }, |
| | |
| | | } |
| | | }, |
| | | methods:{ |
| | | downloadReport(){ |
| | | let selection = this.multipleSelection |
| | | if(!selection || selection.length < 1){ |
| | | this.$message.error("请先选择检验数据") |
| | | return |
| | | }else{ |
| | | let arr = selection.filter(s=>{ |
| | | return s.judgeState==null || s.judgeState=='' |
| | | }) |
| | | if(arr.length > 0){ |
| | | this.$message.error("只能选择已检测的数据") |
| | | return |
| | | } |
| | | let ids = [] |
| | | selection.forEach(ele=>{ |
| | | ids.push(ele.id) |
| | | }) |
| | | downloadReport({ids : ids}).then(res=>{ |
| | | transformZip(res) |
| | | }).catch(error=>{ |
| | | console.log(error) |
| | | }) |
| | | } |
| | | }, |
| | | //查看报告按钮 |
| | | previewFun(row){ |
| | | getObj(row.id).then(res=>{ |
| | | console.log(res); |
| | | this.printFormData = res.data.data |
| | | this.printDialogVisible = true |
| | | }).catch(error=>{ |
| | |
| | | PrintJS({ |
| | | printable: "printRaw", |
| | | type: "html", |
| | | maxWidth: 900, |
| | | // header: "原材料检测报告", |
| | | style: '@page {margin: 0 5mm}', |
| | | targetStyles: ["*"], |
| | | style: `@page {margin: 0mm 5mm;size: A4;} |
| | | html {zoom:100%;} |
| | | @media print { |
| | | html,body{ |
| | | width:200mm; |
| | | height:297mm; |
| | | } |
| | | }`, |
| | | ignoreElements: ["no-ignore"], |
| | | orientation: 'portrait' |
| | | }); |
| | |
| | | }, |
| | | exportRawMaterial(){ |
| | | exportRawMaterial(this.queryParam).then(res=>{ |
| | | console.log(res) |
| | | this.downloadFun(res) |
| | | }).catch(error=>{ |
| | | console.log(error); |
| | |
| | | }, |
| | | // 新增 / 修改 |
| | | addOrUpdateHandle(row) { |
| | | if(!this.permissions.quality_rawMaterial_edit && row.id!=null){ |
| | | this.$message.error("该角色没有操作权限") |
| | | return |
| | | } |
| | | this.$router.push({ |
| | | name: 'rawMaterialForm', |
| | | query: { |
| | | id: row == null ? null : row.id, |
| | | query: { |
| | | id: row == null ? null : row.id |
| | | }, |
| | | params: { |
| | | resultVal: row == null ? null : row.judgeState |
| | | } |
| | | }) |
| | |
| | | } |
| | | }, |
| | | formatJudgeState(row, column, cellValue){ |
| | | if(cellValue != undefined || cellValue != null){ |
| | | if(cellValue != undefined && cellValue != null && cellValue != ''){ |
| | | if(cellValue == 0){ |
| | | return "<span style='color:#E84738;'>不合格</span>" |
| | | } |
| | |
| | | }, |
| | | getData() { |
| | | this.$refs.rawMaterialTable.getDataList() |
| | | |
| | | }, |
| | | // table自带事件 |
| | | handleSelectionChange(val) { |
| | | this.multipleSelection = val |
| | | // 根据状态,禁用表头按钮 |
| | | // 筛选出选中记录的状态 |
| | | var stateArr = val.map(function(value, index) { |
| | | return value.coState |
| | | }) |
| | | // var stateArr = val.map(function(value, index) { |
| | | // return value.coState |
| | | // }) |
| | | // 选中状态数组元素去重 |
| | | var uniqueStateArr = [] |
| | | for (var i = 0; i < stateArr.length; i++) { |
| | | if (uniqueStateArr.indexOf(stateArr[i]) == -1) { |
| | | uniqueStateArr.push(stateArr[i]) |
| | | } |
| | | } |
| | | // var uniqueStateArr = [] |
| | | // for (var i = 0; i < stateArr.length; i++) { |
| | | // if (uniqueStateArr.indexOf(stateArr[i]) == -1) { |
| | | // uniqueStateArr.push(stateArr[i]) |
| | | // } |
| | | // } |
| | | // 循环自定义按钮,判断每个按钮的permitArr是否完全包含选中状态,若完全包含,则按钮亮,否则按钮灰 |
| | | for (var i = 0; i < this.stateTagArr.length; i++) { |
| | | if ( |
| | | uniqueStateArr.every((val) => |
| | | this.stateTagArr[i].permitArr.length <= 0 |
| | | ? true |
| | | : this.stateTagArr[i].permitArr.includes(val) |
| | | ) |
| | | ) { |
| | | this.stateTagArr[i].disabled = false |
| | | } else { |
| | | this.stateTagArr[i].disabled = true |
| | | } |
| | | } |
| | | this.multipleSelection = val |
| | | // for (var i = 0; i < this.stateTagArr.length; i++) { |
| | | // if ( |
| | | // uniqueStateArr.every((val) => |
| | | // this.stateTagArr[i].permitArr.length <= 0 |
| | | // ? true |
| | | // : this.stateTagArr[i].permitArr.includes(val) |
| | | // ) |
| | | // ) { |
| | | // this.stateTagArr[i].disabled = false |
| | | // } else { |
| | | // this.stateTagArr[i].disabled = true |
| | | // } |
| | | // } |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | | |