4
0
Fork 0

update goods-type

master
panliang 2022-10-21 15:40:08 +08:00
parent e3b3dc221f
commit 8c81f3f2c4
5 changed files with 21 additions and 24 deletions

View File

@ -21,6 +21,7 @@ Dcat-admin 商品管理
```php
$permissions = [
'goods' => ['name' => '商品管理', 'curd' => true],
'goods_sku' => ['name' => '货品管理', 'curd' => true],
'goods_category' => ['name' => '商品分类', 'curd' => true],
'goods_brand' => ['name' => '商品品牌', 'curd' => true],
'goods_type' => ['name' => '商品类别', 'curd' => true],

View File

@ -5,6 +5,7 @@ return [
'GoodsType' => '商品类别',
'goods' => '商品管理',
'type' => '商品类别',
'goods-type' => '商品类别',
],
'fields' => [
'name' => '名称',

View File

@ -39,8 +39,8 @@ class Attr extends Field
return $this;
}
// protected function prepareInputValue($value)
// {
// return $value;
// }
protected function prepareInputValue($value)
{
return json_decode($value, true);
}
}

View File

@ -49,31 +49,25 @@ class GoodsTypeController extends AdminController
protected function form()
{
return Form::make(new GoodsType(), function (Form $form) {
$form->block(12, function (Form\BlockForm $form) {
$form->title('基本设置');
$form->text('name')->required();
$form->showFooter();
$form->backButton();
$form->disableResetButton();
});
$form->title('基本设置');
$form->text('name')->required();
$form->block(12, function (Form\BlockForm $form) {
$form->title('属性');
$form->fieldset('属性', function (Form $form) {
$form->attr('attr')->header(['分组', '名称'])->keys(['name']);
});
$form->block(12, function (Form\BlockForm $form) {
$form->title('规格');
})->collapsed();
$form->fieldset('规格', function (Form $form) {
$form->attr('spec')->header(['名称', '可选值'])->keys(['name']);
});
$form->block(12, function (Form\BlockForm $form) {
$form->title('配件');
})->collapsed();
$form->fieldset('配件', function (Form $form) {
$form->attr('part')->header(['名称', '可选值'])->keys(['name']);
});
})->collapsed();
$form->disableCreatingCheck();
$form->disableViewCheck();
$form->disableEditingCheck();
$form->disableListButton();
$form->disableViewButton();
$form->disableDeleteButton();
$form->deleting(function (Form $form) {
$data = $form->model()->toArray();

View File

@ -63,6 +63,7 @@
}
</style>
<script>
$(function () {
var type = JSON.parse('{!! json_encode($type) !!}')
var keys = JSON.parse('{!! json_encode($keys) !!}')
var headers = JSON.parse('{!! json_encode($headers) !!}')
@ -70,14 +71,14 @@
// 添加父级属性
element.on('click', '.add-attr-button', function () {
var value = $('.add-attr-input').val()
var value = element.find('.add-attr-input').val()
if (!value) {
return Dcat.swal.warning(`请填写 ${headers[0]}`)
}
addGroup(value)
$('.add-attr-input').val('')
element.find('.add-attr-input').val('')
updateInputValue()
})
// 添加子属性
@ -219,11 +220,11 @@
})
values.push({name: id, values: subValues})
}
console.log(values)
return values
}
function updateInputValue() {
element.find('input[name="{{$name}}"]').val(JSON.stringify(formatValue()))
}
})
</script>