| | |
| | | <template> |
| | | <div class="material-node"> |
| | | <!-- 当前节点卡片 --> |
| | | <div :class="['node-card', isRoot ? 'root-card' : 'child-card']"> |
| | | <div :class="['node-card', isRoot ? 'root-card' : (row.nodeType === 'semiFinished' ? 'semi-finished-card' : 'child-card')]"> |
| | | <div class="node-header"> |
| | | <div class="node-label"> |
| | | <el-tag :type="isRoot ? '' : 'success'" size="small" effect="dark"> |
| | | {{ isRoot ? '成品' : '原料' }} |
| | | <el-tag :type="isRoot ? '' : (row.nodeType === 'semiFinished' ? 'warning' : 'success')" size="small" effect="dark"> |
| | | {{ isRoot ? '成品' : (row.nodeType === 'semiFinished' ? '半成品' : '原料') }} |
| | | </el-tag> |
| | | <span class="node-title">{{ row.productName || '未选择产品' }}</span> |
| | | <span v-if="row.model" class="node-sub">规格: {{ row.model }}</span> |
| | | <span v-if="row.unit" class="node-sub">单位: {{ row.unit }}</span> |
| | | </div> |
| | | <div class="node-actions"> |
| | | <el-button v-if="editable" |
| | | type="primary" |
| | | text |
| | | size="small" |
| | | @click="handleAdd"> |
| | | + 添加{{ isRoot ? '原料' : '子级原料' }} |
| | | </el-button> |
| | | <template v-if="editable && (isRoot || row.nodeType === 'semiFinished')"> |
| | | <el-button type="primary" |
| | | text |
| | | size="small" |
| | | @click="handleAdd('semiFinished')"> |
| | | + 添加半成品 |
| | | </el-button> |
| | | <el-button type="primary" |
| | | text |
| | | size="small" |
| | | @click="handleAdd('rawMaterial')"> |
| | | + 添加原料 |
| | | </el-button> |
| | | </template> |
| | | <el-button v-if="editable" |
| | | type="danger" |
| | | text |
| | |
| | | :editable="editable" |
| | | :process-options="processOptions" |
| | | @remove="(id:string) => $emit('remove', id)" |
| | | @add="(id:string) => $emit('add', id)" |
| | | @add="(id:string, nodeType:string) => $emit('add', id, nodeType)" |
| | | @select-product="(tempId: string, data: any) => $emit('selectProduct', tempId, data)" |
| | | @process-change="(row: any, v: any) => $emit('processChange', row, v)" |
| | | @quantity-change="$emit('quantityChange')" |
| | |
| | | |
| | | const emit = defineEmits<{ |
| | | remove: [tempId: string] |
| | | add: [tempId: string] |
| | | add: [tempId: string, nodeType: string] |
| | | selectProduct: [tempId: string, data: any] |
| | | processChange: [row: any, value: any] |
| | | quantityChange: [] |
| | |
| | | emit('selectProduct', props.row.tempId, null) |
| | | } |
| | | |
| | | const handleAdd = () => { |
| | | emit('add', props.row.tempId) |
| | | const handleAdd = (nodeType: string) => { |
| | | emit('add', props.row.tempId, nodeType) |
| | | } |
| | | </script> |
| | | |
| | |
| | | background-color: #f0f9eb; |
| | | } |
| | | |
| | | .semi-finished-card { |
| | | border-left: 4px solid #e6a23c; |
| | | background-color: #fdf6ec; |
| | | } |
| | | |
| | | .node-header { |
| | | display: flex; |
| | | align-items: center; |