chenlu
2024-05-23 0a567fd9c3baeb8022c77fa1a6a96d4c60cfa11c
north-glass-erp/northglass-erp/src/views/mm/stockReport/WarehouseReport.vue
@@ -1,288 +1,49 @@
<template>
  <div style="padding: 0;width: 100%;height: 100%">
    <el-header class="m-header" style="height: auto">
    </el-header>
    <el-main style="padding-top: 5px">
      <vxe-grid
          max-height="600"
          @filter-change="filterChanged"
          class="mytable-scrollbar"
          ref="xGrid"
          v-bind="gridOptions"
          v-on="gridEvents"
      >
        <!--      @toolbar-button-click="toolbarButtonClickEvent"-->
        <!--      下拉显示所有信息插槽-->
        <template #content="{ row}">
          <ul class="expand-wrapper">
            <li v-for="(item,key,index) in row">
              <span style="font-weight: bold">{{ key + ':  ' }}</span>
              <span>{{ item }}</span>
            </li>
          </ul>
        </template>
        <!--左边固定显示的插槽-->
        <template #button_slot="{ row }">
          <el-button @click="getTableRow(row,'edit')" link type="primary" size="small">编辑</el-button>
          <!--          <el-button @click="getTableRow(row,'delete')" link type="primary" size="small">删除</el-button>-->
          <!--          <el-button @click="cellClickEvent" link type="primary" size="small">详情</el-button>-->
        </template>
        <template #num1_filter="{ column, $panel }">
          <div>
            <div v-for="(option, index) in column.filters" :key="index">
              <input type="type" v-model="option.data" @input="changeFilterEvent($event, option, $panel)"/>
            </div>
          </div>
        </template>
      </vxe-grid>
    </el-main>
  </div>
</template>
<script setup>
import {ref} from 'vue'
import {reactive} from "vue";
import {useRouter} from 'vue-router'
import {Search} from "@element-plus/icons-vue";
import dayjs from "dayjs";
import {VXETable} from "vxe-table";
let router = useRouter()
const list =  (i) => {
  return {
    'kczz':'人工库',
    'wlbm':'NGWL202312000'+i,
    'wlmc':'这是物料名称',
    'cd':'地球村',
    'kcbh':'KC202300'+i,
    'w':'0',
    'g':'0',
    'h':'0',
    'zdw':'件',
    'aqkc':'0',
    'kcs':'20',
    'kykc':'30',
    'wlsl':'20',
    'zmj':'0',
    'dpmj':'0',
    'scrq':'2023-12-20',
    'bzq':'2025-12-20',
    'kq':'2000',
    'kw':'23',
    'jykc':'5',
    'bz':'这是备注*10086'
  }
}
import BasicTable from "@/components/BasicTable.vue"
import request from "@/utils/request"
import { ref} from "vue"
import { useI18n } from 'vue-i18n'
//组件接收参数
const gridOptions = reactive({
  border: "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe: true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true, height: 50},//鼠标移动或选择高亮
  id: 'CustomerList',
  showFooter: true,//显示脚
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  scrollY: {enabled: true},//开启虚拟滚动
  showOverflow: true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  filterConfig: {   //筛选配置项
    remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },
  columns: [
    /* {title: '操作', width: '8%', slots: {default: 'button_slot'}, fixed: "left"},*/
    {type: 'seq', fixed: "left", title: ' ', width: 50},
    /*{ type: 'checkbox',fixed:"left", title: '', width: 50 },*/
    {type: 'expand', title:'详情', fixed: "left", slots: {content: 'content'}, width: 50},
    {field: 'kczz', width: '13%', title: '库存组织', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'wlbm', width: '10%', title: '物料编码', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'wlmc', width: '10%',title: '物料名称', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'cd', width: '10%',title: '产地', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'kcbh', width: '10%', title: '库存编号', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'w', width: '8%',title: '宽度', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'g', width: '8%',title: '高度', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'h', width: '8%',title: '厚度', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'zdw', width: '8%',title: '主单位', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'aqkc', width: '8%',title: '安全库存', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'kcs', width: '12%',title: '库存数', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'kykc', width: '8%',title: '可用库存', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'wlsl', width: '12%',title: '未领数量', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'zmj', width: '8%',title: '总面积', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'dpmj', width: '12%',title: '单片面积', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'scrq', width: '8%',title: '生产日期', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'bzq', width: '8%',title: '保质期', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    /*{field: 'kcbh', width: '10%',title: '库存编号', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},*/
    {field: 'kq', width: '10%',title: '库区', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'kw', width: '10%',title: '库位', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'jykc', width: '10%',title: '积压库存', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'bz', width: '10%',title: '备注', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true}
  ],//表头参数
  toolbarConfig: {
    buttons: [{type:'text'},{
      'name': '入库记录',
      'code': 'StorageRecord',
    }],
    import: false,
    export: true,
    print: true,
    zoom: true,
    custom: true,
    style: 'paddling-left:10px'
  },//表头按钮
  data: [
    list(0),list(1),list(2),list(3),list(4),list(5),list(6),list(7),list(8),list(9),
//语言获取
const { t } = useI18n()
  ],//table body实际数据
  mergeFooterItems: [
    {row: 0, col: 0, rowspan: 1, colspan: 2}
  ],//合并脚
  footerMethod({columns, data}) {//页脚函数
    return [
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return '合计:'
        }
        /* if (props.tableProp.footList.includes(column.field)) {
           return sumNum(data, column.field)
         }*/
        return ''
      })
    ]
  },
