chenlu
2024-03-29 6c17e1f3da486ffd16b7237d9bc35a9bcbef5348
north-glass-erp/northglass-erp/src/views/mm/mainIngredientStock/ReturnToStorage.vue
@@ -5,25 +5,173 @@
import {reactive, ref} from "vue";
import {useRouter} from  'vue-router'
let router=useRouter()
import request from "@/utils/request";
import deepClone from "@/utils/deepClone";
import useUserInfoStore from "@/stores/userInfo";
import {ElMessage} from "element-plus";
import {Search} from "@element-plus/icons-vue";
import { useI18n } from 'vue-i18n'
import {toolbarButtonClickEvent} from "@/hook/mouseMove";
//语言获取
const { t } = useI18n()
const router = useRouter()
let produceList = ref([])
const getTableRow = (row,type) =>{
  switch (type) {
    case 'edit' :{
      alert('我接收到子组件传送的编辑信息')
      router.push({path: '/main/ingredientsStock/CreateOutbound', query: { id: row.id }})
      router.push({path: '/main/ingredientsStock/ReturnToStorageCreate', query: { returningId: row.returningId }})
      break
    }
    case 'delete':{
      alert('我接收到子组件传送的删除信息')
      break
  }
}
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 pageNum=ref(1)
let total = reactive({
  pageTotal : 0,
  dataTotal : 0,
  pageSize : 4
})
let filterData = ref({
})
let selectDate = ref(["",""])
request.post(`/MaterialInventory/getSelectReturningWarehouseDate/1/${total.pageSize}/${selectDate.value}`,filterData.value).then((res) => {
  if(res.code==200){
    console.log(res.data)
    total.dataTotal = res.data.total.total*1
    total.pageTotal= res.data.total.pageTotal
    pageNum.value=1
    selectDate.value = res.data.selectDate
    produceList = deepClone(res.data.data)
    xGrid.value.loadData(produceList)
    gridOptions.loading=false
  }else{
    ElMessage.warning(res.msg)
    router.push("/login")
  }
})
/*使用筛选,后端获取数据*/
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(`/MaterialInventory/getSelectReturningWarehouseDate/1/${total.pageSize}/${selectDate.value}`,filterData.value).then((res) => {
    if(res.code==200){
      total.dataTotal = res.data.total.total*1
      total.pageTotal= res.data.total.pageTotal
      selectDate.value = res.data.selectDate
      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(`/MaterialInventory/getSelectReturningWarehouseDate/${pageNum.value}/${total.pageSize}/${selectDate.value}`,filterData.value).then((res) => {
    if(res.code==200){
      selectDate.value = res.data.selectDate
      if (res.data.total!=null){
        total.dataTotal = res.data.total.total*1
        total.pageTotal= res.data.total.pageTotal
      }
      produceList = deepClone(res.data.data)
      xGrid.value.loadData(produceList)
      gridOptions.loading=false
    }else{
      ElMessage.warning(res.msg)
      router.push("/login")
    }
  })
}
const changeDate =  ()=>{
  selectOrderList()
}
//页脚跳转
const handlePageChange = ({ currentPage, pageSize }) => {
  total.pageTotal = pageSize
  pageNum.value=currentPage
  selectOrderList()
}
const gridEvents = {
  async toolbarButtonClick({code}) {
    const $grid = xGrid.value
    if ($grid) {
      switch (code) {
        case 'add': {
          router.push({path: '/main/ingredientsStock/ReturnToStorageCreate'})
          break
        }
      }
    }
  }
}
//子组件接收参数
const  xGrid = ref();
const gridOptions = reactive({
  border:  "full",//表格加边框
  keepSource: true,//保持源数据
@@ -53,105 +201,32 @@
    showStatus: true
  },//表头参数
  columns:[
    {type:'expand',fixed:"left",slots: { content:'content' },width: '50'},
    {type:'expand',fixed:"left",slots: { content:'content' },width: '60'},
    {title: '操作', width: '110', slots: { default: 'button_slot' },fixed:"left"},
    // { type: 'checkbox',fixed:"left", title: '选择', width: '80' },
    { type: 'seq',fixed:"left", title: '自序', width: '80' },
    {title: '审核', width: 50, slots: { default: 'state' },},
    {field: 'ReturnNum', width:'150', title: '返库编号', sortable: true,editRender: { name: 'input', attrs: { placeholder: '' } } },
    {field: 'SalesNum', width: '150',title: '销售单号', sortable: true,showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'ReturnType', width: '120',title: '返库类型', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'DocumentType',width: '100', title: '单据类型', sortable: true},
    {field: 'ProjectName', width:'150', title: '项目名称', sortable: true,editRender: { name: 'input', attrs: { placeholder: '' } } },
    {field: 'MaterialCode', width: '100',title: '物料编码', sortable: true},
    {field: 'MaterialName',width: '100', title: '物料名称', sortable: true,showOverflow:"ellipsis"},
    {field: 'Width', width: '80',title: '宽度', sortable: true},
    {field: 'Height',width: '100', title: '高度', sortable: true},
    {field: 'Thickness', width: '100',title: '厚度', sortable: true},
    {field: 'OriginPlace',width: '100', title: '产地', sortable: true},
    {field: 'SaveQuantity', width: '100',title: '节约数量', sortable: true},
    {field: 'Type', width: '100',title: '类型', sortable: true},
    {field: 'Supplier',width: '140', title: '领料员/供应商', sortable: true},
    {field: 'ClassGroup',width: '100', title: '班组/供应商', sortable: true},
    {field: 'WarehouseKeeper',width: '100', title: '仓管员', sortable: true},
    {field: 'Remark',width: '100', title: '备注', sortable: true},
    {field: 'MakingData',width: '100', title: '制单日期', sortable: true},
    {field: 'reviewedState',title: '审核', width: 50, slots: { default: 'state' },},
    {field: 'returningId', width:'150', title: '返库单号', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'materialRequisitionPersonnel', width: '150',title: '领料员/供应商', sortable: true,showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'materialRequisitionTeam', width: '120',title: '领料班组/供应商', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'orderId', width:'150', title: '销售单号', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'project', width:'150', title: '项目名称', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'batch', width:'150', title: '批次', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'returningType', width: '100',title: '返库类型', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'warehouseManager',width: '100', title: '仓管员', sortable: true,showOverflow:"ellipsis",filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'reviewed',width: '100', title: '审核员', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'reviewedTime', width: '100',title: '审核时间', sortable: true},
    {field: 'createTime',width: '100', title: '制单日期', sortable: true},
  ],//表头按钮
  toolbarConfig: {
    buttons: [{
      code:'add','name': '返库新增',status:'primary'
    }],
    import: false,
    buttons: [
      {'code': 'add', 'name': '返库新增',status: 'primary'},
    ],
    /*import: false,
    export: true,
    print: true,
    print: true,*/
    zoom: true,
    custom: true
  },
  data:  [
    {
      "ReturnNum": "FK24010811",
      "SalesNum": "运输材料破损",
      "ReturnType": "采购破损",
      "DocumentType": "审核",
      "ProjectName": "",
      "MaterialCode": "80010128003308035401530000",
      "MaterialName": "白玻-3厘-制镜-优质加工级",
      "Width": '3540.00',
      "Height": "1530.00",
      "Thickness": "3.00",
      "OriginPlace": "广西南宁",
      "SaveQuantity": "1.000",
      "Type": "直接返库",
      "Supplier": "广西南宁伏法",
      "ClassGroup": "曲惠霞",
      "WarehouseKeeper": "曲惠霞",
      "Remark": "2401060345",
      "MakingData": "2024-01-08 08:41:09",
    },
    {
      "ReturnNum": "FK24010811",
      "SalesNum": "运输材料破损",
      "ReturnType": "采购破损",
      "DocumentType": "审核",
      "ProjectName": "",
      "MaterialCode": "80010128003308035401530000",
      "MaterialName": "白玻-3厘-制镜-优质加工级",
      "Width": '3540.00',
      "Height": "1530.00",
      "Thickness": "3.00",
      "OriginPlace": "广西南宁",
      "SaveQuantity": "1.000",
      "Type": "直接返库",
      "Supplier": "广西南宁伏法",
      "ClassGroup": "曲惠霞",
      "WarehouseKeeper": "曲惠霞",
      "Remark": "2401060345",
      "MakingData": "2024-01-08 08:41:09",
    },
    {
      "ReturnNum": "FK24010811",
      "SalesNum": "运输材料破损",
      "ReturnType": "采购破损",
      "DocumentType": "审核",
      "ProjectName": "",
      "MaterialCode": "80010128003308035401530000",
      "MaterialName": "白玻-3厘-制镜-优质加工级",
      "Width": '3540.00',
      "Height": "1530.00",
      "Thickness": "3.00",
      "OriginPlace": "广西南宁",
      "SaveQuantity": "1.000",
      "Type": "直接返库",
      "Supplier": "广西南宁伏法",
      "ClassGroup": "曲惠霞",
      "WarehouseKeeper": "曲惠霞",
      "Remark": "2401060345",
      "MakingData": "2024-01-08 08:41:09",
    },
  ],//table body实际数据
  footerMethod ({ columns, data }) {//页脚函数
    return[
      columns.map((column, columnIndex) => {
@@ -168,44 +243,23 @@
})
const  xGrid = ref();
const gridEvents = {
  toolbarButtonClick({ code }) {
    const $grid = xGrid.value
    if($grid){
      switch (code){
        case 'add':{
          /*VXETable.modal.confirm('点击了库存调拨');*/
          router.push({path: '/main/ingredientsStock/ReturnToStorageCreate'});
          return;
          break
        }
      }
    }
  }
}
</script>
<template>
  <div class="main-div-customer">
    <el-row gutter="10" >
      <el-col :span="2.5">
        <div class="label-text">优化日期</div>
      </el-col>
      <el-col :span="4">
        <el-date-picker
            type="daterange"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            style="width: 200px;"
        />
      </el-col>
      <el-col span="4">
        <el-button id="searchButton" type="primary" :icon="Search">查询</el-button>
      </el-col>
    </el-row>
    <el-date-picker
        v-model="selectDate"
        type="daterange"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        format="YYYY-MM-DD"
        value-format="YYYY-MM-DD"
    />
    <el-button @click="changeDate" style="margin-top: -5px"  id="searchButton" type="primary" :icon="Search">查询</el-button>
    <vxe-grid
        max-height="100%"
        @filter-change="filterChanged"
@@ -239,8 +293,22 @@
        </div>
      </template>
      <template #state="{ row}">
        <el-checkbox checked/>
      <template #state="{ row,column}">
        <el-checkbox @click.native.prevent :checked="row[column.field]===1"/>
      </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>