导入模型修复

dev_2022-03-03
yujialong 3 years ago
parent 50e789bfd2
commit a2a546099b
  1. 1
      src/components/Sidebar.vue
  2. 23
      src/utils/api.js
  3. 82
      src/views/serve/backstage/model.vue

@ -119,7 +119,6 @@ export default {
initMenu() { initMenu() {
if (Setting.dynamicRoute) { if (Setting.dynamicRoute) {
const routes = this.$store.state.routes const routes = this.$store.state.routes
console.log("🚀 ~ file: Sidebar.vue ~ line 122 ~ initMenu ~ routes", routes)
const menus = [] const menus = []
this.menuList.map(e => { this.menuList.map(e => {
routes.find(n => n.path === e.index) && menus.push(e) routes.find(n => n.path === e.index) && menus.push(e)

@ -1,7 +1,6 @@
import Setting from "@/setting"; import Setting from "@/setting";
const uploadURL = Setting.uploadURL const uploadURL = Setting.uploadURL
const host1 = 'http://39.108.250.202:9000/'
export default { export default {
@ -218,17 +217,17 @@ export default {
getKeywordByCategoryId: `data/keyword/getKeywordByCategoryId`, getKeywordByCategoryId: `data/keyword/getKeywordByCategoryId`,
// 后台账号 // 后台账号
deleteArch: `${host1}nakadai/staffAccountArchitecture/delete`, deleteArch: `nakadai/staffAccountArchitecture/delete`,
saveArch: `${host1}nakadai/staffAccountArchitecture/save`, saveArch: `nakadai/staffAccountArchitecture/save`,
treeListArch: `${host1}nakadai/staffAccountArchitecture/treeList`, treeListArch: `nakadai/staffAccountArchitecture/treeList`,
updateArch: `${host1}nakadai/staffAccountArchitecture/update`, updateArch: `nakadai/staffAccountArchitecture/update`,
delStaff: `${host1}nakadai/backstageStaff/delStaff`, delStaff: `nakadai/backstageStaff/delStaff`,
modifyStaff: `${host1}nakadai/backstageStaff/modifyStaff`, modifyStaff: `nakadai/backstageStaff/modifyStaff`,
saveStaff: `${host1}nakadai/backstageStaff/saveStaff`, saveStaff: `nakadai/backstageStaff/saveStaff`,
staffDetail: `${host1}nakadai/backstageStaff/staffDetail`, staffDetail: `nakadai/backstageStaff/staffDetail`,
staffList: `${host1}nakadai/backstageStaff/staffList`, staffList: `nakadai/backstageStaff/staffList`,
importStaff: `${host1}nakadai/backstageStaff/importStaff`, importStaff: `nakadai/backstageStaff/importStaff`,
exportFailure: `${host1}nakadai/backstageStaff/exportFailure`, exportFailure: `nakadai/backstageStaff/exportFailure`,
// 角色管理 // 角色管理
batchRemove: `users/role/batchRemove`, //批量删除角色 batchRemove: `users/role/batchRemove`, //批量删除角色

@ -43,7 +43,8 @@
<el-dialog title="请选择需要导入的模型" :visible.sync="modelVisible" width="500px" class="dialog" :close-on-click-modal="false"> <el-dialog title="请选择需要导入的模型" :visible.sync="modelVisible" width="500px" class="dialog" :close-on-click-modal="false">
<div class="model-wrap"> <div class="model-wrap">
<el-tree <el-tree
v-if="modelData.length"
:data="modelData" v-loading="modelLoading" :data="modelData" v-loading="modelLoading"
ref="model" ref="model"
default-expand-all default-expand-all
@ -51,6 +52,7 @@
node-key="id" node-key="id"
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"> :props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}">
</el-tree> </el-tree>
<div class="none" v-else>暂无可导入的模型</div>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="modelVisible = false"> </el-button> <el-button @click="modelVisible = false"> </el-button>
@ -137,10 +139,10 @@ export default {
// //
this.$post(this.api.sourceModelClassification).then(res => { this.$post(this.api.sourceModelClassification).then(res => {
const { data } = res let { data } = res
const promises = [] const promises = []
const addType = list => { const addType = list => {
list.map(e => { list.map((e, i) => {
// promise // promise
promises.push(new Promise((resolve,reject) => { promises.push(new Promise((resolve,reject) => {
// //
@ -158,7 +160,12 @@ export default {
modelChildren.push(n) modelChildren.push(n)
} }
}) })
e.children = [...e.children, ...modelChildren] // disabled
if (modelChildren.length) {
e.children = [...e.children, ...modelChildren]
} else {
e.disabled = true
}
resolve() resolve()
}).catch(res => { }).catch(res => {
reject() reject()
@ -168,13 +175,27 @@ export default {
}) })
} }
addType(data) addType(data)
// disabledtrue
const handleType = list => {
return list.filter((e, i) => {
return !e.disabled
}).map(e => {
if (e.children) {
e.children = handleType(e.children)
}
return e
})
}
Promise.all(promises).then(_ => { Promise.all(promises).then(_ => {
this.modelData = data data = handleType(data)
this.modelLoading = false this.modelData = data
this.modelLoading = false
}).catch(res => {}) }).catch(res => {})
}).catch(res => {}) }).catch(res => {})
}).catch(res => {}) }).catch(res => {})
}, },
//
// //
show(row) { show(row) {
this.$router.push(`/addModel?categoryId=${this.$refs.tree.$refs.tree.getCurrentKey()}&id=${row.id}&show=1&model=1`) this.$router.push(`/addModel?categoryId=${this.$refs.tree.$refs.tree.getCurrentKey()}&id=${row.id}&show=1&model=1`)
@ -219,27 +240,32 @@ export default {
if (this.submiting) return false if (this.submiting) return false
const data = [] const data = []
const systemId = this.systemId const systemId = this.systemId
const list = this.$refs.model.getCheckedNodes() // if (this.$refs.model) {
const categoryId = this.$refs.tree.$refs.tree.getCurrentKey() // const list = this.$refs.model.getCheckedNodes() //
if (!list.length) return this.$message.error('请选择模型') const categoryId = this.$refs.tree.$refs.tree.getCurrentKey() //
this.submiting = true if (!list.length) return this.$message.error('请选择模型')
list.map(e => { this.submiting = true
// categoryId list.map(e => {
e.categoryId && data.push({ // categoryId
systemId, e.categoryId && data.push({
categoryId, systemId,
copyId: e.id categoryId,
copyId: e.id
})
}) })
}) this.$post(this.api.saveReferenceDemo, data).then(res => {
this.$post(this.api.saveReferenceDemo, data).then(res => { this.modelVisible = false
this.modelVisible = false this.initData()
this.initData() setTimeout(() => {
setTimeout(() => { this.submiting = false
this.submiting = false }, 2000)
}, 2000) }).catch(res => {
}).catch(res => { this.submiting = false
this.submiting = false })
}) } else {
this.submiting = false
this.modelVisible = false
}
} }
} }
}; };
@ -266,5 +292,9 @@ export default {
.model-wrap { .model-wrap {
max-height: 400px; max-height: 400px;
overflow: auto; overflow: auto;
.none {
text-align: center;
color: #8b8b8b;
}
} }
</style> </style>
Loading…
Cancel
Save