廖井涛
96 分钟以前 f7a2fcdda7f1120498c5c5f75c5a99955fc54b43
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/ComputeCard.vue
@@ -1,6 +1,10 @@
<script setup>
import {nextTick, onMounted, reactive, ref, watch} from "vue";
import request from "@/utils/request";
import {useI18n} from "vue-i18n";
import {ElMessage} from "element-plus";
import deepClone from "@/utils/deepClone";
import {addListener, toolbarButtonClickEvent} from "@/hook/mouseMove";
const { t } = useI18n()
const xGrid = ref()
@@ -28,6 +32,16 @@
  scrollX:{enabled: true},
  scrollY:{ enabled: true ,gt:0},//开启虚拟滚动
  showOverflow:true,
  menuConfig: {
    body: {
      options: [
        [
          { code: 'copyChecked', name: t('basicData.selectSame'), prefixIcon: 'vxe-icon-copy', visible: true, disabled: false },
          { code: 'copyAll', name: t('basicData.sameAfterwards'), prefixIcon: 'vxe-icon-feedback', visible: true, disabled: false },
        ]
      ]
    }
  },
  columnConfig: {
    resizable: true,
    useKey: true
@@ -45,16 +59,19 @@
  },
  columns:[
    {type:'seq',fixed:"left",slots: { content:'content' },width: 50},
    {field: 'check', title: '选择', width: 250, cellRender: checkboxCellRender },
    {field: 'process_id',width: 150, title: t('processCard.processId'), sortable: true},
    {field: 'technology_number',width: 70, title: '层', sortable: true},
    {field: 'TotalFloors',width: 150, title: '总层数', sortable: true},
    {type: 'seq', title: t('basicData.Number'), width: 80},
    {field: 'curtain_wall',title: '幕墙模式',width: 80, slots: { default: 'state1' }},
    {field: "allow_rotate", title: '允许横排', width: 80, slots: { default: 'state2' }},
    {field: "tempering", title: '钢化', width: 80, slots: { default: 'state3' }},
    {field: 'processId',width: 150, title: t('processCard.processId'), sortable: true},
    {field: 'technologyNumber',width: 70, title: '层', sortable: true},
    {field: 'total_layers',width: 150, title: '总层数', sortable: true},
    {field: 'TotalNumber',width: 150, title: '规格', sortable: true},
    {field: 'quantity',width: 150, title: t('order.quantity'), sortable: true},
    {field: 'total_num',width: 150, title: t('order.quantity'), sortable: true},
    {field: 'glass_child',width: 150, title: t('order.product'), sortable: true},
    {field: 'project', width:150, title: t('order.project'), showOverflow: "ellipsis"},
    {field: 'area',width: 150, title: t('order.area'), sortable: true},
    {field: 'total_area',width: 150, title: t('order.area'), sortable: true},
  ],//表头参数
