pull/4/head
xk_chenlianjie 1 year ago
commit 22d3509cf8
  1. 33
      src/api/product/productAttr.js
  2. 3
      src/components/Category/edit.vue
  3. 8
      src/utils/validate.js
  4. 71
      src/views/product/brand/components/AddOrEdit.vue
  5. 117
      src/views/product/brand/index.vue
  6. 564
      src/views/product/productAdd/newIndex.vue

@ -1,10 +1,39 @@
import request from '@/utils/request'
var service_name = 'oil-mall'
export default {
brandGetByPage() {
brandGetAll(data) {
return request({
url: `/${service_name}/mallProductBrands/getAll`,
method: 'post',
data
})
},
brandUpdate(data) {
return request({
url: `/${service_name}/mallProductBrands/update`,
method: 'post',
data
})
},
brandDelete(data) {
return request({
url: `/${service_name}/mallProductBrands/delete`,
method: 'post',
data
})
},
brandSave(data) {
return request({
url: `/${service_name}/mallProductBrands/save`,
method: 'post',
data
})
},
brandGetByPage(data) {
return request({
url: `/${service_name}/mallProductBrands/getByPage`,
method: 'get',
method: 'post',
data
})
},
getAllAttributesType() {

@ -86,8 +86,7 @@ export default {
},
addTreeListLabelForCasCard(arr, child) {
},
handlerSubmit() {
console.log(this.model,'454545')
handlerSubmit() {
productApi[this.model](this.editPram).then((result) => {
if(result.code==20000){
this.$parent.$parent.editDialogConfig.visible=false;

@ -156,12 +156,14 @@ export function isStrictPromise(value) {
&& typeof value.then === 'function'
&& typeof value.finally === 'function';
}
export function loadingFn(loading, callback) {
export function loadingFn(loading, callback,minTimes=0) {
this[loading] = true
if (isStrictPromise(callback)) {
callback.finally(() => {
console.log("运行")
this[loading] = false
console.log("运行");
setTimeout(() => {
this[loading] = false
}, minTimes);
})
};
}

@ -0,0 +1,71 @@
<template>
<div>
<el-form ref="form" :model="form">
<el-form-item prop="brandName" label="品牌名称" label-width="100px"
:rules="[{ required: true, message: '请输入品牌名称', trigger: ['blur', 'change'] }]">
<el-input v-model="form.brandName"></el-input>
</el-form-item>
<el-form-item label="品牌首字母" prop="firstLetter" label-width="100px"
:rules="[{ required: true, message: '请输入品牌首字母', trigger: ['blur', 'change'] }]">
<el-input v-model="form.firstLetter"></el-input>
</el-form-item>
<el-form-item label=" 品牌LOGO" label-width="100px">
<upload :photo="form.logoUrl" @success="uploadSuccess" tip="只能上传jpg/png格式文件,文件不能超过50kb">
</upload>
</el-form-item>
<el-form-item label="排序" label-width="100px">
<el-input-number v-model="form.sort" :min="0" />
</el-form-item>
<el-form-item label="是否显示" label-width="100px">
<el-switch v-model="form.showFlag" active-text="显示" inactive-text="隐藏" active-value="1"
inactive-value="2" />
</el-form-item>
</el-form>
<div slot="footer" class="footer">
<el-button @click="$emit('close')" > </el-button>
<el-button @click="save" type="primary"> </el-button>
</div>
</div>
</template>
<script>
import upload from '@/components/Upload/index'
export default {
components: { upload },
data() {
return {
apiMode:"brandSave",
form: {
"brandName": "",
"firstLetter": "",
"logoUrl": "",
"showFlag": "1",
"sort": "1"
}
}
},
methods: {
save() {
this.$refs.form.validate((valid) => {
if (valid) {
this.$emit("brandSave",this.form,this.apiMode)
}
});
},
uploadSuccess(e, res) {
if (res.code == 20000) {
({ publicUrl: this.form.logoUrl } = res.data);
}
},
}
}
</script>
<style scoped>
.footer {
width: 100%;
display: flex;
justify-content: center;
}
</style>

@ -5,7 +5,7 @@
<el-form ref="artFrom" :model="page" label-width="80px" label-position="right" class="tabform"
@submit.native.prevent inline>
<el-form-item label="输入搜索">
<el-input clearable v-model="page.rule_name" placeholder="品牌名称/关键词"
<el-input clearable v-model="page.brandName" placeholder="品牌名称/关键词"
class="form_content_width"></el-input>
</el-form-item>
<el-form-item>
@ -15,7 +15,7 @@
</div>
</el-card>
<el-card :bordered="false" shadow="never" class="ivu-mt-16">
<el-button type="primary" @click="addType">添加品牌</el-button>
<el-button type="primary" @click="addBrand">添加品牌</el-button>
<el-table @current-change="tableCurrentChange" ref="table" :data="tableData" v-loading="loading"
highlight-current-row :row-key="getRowKey" @selection-change="handleSelectRow" empty-text="暂无数据"
class="mt14">
@ -27,57 +27,47 @@
</el-table-column>
<el-table-column label="品牌名称">
<template slot-scope="scope">
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column label="品牌首字母">
<template slot-scope="scope">
<el-button @click="showAttrList(scope.row)" type="text">
{{ scope.row.attrCount }}
</el-button>
</template>
</el-table-column>
<el-table-column label="排序">
<template slot-scope="scope">
<el-button @click="showAttrList(scope.row)" type="text">
{{ scope.row.attrCount }}
</el-button>
<span>{{ scope.row.brandName }}</span>
</template>
</el-table-column>
<el-table-column label="品牌首字母" prop="firstLetter"> </el-table-column>
<el-table-column label="排序" prop="sort"> </el-table-column>
<el-table-column label="是否显示">
<template slot-scope="scope">
<el-button @click="showAttrList(scope.row)" type="text">
{{ scope.row.attrCount }}
</el-button>
<el-switch disabled active-value="1" inactive-value="0" v-model="scope.row.showFlag"
active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right">
<template slot-scope="scope">
<a @click="edit(scope.row)">编辑</a>
<el-button type="text" @click="edit(scope.row)">编辑</el-button>
<el-divider direction="vertical"></el-divider>
<a @click="del(scope.row)">删除</a>
<el-button type="text" @click="del(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="acea-row row-right page">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.currentPage"
:page-sizes="[10, 15, 20, 30]"
:page-size="page.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="page.totalCount" />
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="page.currentPage" :page-sizes="[10, 15, 20, 30]" :page-size="page.pageSize"
layout="total, sizes, prev, pager, next, jumper" :total="page.totalCount" />
</div>
</el-card>
<el-dialog title="品牌设置" :visible.sync="isAddOrEdit" v-loading="addLoading">
<addOrEdit v-if="isAddOrEdit" @close="isAddOrEdit = false" @brandSave="brandSave" ref="addOrEdit"></addOrEdit>
</el-dialog>
</div>
</template>
<script>
import productApi from '@/api/product/productAttr.js';
import { loadingFn } from "@/utils/validate"
import addOrEdit from "./components/AddOrEdit.vue"
export default {
components: { addOrEdit },
data() {
return {
addLoading: false,
isAddOrEdit: false,
selection: [],
selectAttrList: null,
isShowAttrList: false,
@ -85,7 +75,9 @@ export default {
page: {
"currentPage": 1,
"pageSize": 10,
"params": {},
"params": {
brandName:""
},
totalCount: 0
},
tableData: [],
@ -96,14 +88,38 @@ export default {
};
},
computed: {},
created() { },
created() {
this.init()
},
methods: {
addBrand() {
this.isAddOrEdit = true;
},
brandSave(e,model="brandSave") {
loadingFn.call(this, "addLoading", productApi[model](e).then(res => {
if (res.code == 20000) {
this.$message.success("操作成功")
setTimeout(() => {
this.isAddOrEdit = false;
this.getList();
}, 1000);
}
}), 1000);
},
tableCurrentChange(e) { },
handleCurrentChange(val) { },
handleSizeChange(val) { },
handleCurrentChange(val) {
this.page.currentPage = val;
this.getList()
},
handleSizeChange(val) {
this.page.pageSize = val
this.getList()
},
clearSelection() { },
onCancel() { },
addType() { },
showAttrList(e) { },
getRowKey(row) { },
//
@ -112,11 +128,30 @@ export default {
handleSelectRow(selection) { },
setChecked() { },
//
del(row) { },
del(row) {
this.$alert('请确定删除该数据!', '提示', {
confirmButtonText: '确定',
callback: action => {
if (action == "confirm") {
loadingFn.call(this, "loading", productApi.brandDelete(row).then(res => {
if (res.code = 20000) {
this.$message.success("操作成功!")
this.handleCurrentChange()
}
}));
}
}
});
},
addAttr(model) {
},
//
edit(row) {
edit(row) {
this.isAddOrEdit = true;
this.$nextTick(() => {
this.$refs.addOrEdit.apiMode = "brandUpdate"
this.$refs.addOrEdit.form = Object.assign(this.$refs.addOrEdit.form, row);
})
},
//
getList() {
@ -125,7 +160,13 @@ export default {
}));
},
//
userSearchs() { },
userSearchs() {
this.handleCurrentChange()
},
//
init() {
this.getList()
}
},
};
</script>

@ -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")
},
// 02
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) {

Loading…
Cancel
Save