Skip to content

Commit

Permalink
修复 Grid 排序
Browse files Browse the repository at this point in the history
修复 Grid 批量删除
修复 Grid 快捷搜索
修复 Grid ToolbarButton UI间距
ActionButton 添加 message 属性
  • Loading branch information
SmallRuralDog committed Mar 23, 2020
1 parent 1c394e1 commit ca4bbee
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 95 deletions.
3 changes: 2 additions & 1 deletion config/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@
'role_permissions_table' => 'admin_role_permissions',
'role_menu_table' => 'admin_role_menu',
],
//操作日志
'operation_log' => [
'enable' => false,
'enable' => true,
/*
* Only logging allowed methods in the list
*/
Expand Down
3 changes: 2 additions & 1 deletion docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ Icon::make()
ActionButton::make("ActionName")
->order(3) //排序 越大越靠前
->icon("icon-class-name")//图标
>handler("route")
->message("确认操作提示信息")
->handler("route")
->uri("WeChat/manage/{app_id}")//路径,{xxx}会被自动替换成当前行的对应值,支持 ?x=x 参数
//调用代码
$grid->actions(function (Grid\Actions $actions) {
Expand Down
12 changes: 11 additions & 1 deletion docs/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,17 @@ destroyed() {
### 刷新表格

```js
this.$bus.emit("tableReload")
this.$bus.emit("tableReload");
```

设置表格加载状态

```php
this.$bus.emit("tableSetLoading",true);

this.$bus.emit("tableSetLoading",false);
```



更多事件正在开发中......
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=6194a656d0d6c596f473",
"/app.js": "/app.js?id=be0e1de324934e54f7a3",
"/manifest.js": "/manifest.js?id=3c768977c2574a34506e",
"/vendor.js": "/vendor.js?id=38a9d2f43b98aaf4f7dd"
}
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Laravel-Vue-Admin 是一个开箱即用的Laravel后台扩展

前后端分离,后端控制前端组件,无需编写vue即可创建一个`vue`+`vuex`+`vue-route`+`elment-ui`+`laravel`的项目

丰富的`表单` `表格`组件,强大的自定义组件功能。

只需体验三分钟,你就会爱上这款 游戏


[中文文档](https://smallruraldog.github.io/laravel-vue-admin/#/)

Expand Down
15 changes: 7 additions & 8 deletions resources/js/components/grid/BatchActions/Index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<el-dropdown class="mr-10">
<el-button :disabled="rows.length<=0">
<span>已选择 {{rows.length}} 项</span>
<el-button :disabled="rows.length <= 0">
<span>已选择 {{ rows.length }} 项</span>
<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
Expand All @@ -26,17 +26,16 @@ export default {
)
.then(() => {
const deleteUrl = this.routers.resource + "/" + this.keys;
const msg = this.$Message.loading({
content: "正在删除...",
duration: 0
});
this.$bus.emit("tableSetLoading", true);
this.$http
.delete(deleteUrl)
.then(({ code }) => {
code === 200 && this.$bus.emit("tableReload");
})
.finally(() => {
msg();
this.$bus.emit("tableSetLoading", false);
});
})
.catch(() => {});
Expand All @@ -52,4 +51,4 @@ export default {
}
}
};
</script>
</script>
12 changes: 7 additions & 5 deletions resources/js/components/grid/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,26 @@ export default {
this.filterFormData = this._.cloneDeep(
this.$store.getters.thisPage.grids.filterFormData
);
this.sort = this._.cloneDeep(this.$store.getters.thisPage.grids.sort);
}
//加载数据
this.getData();
//监听属性数据事件
//监听事件
this.$bus.on("tableReload", () => {
this.getData();
});
this.$bus.on("tableSetLoading", status => {
this.loading = status;
});
},
destroyed() {
//取消监听
try {
this.$bus.off("tableReload");
this.$bus.off("tableSetLoading");
} catch (e) {}
},
methods: {
Expand Down Expand Up @@ -419,9 +424,6 @@ export default {
}
}
}
.el-table .cell {
line-height: unset;
}
.el-tabs__header {
padding: 0;
margin: 0;
Expand Down
27 changes: 24 additions & 3 deletions resources/js/components/widgets/Actions/ActionButton.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
<template>
<el-popconfirm
placement="top"
:title="action.message"
@onConfirm="onClick"
v-if="action.message"
>
<el-button
slot="reference"
:type="action.type"
:size="action.size"
:plain="action.plain"
:round="action.round"
:circle="action.circle"
:disabled="action.disabled"
:icon="action.icon"
:autofocus="action.autofocus"
:loading="loading"
>{{ action.content }}</el-button
>
</el-popconfirm>
<el-button
v-else
:type="action.type"
:size="action.size"
:plain="action.plain"
Expand All @@ -16,9 +37,9 @@
<script>
export default {
props: {
scope: Object,//当前行的字段定义和数据
action: Object,//当前主键的属性
key_name: String//主键名称
scope: Object, //当前行的字段定义和数据
action: Object, //当前主键的属性
key_name: String //主键名称
},
data() {
return {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/widgets/Actions/DeleteAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:autofocus="action.autofocus"
:loading="loading"
class="action-button"
>删除</el-button
>{{action.content}}</el-button
>
</el-popconfirm>
</template>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/widgets/Actions/EditAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:autofocus="action.autofocus"
:loading="loading"
@click="onHandle"
>编辑</el-button
>{{action.content}}</el-button
>
</template>
<script>
Expand Down
5 changes: 4 additions & 1 deletion resources/js/components/widgets/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export default {
mounted() {},
computed: {
src() {
return getFileUrl(this.attrs.host, this.value);
if (this.value) {
return getFileUrl(this.attrs.host, this.value);
}
return this.attrs.defaultSrc;
}
}
};
Expand Down
31 changes: 17 additions & 14 deletions resources/js/components/widgets/Tools/Create.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<template>
<router-link :to="$route.path + '/create'">
<el-button
:type="attrs.type"
:size="attrs.size"
:plain="attrs.plain"
:round="attrs.round"
:circle="attrs.circle"
:disabled="attrs.disabled"
:icon="attrs.icon"
:autofocus="attrs.autofocus"
class="mr-10"
>{{attrs.content}}</el-button
>
</router-link>
<el-button
:type="attrs.type"
:size="attrs.size"
:plain="attrs.plain"
:round="attrs.round"
:circle="attrs.circle"
:disabled="attrs.disabled"
:icon="attrs.icon"
:autofocus="attrs.autofocus"
@click="onCreate"
>{{ attrs.content }}</el-button
>
</template>
<script>
export default {
props: {
attrs: Object
},
methods: {
onCreate() {
this.$router.push(this.$route.path + "/create");
}
}
};
</script>
1 change: 0 additions & 1 deletion resources/js/components/widgets/Tools/ToolButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
:icon="attrs.icon"
:autofocus="attrs.autofocus"
:loading="loading"
class="mr-10"
@click="onClick"
>{{ attrs.content }}</el-button
>
Expand Down
20 changes: 13 additions & 7 deletions src/Actions/BaseRowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,35 @@ class BaseRowAction extends BaseAction
{
use Button;

protected $icon;

protected $order = 1;

protected $message;


/**
* @param mixed $icon
* 设置排序越大越靠前
* @param int $order
* @return $this
*/
public function icon($icon)
public function order(int $order)
{
$this->icon = $icon;
$this->order = $order;
return $this;
}

/**
* @param int $order
* 确认操作提示信息
* @param mixed $message
* @return $this
*/
public function order(int $order)
public function message($message)
{
$this->order = $order;
$this->message = $message;
return $this;
}




}
16 changes: 5 additions & 11 deletions src/Components/Attrs/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function content($content)
}



/**
* @param mixed $size
* @return $this
Expand All @@ -50,7 +49,7 @@ public function type($type)
* @param bool $plain
* @return $this
*/
public function plain(bool $plain)
public function plain(bool $plain = true)
{
$this->plain = $plain;
return $this;
Expand All @@ -60,7 +59,7 @@ public function plain(bool $plain)
* @param bool $round
* @return $this
*/
public function round(bool $round)
public function round(bool $round = true)
{
$this->round = $round;
return $this;
Expand All @@ -70,7 +69,7 @@ public function round(bool $round)
* @param bool $circle
* @return $this
*/
public function circle(bool $circle)
public function circle(bool $circle = true)
{
$this->circle = $circle;
return $this;
Expand All @@ -80,7 +79,7 @@ public function circle(bool $circle)
* @param bool $disabled
* @return $this
*/
public function disabled(bool $disabled)
public function disabled(bool $disabled = true)
{
$this->disabled = $disabled;
return $this;
Expand All @@ -100,16 +99,11 @@ public function icon($icon)
* @param bool $autofocus
* @return $this
*/
public function autofocus(bool $autofocus)
public function autofocus(bool $autofocus = true)
{
$this->autofocus = $autofocus;
return $this;
}







}
18 changes: 18 additions & 0 deletions src/Components/Avatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ class Avatar extends GridComponent
*/
protected $fit = "cover";


protected $defaultSrc;

public function __construct($value = null)
{
$this->host = \Storage::disk(config('admin.upload.disk'))->url('/');

$this->componentValue($value);

$this->defaultSrc = config('admin.default_avatar');
}


Expand Down Expand Up @@ -131,5 +136,18 @@ public function fit(string $fit)
return $this;
}

/**
* 设置默认头像
* @param string $defaultSrc
* @return $this
*/
public function defaultSrc($defaultSrc)
{
$this->defaultSrc = $defaultSrc;
return $this;
}




}
Loading

0 comments on commit ca4bbee

Please sign in to comment.