diff --git a/src/api/material/type.js b/src/api/material/type.js index a47ce1e..2d1320f 100644 --- a/src/api/material/type.js +++ b/src/api/material/type.js @@ -23,3 +23,14 @@ export const queryIdWhenAddMa = (data) => { params: data }) } + +/** 提交物资添加表单 */ +export const submitAddForm = (data) => { + return request.post('/material/maType/add', data) +} + +/** 删除单个物资 */ +export const delSingleMa = (id) => { + return request.delete(`/material/maType/${id}` ) +} + diff --git a/src/components/TableModel/index.vue b/src/components/TableModel/index.vue index c1c80c7..3f4bbf4 100644 --- a/src/components/TableModel/index.vue +++ b/src/components/TableModel/index.vue @@ -253,8 +253,10 @@ export default { if(res.code === 200) { if(res.data) { this.tableList = res.data.rows + this.total = res.data.total } else { this.tableList = res.rows + this.total = res.total } } }, diff --git a/src/views/material/mixins/common.js b/src/views/material/mixins/common.js index 89c4eda..758d82b 100644 --- a/src/views/material/mixins/common.js +++ b/src/views/material/mixins/common.js @@ -10,7 +10,7 @@ export const commonMixin = { handleAddData(level) { if(level == null) { this.$modal.msgError('请在左侧菜单选择设备类型!') - } else if(level >= 3) { + } else if(level > 3) { this.$modal.msgError('该类型无法添加子类型!') } else { this.editParams = null @@ -25,8 +25,9 @@ export const commonMixin = { method(id).then(res => { console.log(res) if(res.code === 200) { - // this.$message.msgSuccess('操作成功!') + this.$modal.msgSuccess('操作成功!') this.$refs.tableRef.getTableList() + this.getTreeData() } }).catch(err => {}) }) diff --git a/src/views/material/type/components/form-type.vue b/src/views/material/type/components/form-type.vue index 24aac6f..24893d1 100644 --- a/src/views/material/type/components/form-type.vue +++ b/src/views/material/type/components/form-type.vue @@ -27,6 +27,9 @@ + + + + + + + + + + + + + + + null + }, + treeMethod: { + type: Function, + default: () => null } }, created() { @@ -157,6 +183,9 @@ export default { case 2: this.typeParamsLv2.code = res.data.code break; + case 3: + this.typeParamsLv3.code = res.data.code + break; } }).catch(err => {}) } @@ -172,11 +201,18 @@ export default { }, // 物资新增表单 Lv1 typeParamsLv1: { - code: undefined + code: undefined, + name: undefined, }, // 物资新增表单 Lv2 typeParamsLv2: { - code: undefined + code: undefined, + name: undefined, + }, + // 物资新增表单 Lv3 + typeParamsLv3: { + code: undefined, + name: undefined, }, // 物资修改表单 typeEditParams: { @@ -260,15 +296,39 @@ export default { onSubmitAdd(level) { switch(level) { case 0: - console.log(this.typeParamsLv0) + console.log(1) + this.typeParamsLv0.id = this.sendData.id + this.typeParamsLv0.level = this.sendData.level + submitAddForm(this.typeParamsLv0).then(res => { + console.log(res) + }).catch(err => {}) break; case 1: - console.log(this.typeParamsLv1) + this.typeParamsLv1.id = this.sendData.id + this.typeParamsLv1.level = this.sendData.level + submitAddForm(this.typeParamsLv1).then(res => { + console.log(res) + }).catch(err => {}) break; case 2: - console.log(this.typeParamsLv2) + this.typeParamsLv2.id = this.sendData.id + this.typeParamsLv2.level = this.sendData.level + submitAddForm(this.typeParamsLv2).then(res => { + console.log(res) + }).catch(err => {}) + break; + case 3: + this.typeParamsLv3.id = this.sendData.id + this.typeParamsLv3.level = this.sendData.level + submitAddForm(this.typeParamsLv3).then(res => { + console.log(res) + }).catch(err => {}) break; } + // 2. 成功之后通知父组件关闭弹框 + this.$emit('closeDialog', true) + // this.$emit('treeMethod') + this.treeMethod() /* this.$refs.typeEditParamsRef.validate((valid) => { if (valid) { console.log('校验通过', this.typeEditParams) diff --git a/src/views/material/type/index.vue b/src/views/material/type/index.vue index 3b56c6f..6706c2d 100644 --- a/src/views/material/type/index.vue +++ b/src/views/material/type/index.vue @@ -27,8 +27,8 @@ @node-click="handleNodeClick" > - - + + {{ data.label }} @@ -39,10 +39,8 @@ :formLabel="formLabel" :columnsList="columnsList" :request-api="queryMaListApi" - :show-sel="false" ref="tableRef" - style="display: flex; flex-direction: column" > @@ -79,9 +83,10 @@ @@ -94,7 +99,8 @@ import { commonMixin } from '../mixins/common' import FormType from './components/form-type.vue' import { queryMaTypeTreeListApi, - queryMaListApi + queryMaListApi, + delSingleMa } from '@/api/material/type' export default { name: 'typeManage', @@ -115,6 +121,7 @@ export default { // 获取树形数据 getTreeData() { queryMaTypeTreeListApi().then(res => { + this.rootOpt[0].children = [] res.data.forEach(item => { this.rootOpt[0].children.push(item) }) @@ -139,7 +146,7 @@ export default { this.transLevel = data.level this.transData = data this.$refs.tableRef.queryTableList({ - typeId: data.id + code: data.code }) }, }, @@ -186,6 +193,8 @@ export default { }, // 查询右侧数据 queryMaListApi, + // 删除单个物资 + delSingleMa, // 传递给表单的数据, level, 数据 transData: null, transLevel: null,