zouyu
2024-03-07 62be85bac61d46f1a60fa77c2e9532a57e1b4850
src/views/quality/rawMaterial/index.vue
@@ -17,7 +17,7 @@
<template>
    <div class="mod-config">
        <basic-container>
            <ttable
            <ttable
            :table="table"
            :resultData="resultData"
            @handleSelectionChange="handleSelectionChange"
@@ -27,7 +27,7 @@
            @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>
@@ -54,12 +54,13 @@
</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,checkPutIFS } 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 {
@@ -101,6 +102,29 @@
                        isSearch: true,
                        searchInfoType: 'text',
                        render: { fun: this.addOrUpdateHandle }
                    },
                    {
                        minWidth: '120',
                        prop: 'type',
                        label: '检验类型',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'select',
                        optList: () => {
                            return this.typeList
                        }
                    },
                    {
                        minWidth: '120',
                        prop: 'checkState',
                        label: '审核状态',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'select',
                        formatter: this.checkStateFormat,
                        optList: () => {
                            return this.checkStateList
                        }
                    },
                    {
                        minWidth: '120',
@@ -213,37 +237,8 @@
                            }
                    },
                ],
                toolbar: [
                    {
                        text: '新增',
                        type: 'primary',
                        fun: this.addOrUpdateHandle
                    },
                    {
                        text: '下载检验报告',
                        type: 'primary',
                        fun: this.downloadReport
                    }
                ],
                operator: [{
                    text: '打印',
                    type: 'text',
                    size: 'small',
                    fun: this.previewFun,
                    show: {
                        val: [
                            '1',
                            '0'
                        ],
                        key: 'judgeState'
                    }
                },
                {
                    text: '作废',
                    type: 'text',
                    size: 'small',
                    fun: this.deleteHandle
                }],
                toolbar: [],
                operator: null,
                operatorConfig: {
                fixed: 'right',
                label: '操作',
@@ -253,6 +248,8 @@
            },
            insStateList: [{label:'全部',value:''},{label:'已检测',value:'1'},{label:'未检测',value:'0'}],
            StateList: [{label:'全部',value:''},{label:'已合格',value:'1'},{label:'不合格',value:'0'}],
            typeList: [{label:'全部',value:''},{label:'首检',value:'首检'},{label:'返检',value:'返检'}],
            checkStateList: [{label:'未审核',value:'0'},{label:'审核通过',value:'1'},{label:'审核不通过',value:'2'}],
        }
    },
    components: {
@@ -260,7 +257,48 @@
        RawMaterialForm,
        printTemplate,
    },
    created() { },
    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',
                loading: false,
                disabled: false,
                fun: this.downloadReport,
            })
        }
        this.table.operator = [{
            text: '审核',
            type: 'text',
            size: 'small',
            fun: this.examineHandle,
            showFun: (row)=>{return row.type==='首检'},
            show: {
                key: 'checkState',
                val: ['0']
            }
        }]
        if(this.permissions.quality_rawMaterial_del){
            this.table.operator.push({
                    text: '作废',
                    type: 'text',
                    size: 'small',
                    fun: this.deleteHandle,
                    show: {
                        key: 'judgeState',
                        val: ['',null]
                    }
                })
        }
     },
    computed: {
        ...mapGetters(['permissions'])
    },
@@ -272,6 +310,29 @@
        }
    },
    methods:{
        examineHandle(val){
            this.$confirm('是否审核通过该检验项?', '提示', {
                distinguishCancelAndClose: true,
                confirmButtonText: '通过',
                cancelButtonText: '不通过',
                type: 'warning'
            }).then(() => {
                this.checkPutIFSFun(val.id,1);
            }).catch((action) => {
                if(action === 'cancel'){
                    this.checkPutIFSFun(val.id,2);
                }
            });
        },
        checkPutIFSFun(id,result){
            checkPutIFS(id, result).then(res=>{
                if(res.status===200){
                    this.getData()
                }
            }).catch(error=>{
                console.error(error)
            })
        },
        downloadReport(){
            let selection = this.multipleSelection
            if(!selection || selection.length < 1){
@@ -285,7 +346,22 @@
                    this.$message.error("只能选择已检测的数据")
                    return
                }
                console.log(selection)
                let ids = []
                selection.forEach(ele=>{
                    ids.push(ele.id)
                })
                this.table.toolbar.find((e) => e.text === '下载检验报告').loading = true
                this.table.toolbar.find((e) => e.text === '下载检验报告').disabled = true
                try{
                    downloadReport({ids : ids}).then(res=>{
                        transformZip(res)
                    })
                }catch(error){
                    console.log(error)
                } finally{
                    this.table.toolbar.find((e) => e.text === '下载检验报告').loading = false
                    this.table.toolbar.find((e) => e.text === '下载检验报告').disabled = false
                }
            }
        },
        //查看报告按钮
@@ -322,7 +398,6 @@
        },
        exportRawMaterial(){
            exportRawMaterial(this.queryParam).then(res=>{
                console.log(res)
                this.downloadFun(res)
            }).catch(error=>{
                console.log(error);
@@ -366,10 +441,16 @@
        },
        // 新增 / 修改
        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
                 }
            })
@@ -383,12 +464,20 @@
            }
        },
        formatJudgeState(row, column, cellValue){
            if(cellValue != undefined || cellValue != null){
            if(cellValue != undefined && cellValue != null && cellValue != ''){
                if(cellValue == 0){
                    return "<span style='color:#E84738;'>不合格</span>"
                }
                return "<span style='color:#34BD66;'>合格</span>"
            }
        },
        checkStateFormat(row, column, cellValue){
            this.checkStateList.forEach((obj) => {
                if (obj.value === cellValue) {
                    cellValue = obj.label
                }
            })
            return cellValue
        },
        formatDateTime(row, column, cellValue) {
            return cellValue ? fecha.format(new Date(cellValue), 'yyyy-MM-dd') : ''
@@ -429,4 +518,3 @@
    }
  }
  </script>