const childrenData = ref({
  columns:[
    {type: 'seq',fixed:"left", title: t('basicData.Number'), width: '80' },
    {field: 'operationOrderNumber', width:'150', title: t('productStock.operationOrderNumber'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderId', width: '150',title: t('order.orderId'),showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'operationNumber', width: '100',title: t('order.OrderNum'), showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'operateType', width: '120',title:'类型',filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'quantity', width: '140',title: t('order.quantity'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderDetail.productId',width: '100', title: t('order.productId'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderDetail.productName',width: '140', title: t('order.product'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderDetail.width', width: '100',title: t('order.width'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderDetail.height',width: '100', title: t('order.height'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'staterOperationOrderNumber', width: '150',title: '调拨销售单号',filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'endOperationOrderNumber', width: '100',title: '调拨序号',filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'operator', width: '100',title: t('productStock.creator'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'operateTime', width:'140', title: t('productStock.productionDate'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'processId', width:'140', title: '流程卡号',filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'type', width:'140', title: '领出类型',filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'reviewed', width: '100',title: t('productStock.reviewed'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'reviewedTime', width: '140',title: t('productStock.approvedDate'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'remarks', width: '140',title: t('productStock.remarks'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
  ],//表格表头字段
  data:[],//表格数据
  url :'/FinishedGoodsInventory/getSelectFinishedOperateLogReport',
  exportUrl :'/FinishedGoodsInventory/exportFinishedOperateLogReport',
  exportName:'成品报表',
  footList:['quantity']
})
const getTableRow = (row, type) => {
  switch (type) {
    case 'edit' : {
      //alert('我接收到子组件传送的编辑信息')
      router.push({path: '/main/purchaseOrder/CreatePurchaseOrder', query: {id: row.id}})
      break
    }
    case 'delete': {
      alert('我接收到子组件传送的删除信息'+row.id)
      break
    }
  }
}
const xGrid = ref()
const gridEvents = {
  toolbarButtonClick({code}) {
    const $grid = xGrid.value
    if ($grid) {
      switch (code) {
        case 'ProductStockList': {//新增
          router.push({path: '/main/productStock/ProductStockList'})
          break
        }
        case 'StorageRecord': {//入库
          if ($grid.getCheckboxRecords().length === 0) {
            openAlert({type: 'alert', content: '您点击了查看入库记录', status: 'success'})
            //VXETable.modal.message( '请选择一条数据!')
            return
          } else {
            const type = VXETable.modal.confirm('您选择了' + $grid.getCheckboxRecords().length + '条数据!,是否确认入库?');
            //openAlert({type:'alert', content: '成功入库'+$grid.getCheckboxRecords().length+'条数据!', status: 'success' })
            //VXETable.modal.message( '请选择一条数据!')
            return
          }
          break
        }
        case 'Return': {//退库
          if ($grid.getCheckboxRecords().length === 0) {
            openAlert({type: 'message', content: '请选择至少一条数据', status: 'warning'})
            //VXETable.modal.message( '请选择一条数据!')
            return
          } else {
            /*            async ()=>{
              const type = await.VXETable.modal.confirm('您选择了'+$grid.getCheckboxRecords().length+'条数据!,是否确认退库?');
            }*/
            const type = VXETable.modal.confirm('您选择了' + $grid.getCheckboxRecords().length + '条数据!,是否确认退库?');
            /* if(VXETable.modal.confirm('您选择了'+$grid.getCheckboxRecords().length+'条数据!,是否确认退库?' )){
              //openAlert({type:'message', content: '成功退库'+$grid.getCheckboxRecords().length+'条数据!', status: 'success',lockView: false, mask: false })
            }*/
            /* if(type==='confirm'){
              openAlert({type:'message', content: '成功退库'+$grid.getCheckboxRecords().length+'条数据!', status: 'success' })
            }
*/
            //openAlert({type:'alert', content: '成功退库'+$grid.getCheckboxRecords().length+'条数据!', status: 'success' })
            //VXETable.modal.message( '请选择一条数据!')
            return
          }
          break
        }
      }
    }
  },
  toolbarToolClick({code}) {
    const $grid = xGrid.value
    if ($grid) {
      switch (code) {
        case 'myPrint': {
          $grid.print()
          break
        }
      }
    }
  },
}
const openAlert = (options) => {
  if(options.type==='message'){
    VXETable.modal.message(options)
  }else{
    VXETable.modal.alert(options)
  }
}
</script>
<template>
  <basic-table
      :childrenData="childrenData"/>
</template>
<style scoped>
.el-row {
  margin-bottom: 20px;
}
.el-row:last-child {
  margin-bottom: 0;
}
.el-col {
  border-radius: 4px;
}
.m-header {
  height: 64px;
}
</style>