From eedfb8fa8d1eeb83554081f5785f832f45a64f3a Mon Sep 17 00:00:00 2001
From: chengxiangling <291105840@qq.com>
Date: 星期日, 11 五月 2025 12:29:23 +0800
Subject: [PATCH] 提交页面script加上name命名
---
src/views/basicData/bom/index.vue | 508 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 348 insertions(+), 160 deletions(-)
diff --git a/src/views/basicData/bom/index.vue b/src/views/basicData/bom/index.vue
index 5f530bf..fd9610c 100644
--- a/src/views/basicData/bom/index.vue
+++ b/src/views/basicData/bom/index.vue
@@ -1,210 +1,398 @@
<template>
<div class="app-container">
- <el-form :model="queryParams" ref="queryRef" :rules="rules" :inline="true" v-show="showSearch" label-width="68px">
+ <el-form
+ :model="queryParams"
+ ref="queryRef"
+ :rules="rules"
+ :inline="true"
+ v-show="showSearch"
+ :label-width="locale === 'zh' ? '90px' : '160px'"
+ >
<el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="鏂欏彿" prop="itemCode">
+ <el-col :span="locale === 'zh' ? 5 : 9">
+ <el-form-item :label="$t('plan.query.itemNumber')" prop="itemCode">
<el-input
+ :style="{ width: locale === 'zh' ? '140px' : '220px' }"
v-model="queryParams.itemCode"
- placeholder="璇疯緭鍏ユ枡鍙�"
+ :placeholder="`${$t('common.common.placeholder')}${$t(
+ 'plan.query.itemNumber'
+ )}`"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
- <el-col :span="18" style="text-align: right;">
- <el-form-item>
- <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button>
- <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button>
- </el-form-item>
+ <el-col :span="locale === 'zh' ? 7 : 9">
+ <el-form-item
+ :label="$t('plan.table.applicableFactories')"
+ prop="orgCode"
+ >
+ <el-select
+ clearable
+ v-model="queryParams.orgCode"
+ :style="{ width: locale === 'zh' ? '180px' : '240px' }"
+ :placeholder="`${$t('common.common.placeholder')}${$t(
+ 'plan.table.applicableFactories'
+ )}`"
+ >
+ <el-option
+ v-for="plant in plantList"
+ :key="plant.id"
+ :label="plant.plantName"
+ :value="plant.plantCode"
+ >
+ </el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="locale === 'zh' ? 11 : 6" style="text-align: right">
+ <el-form-item class="column-with-margin">
+ <el-button type="primary" icon="Search" @click="handleQuery">{{
+ $t("common.common.query")
+ }}</el-button>
+ <el-button icon="Refresh" @click="resetQuery">{{
+ $t("common.common.reset")
+ }}</el-button>
+ </el-form-item>
</el-col>
</el-row>
</el-form>
+ <el-row :gutter="10" class="mb8">
+ <el-col :span="1.5">
+ <el-button
+ type="success"
+ plain
+ icon="Refresh"
+ :disabled="loadingRefresh"
+ @click="handleRefresh"
+ v-hasPermi="['Aps:ApsBomHeader:refreshBomData']"
+ >{{ $t("common.common.update") }}</el-button
+ >
+ </el-col>
+ <right-toolbar
+ v-model:showSearch="showSearch"
+ @queryTable="getList"
+ ></right-toolbar>
+ </el-row>
<HxlhTable
- style="width: 100%"
- :columns="columns"
- :data="bomList"
- :loading="loading"
- :height="height"
- :treeConfig="treeConfig"
- :row-style="getRowStyle"
+ style="width: 100%"
+ :columns="columns"
+ :data="bomList"
+ :loading="loading"
+ :height="height"
+ @on-checkbox="handleCheckboxChange"
+ :page="page"
+ @changePageNo="changePageNo"
+ @changePageSize="changePageSize"
>
+ <!-- :expand-config="expandConfig"
+ :subGridOptions="subGridOptions" -->
+ <template #buttons="{ row }">
+ <el-button
+ type="primary"
+ link
+ @click="handleCheckView(row)"
+ v-hasPermi="['Aps:apsBom:list']"
+ >鏌ョ湅</el-button
+ >
+ </template>
</HxlhTable>
+ <el-dialog
+ :title="$t('common.common.viewDetails')"
+ v-model="openDialog"
+ width="900px"
+ append-to-body
+ style="height: 400px; overflow: hidden"
+ >
+ <HxlhTable
+ style="width: 100%"
+ :columns="subGridOptions"
+ :data="subList"
+ :loading="loadingSub"
+ :height="'280px;'"
+ >
+ </HxlhTable>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button @click="openDialog = false">{{
+ $t("common.common.close")
+ }}</el-button>
+ </span>
+ </template>
+ </el-dialog>
</div>
</template>
-<script setup name="ApsBom">
-import { listApsBom } from "@/api/basicData/bom/bom";
+<script setup name="Bom">
+import {
+ listApsBomHeaderList,
+ listApsBomLineList,
+ listApsBomRefreshBomDataList,
+} from "@/api/basicData/bom/bom.js";
import { listAll_plant } from "@/api/basicData/plant";
-import axios from 'axios';
-import HxlhTable from '@/components/HxlhTable'
-
+import HxlhTable from "@/components/HxlhTable/index.vue";
+// import { ElMessage } from "element-plus";
+import { useI18n } from "vue-i18n"; //瑕佸湪js涓娇鐢ㄥ浗闄呭寲
+const { t, locale } = useI18n();
const { proxy } = getCurrentInstance();
-
+// 鍒嗛〉灞炴��
+const page = ref({
+ total: 0,
+ current: 1,
+ size: 10,
+});
+const plantList = ref([]);
const bomList = ref([]);
-const open = ref(false);
+const subList = ref([]);
const loading = ref(false);
+const loadingSub = ref(false);
+const loadingRefresh = ref(false);
const showSearch = ref(true);
-
-const treeConfig= {
- transform: true,
- rowField: 'bomId',
- parentField: 'parentBomId'
-}
-
+const total = ref(0);
+const height = ref(document.documentElement.clientHeight - 210 + "px;");
+const heightSub = ref(document.documentElement.clientHeight - 320 + "px;");
+// 琛ㄦ牸閰嶇疆
+const columns = ref([]);
+const subGridOptions = ref([]);
+const openDialog = ref(false);
const data = reactive({
- form: {},
queryParams: {
+ pageNum: 1,
+ pageSize: 10,
itemCode: null,
+ orgCode: "",
},
- rules: {
- itemCode: [
- { required: true, message: "鏂欏彿涓嶈兘涓虹┖", trigger: "blur" }
- ],
- }
+ rules: {},
});
-// 琛ㄦ牸閰嶇疆
-const columns = ref([
- {
- title: 'bomId',
- field: 'bomId',
- minWidth: 20, treeNode: true
- },
- {
- title: 'parentBomId',
- field: 'parentBomId',
- },
- {
- title: '鏂欏彿',
- field: 'itemCode',
- },
- {
- title: '鐗╂枡鎻忚堪',
- field: 'itemName',
- },
- {
- title: '鐢熸晥鏃ユ湡',
- field: 'startDate',
- },
- {
- title: '澶辨晥鏃ユ湡',
- field: 'endDate',
- },
- {
- title: '閫傜敤宸ュ巶',
- field: 'orgCode',
- formatter: (({ cellValue, row, column }) => {
- if (cellValue) {
- for(let i=0;i<plantList.value.length;i++){
- if(cellValue===plantList.value[i].plantCode){
- return plantList.value[i].plantName
+const { queryParams, rules } = toRefs(data);
+watch(
+ locale,
+ (newLocale) => {
+ rules.value = {
+ itemCode: [
+ {
+ required: true,
+ message: `${t("common.common.placeholder")}${t(
+ "plan.query.itemNumber"
+ )}`,
+ trigger: "blur",
+ },
+ ],
+ };
+ columns.value = [
+ // {
+ // field: "expand",
+ // type: "expand",
+ // width: 60,
+ // align: "center",
+ // slots: { content: "expandContent" },
+ // },
+ // { type: "checkbox", width: 60, align: "center" },
+ {
+ title: "BOM ID",
+ field: "bomHeaderId",
+ },
+ {
+ title: t("basic.table.parentPartNumber"),
+ field: "itemCode",
+ },
+ {
+ title: t("basic.table.parentMaterialDescription"),
+ field: "itemName",
+ },
+ {
+ title: t("basic.table.effectiveDate"),
+ field: "startDate",
+ },
+ {
+ title: t("basic.table.expiringDate"),
+ field: "endDate",
+ },
+ {
+ title: t("basic.table.integrationDate"),
+ field: "createTime",
+ },
+ {
+ title: t("basic.table.applicableFactories"),
+ field: "orgCode",
+ formatter: ({ cellValue, row, column }) => {
+ if (cellValue) {
+ for (let i = 0; i < plantList.value.length; i++) {
+ if (cellValue === plantList.value[i].plantCode) {
+ return plantList.value[i].plantName;
+ }
+ }
}
- }
- }
- return '';
- })
+ },
+ },
+ {
+ title: t("common.common.operate"),
+ width: 100,
+ fixed: "right",
+ slots: { default: "buttons" },
+ align: "center",
+ },
+ ];
+ subGridOptions.value = [
+ {
+ title: t("plan.table.bomItemID"),
+ field: "bomLineId",
+ width: 150,
+ align: "center",
+ },
+ {
+ title: "BOM ID",
+ field: "bomHeaderId",
+ width: 150,
+ align: "center",
+ },
+ {
+ title: t("plan.table.itemNumber"),
+ field: "itemCode",
+ width: 100,
+ align: "center",
+ },
+ {
+ title: t("basic.table.materialDescription"),
+ field: "itemName",
+ width: 100,
+ align: "center",
+ },
+ {
+ title: t("basic.table.usage"),
+ field: "num",
+ width: 100,
+ align: "center",
+ },
+ {
+ title: t("basic.table.effectiveDate"),
+ field: "startDate",
+ width: 150,
+ align: "center",
+ },
+ {
+ title: t("basic.table.expiringDate"),
+ field: "endDate",
+ width: 200,
+ align: "center",
+ },
+ {
+ title: t("basic.table.integrationDate"),
+ field: "createTime",
+ width: 200,
+ align: "center",
+ },
+ {
+ title: t("basic.table.applicableFactories"),
+ field: "orgCode",
+ width: 90,
+ align: "center",
+ formatter: ({ cellValue, row, column }) => {
+ if (cellValue) {
+ for (let i = 0; i < plantList.value.length; i++) {
+ if (cellValue === plantList.value[i].plantCode) {
+ return plantList.value[i].plantName;
+ }
+ }
+ }
+ },
+ },
+ ];
},
- {
- title: '鍒涘缓鏃堕棿',
- field: 'createTime',
- },
-]);
-
-// 瀹氫箟涓�涓嚱鏁版潵鑾峰彇琛岀殑灞傜骇
-const getRowLevel = (row, dataMap) => {
- let level = 0
- let parentBomId = row.parentBomId
- while (parentBomId!== null) {
- const parentRow = dataMap.get(parentBomId)
- if (parentRow) {
- level++
- parentBomId = parentRow.parentBomId
- } else {
- break
- }
- }
- return level
-}
-
-// 瀹氫箟涓�涓嚱鏁版潵璁剧疆琛岀殑鏍峰紡
-const getRowStyle = (row, rowIndex) => {
- if (!Array.isArray(bomList.value)) {
- console.error('bomList 涓嶆槸涓�涓暟缁勭被鍨�');
- return {};
- }
- const dataMap = new Map(bomList.value.map(item => [item.bomId, item]))
- const level = getRowLevel(row.row, dataMap)
- const colors = ['#f0f9ff', '#e6f7ff', '#bae7ff', '#91d5ff', '#69c0ff']
- return {
- backgroundColor: colors[level % colors.length]
- }
-}
-
-const { queryParams, form, rules } = toRefs(data);
-
-const queryPlants = ref({status: 1});
-const plantList = ref([]);
-const height = ref(document.documentElement.clientHeight - 180 + "px;")
-
-/** 鏌ヨBOM鏁版嵁绠$悊鍒楄〃 */
-function getList() {
- loading.value = true;
- axios.all([
- listAll_plant(queryPlants.value),
- listApsBom(queryParams.value)
- ])
- .then(axios.spread((response1, response2) => {
- plantList.value = response1.data;
- bomList.value = response2.rows;
- loading.value = false;
- }))
- .catch(error => {
- console.error('璇锋眰鍑洪敊:', error);
+ { immediate: true, deep: true }
+);
+async function handleRefresh() {
+ loadingRefresh.value = true;
+ const res = await listApsBomRefreshBomDataList();
+ if (res.code == 200) {
+ ElMessage({
+ message: t("plan.message.update"),
+ type: "success",
});
+ loadingRefresh.value = false;
+ getList();
+ } else {
+ loadingRefresh.value = false;
+ }
+}
+function changePageNo(currentPage) {
+ queryParams.value.pageNum = currentPage;
+ page.value.current = currentPage;
+ getList();
+}
+function changePageSize(pageSize) {
+ page.value.current = 1;
+ queryParams.value.pageNum = 1;
+ queryParams.value.pageSize = pageSize;
+ getList();
}
-// 鍙栨秷鎸夐挳
-function cancel() {
- open.value = false;
- reset();
-}
-
-// 琛ㄥ崟閲嶇疆
-function reset() {
- form.value = {
- id: null,
- bomId: null,
- parentBomId: null,
- itemCode: null,
- itemName: null,
- startDate: null,
- endDate: null,
- orgCode: null,
- delFlag: null,
- createBy: null,
- createTime: null,
- updateBy: null,
- updateTime: null
- };
- proxy.resetForm("ApsBomRef");
+/** 鏌ヨ闆朵欢璁″垝绠$悊鍒楄〃 */
+function getList() {
+ page.value.current = 1;
+ queryParams.value.pageNum = 1;
+ loading.value = true;
+ listApsBomHeaderList(queryParams.value)
+ .then((response) => {
+ console.log(response, "listApsBomHeaderList");
+ bomList.value = response.rows;
+ page.value.total = response.total;
+ loading.value = false;
+ })
+ .catch(() => {
+ loading.value = false;
+ });
}
/** 鎼滅储鎸夐挳鎿嶄綔 */
function handleQuery() {
- proxy.$refs["queryRef"].validate(valid => {
+ proxy.$refs["queryRef"].validate((valid) => {
if (valid) {
- getList();
- }
+ getList();
+ }
});
}
/** 閲嶇疆鎸夐挳鎿嶄綔 */
function resetQuery() {
+ page.value.current = 1;
+ page.value.total = 0;
+ queryParams.value.pageNum = 1;
proxy.resetForm("queryRef");
- bomList.value = null;
+ bomList.value = [];
+ subList.value = [];
}
-console.log("123");
+function handleCheckView(row) {
+ openDialog.value = true;
+ listApsBomLineList({ bomHeaderId: row.bomHeaderId }).then((data) => {
+ console.log(data, "listApsBomLineList");
+ subList.value = data.rows;
+ });
+}
+
+// /*瀹氫箟涓嬫媺浜岀骇琛�*/
+// const expandConfig = ref({
+// lazy: true,
+// loadMethod({ row }) {
+// // 璋冪敤鎺ュ彛
+// return listProcessRoute({ workOrderNo: row.documentNumber }).then(
+// (data) => {
+// row.subList = data.rows;
+// }
+// );
+// },
+// });
+
+onMounted(async () => {
+ const res = await listAll_plant({});
+ plantList.value = res.data;
+});
</script>
+<style lang="css" scoped>
+h4 {
+ font-weight: bold;
+}
+</style>
--
Gitblit v1.9.3