From fcc2feb57154cdb9fcedf10c526a1fe57e4bc2cc Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 01 四月 2025 16:29:59 +0800
Subject: [PATCH] 可靠性计划产品选择
---
src/views/business/reliabilityPlan/index.vue | 169 ++++++++++++++++++++++++++++++++++++++---
src/api/structural/capability.js | 27 ++++++
2 files changed, 181 insertions(+), 15 deletions(-)
diff --git a/src/api/structural/capability.js b/src/api/structural/capability.js
index b65e14c..d6bb3ec 100644
--- a/src/api/structural/capability.js
+++ b/src/api/structural/capability.js
@@ -47,6 +47,33 @@
method: "get",
});
}
+
+// 鑾峰彇妫�楠屽璞℃爲
+export function getItemTreeProduct(query) {
+ return request({
+ url: "/capacityScope/getItemTreeProduct",
+ method: "get",
+ params: query,
+ });
+}
+
+//鏍规嵁浜у搧鑾峰彇鍨嬪彿
+export function getProductTypes(query) {
+ return request({
+ url: "/capacityScope/getProductTypes",
+ method: "get",
+ params: query,
+ });
+}
+
+//鏍规嵁浜у搧鑾峰彇闆朵欢鍙�
+export function getPartNoList(query) {
+ return request({
+ url: "/capacityScope/getPartNoList",
+ method: "get",
+ params: query,
+ });
+}
// 鏂板妫�娴嬪璞�
export function addTestObject(query) {
return request({
diff --git a/src/views/business/reliabilityPlan/index.vue b/src/views/business/reliabilityPlan/index.vue
index a9c2486..393f7ff 100644
--- a/src/views/business/reliabilityPlan/index.vue
+++ b/src/views/business/reliabilityPlan/index.vue
@@ -45,24 +45,34 @@
</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>
@@ -77,20 +87,22 @@
<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>
@@ -116,6 +128,7 @@
} 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: '',
@@ -131,7 +144,16 @@
tabIndex: 0,
// 鎴愬搧table鏁版嵁
tableData: [],
+ typeOption: [],
+ partNoOption: [], // 娣诲姞浜у搧鍨嬪彿閫夐」鏁版嵁
tableLoading: false,
+ itemParameterData: {
+ cascaderField: {
+ sample: {
+ tree: []
+ },
+ }
+ },
column: [
{ label: '浜у搧鍨嬪彿', prop: 'productType' },
{ label: '浜у搧鍚嶇О', prop: 'productName' },
@@ -289,6 +311,9 @@
},
mounted() {
this.goSearch()
+ this.selectTestObjectByName()
+ this.getTypeOptions()
+ this.getPartNoOptions()
},
// 鏂规硶闆嗗悎
methods: {
@@ -305,6 +330,7 @@
handleTab(m) {
this.tabIndex = m;
this.refreshTable()
+ this.selectTestObjectByName() // 娣诲姞杩欒锛屽垏鎹ab鏃堕噸鏂拌幏鍙栨爲褰㈡暟鎹�
},
pagination(page) {
this.page.size = page.limit
@@ -350,15 +376,33 @@
// 鎵撳紑鏂板寮规
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 }
}
}
@@ -445,6 +489,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