From fcbba75febaa36d23c6c49473ab5bcee0e1a2c04 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 08 四月 2025 09:37:11 +0800
Subject: [PATCH] 检验项目新增是否委托要求字段
---
src/views/business/reliabilityPlan/index.vue | 474 ++++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 371 insertions(+), 103 deletions(-)
diff --git a/src/views/business/reliabilityPlan/index.vue b/src/views/business/reliabilityPlan/index.vue
index 4e3246f..a0d9c30 100644
--- a/src/views/business/reliabilityPlan/index.vue
+++ b/src/views/business/reliabilityPlan/index.vue
@@ -4,12 +4,12 @@
<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>
@@ -23,7 +23,7 @@
<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>
@@ -32,68 +32,103 @@
</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>
@@ -108,13 +143,14 @@
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 {
@@ -125,7 +161,17 @@
tabIndex: 0,
// 鎴愬搧table鏁版嵁
tableData: [],
+ typeOption: [],
+ partNoOption: [], // 娣诲姞浜у搧鍨嬪彿閫夐」鏁版嵁
+ materialPartNoOption:[],
tableLoading: false,
+ itemParameterData: {
+ cascaderField: {
+ sample: {
+ tree: []
+ },
+ }
+ },
column: [
{ label: '浜у搧鍨嬪彿', prop: 'productType' },
{ label: '浜у搧鍚嶇О', prop: 'productName' },
@@ -135,21 +181,25 @@
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'
}
}
},
@@ -162,14 +212,40 @@
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);
},
},
{
@@ -179,7 +255,7 @@
this.handleDelete(row);
},
disabled: (row) => {
- return row.state == 1
+ return row.state > 0
},
},
]
@@ -191,32 +267,36 @@
current: 1
},
//
- // 鍘熻緟鏂檛able鏁版嵁
+ // 鍘熻緟鏉恡able鏁版嵁
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'
}
}
},
@@ -229,14 +309,40 @@
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);
},
},
{
@@ -246,7 +352,7 @@
this.handleDeleteM(row);
},
disabled: (row) => {
- return row.state == 1
+ return row.state > 0
},
},
]
@@ -283,6 +389,9 @@
},
mounted() {
this.goSearch()
+ this.selectTestObjectByName()
+ this.getTypeOptions()
+ this.getPartNoOptions()
},
// 鏂规硶闆嗗悎
methods: {
@@ -299,6 +408,7 @@
handleTab(m) {
this.tabIndex = m;
this.refreshTable()
+ this.selectTestObjectByName() // 娣诲姞杩欒锛屽垏鎹ab鏃堕噸鏂拌幏鍙栨爲褰㈡暟鎹�
},
pagination(page) {
this.page.size = page.limit
@@ -314,22 +424,22 @@
// 鎴愬搧鏌ヨ
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 => {
@@ -344,28 +454,89 @@
// 鎵撳紑鏂板寮规
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 }
+ // 缂栬緫鏃惰幏鍙栭�変腑鑺傜偣鐨処D骞跺姞杞界浉鍏虫暟鎹�
+ 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 }
+ // 缂栬緫鏃惰幏鍙栭�変腑鑺傜偣鐨処D骞跺姞杞界浉鍏虫暟鎹�
+ 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
+ // 鑾峰彇閫変腑鑺傜偣鐨処D
+ 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('鎿嶄綔鎴愬姛')
@@ -378,19 +549,21 @@
})
},
// 鍏抽棴鎴愬搧淇℃伅寮规
- 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
+ // 鑾峰彇閫変腑鑺傜偣鐨処D
+ 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('鎿嶄綔鎴愬姛')
@@ -402,19 +575,19 @@
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();
}
@@ -423,14 +596,14 @@
});
},
- 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();
}
@@ -439,6 +612,101 @@
});
},
+ 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 => {
--
Gitblit v1.9.3