wxy 4 jaren geleden
bovenliggende
commit
3c5ed4245c
2 gewijzigde bestanden met toevoegingen van 107 en 12 verwijderingen
  1. 10 6
      src/store/lunbo.js
  2. 97 6
      src/views/test/index.vue

+ 10 - 6
src/store/lunbo.js

@@ -10,20 +10,24 @@ const state = () => ({});
 const mutations = {};
 
 const actions = {
-  async query({ commit }, { skip = 0, limit = undefined, ...info } = {}) {
-    const res = await this.$axios.$get(api.lunboInfo, { skip, limit, ...info });
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.lunboInfo}`, {
+      skip,
+      limit,
+      ...info,
+    });
     return res;
   },
-  async create({ commit }, { id, ...info } = {}) {
-    const res = await this.$axios.$post(`${api.lunboInfo}/${id}`, { ...info });
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.lunboInfo}`, payload);
     return res;
   },
   async fetch({ commit }, payload) {
     const res = await this.$axios.$get(`${api.lunboInfo}/${payload}`);
     return res;
   },
-  async update({ commit }, { dock_id, id, ...data }) {
-    const res = await this.$axios.$post(`${api.lunboInfo}/${dock_id}/check/${id}`, data);
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.lunboInfo}/update/${id}`, data);
     return res;
   },
   async delete({ commit }, payload) {

+ 97 - 6
src/views/test/index.vue

@@ -2,35 +2,126 @@
   <div id="index">
     <el-row>
       <el-col :span="24">
-        <p>index</p>
+        <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
+        <el-col :span="24" class="container">
+          <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">
+            <el-table :data="list" style="width: 100%">
+              <el-table-column prop="name" label="名称" align="center"> </el-table-column>
+              <el-table-column prop="create_time" label="创建时间" align="center"> </el-table-column>
+              <el-table-column label="操作" align="center">
+                <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>
+          </el-col>
+        </el-col>
       </el-col>
     </el-row>
+    <el-dialog title="轮播图" :visible.sync="dialogFormVisible">
+      <el-form :model="form">
+        <el-form-item label="名称" label-width="120px">
+          <el-input v-model="form.name" autocomplete="off"></el-input>
+        </el-form-item>
+        <el-form-item label="图片地址" label-width="120px">
+          <upload :limit="1" :data="form.filepath" type="filepath" :url="'/files/filepath/upload'" @upload="uploadSuccess"></upload>
+        </el-form-item>
+        <el-form-item label="创建时间" label-width="120px">
+          <el-date-picker v-model="form.create_time" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd"> </el-date-picker>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" style="text-align:center">
+        <el-button @click="quSeve()">取 消</el-button>
+        <el-button type="primary" @click="onSubmit()">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
+import upload from '@/components/frame/uploadone.vue';
+import breadcrumb from '@c/common/breadcrumb.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: lunbo } = createNamespacedHelpers('lunbo');
 export default {
-    metaInfo() {
+  metaInfo() {
     return { title: this.$route.meta.title };
   },
   name: 'index',
   props: {},
-  components: {},
+  components: {
+    breadcrumb,
+    upload,
+  },
   data: function() {
-    return {};
+    return {
+      list: [],
+      dialogFormVisible: false,
+      form: {},
+    };
   },
   created() {
     this.search();
   },
   methods: {
-    ...lunbo(['query']),
+    ...lunbo(['query', 'fetch', 'create', 'update', 'delete']),
+    // 查询列表
     async search({ skip = 0, limit = 10, ...info } = {}) {
       let res = await this.query({ skip, limit, ...info });
       if (this.$checkRes(res)) {
-        console.log(res);
+        this.$set(this, `list`, res.data);
+      }
+    },
+    // 提交
+    async onSubmit() {
+      let data = this.form;
+      if (data.id) {
+        let res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '修改成功',
+            type: 'success',
+          });
+        }
+      } else {
+        let res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '创建成功',
+            type: 'success',
+          });
+        }
       }
+      this.quSeve();
+    },
+    // 取消
+    quSeve() {
+      this.form = {};
+      this.dialogFormVisible = false;
+    },
+    // 修改
+    handleEdit(data) {
+      this.dialogFormVisible = true;
+      this.$set(this, `form`, data);
+    },
+    // 删除
+    async handleDelete(data) {
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '创建成功',
+          type: 'success',
+        });
+        this.search();
+      }
+    },
+    // 图片
+    uploadSuccess({ type, data }) {
+      this.$set(this.form, `${type}`, data.uri);
     },
   },
   computed: {