Pārlūkot izejas kodu

feat: 修改列表页面模板

aXin-0810 2 gadi atpakaļ
vecāks
revīzija
7f2ac62d4a
1 mainītis faili ar 14 papildinājumiem un 3 dzēšanām
  1. 14 3
      src/components/template/template-page-1.vue

+ 14 - 3
src/components/template/template-page-1.vue

@@ -86,7 +86,7 @@ export default {
     // 获取操作记录的主键字段
     operationRecordkey: {
       type: String,
-      default: 'id'
+      default: ''
     },
     // 操作按钮单元格宽度
     operationColumnWidth: {
@@ -97,6 +97,10 @@ export default {
     cstomClumn: {
       type: Function
     },
+    // 结构数据钩子
+    fieldBeansHook: {
+      type: Function
+    },
     // 菜单名称
     customModuleName: {
       type: String,
@@ -135,7 +139,8 @@ export default {
       columnList: [],
       showTable: false,
       codeGather: {},
-      frontCodes: []
+      frontCodes: [],
+      pk: ''
     }
   },
   computed: {
@@ -164,7 +169,7 @@ export default {
             size="mini"
             type="text"
             onClick={() => {
-              console.log(row[this.operationRecordkey])
+              console.log(row[this.operationRecordkey || this.pk || 'id'])
             }}
           >
             操作记录
@@ -228,7 +233,13 @@ export default {
               this.showTable = true
             })
           }
+          if (this.fieldBeansHook) {
+            res.fieldBeans = this.fieldBeansHook(res.fieldBeans) || res.fieldBeans
+          }
           for (var item of res.fieldBeans) {
+            if (item.pk) {
+              this.pk = item.colName
+            }
             if (item.frontCode && !~this.frontCodes.indexOf(item.frontCode)) {
               this.frontCodes.push(item.frontCode)
             }