|
@@ -0,0 +1,288 @@
|
|
|
+<template>
|
|
|
+ <div class="dashboard-container">
|
|
|
+ <div class="dashboard-text">
|
|
|
+ <el-button type="primary" @click="addList">增加行列表</el-button>
|
|
|
+ <el-table
|
|
|
+ :data="getBlockRowData"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column
|
|
|
+ label="序号"
|
|
|
+ width="60"
|
|
|
+ prop="sort"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="id"
|
|
|
+ width="160"
|
|
|
+ prop="id"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="区域名称"
|
|
|
+ width="100"
|
|
|
+ >
|
|
|
+ <template>
|
|
|
+ <span>{{ name() }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="模板名称"
|
|
|
+ width="180"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ template(scope.row.templateCode) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="状态"
|
|
|
+ width="80"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.status === 'HAS_ON_STOCK' ? '上架' : '下架' }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="创建时间"
|
|
|
+ width="180"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ newDate(scope.row.gmtCreated) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="修改时间"
|
|
|
+ width="180"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ newDate(scope.row.gmtModified) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ @click="handleEdit(scope.$index, scope.row)"
|
|
|
+ >修改</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ @click="handleUp(scope.$index, scope.row)"
|
|
|
+ >{{ scope.row.status === 'HAS_ON_STOCK' ? '下架' : '上架' }}</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ @click="handleDetail(scope.$index, scope.row)"
|
|
|
+ >查看</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <el-dialog title="首页行列表" :rules="rules" :visible.sync="dialogFormVisible">
|
|
|
+ <el-form :model="form">
|
|
|
+ <el-form-item label="模板" :label-width="formLabelWidth">
|
|
|
+ <el-select v-model="form.templateCode" placeholder="请选择">
|
|
|
+ <el-option value="IMAGE_TEMPATE_5" label="689*174图片模板" />
|
|
|
+ <el-option value="TEXT_TEMPLATE" label="文字模板" />
|
|
|
+ <el-option value="IMAGE_TEMPATE_4" label="256*360图片模板" />
|
|
|
+ <el-option value="IMAGE_TEMPATE_3" label="404*256图片模板" />
|
|
|
+ <el-option value="IMAGE_TEMPATE_2" label="548*300图片模板" />
|
|
|
+ <el-option value="IMAGE_TEMPATE_1" label="840*300图片模板" />
|
|
|
+ <el-option value="SCHEDULE_TEMPATE_1" label="1414*172课程表模板" />
|
|
|
+ <el-option value="SCHEDULE_TEMPATE_2" label="689*172课程表模板" />
|
|
|
+ <el-option value="SCHEDULE_TEMPATE_3" label="326*174课程表模板" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序" :label-width="formLabelWidth">
|
|
|
+ <el-input v-model="form.sort" autocomplete="off" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="type === 'add'" label="状态" :label-width="formLabelWidth">
|
|
|
+ <el-select v-model="form.status" placeholder="请选择">
|
|
|
+ <el-option value="NOT_ON_STOCK" label="下架" />
|
|
|
+ <el-option value="HAS_ON_STOCK" label="上架" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handOk">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'Dashboard',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dialogFormVisible: false,
|
|
|
+ form: {},
|
|
|
+ formLabelWidth: '120px',
|
|
|
+ type: '',
|
|
|
+ rules: {
|
|
|
+ templateCode: [
|
|
|
+ { required: true, message: '请选择模板', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ status: [
|
|
|
+ { required: true, message: '请选择状态', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ sort: [
|
|
|
+ { required: true, message: '请输入排序', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.$store.dispatch('dashboard/getBlockRowList', {
|
|
|
+ id: this.$route.query.id
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // eslint-disable-next-line vue/order-in-components
|
|
|
+ computed: {
|
|
|
+ ...mapGetters([
|
|
|
+ 'getBlockRowData'
|
|
|
+ ])
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ newDate(date) {
|
|
|
+ return new Date(date).toLocaleString()
|
|
|
+ },
|
|
|
+ name() {
|
|
|
+ const id = this.$route.query.id
|
|
|
+ let name = ''
|
|
|
+ switch (id) {
|
|
|
+ case '0':
|
|
|
+ name = '知识付费'
|
|
|
+ break
|
|
|
+ case '1':
|
|
|
+ name = '学前'
|
|
|
+ break
|
|
|
+ case '2':
|
|
|
+ name = '小学'
|
|
|
+ break
|
|
|
+ case '3':
|
|
|
+ name = '中学'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ return name
|
|
|
+ },
|
|
|
+ template(code) {
|
|
|
+ let templateCode = ''
|
|
|
+ switch (code) {
|
|
|
+ case 'IMAGE_TEMPATE_5':
|
|
|
+ templateCode = '689*174图片模板'
|
|
|
+ break
|
|
|
+ case 'TEXT_TEMPLATE':
|
|
|
+ templateCode = '文字模板'
|
|
|
+ break
|
|
|
+ case 'IMAGE_TEMPATE_1':
|
|
|
+ templateCode = '840*300图片模板'
|
|
|
+ break
|
|
|
+ case 'IMAGE_TEMPATE_2':
|
|
|
+ templateCode = '548*300图片模板'
|
|
|
+ break
|
|
|
+ case 'IMAGE_TEMPATE_3':
|
|
|
+ templateCode = '404*256图片模板'
|
|
|
+ break
|
|
|
+ case 'IMAGE_TEMPATE_4':
|
|
|
+ templateCode = '256*360图片模板'
|
|
|
+ break
|
|
|
+ case 'SCHEDULE_TEMPATE_1':
|
|
|
+ templateCode = '1414*172课程表模板'
|
|
|
+ break
|
|
|
+ case 'SCHEDULE_TEMPATE_2':
|
|
|
+ templateCode = '689*172课程表模板'
|
|
|
+ break
|
|
|
+ case 'SCHEDULE_TEMPATE_3':
|
|
|
+ templateCode = '326*174课程表模板'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ return templateCode
|
|
|
+ },
|
|
|
+ handleEdit(index, row) {
|
|
|
+ console.log(index, row)
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.type = 'set'
|
|
|
+ this.form = {
|
|
|
+ id: '',
|
|
|
+ blockId: '',
|
|
|
+ templateCode: '',
|
|
|
+ status: '',
|
|
|
+ sort: ''
|
|
|
+ }
|
|
|
+ this.setForm(row)
|
|
|
+ },
|
|
|
+ handleUp(index, row) {
|
|
|
+ console.log(index, row)
|
|
|
+ this.setForm(row)
|
|
|
+ this.form.status = row.status === 'NOT_ON_STOCK' ? 'HAS_ON_STOCK' : 'NOT_ON_STOCK'
|
|
|
+ this.$store.dispatch('dashboard/setBlockRowList', this.form).then(() => {
|
|
|
+ this.$store.dispatch('dashboard/getBlockRowList', {
|
|
|
+ id: this.$route.query.id
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleDetail(index, row) {
|
|
|
+ console.log(index, row)
|
|
|
+ this.$router.push({
|
|
|
+ path: '/dashboardRowItem/dashboardRowItem',
|
|
|
+ query: {
|
|
|
+ id: row.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handOk() {
|
|
|
+ if (this.type === 'set') {
|
|
|
+ console.log(this.form)
|
|
|
+ this.$store.dispatch('dashboard/setBlockRowList', this.form).then(() => {
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$store.dispatch('dashboard/getBlockRowList', {
|
|
|
+ id: this.$route.query.id
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else if (this.form.templateCode !== '' && this.form.status !== '' && this.form.sort !== '') {
|
|
|
+ this.$store.dispatch('dashboard/addBlockRowList', this.form).then(() => {
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$store.dispatch('dashboard/getBlockRowList', {
|
|
|
+ id: this.$route.query.id
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addList() {
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.type = 'add'
|
|
|
+ this.form = {
|
|
|
+ blockId: this.$route.query.id,
|
|
|
+ templateCode: '',
|
|
|
+ status: '',
|
|
|
+ sort: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setForm(data) {
|
|
|
+ this.form.id = data.id
|
|
|
+ this.form.blockId = data.blockId
|
|
|
+ this.form.templateCode = data.templateCode
|
|
|
+ this.form.sort = data.sort
|
|
|
+ this.form.status = data.status
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.dashboard {
|
|
|
+ &-container {
|
|
|
+ margin: 30px;
|
|
|
+ }
|
|
|
+ &-text {
|
|
|
+ font-size: 30px;
|
|
|
+ line-height: 46px;
|
|
|
+ }
|
|
|
+}
|
|
|
+ .el-input {
|
|
|
+ width: 300px;
|
|
|
+ }
|
|
|
+ .el-select>.el-input {
|
|
|
+ width: 300px;
|
|
|
+ }
|
|
|
+</style>
|