Commit cac4728b authored by xuguangxing's avatar xuguangxing

feat: 支持折扣组件v2

parent 5d699e21
......@@ -3,15 +3,15 @@ const protocol = EASY_ENV_IS_BROWSER ? window.location.protocol : 'http';
const hostMap = {
apiHost: `http://localhost:7002/`,
// apiHost: `http://192.168.28.199:7001/`,
// apiHost: 'https://quantum-blocks-vcc2.liangkebang.net/',
h5Host: 'https://quantum-h5-vcc2.liangkebang.net',
// apiHost: 'https://quantum-blocks-test1.liangkebang.net/',
h5Host: 'https://quantum-h5-test1.liangkebang.net',
qiniuHost: `https://appsync.lkbang.net`,
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`,
opapiHost: `https://opapi-vcc2.liangkebang.net`,
opapiHost: `https://opapi-test1.liangkebang.net`,
qiniuUpHost: `${protocol}//up-z0.qiniup.com`,
// kdspHost: 'https://kdsp-api-vcc2.liangkebang.net',
talosHost: 'https://talos-vcc2.liangkebang.net',
kdspHost: 'https://kdsp-api-vcc2.liangkebang.net',
// kdspHost: 'https://kdsp-api-test1.liangkebang.net',
talosHost: 'https://talos-test1.liangkebang.net',
kdspHost: 'https://kdsp-api-test1.liangkebang.net',
yxmTenantId: 560761,
appIdMap: {
560761: 'wxe16bf9293671506c',
......
......@@ -38,10 +38,14 @@ export default {
}
},
watch: {
value: {
handler(val) {
this.data = val;
}
},
data: {
deep: true,
handler(val) {
console.log(val);
this.$emit('input', val);
}
}
......@@ -55,12 +59,15 @@ export default {
}
},
created() {
const data = JSON.parse(JSON.stringify(this.value));
this.data = JSON.parse(JSON.stringify(this.value));
},
methods: {
init() {
const data = this.value;
if (!data.ids) data.ids = '';
if (!data.data) data.data = [];
this.data = data;
},
methods: {
async getGoods(params) {
const res = await operationApi.getGoods(params);
try {
......@@ -77,14 +84,17 @@ export default {
item.status = goodsList[i].status;
arr.push(item)
}
this.data.data = arr;
this.$set(this.data, 'data', arr);
} else {
this.data.data = []
this.$set(this.data, 'data', []);
}
} catch (err) {
console.log(err);
this.data.data = []
this.$set(this.data, 'data', []);
}
setTimeout(() => {
this.$emit('adjust')
}, 1000)
},
changeIds() {
const skus = this.data.ids ? this.data.ids.split(',') : [];
......
<template>
<div class="VerticalAdGoodsSelectorContainer">
<Input
v-model="data.ids"
type="textarea"
:autosize="{minRows: 3,maxRows: 10}"
placeholder="请输入skuNo,每个skuNo使用英文逗号隔开"
@on-blur="changeIds"
/>
<div class="goodsItem" v-for="(item, index) in data.data" :key="index">
<Form @submit.native.prevent ref="formCustom" :model="item" :label-width="90" label-position="left">
<FormItem label="sku_no" prop="skuNo">
<Input v-model="item.skuNo" disabled />
</FormItem>
<FormItem label="商品名称" prop="goodsName">
<Input v-model="item.goodsName" />
</FormItem>
<FormItem label="商品主图" prop="img">
<Upload v-model="item.img"></Upload>
</FormItem>
<FormItem label="横幅文案" prop="subtitle">
<Input v-model="item.subtitle" />
</FormItem>
<FormItem label="标签文案" prop="tag">
<Input v-model="item.tag" />
</FormItem>
<FormItem label="标签文案颜色" prop="tagColor">
<ColorSelector v-model="item.tagColor" />
</FormItem>
<FormItem label="标签背景图" prop="tagBgImg">
<Upload v-model="item.tagBgImg"></Upload>
</FormItem>
</Form>
<Button type="error" long @click="del(index, item.skuNo)" class="deleteGood">删除</Button>
</div>
</div>
</template>
<script>
import operationApi from '@api/operation.api';
import ColorSelector from '@editor/component/DynamicForm/component/ColorSelector/index.vue';
import Upload from '@editor/component/DynamicForm/component/Upload/index.vue';
export default {
inject: ['editor'],
props: {
value: {
type: Object,
default: () => {}
}
},
watch: {
value: {
handler(val) {
this.data = val;
// this.$nextTick(() =>this.editor.adjustHeight());
}
},
data: {
deep: true,
handler(val) {
this.$emit('input', val);
}
}
},
components: {
Upload,
ColorSelector
},
data() {
return {
data: {}
}
},
created() {
this.data = JSON.parse(JSON.stringify(this.value));
},
methods: {
init() {
const data = this.value;
if (!data.ids) data.ids = '';
if (!data.data) data.data = [];
this.data = data;
},
async getGoods(params) {
const res = await operationApi.getGoods(params);
try {
let goodsList = res.skus || [];
let arr = [];
if (goodsList.length) {
for (let i = 0; i < goodsList.length; i++) {
let item = {};
item.goodsName = goodsList[i].skuName;
item.salePrice = goodsList[i].salePrice;
item.skuNo = goodsList[i].skuNo;
item.img = goodsList[i].skuUrl;
item.subtitle = '';
item.tag = '';
item.tagColor = '';
item.tagBgImg = '';
item.status = goodsList[i].status;
arr.push(item)
}
this.$set(this.data, 'data', arr);
} else {
this.$set(this.data, 'data', []);
}
} catch (err) {
console.log(err);
this.$set(this.data, 'data', []);
}
setTimeout(() => {
this.$emit('adjust')
}, 1000)
},
changeIds() {
const skus = this.data.ids ? this.data.ids.split(',') : [];
if (skus.length) {
if (skus.length > 15) {
this.$toast('最多填入15个商品');
return;
}
this.getGoods({
skus
});
}
},
del(index, skuNo) {
this.data.data.splice(index, 1)
const ids = this.data.ids ? this.data.ids.split(',') : [];
const idx = ids.indexOf(skuNo);
if (idx > -1 && ids.length) ids.splice(idx, 1);
this.data.ids = ids.join();
if (this.data.data.length == 0) this.data.ids = '';
}
}
}
</script>
<style scoped lang="less">
.goodsItem{
border: 1px solid #dddee1;
border-radius: 4px;
margin-top: 10px;
padding: 5px;
/deep/ .ivu-form-item{
margin-bottom: 10px;
}
}
</style>
<template>
<Input v-model="text" :number="true"></Input>
<Input v-model="text" :number="true" @on-blur="$emit('adjust')" />
</template>
<script>
export default {
......@@ -12,6 +12,9 @@
}
},
watch: {
value(val) {
this.text = val;
},
text(val) {
this.$emit('input', val);
}
......
......@@ -11,8 +11,8 @@ import operationApi from '@api/operation.api';
export default {
props: {
value: {
type: Number,
default: 0
type: String,
default: ''
}
},
watch: {
......@@ -38,6 +38,9 @@ export default {
const res = await operationApi.getActivityList({
templateType: 11
});
for (let i = 0; i < res.length; i++) {
res[i].id = res[i].id.toString();
}
this.list = res;
}
}
......
......@@ -12,6 +12,9 @@ export default {
}
},
watch: {
value(val) {
this.styleType = val;
},
styleType(val) {
this.$emit('input', val);
}
......
......@@ -11,6 +11,7 @@ import VerticalAdStyleSelector from './component/VerticalAdStyleSelector/index.v
import CategoryTypeSelector from './component/CategoryTypeSelector/index.vue';
import CategorySelector from './component/CategorySelector/index.vue';
import BatchGoodsSelector from './component/BatchGoodsSelector/index.vue';
import DiscountGoodsSelectorV2 from './component/DiscountGoodsSelectorV2/index.vue';
import BaseSelect from './component/BaseSelect/index.vue';
import ComponentSelect from './component/ComponentSelect/index.vue';
import FormList from './component/FormList/index.vue';
......@@ -24,7 +25,25 @@ import { getAllScheme } from '../../../store/modules/editor/scheme';
import EventBus from '@service/eventBus.service';
const allComponentsMap = getAllScheme();
@Component({ components: { Upload, ColorSelector, BaseSelect, FormList, Textarea, Number, ComponentSelect, GoodsTableModal, CouponTableModal, ColumnSelector, DiscountGoodsSelector, SnapUpActivitySelector, CategoryTypeSelector, CategorySelector, VerticalAdStyleSelector, BatchGoodsSelector }, name: 'DynamicForm' })
@Component({ components: {
Upload,
ColorSelector,
BaseSelect,
FormList,
Textarea,
Number,
ComponentSelect,
GoodsTableModal,
CouponTableModal,
ColumnSelector,
DiscountGoodsSelector,
SnapUpActivitySelector,
CategoryTypeSelector,
CategorySelector,
VerticalAdStyleSelector,
BatchGoodsSelector,
DiscountGoodsSelectorV2
}, name: 'DynamicForm' })
export default class DynamicForm extends Mixins(ContextMenuMixin, DynamicFormMixin) {
@State(state => state.editor.curEleIndex) curEleIndex;
@State(state => state.editor.curChildIndex) curChildIndex;
......
......@@ -10,11 +10,11 @@
<div v-if="item.title">
<h3>{{ item.title }}</h3>
<FormItem :label="child.name" :key="curElement.id + child.key" v-for="child in item.children">
<component :is="getComponent(child.type)" :options="child.options" :formControl="child.formControl" :limit-name="child.type === 'FormList' && curElement.name === 'cs-goods-tabs' ? 'cs-goods' : ''" v-model="form[child.key]" />
<component @adjust="adjustHeight" :is="getComponent(child.type)" :options="child.options" :formControl="child.formControl" :limit-name="child.type === 'FormList' && curElement.name === 'cs-goods-tabs' ? 'cs-goods' : ''" v-model="form[child.key]" />
</FormItem>
</div>
<FormItem class="Df-component-formitem" v-else :label="item.name" :title="item.desc || ''">
<component :hide3Column="curElement.name === 'cs-discount' && item.key ==='column'" :is="getComponent(item.type)" :options="item.options" :formControl="item.formControl" :limit-name="item.type === 'ComponentSelect' && curElement.name === 'cs-goods-tabs' ? 'cs-goods' : ''" v-model="form[item.key]" />
<component @adjust="adjustHeight" :hide3Column="curElement.name === 'cs-discount' && item.key ==='column'" :is="getComponent(item.type)" :options="item.options" :formControl="item.formControl" :limit-name="item.type === 'ComponentSelect' && curElement.name === 'cs-goods-tabs' ? 'cs-goods' : ''" v-model="form[item.key]" />
</FormItem>
</template>
</Form>
......
......@@ -16,7 +16,7 @@
"@hubcarl/json-typescript-mapper": "^2.0.0",
"@qg/apollo-nodejs": "^2.1.2",
"@qg/cherry-ui": "2.23.10",
"@qg/citrus-ui": "0.3.39-beta3",
"@qg/citrus-ui": "0.3.40-beta1",
"@riophae/vue-treeselect": "^0.4.0",
"@types/lodash": "^4.14.117",
"@types/node": "^10.12.0",
......@@ -3081,9 +3081,9 @@
}
},
"node_modules/@qg/citrus-ui": {
"version": "0.3.39-beta3",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.3.39-beta3.tgz",
"integrity": "sha512-pxVwAYAlPQXAKYuhczZiHPB8FHEAMSPCFO0nCmsKE0YsAW279WlXPTfsrBKhWBTLTr7J+a6OsRp+z2mQweicIQ==",
"version": "0.3.40-beta1",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.3.40-beta1.tgz",
"integrity": "sha512-mQhPc/JgK1P2ZTimZwh2i5fL9HaSiKcUjUeFyc37KcWXRdrslh2ktEHeZsHrqOB/CYH2+JTnhqxOjjxN/BchEQ==",
"license": "MIT",
"dependencies": {
"@better-scroll/core": "^2.1.1",
......@@ -38895,9 +38895,9 @@
}
},
"@qg/citrus-ui": {
"version": "0.3.39-beta3",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.3.39-beta3.tgz",
"integrity": "sha512-pxVwAYAlPQXAKYuhczZiHPB8FHEAMSPCFO0nCmsKE0YsAW279WlXPTfsrBKhWBTLTr7J+a6OsRp+z2mQweicIQ==",
"version": "0.3.40-beta1",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.3.40-beta1.tgz",
"integrity": "sha512-mQhPc/JgK1P2ZTimZwh2i5fL9HaSiKcUjUeFyc37KcWXRdrslh2ktEHeZsHrqOB/CYH2+JTnhqxOjjxN/BchEQ==",
"requires": {
"@better-scroll/core": "^2.1.1",
"@qg/cherry-ui": "^2.23.9",
......@@ -8,7 +8,7 @@
"test": "cross-env NODE_ENV=production EGG_SERVER_ENV=sit egg-scripts start --port 80 --workers 1",
"stop": "egg-scripts stop",
"backend": "nohup egg-scripts start --port 7001 --workers 4",
"dev": "cross-env NODE_ENV=test APOLLO_CLUSTER=k8s NAMESPACE=vcc2 npm run apollo && egg-bin dev -r egg-ts-helper/register --port 7002",
"dev": "cross-env NODE_ENV=test APOLLO_CLUSTER=k8s NAMESPACE=test1 npm run apollo && egg-bin dev -r egg-ts-helper/register --port 7002",
"debug": "egg-bin debug -r egg-ts-helper/register",
"apollo": "node bin/apollo.js",
"build": "cross-env NODE_ENV=production APOLLO_CLUSTER=3C npm run apollo && cross-env COS_ENV=production easy build --devtool",
......@@ -30,7 +30,7 @@
"@hubcarl/json-typescript-mapper": "^2.0.0",
"@qg/apollo-nodejs": "^2.1.2",
"@qg/cherry-ui": "2.23.10",
"@qg/citrus-ui": "0.3.39-beta2",
"@qg/citrus-ui": "0.3.40-beta1",
"@riophae/vue-treeselect": "^0.4.0",
"@types/lodash": "^4.14.117",
"@types/node": "^10.12.0",
......
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