| | |
| | | <div class="search"> |
| | | <el-form :inline="true" :model="searchForm" class="demo-form-inline"> |
| | | <el-form-item label="分类名称"> |
| | | <el-input v-model="searchForm.typeName" size="small" placeholder="分类名称"></el-input> |
| | | <el-input v-model="searchForm.typeName" size="small" placeholder="分类名称" clearable @clear="page"></el-input> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="page" size="small">查询</el-button> |
| | |
| | | label="操作" |
| | | width="140"> |
| | | <template slot-scope="scope"> |
| | | <el-button @click="handleUpdate(scope.row)" type="text" size="small">修改</el-button> |
| | | <el-button type="text" size="small">删除</el-button> |
| | | <el-button @click="handleUpdate(scope.row)" type="primary" size="small" style="margin-right: 5px">修改</el-button> |
| | | |
| | | <el-popconfirm |
| | | :title="getTitle(scope.row.typeName)" |
| | | @confirm="remove(scope.row.id)" |
| | | > |
| | | <el-button slot="reference" type="danger" size="small">删除</el-button> |
| | | </el-popconfirm> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <el-dialog |
| | | title="提示" |
| | | title="添加视频分类" |
| | | :visible.sync="open" |
| | | width="300" |
| | | width="300px" |
| | | :before-close="handleClose"> |
| | | <el-form label-position="top" label-width="80px" :rules="rules" :model="form"> |
| | | <el-form label-position="top" label-width="80px" ref="form" :rules="rules" :model="form"> |
| | | <el-form-item label="分类名称" prop="typeName"> |
| | | <el-input v-model="form.typeName"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="排序值" prop="orderNum"> |
| | | <el-input v-model="form.orderNum" type="number" placeholder=""排序值></el-input> |
| | | <el-input v-model="form.orderNum" type="number" placeholder="排序值"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="open = false">取 消</el-button> |
| | | <el-button type="primary" @click="handlerSubmit">确 定</el-button> |
| | | <el-button type="primary" @click="handlerSubmit">添 加</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | |
| | | typeName: '' |
| | | }, |
| | | tableData: [], |
| | | open: false, |
| | | form: { |
| | | typeName: '', |
| | | orderNum: null, |
| | | open: false |
| | | orderNum: null |
| | | }, |
| | | rules: { |
| | | typeName: [ |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | remove (id) { |
| | | VideoTypeAPI.remove(id).then(res => { |
| | | if (res.code === 1) { |
| | | this.$message.success('删除成功') |
| | | } |
| | | }) |
| | | }, |
| | | getTitle (typeName) { |
| | | return '确定要删除' + typeName + '这个分类吗?' |
| | | }, |
| | | handlerSubmit () { |
| | | |
| | | this.$refs['form'].validate((valid) => { |
| | | if (valid) { |
| | | if (this.form.id) { |
| | | VideoTypeAPI.update(this.form).then(res => { |
| | | if (res.code === 1) { |
| | | this.$message.success('修改成功') |
| | | this.open = false |
| | | this.page() |
| | | } |
| | | }) |
| | | } else { |
| | | VideoTypeAPI.add(this.form).then(res => { |
| | | if (res.code === 1) { |
| | | this.$message.success('添加成功') |
| | | this.open = false |
| | | this.page() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | handleClose () { |
| | | this.open = false |
| | |
| | | handleUpdate (row) { |
| | | this.form.typeName = row.typeName |
| | | this.form.orderNum = row.orderNum |
| | | this.form.id = row.id |
| | | this.open = true |
| | | } |
| | | }, |