|
|
|
@ -5,7 +5,7 @@ |
|
|
|
|
<el-steps :active="currentTab" align-center finish-status="success"> |
|
|
|
|
<el-step title="商品信息" /> |
|
|
|
|
<el-step title="商品详情" /> |
|
|
|
|
<el-step title="其他设置" /> |
|
|
|
|
<!-- <el-step title="其他设置" /> --> |
|
|
|
|
<!--<el-step title="规格设置" />--> |
|
|
|
|
</el-steps> |
|
|
|
|
</div> |
|
|
|
@ -14,14 +14,14 @@ |
|
|
|
|
<el-row v-show="currentTab === 0" :gutter="24"> |
|
|
|
|
<!-- 商品信息--> |
|
|
|
|
<el-col v-bind="grid2"> |
|
|
|
|
<el-form-item label="商品名称:" prop="storeName"> |
|
|
|
|
<el-input v-model="formValidate.storeName" maxlength="249" placeholder="请输入商品名称" :disabled="isDisabled" /> |
|
|
|
|
<el-form-item label="商品分类:" prop="categorys"> |
|
|
|
|
<el-cascader @change="cascaderChange" v-model="formValidate.categorys" :options="merCateList" |
|
|
|
|
:props="props2" clearable class="selWidth" :show-all-levels="false" :disabled="isDisabled" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col v-bind="grid2"> |
|
|
|
|
<el-form-item label="商品分类:" prop="cateIds"> |
|
|
|
|
<el-cascader v-model="formValidate.cateIds" :options="merCateList" :props="props2" clearable |
|
|
|
|
class="selWidth" :show-all-levels="false" :disabled="isDisabled" /> |
|
|
|
|
<el-form-item label="商品名称:" prop="productName"> |
|
|
|
|
<el-input v-model="formValidate.productName" maxlength="249" placeholder="请输入商品名称" :disabled="isDisabled" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col v-bind="grid2"> |
|
|
|
@ -29,18 +29,35 @@ |
|
|
|
|
<el-input v-model="formValidate.keyword" placeholder="请输入商品关键字" :disabled="isDisabled" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<!-- <el-col v-bind="grid2"> |
|
|
|
|
<el-form-item label="单位:" prop="unitName"> |
|
|
|
|
<el-input v-model="formValidate.unitName" placeholder="请输入单位" :disabled="isDisabled" /> |
|
|
|
|
<el-col v-bind="grid2"> |
|
|
|
|
<el-form-item label="商品品牌:" prop="brandId"> |
|
|
|
|
<el-select style="width: 100%;" v-model="formValidate.brandId" placeholder="请选择"> |
|
|
|
|
<el-option v-for="item in brandOptions" :key="item.id" :label="item.brandName" :value="item.id"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col v-bind="grid2"> |
|
|
|
|
<el-form-item label="商品货号" prop="productNum"> |
|
|
|
|
<el-input v-model="formValidate.productNum" maxlength="249" placeholder="请输入商品货号" :disabled="isDisabled" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> --> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col v-bind="grid2"> |
|
|
|
|
<el-form-item label="商品类型:" prop="productType"> |
|
|
|
|
<el-select style="width: 100%;" v-model="formValidate.productType" placeholder="请选择商品类型"> |
|
|
|
|
<el-option label="店铺商品" value="2"> </el-option> |
|
|
|
|
<el-option label="平台商品" value="1"> </el-option> |
|
|
|
|
|
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col v-bind="grid2"> |
|
|
|
|
<el-form-item label="商品简介:" prop="storeInfo"> |
|
|
|
|
<el-input v-model="formValidate.storeInfo" type="textarea" maxlength="250" :rows="3" placeholder="请输入商品简介" |
|
|
|
|
:disabled="isDisabled" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col v-bind="grid2"> |
|
|
|
|
<el-col :span="24"> |
|
|
|
|
<el-form-item label="商品封面图:" prop="image"> |
|
|
|
|
<div class="upLoadPicBox" @click="modalPicTap('1')" :disabled="isDisabled"> |
|
|
|
|
<div v-if="formValidate.image" class="pictrue"><img :src="formValidate.image"></div> |
|
|
|
@ -68,17 +85,6 @@ |
|
|
|
|
</div> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<!-- <el-col :xs="18" :sm="18" :md="18" :lg="12" :xl="12"> |
|
|
|
|
<el-form-item label="运费模板:" prop="tempId"> |
|
|
|
|
<el-select v-model="formValidate.tempId" placeholder="请选择" class="mr20" :disabled="isDisabled" |
|
|
|
|
style="width:100%;"> |
|
|
|
|
<el-option v-for="item in shippingList" :key="item.id" :label="item.name" :value="item.id" /> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> --> |
|
|
|
|
<!-- <el-col :xs="6" :sm="6" :md="6" :lg="12" :xl="12"> |
|
|
|
|
<el-button v-show="!isDisabled" class="mr15" @click="addTem">运费模板</el-button> |
|
|
|
|
</el-col> --> |
|
|
|
|
<el-col :span="24"> |
|
|
|
|
<el-form-item label="商品规格:" props="specType"> |
|
|
|
|
<el-radio-group v-model="formValidate.specType" @change="onChangeSpec(formValidate.specType)" |
|
|
|
@ -87,13 +93,6 @@ |
|
|
|
|
<el-radio :label="true">多规格</el-radio> |
|
|
|
|
</el-radio-group> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="佣金设置:" props="isSub"> |
|
|
|
|
<el-radio-group v-model="formValidate.isSub" @change="onChangetype(formValidate.isSub)" |
|
|
|
|
:disabled="isDisabled"> |
|
|
|
|
<el-radio :label="true" class="radio">单独设置</el-radio> |
|
|
|
|
<el-radio :label="false">默认设置</el-radio> |
|
|
|
|
</el-radio-group> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<!-- 多规格添加--> |
|
|
|
|
<el-col v-if="formValidate.specType && !isDisabled" :span="24" class="noForm"> |
|
|
|
@ -103,7 +102,7 @@ |
|
|
|
|
<el-option v-for="item in ruleList" :key="item.id" :label="item.name" :value="item.id" /> |
|
|
|
|
</el-select> |
|
|
|
|
<el-button type="primary" class="mr20" @click="confirm">确认</el-button> |
|
|
|
|
<el-button class="mr15" @click="addRule">添加规格</el-button> |
|
|
|
|
<!-- <el-button class="mr15" @click="addRule">添加规格</el-button> --> |
|
|
|
|
</div> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item> |
|
|
|
@ -111,44 +110,19 @@ |
|
|
|
|
<div class="acea-row row-middle"><span class="mr5">{{ item.attributeName }}</span><i |
|
|
|
|
class="el-icon-circle-close" @click="handleRemoveAttr(index)" /></div> |
|
|
|
|
<div class="rulesBox"> |
|
|
|
|
<el-tag v-for="(j, indexn) in item.attributeContentList" :key="indexn" closable size="medium" |
|
|
|
|
:disable-transitions="false" class="mb5 mr10" @close="handleClose(item.attrValue, indexn)"> |
|
|
|
|
<el-tag v-for="(j, indexn) in item.sku.value" :key="indexn" closable size="medium" |
|
|
|
|
:disable-transitions="false" class="mb5 mr10" @close="handleClose(item.sku.value, indexn,index)"> |
|
|
|
|
{{ j }} |
|
|
|
|
</el-tag> |
|
|
|
|
<el-input v-if="item.inputVisible" ref="saveTagInput" v-model="item.attrValue.attrsVal" |
|
|
|
|
class="input-new-tag" size="small" @keyup.enter.native="createAttr(item.attrValue.attrsVal, index)" |
|
|
|
|
@blur="createAttr(item.attrValue.attrsVal, index)" /> |
|
|
|
|
<el-button v-else class="button-new-tag" size="small" @click="showInput(item)">+ 添加</el-button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-col v-if="isBtn"> |
|
|
|
|
<el-col :xl="6" :lg="9" :md="9" :sm="24" :xs="24"> |
|
|
|
|
<el-form-item label="规格:"> |
|
|
|
|
<el-input v-model="formDynamic.attrsName" placeholder="请输入规格" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :xl="6" :lg="9" :md="9" :sm="24" :xs="24"> |
|
|
|
|
<el-form-item label="规格值:"> |
|
|
|
|
<el-input v-model="formDynamic.attrsVal" placeholder="请输入规格值" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :xl="12" :lg="6" :md="6" :sm="24" :xs="24"> |
|
|
|
|
<el-form-item class="noLeft"> |
|
|
|
|
<el-button type="primary" class="mr15" @click="createAttrName">确定</el-button> |
|
|
|
|
<el-button @click="offAttrName">取消</el-button> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-col> |
|
|
|
|
<el-form-item v-if="!isBtn"> |
|
|
|
|
<el-button type="primary" icon="md-add" class="mr15" @click="addBtn">添加新规格</el-button> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<!-- 批量设置--> |
|
|
|
|
<el-col v-if="formValidate.attr.length > 0 && formValidate.specType && !isDisabled" :span="24" class="noForm"> |
|
|
|
|
<el-form-item label="批量设置:"> |
|
|
|
|
<el-table :data="oneFormBatch" border class="tabNumWidth" size="mini"> |
|
|
|
|
<el-table-column align="center" label="图片" min-width="80"> |
|
|
|
|
<!-- <el-table-column align="center" label="图片" min-width="80"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<div class="upLoadPicBox" @click="modalPicTap('1', 'pi')"> |
|
|
|
|
<div v-if="scope.row.image" class="pictrue tabPic"><img :src="scope.row.image"></div> |
|
|
|
@ -157,28 +131,14 @@ |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column v-for="(item, iii) in attrValue" :key="iii" :label="formThead[iii].title" align="center" |
|
|
|
|
</el-table-column> --> |
|
|
|
|
<el-table-column v-for="(item, iii) in attrValue" :key="iii" :label="item.label" align="center" |
|
|
|
|
min-width="120"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input v-model="scope.row[iii]" maxlength="9" min="0.01" class="priceBox" |
|
|
|
|
@blur="keyupEvent(iii, scope.row[iii], scope.$index, 1)" /> |
|
|
|
|
<el-input :disabled="isDisabled" maxlength="9" min="0.01" v-model="scope.row[item.value]" |
|
|
|
|
class="priceBox" @blur="keyupEvent(iii, scope.row[item.value], scope.$index, 3)" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<template v-if="formValidate.isSub"> |
|
|
|
|
<el-table-column align="center" label="一级返佣(元)" min-width="120"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input v-model="scope.row.brokerage" type="number" :min="0" :max="scope.row.price" |
|
|
|
|
class="priceBox" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column align="center" label="二级返佣(元)" min-width="120"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input v-model="scope.row.brokerageTwo" type="number" :min="0" :max="scope.row.price" |
|
|
|
|
class="priceBox" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
</template> |
|
|
|
|
<el-table-column align="center" label="操作" min-width="80"> |
|
|
|
|
<template> |
|
|
|
|
<el-button type="text" class="submission" @click="batchAdd">批量添加</el-button> |
|
|
|
@ -190,41 +150,16 @@ |
|
|
|
|
<el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24"> |
|
|
|
|
<!-- 单规格表格--> |
|
|
|
|
<el-form-item v-if="formValidate.specType === false"> |
|
|
|
|
<el-table :data="OneattrValue" border class="tabNumWidth" size="mini"> |
|
|
|
|
<el-table-column align="center" label="图片" min-width="80"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<div class="upLoadPicBox" @click="modalPicTap('1', 'dan', 'pi')"> |
|
|
|
|
<div v-if="formValidate.image" class="pictrue tabPic"><img :src="scope.row.image"></div> |
|
|
|
|
<div v-else class="upLoad tabPic"> |
|
|
|
|
<i class="el-icon-camera cameraIconfont" /> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column v-for="(item, iii) in attrValue" :key="iii" :label="formThead[iii].title" align="center" |
|
|
|
|
<el-table :data="OneattrValue" border class="tabNumWidth" size="mini"> |
|
|
|
|
<el-table-column v-for="(item, iii) in attrValue" :key="iii" :label="item.label" align="center" |
|
|
|
|
min-width="120"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input :disabled="isDisabled" v-model="scope.row[iii]" maxlength="9" min="0.01" class="priceBox" |
|
|
|
|
@blur="keyupEvent(iii, scope.row[iii], scope.$index, 2)" /> |
|
|
|
|
<el-input :disabled="isDisabled" maxlength="9" min="0.01" v-model="scope.row[item.value]" |
|
|
|
|
class="priceBox" @blur="keyupEvent(iii, scope.row[item.value], scope.$index, 3)" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<template v-if="formValidate.isSub"> |
|
|
|
|
<el-table-column align="center" label="一级返佣(元)" min-width="120"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input :disabled="isDisabled" v-model="scope.row.brokerage" type="number" :min="0" |
|
|
|
|
class="priceBox" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column align="center" label="二级返佣(元)" min-width="120"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input :disabled="isDisabled" v-model="scope.row.brokerageTwo" type="number" :min="0" |
|
|
|
|
class="priceBox" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
</template> |
|
|
|
|
</el-table> |
|
|
|
|
</el-form-item> |
|
|
|
|
<!-- <div>manyTabDate:{{manyTabDate}}</div> --> |
|
|
|
|
<el-form-item label="全部sku:" v-if="$route.params.id && showAll"> |
|
|
|
|
<el-button type="default" @click="showAllSku()" :disabled="isDisabled">展示</el-button> |
|
|
|
|
</el-form-item> |
|
|
|
@ -233,47 +168,23 @@ |
|
|
|
|
:class="isDisabled ? 'disLabel' : 'disLabelmoren'"> |
|
|
|
|
<el-table :data="ManyAttrValue" border class="tabNumWidth" size="mini"> |
|
|
|
|
<template v-if="manyTabDate"> |
|
|
|
|
<el-table-column v-for="(item, iii) in manyTabDate" :key="iii" align="center" |
|
|
|
|
:label="manyTabTit[iii].title" min-width="80"> |
|
|
|
|
<el-table-column v-for="(item) in manyTabDate" :key="item" align="center" :label="item" min-width="80"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<span class="priceBox" v-text="scope.row[iii]" /> |
|
|
|
|
<span class="priceBox" v-text="scope.row[item]" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
</template> |
|
|
|
|
<el-table-column align="center" label="图片" min-width="80"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<div class="upLoadPicBox" @click="modalPicTap('1', 'duo', scope.$index)"> |
|
|
|
|
<div v-if="scope.row.image" class="pictrue tabPic"><img :src="scope.row.image"></div> |
|
|
|
|
<div v-else class="upLoad tabPic"> |
|
|
|
|
<i class="el-icon-camera cameraIconfont" /> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column v-for="(item, iii) in attrValue" :key="iii" :label="formThead[iii].title" align="center" |
|
|
|
|
</template> |
|
|
|
|
<el-table-column v-for="(item, iii) in attrValue" :key="iii" :label="item.label" align="center" |
|
|
|
|
min-width="120"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<!-- <span>scope.row:{{scope.row}}</span>--> |
|
|
|
|
<el-input :disabled="isDisabled" maxlength="9" min="0.01" v-model="scope.row[iii]" class="priceBox" |
|
|
|
|
@blur="keyupEvent(iii, scope.row[iii], scope.$index, 3)" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column align="center" label="一级返佣(元)" min-width="120" v-if="formValidate.isSub"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input :disabled="isDisabled" v-model="scope.row.brokerage" type="number" :min="0" |
|
|
|
|
:max="scope.row.price" class="priceBox" /> |
|
|
|
|
<el-input :disabled="isDisabled" maxlength="9" min="0.01" v-model="scope.row[item.value]" |
|
|
|
|
class="priceBox" @blur="keyupEvent(iii, scope.row[item.value], scope.$index, 3)" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column align="center" label="二级返佣(元)" min-width="120" v-if="formValidate.isSub"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input :disabled="isDisabled" v-model="scope.row.brokerageTwo" type="number" :min="0" |
|
|
|
|
:max="scope.row.price" class="priceBox" /> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column v-if="!isDisabled" key="3" align="center" label="操作" min-width="80"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-button type="text" class="submission" @click="delAttrTable(scope.$index)">删除</el-button> |
|
|
|
|
</template> |
|
|
|
|
<el-table-column label="操作" fixed="right"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-button type="text" @click="delAttrTable(scope.$index)">删除</el-button> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
</el-table> |
|
|
|
|
</el-form-item> |
|
|
|
@ -348,9 +259,9 @@ |
|
|
|
|
</el-row> |
|
|
|
|
<el-form-item> |
|
|
|
|
<el-button v-show="currentTab > 0" class="submission priamry_border" @click="handleSubmitUp">上一步</el-button> |
|
|
|
|
<el-button v-show="currentTab < 2" type="primary" class="submission" |
|
|
|
|
<el-button v-show="currentTab < 1" type="primary" class="submission" |
|
|
|
|
@click="handleSubmitNest('formValidate')">下一步</el-button> |
|
|
|
|
<el-button v-show="(currentTab === 2 || $route.params.id) && !isDisabled" type="primary" class="submission" |
|
|
|
|
<el-button v-show="(currentTab === 1 || $route.params.id) && !isDisabled" type="primary" class="submission" |
|
|
|
|
@click="handleSubmit('formValidate')">提交</el-button> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
@ -408,32 +319,27 @@ const defaultObj = { |
|
|
|
|
} |
|
|
|
|
const objTitle = { |
|
|
|
|
price: { |
|
|
|
|
title: '售价' |
|
|
|
|
title: '市场价格' |
|
|
|
|
}, |
|
|
|
|
cost: { |
|
|
|
|
title: '成本价' |
|
|
|
|
title: '销售价格' |
|
|
|
|
}, |
|
|
|
|
otPrice: { |
|
|
|
|
title: '原价' |
|
|
|
|
title: '商品库存' |
|
|
|
|
}, |
|
|
|
|
stock: { |
|
|
|
|
title: '库存' |
|
|
|
|
title: 'SKU编号' |
|
|
|
|
}, |
|
|
|
|
barCode: { |
|
|
|
|
title: '商品编号' |
|
|
|
|
}, |
|
|
|
|
weight: { |
|
|
|
|
title: '重量(KG)' |
|
|
|
|
}, |
|
|
|
|
volume: { |
|
|
|
|
title: '体积(m³)' |
|
|
|
|
title: '兑换积分' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
export default { |
|
|
|
|
name: 'ProductProductAdd', |
|
|
|
|
components: { Templates, CreatTemplates, Tinymce }, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
return { |
|
|
|
|
brandOptions: [], |
|
|
|
|
isDisabled: this.$route.params.isDisabled === '1' ? true : false, |
|
|
|
|
activity: { '默认': 'red', '秒杀': 'blue', '砍价': 'green', '拼团': 'yellow' }, |
|
|
|
|
props2: { |
|
|
|
@ -488,33 +394,33 @@ export default { |
|
|
|
|
xs: 24 |
|
|
|
|
}, |
|
|
|
|
ruleValidate: { |
|
|
|
|
storeName: [ |
|
|
|
|
{ required: true, message: '请输入商品名称', trigger: 'blur' } |
|
|
|
|
], |
|
|
|
|
cateIds: [ |
|
|
|
|
{ required: true, message: '请选择商品分类', trigger: 'change', type: 'array', min: '1' } |
|
|
|
|
], |
|
|
|
|
keyword: [ |
|
|
|
|
{ required: true, message: '请输入商品关键字', trigger: 'blur' } |
|
|
|
|
], |
|
|
|
|
unitName: [ |
|
|
|
|
{ required: true, message: '请输入单位', trigger: 'blur' } |
|
|
|
|
], |
|
|
|
|
storeInfo: [ |
|
|
|
|
{ required: true, message: '请输入商品简介', trigger: 'blur' } |
|
|
|
|
], |
|
|
|
|
tempId: [ |
|
|
|
|
{ required: true, message: '请选择运费模板', trigger: 'change' } |
|
|
|
|
], |
|
|
|
|
image: [ |
|
|
|
|
{ required: true, message: '请上传商品图', trigger: 'change' } |
|
|
|
|
], |
|
|
|
|
sliderImages: [ |
|
|
|
|
{ required: true, message: '请上传商品轮播图', type: 'array', trigger: 'change' } |
|
|
|
|
], |
|
|
|
|
specType: [ |
|
|
|
|
{ required: true, message: '请选择商品规格', trigger: 'change' } |
|
|
|
|
] |
|
|
|
|
// storeName: [ |
|
|
|
|
// { required: true, message: '请输入商品名称', trigger: 'blur' } |
|
|
|
|
// ], |
|
|
|
|
// cateIds: [ |
|
|
|
|
// { required: true, message: '请选择商品分类', trigger: 'change', type: 'array', min: '1' } |
|
|
|
|
// ], |
|
|
|
|
// keyword: [ |
|
|
|
|
// { required: true, message: '请输入商品关键字', trigger: 'blur' } |
|
|
|
|
// ], |
|
|
|
|
// unitName: [ |
|
|
|
|
// { required: true, message: '请输入单位', trigger: 'blur' } |
|
|
|
|
// ], |
|
|
|
|
// storeInfo: [ |
|
|
|
|
// { required: true, message: '请输入商品简介', trigger: 'blur' } |
|
|
|
|
// ], |
|
|
|
|
// tempId: [ |
|
|
|
|
// { required: true, message: '请选择运费模板', trigger: 'change' } |
|
|
|
|
// ], |
|
|
|
|
// image: [ |
|
|
|
|
// { required: true, message: '请上传商品图', trigger: 'change' } |
|
|
|
|
// ], |
|
|
|
|
// sliderImages: [ |
|
|
|
|
// { required: true, message: '请上传商品轮播图', type: 'array', trigger: 'change' } |
|
|
|
|
// ], |
|
|
|
|
// specType: [ |
|
|
|
|
// { required: true, message: '请选择商品规格', trigger: 'change' } |
|
|
|
|
// ] |
|
|
|
|
}, |
|
|
|
|
attrInfo: {}, |
|
|
|
|
tableFrom: { |
|
|
|
@ -527,14 +433,37 @@ export default { |
|
|
|
|
isAttr: false, |
|
|
|
|
showAll: false, |
|
|
|
|
videoLink: "", |
|
|
|
|
attrValue: [ |
|
|
|
|
{ |
|
|
|
|
label: "市场价格", |
|
|
|
|
name: "市场价格", |
|
|
|
|
value: "marketPrice" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: "销售价格", |
|
|
|
|
name: "销售价格", |
|
|
|
|
value: "sellPrice" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: "商品库存", |
|
|
|
|
name: "商品库存", |
|
|
|
|
value: "stock" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: "SKU编号", |
|
|
|
|
name: "SKU编号", |
|
|
|
|
|
|
|
|
|
value: "skuNum" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: "兑换积分", |
|
|
|
|
name: "兑换积分", |
|
|
|
|
value: "integral" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
attrValue() { |
|
|
|
|
const obj = Object.assign({}, defaultObj.attrValue[0]) |
|
|
|
|
delete obj.image |
|
|
|
|
return obj |
|
|
|
|
}, |
|
|
|
|
oneFormBatch() { |
|
|
|
|
const obj = [Object.assign({}, defaultObj.attrValue[0])] |
|
|
|
|
delete obj[0].barCode |
|
|
|
@ -542,6 +471,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
ManyAttrValue(n) { }, |
|
|
|
|
'formValidate.attr': { |
|
|
|
|
handler: function (val) { |
|
|
|
|
if (this.formValidate.specType && this.isAttr) this.watCh(val) //重要!!! |
|
|
|
@ -550,13 +480,24 @@ export default { |
|
|
|
|
deep: true |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
created() { |
|
|
|
|
this.getCategorySelect(); |
|
|
|
|
this.productGetRule() |
|
|
|
|
this.productGetRule(); |
|
|
|
|
this.brandGetAll() |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
mounted() { |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
methods: { |
|
|
|
|
brandGetAll(){ |
|
|
|
|
productApi.brandGetAll().then(res=>{ |
|
|
|
|
if(res.code==20000){ |
|
|
|
|
this.brandOptions =res.data |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
cascaderChange(e) { |
|
|
|
|
console.log(e, "cascaderChange") |
|
|
|
|
}, |
|
|
|
|
// 校验输入框不能输入0,保留2位小数,库存为正整数 |
|
|
|
|
keyupEvent(key, val, index, num) { |
|
|
|
|
if (key === 'barCode') return; |
|
|
|
@ -621,27 +562,30 @@ export default { |
|
|
|
|
this.checkboxGroup.includes('isNew') ? this.formValidate.isNew = true : this.formValidate.isNew = false |
|
|
|
|
this.checkboxGroup.includes('isHot') ? this.formValidate.isHot = true : this.formValidate.isHot = false |
|
|
|
|
}, |
|
|
|
|
// sku算法 |
|
|
|
|
watCh(val) { |
|
|
|
|
const tmp = {} |
|
|
|
|
const tmpTab = {} |
|
|
|
|
this.formValidate.attr.forEach((o, i) => { |
|
|
|
|
// tmp['value' + i] = { title: o.attrName } |
|
|
|
|
// tmpTab['value' + i] = '' |
|
|
|
|
tmp[o.attrName] = { title: o.attrName }; |
|
|
|
|
tmpTab[o.attrName] = ''; |
|
|
|
|
}); |
|
|
|
|
this.ManyAttrValue = this.attrFormat(val); |
|
|
|
|
this.ManyAttrValue.forEach((val, index) => { |
|
|
|
|
const key = Object.values(val.attrValue).sort().join('/') |
|
|
|
|
if (this.attrInfo[key]) this.ManyAttrValue[index] = this.attrInfo[key] |
|
|
|
|
}) |
|
|
|
|
this.attrInfo = []; |
|
|
|
|
this.ManyAttrValue.forEach((val) => { |
|
|
|
|
this.attrInfo[Object.values(val.attrValue).sort().join('/')] = val |
|
|
|
|
}) |
|
|
|
|
this.manyTabTit = tmp |
|
|
|
|
this.manyTabDate = tmpTab |
|
|
|
|
this.formThead = Object.assign({}, this.formThead, tmp) |
|
|
|
|
let arr = []; |
|
|
|
|
this.manyTabDate = []; |
|
|
|
|
for (let i = 0; i < val.length; i++) { |
|
|
|
|
arr.push(val[i].sku); |
|
|
|
|
this.manyTabDate.push(val[i].sku.name) |
|
|
|
|
}; |
|
|
|
|
this.ManyAttrValue = arr.reduce((a, b, c) => { |
|
|
|
|
let res = []; |
|
|
|
|
a.map(x => { |
|
|
|
|
b.value.map(y => { |
|
|
|
|
res.push({ |
|
|
|
|
...x, |
|
|
|
|
[b.name]: y, |
|
|
|
|
data: Object.assign({},x.data||{},{ [b.name]: y}), |
|
|
|
|
...Object.fromEntries(this.attrValue.map(item=>{ |
|
|
|
|
return [item.value,""] |
|
|
|
|
})) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
return res |
|
|
|
|
}, [{}]); |
|
|
|
|
}, |
|
|
|
|
attrFormat(arr) { |
|
|
|
|
let data = [] |
|
|
|
@ -737,39 +681,16 @@ export default { |
|
|
|
|
this.isAttr = true |
|
|
|
|
if (!this.formValidate.selectRule) { |
|
|
|
|
return this.$message.warning('请选择属性') |
|
|
|
|
} |
|
|
|
|
const data = []; |
|
|
|
|
this.formValidate.attr = this.ruleList.find(item=>item.id==this.formValidate.selectRule).attributesList; |
|
|
|
|
|
|
|
|
|
console.log(this.formValidate.attr,'attributeContentList') |
|
|
|
|
// this.ruleList.forEach(item => { attributesList |
|
|
|
|
// if (item.id === this.formValidate.selectRule) { |
|
|
|
|
// item.ruleValue.forEach(i => { |
|
|
|
|
// data.push({ |
|
|
|
|
// attrName: i.value, |
|
|
|
|
// attrValue: i.detail |
|
|
|
|
// }) |
|
|
|
|
// }) |
|
|
|
|
// } |
|
|
|
|
// this.formValidate.attr = data; |
|
|
|
|
// }); |
|
|
|
|
} |
|
|
|
|
this.formValidate.attr = JSON.parse(JSON.stringify(this.ruleList.find(item => item.id == this.formValidate.selectRule).attributesList)); |
|
|
|
|
}, |
|
|
|
|
// 商品分类; |
|
|
|
|
getCategorySelect() { |
|
|
|
|
productApi.getClassificationTree().then(res=>{ |
|
|
|
|
if(res.code==20000){ |
|
|
|
|
this.merCateList = res.data; |
|
|
|
|
productApi.getClassificationTree().then(res => { |
|
|
|
|
if (res.code == 20000) { |
|
|
|
|
this.merCateList = res.data; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// categoryApi({ status: -1, type: 1 }).then(res => { |
|
|
|
|
// this.merCateList = this.filerMerCateList(res) |
|
|
|
|
// let newArr = []; |
|
|
|
|
// res.forEach((value,index) => { |
|
|
|
|
// newArr[index] = value; |
|
|
|
|
// if(value.child) newArr[index].child = value.child.filter(item => item.status === true) |
|
|
|
|
// }) //过滤商品分类设置为隐藏的子分类不出现在树形列表里 |
|
|
|
|
// this.merCateList = this.filerMerCateList(newArr) |
|
|
|
|
// }) |
|
|
|
|
}, |
|
|
|
|
filerMerCateList(treeData) { |
|
|
|
|
return treeData.map((item) => { |
|
|
|
@ -782,29 +703,21 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 获取商品属性模板; |
|
|
|
|
productGetRule() { |
|
|
|
|
productApi.getAllAttributesType().then(res=>{ |
|
|
|
|
if(res.code==20000){ |
|
|
|
|
this.ruleList = res.data.map(item=>{ |
|
|
|
|
return { |
|
|
|
|
...item, |
|
|
|
|
attributesList:item.attributesList.map(citem=>{ |
|
|
|
|
return { |
|
|
|
|
...citem, |
|
|
|
|
attributeContentList:citem.attributeContent.split(",") |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
productApi.getAllAttributesType().then(res => { |
|
|
|
|
if (res.code == 20000) { |
|
|
|
|
this.ruleList = res.data.map(item => { |
|
|
|
|
return { |
|
|
|
|
...item, |
|
|
|
|
attributesList: item.attributesList.map(citem => { |
|
|
|
|
return { |
|
|
|
|
...citem, |
|
|
|
|
sku: { name: citem.attributeName, value: citem.attributeContent.split(",") } |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
console.log( this.ruleList,' this.ruleList') |
|
|
|
|
}) |
|
|
|
|
// templateListApi(this.tableFrom).then(res => { |
|
|
|
|
// const list = res.list |
|
|
|
|
// for (var i = 0; i < list.length; i++) { |
|
|
|
|
// list[i].ruleValue = JSON.parse(list[i].ruleValue) |
|
|
|
|
// } |
|
|
|
|
// this.ruleList = list |
|
|
|
|
// }) |
|
|
|
|
}, |
|
|
|
|
// 运费模板; |
|
|
|
|
getShippingList() { |
|
|
|
@ -846,18 +759,10 @@ export default { |
|
|
|
|
batchAdd() { |
|
|
|
|
// if (!this.oneFormBatch[0].pic || !this.oneFormBatch[0].price || !this.oneFormBatch[0].cost || !this.oneFormBatch[0].ot_price || |
|
|
|
|
// !this.oneFormBatch[0].stock || !this.oneFormBatch[0].bar_code) return this.$Message.warning('请填写完整的批量设置内容!'); |
|
|
|
|
for (const val of this.ManyAttrValue) { |
|
|
|
|
this.$set(val, 'image', this.oneFormBatch[0].image) |
|
|
|
|
this.$set(val, 'price', this.oneFormBatch[0].price) |
|
|
|
|
this.$set(val, 'cost', this.oneFormBatch[0].cost) |
|
|
|
|
this.$set(val, 'otPrice', this.oneFormBatch[0].otPrice) |
|
|
|
|
this.$set(val, 'stock', this.oneFormBatch[0].stock) |
|
|
|
|
this.$set(val, 'barCode', this.oneFormBatch[0].barCode) |
|
|
|
|
this.$set(val, 'weight', this.oneFormBatch[0].weight) |
|
|
|
|
this.$set(val, 'volume', this.oneFormBatch[0].volume) |
|
|
|
|
this.$set(val, 'brokerage', this.oneFormBatch[0].brokerage) |
|
|
|
|
this.$set(val, 'brokerageTwo', this.oneFormBatch[0].brokerageTwo) |
|
|
|
|
} |
|
|
|
|
console.log( this.ManyAttrValue,this.oneFormBatch," this.ManyAttrValue"); |
|
|
|
|
this.ManyAttrValue.forEach(item=>{ |
|
|
|
|
Object.assign(item,this.oneFormBatch[0]) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 添加按钮 |
|
|
|
|
addBtn() { |
|
|
|
@ -876,12 +781,17 @@ export default { |
|
|
|
|
// 删除规格 |
|
|
|
|
handleRemoveAttr(index) { |
|
|
|
|
this.isAttr = true |
|
|
|
|
this.formValidate.attr.splice(index, 1) |
|
|
|
|
this.manyFormValidate.splice(index, 1) |
|
|
|
|
this.formValidate.attr.splice(index, 1); |
|
|
|
|
this.manyFormValidate.splice(index, 1); |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
// 删除属性 |
|
|
|
|
handleClose(item, index) { |
|
|
|
|
item.splice(index, 1) |
|
|
|
|
handleClose(item, index,parentIndex) { |
|
|
|
|
if (item.length == 1) { |
|
|
|
|
this.handleRemoveAttr(parentIndex) |
|
|
|
|
} else { |
|
|
|
|
item.splice(index, 1); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 添加规则名称 |
|
|
|
|
createAttrName() { |
|
|
|
@ -1099,59 +1009,59 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 提交 |
|
|
|
|
handleSubmit: Debounce(function (name) { |
|
|
|
|
this.onChangeGroup() |
|
|
|
|
if (this.formValidate.specType && this.formValidate.attr.length < 1) return this.$message.warning("请填写多规格属性!"); |
|
|
|
|
this.formValidate.cateId = this.formValidate.cateIds.join(',') |
|
|
|
|
this.formValidate.sliderImage = JSON.stringify(this.formValidate.sliderImages) |
|
|
|
|
if (this.formValidate.specType) { |
|
|
|
|
this.formValidate.attrValue = this.ManyAttrValue; |
|
|
|
|
this.formValidate.attr = this.formValidate.attr.map((item) => { |
|
|
|
|
return { |
|
|
|
|
attrName: item.attrName, |
|
|
|
|
id: item.id, |
|
|
|
|
attrValues: item.attrValue.join(','), |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
for (var i = 0; i < this.formValidate.attrValue.length; i++) { |
|
|
|
|
this.$set(this.formValidate.attrValue[i], 'id', 0); |
|
|
|
|
this.$set(this.formValidate.attrValue[i], 'productId', 0); |
|
|
|
|
this.$set(this.formValidate.attrValue[i], 'attrValue', JSON.stringify(this.formValidate.attrValue[i].attrValue)); // |
|
|
|
|
delete this.formValidate.attrValue[i].value0 |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.formValidate.attr = [{ attrName: '规格', attrValues: '默认', id: this.$route.params.id ? this.formValidate.attr[0].id : 0 }] |
|
|
|
|
this.OneattrValue.map(item => { |
|
|
|
|
this.$set(item, 'attrValue', JSON.stringify({ '规格': '默认' })) |
|
|
|
|
}) |
|
|
|
|
this.formValidate.attrValue = this.OneattrValue |
|
|
|
|
} |
|
|
|
|
this.$refs[name].validate((valid) => { |
|
|
|
|
if (valid) { |
|
|
|
|
this.fullscreenLoading = true |
|
|
|
|
this.$route.params.id ? productUpdateApi(this.formValidate).then(async res => { |
|
|
|
|
this.$message.success('编辑成功'); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.$router.push({ path: '/store/index' }); |
|
|
|
|
}, 500); |
|
|
|
|
this.fullscreenLoading = false |
|
|
|
|
}).catch(res => { |
|
|
|
|
this.fullscreenLoading = false |
|
|
|
|
}) : productCreateApi(this.formValidate).then(async res => { |
|
|
|
|
this.$message.success('新增成功'); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.$router.push({ path: '/store/index' }); |
|
|
|
|
}, 500); |
|
|
|
|
this.fullscreenLoading = false |
|
|
|
|
}).catch(res => { |
|
|
|
|
this.fullscreenLoading = false |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
if (!this.formValidate.storeName || !this.formValidate.cateId || !this.formValidate.keyword |
|
|
|
|
|| !this.formValidate.unitName || !this.formValidate.storeInfo || !this.formValidate.image || !this.formValidate.sliderImages) { |
|
|
|
|
this.$message.warning("请填写完整商品信息!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
// this.onChangeGroup() |
|
|
|
|
// if (this.formValidate.specType && this.formValidate.attr.length < 1) return this.$message.warning("请填写多规格属性!"); |
|
|
|
|
// this.formValidate.cateId = this.formValidate.cateIds.join(',') |
|
|
|
|
// this.formValidate.sliderImage = JSON.stringify(this.formValidate.sliderImages) |
|
|
|
|
// if (this.formValidate.specType) { |
|
|
|
|
// this.formValidate.attrValue = this.ManyAttrValue; |
|
|
|
|
// this.formValidate.attr = this.formValidate.attr.map((item) => { |
|
|
|
|
// return { |
|
|
|
|
// attrName: item.attrName, |
|
|
|
|
// id: item.id, |
|
|
|
|
// attrValues: item.attrValue.join(','), |
|
|
|
|
// } |
|
|
|
|
// }) |
|
|
|
|
// for (var i = 0; i < this.formValidate.attrValue.length; i++) { |
|
|
|
|
// this.$set(this.formValidate.attrValue[i], 'id', 0); |
|
|
|
|
// this.$set(this.formValidate.attrValue[i], 'productId', 0); |
|
|
|
|
// this.$set(this.formValidate.attrValue[i], 'attrValue', JSON.stringify(this.formValidate.attrValue[i].attrValue)); // |
|
|
|
|
// delete this.formValidate.attrValue[i].value0 |
|
|
|
|
// } |
|
|
|
|
// } else { |
|
|
|
|
// this.formValidate.attr = [{ attrName: '规格', attrValues: '默认', id: this.$route.params.id ? this.formValidate.attr[0].id : 0 }] |
|
|
|
|
// this.OneattrValue.map(item => { |
|
|
|
|
// this.$set(item, 'attrValue', JSON.stringify({ '规格': '默认' })) |
|
|
|
|
// }) |
|
|
|
|
// this.formValidate.attrValue = this.OneattrValue |
|
|
|
|
// } |
|
|
|
|
// this.$refs[name].validate((valid) => { |
|
|
|
|
// if (valid) { |
|
|
|
|
// this.fullscreenLoading = true |
|
|
|
|
// this.$route.params.id ? productUpdateApi(this.formValidate).then(async res => { |
|
|
|
|
// this.$message.success('编辑成功'); |
|
|
|
|
// setTimeout(() => { |
|
|
|
|
// this.$router.push({ path: '/store/index' }); |
|
|
|
|
// }, 500); |
|
|
|
|
// this.fullscreenLoading = false |
|
|
|
|
// }).catch(res => { |
|
|
|
|
// this.fullscreenLoading = false |
|
|
|
|
// }) : productCreateApi(this.formValidate).then(async res => { |
|
|
|
|
// this.$message.success('新增成功'); |
|
|
|
|
// setTimeout(() => { |
|
|
|
|
// this.$router.push({ path: '/store/index' }); |
|
|
|
|
// }, 500); |
|
|
|
|
// this.fullscreenLoading = false |
|
|
|
|
// }).catch(res => { |
|
|
|
|
// this.fullscreenLoading = false |
|
|
|
|
// }) |
|
|
|
|
// } else { |
|
|
|
|
// if (!this.formValidate.storeName || !this.formValidate.cateId || !this.formValidate.keyword |
|
|
|
|
// || !this.formValidate.unitName || !this.formValidate.storeInfo || !this.formValidate.image || !this.formValidate.sliderImages) { |
|
|
|
|
// this.$message.warning("请填写完整商品信息!"); |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
}), |
|
|
|
|
// 表单验证 |
|
|
|
|
validate(prop, status, error) { |
|
|
|
|