¶Ô±ÈÐÂÎļþ |
| | |
| | | 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' |
| | | }) |
| | | } |
| | |
| | | :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" |
| | |
| | | default :()=>{ |
| | | return {} |
| | | } |
| | | }, |
| | | treeConfig: { |
| | | type: Object, |
| | | default: () => { |
| | | return {} |
| | | } |
| | | }, |
| | | rowStyle: { |
| | | type: Function, |
| | | default: () => { |
| | | return {} |
| | | } |
| | | }, |
| | | |
| | | }) |
| | | |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| | |
| | | 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 |