| | |
| | | <template> |
| | | <el-dialog |
| | | v-model="visible" |
| | | title="Tips" |
| | | width="500" |
| | | :before-close="visible = false" |
| | | title="结构" |
| | | width="1200" |
| | | close-on-click-modal |
| | | @close="visible = false" |
| | | > |
| | | <el-button |
| | | v-if="dataValue.isEdit" |
| | | type="primary" |
| | | @click="addItem" |
| | | style="margin-bottom: 10px" |
| | | >添加 |
| | | </el-button> |
| | | <el-button |
| | | v-if="!dataValue.isEdit" |
| | | type="primary" |
| | | @click="dataValue.isEdit = true" |
| | | style="margin-bottom: 10px" |
| | | >编辑 |
| | | </el-button> |
| | | <el-button |
| | | v-if="dataValue.isEdit" |
| | | type="primary" |
| | | @click="cancelEdit" |
| | | style="margin-bottom: 10px" |
| | | >取消 |
| | | </el-button> |
| | | <el-form |
| | | ref="form" |
| | | :model="dataValue" |
| | | label-width="80px" |
| | | > |
| | | <el-table :data="dataValue.dataList" style="width: 100%"> |
| | | <el-table-column prop="productName" label="产品" width="180" /> |
| | | <el-table-column prop="model" label="规格" width="180"> |
| | | <template #default="{ row, index }"> |
| | | <el-table-column prop="productName" label="产品" width="150"/> |
| | | <el-table-column prop="model" label="规格" width="150"> |
| | | <template #default="{ row, $index }"> |
| | | <el-form-item |
| | | :prop="`dataList.${index}.model`" |
| | | v-if="dataValue.isEdit" |
| | | :prop="`dataList.${$index}.model`" |
| | | :rules="[{ required: true, message: '请选择规格', trigger: ['blur','change'] }]" |
| | | style="margin: 0" |
| | | > |
| | | <el-input |
| | | v-model="dataValue.dataList[index].model" |
| | | <el-select |
| | | v-model="row.model" |
| | | placeholder="请选择产品" |
| | | readonly |
| | | @focus="() => { |
| | | dataValue.currentRowIndex = index |
| | | showModel = true |
| | | }" |
| | | /> |
| | | clearable |
| | | :disabled="!dataValue.isEdit" |
| | | style="width: 100%" |
| | | @visible-change="(v) => { if (v) openDialog($index) }" |
| | | > |
| | | <el-option v-if="row.model" :label="row.model" :value="row.model" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column prop="processName" label="消耗工序" width="180"> |
| | | <template #default="{ row, index }"> |
| | | <el-table-column prop="processId" label="消耗工序" width="150"> |
| | | <template #default="{ row, $index }"> |
| | | <el-form-item |
| | | :prop="`dataList.${index}.processId`" |
| | | :prop="`dataList.${$index}.processId`" |
| | | :rules="[{ required: true, message: '请选择消耗工序', trigger: 'change' }]" |
| | | style="margin: 0" |
| | | > |
| | | <el-select |
| | | v-model="dataValue.dataList[index].processId" |
| | | v-model="row.processId" |
| | | placeholder="请选择" |
| | | filterable |
| | | clearable |
| | | style="width: 100%" |
| | | :disabled="!dataValue.isEdit" |
| | | > |
| | | <el-option |
| | | v-for="item in dataValue.processOptions" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column prop="unitQuantity" label="单位产出所需数量"> |
| | | <template #default="{ row, index }"> |
| | | <el-table-column prop="unitQuantity" label="单位产出所需数量" width="150"> |
| | | <template #default="{ row, $index }"> |
| | | <el-form-item |
| | | :prop="`dataList.${index}.unitQuantity`" |
| | | :prop="`dataList.${$index}.unitQuantity`" |
| | | :rules="[{ required: true, message: '请输入单位产出所需数量', trigger: ['blur','change'] }]" |
| | | style="margin: 0" |
| | | > |
| | | <el-input-number |
| | | v-model="dataValue.dataList[index].unitQuantity" |
| | | v-model="row.unitQuantity" |
| | | :min="0" |
| | | :precision="2" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%" |
| | | :disabled="!dataValue.isEdit" |
| | | /> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column prop="demandedQuantity" label="需求总量"> |
| | | <template #default="{ row, index }"> |
| | | <el-table-column prop="demandedQuantity" label="需求总量" width="150"> |
| | | <template #default="{ row, $index }"> |
| | | <el-form-item |
| | | :prop="`dataList.${index}.demandedQuantity`" |
| | | :prop="`dataList.${$index}.demandedQuantity`" |
| | | :rules="[{ required: true, message: '请输入需求总量', trigger: ['blur','change'] }]" |
| | | style="margin: 0" |
| | | > |
| | | <el-input-number |
| | | v-model="dataValue.dataList[index].demandedQuantity" |
| | | v-model="row.demandedQuantity" |
| | | :min="0" |
| | | :precision="2" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%" |
| | | :disabled="!dataValue.isEdit" |
| | | /> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column prop="unit" label="单位"> |
| | | <template #default="{ row, index }"> |
| | | <el-table-column prop="unit" label="单位" width="150"> |
| | | <template #default="{ row, $index }"> |
| | | <el-form-item |
| | | :prop="`dataList.${index}.unit`" |
| | | :prop="`dataList.${$index}.unit`" |
| | | :rules="[{ required: true, message: '请输入单位', trigger: ['blur','change'] }]" |
| | | style="margin: 0" |
| | | > |
| | | <el-input |
| | | v-model="dataValue.dataList[index].unit" |
| | | v-model="row.unit" |
| | | placeholder="请输入单位" |
| | | clearable |
| | | :disabled="!dataValue.isEdit" |
| | | /> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column prop="address" label="盘数(盘)"> |
| | | <template #default="{ row, index }"> |
| | | <el-table-column prop="diskQuantity" label="盘数(盘)" width="150"> |
| | | <template #default="{ row, $index }"> |
| | | <el-form-item |
| | | :prop="`dataList.${index}.address`" |
| | | :prop="`dataList.${$index}.diskQuantity`" |
| | | :rules="[{ required: true, message: '请输入盘数', trigger: ['blur','change'] }]" |
| | | style="margin: 0" |
| | | > |
| | | <el-input-number |
| | | v-model="dataValue.dataList[index].address" |
| | | v-model="row.diskQuantity" |
| | | :min="0" |
| | | :precision="0" |
| | | :step="1" |
| | | controls-position="right" |
| | | style="width: 100%" |
| | | :disabled="!dataValue.isEdit" |
| | | /> |
| | | </el-form-item> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="操作"> |
| | | <template #default="{ row, index }"> |
| | | <template #default="{ row, $index }"> |
| | | <el-button |
| | | type="danger" |
| | | icon="el-icon-delete" |
| | | circle |
| | | @click="dataValue.dataList.splice(index, 1)" |
| | | text |
| | | @click="dataValue.dataList.splice($index, 1)" |
| | | >删除 |
| | | </el-button> |
| | | </template> |
| | |
| | | |
| | | <product-select-dialog |
| | | v-if="dataValue.showProductDialog" |
| | | :model-value="dataValue.showProductDialog" |
| | | v-model:model-value="dataValue.showProductDialog" |
| | | @confirm="handleProduct"/> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button @click="visible = false">取消</el-button> |
| | | <el-button type="primary" :loading="dataValue.loading" @click="submit"> |
| | | <el-button type="primary" :loading="dataValue.loading" @click="submit" :disabled="!dataValue.isEdit"> |
| | | 确认 |
| | | </el-button> |
| | | </div> |
| | |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import {computed, defineComponent, onMounted, reactive, ref} from "vue"; |
| | | import {computed, defineAsyncComponent, defineComponent, onMounted, reactive, ref} from "vue"; |
| | | import {queryList, add} from '@/api/productionManagement/productStructure.js' |
| | | import {list} from '@/api/productionManagement/productionProcess' |
| | | import {ElMessage} from "element-plus"; |
| | |
| | | name: "StructureEdit", |
| | | }) |
| | | |
| | | const ProductSelectDialog = () => import('@/views/basicData/product/ProductSelectDialog.vue') |
| | | const from = ref() |
| | | const ProductSelectDialog = defineAsyncComponent(() => import('@/views/basicData/product/ProductSelectDialog.vue')) |
| | | const form = ref() |
| | | |
| | | |
| | | |
| | | const props = defineProps({ |
| | |
| | | } |
| | | }) |
| | | |
| | | const emits = defineEmits(['update:visible']) |
| | | const emits = defineEmits(['update:showModel']) |
| | | const visible = computed({ |
| | | get() { |
| | | return props.showModel |
| | | }, |
| | | set(val) { |
| | | emits('update:visible', val) |
| | | emits('update:showModel', val) |
| | | } |
| | | }) |
| | | |
| | |
| | | showProductDialog: false, |
| | | currentRowIndex: null, |
| | | loading: false, |
| | | isEdit: false, |
| | | }); |
| | | |
| | | const openDialog = (index) => { |
| | | dataValue.currentRowIndex = index |
| | | dataValue.showProductDialog = true |
| | | } |
| | | |
| | | const fetchData = async () => { |
| | | const {data} = await queryList(props.productModelId) |
| | |
| | | } |
| | | |
| | | const handleProduct = (row) => { |
| | | if (row?.length > 1) { |
| | | ElMessage.error('只能选择一个产品') |
| | | } |
| | | dataValue.dataList[dataValue.currentRowIndex].productName = row[0].productName |
| | | dataValue.dataList[dataValue.currentRowIndex].model = row[0].model |
| | | dataValue.dataList[dataValue.currentRowIndex].productModelId = row[0].id |
| | | dataValue.showProductDialog = false |
| | | dataValue.dataList[dataValue.currentRowIndex].speculativeTradingName = row.productName + '-' + row.model |
| | | dataValue.dataList[dataValue.currentRowIndex].productModelId = row.id |
| | | } |
| | | |
| | | const submit = () => { |
| | | from.value.validate(valid => { |
| | | form.value.validate(valid => { |
| | | dataValue.loading = true |
| | | if (valid) { |
| | | add({ |
| | | productModelId: props.productModelId, |
| | | dataList: dataValue.dataList |
| | | parentId: props.productModelId, |
| | | productStructureList: dataValue.dataList || [] |
| | | }).then(res => { |
| | | ElMessage.success('保存成功') |
| | | visible.value = false |
| | |
| | | }) |
| | | } |
| | | |
| | | const addItem = () => { |
| | | dataValue.dataList.push({ |
| | | productName: '', |
| | | productId: '', |
| | | model: undefined, |
| | | productModelId: undefined, |
| | | processId: '', |
| | | unitQuantity: 0, |
| | | demandedQuantity: 0, |
| | | unit: '', |
| | | diskQuantity: 0, |
| | | }) |
| | | } |
| | | |
| | | const cancelEdit = () => { |
| | | dataValue.isEdit = false |
| | | dataValue.dataList = dataValue.dataList.filter(item => item.id !== undefined) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchData() |
| | | fetchProcessOptions() |