guhongwei пре 4 година
родитељ
комит
bdf5385cef
3 измењених фајлова са 70 додато и 25 уклоњено
  1. 2 0
      src/store/index.js
  2. 54 0
      src/store/testmess.js
  3. 14 25
      src/views/company/index.vue

+ 2 - 0
src/store/index.js

@@ -4,6 +4,7 @@ import * as ustate from './user/state';
 import * as umutations from './user/mutations';
 import login from './login';
 import company from './company';
+import testmess from './testmess';
 
 Vue.use(Vuex);
 
@@ -14,5 +15,6 @@ export default new Vuex.Store({
   modules: {
     login,
     company,
+    testmess,
   },
 });

+ 54 - 0
src/store/testmess.js

@@ -0,0 +1,54 @@
+//第一步
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  //接口地址
+  company: `/api/servicetest/testmess`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  //查询列表 skip:第一页,limit:第一页显示的数据,info:其余查询参数
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    //连接接口。。。。
+    const res = await this.$axios.$get(`${api.company}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    //把数据集合res返回
+    return res;
+  },
+  //创建数据  payload是添加form表单中的数据集合  创建数据的时候需要拿到form表单里面的数据
+  async create({ commit }, payload) {
+    //通过$axios提交post请求????
+    const res = await this.$axios.$post(`${api.company}`, payload);
+    return res;
+  },
+  //查询详情,payload:参数位,一般传当前数据id
+  async fetch({ commit }, payload) {
+    //有/一般都是路径
+    const res = await this.$axios.$get(`${api.company}/${payload}`);
+    return res;
+  },
+  //修改:id: 当前数据id, data: 当前修改数据的新form表单
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.company}/update/${id}`, data);
+    return res;
+  },
+  //删除:payload:参数位,一般传当前数据id
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.company}/${payload}`);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 14 - 25
src/views/company/index.vue

@@ -24,7 +24,7 @@
           </template>
         </template> -->
         <!-- 下拉单选 -->
-        <template #options="{item}">
+        <!-- <template #options="{item}">
           <template v-if="item.model == 'type'">
             <template v-for="(i, index) in typeList">
               <el-option :key="index" :label="`${i.name}`" :value="i.id"></el-option>
@@ -67,7 +67,7 @@
               @delete="uploadDelete"
             ></upload>
           </template>
-        </template>
+        </template> -->
       </data-form>
     </el-dialog>
   </div>
@@ -79,7 +79,7 @@ import dataTable from '@/components/frame/filter-page-table.vue';
 import dataForm from '@/components/frame/form.vue';
 import upload from '@/components/frame/uploadone.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions: company } = createNamespacedHelpers('company');
+const { mapActions: testmess } = createNamespacedHelpers('testmess');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -90,7 +90,7 @@ export default {
     breadcrumb,
     dataTable,
     dataForm,
-    upload,
+    // upload,
   },
   data: function() {
     return {
@@ -107,34 +107,23 @@ export default {
         },
       ],
       fields: [
-        { label: '企业名称', prop: 'company', filter: 'input' },
-        { label: '电话', prop: 'mobile' },
-        {
-          label: '企业信息类型',
-          prop: 'type',
-          format: i => {
-            return i == '0' ? '技术' : i == '1' ? '产品' : '服务';
-          },
-        },
+        { label: '标题', prop: 'title' },
+        { label: '发布时间', prop: 'publish_time' },
+        { label: '来源', prop: 'origin' },
+        { label: '内容', prop: 'content' },
       ],
       list: [],
       total: 0,
       // 增加菜单
       dialog: false,
       formFields: [
-        { label: '企业名称', required: true, model: 'company' },
-        { label: '电话', required: true, model: 'mobile', options: { minlength: 11, maxlength: 11 } },
-        { label: '类型', required: true, model: 'type', type: 'select' },
-        { label: '图片(单张)', required: false, model: 'file', custom: true },
-        { label: '视频(视频)', required: false, model: 'video', custom: true },
-        { label: '图片数组(数组)', required: false, model: 'image', custom: true },
+        { label: '标题', required: true, model: 'title' },
+        { label: '发布时间', required: true, model: 'publish_time', type: 'date' },
+        { label: '来源', required: true, model: 'origin' },
+        { label: '内容', required: true, model: 'content' },
       ],
       form: {},
-      rules: {
-        company: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
-        mobile: [{ required: true, message: '请输入电话', trigger: 'blur' }],
-        type: [{ required: true, message: '请输入电话', trigger: 'change' }],
-      },
+      rules: {},
       // 类型
       typeList: [
         {
@@ -156,7 +145,7 @@ export default {
     this.search();
   },
   methods: {
-    ...company(['query', 'fetch', 'create', 'update', 'delete']),
+    ...testmess(['query', 'fetch', 'create', 'update', 'delete']),
     // 查询列表
     async search({ skip = 0, limit = 10, ...info } = {}) {
       let res = await this.query({ skip, limit, ...info });