|
@@ -2,65 +2,75 @@
|
|
|
<div id="index">
|
|
|
<el-row>
|
|
|
<el-col :span="24">
|
|
|
- <el-button type="text" @click="dialogFormVisible = true">添加</el-button>
|
|
|
- <el-dialog title="轮播信息" :visible.sync="dialogFormVisible">
|
|
|
- <el-form :model="form">
|
|
|
- <el-form-item label="名称" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.name" autocomplete="off"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="图片路径" :label-width="formLabelWidth">
|
|
|
- <el-input v-model="form.filepath" autocomplete="off"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="发布时间" :label-width="formLabelWidth">
|
|
|
- <!-- <el-input v-model="form.create_time" autocomplete="off"></el-input> -->
|
|
|
- <div class="block">
|
|
|
- <!-- <span class="demonstration">设置默认时间</span> -->
|
|
|
- <el-date-picker v-model="value3" type="datetime" placeholder="选择日期时间" default-time="12:00:00"> </el-date-picker>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24">
|
|
|
- <el-table :data="tableData" style="width: 100%">
|
|
|
- <el-table-column prop="name" label="名称" width="180"> </el-table-column>
|
|
|
- <el-table-column prop="filepath" label="图片路径" width="180"> </el-table-column>
|
|
|
- <el-table-column prop="create_time" label="发布时间"> </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" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
|
|
|
+ <!-- 哪个组件活跃就显示哪个的meta的title -->
|
|
|
+ <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
|
|
|
+ <el-col :span="24" class="contain">
|
|
|
+ <!-- text-align: right 按钮移到右侧 -->
|
|
|
+ <el-col :span="24" style="margin:15px 0;text-align:right;">
|
|
|
+ <el-button type="primary" size="mini" @click="dialogFormVisible = true">添加</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <template>
|
|
|
+ <el-table :data="list" style="width: 100%">
|
|
|
+ <el-table-column prop="name" label="名称" width="180"> </el-table-column>
|
|
|
+ <el-table-column prop="create_time" label="创建时间" width="180"> </el-table-column>
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button size="mini" @click="handleEdit(scope.row)">编辑</el-button>
|
|
|
+ <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
+ <!-- dialog与el-row实同一级的代码 不用和Button写在一起他们俩通过dialogTableVisible绑定在一起-->
|
|
|
+ <el-dialog title="轮播测试" :visible.sync="dialogFormVisible">
|
|
|
+ <el-form :model="form">
|
|
|
+ <el-form-item label="名称" :label-width="formLabelWidth">
|
|
|
+ <el-input v-model="form.name" auto-complete="off"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图片地址" :label-width="formLabelWidth">
|
|
|
+ <upload :limit="1" :data="form.filepath" type="filepath" :url="'/files/filepath/upload'" @upload="uploadSuccess"></upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="创建时间" :label-width="formLabelWidth">
|
|
|
+ <el-date-picker v-model="form.create_time" type="date" placeholder="选择日期"> </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="hide">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+//引用upload
|
|
|
+import upload from '@/components/frame/uploadone.vue';
|
|
|
+//引用breadcrumb组件来显示上面的小title
|
|
|
+import breadcrumb from '@c/common/breadcrumb.vue';
|
|
|
+//页面引用文件lunbo
|
|
|
const { mapActions: lunbo } = createNamespacedHelpers('lunbo');
|
|
|
export default {
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.route.meta.title };
|
|
|
+ },
|
|
|
name: 'index',
|
|
|
props: {},
|
|
|
- components: {},
|
|
|
+ components: {
|
|
|
+ breadcrumb,
|
|
|
+ upload,
|
|
|
+ },
|
|
|
data: function() {
|
|
|
return {
|
|
|
- tableData: [],
|
|
|
- dialogTableVisible: false,
|
|
|
dialogFormVisible: false,
|
|
|
- form: {
|
|
|
- name: '',
|
|
|
- filepath: '',
|
|
|
- create_time: '',
|
|
|
- },
|
|
|
formLabelWidth: '120px',
|
|
|
- value3: '',
|
|
|
+ form: {},
|
|
|
+ list: [],
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -71,59 +81,55 @@ export default {
|
|
|
async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
let res = await this.query({ skip, limit, ...info });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `tableData`, res.data);
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
}
|
|
|
},
|
|
|
+ hide() {
|
|
|
+ dialogFormVisible = false;
|
|
|
+ form = {};
|
|
|
+ },
|
|
|
async onSubmit() {
|
|
|
// this.form的数据集合用data变量接收
|
|
|
let data = this.form; // 判断data中有无id,有id:走修改,无id:走创建
|
|
|
if (data.id) {
|
|
|
const res = await this.update(data);
|
|
|
if (this.$checkRes(res)) {
|
|
|
- // vant组件中,消息提示方法
|
|
|
- this.$notify({
|
|
|
+ this.$message({
|
|
|
message: '修改成功',
|
|
|
type: 'success',
|
|
|
- }); // 执行完方法,修改再走一遍查询,查询数据更新之后的数据
|
|
|
- this.search();
|
|
|
+ });
|
|
|
}
|
|
|
} else {
|
|
|
const res = await this.create(data);
|
|
|
if (this.$checkRes(res)) {
|
|
|
- this.$notify({
|
|
|
- message: '添加成功',
|
|
|
+ this.$message({
|
|
|
+ message: '修改成功',
|
|
|
type: 'success',
|
|
|
});
|
|
|
- this.search();
|
|
|
}
|
|
|
}
|
|
|
+ this.hide();
|
|
|
},
|
|
|
- // handleEdit(index, row) {
|
|
|
- // console.log(index, row);
|
|
|
- // },
|
|
|
- async handleDelete(row) {
|
|
|
- // console.log(index, row);
|
|
|
- const res = await this.delete(row.id);
|
|
|
+ async handleDelete(data) {
|
|
|
+ let res = await this.delete(data.id);
|
|
|
if (this.$checkRes(res)) {
|
|
|
this.$message({
|
|
|
- message: '恭喜你,这是一条成功消息',
|
|
|
+ message: '创建成功',
|
|
|
type: 'success',
|
|
|
});
|
|
|
this.search();
|
|
|
}
|
|
|
},
|
|
|
- // dialogFormVisible() {
|
|
|
-
|
|
|
- // },
|
|
|
+ handleEdit(data) {
|
|
|
+ this.$set(this, `form`, data);
|
|
|
+ this.dialogFormVisible = true;
|
|
|
+ },
|
|
|
+ uploadSuccess({ type, data }) {
|
|
|
+ this.$set(this.form, `${type}`, data.uri);
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
|
- pageTitle() {
|
|
|
- return `${this.$route.meta.title}`;
|
|
|
- },
|
|
|
- },
|
|
|
- metaInfo() {
|
|
|
- return { title: this.$route.meta.title };
|
|
|
},
|
|
|
};
|
|
|
</script>
|