| | |
| | | <el-form :model="entity" ref="entity" size="small" :inline="true"> |
| | | <el-form-item label="产品型号" prop="productType" v-if="tabIndex === 0"> |
| | | <el-input v-model="entity.productType" clearable placeholder="请输入" size="small" |
| | | @keyup.enter.native="goSearch($event)"> |
| | | @keyup.enter.native="goSearch($event)"> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="原辅料名称" prop="entrustCode" v-if="tabIndex === 1"> |
| | | <el-form-item label="原辅材名称" prop="entrustCode" v-if="tabIndex === 1"> |
| | | <el-input v-model="entity.entrustCode" clearable placeholder="请输入" size="small" |
| | | @keyup.enter.native="goSearch($event)"> |
| | | @keyup.enter.native="goSearch($event)"> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item> |
| | |
| | | <div> |
| | | <ul class="tab"> |
| | | <li :class="{ active: tabIndex === 0 }" @click="handleTab(0)">成品</li> |
| | | <li :class="{ active: tabIndex === 1 }" @click="handleTab(1)">原辅料</li> |
| | | <li :class="{ active: tabIndex === 1 }" @click="handleTab(1)">原辅材</li> |
| | | </ul> |
| | | </div> |
| | | <div> |
| | |
| | | </div> |
| | | <!--成品--> |
| | | <div class="table"> |
| | | <lims-table :tableData="tableData" :column="column" |
| | | v-if="tabIndex === 0" |
| | | @pagination="pagination" |
| | | ref="tableData" |
| | | :height="'calc(100vh - 290px)'" |
| | | key="tableData" :page="page" |
| | | :tableLoading="tableLoading"></lims-table> |
| | | <lims-table :tableData="tableData" :column="column" v-if="tabIndex === 0" @pagination="pagination" |
| | | ref="tableData" :height="'calc(100vh - 290px)'" key="tableData" :page="page" |
| | | :tableLoading="tableLoading"></lims-table> |
| | | </div> |
| | | <!--原辅料--> |
| | | <!--原辅材--> |
| | | <div class="table"> |
| | | <lims-table :tableData="tableData1" :column="column1" |
| | | v-if="tabIndex === 1" :isSelection="true" |
| | | @pagination="pagination1" |
| | | :height="'calc(100vh - 290px)'" |
| | | key="tableData1" :page="page1" :tableLoading="tableLoading1"></lims-table> |
| | | <lims-table :tableData="tableData1" :column="column1" v-if="tabIndex === 1" :isSelection="true" |
| | | @pagination="pagination1" :height="'calc(100vh - 290px)'" key="tableData1" :page="page1" |
| | | :tableLoading="tableLoading1"></lims-table> |
| | | </div> |
| | | </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' || operationType === 'submit'" @change="handleProductNameChange"> |
| | | </el-cascader> |
| | | </el-form-item> |
| | | <el-form-item label="零件号" prop="partNo"> |
| | | <el-input v-model="proPlanForm.partNo" placeholder="请填写零件号" :disabled="operationType === 'review'"></el-input> |
| | | </el-form-item> |
| | | <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-form-item label="产品型号" prop="productType"> |
| | | <el-select v-model="proPlanForm.productType" clearable filterable placeholder="请选择产品型号" |
| | | :disabled="operationType === 'review' || !proPlanForm.productName || operationType === 'submit'" |
| | | 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-select v-model="proPlanForm.partNo" placeholder="请选择" clearable filterable |
| | | :disabled="operationType === 'review' || !proPlanForm.productName || operationType === 'submit'" |
| | | 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-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> |
| | | <div slot="footer" class="foot"> |
| | | <el-button v-if="operationType !== 'review'" @click="closeProDia">取 消</el-button> |
| | | <el-button v-if="operationType !== 'review'" type="primary" :loading="submitProLoading" @click="submitProForm">保 存</el-button> |
| | | <el-button v-if="operationType === 'review'" :loading="submitProLoading" @click="submitProForm(0)">不通过</el-button> |
| | | <el-button v-if="operationType === 'review'" type="primary" :loading="submitProLoading" @click="submitProForm(1)">通过</el-button> |
| | | <el-button v-if="operationType !== 'review' && operationType !== 'submit'" type="primary" |
| | | :loading="submitProLoading" @click="submitProForm(0)">保 |
| | | 存</el-button> |
| | | <el-button v-if="operationType == 'submit'" type="primary" :loading="submitProLoading" |
| | | @click="submitProForm(1)">提 交</el-button> |
| | | <el-button v-if="operationType === 'review'" :loading="submitProLoading" |
| | | @click="submitProForm(3)">不通过</el-button> |
| | | <el-button v-if="operationType === 'review'" type="primary" :loading="submitProLoading" |
| | | @click="submitProForm(2)">通过</el-button> |
| | | <el-button v-if="operationType === 'review'" type="primary" :loading="submitMatLoading" |
| | | @click="submitProForm(0)">变 更</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <el-dialog :visible.sync="materialDia" title="原辅料计划"> |
| | | <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-form-item label="原辅材名称" prop="materialName"> |
| | | <el-cascader v-model="materialForm.materialName" :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' || operationType === 'submit'" @change="handleMaterialNameChange"> |
| | | </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-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-select v-model="materialForm.partNo" placeholder="请选择" clearable filterable |
| | | :disabled="operationType === 'review' || !materialForm.materialName || operationType === 'submit'" |
| | | style="width: 100%;"> |
| | | <el-option v-for="item in materialPartNoOption" :key="item.id" :label="item.partNo" :value="item.partNo"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- <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> |
| | | <div slot="footer" class="foot"> |
| | | <el-button v-if="operationType !== 'review'" @click="closeMaterialRulesDia">取 消</el-button> |
| | | <el-button v-if="operationType !== 'review'" type="primary" :loading="submitMatLoading" @click="submitMaterialRulesForm">保 存</el-button> |
| | | <el-button v-if="operationType === 'review'" :loading="submitMatLoading" @click="submitMaterialRulesForm(0)">不通过</el-button> |
| | | <el-button v-if="operationType === 'review'" type="primary" :loading="submitMatLoading" @click="submitMaterialRulesForm(1)">通过</el-button> |
| | | <el-button v-if="operationType !== 'review'" @click="closeMaterialRulesDia">取 |
| | | 消</el-button> |
| | | <el-button v-if="operationType !== 'review' && operationType !== 'submit'" type="primary" |
| | | :loading="submitMatLoading" @click="submitMaterialRulesForm(0)">保 存</el-button> |
| | | <el-button v-if="operationType == 'submit'" type="primary" :loading="submitProLoading" |
| | | @click="submitMaterialRulesForm(1)">提 交</el-button> |
| | | <el-button v-if="operationType === 'review'" :loading="submitMatLoading" |
| | | @click="submitMaterialRulesForm(3)">不通过</el-button> |
| | | <el-button v-if="operationType === 'review'" type="primary" :loading="submitMatLoading" |
| | | @click="submitMaterialRulesForm(2)">通 过</el-button> |
| | | <el-button v-if="operationType === 'review'" type="primary" :loading="submitMatLoading" |
| | | @click="submitMaterialRulesForm(0)">变 更</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | |
| | | selectMaterial, |
| | | selectProduct |
| | | } from "@/api/business/reliabilityPlan"; |
| | | import {selectUserCondition} from "@/api/system/user"; |
| | | import {deleteAuxiliaryWorkingHours} from "@/api/performance/manHour"; |
| | | import { selectUserCondition } from "@/api/system/user"; |
| | | import { deleteAuxiliaryWorkingHours } from "@/api/performance/manHour"; |
| | | import { getItemTreeProduct, getProductTypes, getPartNoList } from "@/api/structural/capability"; |
| | | |
| | | export default { |
| | | name: '', |
| | | // import 引入的组件需要注入到对象中才能使用 |
| | | components: {limsTable}, |
| | | components: { limsTable }, |
| | | data() { |
| | | // 这里存放数据 |
| | | return { |
| | |
| | | tabIndex: 0, |
| | | // 成品table数据 |
| | | tableData: [], |
| | | typeOption: [], |
| | | partNoOption: [], // 添加产品型号选项数据 |
| | | materialPartNoOption:[], |
| | | tableLoading: false, |
| | | itemParameterData: { |
| | | cascaderField: { |
| | | sample: { |
| | | tree: [] |
| | | }, |
| | | } |
| | | }, |
| | | column: [ |
| | | { label: '产品型号', prop: 'productType' }, |
| | | { label: '产品名称', prop: 'productName' }, |
| | |
| | | label: '审核状态', |
| | | prop: 'state', |
| | | formatData: (params) => { |
| | | if (params == 1) { |
| | | if (params == 0 || !params) { |
| | | return '待提交' |
| | | } else if (params == 1) { |
| | | return '待审核' |
| | | } else if (params == 2) { |
| | | return '通过' |
| | | } else if (params == 0) { |
| | | } else if (params == 3) { |
| | | return '不通过' |
| | | } else { |
| | | return null |
| | | } |
| | | }, |
| | | formatType: (params) => { |
| | | if (params == 1) { |
| | | return 'success' |
| | | } else if (params == 0) { |
| | | if (params == 0 || !params) { |
| | | return 'warning' |
| | | } else if (params == 1) { |
| | | return 'danger' |
| | | } else { |
| | | return null |
| | | } else if (params == 2) { |
| | | return 'success' |
| | | } else if (params == 3) { |
| | | return 'danger' |
| | | } |
| | | } |
| | | }, |
| | |
| | | name: '编辑', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.openAddDia('edit',row); |
| | | } |
| | | this.openAddDia('edit', row); |
| | | }, |
| | | disabled: (row) => { |
| | | return row.state > 0 |
| | | }, |
| | | }, |
| | | { |
| | | name: '计划', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.$router.push({ |
| | | path: "/reliabilityPlan/plan", query: { |
| | | id: row.id, |
| | | type: '成品', |
| | | state: row.state |
| | | } |
| | | }); |
| | | }, |
| | | }, |
| | | { |
| | | name: '提交', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.openAddDia('submit', row); |
| | | }, |
| | | disabled: (row) => { |
| | | return row.state > 0 |
| | | }, |
| | | }, |
| | | { |
| | | name: '审核', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.openAddDia('review',row); |
| | | this.openAddDia('review', row); |
| | | }, |
| | | }, |
| | | { |
| | |
| | | this.handleDelete(row); |
| | | }, |
| | | disabled: (row) => { |
| | | return row.state == 1 |
| | | return row.state > 0 |
| | | }, |
| | | }, |
| | | ] |
| | |
| | | current: 1 |
| | | }, |
| | | // |
| | | // 原辅料table数据 |
| | | // 原辅材table数据 |
| | | tableData1: [], |
| | | tableLoading1: false, |
| | | column1: [ |
| | | { label: '原辅料名称', prop: 'materialName' }, |
| | | { label: '原辅材名称', prop: 'materialName' }, |
| | | { label: '零件号', prop: 'partNo' }, |
| | | { |
| | | dataType: 'tag', |
| | | label: '审核状态', |
| | | prop: 'state', |
| | | formatData: (params) => { |
| | | if (params == 1) { |
| | | if (params == 0 || !params) { |
| | | return '待提交' |
| | | } else if (params == 1) { |
| | | return '待审核' |
| | | } else if (params == 2) { |
| | | return '通过' |
| | | } else if (params == 0) { |
| | | } else if (params == 3) { |
| | | return '不通过' |
| | | } else { |
| | | return null |
| | | } |
| | | }, |
| | | formatType: (params) => { |
| | | if (params == 1) { |
| | | return 'success' |
| | | } else if (params == 0) { |
| | | if (params == 0 || !params) { |
| | | return 'warning' |
| | | } else if (params == 1) { |
| | | return 'danger' |
| | | } else { |
| | | return null |
| | | } else if (params == 2) { |
| | | return 'success' |
| | | } else if (params == 3) { |
| | | return 'danger' |
| | | } |
| | | } |
| | | }, |
| | |
| | | name: '编辑', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.openAddDia('edit',row); |
| | | } |
| | | this.openAddDia('edit', row); |
| | | }, |
| | | disabled: (row) => { |
| | | return row.state > 0 |
| | | }, |
| | | }, |
| | | { |
| | | name: '计划', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.$router.push({ |
| | | path: "/reliabilityPlan/plan", query: { |
| | | id: row.id, |
| | | type: '原辅材', |
| | | state: row.state |
| | | } |
| | | }); |
| | | }, |
| | | }, |
| | | { |
| | | name: '提交', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.openAddDia('submit', row); |
| | | }, |
| | | disabled: (row) => { |
| | | return row.state > 0 |
| | | }, |
| | | }, |
| | | { |
| | | name: '审核', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.openAddDia('review',row); |
| | | this.openAddDia('review', row); |
| | | }, |
| | | }, |
| | | { |
| | |
| | | this.handleDeleteM(row); |
| | | }, |
| | | disabled: (row) => { |
| | | return row.state == 1 |
| | | return row.state > 0 |
| | | }, |
| | | }, |
| | | ] |
| | |
| | | }, |
| | | 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 |
| | |
| | | // 成品查询 |
| | | this.getProductOrderList() |
| | | } else if (this.tabIndex === 1) { |
| | | // 原辅料查询 |
| | | // 原辅材查询 |
| | | this.getMaterialOrderList() |
| | | } |
| | | }, |
| | | getProductOrderList () { |
| | | getProductOrderList() { |
| | | this.tableLoading = true |
| | | selectProduct({...this.entity, ...this.page}).then(response => { |
| | | selectProduct({ ...this.entity, ...this.page }).then(response => { |
| | | this.tableLoading = false |
| | | this.tableData = response.data.records |
| | | }).catch(error => { |
| | | this.tableLoading = false |
| | | }) |
| | | }, |
| | | getMaterialOrderList () { |
| | | getMaterialOrderList() { |
| | | this.tableLoading1 = true |
| | | selectMaterial({...this.entity, ...this.page}).then(response => { |
| | | selectMaterial({ ...this.entity, ...this.page }).then(response => { |
| | | this.tableLoading1 = false |
| | | this.tableData1 = response.data.records |
| | | }).catch(err => { |
| | |
| | | // 打开新增弹框 |
| | | openAddDia(type, row) { |
| | | this.operationType = type |
| | | // this.getUserList() |
| | | if (this.tabIndex === 0) { |
| | | this.proPlanDia = true |
| | | if (this.operationType !== 'add') { |
| | | this.proPlanForm = {...row} |
| | | if (this.operationType === 'add') { |
| | | this.proPlanForm = { |
| | | id: '', |
| | | productName: '', |
| | | productType: '', |
| | | partNo: '', |
| | | reviewerId: '' |
| | | } |
| | | } else { |
| | | this.proPlanForm = { ...row } |
| | | // 编辑时获取选中节点的ID并加载相关数据 |
| | | const selectedNode = this.findNodeById(this.itemParameterData.cascaderField.sample.tree, row.productName) |
| | | if (selectedNode) { |
| | | this.getTypeOptions(selectedNode.id) |
| | | this.getPartNoOptions(selectedNode.id) |
| | | } |
| | | } |
| | | } else { |
| | | this.materialDia = true |
| | | if (this.operationType !== 'add') { |
| | | this.materialForm = {...row} |
| | | } |
| | | if (this.operationType === 'add') { |
| | | this.materialForm = { |
| | | id: '', |
| | | materialName: '', |
| | | partNo: '', |
| | | state: '', |
| | | reviewerId: '' |
| | | } |
| | | } else { |
| | | this.materialForm = { ...row } |
| | | // 编辑时获取选中节点的ID并加载相关数据 |
| | | const selectedNode = this.findNodeById(this.itemParameterData.cascaderField.sample.tree, row.materialName) |
| | | if (selectedNode) { |
| | | this.getMaterialPartNoOptions(selectedNode.id) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | |
| | | //原辅材零件号选择 |
| | | handleMaterialNameChange(value) { |
| | | if (value) { |
| | | const selectedNode = this.findNodeById(this.itemParameterData.cascaderField.sample.tree, value) |
| | | if (selectedNode) { |
| | | this.getMaterialPartNoOptions(selectedNode.id) |
| | | } |
| | | } else { |
| | | this.materialPartNoOption = [] |
| | | this.materialForm.partNo = '' |
| | | } |
| | | }, |
| | | |
| | | // 获取原辅材零件号列表 |
| | | getMaterialPartNoOptions(materialId) { |
| | | if (!materialId) { |
| | | this.materialPartNoOption = [] |
| | | return |
| | | } |
| | | getPartNoList({ productId: materialId }).then(res => { |
| | | if (res.code === 200) { |
| | | this.materialPartNoOption = res.data || [] |
| | | if (this.materialPartNoOption.length === 0) { |
| | | this.materialForm.partNo = '' |
| | | } |
| | | } |
| | | }).catch(() => { |
| | | this.materialPartNoOption = [] |
| | | this.materialForm.partNo = '' |
| | | }) |
| | | }, |
| | | // 成品信息提交 |
| | | submitProForm (state) { |
| | | submitProForm(state) { |
| | | this.submitProLoading = true |
| | | if (this.operationType === 'add') { |
| | | this.proPlanForm.state = '' |
| | | } else { |
| | | this.proPlanForm.state = state |
| | | // 获取选中节点的ID |
| | | const selectedNode = this.findNodeById(this.itemParameterData.cascaderField.sample.tree, this.proPlanForm.productName) |
| | | const params = { |
| | | ...this.proPlanForm, |
| | | state: state === undefined ? null : parseInt(state), |
| | | productId: selectedNode?.id |
| | | } |
| | | addOrUpdateProduct(this.proPlanForm).then(res => { |
| | | |
| | | addOrUpdateProduct(params).then(res => { |
| | | if (res.code === 200) { |
| | | this.closeProDia() |
| | | this.$message.success('操作成功') |
| | |
| | | }) |
| | | }, |
| | | // 关闭成品信息弹框 |
| | | closeProDia () { |
| | | closeProDia() { |
| | | this.resetForm('proPlanDia') |
| | | this.proPlanDia = false |
| | | }, |
| | | // 原辅料信息提交 |
| | | submitMaterialRulesForm (state) { |
| | | // 原辅材信息提交 |
| | | submitMaterialRulesForm(state) { |
| | | this.submitMatLoading = true |
| | | if (this.operationType === 'add') { |
| | | this.materialForm.state = '' |
| | | } else { |
| | | this.materialForm.state = state |
| | | // 获取选中节点的ID |
| | | const selectedNode = this.findNodeById(this.itemParameterData.cascaderField.sample.tree, this.materialForm.materialName) |
| | | const params = { |
| | | ...this.materialForm, |
| | | state: state === undefined ? null : parseInt(state), |
| | | materialId: selectedNode?.id |
| | | } |
| | | addOrUpdateMaterial(this.materialForm).then(res => { |
| | | addOrUpdateMaterial(params).then(res => { |
| | | if (res.code === 200) { |
| | | this.closeMaterialRulesDia() |
| | | this.$message.success('操作成功') |
| | |
| | | this.submitMatLoading = false |
| | | }) |
| | | }, |
| | | // 关闭原辅料信息弹框 |
| | | // 关闭原辅材信息弹框 |
| | | closeMaterialRulesDia() { |
| | | this.resetForm('materialForm') |
| | | this.materialDia = false |
| | | }, |
| | | handleDelete (row) { |
| | | handleDelete(row) { |
| | | this.$confirm("是否删除该条数据?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(() => { |
| | | delProduct({ id: row.id }).then((res) => { |
| | | if (res.code == 200){ |
| | | if (res.code == 200) { |
| | | this.$message.success("删除成功"); |
| | | this.goSearch(); |
| | | } |
| | |
| | | |
| | | }); |
| | | }, |
| | | handleDeleteM (row) { |
| | | handleDeleteM(row) { |
| | | this.$confirm("是否删除该条数据?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(() => { |
| | | delMaterial({ id: row.id }).then((res) => { |
| | | if (res.code == 200){ |
| | | if (res.code == 200) { |
| | | this.$message.success("删除成功"); |
| | | this.goSearch(); |
| | | } |
| | |
| | | |
| | | }); |
| | | }, |
| | | 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 => { |