From ee833b9eaa4ab1ece0fbb535ddeae93fdb93b345 Mon Sep 17 00:00:00 2001 From: pushuo Date: Fri, 3 Feb 2023 15:03:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0=20?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=AE=A1=E7=90=86=E3=80=81=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E3=80=81=E5=AE=A2=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E5=88=97=E8=A1=A8=E7=AD=9B=E9=80=89=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/beike/admin/js/common.js | 39 +++- .../admin/views/layouts/master.blade.php | 2 +- .../views/pages/customers/index.blade.php | 152 ++++++-------- .../admin/views/pages/orders/index.blade.php | 33 +--- .../views/pages/products/index.blade.php | 186 +++++++----------- resources/beike/shop/default/css/footer.scss | 2 +- resources/beike/shop/default/css/header.scss | 14 +- resources/beike/shop/default/js/app.js | 2 +- 8 files changed, 188 insertions(+), 242 deletions(-) diff --git a/resources/beike/admin/js/common.js b/resources/beike/admin/js/common.js index 1a3165f3..cf6138db 100644 --- a/resources/beike/admin/js/common.js +++ b/resources/beike/admin/js/common.js @@ -3,10 +3,11 @@ * @link https://beikeshop.com * @Author pu shuo * @Date 2022-08-22 18:32:26 - * @LastEditTime 2022-09-16 20:57:51 + * @LastEditTime 2023-02-03 10:12:59 */ export default { + // 打开文件管理器 fileManagerIframe(callback) { const base = document.querySelector('base').href; @@ -28,6 +29,7 @@ export default { }); }, + // 防抖 debounce(fn, delay) { var timeout = null; // 创建一个标记用来存放定时器的返回值 @@ -41,12 +43,14 @@ export default { } }, + // 生成随机字符串 randomString(length) { let str = ''; for (; str.length < length; str += Math.random().toString(36).substr(2)); return str.substr(0, length); }, + // 获取url参数 getQueryString(name, defaultValue) { const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); const r = window.location.search.substr(1).match(reg); @@ -57,11 +61,44 @@ export default { return typeof(defaultValue) != 'undefined' ? defaultValue : ''; }, + // 控制字符串长度 超出显示... stringLengthInte(text, length = 50) { if (text.length) { return text.slice(0, length) + (text.length > length ? '...' : ''); } return ''; + }, + + // 给列表页筛选开发插件使用,场景:开发者需要添加筛选条件,不需要到filter添加筛选key + addFilterCondition(app) { + if (location.search) { + const params = location.search.substr(1).split('&'); + params.forEach(param => { + const [key, value] = param.split('='); + app.$set(app.filter, key, value); + }); + } + }, + + // 将对象内不为空的转换为url参数 并 添加到url后面 + objectToUrlParams(obj, url) { + const params = []; + for (const key in obj) { + if (obj[key] !== '') { + params.push(`${key}=${obj[key]}`); + } + } + + return `${url}${params.length ? '?' : ''}${params.join('&')}`; + }, + + // 清空对象内的值 + clearObjectValue(obj) { + for (const key in obj) { + obj[key] = ''; + } + + return obj; } } \ No newline at end of file diff --git a/resources/beike/admin/views/layouts/master.blade.php b/resources/beike/admin/views/layouts/master.blade.php index dc7b3473..6cdd7126 100644 --- a/resources/beike/admin/views/layouts/master.blade.php +++ b/resources/beike/admin/views/layouts/master.blade.php @@ -36,7 +36,7 @@
@yield('title')
- @yield('page-title-right') +
@yield('page-title-right')
@yield('content') diff --git a/resources/beike/admin/views/pages/customers/index.blade.php b/resources/beike/admin/views/pages/customers/index.blade.php index 41647df5..976a1ff4 100644 --- a/resources/beike/admin/views/pages/customers/index.blade.php +++ b/resources/beike/admin/views/pages/customers/index.blade.php @@ -47,55 +47,59 @@ @endif
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
{{ __('common.id') }}{{ __('customer.email') }}{{ __('customer.name') }}{{ __('customer.from') }}{{ __('customer.customer_group') }}{{ __('common.status') }}{{ __('common.created_at') }}{{ __('common.action') }}
@{{ customer.id }}@{{ customer.email }} -
- {{-- --}} -
@{{ customer.name }}
-
-
@{{ customer.from }}@{{ customer.customer_group_name }} - {{ __('common.enable') }} - {{ __('common.disable') }} - @{{ customer.created_at }} - @if ($type != 'trashed') - {{ __('common.edit') }} - - @else - {{ __('common.restore') }} - - @endif -
-
- + @if ($customers->total()) +
+ + + + + + + + + + + + + + + @foreach ($customers as $customer) + + + + + + + + + + + @endforeach + +
{{ __('common.id') }}{{ __('customer.email') }}{{ __('customer.name') }}{{ __('customer.from') }}{{ __('customer.customer_group') }}{{ __('common.status') }}{{ __('common.created_at') }}{{ __('common.action') }}
{{ $customer['id'] }}{{ $customer['email'] }} +
+
{{ $customer['name'] }}
+
+
{{ $customer['from'] }}{{ $customer->customerGroup->description->name ?? '' }} + + {{ $customer['active'] ? __('common.enable') : __('common.disable') }} + + {{ $customer['created_at'] }} + @if ($type != 'trashed') + {{ __('common.edit') }} + + @else + {{ __('common.restore') }} + + @endif +
+
+ {{ $customers->withQueryString()->links('admin::vendor/pagination/bootstrap-4') }} + @else + + @endif
__('shop/login.password')] ) }}',trigger: 'blur'}, ], }, - url: @json(admin_route('customers.index')), + url: '{{ $type == 'trashed' ? admin_route('customers.trashed') : admin_route('customers.index') }}', filter: { + page: bk.getQueryString('page'), email: bk.getQueryString('email'), name: bk.getQueryString('name'), customer_group_id: bk.getQueryString('customer_group_id'), status: bk.getQueryString('status'), }, + + customerIds: @json($customers->pluck('id')), }, - mounted () { - }, - - watch: { - page: function() { - this.loadData(); - }, - }, - - computed: { - query() { - let query = ''; - const filter = Object.keys(this.filter) - .filter(key => this.filter[key]) - .map(key => key + '=' + this.filter[key]) - .join('&'); - - if (filter) { - query += '?' + filter; - } - - return query; - } + created() { + bk.addFilterCondition(this); }, methods: { - loadData() { - $http.get(`customers?page=${this.page}`).then((res) => { - this.customers = res.data.customers; - }) - }, - checkedCustomersCreate() { this.dialogCustomers.show = true }, @@ -254,23 +231,22 @@ $http.post('customers', this.dialogCustomers.form).then((res) => { this.$message.success(res.message); - this.loadData();// this.customers.data.push(res.data); + window.location.reload(); this.dialogCustomers.show = false }) }); }, - deleteCustomer(url, index) { + deleteCustomer(id) { const self = this; this.$confirm('{{ __('common.confirm_delete') }}', '{{ __('common.text_hint') }}', { confirmButtonText: '{{ __('common.confirm') }}', cancelButtonText: '{{ __('common.cancel') }}', type: 'warning' }).then(() => { - $http.delete(url).then((res) => { + $http.delete(`customers/${id}`).then((res) => { self.$message.success(res.message); window.location.reload(); - // self.customers.splice(index, 1) }) }).catch(()=>{}) }, @@ -281,12 +257,12 @@ }, search() { - location = this.url + this.query + location = bk.objectToUrlParams(this.filter, this.url) }, resetSearch() { - Object.keys(this.filter).forEach(key => this.filter[key] = '') - location = this.url + this.query + this.filter = bk.clearObjectValue(this.filter) + location = bk.objectToUrlParams(this.filter, this.url) }, } }) diff --git a/resources/beike/admin/views/pages/orders/index.blade.php b/resources/beike/admin/views/pages/orders/index.blade.php index c1002ba4..1b6ae7eb 100644 --- a/resources/beike/admin/views/pages/orders/index.blade.php +++ b/resources/beike/admin/views/pages/orders/index.blade.php @@ -10,11 +10,10 @@
- +
- {{-- --}} @@ -109,13 +108,13 @@ @endif
-@endsection -@hook('admin.order.list.content.footer') + @hook('admin.order.list.content.footer') +@endsection @push('footer')