|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
<div class="wrap"> |
|
|
|
|
<div class="side"> |
|
|
|
|
<org ref="tree" |
|
|
|
|
@initData="initData" |
|
|
|
|
@initData="catetoryClick" |
|
|
|
|
@getData="getData"></org> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
@ -83,7 +83,8 @@ |
|
|
|
|
@click="edit(scope.row)">编辑</el-button> |
|
|
|
|
<el-button type="text" |
|
|
|
|
@click="del(scope.row)">删除</el-button> |
|
|
|
|
<el-button type="text" |
|
|
|
|
<el-button v-if="isSchool" |
|
|
|
|
type="text" |
|
|
|
|
@click="copy(scope.row)">复制</el-button> |
|
|
|
|
<el-switch v-if="scope.row.postStatus" |
|
|
|
|
v-model="scope.row.ztOpen" |
|
|
|
@ -116,7 +117,7 @@ |
|
|
|
|
style="width: 280px"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="模型分类"> |
|
|
|
|
<el-cascader :options="categoryList" |
|
|
|
|
<el-cascader :options="categories" |
|
|
|
|
v-model="categoryIdCus" |
|
|
|
|
:props="categoryProps" |
|
|
|
|
clearable |
|
|
|
@ -135,9 +136,11 @@ |
|
|
|
|
</template> |
|
|
|
|
<script> |
|
|
|
|
import org from "./sourceType" |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
export default { |
|
|
|
|
data () { |
|
|
|
|
return { |
|
|
|
|
systemId: this.$route.query.systemId, |
|
|
|
|
isTopLevel: true, // 是否是在顶级分类 |
|
|
|
|
listData: [], |
|
|
|
|
keyword: "", |
|
|
|
@ -154,7 +157,9 @@ export default { |
|
|
|
|
label: 'categoryName', |
|
|
|
|
value: 'id' |
|
|
|
|
}, |
|
|
|
|
timer: null |
|
|
|
|
timer: null, |
|
|
|
|
isSchool: 0, |
|
|
|
|
categories: [] |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
components: { |
|
|
|
@ -175,31 +180,44 @@ export default { |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 获取列表 |
|
|
|
|
async getList (school) { |
|
|
|
|
async getList () { |
|
|
|
|
const curNode = this.$refs.tree.$refs.tree.getCurrentNode() || {}// 获取当前选中的分类 |
|
|
|
|
this.isTopLevel = !curNode.level |
|
|
|
|
// 如果是首级,要调另一个接口 |
|
|
|
|
const { data } = await this.$post(this.api[school ? 'InstitutionSourceModel' : !curNode.level ? 'getAllModelListBySys' : 'sysModelDemoList'], { |
|
|
|
|
const { data } = await this.$post(this.api[this.isSchool ? 'InstitutionSourceModel' : !curNode.level ? 'getAllModelListBySys' : 'sysModelDemoList'], { |
|
|
|
|
modelName: this.keyword, |
|
|
|
|
pageNum: this.page, |
|
|
|
|
pageSize: this.pageSize, |
|
|
|
|
categoryId: curNode.id, |
|
|
|
|
founder: school ? 1 : 0 |
|
|
|
|
founder: this.isSchool ? 1 : 0 |
|
|
|
|
}) |
|
|
|
|
this.listData = data.records |
|
|
|
|
this.total = data.total |
|
|
|
|
}, |
|
|
|
|
getData (school) { |
|
|
|
|
getData () { |
|
|
|
|
clearInterval(this.timer) |
|
|
|
|
this.getList(school) |
|
|
|
|
// this.timer = setInterval(() => { |
|
|
|
|
// this.getList(school) |
|
|
|
|
// }, 1000) |
|
|
|
|
this.getList() |
|
|
|
|
if (!Setting.isDev) { |
|
|
|
|
this.timer = setInterval(this.getRedis, 1000) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
initData (school) { |
|
|
|
|
this.$refs.table.clearSelection() |
|
|
|
|
// 获取redis缓存 |
|
|
|
|
getRedis () { |
|
|
|
|
this.$post(this.api.modelRedis).then(({ data }) => { |
|
|
|
|
if (data) { |
|
|
|
|
localStorage.getItem('modelNakadai') !== data && this.getList() // 本地缓存跟redis返回的不一样,就查询列表 |
|
|
|
|
localStorage.setItem('modelNakadai', data) |
|
|
|
|
} |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}, |
|
|
|
|
// 分类点击回调 |
|
|
|
|
catetoryClick (school) { |
|
|
|
|
this.isSchool = school |
|
|
|
|
this.initData() |
|
|
|
|
}, |
|
|
|
|
initData () { |
|
|
|
|
this.page = 1 |
|
|
|
|
this.getData(school) |
|
|
|
|
this.getData() |
|
|
|
|
}, |
|
|
|
|
// 新增 |
|
|
|
|
add () { |
|
|
|
@ -232,28 +250,23 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 复制 |
|
|
|
|
copy (row) { |
|
|
|
|
this.$post(this.api.sourceModelClassification + '?founder=0').then(res => { |
|
|
|
|
const { data } = res |
|
|
|
|
// 没有子级,删除children属性 |
|
|
|
|
const handleLeaf = list => { |
|
|
|
|
list.map(e => { |
|
|
|
|
if (e.children.length) { |
|
|
|
|
handleLeaf(e.children) |
|
|
|
|
} else { |
|
|
|
|
delete e.children |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
handleLeaf(data) |
|
|
|
|
this.categoryList = data[0].children |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
|
|
|
|
|
this.curRow = JSON.parse(JSON.stringify(row)) |
|
|
|
|
this.copyVisible = true |
|
|
|
|
}, |
|
|
|
|
// 复制提交 |
|
|
|
|
copySubmit () { |
|
|
|
|
|
|
|
|
|
async copySubmit () { |
|
|
|
|
const ids = this.categoryIdCus |
|
|
|
|
const row = this.curRow |
|
|
|
|
if (!row.modelName) return this.$message.error('请输入模型名称!') |
|
|
|
|
if (!ids.length) return this.$message.error('请选择模型分类!') |
|
|
|
|
await this.$post(this.api.copyTheModelToTheNakadai, { |
|
|
|
|
beCopiedModelId: row.id, |
|
|
|
|
categoryId: ids[ids.length - 1], |
|
|
|
|
modelName: row.modelName, |
|
|
|
|
systemId: this.systemId |
|
|
|
|
}) |
|
|
|
|
this.$message.success('复制成功!') |
|
|
|
|
this.copyVisible = false |
|
|
|
|
}, |
|
|
|
|
del (row) { |
|
|
|
|
this.$confirm("确定要删除吗?", "提示", { |
|
|
|
|