update goods-type
parent
e3b3dc221f
commit
8c81f3f2c4
|
|
@ -21,6 +21,7 @@ Dcat-admin 商品管理
|
||||||
```php
|
```php
|
||||||
$permissions = [
|
$permissions = [
|
||||||
'goods' => ['name' => '商品管理', 'curd' => true],
|
'goods' => ['name' => '商品管理', 'curd' => true],
|
||||||
|
'goods_sku' => ['name' => '货品管理', 'curd' => true],
|
||||||
'goods_category' => ['name' => '商品分类', 'curd' => true],
|
'goods_category' => ['name' => '商品分类', 'curd' => true],
|
||||||
'goods_brand' => ['name' => '商品品牌', 'curd' => true],
|
'goods_brand' => ['name' => '商品品牌', 'curd' => true],
|
||||||
'goods_type' => ['name' => '商品类别', 'curd' => true],
|
'goods_type' => ['name' => '商品类别', 'curd' => true],
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ return [
|
||||||
'GoodsType' => '商品类别',
|
'GoodsType' => '商品类别',
|
||||||
'goods' => '商品管理',
|
'goods' => '商品管理',
|
||||||
'type' => '商品类别',
|
'type' => '商品类别',
|
||||||
|
'goods-type' => '商品类别',
|
||||||
],
|
],
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'name' => '名称',
|
'name' => '名称',
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ class Attr extends Field
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected function prepareInputValue($value)
|
protected function prepareInputValue($value)
|
||||||
// {
|
{
|
||||||
// return $value;
|
return json_decode($value, true);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,31 +49,25 @@ class GoodsTypeController extends AdminController
|
||||||
protected function form()
|
protected function form()
|
||||||
{
|
{
|
||||||
return Form::make(new GoodsType(), function (Form $form) {
|
return Form::make(new GoodsType(), function (Form $form) {
|
||||||
$form->block(12, function (Form\BlockForm $form) {
|
$form->title('基本设置');
|
||||||
$form->title('基本设置');
|
$form->text('name')->required();
|
||||||
$form->text('name')->required();
|
|
||||||
$form->showFooter();
|
|
||||||
$form->backButton();
|
|
||||||
$form->disableResetButton();
|
|
||||||
});
|
|
||||||
|
|
||||||
$form->block(12, function (Form\BlockForm $form) {
|
$form->fieldset('属性', function (Form $form) {
|
||||||
$form->title('属性');
|
|
||||||
$form->attr('attr')->header(['分组', '名称'])->keys(['name']);
|
$form->attr('attr')->header(['分组', '名称'])->keys(['name']);
|
||||||
});
|
})->collapsed();
|
||||||
|
$form->fieldset('规格', function (Form $form) {
|
||||||
$form->block(12, function (Form\BlockForm $form) {
|
|
||||||
$form->title('规格');
|
|
||||||
$form->attr('spec')->header(['名称', '可选值'])->keys(['name']);
|
$form->attr('spec')->header(['名称', '可选值'])->keys(['name']);
|
||||||
});
|
})->collapsed();
|
||||||
$form->block(12, function (Form\BlockForm $form) {
|
$form->fieldset('配件', function (Form $form) {
|
||||||
$form->title('配件');
|
|
||||||
$form->attr('part')->header(['名称', '可选值'])->keys(['name']);
|
$form->attr('part')->header(['名称', '可选值'])->keys(['name']);
|
||||||
});
|
})->collapsed();
|
||||||
|
|
||||||
$form->disableCreatingCheck();
|
$form->disableCreatingCheck();
|
||||||
$form->disableViewCheck();
|
$form->disableViewCheck();
|
||||||
$form->disableEditingCheck();
|
$form->disableEditingCheck();
|
||||||
|
$form->disableListButton();
|
||||||
|
$form->disableViewButton();
|
||||||
|
$form->disableDeleteButton();
|
||||||
|
|
||||||
$form->deleting(function (Form $form) {
|
$form->deleting(function (Form $form) {
|
||||||
$data = $form->model()->toArray();
|
$data = $form->model()->toArray();
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
|
$(function () {
|
||||||
var type = JSON.parse('{!! json_encode($type) !!}')
|
var type = JSON.parse('{!! json_encode($type) !!}')
|
||||||
var keys = JSON.parse('{!! json_encode($keys) !!}')
|
var keys = JSON.parse('{!! json_encode($keys) !!}')
|
||||||
var headers = JSON.parse('{!! json_encode($headers) !!}')
|
var headers = JSON.parse('{!! json_encode($headers) !!}')
|
||||||
|
|
@ -70,14 +71,14 @@
|
||||||
|
|
||||||
// 添加父级属性
|
// 添加父级属性
|
||||||
element.on('click', '.add-attr-button', function () {
|
element.on('click', '.add-attr-button', function () {
|
||||||
var value = $('.add-attr-input').val()
|
var value = element.find('.add-attr-input').val()
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return Dcat.swal.warning(`请填写 ${headers[0]}`)
|
return Dcat.swal.warning(`请填写 ${headers[0]}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
addGroup(value)
|
addGroup(value)
|
||||||
|
|
||||||
$('.add-attr-input').val('')
|
element.find('.add-attr-input').val('')
|
||||||
updateInputValue()
|
updateInputValue()
|
||||||
})
|
})
|
||||||
// 添加子属性
|
// 添加子属性
|
||||||
|
|
@ -219,11 +220,11 @@
|
||||||
})
|
})
|
||||||
values.push({name: id, values: subValues})
|
values.push({name: id, values: subValues})
|
||||||
}
|
}
|
||||||
console.log(values)
|
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInputValue() {
|
function updateInputValue() {
|
||||||
element.find('input[name="{{$name}}"]').val(JSON.stringify(formatValue()))
|
element.find('input[name="{{$name}}"]').val(JSON.stringify(formatValue()))
|
||||||
}
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue