guoyuji
2024-05-07 fcd6de629c4f6b8d9e610da854f15ef40115b058
north-glass-erp/northglass-erp/src/views/mm/mainProductStock/CreateProductStock.vue
@@ -1,156 +1,372 @@
<!--产品入库-->
<script setup>
import {reactive, ref} from "vue";
import {useRouter} from  'vue-router'
import request from "@/utils/request"
import deepClone from "@/utils/deepClone"
import VXETable from "vxe-table";
import useUserInfoStore from "@/stores/userInfo";
import {ElMessage} from "element-plus";
import { useI18n } from 'vue-i18n'
//语言获取
const { t } = useI18n()
const userStore = useUserInfoStore()
const username = userStore.user.userName
const userid = userStore.user.userId
let router=useRouter()
let produceList = ref([])
let tableRef = ref([])
const getTableRow = (row,type) =>{
  switch (type) {
    case 'edit' :{
      //alert('我接收到子组件传送的编辑信息')
      router.push({path: '/main/productStock/OrderAllocation', query: { id: row.id }})
      break
    }
    case 'back':{
      router.push({path: '/main/productStock/FinishedProductRework', query: { id: row.id }})
      break
    }
    case 'out' :{
      //alert('我接收到子组件传送的编辑信息')
      router.push({path: '/main/productStock/FinishedGoodsIssue', query: { id: row.id }})
      break
    }
  }
}
<script lang="ts" setup>
import {ref} from "vue";
let tableData = ref([
  {
    "销售单号":'NG23072003',
    "楼层编号":'10059419',
    "成品编号":'0604000027',
    "成品名称":'NG23072003A01',
    "产品名称":'',
    "长":'1075.00',
    "宽":'440.00',
    "业务员":'陈宗凯',
    "客户名称":'71',
    "项目名称":'钢化玻璃',
    "订序":'1',
    "订单总数":'3800',
    "数量":'1140',
    "完工":'1140',
    "面积":'505.270000',
    "流程卡号":'NG23112311A01',
    "已入数量":'0',
    "下工序":'成品',
    "批次":'',
  },{
    "销售单号":'NG23072003',
    "楼层编号":'10059419',
    "成品编号":'0604000027',
    "成品名称":'NG23072003A01',
    "产品名称":'',
    "长":'1075.00',
    "宽":'440.00',
    "业务员":'陈宗凯',
    "客户名称":'71',
    "项目名称":'钢化玻璃',
    "订序":'1',
    "订单总数":'3800',
    "数量":'1140',
    "完工":'1140',
    "面积":'505.270000',
    "流程卡号":'NG23112311A01',
    "已入数量":'0',
    "下工序":'成品',
    "批次":'',
  },{
    "销售单号":'NG23072003',
    "楼层编号":'10059419',
    "成品编号":'0604000027',
    "成品名称":'NG23072003A01',
    "产品名称":'',
    "长":'1075.00',
    "宽":'440.00',
    "业务员":'陈宗凯',
    "客户名称":'71',
    "项目名称":'钢化玻璃',
    "订序":'1',
    "订单总数":'3800',
    "数量":'1140',
    "完工":'1140',
    "面积":'505.270000',
    "流程卡号":'NG23112311A01',
    "已入数量":'0',
    "下工序":'成品',
    "批次":'',
  },{
    "销售单号":'NG23072003',
    "楼层编号":'10059419',
    "成品编号":'0604000027',
    "成品名称":'NG23072003A01',
    "产品名称":'',
    "长":'1075.00',
    "宽":'440.00',
    "业务员":'陈宗凯',
    "客户名称":'71',
    "项目名称":'钢化玻璃',
    "订序":'1',
    "订单总数":'3800',
    "数量":'1140',
    "完工":'1140',
    "面积":'505.270000',
    "流程卡号":'NG23112311A01',
    "已入数量":'0',
    "下工序":'成品',
    "批次":'',
const hasDecimal=(value)=>{
  const regex=/\./ // 定义正则表达式,查找小数点
  return regex.test(value) //返回true/false
}
const hasDecimalhtml=(item,row)=>{
  let aa=item.split('.').length
  if (aa===2){
    return row[item.split('.')[0]][item.split('.')[1]]
  }else if(aa===3){
    return row[item.split('.')[0]][item.split('.')[1]][item.split('.')[2]]
  }
}
//筛选条件,有外键需要先定义明细里面的数据
let filterData = ref({
  orderDetail:{
    orderNumber:'',
    productName:'',
    productId:'',
    width:'',
    height:'',
    quantity:''
  },
])
const checked1 = ref(true)
  order:{
    orderId:'',
    creater:'',
    project:'',
    area:'',
    batch:''
  }
})
let pageNum=ref(1)
let total = reactive({
  pageTotal : 0,
  dataTotal : 0,
  pageSize : 100
})
//第一次调用
request.post(`/FinishedGoodsInventory/getSelectWarehousing/1/${total.pageSize}`,filterData.value).then((res) => {
  if(res.code==200){
    total.dataTotal = res.data.total.total*1
    total.pageTotal= res.data.total.pageTotal
    pageNum.value=1
    produceList = deepClone(res.data.data)
    xGrid.value.loadData(produceList)
    gridOptions.loading=false
  }else{
    ElMessage.warning(res.msg)
    router.push("/login")
  }
})
let pageState = null
/*使用筛选,后端获取数据*/
const changeFilterEvent = (event, option, $panel,) => {
  // 手动触发筛选
  $panel.changeOption(event, !!option.data, option)
}
function filterChanged(column){
  gridOptions.loading=true
  //筛选条件发生变化条件发生变化
  let value = column.datas[0]!=undefined?column.datas[0]:''
  value = value.trim()
  //判断是否存在外键
  if (column.property.indexOf('.')>-1){
    const  columnArr = column.property.split('.')
    filterData.value[columnArr[0]] = {
      [columnArr[1]]:value
    }
  }else{
    filterData.value[column.property] = value
  }
  request.post(`/FinishedGoodsInventory/getSelectWarehousing/1/${total.pageSize}`,filterData.value).then((res) => {
    if(res.code==200){
      total.dataTotal = res.data.total.total*1
      total.pageTotal= res.data.total.pageTotal
      pageNum.value=1
      produceList = deepClone(res.data.data)
      xGrid.value.loadData(produceList)
      gridOptions.loading=false
    }else{
      ElMessage.warning(res.msg)
      router.push("/login")
    }
  })
}
const selectOrderList = ()=>{
  request.post(`/FinishedGoodsInventory/getSelectWarehousing/${pageNum.value}/${total.pageSize}`,filterData.value).then((res) => {
    if(res.code==200){
      produceList = deepClone(res.data.data)
      xGrid.value.loadData(produceList)
      gridOptions.loading=false
    }else{
      ElMessage.warning(res.msg)
      router.push("/login")
    }
  })
}
//页脚跳转
const handlePageChange = ({ currentPage, pageSize }) => {
  total.pageTotal = pageSize
  pageNum.value=currentPage
  selectOrderList()
}
//子组件接收参数
const gridOptions = reactive({
  border:  "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe:true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮
  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:[
    {type:'expand',fixed:"left",slots: { content:'content' },width: '60'},
    { type: 'checkbox',fixed:"left", title: t('basicData.check'), width: '80' },
    { type: 'seq',fixed:"left", title: t('basicData.Number'), width: '80' },
    {field: 'order.orderId', width: '150',title: t('order.orderId'), showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    //{field: 'orderDetail.buildingNumber', width: '120',title: '楼号',filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderDetail.productId',width: '100', title: t('order.productId'), filters:[{ data: '' }],showOverflow:"ellipsis",slots: { filter: 'num1_filter' }},
    {field: 'orderDetail.productName',width: '100', 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: 'order.creater', width: '100',title: t('order.salesman'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'order.project', width: '100',title: t('order.project'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderNumber',width: '140', title: t('order.OrderNum'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderDetail.quantity',width: '140', title: t('productStock.totalNumberOfOrders'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'inventoryQuantity',width: '100', title: t('productStock.quantityToBeStockedIn'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'order.area',width: '140', title: t('order.area'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'processId',width: '100', title: t('processCard.processId'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'receivedQuantity',width: '100', title: t('productStock.quantityAlreadyInStock'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'order.batch',width: '100', title: t('order.batch'), filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
  ],//表头按钮
  toolbarConfig: {
    buttons: [{
        'name': t('productStock.confirmReceiptOfGoods'),status: 'primary',
        'code':'add'
      },
      {
        'name': t('productStock.warehousingRecords'),status: 'primary',
        'code':'jump'
      }
      ],
    /*import: false,
   export: true,
   print: true,*/
    zoom: true,
    custom: true
  }
  ,//table body实际数据
  footerMethod ({ columns, data }) {//页脚函数
    return[
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return t('basicData.total')
        }
        return ''
      })
    ]
  }
})
const  xGrid = ref();
const storageRegion = ref(null);
const remark = ref(null);
const gridEvents = {
  toolbarButtonClick ({ code }) {
    const $grid = xGrid.value
    if ($grid) {
      switch (code) {
        case 'add': {
          const $table = xGrid.value
          if ($table) {
            const selectRecords = $table.getCheckboxRecords()
            let flowData = ref({
              userId:userid,
              userName:username,
              storageRegion:storageRegion.value,
              remark:remark.value,
              flowcard:selectRecords
            })
              request.post("/FinishedGoodsInventory/addSelectWarehousing",flowData.value).then((res) => {
                if(res.code==200){
                  ElMessage.success(t('productStock.receivedSuccessfully'))
                  router.push({path:'/main/productStock/CreateProductStock',query:{random:Math.random()}})
                }else{
                  ElMessage.warning(res.msg)
                  router.push("/login")
                }
              })
          }
          return;
        }
        case 'jump': {
          router.push({path: '/main/productStock/storageRecord', query: { storageType: '入库' }})
          return;
        }
      }
    }
  },
}
</script>
<template>
<div>
  <div>
    <el-form  size="medium" >
  <div class="main-div-customer">
    <div id="selectForm">
        <el-input style="width: 200px" v-model="storageRegion" class="m-2" :placeholder="$t('productStock.pleaseEnterTheStorageLocation')">
      </el-input>
        <el-input style="width: 200px" v-model="remark" class="m-2" :placeholder="$t('productStock.pleaseEnterANote')">
        </el-input>
<!--      <el-row gutter="7">-->
<!--        <el-col :span="4">-->
<!--          <el-input v-model="name" placeholder="销售单号" style="width: 200px; height: 30px;" />-->
<!--        </el-col>-->
<!--        <el-col :span="4">-->
<!--          <el-input v-model="productName" placeholder="流程卡号" style="width: 200px; height: 30px;" />-->
<!--        </el-col>-->
<!--        <el-col :span="4">-->
<!--          <el-input v-model="salId" placeholder="订序" style="width: 200px; height: 30px;" />-->
<!--        </el-col>-->
<!--        <el-col :span="4">-->
<!--          <el-button id="searchButton" type="primary" :icon="Search" style="width: 100px; height: 25px">查询</el-button>-->
<!--        </el-col>-->
<!--      </el-row>-->
      <el-row gutter="7">
        <el-col :span="4">
          <el-input v-model="name" placeholder="制单员" style="width: 200px; height: 30px;" />
        </el-col>
        <el-col :span="4">
          <el-input v-model="productName" placeholder="工号" style="width: 200px; height: 30px;" />
        </el-col>
        <el-col :span="4">
          <el-input v-model="salId" placeholder="库位" style="width: 200px; height: 30px;" />
        </el-col>
        <el-col :span="4">
          <el-button id="searchButton" type="primary" :icon="Search" style="width: 100px; height: 25px">确定</el-button>
        </el-col>
      </el-row>
    </el-form>
    <div>
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="销售单号" label="销售单号" width="100" />
        <el-table-column prop="楼层编号" label="楼层编号" width="100" />
        <el-table-column prop="成品编号" label="成品编号" width="100"/>
        <el-table-column prop="成品名称" label="成品名称" width="180"/>
        <el-table-column prop="长" label="长" width="80"/>
        <el-table-column prop="宽" label="宽" width="80"/>
        <el-table-column prop="业务员" label="业务员" width="100"/>
        <el-table-column prop="客户名称" label="客户名称" width="100"/>
        <el-table-column prop="项目名称" label="项目名称" width="180"/>
        <el-table-column prop="订序" label="订序" width="80"/>
        <el-table-column prop="订单总数" label="订单总数" width="100"/>
        <el-table-column prop="数量" label="数量" width="80"/>
        <el-table-column prop="完工" label="完工" width="80"/>
        <el-table-column prop="面积" label="面积" width="80"/>
        <el-table-column prop="流程卡号" label="流程卡号" width="100"/>
        <el-table-column prop="已入数量" label="已入数量" width="100"/>
        <el-table-column prop="下工序" label="下工序" width="80"/>
        <el-table-column prop="批次" label="批次" width="80"/>
        <el-table-column prop="选择" label="选择"  type="selection" width="80"/>
      </el-table>
    </div>
  </div>
</div>
</template>
<style>
    <vxe-grid
        max-height="100%"
        @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 gridOptions.columns" v-show="item.field!=undefined ">
            <span style="font-weight: bold">{{item.title+':  '}}</span>
            <span v-if="hasDecimal(item.field)">{{ hasDecimalhtml(item.field,row) }}</span>
            <span v-else>{{ row[item.field] }}</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,'out')" link type="primary" size="small">成品领出</el-button>-->
<!--        <el-button @click="getTableRow(row,'back')" 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>
      <template #pager>
        <!--使用 pager 插槽-->
        <vxe-pager
            @page-change="handlePageChange"
            :layouts="[  'PrevPage', 'Jump','PageCount', 'NextPage',  'Total']"
            v-model:current-page="pageNum"
            v-model:page-size="total.pageSize"
            v-model:pager-count="total.pageTotal"
            :total="total.dataTotal"
        >
        </vxe-pager>
      </template>
    </vxe-grid>
  </div>
</template>
<style scoped>
.main-div-customer{
  width: 99%;
  height: 100%;
}
</style>