王震
2023-12-04 8afbe0b83915dc417cea62221782e7ce15c00c78
src/views/quality/packageinspect/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,231 @@
<!--
  -    Copyright (c) 2018-2025, ztt All rights reserved.
  -
  - Redistribution and use in source and binary forms, with or without
  - modification, are permitted provided that the following conditions are met:
  -
  - Redistributions of source code must retain the above copyright notice,
  - this list of conditions and the following disclaimer.
  - Redistributions in binary form must reproduce the above copyright
  - notice, this list of conditions and the following disclaimer in the
  - documentation and/or other materials provided with the distribution.
  - Neither the name of the pig4cloud.com developer nor the names of its
  - contributors may be used to endorse or promote products derived from
  - this software without specific prior written permission.
  - Author: ztt
  -->
  <template>
    <div class="mod-config">
        <basic-container>
            <ttable
            :table="table"
            :resultData="resultData"
            @handleSelectionChange="handleSelectionChange"
            :prelang="prelang"
            :options="options"
            :ajaxFun="ajaxFun"
            ref="packageInspectTable">
            <template #toolbar>
            </template>
            </ttable>
        </basic-container>
        <!-- å¼¹çª—, æ–°å¢ž / ä¿®æ”¹ -->
        <!-- <RawMaterialForm
            v-if="addOrUpdateVisible"
            ref="addOrUpdate"
            @refreshDataList="getData"
        ></RawMaterialForm> -->
    </div>
</template>
<script>
import ttable from '@/views/common/ztt-table.vue'
import { fetchList,deleteById } from '@/api/quality/packageInspect'
// import RawMaterialForm from './rawMaterial-form'
import * as fecha from 'element-ui/lib/utils/date'
import { mapGetters } from 'vuex'
  export default {
    data() {
        return {
            resultData:[],
            addOrUpdateVisible: false,
            type: [1],
            multipleSelection: [],
            prelang: 'packageInspect',
            ajaxFun: fetchList,
            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: '180',
                        prop: 'packInsNo',
                        label: '包装检验编号',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text',
                        render: { fun: this.addOrUpdateHandle }
                    },
                    {
                        minWidth: '180',
                        prop: 'packageNo',
                        label: '包装编码',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '180',
                        prop: 'contractNo',
                        label: '合同号',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '180',
                        prop: 'projectName',
                        label: '项目名称',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '180',
                        prop: 'customerName',
                        label: '客户名称',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '180',
                        prop: 'createTime',
                        label: '报检日期',
                        isTrue: true,
                        sort: true,
                        isSearch: true,
                        searchInfoType: 'text',
                        formatter: this.formatDateTime,
                    },
                    {
                        minWidth: '180',
                        prop: 'createUser',
                        label: '报检人',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                    {
                        minWidth: '200',
                        prop: 'result',
                        label: '结论',
                        isTrue: true,
                        isSearch: true,
                        searchInfoType: 'text'
                    },
                ],
                toolbar: [
                    // {
                    //     text: '新增',
                    //     type: 'primary',
                    //     fun: this.addOrUpdateHandle
                    // },
                ],
                operator: [
                {
                    text: '作废',
                    type: 'text',
                    size: 'small',
                    fun: this.deleteHandle
                }],
                operatorConfig: {
                fixed: 'right',
                label: '操作',
                width: 100,
                minWidth: 100
                },
            },
        }
    },
    components: {
        ttable,
    },
    created() { },
    computed: {
        ...mapGetters(['permissions'])
    },
    watch:{
    },
    methods:{
        // åˆ é™¤
        deleteHandle(row) {
            const _than = this
            this.$confirm('是否确认删除包装编号【' + row.packInsNo+'】的数据?' , '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                closeOnClickModal: false,
                type: 'warning'
            }).then(function() {
                deleteById(row.id).then((response)=>{
                    var data = response.data
                    if (data.code == 0) {
                        _than.$message.success('删除成功')
                    } else {
                        _than.$message.error('删除失败')
                    }
                    _than.getData()
                })
            }).catch((error) => {
                console.log(error);
            })
        },
        // æ–°å¢ž / ä¿®æ”¹
        addOrUpdateHandle(row) {
            this.$router.push({
                name: 'packageInspectForm',
                query: {
                    id: row == null ? null : row.id
                 },
                 params:{resultVal : row.result=='' ? null : row.result}
            })
        },
        formatResult(row, column, cellValue){
            if(cellValue != undefined || cellValue != null){
                if(cellValue == '不合格'){
                    return "<span style='color:#E84738;'>不合格</span>"
                }
                return "<span style='color:#34BD66;'>合格</span>"
            }
        },
        formatDateTime(row, column, cellValue) {
            return cellValue ? fecha.format(new Date(cellValue), 'yyyy-MM-dd') : ''
        },
        getData() {
            this.$refs.packageInspectTable.getDataList()
        },
        // table自带事件
        handleSelectionChange(val) {
            this.multipleSelection = val
        },
    }
  }
  </script>