Commit ccf30aa0 authored by 郝聪敏's avatar 郝聪敏

fix: 修改bug

parent d3a174d2
......@@ -4,7 +4,7 @@
import { AutoIncrement, Column, DataType, Model, PrimaryKey, Table, AllowNull } from 'sequelize-typescript';
@Table({
modelName: 'page_config_info',
modelName: 'page_info',
freezeTableName: true
})
......
<template>
<div class="select">
<Select style="width: 128px" v-model="selected">
<Select v-model="selected">
<Option v-for="item in list" :value="item.id" :key="item.id">{{ item.label }}</Option>
</Select>
</div>
</template>
<script lang="ts" src="./index.ts"></script>
<style lang="less">
.color-selector {
display: flex;
align-items: center;
justify-content: space-between;
&-input {
flex-basis: 150px;
}
}
<style lang="less" scoped>
</style>
\ No newline at end of file
......@@ -10,6 +10,7 @@ export default class CouponTableModal extends Vue {
@Prop({ default: () => ([]), type: Array }) formControl;
coupon: object = cloneDeep(this.value);
templates: object[] = [];
table: object[] = [
{
title: '选择优惠券',
......@@ -36,7 +37,9 @@ export default class CouponTableModal extends Vue {
? `自领取后有效${item.validHours}小时`
: `自领取${item.receiverDaysValid}天后生效,有效天数${item.validDays}天`;
// item.useTime = item.useTimeStart ? `${item.useTimeStart}-${item.useTimeEnd}` : `自领取${item.receiverDaysValid}天后生效,有效天数${item.validDays}天`;
if (this.coupon.some(v => v === item.id)) {
const selections = this.templates.length ? this.templates : this.coupon;
console.log('query', selections, this.coupon);
if (selections.some(v => v === item.id)) {
item._checked = true;
}
return item;
......
<template>
<table-modal :table="table" :formControl="formControl" v-model="coupon" title="优惠券"></table-modal>
<table-modal :table="table" :templates.sync="templates" :formControl="formControl" v-model="coupon" title="优惠券"></table-modal>
</template>
<script lang="ts" src="./index.ts"></script>
<style></style>
\ No newline at end of file
......@@ -13,6 +13,7 @@ export default class GoodsTableModal extends Vue {
}), type: Object }) value;
@Prop({ default: () => ([]), type: Array }) formControl;
templates: object = {};
goods: object = cloneDeep(this.value);
table: object[] = [
{
......@@ -40,8 +41,10 @@ export default class GoodsTableModal extends Vue {
async query(data) {
const { records, total } = await operationApi.skuInfo({ type: 'list', ...data });
const selections = this.templates?.ids ? this.templates.ids : this.goods.ids;
console.log('query', selections, this.templates.ids);
records?.forEach(record => {
if (this.goods.ids.some(v => v === record.skuNo)) {
if (selections.some(v => v === record.skuNo)) {
record._checked = true;
}
});
......@@ -64,8 +67,10 @@ export default class GoodsTableModal extends Vue {
},
async queryGroup(data) {
const { records, total } = await operationApi.specialPage(data);
const selections = this.templates?.ids ? this.templates.ids : this.goods.ids;
console.log('query', selections, this.templates.ids);
records?.forEach(record => {
if (this.goods.ids.some(v => v === record.id)) {
if (selections.some(v => v === record.id)) {
record._checked = true;
}
});
......
<template>
<table-modal :table="table" :formControl="formControl" v-model="goods" title="商品"></table-modal>
<table-modal :table="table" :templates.sync="templates" :formControl="formControl" v-model="goods" title="商品"></table-modal>
</template>
<script lang="ts" src="./index.ts"></script>
<style></style>
\ No newline at end of file
import {Component, Prop, Watch, Vue, Mixins} from 'vue-property-decorator';
import {Component, Prop, Watch, Vue, Mixins, Emit} from 'vue-property-decorator';
import { Getter, State } from 'vuex-class';
import { cloneDeep } from 'lodash';
import { cloneDeep, uniqBy } from 'lodash';
import Number from '../Number/index.vue';
import QGTable from '@editor/component/QgTable/index.vue';
import { validateType } from '@/service/utils.service';
......@@ -15,6 +15,7 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
@Prop({ default: () => ([]), type: Array }) table;
@Prop([Object, Array]) value;
@Prop(String) title;
@Prop([Object, Array]) templates;
form: object = {};
modal: boolean = false;
......@@ -44,7 +45,7 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
@Watch('form', { immediate: true, deep: true })
onFormChange(newVal) {
console.log('onFormChange', newVal);
// console.log('onFormChange', newVal);
let parent = this.$parent;
while (!parent.modProps) {
parent = parent.$parent;
......@@ -56,29 +57,58 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
this.modal = true;
}
@Emit('update:templates')
selectionChange(selection) {
if (!this.table[this.activeName]?.multiple && selection.length > 1) {
return this.$Notice.warning({
title: '商品组只能单选'
});
}
this.selections = selection;
this.selections = uniqBy([...this.selections, ...selection], 'id');
console.log('selectionChange', this.selections, selection);
let rs = null;
if (this.table.length > 1) {
rs = {
type: this.table[this.activeName].type,
ids: this.selections.map(v => v[this.table[this.activeName].key])
};
} else {
rs = this.selections.map(v => v.id);
}
return rs;
}
selectionCancel(_, row) {
const index = this.selections.findIndex(v => v.id === row.id);
this.selections.splice(index, 1);
console.log('selectionCancel', this.selections, row, index);
}
ok() {
const defaultIds = this.getDefaultIds();
const selections = this.selections.length ? this.selections : this.getDefaultIds();
// console.log('commit', selections);
if (this.table.length > 1) {
this.$emit('input', {
type: this.table[this.activeName].type,
ids: this.selections.map(v => v[this.table[this.activeName].key])?.concat(defaultIds);
ids: selections.map(v => v[this.table[this.activeName].key])
});
} else {
this.$emit('input', this.selections.map(v => v.id)?.concat(defaultIds));
this.$emit('input', selections.map(v => v.id));
}
}
@Emit('update:templates')
cancel() {
this.selections = [];
let rs = null;
if (this.table.length > 1) {
rs = {};
} else {
rs = [];
}
return rs;
}
menuChange(name) {
......
......@@ -34,6 +34,7 @@
:hideAdd="true"
:height="500"
@on-selection-change="selectionChange"
@on-select-cancel="selectionCancel"
>
</QGTable>
</div>
......
......@@ -137,16 +137,7 @@ export default class DynamicForm extends Mixins(ContextMenuMixin, DynamicFormMix
};
get curElement() {
let element = {};
if (this.curEleIndex !== null) {
if (this.curChildIndex !== null && this.pageData.elements[this.curEleIndex]) {
element = this.pageData.elements[this.curEleIndex].child[this.curChildIndex];
} else {
element = this.pageData.elements[this.curEleIndex];
}
}
// console.log('curElement', element);
return element;
return this.getCurElement();
}
get point() {
......@@ -204,29 +195,49 @@ export default class DynamicForm extends Mixins(ContextMenuMixin, DynamicFormMix
return (this.curEleIndex || this.curEleIndex === 0) && !this.curChildIndex && this.curChildIndex !== 0;
}
// 监听curElement变化, 更新form
@Watch('curElement', { immediate: true, deep: true })
onElementChange(newVal) {
// curEleIndex选中时commonStyle为空, curChildIndex选中时commonStyle有值且不可设置背景
newVal?.schame?.forEach(schame => {
@Watch('curEleIndex', { immediate: true })
onCurEleIndexChange(newVal) {
this.setForm(newVal, 'curEleIndex');
}
@Watch('curChildIndex', { immediate: true })
onCurChildIndexChange(newVal) {
this.setForm(newVal, 'curChildIndex');
}
getCurElement() {
let element = {};
if (this.curEleIndex !== null) {
if (this.curChildIndex !== null && this.pageData.elements[this.curEleIndex]) {
element = this.pageData.elements[this.curEleIndex].child[this.curChildIndex];
} else {
element = this.pageData.elements[this.curEleIndex];
}
}
return element;
}
setForm(newVal, type) {
this.form = { id: `${type}${newVal}` };
const element = this.getCurElement();
element?.schame?.forEach(schame => {
if (schame.children) {
schame.children.forEach(child => {
this.$set(this.form, child.key, newVal.props[child.key]);
this.$set(this.form, child.key, element.props[child.key]);
});
} else {
this.$set(this.form, schame.key, newVal.props[schame.key]);
this.$set(this.form, schame.key, element.props[schame.key]);
}
});
// console.log('curElement', newVal, this.form);
// console.log('setForm', this.form);
}
// 监听form变化, 更新pageData
@Watch('form', { immediate: true, deep: true })
onFormChange(newVal) {
if (!Object.keys(newVal).length) { return; }
onFormChange(newVal, oldVal) {
// console.log('onFormChange', newVal?.id, oldVal?.id);
if (newVal?.id !== oldVal?.id) { return; }
const params = pick(this.form, this.curFormKey);
console.log('form', newVal, params);
this.$nextTick(() => this.adjustHeight());
this.$emit('modProps', params, 'component');
}
......@@ -238,7 +249,7 @@ export default class DynamicForm extends Mixins(ContextMenuMixin, DynamicFormMix
}
updateStyle(value, key) {
console.log('updateCommonStyle', this.commonStyle);
// console.log('updateCommonStyle', this.commonStyle);
const elements = this.pageData.elements[this.curEleIndex];
// this.updatePageInfo({ containerIndex: this.curEleIndex, data: { ...elements, commonStyle: { ...elements.commonStyle, ...this.commonStyle } } });
this.updateCommonStyle({ containerIndex: this.curEleIndex, childIndex: this.curChildIndex, data: this.commonStyle });
......
......@@ -4,7 +4,7 @@
<Form @submit.native.prevent inline ref="searchForm" :rules="searchCondition.rules || {}" :model="searchForm" class="inline">
<FormItem :key="getKey(item.key)" :prop="getKey(item.key)" :rules="item.rules" :label="item.label" v-for="item in searchCondition">
<Input v-model="searchForm[item.key]" placeholder="" class="comWidth" v-if="item.type === 'input'" clearable />
<Select v-model="searchForm[item.key]" class="comWidth" filterable v-else-if="item.type === 'select'" clearable>
<Select ref="searchSelect" v-model="searchForm[item.key]" class="comWidth" filterable v-else-if="item.type === 'select'" clearable>
<Option :value="isNum(value, item.number)" :key="value" v-for="(label,value) in item.option" :label="label" />
</Select>
<DatePicker v-else-if="item.type === 'date'" class="timeWidth" type="datetimerange" placeholder="" v-model="searchForm[item.key]"></DatePicker>
......@@ -26,7 +26,7 @@
<slot></slot>
</div>
</div>
<Table :height="height" @on-selection-change="selectionChange" :columns="renderColumns" :data="tableData" class="tableStyle"></Table>
<Table :height="height" @on-select-cancel="selectionCancel" @on-selection-change="selectionChange" :columns="renderColumns" :data="tableData" class="tableStyle"></Table>
<Page
:total="total"
v-if="total > 0"
......@@ -76,10 +76,9 @@ export default {
newVal.forEach(item => {
this.$set(this.searchForm, item.key, item.value || null)
});
console.log('searchCondition', newVal, this.searchForm);
},
immediate: true,
},
}
},
computed: {
renderColumns: function() {
......@@ -106,6 +105,10 @@ export default {
},
resetForm(formName) {
this.$refs[formName].resetFields();
// 处理select bug
this.$refs.searchSelect.forEach(selectEle => {
selectEle.setQuery(null);
});
},
isArray(key) {
return Array.isArray(key);
......@@ -149,6 +152,9 @@ export default {
selectionChange(selection) {
this.$emit('on-selection-change', selection);
},
selectionCancel(selection, row) {
this.$emit('on-select-cancel', selection, row);
},
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
......
......@@ -16,8 +16,11 @@ export default class GoodsTabsMixin extends Vue {
const childs = [];
const childIndexs = [];
const idList = element.props.list.map(v => v.componentId);
if (idList.some(v => !v)) {
throw new Error('商品导航组件不可为空');
}
if (idList.length && idList.length !== Array.from(new Set(idList)).length) {
throw new Error('商品标签不可重复选择组件');
throw new Error('商品导航不可重复选择组件');
}
element.props.list.forEach((data, index) => {
const index = pageData.elements.findIndex(v => v.id === data.componentId);
......@@ -29,15 +32,20 @@ export default class GoodsTabsMixin extends Vue {
goodsTabs[element.id] = { idx, childs, childIndexs };
}
});
let indexs = [];
Object.keys(goodsTabs).forEach(key => {
const { idx, childIndexs, childs } = goodsTabs[key];
pageData.elements[idx].child = childs;
// 逆向循环
for (let i = childIndexs.length - 1; i >= 0; i--) {
pageData.elements.splice(childIndexs[i], 1);
}
indexs = [...indexs, ...childIndexs];
});
indexs = indexs.sort((a, b) => a - b);
// 逆向循环
for (let i = indexs.length - 1; i >= 0; i--) {
pageData.elements.splice(indexs[i], 1);
}
return pageData;
}
......
......@@ -68,12 +68,14 @@ export default class EditorModule implements Module<EditorState, RootState> {
}
}
});
let tempIndex = 0;
Object.keys(goodsTabs).forEach(key => {
goodsTabs[key].forEach((child, index) => {
commit(UPDATE_PAGE_INFO, { containerIndex: +key + 1 + index, data: child });
commit(UPDATE_PAGE_INFO, { containerIndex: +key + 1 + index + tempIndex, data: child, type: 'add' });
// console.log('parseGoodsTabs', { containerIndex: +key + 1 + index, data: child });
// this.updatePageInfo({ containerIndex: +key + 1 + index, data: child });
});
tempIndex++;
});
},
async getTemplateList({ commit }) {
......@@ -140,10 +142,12 @@ export default class EditorModule implements Module<EditorState, RootState> {
}
}
},
[UPDATE_PAGE_INFO](state, { containerIndex, childIndex, data }) {
[UPDATE_PAGE_INFO](state, { containerIndex, childIndex, data, type }) {
const page = (state.pageInfo.page as Page).elements;
if (childIndex || childIndex === 0) {
page[containerIndex].child.splice(childIndex, 1, data);
} else if (type === 'add') {
page.splice(containerIndex, 0, data);
} else {
page.splice(containerIndex, 1, data);
}
......
......@@ -1479,18 +1479,31 @@
}
},
"@qg/citrus-ui": {
"version": "0.0.35",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.0.35.tgz",
"integrity": "sha512-cERJzjhybdUbc0CYi4cmSLThX4DD/QaojhadoNnqIPPFtYtBECy7UTFWIjGL1IYQptBtTTFuBSO6gh0XIApyPA==",
"version": "0.0.42",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.0.42.tgz",
"integrity": "sha512-hBHTOdXCpfI42BxKtivJOldjRIZM77Vpmg54A5oqe/okEmQwUOzWg81CNAJm/+C0ruNzLviEH7RMEIx2A8daJA==",
"requires": {
"@better-scroll/core": "^2.1.1",
"@qg/cherry-ui": "^2.20.3",
"@qg/cherry-ui": "^2.20.5",
"@qg/js-bridge": "^1.1.9",
"axios": "^0.21.1",
"js-cookie": "^2.2.1",
"lodash-es": "^4.17.21",
"sa-sdk-javascript": "^1.16.1",
"swiper": "^4.5.1",
"vuex": "^3.6.0"
},
"dependencies": {
"@qg/cherry-ui": {
"version": "2.20.5",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcherry-ui/-/cherry-ui-2.20.5.tgz",
"integrity": "sha512-DL3ZtlydZzj8uz+Z7WavMUD9qq0xXTig+cb05FtajKXsY8ZjHIaZJQmUB3kYJQzeWfks1nubJDb4UcG4GdMm6A==",
"requires": {
"@popperjs/core": "^2.5.4",
"vue-lazyload": "^1.3.3",
"vue-video-player": "^5.0.2"
}
}
}
},
"@qg/js-bridge": {
......@@ -12421,6 +12434,11 @@
"resolved": "http://npmprivate.quantgroups.com/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"lodash-es": {
"version": "4.17.21",
"resolved": "http://npmprivate.quantgroups.com/lodash-es/-/lodash-es-4.17.21.tgz",
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
},
"lodash._reinterpolate": {
"version": "3.0.0",
"resolved": "http://npmprivate.quantgroups.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
......@@ -19826,9 +19844,9 @@
"integrity": "sha1-8z/pz7Urv9UgqhgyO8ZdsRCht2w="
},
"rollup": {
"version": "2.42.3",
"resolved": "http://npmprivate.quantgroups.com/rollup/-/rollup-2.42.3.tgz",
"integrity": "sha512-JjaT9WaUS5vmjy6xUrnPOskjkQg2cN4WSACNCwbOvBz8VDmbiKVdmTFUoMPRqTud0tsex8Xy9/boLbDW9HKD1w==",
"version": "2.42.4",
"resolved": "http://npmprivate.quantgroups.com/rollup/-/rollup-2.42.4.tgz",
"integrity": "sha512-Zqv3EvNfcllBHyyEUM754npqsZw82VIjK34cDQMwrQ1d6aqxzeYu5yFb7smGkPU4C1Bj7HupIMeT6WU7uIdnMw==",
"requires": {
"fsevents": "~2.3.1"
}
......
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