Skip to content

Commit

Permalink
修复Grid隐藏操作栏问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallRuralDog committed Jun 2, 2020
1 parent 819f337 commit 1b30107
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 82 deletions.
22 changes: 8 additions & 14 deletions docs/grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ $grid->column('permissions.name')->component(Tag::make()->type('info'));
##### 最小宽度

```php
$grid->actionWidth(180)
$grid->actionWidth(180);
```

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

##### 操作栏名称

> `v0.1.12 `以上版本
```php
$grid->actionLabel('操作');
```

#### 获取当前行的下标
##### 隐藏所有操作

```php
$grid->hideActions();
```

v0.1.5 +
#### 获取当前行的下标

```php
$actions->getKey();
Expand All @@ -683,12 +685,6 @@ $grid->actionLabel('操作');
$actions->getRow();
```

#### 隐藏所有操作

```php
$actions->hideActions()
```

#### 隐藏详情操作

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



#### 添加自定义操作

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

```php
$actions->add(new MyAction())
$actions->add(ActionButton::make("操作名称")->...);
```

## 批量操作
Expand Down
240 changes: 188 additions & 52 deletions public/3.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/app.js": "/app.js?id=50a352ebba034d8815f8",
"/app.js": "/app.js?id=44b53029cb7cbb645934",
"/manifest.js": "/manifest.js?id=8991394a854ee5cdffc3",
"/vendor.js": "/vendor.js?id=159feaa1cb9cfd111212"
}
5 changes: 3 additions & 2 deletions resources/js/components/grid/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
</el-table-column>
</template>
<el-table-column
v-if="!attrs.attributes.hideActions"
:label="attrs.attributes.actionLabel"
prop="grid_actions"
:fixed="attrs.attributes.actionFixed"
Expand Down Expand Up @@ -218,7 +219,7 @@
<DialogForm
ref="DialogGridFrom"
v-if="attrs.dialogForm"
:dialogFormWidth='attrs.dialogFormWidth'
:dialogFormWidth="attrs.dialogFormWidth"
:dialogForm="attrs.dialogForm"
:dialogTitle="attrs.dialogTitle"
/>
Expand Down Expand Up @@ -306,7 +307,7 @@ export default {
this.loading = status;
});
this.$bus.on("showDialogGridFrom", ({ isShow ,key}) => {
this.$bus.on("showDialogGridFrom", ({ isShow, key }) => {
this.$refs["DialogGridFrom"].dialogVisible = isShow;
this.$refs["DialogGridFrom"].key = key;
});
Expand Down
10 changes: 0 additions & 10 deletions src/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,6 @@ public function getDialogForm()
}


/**
* 隐藏行操作
* @return $this
*/
public function hideActions()
{
$this->actions->hideActions();
return $this;
}

public function top($closure)
{
$this->top = new Content();
Expand Down
15 changes: 15 additions & 0 deletions src/Grid/Concerns/HasGridAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ public function actionFixed($actionFixed)
return $this;
}

/**
* 隐藏操作栏
* @return $this
*/
public function hideActions()
{
$this->attributes->hideActions = true;
return $this;
}
public function getHideActions()
{
return $this->attributes->hideActions;

}

/**
* 表格数据是否存入vuex
* @param $dataVuex
Expand Down
6 changes: 5 additions & 1 deletion src/Grid/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,11 @@ protected function displayData($data)
data_set($item, $column->getName(), $n_value);
}
}
data_set($item, 'grid_actions', $this->grid->getActions($row, $key));
if (!$this->grid->getHideActions()) {
data_set($item, 'grid_actions', $this->grid->getActions($row, $key));
}


data_set($item, $this->grid->getKeyName(), data_get($row, $this->grid->getKeyName()));

//如果存在下级
Expand Down
4 changes: 3 additions & 1 deletion src/Grid/Table/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Attributes
public $rowKey = 'id';


public $hideCreateButton = false;
protected $hideCreateButton = false;

public $draggable = false;
public $draggableUrl;
Expand All @@ -57,6 +57,8 @@ class Attributes

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


public $hideActions=false;
public $actionWidth;
public $actionLabel = "操作";
public $actionFixed;
Expand Down

0 comments on commit 1b30107

Please sign in to comment.