From eaafc29bc72b22b59b95b54c27d1a3113b3e7871 Mon Sep 17 00:00:00 2001 From: CD配唱片 <CD配唱片> Date: 星期三, 23 四月 2025 14:42:42 +0800 Subject: [PATCH] Merge branch 'dev' of http://192.168.50.149:8085/r/aps-kj-web into dev --- src/views/basicData/materialManagement/index.vue | 1 src/components/HxlhTable/index.vue | 31 ++++- src/api/basicData/bom/bom.js | 44 ++++++++ src/views/basicData/bom/index.vue | 210 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 277 insertions(+), 9 deletions(-) diff --git a/src/api/basicData/bom/bom.js b/src/api/basicData/bom/bom.js new file mode 100644 index 0000000..958f630 --- /dev/null +++ b/src/api/basicData/bom/bom.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 鏌ヨBOM鏁版嵁绠$悊鍒楄〃 +export function listApsBom(query) { + return request({ + url: '/aps/ApsBom/list', + method: 'get', + params: query + }) +} + +// 鏌ヨBOM鏁版嵁绠$悊璇︾粏 +export function getApsBom(id) { + return request({ + url: '/ApsBom/ApsBom/' + id, + method: 'get' + }) +} + +// 鏂板BOM鏁版嵁绠$悊 +export function addApsBom(data) { + return request({ + url: '/ApsBom/ApsBom', + method: 'post', + data: data + }) +} + +// 淇敼BOM鏁版嵁绠$悊 +export function updateApsBom(data) { + return request({ + url: '/ApsBom/ApsBom', + method: 'put', + data: data + }) +} + +// 鍒犻櫎BOM鏁版嵁绠$悊 +export function delApsBom(id) { + return request({ + url: '/ApsBom/ApsBom/' + id, + method: 'delete' + }) +} diff --git a/src/components/HxlhTable/index.vue b/src/components/HxlhTable/index.vue index b0b86fa..dce06fe 100644 --- a/src/components/HxlhTable/index.vue +++ b/src/components/HxlhTable/index.vue @@ -27,6 +27,8 @@ :scroll-x="{enabled: true}" :scroll-y="{enabled: true}" :expand-config="expandConfig" + :tree-config="treeConfig" + :row-style="rowStyle" @sort-change="sortChange" @page-change="pagerChange" @form-submit="findList" @@ -142,17 +144,30 @@ } }, expandConfig: { - type: Object, - default: () => { - return {lazy: false} - } + type: Object, + default: () => { + return {lazy: false} + } }, subGridOptions: { - type:Object, - default :()=>{ + type:Object, + default :()=>{ + return {} + } +}, +treeConfig: { + type: Object, + default: () => { return {} - } -} + } +}, +rowStyle: { + type: Function, + default: () => { + return {} + } +}, + }) diff --git a/src/views/basicData/bom/index.vue b/src/views/basicData/bom/index.vue new file mode 100644 index 0000000..5f530bf --- /dev/null +++ b/src/views/basicData/bom/index.vue @@ -0,0 +1,210 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" ref="queryRef" :rules="rules" :inline="true" v-show="showSearch" label-width="68px"> + <el-row :gutter="20"> + <el-col :span="6"> + <el-form-item label="鏂欏彿" prop="itemCode"> + <el-input + v-model="queryParams.itemCode" + placeholder="璇疯緭鍏ユ枡鍙�" + 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> + </el-row> + </el-form> + + <HxlhTable + style="width: 100%" + :columns="columns" + :data="bomList" + :loading="loading" + :height="height" + :treeConfig="treeConfig" + :row-style="getRowStyle" + > + </HxlhTable> + </div> +</template> + +<script setup name="ApsBom"> +import { listApsBom } from "@/api/basicData/bom/bom"; +import { listAll_plant } from "@/api/basicData/plant"; +import axios from 'axios'; +import HxlhTable from '@/components/HxlhTable' + +const { proxy } = getCurrentInstance(); + +const bomList = ref([]); +const open = ref(false); +const loading = ref(false); +const showSearch = ref(true); + +const treeConfig= { + transform: true, + rowField: 'bomId', + parentField: 'parentBomId' +} + +const data = reactive({ + form: {}, + queryParams: { + itemCode: null, + }, + rules: { + itemCode: [ + { required: true, message: "鏂欏彿涓嶈兘涓虹┖", trigger: "blur" } + ], + } +}); + +// 琛ㄦ牸閰嶇疆 +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 + } + } + } + return ''; + }) + }, + { + 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); + }); +} + +// 鍙栨秷鎸夐挳 +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 handleQuery() { + proxy.$refs["queryRef"].validate(valid => { + if (valid) { + getList(); + } + }); +} + +/** 閲嶇疆鎸夐挳鎿嶄綔 */ +function resetQuery() { + proxy.resetForm("queryRef"); + bomList.value = null; +} + +console.log("123"); +</script> diff --git a/src/views/basicData/materialManagement/index.vue b/src/views/basicData/materialManagement/index.vue index b3f78d3..e1dd58f 100644 --- a/src/views/basicData/materialManagement/index.vue +++ b/src/views/basicData/materialManagement/index.vue @@ -165,7 +165,6 @@ width: 150, formatter: (({ cellValue, row, column }) => { if (cellValue) { - console.log(plantList.value); for(let i=0;i<plantList.value.length;i++){ if(cellValue===plantList.value[i].plantCode){ return plantList.value[i].plantName -- Gitblit v1.9.3