周兴 2 лет назад
Родитель
Сommit
35c8b470ae
1 измененных файлов с 45 добавлено и 2 удалено
  1. 45 2
      src/components/base/edit-table/edit-table.vue

+ 45 - 2
src/components/base/edit-table/edit-table.vue

@@ -530,6 +530,32 @@
           </template>
         </vxe-column>
 
+        <!-- 文本按钮 -->
+        <vxe-column v-if="colItem.type === 'textButton'" :params="{type:'textButton'}"
+                    :title="colItem.title?colItem.title:$t(colItem.field)"
+                    :type="colItem.type"
+                    :width="colItem.width?colItem.width:vm.$config.columnWidth"
+                    :min-width="colItem.minWidth?colItem.minWidth:vm.$config.columnWidthMin"
+                    :field="$t(colItem.field)" :edit-render="{autofocus: '.vxe-input--inner'}">
+          <template #default="{ row,rowIndex }">
+            <div style="display: flex" v-show="setCellCanInput( row ,colItem)">
+              <vxe-input :ref="colItem.field+'_default_'+rowIndex" v-model="row[colItem.field]"
+                         :content="row[colItem.field]"
+                         :readonly="true"/>
+              <vxe-button class-name="text-button-class" content="测试"
+                          @click.native="buttonClick(colItem,rowIndex,row)"></vxe-button>
+            </div>
+          </template>
+          <template #edit="{ row,rowIndex }">
+            <div style="display: flex" v-show="setCellCanInput( row ,colItem)">
+              <vxe-input :ref="colItem.field+'_default_'+rowIndex" v-model="row[colItem.field]"
+                         :content="row[colItem.field]"
+                         :readonly="true"/>
+              <vxe-button class-name="text-button-class" content="测试" @click.native="buttonClick(colItem,rowIndex,row)"></vxe-button>
+            </div>
+          </template>
+        </vxe-column>
+
         <!--      checkbox-->
         <!--        <vxe-column type="checkbox" width="60" v-if="colItem.type === 'checkbox'"></vxe-column>-->
       </div>
@@ -564,7 +590,7 @@ export default {
       default: undefined,
     },
     // 标题说明
-    titleInfo:{
+    titleInfo: {
       type: String,
       default: undefined,
     },
@@ -958,7 +984,7 @@ export default {
      * @date   : 2023/5/29 14:25
      */
     changeColumnTitle(field, title) {
-      if(this.$refs['title_' + field] && this.$refs['title_' + field].length > 0){
+      if (this.$refs['title_' + field] && this.$refs['title_' + field].length > 0) {
         this.$refs['title_' + field][0].innerText = title;
       }
     },
@@ -3069,4 +3095,21 @@ export default {
   margin-top: 1px !important;
 }
 
+.text-button-class {
+  margin-left: 0 !important;
+  width: 65px !important;
+  background-color: #17a2b8 !important;
+  color: white !important;
+}
+
+.vxe-table--render-default .vxe-body--row.row--current .vxe-body--column .vxe-cell .text-button-class {
+  background-color: #17a2b8 !important;
+  color: white !important;
+}
+
+.vxe-table--render-default .vxe-body--row.row--checked, .vxe-table--render-default .vxe-body--row.row--radio .vxe-body--column .vxe-cell .text-button-class {
+  background-color: #17a2b8 !important;
+  color: white !important;
+}
+
 </style>