86134
2023-11-08 480fd6b48efc83dc4754ea2d6211e5b0f3a97429
src/views/quality/rawMaterial/index.vue
@@ -19,12 +19,16 @@
        <basic-container>
            <ttable 
            :table="table"
            :resultData="resultData"
            @handleSelectionChange="handleSelectionChange"
            :prelang="prelang"
            :options="options"
            :ajaxFun="ajaxFun"
            @queryParam="getQueryParam($event)"
            ref="rawMaterialTable">
            <template #toolbar></template>
            <template #toolbar>
                <el-button @click="exportRawMaterial" type="primary" >导出</el-button>
            </template>
            </ttable>
        </basic-container>
        <!-- 弹窗, 新增 / 修改 -->
@@ -35,16 +39,17 @@
        ></RawMaterialForm>
    </div>
</template>
<script>
import ttable from '@/views/common/ztt-table.vue'
import { getRawInspectList,delObj } from '@/api/quality/rawMaterial'
import { getRawInspectList,delObj,exportRawMaterial } from '@/api/quality/rawMaterial'
import RawMaterialForm from './rawMaterial-form'
import * as fecha from 'element-ui/lib/utils/date'
import { mapGetters } from 'vuex'
  export default {
    data() {
        return {
            queryParam: {},
            resultData:[],
            addOrUpdateVisible: false,
            type: [1],
            prelang: 'rawMaterial',
@@ -61,7 +66,7 @@
                isRefresh: true, // 是否显示刷新按钮
                isShowHide: true, // 是否显示显影按钮H
                isSearch: true, // 高级查询按钮
                defaultOrderBy: { column: 'formTime', direction: 'desc' },
                defaultOrderBy: { column: 'createTime', direction: 'desc' },
            },
            table: {
                total: 0,
@@ -78,6 +83,14 @@
                        isSearch: true,
                        searchInfoType: 'text',
                        render: { fun: this.addOrUpdateHandle }
                    },
                    {
                        minWidth: '120',
                        prop: 'projectName',
                        label: '项目名称',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '120',
@@ -127,6 +140,7 @@
                        prop: 'createTime',
                        label: '报检日期',
                        isTrue: true,
                        sort: true,
                        isSearch: true,
                        searchInfoType: 'text',
                        formatter: this.formatDateTime,
@@ -166,8 +180,11 @@
                        label: '合格状态',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text',
                        searchInfoType: 'select',
                        formatter: this.formatJudgeState,
                        optList: () => {
                                return this.StateList
                            }
                    },
                ],
                toolbar: [
@@ -175,16 +192,8 @@
                    text: '新增',
                    type: 'primary',
                    fun: this.addOrUpdateHandle
                },
                {
                    text: '导出',
                }
                ],
                }],
                operator: [{
                    text: '打印',
                    type: 'text',
                    size: 'small',
                },{
                    text: '作废',
                    type: 'text',
                    size: 'small',
@@ -197,19 +206,57 @@
                minWidth: 100
                },
            },
            insStateList: [{label:'全部',value:''},{label:'已检测',value:'1'},{label:'未检测',value:'0'}]
            insStateList: [{label:'全部',value:''},{label:'已检测',value:'1'},{label:'未检测',value:'0'}],
            StateList: [{label:'全部',value:''},{label:'已合格',value:'1'},{label:'不合格',value:'0'}],
        }
    },
    // props:{
    //     queryParam:{
    //         type: Object,
    //         default: ()=>{
    //             return {}
    //         }
    //     }
    // },
    components: {
        ttable,
        RawMaterialForm,
    },
    created() {
    },
    computed: {
        ...mapGetters(['permissions'])
    },
    methods:{
        getQueryParam(data){
            this.queryParam = data
        },
        exportRawMaterial(){
            exportRawMaterial(this.queryParam).then(res=>{
                console.log(res)
                this.downloadFun(res)
            }).catch(error=>{
                console.log(error);
            })
        },
        downloadFun(result){
            if(result == null || result == undefined){
                return;
            }
            var nameList = result.headers['content-disposition'];
            nameList = decodeURI(nameList);
            var fileName = nameList.split('=')[1];
            const blob = new Blob([result.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
            const downloadElement = document.createElement('a') // 新建一个DOM节点
            const href = window.URL.createObjectURL(blob) // 创建下载的链接
            downloadElement.href = href
            downloadElement.download = fileName // 下载后文件名
            document.body.appendChild(downloadElement) // 将新增的节点挂载到页面上
            downloadElement.click() // 点击下载
            document.body.removeChild(downloadElement) // 下载完成移除元素
            window.URL.revokeObjectURL(href)
        },
        // 删除
        deleteHandle(row) {
        this.$confirm('是否确认删除该数据:' + row.code , '提示', {
@@ -260,6 +307,7 @@
        },
        getData() {
            this.$refs.rawMaterialTable.getDataList()
        },
        // table自带事件
        handleSelectionChange(val) {