Skip to content

Commit 1b30107

Browse files
committed
修复Grid隐藏操作栏问题
1 parent 819f337 commit 1b30107

File tree

9 files changed

+224
-82
lines changed

9 files changed

+224
-82
lines changed

docs/grid.md

+8-14
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ $grid->column('permissions.name')->component(Tag::make()->type('info'));
644644
##### 最小宽度
645645

646646
```php
647-
$grid->actionWidth(180)
647+
$grid->actionWidth(180);
648648
```
649649

650650
##### 操作栏固定
@@ -661,15 +661,17 @@ $grid->actionAlign('right');//left right center
661661

662662
##### 操作栏名称
663663

664-
> `v0.1.12 `以上版本
665-
666664
```php
667665
$grid->actionLabel('操作');
668666
```
669667

670-
#### 获取当前行的下标
668+
##### 隐藏所有操作
669+
670+
```php
671+
$grid->hideActions();
672+
```
671673

672-
v0.1.5 +
674+
#### 获取当前行的下标
673675

674676
```php
675677
$actions->getKey();
@@ -683,12 +685,6 @@ $grid->actionLabel('操作');
683685
$actions->getRow();
684686
```
685687

686-
#### 隐藏所有操作
687-
688-
```php
689-
$actions->hideActions()
690-
```
691-
692688
#### 隐藏详情操作
693689

694690
当前版本暂无详情功能
@@ -718,14 +714,12 @@ $actions->editAction()->disabled(true);//获取编辑操作实例,并置属性
718714
$actions->deleteAction()->message("确定要删除吗,删除不可恢复?");//获取删除操作实例
719715
```
720716

721-
722-
723717
#### 添加自定义操作
724718

725719
创建自定义操作请查看 [如何创建自定义操作](./custom?id=%e8%a1%a8%e6%a0%bc%e6%93%8d%e4%bd%9c%e7%bb%84%e4%bb%b6)
726720

727721
```php
728-
$actions->add(new MyAction())
722+
$actions->add(ActionButton::make("操作名称")->...);
729723
```
730724

731725
## 批量操作

public/3.js

+188-52
Large diffs are not rendered by default.

public/app.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"/app.js": "/app.js?id=50a352ebba034d8815f8",
2+
"/app.js": "/app.js?id=44b53029cb7cbb645934",
33
"/manifest.js": "/manifest.js?id=8991394a854ee5cdffc3",
44
"/vendor.js": "/vendor.js?id=159feaa1cb9cfd111212"
55
}

resources/js/components/grid/Table.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
</el-table-column>
179179
</template>
180180
<el-table-column
181+
v-if="!attrs.attributes.hideActions"
181182
:label="attrs.attributes.actionLabel"
182183
prop="grid_actions"
183184
:fixed="attrs.attributes.actionFixed"
@@ -218,7 +219,7 @@
218219
<DialogForm
219220
ref="DialogGridFrom"
220221
v-if="attrs.dialogForm"
221-
:dialogFormWidth='attrs.dialogFormWidth'
222+
:dialogFormWidth="attrs.dialogFormWidth"
222223
:dialogForm="attrs.dialogForm"
223224
:dialogTitle="attrs.dialogTitle"
224225
/>
@@ -306,7 +307,7 @@ export default {
306307
this.loading = status;
307308
});
308309
309-
this.$bus.on("showDialogGridFrom", ({ isShow ,key}) => {
310+
this.$bus.on("showDialogGridFrom", ({ isShow, key }) => {
310311
this.$refs["DialogGridFrom"].dialogVisible = isShow;
311312
this.$refs["DialogGridFrom"].key = key;
312313
});

src/Grid.php

-10
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,6 @@ public function getDialogForm()
281281
}
282282

283283

284-
/**
285-
* 隐藏行操作
286-
* @return $this
287-
*/
288-
public function hideActions()
289-
{
290-
$this->actions->hideActions();
291-
return $this;
292-
}
293-
294284
public function top($closure)
295285
{
296286
$this->top = new Content();

src/Grid/Concerns/HasGridAttributes.php

+15
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,21 @@ public function actionFixed($actionFixed)
230230
return $this;
231231
}
232232

233+
/**
234+
* 隐藏操作栏
235+
* @return $this
236+
*/
237+
public function hideActions()
238+
{
239+
$this->attributes->hideActions = true;
240+
return $this;
241+
}
242+
public function getHideActions()
243+
{
244+
return $this->attributes->hideActions;
245+
246+
}
247+
233248
/**
234249
* 表格数据是否存入vuex
235250
* @param $dataVuex

src/Grid/Model.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,11 @@ protected function displayData($data)
413413
data_set($item, $column->getName(), $n_value);
414414
}
415415
}
416-
data_set($item, 'grid_actions', $this->grid->getActions($row, $key));
416+
if (!$this->grid->getHideActions()) {
417+
data_set($item, 'grid_actions', $this->grid->getActions($row, $key));
418+
}
419+
420+
417421
data_set($item, $this->grid->getKeyName(), data_get($row, $this->grid->getKeyName()));
418422

419423
//如果存在下级

src/Grid/Table/Attributes.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Attributes
4848
public $rowKey = 'id';
4949

5050

51-
public $hideCreateButton = false;
51+
protected $hideCreateButton = false;
5252

5353
public $draggable = false;
5454
public $draggableUrl;
@@ -57,6 +57,8 @@ class Attributes
5757

5858
public $treeProps = ['hasChildren' => 'hasChildren', 'children' => 'children'];
5959

60+
61+
public $hideActions=false;
6062
public $actionWidth;
6163
public $actionLabel = "操作";
6264
public $actionFixed;

0 commit comments

Comments
 (0)