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

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

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