edit修改后台内容
This commit is contained in:
parent
4264cd8902
commit
48c9040186
@ -67,12 +67,15 @@ class CommonGoodsEditForm extends Model
|
||||
public $date;
|
||||
public $signing_foot_img;
|
||||
public $signing_head_img;
|
||||
public $video_url_data_title;
|
||||
public $video_url_data_url;
|
||||
public $video_url_data_img;
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'subtitle', 'detail', 'cover_pic', 'video_url', 'unit', 'plugin_sign', 'goods_no',], 'trim'],
|
||||
[['name', 'subtitle', 'detail', 'price', 'cover_pic', 'video_url', 'video_banner_urls', 'banner_urls', 'unit', 'plugin_sign', 'goods_no', 'date', 'signing_head_img', 'signing_foot_img'], 'string'],
|
||||
[['name', 'subtitle','video_url_data_url','video_url_data_title','video_url_data_img', 'detail', 'price', 'cover_pic', 'video_url', 'video_banner_urls', 'banner_urls', 'unit', 'plugin_sign', 'goods_no', 'date', 'signing_head_img', 'signing_foot_img'], 'string'],
|
||||
[['original_price', 'cost_price', 'goods_weight'], 'number'],
|
||||
[['type', 'use_attr', 'goods_stock', 'virtual_sales', 'confine_count', 'freight_id', 'sort', 'cx_mch_id'], 'integer'],
|
||||
|
||||
@ -185,6 +188,18 @@ class CommonGoodsEditForm extends Model
|
||||
$goods_hub = new GoodsHub();
|
||||
$goods_hub->cx_mch_id = $this->cx_mch_id;
|
||||
}
|
||||
$video_url_data_arr = [];
|
||||
if(!empty($this->video_url_data_url)){
|
||||
$video_url_data_arr[0]['url'] = $this->video_url_data_url;
|
||||
}
|
||||
if(!empty($this->video_url_data_title)){
|
||||
$video_url_data_arr[0]['title'] = $this->video_url_data_title;
|
||||
}
|
||||
if(!empty($this->video_url_data_img)){
|
||||
$video_url_data_arr[0]['img'] = $this->video_url_data_img;
|
||||
}
|
||||
|
||||
$goods_hub->video_url_data = json_encode($video_url_data_arr,JSON_UNESCAPED_UNICODE);
|
||||
$goods_hub->name = $this->name;
|
||||
$goods_hub->subtitle = $this->subtitle;
|
||||
// $goods_hub->original_price = $this->original_price ? $this->original_price : $this->price;
|
||||
@ -333,6 +348,9 @@ class CommonGoodsEditForm extends Model
|
||||
|
||||
private function addAttrGroupsId($list, &$id = 1)
|
||||
{
|
||||
if(!is_array($list)){
|
||||
return [];
|
||||
}
|
||||
$newId = 1;
|
||||
foreach ($list as $key => $item) {
|
||||
if (isset($item['attr_list'])) {
|
||||
@ -401,7 +419,7 @@ class CommonGoodsEditForm extends Model
|
||||
];
|
||||
|
||||
// 未使用规格情况下,要把上一次的规格ID 存回去,不然规格记录会重复添加
|
||||
if (count($this->attr) === 1 && isset($this->attr[0]['id'])) {
|
||||
if (!empty($this->attr) && count($this->attr) === 1 && isset($this->attr[0]['id'])) {
|
||||
$newAttrs[0]['id'] = $this->attr[0]['id'];
|
||||
}
|
||||
|
||||
|
||||
@ -219,8 +219,16 @@ class GoodsController extends Controller
|
||||
$attr[$index] = $item;
|
||||
}
|
||||
}
|
||||
$video_url_data_url = "";
|
||||
$video_url_data_title = "";
|
||||
$video_url_data_img = "";
|
||||
if(!empty($model->goodsHub->video_url_data)){
|
||||
$json_decode = json_decode($model->goodsHub->video_url_data,true);
|
||||
$video_url_data_url = $json_decode[0]['url'];
|
||||
$video_url_data_title = $json_decode[0]['title'];
|
||||
$video_url_data_img = $json_decode[0]['img'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $this->render('edit', [
|
||||
'cat_list' => $cat_list,
|
||||
@ -232,6 +240,9 @@ class GoodsController extends Controller
|
||||
'attr_groups' => $attr_groups,
|
||||
'model' => $model,
|
||||
'return_url' => $return_url,
|
||||
'video_url_data_url' => $video_url_data_url,
|
||||
'video_url_data_title' => $video_url_data_title,
|
||||
'video_url_data_img' => $video_url_data_img,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +198,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
foreach ($json_de as $key => $val) {
|
||||
$explode = explode('/', $val);
|
||||
$end = end($explode);
|
||||
//
|
||||
//12G
|
||||
$temp_arr[] = [
|
||||
'name' => $end,
|
||||
'url' => $val,
|
||||
@ -208,13 +208,44 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
}
|
||||
?>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'video',
|
||||
'multiple' => false,
|
||||
'id' => 'video_url_data_url',
|
||||
'name' => 'video_url_data_url',
|
||||
'label' => '冠军视频',
|
||||
'value' => $video_url_data_url ? $video_url_data_url : '',
|
||||
'tip' => '视频最大50M',
|
||||
'required' => false
|
||||
]) ?>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">冠军视频标题</label>
|
||||
<div class="layui-input-inline">
|
||||
<input name="video_url_data_title" placeholder="请输入视频标题" autocomplete="off"
|
||||
class="layui-input" value="<?= $video_url_data_title ?>"
|
||||
>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'images',
|
||||
'id' => 'video_url_data_img',
|
||||
'name' => 'video_url_data_img',
|
||||
'label' => '冠军视频图片',
|
||||
'value' => $video_url_data_img,
|
||||
// 'tip' => '图片大小750×750',
|
||||
|
||||
'imageCompressEnable' => 1,
|
||||
'imageCompressBorder' => 750,
|
||||
]) ?>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'file',
|
||||
'multiple' => true,
|
||||
'id' => 'video_url',
|
||||
'name' => 'video_url',
|
||||
'label' => '冠军视频',
|
||||
'label' => '冠军视频列表',
|
||||
'value' => $model->goodsHub ? $model->goodsHub->video_url : '',
|
||||
'tip' => '视频最大50M',
|
||||
'required' => false
|
||||
|
||||
@ -144,7 +144,7 @@ class GoodsController extends Controller
|
||||
$form->cx_mch_id = $this->cx_mch_id;
|
||||
$form->status = Goods::STATUS_ONLINE;
|
||||
$form->plugin_sign = SysConst::$cxPluginSceneIntegralMall;
|
||||
$form->setFields('g.id,g.price,g.date,g.sort,gh.subtitle,gh.banner_urls,g.created_at,gh.name,gh.cover_pic,gh.video_url,gh.pic_urls,gh.video_banner_urls');
|
||||
$form->setFields('g.id,g.price,g.date,g.sort,gh.subtitle,gh.banner_urls,g.created_at,gh.name,gh.cover_pic,gh.video_url,gh.pic_urls,gh.video_banner_urls,gh.video_url_data');
|
||||
$data = $form->search();
|
||||
|
||||
foreach ($data['data'] as $key => $value) {
|
||||
@ -160,15 +160,25 @@ class GoodsController extends Controller
|
||||
$data['data'][$key]['pic_arr'] = $pic_arr;
|
||||
}
|
||||
}
|
||||
$video = [];
|
||||
$i = 0;
|
||||
$video[$i] = [];
|
||||
if(!empty($value['video_url_data'])){
|
||||
$json_de = json_decode($value['video_url_data'],true);
|
||||
if(!empty($json_de[0]['url'])){
|
||||
$video[$i]['img'] = $json_de[0]['img']??'';
|
||||
$video[$i]['video_url'] = $json_de[0]['url']??'';
|
||||
$video[$i]['title'] = $json_de[0]['title']??'';
|
||||
}
|
||||
}
|
||||
$data['data'][$key]['video_arr'] = [];
|
||||
if ($value['video_url'] != null) {
|
||||
$video_arr = json_decode($value['video_url'], true);
|
||||
$video_banner_urls = json_decode($value['video_banner_urls'], true);
|
||||
|
||||
$video = [];
|
||||
foreach ($video_arr as $key1 => $value1) {
|
||||
$video[$key1]['img'] = $video_banner_urls[$key1] ?? '';
|
||||
$video[$key1]['video_url'] = $value1 ?? '';
|
||||
$i++;
|
||||
$video[$i]['img'] = $video_banner_urls[$key1] ?? '';
|
||||
$video[$i]['video_url'] = $value1 ?? '';
|
||||
}
|
||||
$data['data'][$key]['video_arr'] = $video;
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -40,12 +40,12 @@
|
||||
}
|
||||
</style>
|
||||
<div class="layui-form-item attr-group-panel" id="<?=$id?>" lay-ignore>
|
||||
<label class="layui-form-label">业务类型</label>
|
||||
<label class="layui-form-label">规格组与规格值</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="input-control-group">
|
||||
<label class="label">业务组</label>
|
||||
<label class="label">规格组</label>
|
||||
<div class="input-wrap">
|
||||
<input type="text" name="" required="" placeholder="请输入业务" autocomplete="off" class="input-control" v-model="attr_group_name">
|
||||
<input type="text" name="" required="" placeholder="请输入如颜色" autocomplete="off" class="input-control" v-model="attr_group_name">
|
||||
</div>
|
||||
<span class="btn-control" v-on:click="add_attr_group"><i class="layui-icon"></i>添加</span>
|
||||
</div>
|
||||
@ -83,13 +83,57 @@
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_price()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
|
||||
<th>
|
||||
<div class="layui-inline">库存</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="text" placeholder="批量设置库存" name="batch_stock" v-model="batch_stock" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_stock()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
<?php if($open_integral):?>
|
||||
<th>
|
||||
<div class="layui-inline">积分</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="number" placeholder="批量设置积分" name="batch_integral_num" v-model="batch_integral_num" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_integral_num()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
<?php endif;?>
|
||||
<th>
|
||||
<div class="layui-inline">货号</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="layui-inline">重量</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="layui-inline">图片</div>
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(goods_attr,index) in attr">
|
||||
<td v-for="attr_val in goods_attr['attr_list']">{{attr_val.attr_name}}</td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['price']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['stock']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
<?php if($open_integral):?>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['integral_num']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
<?php endif;?>
|
||||
<td><input class="layui-input" type="text" placeholder="" name="" v-model="attr[index]['serial_no']" style="margin-right: 0;height: 34px;line-height: 34px;width:88px"/></td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['weight']" style="margin-right: 0;height: 34px;line-height: 34px;width:88px"/></td>
|
||||
<td>
|
||||
<div class="layui-inline">
|
||||
<img v-bind:src="attr[index]['cover_pic']" style="width:34px;height:34px;">
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="text" placeholder="" name="" v-model="attr[index]['cover_pic']" style="margin-right: 0;height: 34px;line-height: 34px;"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm " v-on:click="upload_goods_cover_pic(index)"><i class="layui-icon"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -99,13 +143,15 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<?php $this->beginBlock('js_script_wrap') ?>
|
||||
<?php $this->beginBlock('js_script_wrap') ?>
|
||||
var _attr_<?=$id?> = JSON.parse('<?=$attr?>');
|
||||
var _attr_groups_<?=$id?> = JSON.parse('<?=$attr_groups?>');
|
||||
function fixAttrGroups(action){
|
||||
var data = {};
|
||||
data.attr_groups = _attr_groups_<?=$id?>;
|
||||
data.attr = _attr_<?=$id?>;
|
||||
|
||||
if( 'object' == typeof data.attr_groups ){
|
||||
$.each(data.attr_groups,function(index,item){
|
||||
if(action){
|
||||
item.attr_name = '';
|
||||
@ -114,6 +160,15 @@
|
||||
}
|
||||
data.attr_groups[index] = item;
|
||||
});
|
||||
}
|
||||
// $.each(data.attr_groups,function(index,item){
|
||||
// if(action){
|
||||
// item.attr_name = '';
|
||||
// } else {
|
||||
// delete item.attr_name;
|
||||
// }
|
||||
// data.attr_groups[index] = item;
|
||||
// });
|
||||
$.each(data.attr,function(index,item){
|
||||
if(!action && item.integral_num){
|
||||
item.integral_num = item.integral_num * 1;
|
||||
@ -278,6 +333,10 @@
|
||||
item.sign_id = sign_ids.join(':');
|
||||
item.attr_list = attr_list;
|
||||
item.price = '';
|
||||
item.stock = 0;
|
||||
item.cover_pic = '';
|
||||
item.serial_no = '';
|
||||
item.weight = '';
|
||||
<?php if($open_integral):?>
|
||||
item.integral_num = 0;
|
||||
<?php endif;?>
|
||||
@ -385,7 +444,7 @@
|
||||
})
|
||||
|
||||
})($,layui,layer);
|
||||
<?php $this->endBlock(); ?>
|
||||
<?php $this->endBlock(); ?>
|
||||
</script>
|
||||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user