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

fix: 修改商品组和商品选择混淆bug;接入埋点指令

parent e60201a5
import { Vue } from 'vue-property-decorator';
import micro from './micro/index.vue'; import micro from './micro/index.vue';
import single from './single/index.vue'; import single from './single/index.vue';
Vue.directive('track', {});
export default window.__POWERED_BY_QIANKUN__ ? micro : single; export default window.__POWERED_BY_QIANKUN__ ? micro : single;
\ No newline at end of file
...@@ -21,24 +21,30 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) { ...@@ -21,24 +21,30 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
modal: boolean = false; modal: boolean = false;
selections: object[] = []; selections: object[] = [];
activeName: number = 0; activeName: number = 0;
tableData: object[] = [];
get idsLength() { get idsLength() {
return this.getLength('value'); return this.getLength('value');
} }
getTableData() {
const tableData = this.$refs?.[`qgTable${this.activeName}`]?.[0]?.tableData || [];
console.log('get tableData', tableData);
return tableData;
}
// 获取除本页之外的默认值 // 获取除本页之外的默认值
getDefaultIds() { getDefaultIds() {
const tableData = this.getTableData();
let defaultIds = this.value; let defaultIds = this.value;
if (validateType(this.value) === 'object') { if (validateType(this.value) === 'object') {
defaultIds = this.value?.ids; defaultIds = this.value.type === this.table[this.activeName].type ? this.value?.ids : [];
} }
let filterIds = []; let filterIds = [];
if (this.table.length > 1) { if (this.table.length > 1) {
filterIds = this.tableData.map(v => v[this.table[this.activeName].key]); filterIds = tableData.map(v => v[this.table[this.activeName].key]);
} else { } else {
filterIds = this.tableData.map(v => v.id); filterIds = tableData.map(v => v.id);
} }
const rs = defaultIds.filter(v => !filterIds.includes(v)); const rs = defaultIds.filter(v => !filterIds.includes(v));
...@@ -58,11 +64,12 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) { ...@@ -58,11 +64,12 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
getTemplateIds() { getTemplateIds() {
let filterIds = []; let filterIds = [];
let templates = []; let templates = [];
const tableData = this.getTableData();
if (this.table.length > 1) { if (this.table.length > 1) {
filterIds = this.tableData.map(v => v[this.table[this.activeName].key]); filterIds = tableData.map(v => v[this.table[this.activeName].key]);
templates = this.templates.ids; templates = this.templates.ids;
} else { } else {
filterIds = this.tableData.map(v => v.id); filterIds = tableData.map(v => v.id);
templates = this.templates; templates = this.templates;
} }
...@@ -73,9 +80,9 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) { ...@@ -73,9 +80,9 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
getLength(type) { getLength(type) {
const rs = type === 'templates' ? this.templates : this.value; const rs = type === 'templates' ? this.templates : this.value;
if (validateType(this.templates) === 'object') { if (validateType(this.templates) === 'object') {
return this.templates?.ids?.length; return rs?.ids?.length;
} }
return this.templates?.length; return rs?.length;
} }
// 当table取消全选时的默认值 // 当table取消全选时的默认值
...@@ -90,6 +97,20 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) { ...@@ -90,6 +97,20 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
return rs; return rs;
} }
setTemplates(ids = []) {
let rs = null;
if (this.table.length > 1) {
rs = {
type: this.table[this.activeName].type,
ids
};
} else {
rs = ids;
}
return rs;
}
@Watch('curEleIndex', { immediate: true }) @Watch('curEleIndex', { immediate: true })
onElementChange(newVal) { onElementChange(newVal) {
this.formControl.forEach(schame => { this.formControl.forEach(schame => {
...@@ -99,7 +120,6 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) { ...@@ -99,7 +120,6 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
@Watch('form', { immediate: true, deep: true }) @Watch('form', { immediate: true, deep: true })
onFormChange(newVal) { onFormChange(newVal) {
// console.log('onFormChange', newVal);
let parent = this.$parent; let parent = this.$parent;
while (!parent.modProps) { while (!parent.modProps) {
parent = parent.$parent; parent = parent.$parent;
...@@ -107,47 +127,48 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) { ...@@ -107,47 +127,48 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
parent.modProps(this.form, 'component'); parent.modProps(this.form, 'component');
} }
add() { @Watch('value', { immediate: true })
this.modal = true; onValueChange(newVal) {
if (newVal && this.table.length > 1) {
this.activeName = this.table.findIndex(v => v.type === newVal.type);
}
} }
@Emit('update:templates') @Emit('update:templates')
selectionChange(selection) { selectionChange(selection) {
if (!this.table[this.activeName]?.multiple && selection.length > 1) { if (!this.table[this.activeName]?.multiple && selection.length > 1) {
return this.$Notice.warning({ this.$Notice.warning({
title: '商品组只能单选' title: '商品组只能单选'
}); });
return this.templates;
} }
this.selections = selection.length ? selection : this.getDefaultSelections(); this.selections = selection.length ? selection : this.getDefaultSelections();
const ids = [...this.getSelectionsIds(), ...(this.getLength('templates') ? this.getTemplateIds() : this.getDefaultIds())]; const ids = Array.from(new Set([...this.getSelectionsIds(), ...(this.getLength('templates') ? this.getTemplateIds() : this.getDefaultIds())]));
console.log('selectionChange', ids, selection); console.log('selectionChange', ids, selection);
let rs = null; const rs = this.setTemplates(ids);
if (this.table.length > 1) {
rs = {
type: this.table[this.activeName].type,
ids
};
} else {
rs = ids;
}
return rs; return rs;
} }
add() {
this.modal = true;
}
ok() { ok() {
const ids = [...this.getSelectionsIds(), ...(this.getLength('templates') ? this.getTemplateIds() : this.getDefaultIds())].filter(v => v !== -1); const ids = [...this.getSelectionsIds(), ...(this.getLength('templates') ? this.getTemplateIds() : this.getDefaultIds())].filter(v => v !== -1);
if (!ids.length) { return; } // if (!ids.length) { return; }
this.selections = []; this.selections = [];
// console.log('commit', selections); // console.log('commit', selections);
if (this.table.length > 1) { if (this.table.length > 1) {
this.$emit('update:templates', {}); this.$emit('update:templates', {});
this.$emit('input', { this.$emit('input', {
type: this.table[this.activeName].type, type: this.table[this.activeName].type,
ids ids: Array.from(new Set(ids))
}); });
} else { } else {
this.$emit('update:templates', []); this.$emit('update:templates', this.setTemplates());
this.$emit('input', ids); this.$emit('input', Array.from(new Set(ids)));
} }
} }
...@@ -164,8 +185,11 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) { ...@@ -164,8 +185,11 @@ export default class DynamicForm extends Mixins(DynamicFormMixin) {
return rs; return rs;
} }
menuChange(name) { async menuChange(name) {
// console.log('menuChange', `qgTable${name}`, this.$refs);
await this.$refs[`qgTable${name}`][0].query();
this.activeName = name; this.activeName = name;
this.$emit('update:templates', this.setTemplates());
this.selections = []; this.selections = [];
} }
......
...@@ -28,12 +28,11 @@ ...@@ -28,12 +28,11 @@
<template v-for="(item, index) in table"> <template v-for="(item, index) in table">
<div v-show="activeName === index" > <div v-show="activeName === index" >
<QGTable <QGTable
ref="qgTable" :ref="`qgTable${index}`"
:columns="item.columns" :columns="item.columns"
:request="item.query" :request="item.query"
:hideAdd="true" :hideAdd="true"
:height="500" :height="500"
:tableData.sync="tableData"
@on-selection-change="selectionChange" @on-selection-change="selectionChange"
> >
</QGTable> </QGTable>
......
...@@ -100,7 +100,6 @@ export default { ...@@ -100,7 +100,6 @@ export default {
const getQueryData = (await this.request(this.searchForm)) || {}; const getQueryData = (await this.request(this.searchForm)) || {};
this.tableData = getQueryData.data || []; this.tableData = getQueryData.data || [];
this.total = getQueryData.total || 0; this.total = getQueryData.total || 0;
this.$emit('update:tableData', this.tableData);
} }
}); });
}, },
......
...@@ -1456,9 +1456,9 @@ ...@@ -1456,9 +1456,9 @@
} }
}, },
"@qg/citrus-ui": { "@qg/citrus-ui": {
"version": "0.0.47", "version": "0.0.48",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.0.47.tgz", "resolved": "http://npmprivate.quantgroups.com/@qg%2fcitrus-ui/-/citrus-ui-0.0.48.tgz",
"integrity": "sha512-SWld0LQ++qtq4Tw+HDKlD1IoITbWAcJIA3j0mDS17UAlRpGaiY7pzPq/9eyqGm7aQwDiJ6NeeofMXHMvF6Sqwg==", "integrity": "sha512-zO2HQaeZok1XbWx8/t/GEzORYBfDlCRaWuhY/N3Bf2t361odO9L9Xlm3xHdo3PD+ZlFiJPzBR3pREQkAAKsx5A==",
"requires": { "requires": {
"@better-scroll/core": "^2.1.1", "@better-scroll/core": "^2.1.1",
"@qg/cherry-ui": "^2.20.5", "@qg/cherry-ui": "^2.20.5",
...@@ -19942,9 +19942,9 @@ ...@@ -19942,9 +19942,9 @@
"integrity": "sha1-8z/pz7Urv9UgqhgyO8ZdsRCht2w=" "integrity": "sha1-8z/pz7Urv9UgqhgyO8ZdsRCht2w="
}, },
"rollup": { "rollup": {
"version": "2.43.0", "version": "2.43.1",
"resolved": "http://npmprivate.quantgroups.com/rollup/-/rollup-2.43.0.tgz", "resolved": "http://npmprivate.quantgroups.com/rollup/-/rollup-2.43.1.tgz",
"integrity": "sha512-FRsYGqlo1iF/w3bv319iStAK0hyhhwon35Cbo7sGUoXaOpsZFy6Lel7UoGb5bNDE4OsoWjMH94WiVvpOM26l3g==", "integrity": "sha512-kvRE6VJbiv4d8m2nGeccc3qRpzOMghAhu2KeITjyZVCjneIFLPQ3zm2Wmqnl0LcUg3FvDaV0MfKnG4NCMbiSfw==",
"requires": { "requires": {
"fsevents": "~2.3.1" "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