lrf402788946 5 vuotta sitten
vanhempi
commit
e3ba2ab5d0
4 muutettua tiedostoa jossa 23 lisäystä ja 1 poistoa
  1. 11 1
      components/data-table.vue
  2. 2 0
      components/table.md
  3. 5 0
      store/bedroom.js
  4. 5 0
      store/student.js

+ 11 - 1
components/data-table.vue

@@ -13,7 +13,17 @@
     >
       <el-table-column type="selection" width="55" v-if="select" prop="id" :reserve-selection="true"> </el-table-column>
       <template v-for="(item, index) in fields">
-        <el-table-column :key="index" align="center" :label="item.label" :prop="item.prop" :formatter="toFormatter" sortable></el-table-column>
+        <template v-if="item.custom">
+          <el-table-column :key="index" align="center" :label="item.label" v-bind="item.options">
+            <template v-slot="{ row, $index }">
+              <slot name="custom" v-bind="{ item, row }"></slot>
+            </template>
+          </el-table-column>
+        </template>
+        <template v-else>
+          <el-table-column :key="index" align="center" :label="item.label" :prop="item.prop" :formatter="toFormatter" sortable v-bind="item.options">
+          </el-table-column>
+        </template>
       </template>
       <template v-if="opera.length > 0">
         <el-table-column label="操作" align="center">

+ 2 - 0
components/table.md

@@ -17,6 +17,8 @@
 |label|String|`-`|是|列名称|
 |prop|String|`-`|是|字段名称|
 |format|Function/String|`-`|否|Function类型:数据需要过滤则将过滤方法写在这;String类型:走toFormat方法,参数位(model=>字段名,value=>值)|
+|custom|Boolean|false|否|自定义输出|
+|options|Object|`-`|否|添加额外属性,比如说样式之类的|
 
 >opera
 >>

+ 5 - 0
store/bedroom.js

@@ -5,6 +5,7 @@ import _ from 'lodash';
 Vue.use(Vuex);
 const api = {
   interface: `/api/train/bedroom`,
+  apart: `/api/train/bedroom/apart`,
 };
 const state = () => ({});
 const mutations = {};
@@ -30,6 +31,10 @@ const actions = {
     const res = await this.$axios.$delete(`${api.interface}/${payload}`);
     return res;
   },
+  async apart({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.apart}`, payload);
+    return res;
+  },
   async mergeRequest({ commit, dispatch }, { method, data }) {
     let toRequest = () => {
       let res = [];

+ 5 - 0
store/student.js

@@ -6,6 +6,7 @@ Vue.use(Vuex);
 const api = {
   interface: `/api/train/student`,
   noClass: '/api/train/student/seek',
+  bedroom: `/api/train/student/findbedroom`,
 };
 const state = () => ({});
 const mutations = {};
@@ -35,6 +36,10 @@ const actions = {
     const res = await this.$axios.$get(`${api.noClass}`, payload);
     return res;
   },
+  async bedRoom({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.bedroom}`, payload);
+    return res;
+  },
   async mergeRequest({ commit, dispatch }, { method, data }) {
     let toRequest = () => {
       let res = [];