edit修改后台内容
This commit is contained in:
parent
4264cd8902
commit
48c9040186
@ -67,12 +67,15 @@ class CommonGoodsEditForm extends Model
|
|||||||
public $date;
|
public $date;
|
||||||
public $signing_foot_img;
|
public $signing_foot_img;
|
||||||
public $signing_head_img;
|
public $signing_head_img;
|
||||||
|
public $video_url_data_title;
|
||||||
|
public $video_url_data_url;
|
||||||
|
public $video_url_data_img;
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['name', 'subtitle', 'detail', 'cover_pic', 'video_url', 'unit', 'plugin_sign', 'goods_no',], 'trim'],
|
[['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'],
|
[['original_price', 'cost_price', 'goods_weight'], 'number'],
|
||||||
[['type', 'use_attr', 'goods_stock', 'virtual_sales', 'confine_count', 'freight_id', 'sort', 'cx_mch_id'], 'integer'],
|
[['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 = new GoodsHub();
|
||||||
$goods_hub->cx_mch_id = $this->cx_mch_id;
|
$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->name = $this->name;
|
||||||
$goods_hub->subtitle = $this->subtitle;
|
$goods_hub->subtitle = $this->subtitle;
|
||||||
// $goods_hub->original_price = $this->original_price ? $this->original_price : $this->price;
|
// $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)
|
private function addAttrGroupsId($list, &$id = 1)
|
||||||
{
|
{
|
||||||
|
if(!is_array($list)){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
$newId = 1;
|
$newId = 1;
|
||||||
foreach ($list as $key => $item) {
|
foreach ($list as $key => $item) {
|
||||||
if (isset($item['attr_list'])) {
|
if (isset($item['attr_list'])) {
|
||||||
@ -401,7 +419,7 @@ class CommonGoodsEditForm extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
// 未使用规格情况下,要把上一次的规格ID 存回去,不然规格记录会重复添加
|
// 未使用规格情况下,要把上一次的规格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'];
|
$newAttrs[0]['id'] = $this->attr[0]['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -219,8 +219,16 @@ class GoodsController extends Controller
|
|||||||
$attr[$index] = $item;
|
$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', [
|
return $this->render('edit', [
|
||||||
'cat_list' => $cat_list,
|
'cat_list' => $cat_list,
|
||||||
@ -232,6 +240,9 @@ class GoodsController extends Controller
|
|||||||
'attr_groups' => $attr_groups,
|
'attr_groups' => $attr_groups,
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'return_url' => $return_url,
|
'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) {
|
foreach ($json_de as $key => $val) {
|
||||||
$explode = explode('/', $val);
|
$explode = explode('/', $val);
|
||||||
$end = end($explode);
|
$end = end($explode);
|
||||||
//
|
//12G
|
||||||
$temp_arr[] = [
|
$temp_arr[] = [
|
||||||
'name' => $end,
|
'name' => $end,
|
||||||
'url' => $val,
|
'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([
|
<?= PickFile::widget([
|
||||||
'accept' => 'file',
|
'accept' => 'file',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'id' => 'video_url',
|
'id' => 'video_url',
|
||||||
'name' => 'video_url',
|
'name' => 'video_url',
|
||||||
'label' => '冠军视频',
|
'label' => '冠军视频列表',
|
||||||
'value' => $model->goodsHub ? $model->goodsHub->video_url : '',
|
'value' => $model->goodsHub ? $model->goodsHub->video_url : '',
|
||||||
'tip' => '视频最大50M',
|
'tip' => '视频最大50M',
|
||||||
'required' => false
|
'required' => false
|
||||||
|
|||||||
@ -144,7 +144,7 @@ class GoodsController extends Controller
|
|||||||
$form->cx_mch_id = $this->cx_mch_id;
|
$form->cx_mch_id = $this->cx_mch_id;
|
||||||
$form->status = Goods::STATUS_ONLINE;
|
$form->status = Goods::STATUS_ONLINE;
|
||||||
$form->plugin_sign = SysConst::$cxPluginSceneIntegralMall;
|
$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();
|
$data = $form->search();
|
||||||
|
|
||||||
foreach ($data['data'] as $key => $value) {
|
foreach ($data['data'] as $key => $value) {
|
||||||
@ -160,15 +160,25 @@ class GoodsController extends Controller
|
|||||||
$data['data'][$key]['pic_arr'] = $pic_arr;
|
$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'] = [];
|
$data['data'][$key]['video_arr'] = [];
|
||||||
if ($value['video_url'] != null) {
|
if ($value['video_url'] != null) {
|
||||||
$video_arr = json_decode($value['video_url'], true);
|
$video_arr = json_decode($value['video_url'], true);
|
||||||
$video_banner_urls = json_decode($value['video_banner_urls'], true);
|
$video_banner_urls = json_decode($value['video_banner_urls'], true);
|
||||||
|
|
||||||
$video = [];
|
|
||||||
foreach ($video_arr as $key1 => $value1) {
|
foreach ($video_arr as $key1 => $value1) {
|
||||||
$video[$key1]['img'] = $video_banner_urls[$key1] ?? '';
|
$i++;
|
||||||
$video[$key1]['video_url'] = $value1 ?? '';
|
$video[$i]['img'] = $video_banner_urls[$key1] ?? '';
|
||||||
|
$video[$i]['video_url'] = $value1 ?? '';
|
||||||
}
|
}
|
||||||
$data['data'][$key]['video_arr'] = $video;
|
$data['data'][$key]['video_arr'] = $video;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -5,12 +5,12 @@
|
|||||||
* @description KISS
|
* @description KISS
|
||||||
* @date 2021年10月7日
|
* @date 2021年10月7日
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*
|
*
|
||||||
* _____LOG_____
|
* _____LOG_____
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
.input-control-group .btn-control,
|
.input-control-group .btn-control,
|
||||||
.input-control-group .input-wrap,
|
.input-control-group .input-wrap,
|
||||||
.input-control-group .label {
|
.input-control-group .label {
|
||||||
@ -18,7 +18,7 @@
|
|||||||
height: 30px;
|
height: 30px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
border: 1px solid #C9C9C9;
|
border: 1px solid #C9C9C9;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
color: #555;
|
color: #555;
|
||||||
@ -40,12 +40,12 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="layui-form-item attr-group-panel" id="<?=$id?>" lay-ignore>
|
<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="layui-input-block">
|
||||||
<div class="input-control-group">
|
<div class="input-control-group">
|
||||||
<label class="label">业务组</label>
|
<label class="label">规格组</label>
|
||||||
<div class="input-wrap">
|
<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>
|
</div>
|
||||||
<span class="btn-control" v-on:click="add_attr_group"><i class="layui-icon"></i>添加</span>
|
<span class="btn-control" v-on:click="add_attr_group"><i class="layui-icon"></i>添加</span>
|
||||||
</div>
|
</div>
|
||||||
@ -55,65 +55,120 @@
|
|||||||
<div class="layui-btn-group">
|
<div class="layui-btn-group">
|
||||||
<button class="layui-btn layui-btn-primary layui-btn-sm">{{attr_group['attr_group_name']}}</button>
|
<button class="layui-btn layui-btn-primary layui-btn-sm">{{attr_group['attr_group_name']}}</button>
|
||||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="remove_attr_group(index)"><i class="layui-icon">ဆ</i></button>
|
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="remove_attr_group(index)"><i class="layui-icon">ဆ</i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-mt-15">
|
<div class="layui-mt-15">
|
||||||
<div class="input-control-group">
|
<div class="input-control-group">
|
||||||
<label class="label">{{attr_group['attr_group_name']}}</label>
|
<label class="label">{{attr_group['attr_group_name']}}</label>
|
||||||
<div class="input-wrap">
|
<div class="input-wrap">
|
||||||
<input type="text" name="" required="" placeholder="请输入规格值" autocomplete="off" class="input-control" v-model="attr_group.attr_name">
|
<input type="text" name="" required="" placeholder="请输入规格值" autocomplete="off" class="input-control" v-model="attr_group.attr_name">
|
||||||
</div>
|
</div>
|
||||||
<span class="btn-control" v-on:click="add_attr_name(index)"><i class="layui-icon"></i>添加</span>
|
<span class="btn-control" v-on:click="add_attr_name(index)"><i class="layui-icon"></i>添加</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-row">
|
<div class="layui-row">
|
||||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-mt-15" v-for="(attr_item,i) in attr_group['attr_list']" v-on:click="remove_attr_name(index,i)">{{attr_item['attr_name']}} <i class="layui-icon"></i> </button>
|
<button class="layui-btn layui-btn-sm layui-btn-normal layui-mt-15" v-for="(attr_item,i) in attr_group['attr_list']" v-on:click="remove_attr_name(index,i)">{{attr_item['attr_name']}} <i class="layui-icon"></i> </button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-input-block" v-show="attr_groups.length > 0">
|
<div class="layui-input-block" v-show="attr_groups.length > 0">
|
||||||
<table class="layui-table">
|
<table class="layui-table">
|
||||||
<thead>
|
<thead>
|
||||||
<th v-for="attr_group in attr_groups" v-show="attr_group['attr_list'].length > 0">{{attr_group['attr_group_name']}}</th>
|
<th v-for="attr_group in attr_groups" v-show="attr_group['attr_list'].length > 0">{{attr_group['attr_group_name']}}</th>
|
||||||
|
<th>
|
||||||
|
<div class="layui-inline">价格</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input class="layui-input" type="text" placeholder="批量设置价格" name="batch_price" v-model="batch_price" 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_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>
|
<th>
|
||||||
<div class="layui-inline">价格</div>
|
<div class="layui-inline">积分</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<input class="layui-input" type="text" placeholder="批量设置价格" name="batch_price" v-model="batch_price" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
<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>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_price()" >设置</button>
|
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_integral_num()" >设置</button>
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</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>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(goods_attr,index) in attr">
|
<tr v-for="(goods_attr,index) in attr">
|
||||||
<td v-for="attr_val in goods_attr['attr_list']">{{attr_val.attr_name}}</td>
|
<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]['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>
|
||||||
</tr>
|
<?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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-mid layui-word-aux"></div>
|
<div class="layui-form-mid layui-word-aux"></div>
|
||||||
<div class="layui-hide" id="uploadCoverPicBtn"></div>
|
<div class="layui-hide" id="uploadCoverPicBtn"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
<?php $this->beginBlock('js_script_wrap') ?>
|
<?php $this->beginBlock('js_script_wrap') ?>
|
||||||
var _attr_<?=$id?> = JSON.parse('<?=$attr?>');
|
var _attr_<?=$id?> = JSON.parse('<?=$attr?>');
|
||||||
var _attr_groups_<?=$id?> = JSON.parse('<?=$attr_groups?>');
|
var _attr_groups_<?=$id?> = JSON.parse('<?=$attr_groups?>');
|
||||||
function fixAttrGroups(action){
|
function fixAttrGroups(action){
|
||||||
var data = {};
|
var data = {};
|
||||||
data.attr_groups = _attr_groups_<?=$id?>;
|
data.attr_groups = _attr_groups_<?=$id?>;
|
||||||
data.attr = _attr_<?=$id?>;
|
data.attr = _attr_<?=$id?>;
|
||||||
$.each(data.attr_groups,function(index,item){
|
|
||||||
if(action){
|
if( 'object' == typeof data.attr_groups ){
|
||||||
item.attr_name = '';
|
$.each(data.attr_groups,function(index,item){
|
||||||
} else {
|
if(action){
|
||||||
delete item.attr_name;
|
item.attr_name = '';
|
||||||
}
|
} else {
|
||||||
data.attr_groups[index] = item;
|
delete item.attr_name;
|
||||||
});
|
}
|
||||||
|
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){
|
$.each(data.attr,function(index,item){
|
||||||
if(!action && item.integral_num){
|
if(!action && item.integral_num){
|
||||||
item.integral_num = item.integral_num * 1;
|
item.integral_num = item.integral_num * 1;
|
||||||
@ -155,7 +210,7 @@
|
|||||||
else {
|
else {
|
||||||
return doubleArrays[0];
|
return doubleArrays[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function hasExistAttr(mark, attr){
|
function hasExistAttr(mark, attr){
|
||||||
for(var i in attr){
|
for(var i in attr){
|
||||||
var _mark = '';
|
var _mark = '';
|
||||||
@ -203,7 +258,7 @@
|
|||||||
vm.attr_groups.push({
|
vm.attr_groups.push({
|
||||||
'attr_group_name':attr_group_name,
|
'attr_group_name':attr_group_name,
|
||||||
'attr_list':[],
|
'attr_list':[],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
vm.attr_group_name = '';
|
vm.attr_group_name = '';
|
||||||
vm.update_attr();
|
vm.update_attr();
|
||||||
@ -213,7 +268,7 @@
|
|||||||
attr_groups.splice(index,1);
|
attr_groups.splice(index,1);
|
||||||
vm.attr_groups = attr_groups;
|
vm.attr_groups = attr_groups;
|
||||||
vm.update_attr();
|
vm.update_attr();
|
||||||
},
|
},
|
||||||
add_attr_name:function(index){
|
add_attr_name:function(index){
|
||||||
var attr_list = vm.attr_groups[index]['attr_list'];
|
var attr_list = vm.attr_groups[index]['attr_list'];
|
||||||
var attr_name = vm.attr_groups[index]['attr_name'];
|
var attr_name = vm.attr_groups[index]['attr_name'];
|
||||||
@ -241,7 +296,7 @@
|
|||||||
attr_list.splice(attr_list_index,1);
|
attr_list.splice(attr_list_index,1);
|
||||||
vm.attr_groups[index]['attr_list'] = attr_list;
|
vm.attr_groups[index]['attr_list'] = attr_list;
|
||||||
vm.update_attr();
|
vm.update_attr();
|
||||||
},
|
},
|
||||||
update_attr(){
|
update_attr(){
|
||||||
vm.handle_attr_groups();
|
vm.handle_attr_groups();
|
||||||
var attr_temp = vm.attr;
|
var attr_temp = vm.attr;
|
||||||
@ -278,12 +333,16 @@
|
|||||||
item.sign_id = sign_ids.join(':');
|
item.sign_id = sign_ids.join(':');
|
||||||
item.attr_list = attr_list;
|
item.attr_list = attr_list;
|
||||||
item.price = '';
|
item.price = '';
|
||||||
|
item.stock = 0;
|
||||||
|
item.cover_pic = '';
|
||||||
|
item.serial_no = '';
|
||||||
|
item.weight = '';
|
||||||
<?php if($open_integral):?>
|
<?php if($open_integral):?>
|
||||||
item.integral_num = 0;
|
item.integral_num = 0;
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
attr.push(item);
|
attr.push(item);
|
||||||
}
|
}
|
||||||
vm.attr = attr;
|
vm.attr = attr;
|
||||||
vm.remit();
|
vm.remit();
|
||||||
},
|
},
|
||||||
handle_attr_groups:function(){
|
handle_attr_groups:function(){
|
||||||
@ -301,46 +360,46 @@
|
|||||||
vm.attr_groups = attr_groups;
|
vm.attr_groups = attr_groups;
|
||||||
},
|
},
|
||||||
batch_set_goods_price(){
|
batch_set_goods_price(){
|
||||||
var price = vm.batch_price;
|
var price = vm.batch_price;
|
||||||
if(price * 1 < 0){
|
if(price * 1 < 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var attr = vm.attr;
|
var attr = vm.attr;
|
||||||
$.each(attr,function(index,item){
|
$.each(attr,function(index,item){
|
||||||
item.price = price;
|
item.price = price;
|
||||||
attr[index] = item;
|
attr[index] = item;
|
||||||
});
|
});
|
||||||
vm.batch_price = '';
|
vm.batch_price = '';
|
||||||
vm.attr = attr;
|
vm.attr = attr;
|
||||||
vm.remit();
|
vm.remit();
|
||||||
},
|
},
|
||||||
batch_set_goods_stock(){
|
batch_set_goods_stock(){
|
||||||
var stock = vm.batch_stock;
|
var stock = vm.batch_stock;
|
||||||
if(stock * 1 < 0){
|
if(stock * 1 < 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var attr = vm.attr;
|
var attr = vm.attr;
|
||||||
$.each(attr,function(index,item){
|
$.each(attr,function(index,item){
|
||||||
item.stock = stock;
|
item.stock = stock;
|
||||||
attr[index] = item;
|
attr[index] = item;
|
||||||
});
|
});
|
||||||
vm.batch_stock = '';
|
vm.batch_stock = '';
|
||||||
vm.attr = attr;
|
vm.attr = attr;
|
||||||
vm.remit();
|
vm.remit();
|
||||||
},
|
},
|
||||||
batch_set_goods_integral_num(){
|
batch_set_goods_integral_num(){
|
||||||
var integral_num = vm.batch_integral_num;
|
var integral_num = vm.batch_integral_num;
|
||||||
if(integral_num * 1 < 0){
|
if(integral_num * 1 < 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var attr = vm.attr;
|
var attr = vm.attr;
|
||||||
$.each(attr,function(index,item){
|
$.each(attr,function(index,item){
|
||||||
item.integral_num = integral_num;
|
item.integral_num = integral_num;
|
||||||
attr[index] = item;
|
attr[index] = item;
|
||||||
});
|
});
|
||||||
vm.batch_integral_num = '';
|
vm.batch_integral_num = '';
|
||||||
vm.attr = attr;
|
vm.attr = attr;
|
||||||
vm.remit();
|
vm.remit();
|
||||||
},
|
},
|
||||||
upload_goods_cover_pic(index){
|
upload_goods_cover_pic(index){
|
||||||
vm.upload_cover_pic_index = index;
|
vm.upload_cover_pic_index = index;
|
||||||
@ -351,41 +410,41 @@
|
|||||||
layui.use(['upload', 'element'],function(){
|
layui.use(['upload', 'element'],function(){
|
||||||
var uploader = layui.upload;
|
var uploader = layui.upload;
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
uploader.render({
|
uploader.render({
|
||||||
elem: '#uploadCoverPicBtn'
|
elem: '#uploadCoverPicBtn'
|
||||||
, url: '<?= $url ?>'
|
, url: '<?= $url ?>'
|
||||||
, accept: 'images'
|
, accept: 'images'
|
||||||
, exts:'png|jpg|jpeg|gif|ico|bmp'
|
, exts:'png|jpg|jpeg|gif|ico|bmp'
|
||||||
, before: function (obj) {
|
, before: function (obj) {
|
||||||
//预读本地文件示例,不支持ie8
|
//预读本地文件示例,不支持ie8
|
||||||
obj.preview(function (index, file, result) {
|
obj.preview(function (index, file, result) {
|
||||||
console.log(result)
|
console.log(result)
|
||||||
if(vm.upload_cover_pic_index != -1){
|
|
||||||
vm.attr[vm.upload_cover_pic_index]['cover_pic'] = result;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
, progress: function(n, elem){
|
|
||||||
}
|
|
||||||
, done: function (res) {
|
|
||||||
//如果上传失败
|
|
||||||
if (res.code != 0) {
|
|
||||||
return layer.msg(res.msg);
|
|
||||||
}
|
|
||||||
if(vm.upload_cover_pic_index != -1){
|
if(vm.upload_cover_pic_index != -1){
|
||||||
vm.attr[vm.upload_cover_pic_index]['cover_pic'] = res.data.url;
|
vm.attr[vm.upload_cover_pic_index]['cover_pic'] = result;
|
||||||
vm.upload_cover_pic_index = -1;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
, progress: function(n, elem){
|
||||||
|
}
|
||||||
|
, done: function (res) {
|
||||||
|
//如果上传失败
|
||||||
|
if (res.code != 0) {
|
||||||
|
return layer.msg(res.msg);
|
||||||
}
|
}
|
||||||
, error: function () {
|
if(vm.upload_cover_pic_index != -1){
|
||||||
|
vm.attr[vm.upload_cover_pic_index]['cover_pic'] = res.data.url;
|
||||||
|
vm.upload_cover_pic_index = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, error: function () {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},1000);
|
},1000);
|
||||||
})
|
})
|
||||||
|
|
||||||
})($,layui,layer);
|
})($,layui,layer);
|
||||||
<?php $this->endBlock(); ?>
|
<?php $this->endBlock(); ?>
|
||||||
</script>
|
</script>
|
||||||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user