From d46bf70433c966d0607e02a3cff01f76b2099607 Mon Sep 17 00:00:00 2001 From: juzi <819872918@qq.com> Date: Mon, 26 Dec 2022 19:23:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0table=E5=8D=95=E9=80=89?= =?UTF-8?q?=E7=9A=84=E5=8F=97=E6=8E=A7=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 14 +++++++------- package.json | 2 +- src/views/table/singleHead.vue | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2f2c824..dfd884f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "code-brick-wd", "version": "0.1.0", "dependencies": { - "code-brick-zj": "^0.0.1", + "code-brick-zj": "^0.0.4", "core-js": "^3.8.3", "element-ui": "^2.15.12", "vue": "^2.6.14", @@ -4007,9 +4007,9 @@ } }, "node_modules/code-brick-zj": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/code-brick-zj/-/code-brick-zj-0.0.1.tgz", - "integrity": "sha512-XLvQEoiVWESDirkMKVKCIdH1jW3drkSS472uMWd1m6Ul5UVTUAiJvBQ15kEo+L7w8Zt7cC5ErF+laYHhNeoaIA==" + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/code-brick-zj/-/code-brick-zj-0.0.4.tgz", + "integrity": "sha512-KSQ/drfIpoZKTrcARtuwG+6olde7fBYl+38Kialqa1NSoSDhPMqXTVw2N4KfA4MlucXQ/s3KZjfUsmKVZ70KkA==" }, "node_modules/color-convert": { "version": "1.9.3", @@ -14473,9 +14473,9 @@ } }, "code-brick-zj": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/code-brick-zj/-/code-brick-zj-0.0.1.tgz", - "integrity": "sha512-XLvQEoiVWESDirkMKVKCIdH1jW3drkSS472uMWd1m6Ul5UVTUAiJvBQ15kEo+L7w8Zt7cC5ErF+laYHhNeoaIA==" + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/code-brick-zj/-/code-brick-zj-0.0.4.tgz", + "integrity": "sha512-KSQ/drfIpoZKTrcARtuwG+6olde7fBYl+38Kialqa1NSoSDhPMqXTVw2N4KfA4MlucXQ/s3KZjfUsmKVZ70KkA==" }, "color-convert": { "version": "1.9.3", diff --git a/package.json b/package.json index f44264e..b165c48 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "lint": "vue-cli-service lint" }, "dependencies": { - "code-brick-zj": "^0.0.1", + "code-brick-zj": "^0.0.4", "core-js": "^3.8.3", "element-ui": "^2.15.12", "vue": "^2.6.14", diff --git a/src/views/table/singleHead.vue b/src/views/table/singleHead.vue index 1aea838..116e309 100644 --- a/src/views/table/singleHead.vue +++ b/src/views/table/singleHead.vue @@ -318,7 +318,11 @@

单选

+ 选中第二行 + 取消选中 highlight-current-row属性即可实现单选。 之后由current-change事件来管理选中时触发的事件,它会传入currentRowoldCurrentRow。 + 使用按钮选中取消,必须要传id,id的值是唯一的,id的值需要和setCurrent中第一参数一样。
+              <el-button size="small" @click="setCurrent(1)">选中第二行</el-button>
+              <el-button size="small" @click="setCurrent(-1)">取消选中</el-button>
               <template>
                 <base-table
+                  ref="palletTable1"
+                  id="palletTable"
                   :table-props="tableProps"
                   :table-data="tableData"
                   :page="1"
@@ -345,6 +354,10 @@
                   @current-change="handleCurrentChange"
                 />
               </template>
+              methods:
+              setCurrent(index) {
+                this.$refs.palletTable1.setCurrent('palletTable', index)
+              }
             
@@ -1168,8 +1181,8 @@ export default { } return '' }, - setCurrent(row) { - this.$refs.singleTable.setCurrentRow(this.tableData[row]) + setCurrent(index) { + this.$refs.palletTable1.setCurrent('palletTable', index) }, handleCurrentChange(val) { console.log(val)