@@ -62,45 +79,128 @@
  toolbarConfig: {
    buttons: [],
    slots:{
      buttons: "toolbar_buttons"
    },
    zoom: true,
    custom: true
  },
})
let emit = defineEmits([
  'changeDialog'
  'changeDialog','upProcessId', 'sendData'
]);
const selectFullData =  () => {
  return xGrid.value.getTableData().fullData
}
const props = defineProps({
  tableData: Array
  tableData: Array,
  processId: null,
  technologyNumber: null,
  patchState: null,
  glassThickness: String,  // 添加玻璃厚度属性
  glassType: String        // 添加玻璃类型属性
});
onMounted(() => {
  if (xGrid.value) {
    const grid = xGrid.value;
    if (typeof grid.setDirty === 'function') {
      grid.setDirty(true);
    }
  } else {
    console.error('vxe-grid 组件实例未获取到,可能挂载出现问题');
  }
});
watch(() => props.tableData, async (newData) => {
  if (Array.isArray(newData)) {
    gridOptions.data = newData;
    await nextTick();
    if (xGrid.value) {
      const grid = xGrid.value;
      if (typeof grid.refresh === 'function') {
        grid.refresh();
      }
    }
  } else {
    console.error('传递给表格的数据格式不符合要求,期望是数组格式');
    addListener(xGrid.value,gridOptions)
    console.log(newData)
    xGrid.value.loadData(deepClone(newData))
    const data = xGrid.value.getTableData().fullData
    data.forEach(item => {
      item.tempering = item.tempering === 1;
      item.allow_rotate = item.allow_rotate === 1;
      item.curtain_wall = item.curtain_wall === 1;
    })
  }
});
let process_id = ref()
//获取流程卡号详情
let rowClickIndex = ref(null)
const gridEvents = {
  cellClick({row}) {
    rowClickIndex.value = row
    // Emit 事件将更新后的值传递给父组件
    emit('upProcessId', rowClickIndex.value.processId,rowClickIndex.value.patch_state,rowClickIndex.value.technologyNumber);
    emit('updateTechnologyNumber', rowClickIndex.value.processId,rowClickIndex.value.patch_state,rowClickIndex.value.technologyNumber);
  },
  menuClick ({ menu, row, column }) {
    const $grid = xGrid.value
    if ($grid) {
      switch (menu.code) {
        case 'copyChecked' :{
          let result = toolbarButtonClickEvent()
          if(result){
            const dataList = xGrid.value.getTableData().visibleData
            let firstVal=null;
            if(result.cell.indexOf('.')>-1){
              firstVal = eval("dataList["+result.start +"]."+result.cell)
            }else {
              firstVal=dataList[result.start][result.cell];
            }
            dataList.forEach((item,index) =>{
              if(index>=result.start && index<=result.end){
                //取消选中
                if(parseInt(firstVal)<=0){
                  xGrid.value.setCheckboxRow(item, false);
                }
                if(result.cell.indexOf('.')>-1){
                  const  columnArr = result.cell.split('.')
                  item[columnArr[0]][columnArr[1]]  = firstVal
                }else{
                  item[result.cell]  = firstVal
                }
              }
            })
          }
          break
        }
        case 'copyAll' :{
          let result = toolbarButtonClickEvent()
          if(result){
            const dataList = xGrid.value.getTableData().visibleData
            let firstVal=null;
            if(result.cell.indexOf('.')>-1){
              firstVal = eval("dataList["+result.start +"]."+result.cell)
            }else {
              firstVal=dataList[result.start][result.cell];
            }
            dataList.forEach((item,index) =>{
              if(index>=result.start){
                //取消选中
                if(parseInt(firstVal)<=0){
                  xGrid.value.setCheckboxRow(item, false);
                }
                if(result.cell.indexOf('.')>-1){
                  const  columnArr = result.cell.split('.')
                  item[columnArr[0]][columnArr[1]]  = firstVal
                }else{
                  item[result.cell]  = firstVal
                }
              }
            })
          }
          break
        }
      }
    }
  }
}
defineExpose({selectFullData})
</script>
<template>
@@ -108,11 +208,11 @@
    <span>流程卡</span>
    <vxe-grid
        size="small"
        @filter-change="filterChanged"
        height="100%"
        class="mytable-scrollbar"
        ref="xGrid"
        v-bind="gridOptions"
        v-on="gridEvents"
    >
      <template #num2_filter="{ column, $panel }">
        <div>
@@ -137,10 +237,34 @@
          </div>
        </div>
      </template>
      <template #state1="{ row,column}">
        <el-checkbox
            v-model="row.curtain_wall"/>
      </template>
      <template #state2="{ row,column}">
        <el-checkbox
            v-model="row.allow_rotate"/>
      </template>
      <template #state3="{ row,column}">
        <el-checkbox
            v-model="row.tempering"/>
      </template>
    </vxe-grid>
  </div>
</template>
<style scoped>
:deep(.vxe-tools--operate){
  height: 20px;
  margin-top: -20px;
}
.vxe-grid {
  /* 禁用浏览器默认选中 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
</style>