张诺
10 小时以前 48c4d75c995e6e986103f1e6510ca0242421cccf
Merge branch 'dev_天津_阳光印刷' of http://114.132.189.42:9002/r/product-inventory-management into dev_天津_阳光印刷
已修改1个文件
114 ■■■■■ 文件已修改
src/views/productionManagement/productionCosting/index.vue 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/productionCosting/index.vue
@@ -36,7 +36,17 @@
          :page="page"
          @row-click="handleLeftRowClick"
          @pagination="pagination"
        ></PIMTable>
        >
          <template #workDuration="{ row }">
            <el-button v-if="Number(row.totalWorkMinutes) > 0"
                       type="primary"
                       text
                       @click.stop="openWorkDurationDialog(row)">
              {{ row.totalWorkMinutes }}
            </el-button>
            <span v-else>-</span>
          </template>
        </PIMTable>
                </div>
            </el-col>
@@ -61,6 +71,23 @@
                </div>
            </el-col>
        </el-row>
    <el-dialog v-model="workDurationDialogVisible"
               :title="`工时明细${currentSchedulingUserName ? ` - ${currentSchedulingUserName}` : ''}`"
               width="600px">
      <el-table :data="workDurationDetailList"
                border
                style="width: 100%; margin-bottom: 16px;">
        <el-table-column type="index"
                         label="序号"
                         width="80"/>
        <el-table-column prop="deviceName"
                         label="机台"
                         min-width="220"/>
        <el-table-column prop="workMinutes"
                         label="工作时间(分钟)"
                         min-width="160"/>
      </el-table>
    </el-dialog>
    </div>
</template>
@@ -68,7 +95,11 @@
import {onMounted, ref} from "vue";
import { ElMessageBox } from "element-plus";
import dayjs from "dayjs";
import {salesLedgerProductionAccountingListProductionDetails, salesLedgerProductionAccountingList} from "@/api/productionManagement/productionCosting.js";
import {
  salesLedgerProductionAccountingListProductionDetails,
  salesLedgerProductionAccountingList
} from "@/api/productionManagement/productionCosting.js";
const { proxy } = getCurrentInstance();
const tableColumn = ref([
@@ -127,6 +158,16 @@
        prop: "wages",
    minWidth: 100,
    },
  {
    label: "机台",
    prop: "deviceName",
    minWidth: 100,
  },
  {
    label: "工时(分钟)",
    prop: "workMinutes",
    width: 110,
  },
]);
// 左侧汇总台账列(生产人、产量、工资、合格率)
@@ -157,12 +198,22 @@
      return parseFloat(val).toFixed(2)
    },
    },
  {
    label: "工时(分钟)",
    prop: "totalWorkMinutes",
    minWidth: 120,
    dataType: "slot",
    slot: "workDuration",
  },
]);
const tableData = ref([]);
const tableLoading = ref(false);
const tableLoading1 = ref(false);
const leftTableData = ref([]);
const workDurationDialogVisible = ref(false);
const workDurationDetailList = ref([]);
const currentSchedulingUserName = ref("");
// 日 / 月 切换(默认按日)
const page = reactive({
    current: 1,
@@ -224,12 +275,22 @@
  salesLedgerProductionAccountingList(params).then((res) => {
        const records = res.data.records || [];
    leftTableData.value = records;
    leftTableData.value = records.map(item => {
      const workDurationDetailListValue = buildWorkDurationDetailList(item.deviceWorkInfoPairList);
      const totalWorkMinutes = workDurationDetailListValue.reduce(
          (sum, detail) => sum + Number(detail.workMinutes || 0),
          0
      );
      return {
        ...item,
        workDurationDetailList: workDurationDetailListValue,
        totalWorkMinutes,
      };
    });
        page.total = res.data.total || 0;
    }).finally(() => {
    tableLoading.value = false;
  })
};
@@ -238,7 +299,8 @@
  tableLoading1.value = true;
  const params = { ...page1, ...searchForm.value };
  salesLedgerProductionAccountingListProductionDetails(params).then((res) => {
    tableData.value = res.data.records || [];;
    tableData.value = res.data.records || [];
    ;
    page1.total = res.data.total || 0;
  }).finally(() => {
    tableLoading1.value = false;
@@ -290,6 +352,48 @@
  tableData.value = []
}
const buildWorkDurationDetailList = (deviceWorkInfoPairList) => {
  if (!deviceWorkInfoPairList) {
    return [];
  }
  let listData = deviceWorkInfoPairList;
  if (typeof deviceWorkInfoPairList === "string") {
    try {
      listData = JSON.parse(deviceWorkInfoPairList);
    } catch {
      return [];
    }
  }
  if (!Array.isArray(listData)) {
    return [];
  }
  const details = [];
  listData.forEach(item => {
    if (!item || typeof item !== "object") {
      return;
    }
    Object.entries(item).forEach(([deviceName, workMinutes]) => {
      const numericMinutes = Number(workMinutes);
      if (deviceName) {
        details.push({
          deviceName,
          workMinutes: Number.isFinite(numericMinutes) ? numericMinutes : 0,
        });
      }
    });
  });
  return details;
};
const openWorkDurationDialog = row => {
  currentSchedulingUserName.value = row?.schedulingUserName || "";
  const details = Array.isArray(row?.workDurationDetailList)
      ? row.workDurationDetailList
      : buildWorkDurationDetailList(row?.deviceWorkInfoPairList);
  workDurationDetailList.value = details;
  workDurationDialogVisible.value = true;
};
// 点击左侧行,刷右侧明细(按生产人过滤)
const handleLeftRowClick = (row) => {
    searchForm.value.schedulingUserName = row.schedulingUserName || "";