lrf402788946 5 лет назад
Родитель
Сommit
6c1b1d636a
2 измененных файлов с 7 добавлено и 3 удалено
  1. 6 2
      components/data-table.vue
  2. 1 1
      components/table.md

+ 6 - 2
components/data-table.vue

@@ -69,11 +69,15 @@ export default {
       }
     },
     handleOpera(data, method, confirm = false, methodZh, label, index) {
-      if (!methodZh) {
+      let self = true;
+      if (_.isFunction(methodZh)) {
+        methodZh = methodZh(data);
+      } else if (!_.isString(methodZh)) {
         methodZh = label;
+        self = false;
       }
       if (confirm) {
-        this.$confirm(`您确认${methodZh}该数据?`, '提示', {
+        this.$confirm(self ? methodZh : `您确认${methodZh}该数据?`, '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
           type: 'warning',

+ 1 - 1
components/table.md

@@ -25,7 +25,7 @@
 |icon|String|`-`|否|图标|
 |method|String|`-`|是|此按钮连接的父级方法($emit)|
 |confirm|Boolean|`-`|否|是否需要确认提示|
-|methodZh|String|label|否|确认提示的操作文字|
+|methodZh|String/Function|label|否|确认提示的操作文字,1,Function参数为这条数据,自己随意组合;2,String为纯自定义字符串,需要自己写整个提示语;3,默认,使用label字段提示|
 |display|Function|`-`|否|控制按钮是否显示(目前为简单版,只是根据此条数据中的内容判断,以后要是有需求会修改成toFormat的形式)|
 
 >methods