|
@@ -9,6 +9,11 @@
|
|
|
<div class="obstruct"></div>
|
|
|
<div class="conten">
|
|
|
<div class="con_left">
|
|
|
+ <div class="moBtn">
|
|
|
+ <el-button type="primary" @click="dialogShow = true"
|
|
|
+ >新增模块</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
<div class="cutJT">
|
|
|
<i class="el-icon-arrow-down"></i>
|
|
|
教育基地
|
|
@@ -17,10 +22,22 @@
|
|
|
<li
|
|
|
v-for="item in conLeftArr"
|
|
|
:key="item.id"
|
|
|
- :class="{ active: formData.type === item.type }"
|
|
|
- @click="cutLeft(item.type)"
|
|
|
+ :class="{ active: formData.moduleId === item.id }"
|
|
|
+ @click="cutLeft(item.id,item.type)"
|
|
|
>
|
|
|
- {{ item.name }}
|
|
|
+ <span :title="item.name">{{ item.name }}</span>
|
|
|
+ <div class="inco" v-if="item.id !== 1 && item.id !== 2 && item.id !== 3">
|
|
|
+ <i
|
|
|
+ @click="moduleEdit(item.id)"
|
|
|
+ title="编辑"
|
|
|
+ class="el-icon-edit"
|
|
|
+ ></i>
|
|
|
+ <i
|
|
|
+ title="删除"
|
|
|
+ class="el-icon-delete"
|
|
|
+ @click="moduleRemove(item.id)"
|
|
|
+ ></i>
|
|
|
+ </div>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</div>
|
|
@@ -71,40 +88,63 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="标题" width="250">
|
|
|
<template #default="{ row }">
|
|
|
- <span class="table_name" :title="row.name">{{
|
|
|
- row.name
|
|
|
- }}</span>
|
|
|
+ <span class="table_name" :title="row.name">{{ row.name }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="封面图片" width="120">
|
|
|
- <template #default='{row}'>
|
|
|
- <img class="table_img" :src="baseURL+row.thumb" alt="" :onerror="defaultImg"/>
|
|
|
+ <template #default="{ row }">
|
|
|
+ <img
|
|
|
+ class="table_img"
|
|
|
+ :src="baseURL + row.thumb"
|
|
|
+ alt=""
|
|
|
+ :onerror="defaultImg"
|
|
|
+ />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="visit" label="阅读" width="100"> </el-table-column>
|
|
|
- <el-table-column prop="creatorName" label="发布人"> </el-table-column>
|
|
|
+ <el-table-column prop="visit" label="阅读" width="100">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="creatorName" label="发布人">
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="createTime" label="发布时间" width="200">
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="排序" width="80">
|
|
|
+ <el-table-column label="排序" width="80">
|
|
|
<template #default="{ row }">
|
|
|
- <el-input type="text" v-model="row.sort" @blur="changeSort(row.sort,row.id)"></el-input>
|
|
|
+ <el-input
|
|
|
+ type="text"
|
|
|
+ v-model="row.sort"
|
|
|
+ @blur="changeSort(row.sort, row.id)"
|
|
|
+ ></el-input>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="是否显示">
|
|
|
<template #default="{ row }">
|
|
|
- <el-switch v-model="row.display" active-color="#b9412e" :active-value='1' :inactive-value='0' @change='changeSwit($event,row.id)'>
|
|
|
+ <el-switch
|
|
|
+ v-model="row.display"
|
|
|
+ active-color="#b9412e"
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="0"
|
|
|
+ @change="changeSwit($event, row.id)"
|
|
|
+ >
|
|
|
</el-switch>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作">
|
|
|
<template #default="{ row }">
|
|
|
+ <el-button type="text" @click="lookGood(row.id)"
|
|
|
+ >查看</el-button
|
|
|
+ >
|
|
|
<el-button
|
|
|
type="text"
|
|
|
- @click="lookGood(row.id)"
|
|
|
- >查看</el-button
|
|
|
+ v-if="!row.display"
|
|
|
+ @click="editGood(row.id)"
|
|
|
+ >编辑</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ v-if="!row.display"
|
|
|
+ @click="delGoods(row.id)"
|
|
|
+ >删除</el-button
|
|
|
>
|
|
|
- <el-button type="text" v-if="!row.display" @click="editGood(row.id)">编辑</el-button>
|
|
|
- <el-button type="text" v-if="!row.display" @click="delGoods(row.id)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -122,24 +162,68 @@
|
|
|
>
|
|
|
</el-pagination>
|
|
|
</div>
|
|
|
+ <!-- 点击新增模块出现的弹窗 -->
|
|
|
+ <el-dialog
|
|
|
+ :title="dialogData.id?'编辑模块':'新增模块'"
|
|
|
+ :visible="dialogShow"
|
|
|
+ class="myDialog"
|
|
|
+ @close="btnX"
|
|
|
+ >
|
|
|
+ <div class="row">
|
|
|
+ <span>模块名称:</span>
|
|
|
+ <el-input
|
|
|
+ style="width: 500px"
|
|
|
+ v-model="dialogData.name"
|
|
|
+ maxlength="10"
|
|
|
+ show-word-limit
|
|
|
+ ></el-input>
|
|
|
+ </div>
|
|
|
+ <div class="row">
|
|
|
+ <span>展示类型:</span>
|
|
|
+ <el-radio :disabled='!!dialogData.id' v-model="dialogData.type" label="model">实物模型</el-radio>
|
|
|
+ <el-radio :disabled='!!dialogData.id' v-model="dialogData.type" label="img">专题图库</el-radio>
|
|
|
+ <el-radio :disabled='!!dialogData.id' v-model="dialogData.type" label="video">视频档案</el-radio>
|
|
|
+ </div>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="btnX">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="btnOk">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import axios from '@/utils/request'
|
|
|
-import { goodsList, goodsRemove, goodsDisplay, goodsSort } from '@/apis/tab1'
|
|
|
+import {
|
|
|
+ goodsList,
|
|
|
+ goodsRemove,
|
|
|
+ goodsDisplay,
|
|
|
+ goodsSort,
|
|
|
+ moduleList,
|
|
|
+ moduleSave,
|
|
|
+ moduleRemove,
|
|
|
+ moduleDetail
|
|
|
+} from '@/apis/tab1'
|
|
|
export default {
|
|
|
name: 'tab3',
|
|
|
components: {},
|
|
|
data () {
|
|
|
// 这里存放数据
|
|
|
return {
|
|
|
+ dialogShow: false,
|
|
|
+ dialogData: {
|
|
|
+ module: 'news',
|
|
|
+ name: '',
|
|
|
+ type: 'model'
|
|
|
+ },
|
|
|
+ // 关于新增模块的数据↑
|
|
|
baseURL: '',
|
|
|
total: 0,
|
|
|
time: '',
|
|
|
conLeftArr: [
|
|
|
- { name: '知识共享', type: 'model' },
|
|
|
- { name: '知识阅览', type: 'img' }
|
|
|
+ { id: 1, name: '...' },
|
|
|
+ { id: 2, name: '...' },
|
|
|
+ { id: 3, name: '...' }
|
|
|
],
|
|
|
formData: {
|
|
|
startTime: '',
|
|
@@ -148,8 +232,10 @@ export default {
|
|
|
pageSize: 10,
|
|
|
searchKey: '',
|
|
|
sortType: 0,
|
|
|
- type: 'model'
|
|
|
+ moduleId: 1
|
|
|
},
|
|
|
+ // 当前选中的模块类型
|
|
|
+ activeType: 'model',
|
|
|
tableData: []
|
|
|
}
|
|
|
},
|
|
@@ -163,6 +249,50 @@ export default {
|
|
|
},
|
|
|
// 方法集合
|
|
|
methods: {
|
|
|
+ async moduleEdit (id) {
|
|
|
+ const res = await moduleDetail(id)
|
|
|
+ this.dialogData = res.data
|
|
|
+ this.dialogShow = true
|
|
|
+ },
|
|
|
+ moduleRemove (id) {
|
|
|
+ this.$confirm('确定删除吗? 当前模块下如果存在数据,也会一并删除.', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ .then(async () => {
|
|
|
+ const res = await moduleRemove(id)
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('删除成功')
|
|
|
+ const res2 = await moduleList('goods')
|
|
|
+ this.conLeftArr = res2.data
|
|
|
+ } else this.$message.warning(res.msg)
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message.info('已取消')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ btnX () {
|
|
|
+ this.dialogShow = false
|
|
|
+ this.dialogData = {
|
|
|
+ module: 'goods',
|
|
|
+ name: '',
|
|
|
+ type: 'model'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async btnOk () {
|
|
|
+ if (this.dialogData.name.trim() === '') {
|
|
|
+ return this.$message.warning('模块名称不能为空')
|
|
|
+ }
|
|
|
+ const res = await moduleSave(this.dialogData)
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message.success('操作成功')
|
|
|
+ this.btnX()
|
|
|
+ const res2 = await moduleList('goods')
|
|
|
+ this.conLeftArr = res2.data
|
|
|
+ } else this.$message.warning(res.msg)
|
|
|
+ },
|
|
|
+ // 关于新增模块的方法↑
|
|
|
// 点击重置
|
|
|
resetBtn () {
|
|
|
this.formData.searchKey = ''
|
|
@@ -194,7 +324,6 @@ export default {
|
|
|
this.$message.success('操作成功')
|
|
|
this.goodsList(this.formData)
|
|
|
} else this.$message.warning(res.msg)
|
|
|
- console.log(998, val, id)
|
|
|
},
|
|
|
// 分页器方法
|
|
|
currentChange (val) {
|
|
@@ -230,38 +359,34 @@ export default {
|
|
|
lookGood (id) {
|
|
|
this.$router.push({
|
|
|
path: '/layout/tab1Look',
|
|
|
- query: { conLeftId: this.formData.type, id }
|
|
|
+ query: { Sid: id, id: this.formData.moduleId }
|
|
|
})
|
|
|
},
|
|
|
// 点击编辑文物
|
|
|
editGood (id) {
|
|
|
- if (this.formData.type === 'img') {
|
|
|
- this.$router.push({
|
|
|
- path: '/layout/tab1Add2',
|
|
|
- query: { id }
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.$router.push({
|
|
|
- path: '/layout/tab1Add',
|
|
|
- query: { conLeftId: this.formData.type, id }
|
|
|
- })
|
|
|
- }
|
|
|
+ let temp = '/layout/tab1Add'
|
|
|
+ if (this.activeType === 'img') temp = '/layout/tab1Add2'
|
|
|
+ this.$router.push({
|
|
|
+ path: temp,
|
|
|
+ query: { Sid: id, id: this.formData.moduleId }
|
|
|
+ })
|
|
|
},
|
|
|
// 点击新增文物
|
|
|
addGood () {
|
|
|
- if (this.formData.type === 'img') this.$router.push('/layout/tab1Add2')
|
|
|
- else {
|
|
|
- this.$router.push({
|
|
|
- path: '/layout/tab1Add',
|
|
|
- query: { conLeftId: this.formData.type }
|
|
|
- })
|
|
|
- }
|
|
|
+ let temp = '/layout/tab1Add'
|
|
|
+ if (this.activeType === 'img') temp = '/layout/tab1Add2'
|
|
|
+ this.$router.push({
|
|
|
+ path: temp,
|
|
|
+ query: { id: this.formData.moduleId, k: this.activeType }
|
|
|
+ })
|
|
|
},
|
|
|
// 点击左侧的tab栏
|
|
|
- cutLeft (type) {
|
|
|
- if (type === this.formData.type) return
|
|
|
- this.formData.type = type
|
|
|
+ cutLeft (id, type) {
|
|
|
+ if (id === this.formData.moduleId) return
|
|
|
+ this.formData.moduleId = id
|
|
|
this.goodsList(this.formData)
|
|
|
+ // 把当前选中的模块类型保存
|
|
|
+ this.activeType = type
|
|
|
},
|
|
|
// 时间处理----------------
|
|
|
handleSelect (e) {
|
|
@@ -305,13 +430,21 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 生命周期 - 创建完成(可以访问当前this实例)
|
|
|
- created () {
|
|
|
+ async created () {
|
|
|
+ // 获取模块列表
|
|
|
+ const res = await moduleList('goods')
|
|
|
+ this.conLeftArr = res.data
|
|
|
+
|
|
|
// 获取服务器前缀地址
|
|
|
this.baseURL = axios.defaults.baseURL
|
|
|
// 判断是第一次进来还是修改或者新增或者查看后返回
|
|
|
// 拿到路由跳转传过来的数据
|
|
|
- if (this.$route.query.conLeftId) {
|
|
|
- this.formData.type = this.$route.query.conLeftId
|
|
|
+ if (this.$route.query.k) {
|
|
|
+ const temp = Number(this.$route.query.k)
|
|
|
+ this.formData.moduleId = temp
|
|
|
+ this.conLeftArr.forEach(v => {
|
|
|
+ if (v.id === temp) this.activeType = v.type
|
|
|
+ })
|
|
|
}
|
|
|
this.goodsList(this.formData)
|
|
|
},
|
|
@@ -333,28 +466,87 @@ export default {
|
|
|
display: flex;
|
|
|
height: calc(100% - 32px);
|
|
|
.con_left {
|
|
|
- padding: 20px 0 0 15px;
|
|
|
+ position: relative;
|
|
|
+ padding: 50px 0 0 0;
|
|
|
width: 180px;
|
|
|
height: 100%;
|
|
|
border: 1px solid #ccc;
|
|
|
+ border-top: none;
|
|
|
+ .moBtn {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 40px;
|
|
|
+ /deep/button {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
.cutJT {
|
|
|
+ padding-left: 8px;
|
|
|
margin-bottom: 10px;
|
|
|
}
|
|
|
ul {
|
|
|
+ height: 600px;
|
|
|
+ overflow-y: auto;
|
|
|
+ &::-webkit-scrollbar {
|
|
|
+ /*滚动条整体样式*/
|
|
|
+ width: 2px; /*高宽分别对应横竖滚动条的尺寸*/
|
|
|
+ }
|
|
|
+ &::-webkit-scrollbar-thumb {
|
|
|
+ /*滚动条里面小方块*/
|
|
|
+ border-radius: 10px;
|
|
|
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
|
+ background: #b9412e;
|
|
|
+ }
|
|
|
li {
|
|
|
+ position: relative;
|
|
|
+ padding-left: 30px;
|
|
|
cursor: pointer;
|
|
|
- margin-left: 20px;
|
|
|
- width: 100px;
|
|
|
- text-align: center;
|
|
|
- line-height: 30px;
|
|
|
- height: 30px;
|
|
|
+ width: 100%;
|
|
|
+ text-align: left;
|
|
|
+ line-height: 40px;
|
|
|
+ height: 40px;
|
|
|
+ & > span {
|
|
|
+ display: inline-block;
|
|
|
+ width: calc(100% - 50px);
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+ .inco {
|
|
|
+ display: none;
|
|
|
+ text-align: right;
|
|
|
+ padding: 0 2px;
|
|
|
+ font-size: 20px;
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ top: 0;
|
|
|
+ width: 50px;
|
|
|
+ height: 40px;
|
|
|
+ .el-icon-delete {
|
|
|
+ margin-left: 5px;
|
|
|
+ }
|
|
|
+ i {
|
|
|
+ &:hover {
|
|
|
+ color: #b9412e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
&:hover {
|
|
|
- color: #b9412e;
|
|
|
+ & > span {
|
|
|
+ color: #b9412e;
|
|
|
+ }
|
|
|
background-color: #e6f7ff;
|
|
|
+ .inco {
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
.active {
|
|
|
- color: #b9412e;
|
|
|
+ & > span {
|
|
|
+ color: #b9412e;
|
|
|
+ }
|
|
|
background-color: #e6f7ff;
|
|
|
}
|
|
|
}
|
|
@@ -388,18 +580,26 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .table{
|
|
|
+ .table {
|
|
|
max-width: 1370px;
|
|
|
}
|
|
|
- /deep/.el-table__body-wrapper{
|
|
|
+ /deep/.el-table__body-wrapper {
|
|
|
max-height: 485px;
|
|
|
overflow-y: auto;
|
|
|
}
|
|
|
- .paging {
|
|
|
- position: absolute;
|
|
|
- bottom: 15px;
|
|
|
- right: 50px;
|
|
|
+ .paging {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 15px;
|
|
|
+ right: 50px;
|
|
|
+ }
|
|
|
+ .myDialog {
|
|
|
+ .row {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ &:nth-of-type(1) {
|
|
|
+ margin-bottom: 30px;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|