zouyu
2023-12-21 a48ded866d223f581944ea9043df1b296b3425e3
src/views/quality/finishedProductInspection/index.vue
@@ -35,272 +35,282 @@
   import finishedProductInspectionAdd from './finishedProduct-form'
    import { page,deletePro,exportExaminationProducts,queryById } from '@/api/quality/finishedProduct'
    import { transform } from '@/util/fileTransform'
    import { mapGetters } from 'vuex'
    import printTemplate from './finishedProducter-print.vue'
    import PrintJS from 'print-js'
    import { title } from 'process'
   export default {
      components: {
         finishedProductInspectionAdd,
            ttable,
            printTemplate
      },
      data() {
         return {
                printFormData: null,
                printDialogVisible: false,
                result:[{label:'全部',value: ''},{label:'合格',value: '1'},{label:'不合格',value: '0'}],
                type: [1],
                prelang: 'finishedProduct',
                ajaxFun: page,
                options: {
                    height: 300, // 默认高度-为了表头固定
                    stripe: true, // 是否为斑马纹 table
                    highlightCurrentRow: false, // 是否要高亮当前行
                    border: true, // 是否有纵向边框
                    lazy: false, // 是否需要懒加载
                    fit: true, // 列的宽度是否自撑开
                    multiSelect: true, //
                    seqNo: true,
                    isRefresh: true, // 是否显示刷新按钮
                    isShowHide: true, // 是否显示显影按钮H
                    isSearch: true, // 高级查询按钮
                    defaultOrderBy: { column: 'createTime', direction: 'desc' },
                },
                table: {
                    total: 0,
                    currentPage: 1,
                    pageSize: 20,
                    data: [],
                    // 标题
                    column: [
                         {
                            minWidth: '120',
                            prop: 'finInsNo',
                            label: '产品检验编号',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text',
                            render: { fun: this.addOrUpdateHandle }
                        },
    components: {
        finishedProductInspectionAdd,
        ttable,
        printTemplate
    },
    data() {
        return {
            printFormData: null,
            printDialogVisible: false,
            result:[{label:'全部',value: ''},{label:'合格',value: '1'},{label:'不合格',value: '0'}],
            type: [1],
            prelang: 'finishedProduct',
            ajaxFun: page,
            options: {
                height: 300, // 默认高度-为了表头固定
                stripe: true, // 是否为斑马纹 table
                highlightCurrentRow: false, // 是否要高亮当前行
                border: true, // 是否有纵向边框
                lazy: false, // 是否需要懒加载
                fit: true, // 列的宽度是否自撑开
                multiSelect: true, //
                seqNo: true,
                isRefresh: true, // 是否显示刷新按钮
                isShowHide: true, // 是否显示显影按钮H
                isSearch: true, // 高级查询按钮
                defaultOrderBy: { column: 'createTime', direction: 'desc' },
            },
            table: {
                total: 0,
                currentPage: 1,
                pageSize: 20,
                data: [],
                // 标题
                column: [
                        {
                            minWidth: '120',
                            prop: 'productNo',
                            label: '报工单号',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '120',
                            prop: 'orderNumber',
                            label: '订单号',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '120',
                            prop: 'customerName',
                            label: '客户名称',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '130',
                            width: '150',
                            prop: 'projectName',
                            label: '工程名称',
                            sort: true,
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text',
                        },
                        {
                            minWidth: '120',
                            prop: 'outBatchNo',
                            label: '批次号',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '120',
                            prop: 'materialCode',
                            label: '产品编号',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '120',
                            prop: 'material',
                            label: '产品大类',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '120',
                            prop: 'specs',
                            label: '规格型号',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '120',
                            prop: 'unit',
                            label: '单位',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '120',
                            prop: 'quantity',
                            label: '数量',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'text'
                        },
                        {
                            minWidth: '120',
                            prop: 'createTime',
                            label: '检验日期',
                            sort: true,
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'datetimerange',
                            formatter: this.formatDateTime,
                        },
                        {
                            minWidth: '120',
                            prop: 'result',
                            label: '检测结果',
                            isTrue: true,
                            isSearch: true,
                            searchInfoType: 'select',
                            formatter: this.formatResult,
                            optList: () => {
                                return this.result
                            }
                        },
                    ],
                    toolbar: [
                        {
                            text: '下载检验报告',
                            type: 'primary',
                            fun: this.downloadProReport
                        }
                    ],
                    operator: [{
                        text: '作废',
                        type: 'text',
                        size: 'small',
                        fun: this.deleteHandle
                    }],
                    operatorConfig: {
                    fixed: 'right',
                    label: '操作',
                    width: 100,
                    minWidth: 100
                        minWidth: '120',
                        prop: 'finInsNo',
                        label: '产品检验编号',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text',
                        render: { fun: this.addOrUpdateHandle }
                    },
                    {
                        minWidth: '120',
                        prop: 'productNo',
                        label: '报工单号',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
                        prop: 'orderNumber',
                        label: '订单号',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
                        prop: 'customerName',
                        label: '客户名称',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '130',
                        width: '150',
                        prop: 'projectName',
                        label: '工程名称',
                        sort: true,
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text',
                    },
                    {
                        minWidth: '120',
                        prop: 'outBatchNo',
                        label: '批次号',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
                        prop: 'materialCode',
                        label: '产品编号',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
                        prop: 'material',
                        label: '产品大类',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
                        prop: 'specs',
                        label: '规格型号',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
                        prop: 'unit',
                        label: '单位',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
                        prop: 'quantity',
                        label: '数量',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
                        prop: 'createTime',
                        label: '检验日期',
                        sort: true,
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'datetimerange',
                        formatter: this.formatDateTime,
                    },
                    {
                        minWidth: '120',
                        prop: 'result',
                        label: '检测结果',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'select',
                        formatter: this.formatResult,
                        optList: () => {
                            return this.result
                        }
                    },
                ],
                toolbar: [],
                operator: null,
                operatorConfig: {
                fixed: 'right',
                label: '操作',
                width: 100,
                minWidth: 100
                },
         }
      },
      created() { },
        watch:{
            },
        }
    },
    created() {
        if(this.permissions.quality_finishedProductInspection_download){
            this.table.toolbar.push({
                text: '下载检验报告',
                type: 'primary',
                fun: this.downloadProReport
            })
        }
        if(this.permissions.quality_finishedProductInspection_del){
            this.table.operator = [{
                    text: '作废',
                    type: 'text',
                    size: 'small',
                    fun: this.deleteHandle
                }]
        }
    },
    computed: {
        ...mapGetters(['permissions'])
    },
    watch:{
        printFormData(newVal){
            if(newVal){
                this.printFormData = newVal
            }
        }
    },
      methods: {
            downloadProReport(){
                this.$message.info("开发中...")
            },
            //打印按钮
            printFun() {
                const style = '@page {margin: 10mm 5mm; margin-bottom: 0;margin-top:0;} ' +'@media print {.title{font-size:30pt;font-weight: 400;font-family: 黑体;!important;}' ;
                PrintJS({
                    printable: "printRaw",
                    type: "html",
                    scanStyles: false,
                    maxWidth: 1200,
                    header: "产品检测报告",
                    style:style,
                    css:'./title.css',
                    targetStyles: ["*"],
                    ignoreElements: ["no-ignore"],
                    orientation: 'portrait'
                });
            },
            //查看报告按钮
            showPrint(row){
                queryById(row.id).then(res=>{
                    this.printFormData = res.data.data
                    this.printFormData.createTime = row.createTime
                    this.printFormData.updateTime = row.updateTime
                    this.printDialogVisible = true
                }).catch(error=>{
                })
            },
            exportExcel(){
                let queryParam=this.$refs.finishedProduct.getQueryParam();
                delete queryParam.criteria
                exportExaminationProducts(queryParam).then((res)=>{
                    transform(res)
                })
            },
         deleteHandle(row){
            this.$confirm('确认删除该数据吗?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            }).then(()=>{
               deletePro(row.id).then(res=>{
                  if(res.data.code == 0){
                     this.$message.success("删除成功")
                  }else{
                     this.$message.error("删除失败")
                  }
                  this.getData()
               })
            })
         },
         // 新增 / 修改
         addOrUpdateHandle(row) {
            this.$router.push({
               name: 'finishedProductForm',
               query: {
                        id: row == null ? null : row.id,
                    },
                    params: {
                        resultVal: row == null ? null : row.result
    methods: {
        downloadProReport(){
        },
        //打印按钮
        printFun() {
            const style = '@page {margin: 10mm 5mm; margin-bottom: 0;margin-top:0;} ' +'@media print {.title{font-size:30pt;font-weight: 400;font-family: 黑体;!important;}' ;
            PrintJS({
                printable: "printRaw",
                type: "html",
                scanStyles: false,
                maxWidth: 1200,
                header: "产品检测报告",
                style:style,
                css:'./title.css',
                targetStyles: ["*"],
                ignoreElements: ["no-ignore"],
                orientation: 'portrait'
            });
        },
        //查看报告按钮
        showPrint(row){
            queryById(row.id).then(res=>{
                this.printFormData = res.data.data
                this.printFormData.createTime = row.createTime
                this.printFormData.updateTime = row.updateTime
                this.printDialogVisible = true
            }).catch(error=>{
            })
        },
        exportExcel(){
            let queryParam=this.$refs.finishedProduct.getQueryParam();
            delete queryParam.criteria
            exportExaminationProducts(queryParam).then((res)=>{
                transform(res)
            })
        },
        deleteHandle(row){
            this.$confirm('确认删除该数据吗?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            }).then(()=>{
                deletePro(row.id).then(res=>{
                    if(res.data.code == 0){
                        this.$message.success("删除成功")
                    }else{
                        this.$message.error("删除失败")
                    }
            })
         },
            formatResult(row, column, cellValue){
                if(cellValue != undefined || cellValue != null){
                    if(cellValue == 0){
                        return "<span style='color:#E84738;'>不合格</span>"
                    }else if(cellValue == 1){
                        return "<span style='color:#34BD66;'>合格</span>"
                    }
                    this.getData()
                })
            })
        },
        // 新增 / 修改
        addOrUpdateHandle(row) {
            if(!this.permissions.quality_finishedProductInspection_edit && row.id!=null){
                this.$message.error("该角色没有操作权限")
                return
            }
            this.$router.push({
                name: 'finishedProductForm',
                query: {
                    id: row == null ? null : row.id,
                },
                params: {
                    resultVal: row == null ? null : row.result
                }
            },
            formatDateTime(row, column, cellValue) {
                return cellValue ? fecha.format(new Date(cellValue), 'yyyy-MM-dd') : ''
            },
            handleSelectionChange(){ },
         getData() {
            this.$refs.finishedProduct.getDataList()
         },
      }
   }
            })
        },
        formatResult(row, column, cellValue){
            if(cellValue != undefined || cellValue != null){
                if(cellValue == 0){
                    return "<span style='color:#E84738;'>不合格</span>"
                }else if(cellValue == 1){
                    return "<span style='color:#34BD66;'>合格</span>"
                }
            }
        },
        formatDateTime(row, column, cellValue) {
            return cellValue ? fecha.format(new Date(cellValue), 'yyyy-MM-dd') : ''
        },
        handleSelectionChange(){ },
        getData() {
            this.$refs.finishedProduct.getDataList()
        },
    }
}
</script>
<style scope="scope">