bug修复:1、解决代码生成配置中的查询条件拖拽后不能删除的问题;2、解决删除条件并再次新增条件后点击【保存】按钮无反应问题。

This commit is contained in:
zhoumingfa 2024-08-04 21:58:39 +08:00
parent a1043083dc
commit 594c847523

View File

@ -75,11 +75,9 @@
</template> </template>
<script setup> <script setup>
import _ from 'lodash';
import Sortable from 'sortablejs'; import Sortable from 'sortablejs';
import { inject, nextTick, ref } from 'vue'; import { inject, nextTick, ref } from 'vue';
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue'; import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
import { SmartLoading } from '/@/components/framework/smart-loading';
import { CODE_QUERY_FIELD_QUERY_TYPE_ENUM } from '/@/constants/support/code-generator-const'; import { CODE_QUERY_FIELD_QUERY_TYPE_ENUM } from '/@/constants/support/code-generator-const';
import { convertLowerCamel } from '/@/utils/str-util'; import { convertLowerCamel } from '/@/utils/str-util';
@ -130,12 +128,13 @@
const tableColumns = ref([]); const tableColumns = ref([]);
let rowKeyCounter = 1;
// //
function setData(tableColumnInfos, config) { function setData(tableColumnInfos, config) {
rowKeyCounter = 1; rowKeyCounter = 1;
let data = config && config.queryFields ? config.queryFields : []; let data = config && config.queryFields ? config.queryFields : [];
for (let index = 0; index < data.length; index++) { for (let index = 0; index < data.length; index++) {
data[index].rowKey = 'rowKey' + (index + 1); data[index].rowKey = 'rowKey' + rowKeyCounter;
rowKeyCounter++; rowKeyCounter++;
} }
tableData.value = data; tableData.value = data;
@ -147,7 +146,6 @@
} }
// ------------------- ------------------- // ------------------- -------------------
let rowKeyCounter = 1;
function addQuery() { function addQuery() {
tableData.value.push({ tableData.value.push({
rowKey: 'rowKey' + rowKeyCounter, rowKey: 'rowKey' + rowKeyCounter,
@ -155,13 +153,19 @@
fieldName: '', fieldName: '',
queryTypeEnum: '', queryTypeEnum: '',
columnNameList: null, columnNameList: null,
width: '', width: '200px',
}); });
rowKeyCounter++; rowKeyCounter++;
} }
function onDelete(index) { function onDelete(index) {
_.pullAt(tableData.value, index); //
const tempList = [...tableData.value];
tempList.splice(index, 1);
tableData.value = [];
nextTick(() => {
tableData.value = tempList;
});
} }
// //
@ -173,6 +177,10 @@
ghostClass: 'smart-ghost-class', // ghostClass: 'smart-ghost-class', //
chosenClass: 'smart-ghost-class', // chosenClass: 'smart-ghost-class', //
handle: '.handle', handle: '.handle',
onEnd: ({ oldIndex, newIndex }) => {
const oldRow = tableData.value.splice(oldIndex, 1)[0];
tableData.value.splice(newIndex, 0, oldRow);
},
}); });
} }
@ -211,36 +219,16 @@
// //
function getFieldsForm() { function getFieldsForm() {
let result = []; let result = tableData.value.map((item) => {
let trList = document.querySelectorAll('#smartCodeQueryFieldsTable tbody .column-row'); return {
if (trList && trList.length === 0) { label: item.label,
return result; width: item.width,
} fieldName: item.fieldName,
queryTypeEnum: item.queryTypeEnum,
for (let tr of trList) { //
let rowKey = tr.getAttribute('data-row-key'); columnNameList: item.columnNameList && typeof item.columnNameList === 'string' ? [item.columnNameList] : item.columnNameList,
if (!rowKey) {
continue;
}
if (rowKey && rowKey.indexOf('rowKey') === -1) {
continue;
}
let index = parseInt(rowKey.substring(6));
let tableItem = tableData.value[index - 1];
let obj = {
queryTypeEnum: tableItem.queryTypeEnum,
label: tableItem.label,
fieldName: tableItem.fieldName,
columnNameList: tableItem.columnNameList,
width: tableItem.width,
}; };
// });
if (obj.columnNameList && typeof obj.columnNameList === 'string') {
obj.columnNameList = [obj.columnNameList];
}
result.push(obj);
}
return result; return result;
} }