fix 代码生成编辑表前端排序bug
This commit is contained in:
parent
1fa9d2aad5
commit
21aeb1057b
@ -195,12 +195,17 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
sortField = genTableDto.SortField,
|
sortField = genTableDto.SortField,
|
||||||
sortType = genTable.SortType
|
sortType = genTable.SortType
|
||||||
});
|
});
|
||||||
|
int updateCount = 0;
|
||||||
|
bool result = GenTableService.UseTran2(() =>
|
||||||
|
{
|
||||||
int rows = GenTableService.UpdateGenTable(genTable);
|
int rows = GenTableService.UpdateGenTable(genTable);
|
||||||
if (rows > 0)
|
if (rows > 0)
|
||||||
{
|
{
|
||||||
GenTableColumnService.UpdateGenTableColumn(genTable.Columns);
|
updateCount = GenTableColumnService.UpdateGenTableColumn(genTable.Columns);
|
||||||
}
|
}
|
||||||
return SUCCESS(rows);
|
});
|
||||||
|
|
||||||
|
return SUCCESS(updateCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -219,11 +224,6 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
|
var genTableInfo = GenTableService.GetGenTableInfo(dto.TableId);
|
||||||
genTableInfo.Columns = GenTableColumnService.GenTableColumns(dto.TableId);
|
genTableInfo.Columns = GenTableColumnService.GenTableColumns(dto.TableId);
|
||||||
|
|
||||||
//var dictList = genTableInfo.Columns.FindAll(x => !string.IsNullOrEmpty(x.DictType));
|
|
||||||
//foreach (var item in dictList)
|
|
||||||
//{
|
|
||||||
// item.DictDatas = SysDictDataService.SelectDictDataByType(item.DictType);
|
|
||||||
//}
|
|
||||||
dto.GenTable = genTableInfo;
|
dto.GenTable = genTableInfo;
|
||||||
dto.ZipPath = Path.Combine(WebHostEnvironment.WebRootPath, "Generatecode");
|
dto.ZipPath = Path.Combine(WebHostEnvironment.WebRootPath, "Generatecode");
|
||||||
dto.GenCodePath = Path.Combine(dto.ZipPath, DateTime.Now.ToString("yyyyMMdd"));
|
dto.GenCodePath = Path.Combine(dto.ZipPath, DateTime.Now.ToString("yyyyMMdd"));
|
||||||
|
|||||||
@ -58,7 +58,7 @@ namespace ZR.CodeGenerator
|
|||||||
replaceDto.ShowBtnExport = dto.CheckedBtn.Any(f => f == 4);
|
replaceDto.ShowBtnExport = dto.CheckedBtn.Any(f => f == 4);
|
||||||
|
|
||||||
//循环表字段信息
|
//循环表字段信息
|
||||||
foreach (GenTableColumn dbFieldInfo in dto.GenTable.Columns)
|
foreach (GenTableColumn dbFieldInfo in dto.GenTable.Columns.OrderBy(x => x.Sort))
|
||||||
{
|
{
|
||||||
if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
|
if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
|
||||||
{
|
{
|
||||||
@ -417,7 +417,7 @@ namespace ZR.CodeGenerator
|
|||||||
private static void InitJntTemplate(GenerateDto dto, ReplaceDto replaceDto)
|
private static void InitJntTemplate(GenerateDto dto, ReplaceDto replaceDto)
|
||||||
{
|
{
|
||||||
//Engine.Current.Clean();
|
//Engine.Current.Clean();
|
||||||
|
dto.GenTable.Columns = dto.GenTable.Columns.OrderBy(x => x.Sort).ToList();
|
||||||
//jnt模板引擎全局变量
|
//jnt模板引擎全局变量
|
||||||
Engine.Configure((options) =>
|
Engine.Configure((options) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -64,31 +64,26 @@ namespace ZR.Repository.System
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int UpdateGenTableColumn(List<GenTableColumn> tableColumn)
|
public int UpdateGenTableColumn(List<GenTableColumn> tableColumn)
|
||||||
{
|
{
|
||||||
foreach (var item in tableColumn)
|
return Context.Updateable(tableColumn)
|
||||||
|
.WhereColumns(it => new { it.ColumnId, it.TableId})
|
||||||
|
.UpdateColumns(it => new
|
||||||
{
|
{
|
||||||
Context.Updateable<GenTableColumn>()
|
it.ColumnComment,
|
||||||
.Where(f => f.TableId == item.TableId)
|
it.CsharpField,
|
||||||
.SetColumns(it => new GenTableColumn()
|
it.CsharpType,
|
||||||
{
|
it.IsQuery,
|
||||||
ColumnComment = item.ColumnComment,
|
it.IsEdit,
|
||||||
CsharpField = item.CsharpField,
|
it.IsInsert,
|
||||||
CsharpType = item.CsharpType,
|
it.IsList,
|
||||||
IsQuery = item.IsQuery,
|
it.QueryType,
|
||||||
IsEdit = item.IsEdit,
|
it.HtmlType,
|
||||||
IsInsert = item.IsInsert,
|
it.IsRequired,
|
||||||
IsList = item.IsList,
|
it.Sort,
|
||||||
QueryType = item.QueryType,
|
it.Update_time,
|
||||||
HtmlType = item.HtmlType,
|
it.DictType,
|
||||||
IsRequired = item.IsRequired,
|
it.Update_by
|
||||||
Sort = item.Sort,
|
|
||||||
Update_time = DateTime.Now,
|
|
||||||
DictType = item.DictType
|
|
||||||
})
|
})
|
||||||
.Where(f => f.ColumnId == item.ColumnId)
|
|
||||||
.ExecuteCommand();
|
.ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,8 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="字典类型" min-width="12%">
|
<el-table-column label="字典类型" min-width="12%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择" v-if="scope.row.htmlType == 'select' || scope.row.htmlType == 'radio' || scope.row.htmlType =='checkbox'">
|
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择"
|
||||||
|
v-if="scope.row.htmlType == 'select' || scope.row.htmlType == 'radio' || scope.row.htmlType =='checkbox'">
|
||||||
<el-option v-for="dict in dictOptions" :key="dict.dictType" :label="dict.dictName" :value="dict.dictType">
|
<el-option v-for="dict in dictOptions" :key="dict.dictType" :label="dict.dictName" :value="dict.dictType">
|
||||||
<span style="float: left">{{ dict.dictName }}</span>
|
<span style="float: left">{{ dict.dictName }}</span>
|
||||||
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
|
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
|
||||||
@ -177,13 +178,14 @@ export default {
|
|||||||
if (validateResult) {
|
if (validateResult) {
|
||||||
const genTable = Object.assign({}, basicForm.model, genForm.model);
|
const genTable = Object.assign({}, basicForm.model, genForm.model);
|
||||||
genTable.columns = this.cloumns;
|
genTable.columns = this.cloumns;
|
||||||
// genTable.params = {
|
genTable.params = {
|
||||||
// treeCode: genTable.treeCode,
|
// treeCode: genTable.treeCode,
|
||||||
// treeName: genTable.treeName,
|
// treeName: genTable.treeName,
|
||||||
// treeParentCode: genTable.treeParentCode,
|
// treeParentCode: genTable.treeParentCode,
|
||||||
// parentMenuId: genTable.parentMenuId,
|
//parentMenuId: genTable.parentMenuId,
|
||||||
// };
|
};
|
||||||
// console.log(JSON.stringify(genTable));
|
console.log("genForm", genTable);
|
||||||
|
// return;
|
||||||
updateGenTable(genTable).then((res) => {
|
updateGenTable(genTable).then((res) => {
|
||||||
this.msgSuccess(res.msg);
|
this.msgSuccess(res.msg);
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
@ -207,21 +209,32 @@ export default {
|
|||||||
this.$store.dispatch("tagsView/delView", this.$route);
|
this.$store.dispatch("tagsView/delView", this.$route);
|
||||||
this.$router.push({ path: "/tool/gen", query: { t: Date.now() } });
|
this.$router.push({ path: "/tool/gen", query: { t: Date.now() } });
|
||||||
},
|
},
|
||||||
},
|
sortTable(columns) {
|
||||||
mounted() {
|
|
||||||
const el = this.$refs.dragTable.$el.querySelectorAll(
|
const el = this.$refs.dragTable.$el.querySelectorAll(
|
||||||
".el-table__body-wrapper > table > tbody"
|
".el-table__body-wrapper > table > tbody"
|
||||||
)[0];
|
)[0];
|
||||||
|
var that = this;
|
||||||
const sortable = Sortable.create(el, {
|
const sortable = Sortable.create(el, {
|
||||||
handle: ".allowDrag",
|
handle: ".allowDrag",
|
||||||
onEnd: (evt) => {
|
onEnd: (evt) => {
|
||||||
const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0];
|
const targetRow = that.cloumns.splice(evt.oldIndex, 1)[0];
|
||||||
this.cloumns.splice(evt.newIndex, 0, targetRow);
|
columns.splice(evt.newIndex, 0, targetRow);
|
||||||
for (let index in this.cloumns) {
|
for (let index in columns) {
|
||||||
this.cloumns[index].sort = parseInt(index) + 1;
|
columns[index].sort = parseInt(index) + 1;
|
||||||
}
|
}
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.columns = columns;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
cloumns: {
|
||||||
|
handler(val) {
|
||||||
|
this.sortTable(val);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user