|
@@ -515,53 +515,6 @@ export default {
|
|
|
assetPickerMode: 'single',
|
|
assetPickerMode: 'single',
|
|
|
assetPickerType: 'image',
|
|
assetPickerType: 'image',
|
|
|
assetPickerTarget: 'content',
|
|
assetPickerTarget: 'content',
|
|
|
- removeBundleItem(idx) {
|
|
|
|
|
- this.bundleItems.splice(idx, 1)
|
|
|
|
|
- },
|
|
|
|
|
- buildBundleItemPayload() {
|
|
|
|
|
- return this.bundleItems
|
|
|
|
|
- .filter(function(b) { return b.childProductId })
|
|
|
|
|
- .map(function(b) {
|
|
|
|
|
- return {
|
|
|
|
|
- childProductId: b.childProductId,
|
|
|
|
|
- childSkuId: b.childSkuId || null,
|
|
|
|
|
- quantity: b.quantity || 1
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- async loadBundleItems(productId) {
|
|
|
|
|
- try {
|
|
|
|
|
- const skuRes = await getProductSkuList(productId)
|
|
|
|
|
- const skus = (skuRes && skuRes.code === 200 && Array.isArray(skuRes.data)) ? skuRes.data : []
|
|
|
|
|
- if (!skus.length) {
|
|
|
|
|
- this.bundleItems = []
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- const comboSkuId = skus[0].id
|
|
|
|
|
- const res = await listComboItems(comboSkuId)
|
|
|
|
|
- if (res.code === 200 && Array.isArray(res.data)) {
|
|
|
|
|
- this.bundleItems = res.data.map(function(b) {
|
|
|
|
|
- return {
|
|
|
|
|
- childProductId: b.childProductId,
|
|
|
|
|
- childSkuId: b.childSkuId || null,
|
|
|
|
|
- quantity: b.quantity || 1
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) { /* ignore */ }
|
|
|
|
|
- },
|
|
|
|
|
- openComboPicker() {
|
|
|
|
|
- this.$refs.comboPicker.open()
|
|
|
|
|
- },
|
|
|
|
|
- onComboPickerConfirm(items) {
|
|
|
|
|
- this.bundleItems = (items || []).map(function(it) {
|
|
|
|
|
- return {
|
|
|
|
|
- childProductId: it.childProductId || it.id,
|
|
|
|
|
- childSkuId: it.childSkuId || null,
|
|
|
|
|
- quantity: it.quantity || 1
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -667,6 +620,53 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ removeBundleItem(idx) {
|
|
|
|
|
+ this.bundleItems.splice(idx, 1)
|
|
|
|
|
+ },
|
|
|
|
|
+ buildBundleItemPayload() {
|
|
|
|
|
+ return this.bundleItems
|
|
|
|
|
+ .filter(function(b) { return b.childProductId })
|
|
|
|
|
+ .map(function(b) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ childProductId: b.childProductId,
|
|
|
|
|
+ childSkuId: b.childSkuId || null,
|
|
|
|
|
+ quantity: b.quantity || 1
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ async loadBundleItems(productId) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const skuRes = await getProductSkuList(productId)
|
|
|
|
|
+ const skus = (skuRes && skuRes.code === 200 && Array.isArray(skuRes.data)) ? skuRes.data : []
|
|
|
|
|
+ if (!skus.length) {
|
|
|
|
|
+ this.bundleItems = []
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const comboSkuId = skus[0].id
|
|
|
|
|
+ const res = await listComboItems(comboSkuId)
|
|
|
|
|
+ if (res.code === 200 && Array.isArray(res.data)) {
|
|
|
|
|
+ this.bundleItems = res.data.map(function(b) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ childProductId: b.childProductId,
|
|
|
|
|
+ childSkuId: b.childSkuId || null,
|
|
|
|
|
+ quantity: b.quantity || 1
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) { /* ignore */ }
|
|
|
|
|
+ },
|
|
|
|
|
+ openComboPicker() {
|
|
|
|
|
+ this.$refs.comboPicker.open()
|
|
|
|
|
+ },
|
|
|
|
|
+ onComboPickerConfirm(items) {
|
|
|
|
|
+ this.bundleItems = (items || []).map(function(it) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ childProductId: it.childProductId || it.id,
|
|
|
|
|
+ childSkuId: it.childSkuId || null,
|
|
|
|
|
+ quantity: it.quantity || 1
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
handleEditorCreated(editor) {
|
|
handleEditorCreated(editor) {
|
|
|
// Vue 2 必须 seal,否则会把 editor 做成响应式,内部 WeakMap 取不到实例
|
|
// Vue 2 必须 seal,否则会把 editor 做成响应式,内部 WeakMap 取不到实例
|
|
|
this.editorInstance = Object.seal(editor)
|
|
this.editorInstance = Object.seal(editor)
|