guoyujie
2025-04-15 5b8140730d40e3c44d77828358e09c1f52fc33c2
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/ComputeCard.vue
@@ -49,11 +49,9 @@
  columns:[
    {type: 'seq', title: t('basicData.Number'), width: 80},
    {field: 'curtain_wall',type:'checkbox',title: '幕墙模式', width: 80},
    {field: 'allow_rotate',type:'checkbox',title: '允许横排', width: 80},
    {field: 'tempering',type:'checkbox',title: '钢化', width: 80},
    /*{field: "allow_rotate", title: '允许横排', width: 80, slots: { default: 'state' }},
    {field: "tempering", title: '钢化', width: 80, slots: { default: 'state' }},*/
    {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},
@@ -92,127 +90,20 @@
  technologyNumber: null,
  patchState: null,
});
const handleCheckChange=({ column, records })=> {
  if (column.field === 'tempering') {
    console.log(records)
  }
}
watch(() => props.tableData, async (newData) => {
  if (Array.isArray(newData)) {
    console.log(newData)
    xGrid.value.loadData(deepClone(newData))
    const data=xGrid.value.getTableData().fullData
    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;
    })
    xGrid.value.reloadData(data);
    /*await nextTick();
    if (xGrid.value) {
      const grid = xGrid.value;
      if (typeof grid.refresh === 'function') {
        grid.refresh();
      }
      // 提取所有唯一的process_id
      const processIds = Array.from(new Set(newData.map(item => item.process_id)));
      /!*const requests = newData.map(item =>
          request.post(`/glassOptimize/selectComputeDetail/${item.process_id}/${item.technologyNumber}/${item.patchState}`)
      );*!/
      /!*try {
        const responses = await Promise.all(requests);
        // 整合数据
        const processData = responses.reduce((acc, res, index) => {
          const processId = processIds[index];
          // 检查res.data是否为对象,并且包含'data'字段
          if (typeof res.data === 'object' && res.data !== null && 'data' in res.data) {
            const data = res.data.data;
            // 检查data是否为数组
            if (!Array.isArray(data)) {
              console.error(`响应数据中的'data'字段不是数组,process_id: ${processId}`);
              return acc;
            }
            // 获取对应process_id的newData条目
            const relatedNewData = newData.filter(item => item.process_id === processId);
            // 初始化process_card对象
            const processCard = {
  process_no: processId,
  layers: relatedNewData.technology_number,
  total_layers: relatedNewData.TotalNumber,
  total_num: relatedNewData.quantity,
  total_area: relatedNewData.area,
  is_must: true,
  allow_rotate: relatedNewData.check === 1 ? true : false,
  priority_level: 0,
  tempering: relatedNewData.check === 2 ? true : false,
  curtain_wall: relatedNewData.check === 3 ? true : false,
  patch_state: 0,
  merge: 0,
  glass_details: []
};
            // 整合glass_details
            data.forEach(detail => {
              const matchedNewData = relatedNewData.find(
                item => item.technology_number === detail.technology_number
              );
              processCard.glass_details.push({
                process_id: processId,
                technology_number: detail.technology_number,
                order_number: detail.order_number,
                layers_number: detail.layers_number,
                max_width: detail.width,
                max_height: detail.height,
                child_width: detail.child_width,
                child_height: detail.child_height,
                quantity: matchedNewData ? matchedNewData.quantity : 0,
                patch_state: 0
              });
            });
            // 将processCard添加到acc中
            if (!acc.process_cards) {
              acc.process_cards = [];
            }
            acc.process_cards.push(processCard);
              // 设置其他字段的值
          } else {
            console.error(`响应数据格式不正确,process_id: ${processId}`);
          }
          return acc;
        }, {});
        if (newData.length > 0) {
          // 假设所有条目的thickness和glassType相同
          processData.glass_thickness = newData[0].thickness;
          processData.glass_type = newData[0].glassType;
        } else {
          processData.glass_thickness = "";
          processData.glass_type = "";
        }
        // 发送整合后的数据到父组件
        emit('sendData', processData);
      } catch (error) {
        console.error('请求失败:', error);
      }*!/
    }*/
  } else {
    console.error('传递给表格的数据格式不符合要求,期望是数组格式');
  }
});
@@ -226,8 +117,8 @@
  cellClick({row}) {
    rowClickIndex.value = row
    // Emit 事件将更新后的值传递给父组件
    emit('upProcessId', rowClickIndex.value.process_id,rowClickIndex.value.patch_state,rowClickIndex.value.technology_number);
    emit('updateTechnologyNumber', rowClickIndex.value.process_id,rowClickIndex.value.patch_state,rowClickIndex.value.technology_number);
    emit('upProcessId', rowClickIndex.value.processId,rowClickIndex.value.patch_state,rowClickIndex.value.technologyNumber);
    emit('updateTechnologyNumber', rowClickIndex.value.processId,rowClickIndex.value.patch_state,rowClickIndex.value.technologyNumber);
  }
}
@@ -244,7 +135,6 @@
        ref="xGrid"
        v-bind="gridOptions"
        v-on="gridEvents"
        @checkbox-change="handleCheckChange"
    >
      <template #num2_filter="{ column, $panel }">
        <div>
@@ -270,13 +160,17 @@
        </div>
      </template>
      <template #state="{ row,column}">
      <template #state1="{ row,column}">
        <el-checkbox
            v-if="row[column.field] === 1"
            :checked="true"/>
            v-model="row.curtain_wall"/>
      </template>
      <template #state2="{ row,column}">
        <el-checkbox
            v-else
            :checked="false"/>
            v-model="row.allow_rotate"/>
      </template>
      <template #state3="{ row,column}">
        <el-checkbox
            v-model="row.tempering"/>
      </template>
    </vxe-grid>
  </div>