chenlu
2024-03-29 6c17e1f3da486ffd16b7237d9bc35a9bcbef5348
north-glass-erp/northglass-erp/src/views/mm/mainIngredientStock/MaterialOutbound.vue
@@ -5,25 +5,166 @@
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/CreateOutbound', query: { materialOutboundId: row.materialOutboundId }})
      break
    }
    case 'delete':{
      alert('我接收到子组件传送的删除信息')
      break
      let flowData = ref({
        materialOutboundId:row.materialOutboundId
      })
      request.post("/MaterialInventory/deleteMaterialOutbound",flowData.value).then((res) => {
        if(res.code==200){
          ElMessage.success(t('searchOrder.msgDeleteSuccess'))
          router.push({path:'/main/ingredientsStock/MaterialOutbound', query:{random:Math.random()}})
        }else{
          ElMessage.warning(res.msg)
          router.push("/login")
        }
      })
      return
    }
  }
}
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 : 10
})
let filterData = ref({
})
let selectDate = ref(["",""])
request.post(`/MaterialInventory/getSelectMaterialOutboundDate/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/getSelectMaterialOutboundDate/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/getSelectMaterialOutboundDate/${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  xGrid = ref();
const gridOptions = reactive({
  border:  "full",//表格加边框
  keepSource: true,//保持源数据
@@ -53,116 +194,29 @@
    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: 'InventoryOrganization', width:'150', title: '库存组织', sortable: true,editRender: { name: 'input', attrs: { placeholder: '' } } },
    {field: 'MaterialCode', width: '150',title: '物料编码', sortable: true,showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'MaterialName', width: '120',title: '物料名称', sortable: true,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
    {field: 'InventoryCount',width: '100', title: '库存数量', sortable: true},
    {field: 'OutNum', width:'150', title: '出库数量', sortable: true,editRender: { name: 'input', attrs: { placeholder: '' } } },
    {field: 'Origin', width: '100',title: '产地', sortable: true},
    {field: 'InventoryNumber',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: 'MainUnit',width: '100', title: '主单位', sortable: true},
    {field: 'SafetyStock', width: '100',title: '安全库存', sortable: true},
    {field: 'AvailableInventory', width: '100',title: '可用库存', sortable: true},
    {field: 'UnclaimedQuantity',width: '140', title: '未领取数量', sortable: true},
    {field: 'TotalArea',width: '100', title: '总面积', sortable: true},
    {field: 'ProductionDate',width: '100', title: '生产日期', sortable: true},
    {field: 'ShelfLife',width: '100', title: '保质期', sortable: true},
    {field: 'LocationNumber',width: '100', title: '库位编号', sortable: true},
    {field: 'StorageArea',width: '100', title: '存储区域', sortable: true},
    {field: 'Location',width: '100', title: '库位', sortable: true},
    {field: 'BacklogInventory',width: '100', title: '积压库存', sortable: true},
    {field: 'remark',width: '80', title: '备注', sortable: true},
    {field: 'reviewedState',title: '审核', width: 50, slots: { default: 'state' },},
    {field: 'materialOutboundId', 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: 'outboundType', 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: 'materialRequisitionDate', width: '80',title: '领料日期', sortable: true},
    {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,
    /*import: false,
    export: true,
    print: true,
    print: true,*/
    zoom: true,
    custom: true
  },
  data:  [
    {
      "InventoryOrganization": "人工库",
      "MaterialCode": "700900000000115",
      "MaterialName": "冬装170",
      "Origin": "China",
      "InventoryNumber": "KC2006891",
      "Width": '',
      "Height": "",
      "Thickness": "",
      "MainUnit": "件",
      "SafetyStock": "5",
      "InventoryCount": "20",
      "AvailableInventory": "9",
      "UnclaimedQuantity": "2",
      "TotalArea": "0",
      "ProductionDate": "2016-10-17",
      "ShelfLife": "0",
      "LocationNumber": "0",
      "StorageArea": "0",
      "Location": "0",
      "BacklogInventory": "40",
      "remark": "测试",
    },
    {
      "InventoryOrganization": "人工库",
      "MaterialCode": "700900000000115",
      "MaterialName": "冬装175",
      "Origin": "China",
      "InventoryNumber": "KC2006891",
      "Width": '',
      "Height": "",
      "Thickness": "",
      "MainUnit": "件",
      "SafetyStock": "5",
      "InventoryCount": "20",
      "AvailableInventory": "9",
      "UnclaimedQuantity": "2",
      "TotalArea": "0",
      "ProductionDate": "2016-10-17",
      "ShelfLife": "0",
      "LocationNumber": "0",
      "StorageArea": "0",
      "Location": "0",
      "BacklogInventory": "40",
      "remark": "测试",
    },{
      "InventoryOrganization": "人工库",
      "MaterialCode": "700900000000115",
      "MaterialName": "冬装180",
      "Origin": "China",
      "InventoryNumber": "KC2006891",
      "Width": '',
      "Height": "",
      "Thickness": "",
      "MainUnit": "件",
      "SafetyStock": "2",
      "InventoryCount": "23",
      "AvailableInventory": "4",
      "UnclaimedQuantity": "3",
      "TotalArea": "0",
      "ProductionDate": "2016-10-17",
      "ShelfLife": "0",
      "LocationNumber": "0",
      "StorageArea": "0",
      "Location": "0",
      "BacklogInventory": "40",
      "remark": "测试",
    },
  ],//table body实际数据
  footerMethod ({ columns, data }) {//页脚函数
    return[
      columns.map((column, columnIndex) => {
@@ -179,28 +233,27 @@
})
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/CreateOutbound'});
          return;
          break
        }
      }
    }
  }
}
</script>
<template>
  <div class="main-div-customer">
    <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"
@@ -223,7 +276,7 @@
      <!--左边固定显示的插槽-->
      <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="getTableRow(row,'delete')" link type="primary" size="small">删除</el-button>-->
      </template>
      <template #num1_filter="{ column, $panel }">
@@ -234,10 +287,24 @@
        </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>
  </div>
</template>