--no commit message
Showing
1 changed file
with
80 additions
and
70 deletions
... | @@ -8,51 +8,64 @@ | ... | @@ -8,51 +8,64 @@ |
8 | <div class="fieldcheck"> | 8 | <div class="fieldcheck"> |
9 | <div class="left"> | 9 | <div class="left"> |
10 | <div class="header"> | 10 | <div class="header"> |
11 | <div class="headerconcent"> | ||
11 | <el-checkbox | 12 | <el-checkbox |
12 | class="check" | 13 | class="check" |
13 | :indeterminate="isIndeterminate" | 14 | :indeterminate="isIndeterminate" |
14 | v-model="checkAll" | 15 | v-model="checkAll" |
15 | @change="handleCheckAllChange">待选合集</el-checkbox> | 16 | @change="handleCheckAllChange" |
16 | <div class="num">/</div> | 17 | >待选合集</el-checkbox |
18 | > | ||
19 | <div class="num"> | ||
20 | 总数{{ cities.length }} 已选{{ datalist.length }} | ||
21 | </div> | ||
22 | </div> | ||
17 | </div> | 23 | </div> |
18 | <el-checkbox-group | 24 | <el-checkbox-group |
19 | class="concent" | 25 | class="concent" |
20 | v-model="checkedCities" | 26 | v-model="checkedCities" |
21 | @change="handleCheckedCitiesChange"> | 27 | @change="handleCheckedCitiesChange" |
28 | > | ||
22 | <el-checkbox | 29 | <el-checkbox |
23 | v-for="city in cities" | 30 | v-for="city in cities" |
24 | :label="city.name" | 31 | :label="city.name" |
25 | :key="city.name">{{ city.despriction }}({{ city.name }})</el-checkbox> | 32 | :key="city.name" |
33 | >{{ city.despriction }}({{ city.name }})</el-checkbox | ||
34 | > | ||
26 | </el-checkbox-group> | 35 | </el-checkbox-group> |
27 | </div> | 36 | </div> |
28 | <div class="right"> | 37 | <div class="right"> |
29 | <el-table | 38 | <el-table |
30 | class="tablelist" | 39 | class="tablelist" |
31 | :data="datalist" | 40 | :data="datalist" |
41 | border | ||
32 | ref="listTable" | 42 | ref="listTable" |
33 | :key="key" | 43 | :key="key" |
34 | row-key="name" | 44 | row-key="name" |
35 | :pagination="false" | 45 | :pagination="false" |
36 | :header-cell-style="{ 'text-align': 'center' }" | ||
37 | :heightNumSetting="true" | 46 | :heightNumSetting="true" |
38 | :minHeight="150" | 47 | :minHeight="150" |
39 | height="590" | 48 | height="650" |
40 | style="width: 100%"> | 49 | style="width: 100%" |
50 | > | ||
41 | <el-table-column label="字段" prop="name" min-width="100"> | 51 | <el-table-column label="字段" prop="name" min-width="100"> |
42 | </el-table-column> | 52 | </el-table-column> |
43 | 53 | ||
44 | <el-table-column | 54 | <el-table-column |
45 | label="字段名称" | 55 | label="字段名称" |
46 | prop="desprictionor" | 56 | prop="desprictionor" |
47 | min-width="100"> | 57 | min-width="100" |
58 | > | ||
48 | </el-table-column> | 59 | </el-table-column> |
49 | <el-table-column label="字段别名" min-width="100"> | 60 | <el-table-column label="字段别名" min-width="100"> |
50 | <template slot-scope="scope"> | 61 | <template slot-scope="scope"> |
51 | <el-input | 62 | <el-input |
52 | v-model="scope.row.despriction" | 63 | v-model="scope.row.despriction" |
53 | placeholder="请输入内容" | 64 | placeholder="请输入内容" |
54 | @input="sumTime(scope.$index, scope.row.tdsyqx)"> | 65 | @input="sumTime(scope.$index, scope.row.tdsyqx)" |
55 | ></el-input> | 66 | > |
67 | ></el-input | ||
68 | > | ||
56 | </template> | 69 | </template> |
57 | </el-table-column> | 70 | </el-table-column> |
58 | </el-table> | 71 | </el-table> |
... | @@ -66,16 +79,16 @@ | ... | @@ -66,16 +79,16 @@ |
66 | </template> | 79 | </template> |
67 | 80 | ||
68 | <script> | 81 | <script> |
69 | import Sortable from 'sortablejs' | 82 | import Sortable from "sortablejs"; |
70 | import { getFieldList, getFieldListByQlxx, save } from "@/api/SysDjbFieldDO"; | 83 | import { getFieldList, getFieldListByQlxx, save } from "@/api/SysDjbFieldDO"; |
71 | export default { | 84 | export default { |
72 | props: { | 85 | props: { |
73 | formData: { | 86 | formData: { |
74 | type: Object, | 87 | type: Object, |
75 | default: () => { }, | 88 | default: () => {}, |
76 | }, | 89 | }, |
77 | }, | 90 | }, |
78 | data () { | 91 | data() { |
79 | return { | 92 | return { |
80 | checkAll: false, | 93 | checkAll: false, |
81 | sortable: null, | 94 | sortable: null, |
... | @@ -87,48 +100,51 @@ | ... | @@ -87,48 +100,51 @@ |
87 | isIndeterminate: true, | 100 | isIndeterminate: true, |
88 | }; | 101 | }; |
89 | }, | 102 | }, |
90 | mounted () { | 103 | mounted() { |
91 | this.generateData() | 104 | this.generateData(); |
92 | }, | 105 | }, |
93 | beforeDestroy () { | 106 | beforeDestroy() { |
94 | if (this.sortable) { | 107 | if (this.sortable) { |
95 | this.sortable.destroy(); | 108 | this.sortable.destroy(); |
96 | } | 109 | } |
97 | }, | 110 | }, |
98 | watch: { | 111 | watch: { |
99 | key: { | 112 | key: { |
100 | handler (newName, oldName) { | 113 | handler(newName, oldName) { |
101 | this.initSort() | 114 | this.initSort(); |
102 | } | 115 | }, |
103 | } | 116 | }, |
104 | }, | 117 | }, |
105 | methods: { | 118 | methods: { |
106 | changeIndex (array, index1, index2) { | 119 | changeIndex(array, index1, index2) { |
107 | array[index1] = array.splice(index2, 1, array[index1])[0]; | 120 | array[index1] = array.splice(index2, 1, array[index1])[0]; |
108 | }, | 121 | }, |
109 | initSort () { | 122 | initSort() { |
110 | const el = this.$refs.listTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0] | 123 | const el = this.$refs.listTable.$el.querySelectorAll( |
124 | ".el-table__body-wrapper > table > tbody" | ||
125 | )[0]; | ||
111 | // const sortable = new Sortable(el, options); | 126 | // const sortable = new Sortable(el, options); |
112 | // 根据具体需求配置options配置项 | 127 | // 根据具体需求配置options配置项 |
113 | const sortable = new Sortable(el, { | 128 | const sortable = new Sortable(el, { |
114 | onEnd: (evt) => { // 监听拖动结束事件 | 129 | onEnd: (evt) => { |
115 | console.log(this) // this是当前vue上下文 | 130 | // 监听拖动结束事件 |
116 | console.log(evt.oldIndex) // 当前行的被拖拽前的顺序 | 131 | console.log(this); // this是当前vue上下文 |
117 | console.log(evt.newIndex) // 当前行的被拖拽后的顺序 | 132 | console.log(evt.oldIndex); // 当前行的被拖拽前的顺序 |
133 | console.log(evt.newIndex); // 当前行的被拖拽后的顺序 | ||
118 | // 这里就可以写我们需要传给后台的逻辑代码 | 134 | // 这里就可以写我们需要传给后台的逻辑代码 |
119 | // 我们有了 evt.oldIndex 和 evt.newIndex 这两个参数做索引,我们可以根据绑定在表格上面的 data 这个 Array 找到两个相应的记录。就可以针对数据进行操作啦。 | 135 | // 我们有了 evt.oldIndex 和 evt.newIndex 这两个参数做索引,我们可以根据绑定在表格上面的 data 这个 Array 找到两个相应的记录。就可以针对数据进行操作啦。 |
120 | // 下面将拖拽后的顺序进行修改 | 136 | // 下面将拖拽后的顺序进行修改 |
121 | const currRow = this.datalist.splice(evt.oldIndex, 1)[0] | 137 | const currRow = this.datalist.splice(evt.oldIndex, 1)[0]; |
122 | this.datalist.splice(evt.newIndex, 0, currRow) | 138 | this.datalist.splice(evt.newIndex, 0, currRow); |
123 | } | 139 | }, |
124 | }) | 140 | }); |
125 | }, | 141 | }, |
126 | /** | 142 | /** |
127 | * @description: 初始数据集 | 143 | * @description: 初始数据集 |
128 | * @author: renchao | 144 | * @author: renchao |
129 | */ | 145 | */ |
130 | generateData () { | 146 | generateData() { |
131 | let that = this | 147 | let that = this; |
132 | getFieldList({ qllx: this.formData.qllx }).then((res) => { | 148 | getFieldList({ qllx: this.formData.qllx }).then((res) => { |
133 | if (res.code === 200) { | 149 | if (res.code === 200) { |
134 | let listss = res.result; | 150 | let listss = res.result; |
... | @@ -150,38 +166,37 @@ | ... | @@ -150,38 +166,37 @@ |
150 | desprictionor: item.despriction, | 166 | desprictionor: item.despriction, |
151 | }); | 167 | }); |
152 | that.$nextTick(() => { | 168 | that.$nextTick(() => { |
153 | that.datalist = this.tablelist | 169 | that.datalist = this.tablelist; |
154 | that.checkedCities.push(item.name); | 170 | that.checkedCities.push(item.name); |
155 | }) | 171 | }); |
156 | }) | 172 | }); |
157 | that.initSort() | 173 | that.initSort(); |
158 | } | 174 | } |
159 | }); | 175 | }); |
160 | } | 176 | } |
161 | }); | 177 | }); |
162 | }, | 178 | }, |
163 | handleCheckAllChange (val) { | 179 | handleCheckAllChange(val) { |
164 | let checkedlist = [] | 180 | let checkedlist = []; |
165 | let orlist = [] | 181 | let orlist = []; |
166 | checkedlist = val ? this.cities : []; | 182 | checkedlist = val ? this.cities : []; |
167 | this.isIndeterminate = false; | 183 | this.isIndeterminate = false; |
168 | console.log("this.checkedCities", this.checkedCities); | 184 | console.log("this.checkedCities", this.checkedCities); |
169 | let lists = []; | 185 | let lists = []; |
170 | this.cities.forEach((item, index) => { | 186 | this.cities.forEach((item, index) => { |
171 | |||
172 | checkedlist.forEach((el) => { | 187 | checkedlist.forEach((el) => { |
173 | orlist.push(el.name) | 188 | orlist.push(el.name); |
174 | if (item.name == el.name) { | 189 | if (item.name == el.name) { |
175 | lists.push(this.cities[index]); | 190 | lists.push(this.cities[index]); |
176 | } | 191 | } |
177 | }); | 192 | }); |
178 | }); | 193 | }); |
179 | this.checkedCities = orlist | 194 | this.checkedCities = orlist; |
180 | this.datalist = lists; | 195 | this.datalist = lists; |
181 | // 其他排序逻辑 | 196 | // 其他排序逻辑 |
182 | this.initSort() | 197 | this.initSort(); |
183 | }, | 198 | }, |
184 | handleCheckedCitiesChange (value) { | 199 | handleCheckedCitiesChange(value) { |
185 | console.log("value", value, this.checkedCities); | 200 | console.log("value", value, this.checkedCities); |
186 | let checkedCount = value.length; | 201 | let checkedCount = value.length; |
187 | this.checkAll = checkedCount === this.cities.length; | 202 | this.checkAll = checkedCount === this.cities.length; |
... | @@ -191,16 +206,15 @@ | ... | @@ -191,16 +206,15 @@ |
191 | this.cities.forEach((item, index) => { | 206 | this.cities.forEach((item, index) => { |
192 | this.checkedCities.forEach((el) => { | 207 | this.checkedCities.forEach((el) => { |
193 | if (item.name == el) { | 208 | if (item.name == el) { |
194 | console.log("1"); | ||
195 | lists.push(this.cities[index]); | 209 | lists.push(this.cities[index]); |
196 | } | 210 | } |
197 | }); | 211 | }); |
198 | }); | 212 | }); |
199 | this.datalist = lists; | 213 | this.datalist = lists; |
200 | // 其他排序逻辑 | 214 | // 其他排序逻辑 |
201 | this.initSort() | 215 | this.initSort(); |
202 | }, | 216 | }, |
203 | submitForm () { | 217 | submitForm() { |
204 | save(this.formData.bsmMb, this.datalist).then((res) => { | 218 | save(this.formData.bsmMb, this.datalist).then((res) => { |
205 | if (res.code == 200) { | 219 | if (res.code == 200) { |
206 | this.$popupCacel(); | 220 | this.$popupCacel(); |
... | @@ -217,19 +231,19 @@ | ... | @@ -217,19 +231,19 @@ |
217 | }); | 231 | }); |
218 | }, | 232 | }, |
219 | }, | 233 | }, |
220 | }; | 234 | }; |
221 | </script> | 235 | </script> |
222 | <style scoped lang="scss"> | 236 | <style scoped lang="scss"> |
223 | @import "~@/styles/mixin.scss"; | 237 | @import "~@/styles/mixin.scss"; |
224 | @import "~@/styles/dialogBoxheader.scss"; | 238 | @import "~@/styles/dialogBoxheader.scss"; |
225 | .fieldcheck { | 239 | .fieldcheck { |
226 | width: 100%; | 240 | width: 100%; |
227 | height: 650px; | 241 | height: 650px; |
228 | display: flex; | 242 | display: flex; |
229 | justify-content: space-between; | 243 | justify-content: space-between; |
230 | .left, | 244 | .left, |
231 | .right { | 245 | .right { |
232 | width: 47%; | 246 | width: 49%; |
233 | height: 650px; | 247 | height: 650px; |
234 | border: 1px solid rgb(230, 230, 230); | 248 | border: 1px solid rgb(230, 230, 230); |
235 | } | 249 | } |
... | @@ -237,16 +251,15 @@ | ... | @@ -237,16 +251,15 @@ |
237 | .header { | 251 | .header { |
238 | width: 100%; | 252 | width: 100%; |
239 | height: 50px; | 253 | height: 50px; |
240 | line-height: 50px; | ||
241 | background-color: rgba(243, 242, 242, 0.897); | 254 | background-color: rgba(243, 242, 242, 0.897); |
242 | display: flex; | 255 | .headerconcent { |
243 | justify-content: space-around; | 256 | width: 90%; |
244 | align-items:center .check { | 257 | height: 50px; |
245 | height: 20px; | ||
246 | margin: auto; | 258 | margin: auto; |
247 | } | 259 | line-height: 50px; |
248 | .num { | 260 | display: flex; |
249 | height: 20px; | 261 | justify-content: space-between; |
262 | align-items: center; | ||
250 | } | 263 | } |
251 | } | 264 | } |
252 | .concent { | 265 | .concent { |
... | @@ -273,15 +286,12 @@ | ... | @@ -273,15 +286,12 @@ |
273 | line-height: 50px; | 286 | line-height: 50px; |
274 | background-color: rgba(243, 242, 242, 0.897); | 287 | background-color: rgba(243, 242, 242, 0.897); |
275 | } | 288 | } |
276 | .tablelist { | 289 | |
277 | margin-top: 10px; | ||
278 | height: 680px; | ||
279 | } | ||
280 | } | ||
281 | } | 290 | } |
282 | .btn { | 291 | } |
292 | .btn { | ||
283 | margin-top: 10px; | 293 | margin-top: 10px; |
284 | width: 100%; | 294 | width: 100%; |
285 | text-align: center; | 295 | text-align: center; |
286 | } | 296 | } |
287 | </style> | 297 | </style> | ... | ... |
-
Please register or sign in to post a comment