Commit 3808ff71 authored by verestrasz's avatar verestrasz

update

parent f0901f14
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
:isEdit="isEdit" :isEdit="isEdit"
:isAgain="isAgain" :isAgain="isAgain"
:isSelf="isSelf" :isSelf="isSelf"
:isDraft="isDraft"
:status="status" :status="status"
/> />
<info-con <info-con
...@@ -369,362 +370,362 @@ ...@@ -369,362 +370,362 @@
</template> </template>
<script> <script>
import BaseInfo from './base-info' import BaseInfo from "./base-info";
import SaleInfo from './sale-info' import SaleInfo from "./sale-info";
import DeciptInfo from './decpit-info' import DeciptInfo from "./decpit-info";
import { getPosterFromVideoUrl } from '@/libs/tools' import { getPosterFromVideoUrl } from "@/libs/tools";
import { mapMutations } from 'vuex' import { mapMutations } from "vuex";
import InfoCon from './info-con' import InfoCon from "./info-con";
import { formatTime } from '../../../libs/ali-oss' import { formatTime } from "../../../libs/ali-oss";
export default { export default {
name: 'add_good', name: "add_good",
components: { components: {
BaseInfo, BaseInfo,
SaleInfo, SaleInfo,
DeciptInfo, DeciptInfo,
InfoCon InfoCon,
}, },
computed: { computed: {
title () { title() {
if (this.routeName === 'update_good') { if (this.routeName === "update_good") {
return '编辑商品 - 填写商品信息' return "编辑商品 - 填写商品信息";
} else if (this.routeName == 'good_detail') { } else if (this.routeName == "good_detail") {
return '商品详情' return "商品详情";
// this.isSelf // : `商品详情( 品牌商:${this.form.brandName} )` // this.isSelf // : `商品详情( 品牌商:${this.form.brandName} )`
} else if (this.routeName === 'again_good') { } else if (this.routeName === "again_good") {
return '重新发布商品 - 填写商品信息' return "重新发布商品 - 填写商品信息";
} else { } else {
return '发布商品 - 填写商品信息' return "发布商品 - 填写商品信息";
} }
}, },
isDetail () { isDetail() {
return this.routeName === 'good_detail' return this.routeName === "good_detail";
}, },
isAdd () { isAdd() {
return this.routeName === 'add_good' return this.routeName === "add_good";
}, },
isEdit () { isEdit() {
return this.routeName === 'update_good' return this.routeName === "update_good";
}, },
isAgain () { isAgain() {
return this.routeName === 'again_good' return this.routeName === "again_good";
}, },
isDraft () { isDraft() {
return this.routeName === 'draft_good' return this.routeName === "draft_good";
}, },
isSelf () { isSelf() {
return this.form.brandId === this.$store.state.admin.brandId return this.form.brandId === this.$store.state.admin.brandId;
},
status() {
return this.form.baseInfo.type;
}, },
status () {
return this.form.baseInfo.type
}
}, },
data () { data() {
return { return {
routeName: '', routeName: "",
delayDeliveryDisabled: false, delayDeliveryDisabled: false,
form: { form: {
brandId: '', brandId: "",
brandName: '', brandName: "",
goodsId: '', goodsId: "",
// templateId: '', // templateId: '',
baseInfo: { baseInfo: {
name: '', // 商品名称 name: "", // 商品名称
description: '', // 商品描述 description: "", // 商品描述
prop: [{ name: '', val: '' }], // 商品属性 prop: [{ name: "", val: "" }], // 商品属性
categoryId: [], // 类目选择 categoryId: [], // 类目选择
type: '6' // 商品类型 type: "6", // 商品类型
}, },
saleInfo: { saleInfo: {
sku: [], sku: [],
imgObj: {}, imgObj: {},
commodityPass: 1, commodityPass: 1,
number: '', // 发行数量:只有商户选择“可拷贝”时,才会出现 number: "", // 发行数量:只有商户选择“可拷贝”时,才会出现
price: '', // 商品价格 price: "", // 商品价格
type: '', // NFT类型(1.单个,不可考贝 2.可拷贝) type: "", // NFT类型(1.单个,不可考贝 2.可拷贝)
tzType: '', // 1.内部发行 2.外部绑定 tzType: "", // 1.内部发行 2.外部绑定
tokenId: '', // 绑定的外部通证id tokenId: "", // 绑定的外部通证id
salesType: 4, // 销售模式 salesType: 4, // 销售模式
difficulty: 3, difficulty: 3,
isHide: false, isHide: false,
stock: 0, // stock: 0,
blindBoxRule: '' blindBoxRule: "",
// statu:this.status // statu:this.status
}, },
deciptInfo: { deciptInfo: {
video: '', video: "",
videoList: [], videoList: [],
nftFile: '', nftFile: "",
nftEnclosureList: [], nftEnclosureList: [],
videoThumb: '', videoThumb: "",
thumb: '', thumb: "",
thumbList: [], thumbList: [],
detailPictures: [], detailPictures: [],
detailDescribe: '', detailDescribe: "",
defaultDetailPicture: [], defaultDetailPicture: [],
defaultVideoList: [], defaultVideoList: [],
defaultThumbList: [], defaultThumbList: [],
defaultNftEnclosureList: [] defaultNftEnclosureList: [],
// statu:this.status // statu:this.status
}, },
returnType: '0', // 退货类型 returnType: "0", // 退货类型
returnReason: '', // 退货理由 returnReason: "", // 退货理由
note: '', // 商品备注 note: "", // 商品备注
buyerDeposit: '', // 买家保证金 buyerDeposit: "", // 买家保证金
priceIncrease: '', // 出价最小增幅 priceIncrease: "", // 出价最小增幅
endTime: '', // 结束时间 endTime: "", // 结束时间
deposit: '', // 首付比例 deposit: "", // 首付比例
depositType: '', // 首付比例类型 depositType: "", // 首付比例类型
drawStartTime: '', // 预计提货开始时间 drawStartTime: "", // 预计提货开始时间
drawEndTime: '', // 预计提货结束时间 drawEndTime: "", // 预计提货结束时间
saleStartTime: '', // 预售开始时间 saleStartTime: "", // 预售开始时间
saleEndTime: '', // 预售结束时间 saleEndTime: "", // 预售结束时间
stock: '', // 积分库存 stock: "", // 积分库存
pnum: '', // 积分数量 pnum: "", // 积分数量
traceabilityNumber: '', // 溯源编号 traceabilityNumber: "", // 溯源编号
delayDelivery: false, // 延迟提货 delayDelivery: false, // 延迟提货
packageDTO: { packageDTO: {
resource: [ resource: [
{ {
integralMerchantNameList: [], integralMerchantNameList: [],
goodsId: '', goodsId: "",
skuId: '', skuId: "",
number: '', number: "",
specificationsList: [], specificationsList: [],
actualNumber: '' actualNumber: "",
} },
], // 打包资源 ], // 打包资源
price: '', // 打包价格 price: "", // 打包价格
stock: '' // 库存 stock: "", // 库存
}, },
nftdto: { nftdto: {
number: '', // 发行数量:只有商户选择“可拷贝”时,才会出现 number: "", // 发行数量:只有商户选择“可拷贝”时,才会出现
price: '', // 商品价格 price: "", // 商品价格
type: '', // NFT类型(1.单个,不可考贝 2.可拷贝) type: "", // NFT类型(1.单个,不可考贝 2.可拷贝)
tzType: '', // 1.内部发行 2.外部绑定 tzType: "", // 1.内部发行 2.外部绑定
tokenId: '' // 绑定的外部通证id tokenId: "", // 绑定的外部通证id
} },
}, },
skuNumber: '', skuNumber: "",
loading: true, loading: true,
expressList: [], expressList: [],
profitList: [], profitList: [],
integralMerchantNameList: [], integralMerchantNameList: [],
specificationsList: [], specificationsList: [],
idx: '', idx: "",
fixedProportion: '', fixedProportion: "",
fixedAmount: '', fixedAmount: "",
nftList: [], nftList: [],
submitLoading: false, submitLoading: false,
startOption: { startOption: {
// 指定开始限制时间 // 指定开始限制时间
disabledDate: (date) => { disabledDate: (date) => {
return date && date.valueOf() < Date.now() - 86400000 return date && date.valueOf() < Date.now() - 86400000;
} },
}, },
endOption: { endOption: {
// 指定终止日期 // 指定终止日期
disabledDate: (date) => { disabledDate: (date) => {
return date && date.valueOf() < Date.now() - 86400000 return date && date.valueOf() < Date.now() - 86400000;
} },
}, },
drawStartOption: { drawStartOption: {
// 指定开始限制时间 // 指定开始限制时间
disabledDate: (date) => { disabledDate: (date) => {
return date && date.valueOf() < Date.now() - 86400000 return date && date.valueOf() < Date.now() - 86400000;
} },
}, },
drawEndOption: { drawEndOption: {
// 指定终止日期 // 指定终止日期
disabledDate: (date) => { disabledDate: (date) => {
return date && date.valueOf() < Date.now() - 86400000 return date && date.valueOf() < Date.now() - 86400000;
} },
}, },
buyEndOption: { buyEndOption: {
// 指定终止日期 // 指定终止日期
disabledDate: (date) => { disabledDate: (date) => {
return date && date.valueOf() < Date.now() - 86400000 return date && date.valueOf() < Date.now() - 86400000;
} },
}, },
draftLoading: false draftLoading: false,
} };
}, },
methods: { methods: {
...mapMutations(['closeTag']), ...mapMutations(["closeTag"]),
addAge () { addAge() {
this.form.packageDTO.resource.push({ this.form.packageDTO.resource.push({
integralMerchantNameList: [], integralMerchantNameList: [],
goodsId: '', goodsId: "",
skuId: '', skuId: "",
number: '', number: "",
specificationsList: [], specificationsList: [],
actualNumber: '' actualNumber: "",
}) });
}, },
changeTzType () { changeTzType() {
this.form.nftdto.type = '' this.form.nftdto.type = "";
this.form.nftdto.number = '' this.form.nftdto.number = "";
this.form.nftdto.tokenId = '' this.form.nftdto.tokenId = "";
}, },
changeType () { changeType() {
this.form.nftdto.number = '' this.form.nftdto.number = "";
}, },
delAge (index) { delAge(index) {
this.form.packageDTO.resource.splice(index, 1) this.form.packageDTO.resource.splice(index, 1);
}, },
handleNFT (val) { handleNFT(val) {
console.log(val) console.log(val);
this.form.nftdto.number = val.availableNumber this.form.nftdto.number = val.availableNumber;
}, },
handleSearch (goodsInfo, index) { handleSearch(goodsInfo, index) {
if (!goodsInfo) { if (!goodsInfo) {
return this.$Message.warning('请先输入资源编号以便查询!') return this.$Message.warning("请先输入资源编号以便查询!");
} }
this.api({ this.api({
apiName: 'spugetbyvague', apiName: "spugetbyvague",
postdata: goodsInfo, postdata: goodsInfo,
success: (res) => { success: (res) => {
this.form.packageDTO.resource[index].integralMerchantNameList = this.form.packageDTO.resource[index].integralMerchantNameList =
res.data res.data;
if ( if (
this.form.packageDTO.resource[index].integralMerchantNameList this.form.packageDTO.resource[index].integralMerchantNameList
.length === 1 .length === 1
) { ) {
let goodsId = let goodsId =
this.form.packageDTO.resource[index].integralMerchantNameList[0] this.form.packageDTO.resource[index].integralMerchantNameList[0]
.goodsId .goodsId;
this.api({ this.api({
apiName: 'skugetbygoodsId', apiName: "skugetbygoodsId",
postdata: goodsId, postdata: goodsId,
success: (res) => { success: (res) => {
let arr = [] let arr = [];
let list = let list =
this.form.packageDTO.resource[index].specificationsList this.form.packageDTO.resource[index].specificationsList;
if (list && list.length > 0) { if (list && list.length > 0) {
for (let item of res.data) { for (let item of res.data) {
if ( if (
list.find((x) => { list.find((x) => {
return x.skuId === item.skuId return x.skuId === item.skuId;
}) })
) { ) {
item.stock = list.find((x) => { item.stock = list.find((x) => {
return x.skuId === item.skuId return x.skuId === item.skuId;
}).stock }).stock;
} }
arr.push(item) arr.push(item);
} }
} else { } else {
arr = res.data arr = res.data;
} }
this.form.packageDTO.resource[index].specificationsList = arr this.form.packageDTO.resource[index].specificationsList = arr;
} },
}) });
} }
} },
}) });
}, },
handleSpecifications (idx, index) { handleSpecifications(idx, index) {
this.idx = idx this.idx = idx;
this.form.packageDTO.resource[index].number = '' this.form.packageDTO.resource[index].number = "";
for (var i = 0; i < this.form.packageDTO.resource.length - 1; i++) { for (var i = 0; i < this.form.packageDTO.resource.length - 1; i++) {
for (var j = i + 1; j < this.form.packageDTO.resource.length; j++) { for (var j = i + 1; j < this.form.packageDTO.resource.length; j++) {
if ( if (
this.form.packageDTO.resource[i].skuId === this.form.packageDTO.resource[i].skuId ===
this.form.packageDTO.resource[j].skuId this.form.packageDTO.resource[j].skuId
) { ) {
let title = '规格信息不能重复!' let title = "规格信息不能重复!";
this.form.packageDTO.resource[index].skuId = '' this.form.packageDTO.resource[index].skuId = "";
return this.$Notice.error({ title }) return this.$Notice.error({ title });
} }
} }
} }
}, },
onBlur (index, val) { onBlur(index, val) {
for (let i = 0, len = val.specificationsList.length; i < len; i++) { for (let i = 0, len = val.specificationsList.length; i < len; i++) {
if (val.specificationsList[i].skuId === val.skuId) { if (val.specificationsList[i].skuId === val.skuId) {
this.idx = i this.idx = i;
break break;
} }
} }
let idx = this.idx let idx = this.idx;
this.form.packageDTO.resource[index].actualNumber = this.form.packageDTO.resource[index].actualNumber =
this.form.packageDTO.resource[index].specificationsList[idx].stock this.form.packageDTO.resource[index].specificationsList[idx].stock;
this.$set( this.$set(
this.form.packageDTO.resource, this.form.packageDTO.resource,
index, index,
this.form.packageDTO.resource[index] this.form.packageDTO.resource[index]
) );
let stockNumber = JSON.parse(val.number) * this.form.packageDTO.stock let stockNumber = JSON.parse(val.number) * this.form.packageDTO.stock;
if (stockNumber > this.form.packageDTO.resource[index].actualNumber) { if (stockNumber > this.form.packageDTO.resource[index].actualNumber) {
this.form.packageDTO.resource[index].number = '' this.form.packageDTO.resource[index].number = "";
return this.$Notice.warning({ return this.$Notice.warning({
title: `库存*填写的资源量不能超过总资源数量` title: `库存*填写的资源量不能超过总资源数量`,
}) });
} }
}, },
stockBlur (val) { stockBlur(val) {
let skuNumber = this.form.packageDTO.resource let skuNumber = this.form.packageDTO.resource;
skuNumber.forEach((item, index) => { skuNumber.forEach((item, index) => {
let number = item.number * val let number = item.number * val;
let n = NaN let n = NaN;
for (let i = 0, len = item.specificationsList.length; i < len; i++) { for (let i = 0, len = item.specificationsList.length; i < len; i++) {
if (item.specificationsList[i].skuId === item.skuId) { if (item.specificationsList[i].skuId === item.skuId) {
n = i n = i;
break break;
} }
} }
if (number > item.specificationsList[n].stock) { if (number > item.specificationsList[n].stock) {
this.form.packageDTO.resource[index].number = '' this.form.packageDTO.resource[index].number = "";
return this.$Notice.warning({ return this.$Notice.warning({
title: `库存 * 填写的资源量不能超过总资源数量` title: `库存 * 填写的资源量不能超过总资源数量`,
}) });
} }
}) });
}, },
requestOptionData () { requestOptionData() {
// 获取快递模板 // 获取快递模板
this.api({ this.api({
apiName: 'templateList', apiName: "templateList",
success: (res) => { success: (res) => {
this.expressList = res.data this.expressList = res.data;
} },
}) });
}, },
getNftList () { getNftList() {
// 获取外部NFT // 获取外部NFT
this.api({ this.api({
apiName: 'externnftlist', apiName: "externnftlist",
success: (res) => { success: (res) => {
// console.log('333', this.nftList) // console.log('333', this.nftList)
this.nftList = res.data this.nftList = res.data;
} },
}) });
}, },
getDelayDelivery () { getDelayDelivery() {
if (!this.isDetail) { if (!this.isDetail) {
this.api({ this.api({
apiName: 'merchantDelayDelivery', apiName: "merchantDelayDelivery",
success: (res) => { success: (res) => {
if (res.data == 0) { if (res.data == 0) {
this.delayDeliveryDisabled = true this.delayDeliveryDisabled = true;
} }
} },
}) });
} }
}, },
getTemplateorshopquery () { getTemplateorshopquery() {
if (this.isAdd) { if (this.isAdd) {
this.api({ this.api({
apiName: 'templateorshopquery', apiName: "templateorshopquery",
success: (res) => {} success: (res) => {},
}) });
} }
}, },
requestGoodDetail (goodsId) { requestGoodDetail(goodsId) {
this.loading = true this.loading = true;
this.api({ this.api({
apiName: 'getGoodDetail', apiName: "getGoodDetail",
postdata: { goodsId }, postdata: { goodsId },
success: (res) => { success: (res) => {
let { let {
...@@ -751,8 +752,8 @@ export default { ...@@ -751,8 +752,8 @@ export default {
blindBoxPrice, blindBoxPrice,
difficulty, difficulty,
goodsNftVO, goodsNftVO,
blindBoxRule blindBoxRule,
} = res.data } = res.data;
let form = { let form = {
goodsId: goodsId, goodsId: goodsId,
blindBoxPrice, blindBoxPrice,
...@@ -765,39 +766,39 @@ export default { ...@@ -765,39 +766,39 @@ export default {
this.isDraft || this.isEdit this.isDraft || this.isEdit
? JSON.parse(categoryIds) ? JSON.parse(categoryIds)
: categoryName, // 类目选择 : categoryName, // 类目选择
type: type // 商品类型 type: type, // 商品类型
}, },
deciptInfo: { deciptInfo: {
nftFile: nftFile || '', nftFile: nftFile || "",
nftEnclosureList: nftFile ? [nftFile] : [], nftEnclosureList: nftFile ? [nftFile] : [],
video: video || '', video: video || "",
videoList: video ? [video] : [], videoList: video ? [video] : [],
thumb, thumb,
thumbList: thumb ? [thumb] : '', thumbList: thumb ? [thumb] : "",
detailPictures: imgList ? JSON.parse(imgList) : [], detailPictures: imgList ? JSON.parse(imgList) : [],
detailDescribe: detail, detailDescribe: detail,
defaultDetailPicture: imgList ? JSON.parse(imgList) : [], defaultDetailPicture: imgList ? JSON.parse(imgList) : [],
defaultVideoList: video ? [video] : [], defaultVideoList: video ? [video] : [],
defaultThumbList: [thumb], defaultThumbList: [thumb],
defaultNftEnclosureList: nftFile ? [nftFile] : [] defaultNftEnclosureList: nftFile ? [nftFile] : [],
}, },
returnType: returnType + '', // 退货类型 returnType: returnType + "", // 退货类型
returnReason: returnReason, // 退货理由 returnReason: returnReason, // 退货理由
note: note, // 商品备注 note: note, // 商品备注
delayDelivery: !!delayDelivery, delayDelivery: !!delayDelivery,
traceabilityNumber: traceabilityNumber traceabilityNumber: traceabilityNumber,
} };
let saleInfo = { let saleInfo = {
...goodsNftVO, ...goodsNftVO,
salesType, salesType,
sku: [], sku: [],
blindBoxRule blindBoxRule,
} };
if (salesType === 4) { if (salesType === 4) {
saleInfo.commodityPass = commodityPass || 1 saleInfo.commodityPass = commodityPass || 1;
saleInfo.price = blindBoxPrice || 0 saleInfo.price = blindBoxPrice || 0;
saleInfo.difficulty = difficulty || 1 saleInfo.difficulty = difficulty || 1;
for (let item of skus) { for (let item of skus) {
let obj = { let obj = {
...item, ...item,
...@@ -805,41 +806,41 @@ export default { ...@@ -805,41 +806,41 @@ export default {
name: item.propertyList[0].propVal, name: item.propertyList[0].propVal,
upload: { upload: {
imageList: [item.image], imageList: [item.image],
defaultImgList: [item.image] defaultImgList: [item.image],
} },
} };
saleInfo.sku.push(obj) saleInfo.sku.push(obj);
} }
} }
if (salesType === 1) { // if (salesType === 1) {
saleInfo.stock = 0 // saleInfo.stock = 0
if (skus && skus.length>0) { // if (skus && skus.length>0) {
saleInfo.stock = skus[0].stock // saleInfo.stock = skus[0].stock
} // }
} // }
form.saleInfo = saleInfo form.saleInfo = saleInfo;
this.form = form this.form = form;
}, },
complete: () => { complete: () => {
this.loading = false this.loading = false;
} },
}) });
}, },
initData () { initData() {
let routeName = this.$route.name let routeName = this.$route.name;
let { goodsId } = this.$route.query let { goodsId } = this.$route.query;
this.form.goodsId = goodsId this.form.goodsId = goodsId;
this.routeName = routeName this.routeName = routeName;
if ( if (
routeName == 'update_good' || routeName == "update_good" ||
routeName == 'good_detail' || routeName == "good_detail" ||
routeName == 'again_good' || routeName == "again_good" ||
routeName == 'draft_good' routeName == "draft_good"
) { ) {
this.requestGoodDetail(goodsId) this.requestGoodDetail(goodsId);
} else { } else {
this.loading = false this.loading = false;
} }
}, },
// checkForm() { // checkForm() {
...@@ -1188,13 +1189,13 @@ export default { ...@@ -1188,13 +1189,13 @@ export default {
// form.delayDelivery = delayDelivery == true ? "1" : "0"; // form.delayDelivery = delayDelivery == true ? "1" : "0";
// return { errMsg, form }; // return { errMsg, form };
// }, // },
checkForm () { checkForm() {
let form = { let form = {
blindBoxPrice: 0, blindBoxPrice: 0,
categoryId: categoryId:
this.form.baseInfo.categoryId.length > 0 this.form.baseInfo.categoryId.length > 0
? JSON.stringify(this.form.baseInfo.categoryId) ? JSON.stringify(this.form.baseInfo.categoryId)
: '', : "",
commodityPass: 0, commodityPass: 0,
delayDelivery: this.form.delayDelivery ? 1 : 0, delayDelivery: this.form.delayDelivery ? 1 : 0,
description: this.form.baseInfo.description, description: this.form.baseInfo.description,
...@@ -1203,17 +1204,17 @@ export default { ...@@ -1203,17 +1204,17 @@ export default {
imgList: imgList:
this.form.deciptInfo.detailPictures.length > 0 this.form.deciptInfo.detailPictures.length > 0
? JSON.stringify(this.form.deciptInfo.detailPictures) ? JSON.stringify(this.form.deciptInfo.detailPictures)
: '', : "",
name: this.form.baseInfo.name, name: this.form.baseInfo.name,
nftFile: nftFile:
this.form.deciptInfo.nftEnclosureList.length > 0 this.form.deciptInfo.nftEnclosureList.length > 0
? this.form.deciptInfo.nftEnclosureList[0] ? this.form.deciptInfo.nftEnclosureList[0]
: '', : "",
nftdto: this.form.nftdto, nftdto: this.form.nftdto,
note: this.form.note, note: this.form.note,
prop: this.form.baseInfo.prop prop: this.form.baseInfo.prop
? JSON.stringify(this.form.baseInfo.prop) ? JSON.stringify(this.form.baseInfo.prop)
: '', : "",
returnReason: this.form.returnReason, returnReason: this.form.returnReason,
returnType: this.form.returnType, returnType: this.form.returnType,
salesType: this.form.saleInfo.salesType, salesType: this.form.saleInfo.salesType,
...@@ -1221,254 +1222,262 @@ export default { ...@@ -1221,254 +1222,262 @@ export default {
thumb: thumb:
this.form.deciptInfo.thumbList.length > 0 this.form.deciptInfo.thumbList.length > 0
? this.form.deciptInfo.thumbList[0] ? this.form.deciptInfo.thumbList[0]
: '', : "",
traceabilityNumber: this.form.traceabilityNumber, traceabilityNumber: this.form.traceabilityNumber,
type: this.form.baseInfo.type, type: this.form.baseInfo.type,
video: video:
this.form.deciptInfo.videoList.length > 0 this.form.deciptInfo.videoList.length > 0
? this.form.deciptInfo.videoList[0] ? this.form.deciptInfo.videoList[0]
: '', : "",
videoPoster: videoPoster:
this.form.deciptInfo.videoList.length > 0 this.form.deciptInfo.videoList.length > 0
? getPosterFromVideoUrl(this.form.deciptInfo.videoList[0]) ? getPosterFromVideoUrl(this.form.deciptInfo.videoList[0])
: '' : "",
} };
if (this.form.goodsId) { if (this.form.goodsId) {
form.goodsId = this.form.goodsId form.goodsId = this.form.goodsId;
} }
if (this.form.saleInfo.salesType === 1) { if (this.form.saleInfo.salesType === 1) {
form.commodityPass = this.form.saleInfo.tzType
form.skuList = [
{
stock: this.form.saleInfo.stock,
propertyList: [
{
propKey: '规格名称',
propVal: ' '
}
]
}
]
form.nftdto = { form.nftdto = {
number: 1, number: this.form.saleInfo.number,
price: this.form.saleInfo.price, price: this.form.saleInfo.price,
tokenId: this.form.saleInfo.tokenId, tokenId: this.form.saleInfo.tokenId,
type: this.form.saleInfo.type, type: this.form.saleInfo.type,
tzType: this.form.saleInfo.tzType tzType: this.form.saleInfo.tzType,
};
if (form.type == 6) {
if (this.form.saleInfo.tzType == 1 && this.form.saleInfo.type == 1) {
this.form.saleInfo.number = 1;
}
} }
form.commodityPass = this.form.saleInfo.tzType;
form.skuList = [
{
stock: this.form.saleInfo.number,
propertyList: [
{
propKey: "规格名称",
propVal: " ",
},
],
},
];
} else if (this.form.saleInfo.salesType === 4) { } else if (this.form.saleInfo.salesType === 4) {
form.commodityPass = this.form.saleInfo.commodityPass form.commodityPass = this.form.saleInfo.commodityPass;
form.blindBoxPrice = this.form.saleInfo.price form.blindBoxPrice = this.form.saleInfo.price;
form.blindBoxRule = this.form.saleInfo.blindBoxRule form.blindBoxRule = this.form.saleInfo.blindBoxRule;
let skuList = [] let skuList = [];
for (let item of this.form.saleInfo.sku) { for (let item of this.form.saleInfo.sku) {
let obj = { let obj = {
...item, ...item,
isHide: item.isHide ? 1 : 0, isHide: item.isHide ? 1 : 0,
propertyList: [ propertyList: [
{ {
propKey: '规格名称', propKey: "规格名称",
propVal: item.name || '' propVal: item.name || "",
} },
] ],
} };
if ( if (
item.upload && item.upload &&
item.upload.imageList && item.upload.imageList &&
item.upload.imageList.length !== 0 item.upload.imageList.length !== 0
) { ) {
obj.image = item.upload.imageList[0] obj.image = item.upload.imageList[0];
} }
skuList.push(obj) skuList.push(obj);
} }
form.skuList = skuList form.skuList = skuList;
} }
return form return form;
}, },
validateForm () { validateForm() {
let errMsg = '' let errMsg = "";
if (!this.form.baseInfo) { if (!this.form.baseInfo) {
errMsg = '请完善基本信息!' errMsg = "请完善基本信息!";
} }
if (!this.form.baseInfo.name) { if (!this.form.baseInfo.name) {
errMsg = '请填写 基本信息 - 商品名称!' errMsg = "请填写 基本信息 - 商品名称!";
} }
if (!this.form.baseInfo.type) { if (!this.form.baseInfo.type) {
errMsg = '请填写 基本信息 - 商品类型!' errMsg = "请填写 基本信息 - 商品类型!";
} }
if (!this.form.baseInfo.description) { if (!this.form.baseInfo.description) {
errMsg = '请填写 基本信息 - 商品描述!' errMsg = "请填写 基本信息 - 商品描述!";
} }
if ( if (
!this.form.baseInfo.categoryId || !this.form.baseInfo.categoryId ||
this.form.baseInfo.categoryId.length === 0 this.form.baseInfo.categoryId.length === 0
) { ) {
errMsg = '请填写 基本信息 - 类目选择!' errMsg = "请填写 基本信息 - 类目选择!";
} }
if (!this.form.deciptInfo) { if (!this.form.deciptInfo) {
errMsg = '请完善图文描述!' errMsg = "请完善图文描述!";
} }
if ( if (
!this.form.deciptInfo.detailPictures || !this.form.deciptInfo.detailPictures ||
this.form.deciptInfo.detailPictures.length === 0 this.form.deciptInfo.detailPictures.length === 0
) { ) {
errMsg = '请上传 图文描述 - 商品图片!' errMsg = "请上传 图文描述 - 商品图片!";
} }
if ( if (
!this.form.deciptInfo.thumbList || !this.form.deciptInfo.thumbList ||
this.form.deciptInfo.thumbList.length === 0 this.form.deciptInfo.thumbList.length === 0
) { ) {
errMsg = '请上传 图文描述 - 缩略图!' errMsg = "请上传 图文描述 - 缩略图!";
} }
if (this.form.deciptInfo.detailDescribe.length > 18000) { if (this.form.deciptInfo.detailDescribe.length > 18000) {
errMsg = '图文描述 - 详情描述 内容长度过长!' errMsg = "图文描述 - 详情描述 内容长度过长!";
} }
if (this.form.deciptInfo.detailDescribe.length == 0) { if (this.form.deciptInfo.detailDescribe.length == 0) {
errMsg = '图文描述 - 请输入详情描述!' errMsg = "图文描述 - 请输入详情描述!";
} }
if (!this.form.saleInfo) { if (!this.form.saleInfo) {
errMsg = '请完善规格信息!' errMsg = "请完善规格信息!";
} else { } else {
if (!this.form.saleInfo.price) { if (!this.form.saleInfo.price) {
errMsg = '请填写商品价格!' errMsg = "请填写商品价格!";
} }
if (!this.form.saleInfo.salesType) { if (!this.form.saleInfo.salesType) {
errMsg = '请选择销售模式!' errMsg = "请选择销售模式!";
} else { } else {
if (this.form.saleInfo.salesType === 4) { if (this.form.saleInfo.salesType === 4) {
if (!this.form.saleInfo.blindBoxRule) { if (!this.form.saleInfo.blindBoxRule) {
errMsg = '请完善规格信息 - 盲盒规则!' errMsg = "请完善规格信息 - 盲盒规则!";
} }
if (this.form.saleInfo.blindBoxRule.length == 0) { if (this.form.saleInfo.blindBoxRule.length == 0) {
errMsg = '请完善规格信息 - 盲盒规则!' errMsg = "请完善规格信息 - 盲盒规则!";
} }
if (this.form.saleInfo.blindBoxRule.length > 18000) { if (this.form.saleInfo.blindBoxRule.length > 18000) {
errMsg = '规格信息 - 盲盒规则 内容长度过长!' errMsg = "规格信息 - 盲盒规则 内容长度过长!";
} }
if (this.form.saleInfo.blindBoxRule.length > 18000) { if (this.form.saleInfo.blindBoxRule.length > 18000) {
errMsg = '规格信息 - 盲盒规则 内容长度过长!' errMsg = "规格信息 - 盲盒规则 内容长度过长!";
} }
if ( if (
!this.form.saleInfo.sku || !this.form.saleInfo.sku ||
this.form.saleInfo.sku.length === 0 this.form.saleInfo.sku.length === 0
) { ) {
errMsg = '请完善规格信息!' errMsg = "请完善规格信息!";
} }
for (let item of this.form.saleInfo.sku) { for (let item of this.form.saleInfo.sku) {
if (!item.name) { if (!item.name) {
errMsg = '请填写 规格信息 - 规格名称!' errMsg = "请填写 规格信息 - 规格名称!";
break break;
} }
if (!item.weight) { if (!typeof item.weight === "number") {
errMsg = '请填写 规格信息 - 重量!' errMsg = "请填写 规格信息 - 重量!";
break break;
} }
if ( if (item.weight < 0 || item.weight > 9999) {
item.weight == 0 || errMsg = "规格信息 - 重量 格式不正确!";
(item.weight && item.weight < 0) || break;
item.weight > 9999
) {
errMsg = '规格信息 - 重量 格式不正确!'
break
} }
if (!item.stock) { if (!item.stock) {
errMsg = '请填写 规格信息 - 库存!' errMsg = "请填写 规格信息 - 库存!";
break break;
} }
if ( if (
item.stock < 0 || item.stock < 0 ||
!/^\d+$/.test(item.stock) || !/^\d+$/.test(item.stock) ||
item.stock > 99999999 item.stock > 99999999
) { ) {
errMsg = '规格信息 - 库存 格式不正确!' errMsg = "规格信息 - 库存 格式不正确!";
break break;
} }
} }
} else { }else{
if (!this.form.saleInfo.stock) { if(!this.form.saleInfo.tzType){
errMsg = '请输入库存!' errMsg = "请填写 规格信息 - 商品通证!";
}
if(!this.form.saleInfo.type){
errMsg = "请填写 规格信息 - NFT类型!";
}
if(this.form.saleInfo.type===2&&!this.form.saleInfo.number){
errMsg = "请填写 规格信息 - 发行数量!";
} }
} }
} }
} }
return errMsg return errMsg;
}, },
handleSubmit () { handleSubmit() {
let form = this.checkForm() let form = this.checkForm();
let errMsg = this.validateForm() let errMsg = this.validateForm();
console.log('form', form)
if (errMsg) { if (errMsg) {
return this.$Notice.warning({ title: errMsg }) return this.$Notice.warning({ title: errMsg });
}
if (!errMsg) {
if (form.type == 6 && form.nftdto) {
if (form.nftdto.tzType == 1 && form.nftdto.type == 1) {
form.nftdto.number = 1
}
}
} }
var regex1 = new RegExp( var regex1 = new RegExp(
"(i?)(<p)(?!(.*?style=['\"](.*)['\"])[^>]+>)", "(i?)(<p)(?!(.*?style=['\"](.*)['\"])[^>]+>)",
'gmi' "gmi"
) );
form.detail = form.detail.replace(regex1, '$2 style="padding:0 10px"$3') form.detail = form.detail.replace(regex1, '$2 style="padding:0 10px"$3');
form.blindBoxRule = form.blindBoxRule.replace(regex1, '$2 style="padding:0 10px"$3') form.blindBoxRule = form.blindBoxRule.replace(
regex1,
'$2 style="padding:0 10px"$3'
);
var regex1 = new RegExp( var regex1 = new RegExp(
"(i?)(<p)(?!(.*?style=['\"](.*)['\"])[^>]+>)", "(i?)(<p)(?!(.*?style=['\"](.*)['\"])[^>]+>)",
'gmi' "gmi"
) );
form.detail = form.detail.replace(regex1, '$2 style="padding:0 10px"$3') form.detail = form.detail.replace(regex1, '$2 style="padding:0 10px"$3');
let apiName = (this.isAdd || this.isDraft) ? 'addGood' : this.isAgain ? 'republishGood' : 'updateGood' let apiName =
let title = (this.isAdd || this.isDraft) this.isAdd || this.isDraft
? '添加成功!' ? "addGood"
: this.isAgain : this.isAgain
? '重新发布成功!' ? "republishGood"
: '编辑成功!' : "updateGood";
this.submitLoading = true let title =
this.isAdd || this.isDraft
? "添加成功!"
: this.isAgain
? "重新发布成功!"
: "编辑成功!";
this.submitLoading = true;
this.api({ this.api({
apiName, apiName,
postdata: form, postdata: form,
success: (res) => { success: (res) => {
// 关闭当前标签页 // 关闭当前标签页
let route = this.$route let route = this.$route;
let toRouteName = 'product_list' let toRouteName = "product_list";
this.closeTag({ route, toRouteName }) this.closeTag({ route, toRouteName });
this.$Notice.success({ title }) this.$Notice.success({ title });
}, },
complete: () => { complete: () => {
this.submitLoading = false this.submitLoading = false;
} },
}) });
}, },
handleDraft () { handleDraft() {
let form = this.checkForm() let form = this.checkForm();
this.draftLoading = true this.draftLoading = true;
this.api({ this.api({
apiName: 'draftGood', apiName: "draftGood",
postdata: form, postdata: form,
success: (res) => { success: (res) => {
// 关闭当前标签页 // 关闭当前标签页
let route = this.$route let route = this.$route;
let toRouteName = 'product_list' let toRouteName = "product_list";
this.closeTag({ route, toRouteName }) this.closeTag({ route, toRouteName });
this.$Notice.success({ title: '保存成功!' }) this.$Notice.success({ title: "保存成功!" });
}, },
complete: () => { complete: () => {
this.draftLoading = false this.draftLoading = false;
} },
}) });
} },
}, },
mounted () { mounted() {
// this.getNftList() // this.getNftList()
this.requestOptionData() this.requestOptionData();
this.initData() this.initData();
this.getDelayDelivery() this.getDelayDelivery();
this.getTemplateorshopquery() this.getTemplateorshopquery();
// console.log('base', this.form.baseInfo) // console.log('base', this.form.baseInfo)
} },
} };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -164,7 +164,7 @@ ...@@ -164,7 +164,7 @@
> >
</Select> </Select>
</div> </div>
<div class="item"> <!-- <div class="item">
<label class="label">库存:</label> <label class="label">库存:</label>
<Input <Input
v-model="data.stock" v-model="data.stock"
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
:maxlength="9" :maxlength="9"
@on-change="inputChangeStock($event)" @on-change="inputChangeStock($event)"
/> />
</div> </div> -->
</template> </template>
<template v-if="data.salesType === 4"> <template v-if="data.salesType === 4">
<div class="item" style="text-align: center"> <div class="item" style="text-align: center">
...@@ -391,6 +391,10 @@ export default { ...@@ -391,6 +391,10 @@ export default {
isAgain: { isAgain: {
type: Boolean, type: Boolean,
default: false default: false
},
isDraft:{
type: Boolean,
default: false
} }
}, },
components: { components: {
...@@ -466,9 +470,9 @@ export default { ...@@ -466,9 +470,9 @@ export default {
setTimeout(() => {}) setTimeout(() => {})
}, },
methods: { methods: {
inputChangeStock (e) { // inputChangeStock (e) {
this.data.stock = e.target.value // this.data.stock = e.target.value
}, // },
changeTzType () { changeTzType () {
this.data.type = '' this.data.type = ''
this.data.number = '' this.data.number = ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment