模型修改

Branch_d40a2540
yujialong 1 year 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
handleId (list, id, parentId = []) {
list.map(e => {
for (const e of list) {
// idid
if (id === e.id) {
parentId.shift() // id
// parentId.shift() // id
this.categoryIdCus = [...parentId, e.id]
break
} else {
e.children && this.handleId(e.children, id, [...parentId, e.id])
}
})
}
},
//
getType () {

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

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

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

Loading…
Cancel
Save