lrf402788946 5 anni fa
parent
commit
0919e590e5
3 ha cambiato i file con 16 aggiunte e 3 eliminazioni
  1. 5 2
      components/data-table.vue
  2. 10 0
      components/form.vue
  3. 1 1
      components/table.md

+ 5 - 2
components/data-table.vue

@@ -15,7 +15,7 @@
                     type="text"
                     :icon="item.icon || ''"
                     size="mini"
-                    @click="handleOpera(row, item.method, item.confirm, item.methodZh)"
+                    @click="handleOpera(row, item.method, item.confirm, item.methodZh, item.label)"
                   ></el-button>
                 </el-tooltip>
               </template>
@@ -60,7 +60,10 @@ export default {
         } else return cellValue;
       }
     },
-    handleOpera(data, method, confirm = false, methodZh = '操作') {
+    handleOpera(data, method, confirm = false, methodZh, label) {
+      if (!methodZh) {
+        methodZh = label;
+      }
       if (confirm) {
         this.$confirm(`您确认${methodZh}该数据?`, '提示', {
           confirmButtonText: '确定',

+ 10 - 0
components/form.vue

@@ -6,6 +6,16 @@
           <template v-if="item.type === `date` || item.type === `datetime`">
             <el-date-picker v-model="form[item.model]" :type="item.type" placeholder="选择择" format="yyyy-MM-dd" value-format="yyyy-MM-dd"> </el-date-picker>
           </template>
+          <template v-else-if="item.type === `year` || item.type === `week` || item.type === `day`">
+            <el-date-picker
+              v-model="form[item.model]"
+              :type="item.type"
+              placeholder="选择择"
+              :format="`${item.type === 'year' ? 'yyyy' : item.type === 'week' ? 'MM' : 'dd'}`"
+              :value-format="`${item.type === 'year' ? 'yyyy' : item.type === 'week' ? 'MM' : 'dd'}`"
+            >
+            </el-date-picker>
+          </template>
           <template v-else-if="item.type === 'radio'">
             <el-radio-group v-model="form[item.model]" size="mini" v-bind="item.options">
               <slot name="radios" v-bind="{ item, form, fieldChange }"></slot>

+ 1 - 1
components/table.md

@@ -24,5 +24,5 @@
 |icon|String|`-`|否|图标|
 |method|String|`-`|是|此按钮连接的父级方法($emit)|
 |confirm|Boolean|`-`|否|是否需要确认提示|
-|methodZh|String|`-`|否|确认提示的操作文字|
+|methodZh|String|label|否|确认提示的操作文字|
 |display|Function|`-`|否|控制按钮是否显示(目前为简单版,只是根据此条数据中的内容判断,以后要是有需求会修改成toFormat的形式)|