廖井涛
2024-10-14 6ac9391135ded7e668d2d42f408f4a6c59b27d23
north-glass-erp/northglass-erp/src/views/pp/report/WorkInProgress.vue
@@ -6,7 +6,8 @@
import deepClone from "@/utils/deepClone";
import {ElDatePicker, ElMessage} from "element-plus";
import {useI18n} from 'vue-i18n'
import {changeFilterEvent, filterChanged} from "@/hook"
//import {changeFilterEvent, filterChanged} from "@/hook"
import footSum from "@/hook/footSum"
//语言获取
const {t} = useI18n()
let router = useRouter()
@@ -19,7 +20,28 @@
})
//工序
const value = ref('磨边')
const value = ref(t('machine.edgeGrinding'))
//根据以下字段汇总查询
const stateValue = ref('')
const stateOptions = [
  {
    value: 1,
    label: t('order.orderId'),
  },
  {
    value: 2,
    label: t('processCard.processId'),
  },
  // {
  //   value: 3,
  //   label: t('order.project'),
  // },
  {
    value: 4,
    label: t('processCard.technologyNumber'),
  },
]
//表尾求和
const sumNum = (list, field) => {
@@ -50,24 +72,9 @@
let pageNum = ref(1)
let pageState = null
//获取七天前到当前时间
function getNowTime() {
  const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3)
      .toISOString()
      .replace('T', ' ')
      .slice(0, 10) //默认开始时间7天前
  const end = new Date(new Date().getTime() + 3600 * 1000 * 24)
      .toISOString()
      .replace('T', ' ')
      .slice(0, 10)//默认结束时间当前时间
  return [start, end]
}
//第一次加载获取近七天时间和默认状态
form.date1 = getNowTime()
let startTime = form.date1[0]
let endTime = form.date1[1]
//第一次加载
let selectProcesses = value.value
let inputVal = form.orderId
if (inputVal == '') {
@@ -86,15 +93,20 @@
const titleSelectJson = ref({
  processType: [],
})
let optionVal=stateValue.value
if (optionVal == '') {
  optionVal = null
}
//第一次加载数据
request.post(`/report/workInProgress/${startTime}/${endTime}/${inputVal}/${inputProject}/${selectProcesses}`, filterData.value).then((res) => {
request.post(`/report/workInProgress/1/${total.pageSize}/${inputVal}/${inputProject}/${selectProcesses}/${optionVal}`, filterData.value).then((res) => {
  if (res.code == 200) {
    // total.dataTotal = res.data.total.total*1
    // total.pageTotal= res.data.total.pageTotal
    // pageTotal.value = res.data.total
    total.dataTotal = res.data.total.total*1
    total.pageTotal= res.data.total.pageTotal
    pageTotal.value = res.data.total
    produceList = produceList.value.concat(deepClone(res.data.data))
    titleSelectJson.value.processType = res.data.process
    titleSelectJson.value.processType.splice(0,1)
    xGrid.value.reloadData(produceList)
    gridOptions.loading = false
  } else {
@@ -104,17 +116,17 @@
//页脚翻页查询
const selectPageList = () => {
  let startTime = form.date1[0]
  let endTime = form.date1[1]
  let inputVal = form.orderId
  if (inputVal == '') {
    inputVal = null
  }
  let optionVal=stateValue.value
  if (optionVal == '') {
    optionVal = null
  }
  request.post(`/report/workInProgress/${pageNum.value}/${total.pageSize}/${inputVal}/${inputProject}/${selectProcesses}/${optionVal}`, filterData.value).then((res) => {
  request.post(`/report/selectReportingWork/${pageNum.value}/${total.pageSize}/${startTime}/${endTime}/${inputVal}`, filterData.value).then((res) => {
    if (res.code == 200) {
      produceList = deepClone(res.data.data)
      xGrid.value.reloadData(produceList)
    } else {
@@ -126,8 +138,6 @@
//点击查询
const getWorkOrder = () => {
  let startTime = form.date1[0]
  let endTime = form.date1[1]
  let selectProcesses = value.value
  let inputVal = form.orderId
  if (inputVal == '') {
@@ -137,17 +147,22 @@
  if (inputProject == '') {
    inputProject = null
  }
  request.post(`/report/workInProgress/${startTime}/${endTime}/${inputVal}/${inputProject}/${selectProcesses}`, filterData.value).then((res) => {
  let optionVal=stateValue.value
  if (optionVal == '') {
    optionVal = null
  }
  request.post(`/report/workInProgress/${pageNum.value}/${total.pageSize}/${inputVal}/${inputProject}/${selectProcesses}/${optionVal}`, filterData.value).then((res) => {
    if (res.code == 200) {
      // total.dataTotal = res.data.total.total*1
      // total.pageTotal= res.data.total.pageTotal
      // pageTotal.value = res.data.total
      produceList = deepClone(res.data.data)
      xGrid.value.reloadData(produceList)
      total.dataTotal = res.data.total.total * 1
      total.pageTotal = res.data.total.pageTotal
      pageTotal.value = res.data.total
      xGrid.value.loadData(res.data.data)
      gridOptions.loading = false
    } else {
      ElMessage.warning(res.msg)
    }
    //handleUpdateData(produceList)
  })
}
@@ -160,29 +175,49 @@
/*使用筛选,后端获取数据*/
// const changeFilterEvent = (event, option, $panel,) => {
//   // 手动触发筛选
//   $panel.changeOption(event, !!option.data, option)
// }
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
//   }
//
//   gridOptions.loading = true
//
// }
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
  }
  gridOptions.loading = true
  let startTime = form.date1[0]
  let endTime = form.date1[1]
  let optionVal=stateValue.value
  if (optionVal == '') {
    optionVal = null
  }
  request.post(`/report/workInProgress/1/${total.pageSize}/${inputVal}/${inputProject}/${selectProcesses}/${optionVal}`, filterData.value).then((res) => {
    if (res.code == 200) {
      total.dataTotal = res.data.total.total*1
      total.pageTotal=parseInt(res.data.total)
      pageNum.value=1
      produceList = deepClone(res.data.data)
      xGrid.value.reloadData(produceList)
      gridOptions.loading=false
    } else {
      ElMessage.warning(res.msg)
    }
    //handleUpdateData(produceList)
  })
}
/*后端返回结果多层嵌套展示*/
const hasDecimal = (value) => {
@@ -197,8 +232,8 @@
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe: true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true, height: 50},//鼠标移动或选择高亮
  id: 'CustomerList',
  rowConfig: {isCurrent: true, isHover: true, height: 30},//鼠标移动或选择高亮
  id: 'WorkInProgress',
  showFooter: true,//显示脚
  printConfig: {},
  importConfig: {},
@@ -222,47 +257,58 @@
  },//表头参数
  columns: [
    {type: 'expand', fixed: "left", slots: {content: 'content'}, width: 50},
    {type: 'seq', fixed: "left", title: '自序', width: 50},
    {type: 'seq', fixed: "left", title: t('basicData.Number'), width: 50},
    {
      field: 'thisProcess', width: 120, title: '工序', filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
      field: 'thisProcess', width: 120, title: t('report.workingProcedure'),
      visible: true
    },
    {
      field: 'process_id',
      field: 'orderId',
      width: 120,
      title: '流程卡号',
      title: t('order.orderId'),
      showOverflow: "ellipsis",
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
      visible: true
    },
    {
      field: 'customer_name', width: 130, title: '客户名称', filters: [{data: ''}],
      field: 'processId',
      width: 140,
      title: t('processCard.processId'),
      showOverflow: "ellipsis",
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
      visible: true
    },
    {
      field: 'project', width: 120, title: '项目名称', filters: [{data: ''}],
      field: 'customerName', width: 130, title: t('customer.customerName'), filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
      visible: true
    },
    {
      field: 'batch', width: 100, title: '批次', filters: [{data: ''}],
      field: 'project', width: 120, title: t('order.project'), filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
      visible: true
    },
    {field: 'order_number', width: 100, title: '序号'},
    {field: 'technology_number', width: 120, title: '小片顺序', showOverflow: "ellipsis"},
    {field: 'shape', width: 100, title: '形状'},
    {field: 'process', width: 120, title: '工艺流程'},
    {field: 'quantity', width: 120, title: '订单数'},
    {field: 'child_width', width: 120, title: '宽'},
    {field: 'child_height', width: 120, title: '高'},
    {field: 'stockNum', width: 120, title: '库存数'},
    {field: 'stockArea', width: 120, title: '库存面积'},
    {field: 'product_name', width: 120, title: '成品名称'},
    {field: 'bend_radius', width: 120, title: '弯钢半径'},
    {
      field: 'batch', width: 100, title: t('order.batch'), filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      visible: true
    },
    {field: 'glassNumber', width: 110,title: t('reportingWorks.glassNumber'),showOverflow:"ellipsis",filters: [{data: ''}],
      slots: {filter: 'num1_filter'}},
    {field: 'orderNumber', width: 100, title: t('order.OrderNum'),visible: true},
    {field: 'technologyNumber', width: 120, title: t('processCard.technologyNumber'),filters: [{data: ''}],
      slots: {filter: 'num1_filter'}, showOverflow: "ellipsis",visible: true},
    {field: 'shape', width: 100, title: t('order.shape'),visible: true},
    {field: 'process', width: 120, title: t('craft.process'),visible: true},
    {field: 'quantity', width: 120, title: t('order.quantity'),visible: true},
    {field: 'childWidth', width: 120, title: t('order.width'),visible: true},
    {field: 'childHeight', width: 120, title: t('order.height'),visible: true},
    {field: 'stockNum', width: 120, title: t('productStock.inventoryQuantity'),visible: true},
    {field: 'stockArea', width: 120, title: t('report.inventoryArea'),visible: true},
    {field: 'productName', width: 120, title:  t('order.product'),visible: true},
    {field: 'bendRadius', width: 120, title: t('order.bendRadius'),visible: true},
  ],//表头按钮
  toolbarConfig: {
@@ -280,20 +326,20 @@
  },
  data: [],//table body实际数据
  //脚部求和
  footerMethod({columns, data}) {//页脚函数
    let footList = ['']
    return [
  footerMethod ({ columns, data }) {//页脚函数
    return[
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return '合计:'
          return t('basicData.total')
        }
        if (footList.includes(column.field)) {
          return sumNum(data, column.field)
        const List = ["quantity",'stockNum','stockArea',]
        if (List.includes(column.field)) {
          return footSum(data, column.field)
        }
        return ''
      })
    ]
  }
  },
})
@@ -308,12 +354,12 @@
    inputProject = null
  }
  if(date===null){
    ElMessage.warning("请先选择日期")
    ElMessage.warning(t('report.pleaseSelectADateFirst'))
    return
  }
  if(processes===null){
    ElMessage.warning("请先选择工序")
    ElMessage.warning(t('report.pleaseSelectAProcessFirst'))
    return
  }
@@ -322,7 +368,7 @@
  const timeDiff = Math.abs(date2.getTime() - date1.getTime());
  const daysDiff = timeDiff / (1000 * 3600 * 24);
  if(Math.floor(daysDiff)>180){
    ElMessage.warning("导出的筛选时间不能超过180天")
    ElMessage.warning(t('report.theFilteringTimeForExportCannotExceed180Days'))
    return
  }
  let dataMp = ref({
@@ -348,28 +394,47 @@
  })
}
const handleUpdateData = (data) =>{
  // const usedColumns = new Set();
  // data.forEach(row => {
  //   Object.keys(row).forEach(key => {
  //     usedColumns.add(key);
  //   });
  // });
  // // 更新 columns 数组的 visible 属性来控制列的显示
  // gridOptions.columns.forEach(column => {
  //
  //   column.visible = usedColumns.has(column.field);
  // });
  //const columns = gridOptions.columns;
  // const ageColumn = columns.find(col => col.property === 'age');
  // if (ageColumn) {
  //   ageColumn.visible = !ageColumn.visible;
  //   VXETable.updateColumns(tableRef.value, columns);
  // }
}
</script>
<template>
  <div class="main-div-customer">
    <div id="selectForm">
      <el-row :gutter="0">
        <!--        <el-input placeholder="销售单号" v-model="form.name" style="width: 150px"/>-->
        <!--        <el-input placeholder="项目名称" v-model="form.name" style="width: 150px"/>-->
        <el-date-picker
            v-model="form.date1"
            end-placeholder="结束时间"
            format="YYYY/MM/DD"
            start-placeholder="开始时间"
            style="width: 100px"
            type="daterange"
            value-format="YYYY-MM-DD"
        />
        &nbsp;&nbsp;
        <el-input v-model="form.orderId" :placeholder="$t('order.orderId')" clearable style="width: 130px"></el-input>
        &nbsp;&nbsp;
        <el-input v-model="form.project" clearable placeholder="项目名称" style="width: 130px"></el-input>
        <el-input v-model="form.project" clearable :placeholder="$t('order.project')" style="width: 130px"></el-input>
        &nbsp;
        <el-select v-model="stateValue" class="m-2" :placeholder="$t('processCard.pleaseSelect')" clearable allow-create filterable style="width: 140px">
          <el-option
              v-for="item in stateOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
          />
        </el-select>
        &nbsp;
        <el-select v-model="value" clearable default-value="default_city" style="width: 120px">
          <el-option
@@ -379,58 +444,77 @@
              :value="item.basic_name"
          />
        </el-select>
        <el-button type="primary" @click="getWorkOrder">查询</el-button>
        <el-button type="primary" @click="getWorkOrder">{{$t('basicData.search')}}</el-button>
      </el-row>
    </div>
    <vxe-grid
        ref="xGrid"
        class="mytable-scrollbar"
        max-height="100%"
        v-bind="gridOptions"
    <div style="height: 100%">
      <vxe-grid
          ref="xGrid"
          class="mytable-scrollbar"
          height="100%"
          v-bind="gridOptions"
          :optimize="true"
          @filter-change="filterChanged"
    >
      <!--      @toolbar-button-click="toolbarButtonClickEvent"-->
      <!--      下拉显示所有信息插槽-->
      <template #content="{ row }">
        <ul class="expand-wrapper">
          <li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined ">
            <span style="font-weight: bold">{{ item.title + ':  ' }}</span>
            <span>{{ row[item.field] }}</span>
          </li>
        </ul>
      </template>
      >
        <!--      @toolbar-button-click="toolbarButtonClickEvent"-->
        <!--      下拉显示所有信息插槽-->
        <template #content="{ row }">
          <ul class="expand-wrapper">
            <li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined ">
              <span style="font-weight: bold">{{ item.title + ':  ' }}</span>
              <span>{{ row[item.field] }}</span>
            </li>
          </ul>
        </template>
      <!--左边固定显示的插槽-->
      <template #button_slot="{ row }">
        <el-button link size="small" type="primary" @click="getTableRow(row,'edit')">编辑</el-button>
        <el-button link size="small" type="primary" @click="getTableRow(row,'setType')">反审</el-button>
        <el-button link size="small" type="primary" @click="getTableRow(row,'delete')">删除</el-button>
      </template>
        <!--左边固定显示的插槽-->
        <template #button_slot="{ row }">
          <el-button link size="small" type="primary" @click="getTableRow(row,'edit')">{{$t('basicData.edit')}}</el-button>
          <el-button link size="small" type="primary" @click="getTableRow(row,'setType')">{{$t('basicData.cancelReview')}}</el-button>
          <el-button link size="small" type="primary" @click="getTableRow(row,'delete')">{{$t('basicData.delete')}}</el-button>
        </template>
      <template #num1_filter="{ column, $panel }">
        <div>
          <div v-for="(option, index) in column.filters" :key="index">
            <input v-model="option.data" type="text" @input="changeFilterEvent($event, option, $panel)"/>
        <template #num1_filter="{ column, $panel }">
          <div>
            <div v-for="(option, index) in column.filters" :key="index">
              <input v-model="option.data" type="text"
                     @keyup.enter.native="$panel.confirmFilter()"
                     @input="changeFilterEvent($event, option, $panel)"/>
            </div>
          </div>
        </div>
      </template>
      <template #toolbar_buttons>
        <vxe-button style="margin-right: 0.5rem"
                    @click="exportExcel('/report/exportWorkInProgress',
                                          '在制品报表',
        </template>
        <template #pager>
          <!--使用 pager 插槽-->
          <!--        'PrevJump','NextJump', -->
          <vxe-pager
              v-model:current-page="pageNum"
              v-model:page-size="total.pageSize"
              v-model:pager-count="total.pageTotal"
              :layouts="[  'PrevPage', 'Jump','PageCount', 'NextPage',  'Total']"
              :total="total.dataTotal"
              @page-change="handlePageChange"
          >
          </vxe-pager>
        </template>
        <template #toolbar_buttons>
          <vxe-button style="margin-right: 0.5rem"
                      @click="exportExcel('/report/exportWorkInProgress',
                                          t('report.workInProgressReport'),
                                          form.date1)">
          导出</vxe-button>
      </template>
            {{t('basicData.export')}}</vxe-button>
        </template>
    </vxe-grid>
      </vxe-grid>
    </div>
  </div>
</template>
<style scoped>
.main-div-customer {
  width: 99%;
  height: 100%;
  height: 90%;
}
#selectForm {