diff --git a/src/api/ma/base.js b/src/api/ma/base.js index c61a11cd..ec3d9358 100644 --- a/src/api/ma/base.js +++ b/src/api/ma/base.js @@ -228,4 +228,13 @@ export function delConfigDetails(data) { method: 'post', data }) +} + +// 配件1-2级树 +export function getPartTreeApi(data) { + return request({ + url: '/material/ma_part_type/getPartTree', + method: 'get', + params: data + }) } \ No newline at end of file diff --git a/src/views/material/ma/typeConfigKeeper/index.vue b/src/views/material/ma/typeConfigKeeper/index.vue index 495e3c1c..f5ead378 100644 --- a/src/views/material/ma/typeConfigKeeper/index.vue +++ b/src/views/material/ma/typeConfigKeeper/index.vue @@ -256,7 +256,7 @@ export default { data() { return { // 遮罩层 - loading: true, + loading: false, // 选中数组 ids: [], // 非单个禁用 @@ -458,11 +458,11 @@ export default { this.treeOptionsTwo = response.data; if ( this.treeOptionsTwo.length > 0 && - this.treeOptionsTwo[0].children.length > 0 + this.treeOptionsTwo[0].children && this.treeOptionsTwo[0].children.length > 0 ) { const firstNode = this.treeOptionsTwo[0].children[0]; this.queryParams.typeId = firstNode.id; - this.queryParams.level = 1; + this.queryParams.level = firstNode.level this.queryParams.houseId = firstNode.houseId; this.getList(); } @@ -473,11 +473,20 @@ export default { this.loading = true; this.queryParams.displayBindRelationship = "true"; console.log("queryParams1", this.queryParams); - await getListByMaType(this.queryParams).then((response) => { - this.typeList = response.data.rows; - this.total = response.data.total; - this.loading = false; - }); + try { + const res = await getListByMaType(this.queryParams) + this.loading = false + if (!res.data || !res.data.rows) { + this.typeList = [] + this.total = 0 + return + } + this.typeList = res.data.rows + this.total = res.data.total + } catch (error) { + console.log('🚀 ~ getList ~ error:', error) + this.loading = false + } }, // 筛选节点 - 左侧树 filterNode(value, data) { @@ -500,15 +509,9 @@ export default { }, // 节点单击事件 - 左侧树 async handleNodeClickTwo(data, node) { - if (data.level == 0) { - this.queryParams.typeId = data.id; - this.queryParams.level = data.level; - this.queryParams.houseId = data.id; - } else { - this.queryParams.typeId = data.id; - this.queryParams.level = data.level; - this.queryParams.houseId = data.houseId; - } + this.queryParams.typeId = data.id; + this.queryParams.level = data.level; + this.queryParams.houseId = data.houseId; this.handleQuery(); }, diff --git a/src/views/material/ma/typeConfigRepair/index.vue b/src/views/material/ma/typeConfigRepair/index.vue index e54d08a4..35137141 100644 --- a/src/views/material/ma/typeConfigRepair/index.vue +++ b/src/views/material/ma/typeConfigRepair/index.vue @@ -255,7 +255,7 @@ export default { data() { return { // 遮罩层 - loading: true, + loading: false, // 选中数组 ids: [], // 非单个禁用 @@ -408,11 +408,12 @@ export default { this.treeOptionsTwo = response.data; if ( this.treeOptionsTwo.length > 0 && - this.treeOptionsTwo[0].children.length > 0 + this.treeOptionsTwo[0].children && this.treeOptionsTwo[0].children.length > 0 ) { const firstNode = this.treeOptionsTwo[0].children[0]; + // console.log('🚀 ~ getMaTypeList ~ firstNode:', firstNode) this.queryParams.typeId = firstNode.id; - this.queryParams.level = 1; + this.queryParams.level = firstNode.level this.queryParams.houseId = firstNode.houseId; this.getList(); } @@ -422,11 +423,20 @@ export default { async getList() { this.loading = true; this.queryParams.displayBindRelationship = "true"; - await getListByMaType(this.queryParams).then((response) => { - this.typeList = response.data.rows; - this.total = response.data.total; - this.loading = false; - }); + try { + const res = await getListByMaType(this.queryParams) + this.loading = false + if (!res.data || !res.data.rows) { + this.typeList = [] + this.total = 0 + return + } + this.typeList = res.data.rows + this.total = res.data.total + } catch (error) { + console.log('🚀 ~ getList ~ error:', error) + this.loading = false + } }, // 筛选节点 - 左侧树 filterNode(value, data) { @@ -449,15 +459,10 @@ export default { }, // 节点单击事件 - 左侧树 async handleNodeClickTwo(data, node) { - if (data.level == 0) { - this.queryParams.typeId = data.id; - this.queryParams.level = data.level; - this.queryParams.houseId = data.id; - } else { - this.queryParams.typeId = data.id; - this.queryParams.level = data.level; - this.queryParams.houseId = data.houseId; - } + // console.log('🚀 ~ handleNodeClickTwo ~ data:', data) + this.queryParams.typeId = data.id; + this.queryParams.level = data.level; + this.queryParams.houseId = data.houseId; this.handleQuery(); },