lrf402788946 5 năm trước cách đây
mục cha
commit
1ca7a34fec
3 tập tin đã thay đổi với 11 bổ sung5 xóa
  1. 1 0
      components/form.md
  2. 6 1
      components/form.vue
  3. 4 4
      store/other.js

+ 1 - 0
components/form.md

@@ -28,6 +28,7 @@
 |custom|Boolean|`-`|否|是否使用自定义插槽|
 |tip|String|`-`|否|提示语,例如:请输入11位电话号码|
 |labelWidth|String|`120px`|否|表单label宽度,element的,默认120px|
+|format|Function|`-`|否|当type = text 时需要将该字段内容转换,可以使用format|
 
 
 

+ 6 - 1
components/form.vue

@@ -76,7 +76,12 @@
                 </el-tooltip>
               </template>
               <template v-else>
-                {{ form[item.model] }}
+                <template v-if="item.format">
+                  {{ item.format(form[item.model]) }}
+                </template>
+                <template v-else>
+                  {{ form[item.model] }}
+                </template>
               </template>
             </template>
             <template v-else>

+ 4 - 4
store/other.js

@@ -4,15 +4,15 @@ import _ from 'lodash';
 import axios from 'axios';
 Vue.use(Vuex);
 const api = {
-  calendar: `/jh/calendar/year`,
+  calendar: `/api/train/common/findyear`,
 };
 const state = () => ({});
 const mutations = {};
 
 const actions = {
-  async calendar({ commit }, { key, year } = {}) {
-    const res = await this.$axios.$get(`${api.calendar}`, { key, year });
-    if (res.error_code == '0') return res.result.data;
+  async calendar({ commit }, { year } = {}) {
+    const res = await this.$axios.$get(`${api.calendar}`, { year });
+    if (res.errcode == '0') return res.data;
     else this.$message.error(res.reason || '万年历接口请求失败');
   },
 };