|
|
|
@ -1,7 +1,9 @@ |
|
|
|
|
<template> |
|
|
|
|
<div class="wrap"> |
|
|
|
|
<div class="side"> |
|
|
|
|
<org ref="tree" @initData="initData" @getData="getData"></org> |
|
|
|
|
<org ref="tree" |
|
|
|
|
@initData="initData" |
|
|
|
|
@getData="getData"></org> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div class="right"> |
|
|
|
@ -9,40 +11,94 @@ |
|
|
|
|
<div class="tool"> |
|
|
|
|
<ul class="filter"> |
|
|
|
|
<li> |
|
|
|
|
<el-input placeholder="请输入模型名称" prefix-icon="el-icon-search" v-model.trim="keyword" clearable></el-input> |
|
|
|
|
<el-input placeholder="请输入模型名称" |
|
|
|
|
prefix-icon="el-icon-search" |
|
|
|
|
v-model.trim="keyword" |
|
|
|
|
clearable></el-input> |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
<div> |
|
|
|
|
<el-button type="primary" round @click="add">新增模型</el-button> |
|
|
|
|
<el-button type="primary" round @click="batchDel">批量删除</el-button> |
|
|
|
|
<el-button type="primary" round @click="batchOff(1)">批量禁用</el-button> |
|
|
|
|
<el-button type="primary" round @click="batchOff(0)">批量开启</el-button> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
round |
|
|
|
|
@click="add">新增模型</el-button> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
round |
|
|
|
|
@click="batchDel">批量删除</el-button> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
round |
|
|
|
|
@click="batchOff(1)">批量禁用</el-button> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
round |
|
|
|
|
@click="batchOff(0)">批量开启</el-button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> |
|
|
|
|
<el-table-column type="selection" width="55" align="center"></el-table-column> |
|
|
|
|
<el-table-column type="index" label="序号" width="55" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="modelName" label="模型名称" align="center"></el-table-column> |
|
|
|
|
<el-table-column v-if="isTopLevel" prop="categoryName" label="分类" width="150" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="modifyName" label="编辑人" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="updateTime" label="最新编辑时间" width="150" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="workNumber" label="状态" width="100" align="center"> |
|
|
|
|
<el-table :data="listData" |
|
|
|
|
class="table" |
|
|
|
|
ref="table" |
|
|
|
|
stripe |
|
|
|
|
header-align="center" |
|
|
|
|
@selection-change="handleSelectionChange"> |
|
|
|
|
<el-table-column type="selection" |
|
|
|
|
width="55" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column type="index" |
|
|
|
|
label="序号" |
|
|
|
|
width="55" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="modelName" |
|
|
|
|
label="模型名称" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column v-if="isTopLevel" |
|
|
|
|
prop="categoryName" |
|
|
|
|
label="分类" |
|
|
|
|
width="150" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="modifyName" |
|
|
|
|
label="编辑人" |
|
|
|
|
align="center"> |
|
|
|
|
|
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
{{ scope.row.schoolName || scope.row.modifyName }} |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="updateTime" |
|
|
|
|
label="最新编辑时间" |
|
|
|
|
width="150" |
|
|
|
|
align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="workNumber" |
|
|
|
|
label="状态" |
|
|
|
|
width="100" |
|
|
|
|
align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
{{ scope.row.postStatus ? '已发布' : '草稿' }} |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column label="操作" width="230"> |
|
|
|
|
<el-table-column label="操作" |
|
|
|
|
width="230"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-button type="text" @click="show(scope.row)">查看</el-button> |
|
|
|
|
<el-button type="text" @click="edit(scope.row)">编辑</el-button> |
|
|
|
|
<el-button type="text" @click="del(scope.row)">删除</el-button> |
|
|
|
|
<el-switch v-if="scope.row.postStatus" v-model="scope.row.isOpen" :active-value="0" :inactive-value="1" style="margin: 0 10px 0 5px" :active-text="scope.row.isOpen ? '禁用' : '启用'" @change="switchOff($event,scope.row,scope.$index)"></el-switch> |
|
|
|
|
<el-button type="text" |
|
|
|
|
@click="show(scope.row)">查看</el-button> |
|
|
|
|
<el-button type="text" |
|
|
|
|
@click="edit(scope.row)">编辑</el-button> |
|
|
|
|
<el-button type="text" |
|
|
|
|
@click="del(scope.row)">删除</el-button> |
|
|
|
|
<el-switch v-if="scope.row.postStatus" |
|
|
|
|
v-model="scope.row.isOpen" |
|
|
|
|
:active-value="0" |
|
|
|
|
:inactive-value="1" |
|
|
|
|
style="margin: 0 10px 0 5px" |
|
|
|
|
:active-text="scope.row.isOpen ? '禁用' : '启用'" |
|
|
|
|
@change="switchOff($event,scope.row,scope.$index)"></el-switch> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
</el-table> |
|
|
|
|
<div class="pagination"> |
|
|
|
|
<el-pagination background layout="total, prev, pager, next" :current-page="page" @current-change="handleCurrentChange" :total="total"></el-pagination> |
|
|
|
|
<el-pagination background |
|
|
|
|
layout="total, prev, pager, next" |
|
|
|
|
:current-page="page" |
|
|
|
|
@current-change="handleCurrentChange" |
|
|
|
|
:total="total"></el-pagination> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
@ -50,7 +106,7 @@ |
|
|
|
|
<script> |
|
|
|
|
import org from "./sourceType" |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
data () { |
|
|
|
|
return { |
|
|
|
|
isTopLevel: true, // 是否是在顶级分类 |
|
|
|
|
listData: [], |
|
|
|
@ -65,54 +121,43 @@ export default { |
|
|
|
|
org |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
keyword: function(val) { |
|
|
|
|
keyword: function (val) { |
|
|
|
|
clearTimeout(this.searchTimer); |
|
|
|
|
this.searchTimer = setTimeout(() => { |
|
|
|
|
this.initData() |
|
|
|
|
}, 500) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
mounted () { |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 获取列表 |
|
|
|
|
getData() { |
|
|
|
|
async getData (school) { |
|
|
|
|
const curNode = this.$refs.tree.$refs.tree.getCurrentNode() // 获取当前选中的分类 |
|
|
|
|
this.isTopLevel = !curNode.level |
|
|
|
|
// 如果是首级,要调另一个接口 |
|
|
|
|
if (!curNode.level) { |
|
|
|
|
this.$post(this.api.getAllModelListBySys, { |
|
|
|
|
modelName: this.keyword, |
|
|
|
|
pageNum: this.page, |
|
|
|
|
pageSize: this.pageSize |
|
|
|
|
}).then(res => { |
|
|
|
|
this.listData = res.data.records |
|
|
|
|
this.total = res.data.total |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
} else { |
|
|
|
|
this.$post(this.api.sysModelDemoList, { |
|
|
|
|
const { data } = await this.$post(this.api[school ? 'InstitutionSourceModel' : !curNode.level ? 'getAllModelListBySys' : 'sysModelDemoList'], { |
|
|
|
|
modelName: this.keyword, |
|
|
|
|
pageNum: this.page, |
|
|
|
|
pageSize: this.pageSize, |
|
|
|
|
categoryId: curNode.id |
|
|
|
|
}).then(res => { |
|
|
|
|
this.listData = res.data.records |
|
|
|
|
this.total = res.data.total |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
} |
|
|
|
|
categoryId: curNode.id, |
|
|
|
|
founder: 0 |
|
|
|
|
}) |
|
|
|
|
this.listData = data.records |
|
|
|
|
this.total = data.total |
|
|
|
|
}, |
|
|
|
|
initData() { |
|
|
|
|
initData (school) { |
|
|
|
|
this.$refs.table.clearSelection() |
|
|
|
|
this.page = 1 |
|
|
|
|
this.getData() |
|
|
|
|
this.getData(school) |
|
|
|
|
}, |
|
|
|
|
// 新增 |
|
|
|
|
add() { |
|
|
|
|
add () { |
|
|
|
|
this.$router.push(`/addModel?categoryId=${this.$refs.tree.$refs.tree.getCurrentKey()}`) |
|
|
|
|
}, |
|
|
|
|
// 批量删除 |
|
|
|
|
batchDel() { |
|
|
|
|
batchDel () { |
|
|
|
|
if (this.multipleSelection.length) { |
|
|
|
|
// 批量删除 |
|
|
|
|
let ids = this.multipleSelection.map(e => e.id) |
|
|
|
@ -122,14 +167,14 @@ export default { |
|
|
|
|
this.$post(this.api.deleteSysModelDemo, ids).then(res => { |
|
|
|
|
this.$message.success('删除成功') |
|
|
|
|
this.getData() |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}).catch(() => {}) |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}).catch(() => { }) |
|
|
|
|
} else { |
|
|
|
|
this.$message.error("请先选择模型 !") |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 批量禁用启用 |
|
|
|
|
batchOff(isOpen) { |
|
|
|
|
batchOff (isOpen) { |
|
|
|
|
const off = isOpen === 0 |
|
|
|
|
if (this.multipleSelection.length) { |
|
|
|
|
// 批量删除 |
|
|
|
@ -140,39 +185,39 @@ export default { |
|
|
|
|
this.$post(`${this.api.bulkDisable}?isOpen=${isOpen}`, ids).then(res => { |
|
|
|
|
this.$message.success(`${off ? '启用' : '禁用'}成功`) |
|
|
|
|
this.getData() |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}).catch(() => {}) |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}).catch(() => { }) |
|
|
|
|
} else { |
|
|
|
|
this.$message.error("请先选择模型 !") |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 查看 |
|
|
|
|
show(row) { |
|
|
|
|
show (row) { |
|
|
|
|
this.$router.push(`/addModel?categoryId=${this.$refs.tree.$refs.tree.getCurrentKey()}&id=${row.id}&show=1`) |
|
|
|
|
}, |
|
|
|
|
// 编辑 |
|
|
|
|
edit(row) { |
|
|
|
|
edit (row) { |
|
|
|
|
this.$router.push(`/addModel?categoryId=${this.$refs.tree.$refs.tree.getCurrentKey()}&id=${row.id}&postStatus=${row.postStatus}`) |
|
|
|
|
}, |
|
|
|
|
del(row) { |
|
|
|
|
del (row) { |
|
|
|
|
this.$confirm("确定要删除吗?", "提示", { |
|
|
|
|
type: "warning" |
|
|
|
|
}).then(() => { |
|
|
|
|
this.$post(this.api.deleteSysModelDemo, [row.id]).then(res => { |
|
|
|
|
this.$message.success('删除成功') |
|
|
|
|
this.getData() |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}).catch(() => {}) |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}).catch(() => { }) |
|
|
|
|
}, |
|
|
|
|
switchOff(val,row,index) { |
|
|
|
|
switchOff (val, row, index) { |
|
|
|
|
this.$post(`${this.api.bulkDisable}?isOpen=${val}`, [row.id]).then(res => { |
|
|
|
|
this.$message.success(val ? '禁用成功' : '启用成功') |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}, |
|
|
|
|
handleSelectionChange(val) { |
|
|
|
|
handleSelectionChange (val) { |
|
|
|
|
this.multipleSelection = val |
|
|
|
|
}, |
|
|
|
|
handleCurrentChange(val) { |
|
|
|
|
handleCurrentChange (val) { |
|
|
|
|
this.page = val |
|
|
|
|
this.$router.push({ |
|
|
|
|
path: 'backstage', |
|
|
|
@ -201,7 +246,7 @@ export default { |
|
|
|
|
padding: 24px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.el-input__inner{ |
|
|
|
|
.el-input__inner { |
|
|
|
|
height: 32px; |
|
|
|
|
} |
|
|
|
|
</style> |