| | |
| | | </div> |
| | | <el-dialog :visible.sync="proPlanDia" title="成品计划"> |
| | | <el-form :model="proPlanForm" ref="proPlanForm" :rules="proPlanRules" label-width="80px" size="small"> |
| | | <el-form-item label="产品型号" prop="productType"> |
| | | <el-input v-model="proPlanForm.productType" placeholder="请填写产品型号" |
| | | :disabled="operationType === 'review'"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="产品名称" prop="productName"> |
| | | <el-input v-model="proPlanForm.productName" placeholder="请填写产品名称" |
| | | :disabled="operationType === 'review'"></el-input> |
| | | <el-cascader v-model="proPlanForm.productName" :options="itemParameterData.cascaderField.sample.tree" |
| | | :props="{ value: 'name', label: 'name', checkStrictly: false, multiple: false, emitPath: false }" |
| | | :show-all-levels="false" clearable filterable placeholder="请选择产品名称" size="small" style="width: 100%;" |
| | | :disabled="operationType === 'review'" @change="handleProductNameChange"> |
| | | </el-cascader> |
| | | </el-form-item> |
| | | <el-form-item label="产品型号" prop="productType"> |
| | | <el-select v-model="proPlanForm.productType" clearable filterable placeholder="请选择产品型号" |
| | | :disabled="operationType === 'review' || !proPlanForm.productName" style="width: 100%;"> |
| | | <el-option v-for="item in typeOption" :key="item.id" :label="item.modelName" :value="item.modelName"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="零件号" prop="partNo"> |
| | | <el-input v-model="proPlanForm.partNo" placeholder="请填写零件号" :disabled="operationType === 'review'"></el-input> |
| | | <el-select v-model="proPlanForm.partNo" placeholder="请选择" clearable filterable |
| | | :disabled="operationType === 'review' || !proPlanForm.productName" style="width: 100%;"> |
| | | <el-option v-for="item in partNoOption" :key="item.id" :label="item.partNo" :value="item.partNo"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="审核人" prop="reviewerId"> |
| | | <!-- <el-form-item label="审核人" prop="reviewerId"> |
| | | <el-select v-model="proPlanForm.reviewerId" clearable filterable size="small" style="width: 50%;" |
| | | :disabled="operationType === 'review'"> |
| | | <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | </el-form> |
| | | <div slot="footer" class="foot"> |
| | | <el-button v-if="operationType !== 'review'" @click="closeProDia">取 消</el-button> |
| | |
| | | <el-dialog :visible.sync="materialDia" title="原辅材计划"> |
| | | <el-form :model="materialForm" ref="materialForm" :rules="materialRules" label-width="90px" size="small"> |
| | | <el-form-item label="原辅材名称" prop="materialName"> |
| | | <el-input v-model="materialForm.materialName" placeholder="请填写产品名称" |
| | | :disabled="operationType === 'review'"></el-input> |
| | | <el-cascader v-model="materialForm.materialName" :options="itemParameterData.cascaderField.sample.tree" |
| | | :props="{ value: 'name', label: 'name', checkStrictly: false, multiple: false }" :show-all-levels="false" |
| | | clearable filterable placeholder="请选择原辅材名称" size="small" style="width: 100%;" |
| | | :disabled="operationType === 'review'"></el-cascader> |
| | | </el-form-item> |
| | | <el-form-item label="零件号" prop="partNo"> |
| | | <el-input v-model="materialForm.partNo" placeholder="请填写零件号" |
| | | :disabled="operationType === 'review'"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="审核人" prop="reviewerId"> |
| | | <!-- <el-form-item label="审核人" prop="reviewerId"> |
| | | <el-select v-model="proPlanForm.reviewerId" clearable filterable size="small" style="width: 50%;" |
| | | :disabled="operationType === 'review'"> |
| | | <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | </el-form> |
| | | <div slot="footer" class="foot"> |
| | | <el-button v-if="operationType !== 'review'" @click="closeMaterialRulesDia">取 消</el-button> |
| | |
| | | } from "@/api/business/reliabilityPlan"; |
| | | import { selectUserCondition } from "@/api/system/user"; |
| | | import { deleteAuxiliaryWorkingHours } from "@/api/performance/manHour"; |
| | | import { getItemTreeProduct, getProductTypes, getPartNoList } from "@/api/structural/capability"; |
| | | |
| | | export default { |
| | | name: '', |
| | |
| | | tabIndex: 0, |
| | | // 成品table数据 |
| | | tableData: [], |
| | | typeOption: [], |
| | | partNoOption: [], // 添加产品型号选项数据 |
| | | tableLoading: false, |
| | | itemParameterData: { |
| | | cascaderField: { |
| | | sample: { |
| | | tree: [] |
| | | }, |
| | | } |
| | | }, |
| | | column: [ |
| | | { label: '产品型号', prop: 'productType' }, |
| | | { label: '产品名称', prop: 'productName' }, |
| | |
| | | }, |
| | | mounted() { |
| | | this.goSearch() |
| | | this.selectTestObjectByName() |
| | | this.getTypeOptions() |
| | | this.getPartNoOptions() |
| | | }, |
| | | // 方法集合 |
| | | methods: { |
| | |
| | | handleTab(m) { |
| | | this.tabIndex = m; |
| | | this.refreshTable() |
| | | this.selectTestObjectByName() // 添加这行,切换tab时重新获取树形数据 |
| | | }, |
| | | pagination(page) { |
| | | this.page.size = page.limit |
| | |
| | | // 打开新增弹框 |
| | | openAddDia(type, row) { |
| | | this.operationType = type |
| | | this.getTypeOptions() |
| | | this.getPartNoOptions() |
| | | // this.getUserList() |
| | | if (this.tabIndex === 0) { |
| | | this.proPlanDia = true |
| | | if (this.operationType !== 'add') { |
| | | if (this.operationType === 'add') { |
| | | this.proPlanForm = { |
| | | id: '', |
| | | productName: '', |
| | | productType: '', |
| | | partNo: '', |
| | | reviewerId: '' |
| | | } |
| | | } else { |
| | | this.proPlanForm = { ...row } |
| | | } |
| | | } else { |
| | | this.materialDia = true |
| | | if (this.operationType !== 'add') { |
| | | if (this.operationType === 'add') { |
| | | this.materialForm = { |
| | | id: '', |
| | | materialName: '', |
| | | partNo: '', |
| | | state: '', |
| | | reviewerId: '' |
| | | } |
| | | } else { |
| | | this.materialForm = { ...row } |
| | | } |
| | | } |
| | |
| | | |
| | | }); |
| | | }, |
| | | selectTestObjectByName() { |
| | | getItemTreeProduct({ objectType: this.tabIndex === 0 ? '成品' : '原辅材' }).then(res => { |
| | | if (res.data && res.data.length > 0) { |
| | | res.data.forEach(a => { |
| | | this.cascaderFieldData(a) |
| | | }) |
| | | this.itemParameterData.cascaderField.sample.tree = res.data |
| | | } |
| | | }).catch(err => { |
| | | console.error('获取数据失败:', err) |
| | | }) |
| | | }, |
| | | cascaderFieldData(val) { |
| | | if (val.children === undefined) { |
| | | return |
| | | } else if (val.children.length == 0) { |
| | | val.label = val.name |
| | | val.value = val.id |
| | | delete val.children |
| | | } else { |
| | | val.label = val.name |
| | | val.value = val.id |
| | | val.children.forEach(a => { |
| | | a.label = a.name |
| | | a.value = a.id |
| | | this.cascaderFieldData(a) |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | handleProductNameChange(value) { |
| | | if (value) { |
| | | const selectedNode = this.findNodeById(this.itemParameterData.cascaderField.sample.tree, value) |
| | | if (selectedNode) { |
| | | this.getTypeOptions(selectedNode.id) |
| | | this.getPartNoOptions(selectedNode.id) |
| | | } |
| | | } else { |
| | | this.typeOption = [] |
| | | this.partNoOption = [] |
| | | this.proPlanForm.productType = '' |
| | | this.proPlanForm.partNo = '' |
| | | } |
| | | }, |
| | | |
| | | findNodeById(tree, name) { |
| | | for (let node of tree) { |
| | | if (node.name === name) { |
| | | return node |
| | | } |
| | | if (node.children) { |
| | | const found = this.findNodeById(node.children, name) |
| | | if (found) return found |
| | | } |
| | | } |
| | | return null |
| | | }, |
| | | // 获取产品型号选项 |
| | | getTypeOptions(productId) { |
| | | if (!productId) { |
| | | this.typeOption = [] |
| | | return |
| | | } |
| | | getProductTypes({ productId }).then(res => { |
| | | if (res.code === 200) { |
| | | this.typeOption = res.data || [] // 确保数据为空时设置为空数组 |
| | | if (this.typeOption.length === 0) { |
| | | this.proPlanForm.productType = '' // 清空已选择的产品型号 |
| | | } |
| | | } |
| | | }).catch(() => { |
| | | this.typeOption = [] |
| | | this.proPlanForm.productType = '' |
| | | }) |
| | | }, |
| | | |
| | | // 获取零件号列表的方法 |
| | | getPartNoOptions(productId) { |
| | | if (!productId) { |
| | | this.partNoOption = [] |
| | | return |
| | | } |
| | | getPartNoList({ productId }).then(res => { |
| | | console.log('零件号数据:', res.data) |
| | | if (res.code === 200) { |
| | | this.partNoOption = res.data || [] |
| | | if (this.partNoOption.length === 0) { |
| | | this.proPlanForm.partNo = '' |
| | | } |
| | | } |
| | | }).catch(() => { |
| | | this.partNoOption = [] |
| | | this.proPlanForm.partNo = '' |
| | | }) |
| | | }, |
| | | // 获取负责人信息接口 |
| | | getUserList() { |
| | | selectUserCondition().then(res => { |