zouyu
2023-11-24 ef0c3a4140ba4af8b629838c7a34884e39a64126
src/views/quality/rawMaterial/index.vue
@@ -69,6 +69,7 @@
            resultData:[],
            addOrUpdateVisible: false,
            type: [1],
            multipleSelection: [],
            prelang: 'rawMaterial',
            ajaxFun: getRawInspectList,
            options: {
@@ -205,11 +206,17 @@
                    },
                ],
                toolbar: [
                {
                    text: '新增',
                    type: 'primary',
                    fun: this.addOrUpdateHandle
                }],
                    {
                        text: '新增',
                        type: 'primary',
                        fun: this.addOrUpdateHandle
                    },
                    {
                        text: '下载检验报告',
                        type: 'primary',
                        fun: this.downloadReport
                    }
                ],
                operator: [{
                    text: '打印',
                    type: 'text',
@@ -245,9 +252,7 @@
        RawMaterialForm,
        printTemplate,
    },
    created() {
    },
    created() { },
    computed: {
        ...mapGetters(['permissions'])
    },
@@ -259,6 +264,22 @@
        }
    },
    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
                }
                console.log(selection)
            }
        },
        //查看报告按钮
        previewFun(row){
            getObj(row.id).then(res=>{
@@ -274,10 +295,17 @@
            PrintJS({
                printable: "printRaw",
                type: "html",
                maxWidth: 880,
                // header: "原材料检测报告",
                style: '@page {margin: 10mm 5mm;}',
                targetStyles: ["*"],
                style: `@page {margin: 0mm 5mm;size: A4;};
                    html {zoom:100%;};
                    @media print {
                 html,body{
                   width:880pt;
                   height:900pt;
                   margin:0;
                 }
               }`,
                ignoreElements: ["no-ignore"],
                orientation: 'portrait'
            });
@@ -360,37 +388,36 @@
        },
        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
            //     }
            // }
        },
    }
  }