Commit ed04c24eb35a16c122e4c32b2cc703b5c385760f
1 parent
f9799cd4
代码生成列支持拖动排序
Showing
3 changed files
with
22 additions
and
1 deletions
ruoyi-ui/package.json
ruoyi-ui/src/assets/styles/ruoyi.scss
... | ... | @@ -187,4 +187,11 @@ |
187 | 187 | border-radius: 50%; |
188 | 188 | box-shadow: 0 0 4px #ccc; |
189 | 189 | overflow: hidden; |
190 | +} | |
191 | + | |
192 | +/* 拖拽列样式 */ | |
193 | +.sortable-ghost{ | |
194 | + opacity: .8; | |
195 | + color: #fff!important; | |
196 | + background: #42b983!important; | |
190 | 197 | } |
191 | 198 | \ No newline at end of file |
... | ... |
ruoyi-ui/src/views/tool/gen/editTable.vue
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <basic-info-form ref="basicInfo" :info="info" /> |
6 | 6 | </el-tab-pane> |
7 | 7 | <el-tab-pane label="字段信息" name="cloum"> |
8 | - <el-table :data="cloumns" :max-height="tableHeight"> | |
8 | + <el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight"> | |
9 | 9 | <el-table-column label="序号" type="index" min-width="5%" /> |
10 | 10 | <el-table-column |
11 | 11 | label="字段列名" |
... | ... | @@ -126,6 +126,7 @@ import { getGenTable, updateGenTable } from "@/api/tool/gen"; |
126 | 126 | import { optionselect as getDictOptionselect } from "@/api/system/dict/type"; |
127 | 127 | import basicInfoForm from "./basicInfoForm"; |
128 | 128 | import genInfoForm from "./genInfoForm"; |
129 | +import Sortable from 'sortablejs' | |
129 | 130 | export default { |
130 | 131 | name: "GenEdit", |
131 | 132 | components: { |
... | ... | @@ -198,6 +199,18 @@ export default { |
198 | 199 | this.$store.dispatch("tagsView/delView", this.$route); |
199 | 200 | this.$router.push({ path: "/tool/gen", query: { t: Date.now()}}) |
200 | 201 | } |
202 | + }, | |
203 | + mounted() { | |
204 | + const el = this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0]; | |
205 | + const sortable = Sortable.create(el, { | |
206 | + onEnd: evt => { | |
207 | + const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0]; | |
208 | + this.cloumns.splice(evt.newIndex, 0, targetRow); | |
209 | + for (let index in this.cloumns) { | |
210 | + this.cloumns[index].sort = parseInt(index) + 1; | |
211 | + } | |
212 | + } | |
213 | + }); | |
201 | 214 | } |
202 | 215 | }; |
203 | 216 | </script> |
... | ... |