模型修改

Branch_d40a2540
yujialong 2 years ago
parent e305d06c22
commit 6008670bc8
  1. 7
      src/pages/expSystem/backstage/addModel.vue
  2. 163
      src/pages/expSystem/backstage/model.vue
  3. 1
      src/pages/expSystem/backstage/modelType.vue
  4. 2
      src/pages/expSystem/list/index.vue

@ -102,15 +102,16 @@ export default {
}, },
// id // id
handleId (list, id, parentId = []) { handleId (list, id, parentId = []) {
list.map(e => { for (const e of list) {
// idid // idid
if (id === e.id) { if (id === e.id) {
parentId.shift() // id // parentId.shift() // id
this.categoryIdCus = [...parentId, e.id] this.categoryIdCus = [...parentId, e.id]
break
} else { } else {
e.children && this.handleId(e.children, id, [...parentId, e.id]) e.children && this.handleId(e.children, id, [...parentId, e.id])
} }
}) }
}, },
// //
getType () { getType () {

@ -85,17 +85,26 @@
:visible.sync="modelVisible" :visible.sync="modelVisible"
width="500px" width="500px"
class="dialog" class="dialog"
:close-on-click-modal="false"> :close-on-click-modal="false"
v-loading="modelLoading">
<div class="model-wrap"> <div class="model-wrap">
<el-tree v-if="modelData.length" <el-tree v-if="schoolModels.length"
:data="modelData" :data="schoolModels"
v-loading="modelLoading" ref="schoolModel"
ref="model"
default-expand-all default-expand-all
show-checkbox show-checkbox
node-key="id" node-key="id"
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}"> :props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}">
</el-tree> </el-tree>
<el-tree v-if="systemModels.length"
:data="systemModels"
ref="systemModel"
default-expand-all
show-checkbox
node-key="id"
:props="{children: 'children', label: 'categoryName', isLeaf: 'leaf'}">
</el-tree>
<div class="none" <div class="none"
v-else>暂无可导入的模型</div> v-else>暂无可导入的模型</div>
</div> </div>
@ -124,7 +133,8 @@ export default {
multipleSelection: [], multipleSelection: [],
modelVisible: false, modelVisible: false,
modelLoading: false, modelLoading: false,
modelData: [], schoolModels: [],
systemModels: [],
submiting: false, submiting: false,
timer: null timer: null
}; };
@ -195,83 +205,77 @@ export default {
this.getData() this.getData()
}, },
// //
add () { async add () {
if (!this.$refs.tree.orgList.length) return this.$message.error('请先添加模型分类') if (!this.$refs.tree.orgList.length) return this.$message.error('请先添加模型分类')
if (this.isTopLevel) return this.$message.error('请选择子分类进入导入模型') if (this.isTopLevel) return this.$message.error('请选择子分类进入导入模型')
this.modelVisible = true this.modelVisible = true
this.modelLoading = true this.modelLoading = true
//
this.$post(this.api.getAllModelList, {
founder: 1,
pageNum: 1,
pageSize: 10000,
systemId: this.systemId,
isOpen: 0
}).then(res => {
const modelList = res.data.records
// //
// //
this.$post(this.api.sourceModelClassification + '?founder=1').then(({ data }) => { let { data } = await this.$post(this.api.sourceModelClassification + '?founder=1')
const promises = [] const promises = []
const addType = list => { const addType = (list, system = 0) => {
list.map((e, i) => { list.map((e, i) => {
// promise // promise
promises.push(new Promise((resolve, reject) => { promises.push(new Promise(async (resolve, reject) => {
// try {
this.$post(this.api.sysModelDemoList, { //
pageNum: 1, const res = await this.$post(this.api[system ? 'sortReadingModelByTeacherSideSystem' : 'InstitutionSourceModel'], {
pageSize: 10000, pageNum: 1,
categoryId: e.id, pageSize: 10000,
founder: 1, categoryId: e.id,
postStatus: 1, founder: system ? 0 : 1,
isOpen: 0, postStatus: 1,
ztOpen: 0 isOpen: 0,
}).then(res => { ztOpen: 0
const { records } = res.data })
const modelChildren = [] const { records } = res.data
// copyIdid const modelChildren = []
records.map(n => { // copyIdid
if (!modelList.find(e => e.copyId === n.id)) { records.map(n => {
n.categoryName = n.modelName n.categoryName = n.modelName
modelChildren.push(n) modelChildren.push(n)
} })
}) // disabled
// disabled if (modelChildren.length) {
if (modelChildren.length) { e.children = [...e.children, ...modelChildren]
e.children = [...e.children, ...modelChildren] } else if (records.length) {
} else if (records.length) { e.disabled = true
e.disabled = true
}
resolve()
}).catch(res => {
reject()
})
}))
e.children && e.children.length && addType(e.children)
})
}
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 resolve()
}) } catch (error) {
} reject()
Promise.all(promises).then(_ => { }
data = handleType(data) }))
this.modelData = (data.length && data[0].children && data[0].children.length) ? data : [] e.children && e.children.length && addType(e.children, system)
this.modelLoading = false })
}).catch(res => { }) }
}).catch(res => { }) addType(data)
//
const res = await this.$post(`${this.api.builtInClassificationByNakadai}?systemId=${this.systemId}`)
addType(res.data, 1)
Promise.all(promises).then(_ => {
data = this.handleType(data)
const systemData = this.handleType(res.data)
this.schoolModels = (data.length && data[0].children && data[0].children.length) ? data : []
this.systemModels = (systemData.length && systemData[0].children && systemData[0].children.length) ? systemData : []
this.modelLoading = false
}).catch(res => { }) }).catch(res => { })
}, },
// // disabledtrue
handleType (list) {
return list.filter((e, i) => {
return !e.disabled
}).map(e => {
if (e.children) {
e.children = this.handleType(e.children)
}
return e
})
},
// //
show (row) { show (row) {
@ -323,9 +327,10 @@ export default {
submit () { submit () {
if (this.submiting) return false if (this.submiting) return false
const data = [] const data = []
const systemId = this.systemId const { systemId } = this
if (this.$refs.model) { const { schoolModel, systemModel } = this.$refs
const list = this.$refs.model.getCheckedNodes() // if (schoolModel || systemModel) {
const list = [...schoolModel.getCheckedNodes(), ...systemModel.getCheckedNodes()] //
const categoryId = this.$refs.tree.$refs.tree.getCurrentKey() // const categoryId = this.$refs.tree.$refs.tree.getCurrentKey() //
if (!list.length) return this.$message.error('请选择模型') if (!list.length) return this.$message.error('请选择模型')
this.submiting = true this.submiting = true
@ -334,7 +339,7 @@ export default {
e.categoryId && data.push({ e.categoryId && data.push({
systemId, systemId,
categoryId, categoryId,
copyId: e.id copyId: e.founder ? e.id : e.copyId // copyIdid
}) })
}) })
this.$post(this.api.saveReferenceDemo, data).then(res => { this.$post(this.api.saveReferenceDemo, data).then(res => {

@ -13,6 +13,7 @@
icon="el-icon-refresh" icon="el-icon-refresh"
@click="syncModel">同步原始模型列表</el-button> @click="syncModel">同步原始模型列表</el-button>
<el-button v-auth="'/expSystem/list:进入:模型列表管理:新增分类'" <el-button v-auth="'/expSystem/list:进入:模型列表管理:新增分类'"
v-if="!orgList.length"
type="text" type="text"
@click="addType(0)">添加</el-button> @click="addType(0)">添加</el-button>
</div> </div>

@ -83,7 +83,7 @@ export default {
systemType: "", systemType: "",
systemSearch: "", systemSearch: "",
searchTimer: null, searchTimer: null,
systemData: [{}], systemData: [],
totals: 0, totals: 0,
systemBelongKeys: { systemBelongKeys: {
1: '外部产品', 1: '外部产品',

Loading…
Cancel
Save