增加上移下移功能
Showing
3 changed files
with
89 additions
and
195 deletions
src/utils/operation copy.js
deleted
100644 → 0
| 1 | import { Message } from "element-ui"; | ||
| 2 | export function removeTreeListItem (treeList, dictId, idName = 'bsmDict') { | ||
| 3 | if (!treeList || !treeList.length) { | ||
| 4 | return | ||
| 5 | } | ||
| 6 | for (let i = 0; i < treeList.length; i++) { | ||
| 7 | if (treeList[i][idName] === dictId) { | ||
| 8 | treeList.splice(i, 1); | ||
| 9 | break; | ||
| 10 | } | ||
| 11 | removeTreeListItem(treeList[i].children, dictId) | ||
| 12 | } | ||
| 13 | } | ||
| 14 | // 创造id | ||
| 15 | export function getUuid (len, radix) { | ||
| 16 | var chars = "0123456789abcdefghijklmnopqrstuvwxyz".split( | ||
| 17 | "" | ||
| 18 | ); | ||
| 19 | var uuid = [], | ||
| 20 | i; | ||
| 21 | radix = radix || chars.length; | ||
| 22 | if (len) { | ||
| 23 | for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)]; | ||
| 24 | } else { | ||
| 25 | var r; | ||
| 26 | uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-"; | ||
| 27 | uuid[14] = "4"; | ||
| 28 | for (i = 0; i < 36; i++) { | ||
| 29 | if (!uuid[i]) { | ||
| 30 | r = 0 | (Math.random() * 16); | ||
| 31 | uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r]; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | return uuid.join(""); | ||
| 36 | } | ||
| 37 | export function judgeSort (arr) { | ||
| 38 | if (arr.length) { | ||
| 39 | for (let i in arr) { | ||
| 40 | arr[i]["isTop"] = false; | ||
| 41 | arr[i]["isBottom"] = false; | ||
| 42 | arr[i] == arr[0] && (arr[i].isTop = true); | ||
| 43 | arr[i] == arr[arr.length - 1] && (arr[i].isBottom = true); | ||
| 44 | arr[i].children && arr[i].children.length && judgeSort(arr[i].children) | ||
| 45 | } | ||
| 46 | } | ||
| 47 | return arr | ||
| 48 | } | ||
| 49 | // 上下移动 | ||
| 50 | export function realMove (bsmDict, operate, data) { | ||
| 51 | function changeSort (arr, bsmDict) { | ||
| 52 | if (arr.length) { | ||
| 53 | let flag = false; | ||
| 54 | for (let i in arr) { | ||
| 55 | if (arr[i].bsmDict == bsmDict) { | ||
| 56 | if (operate === "UP") { | ||
| 57 | arr[i] = arr.splice(i - 1, 1, arr[i])[0]; | ||
| 58 | } else if (operate === "DOWN") { | ||
| 59 | let temp = arr.splice(i - 0 + 1, 1, arr[i]) | ||
| 60 | arr[i] = temp[0]; | ||
| 61 | } | ||
| 62 | flag = true; | ||
| 63 | break; | ||
| 64 | } | ||
| 65 | if (!flag && arr[i].children && arr[i].children.length) { | ||
| 66 | arr[i].children = changeSort(arr[i].children, bsmDict); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
| 70 | return arr; | ||
| 71 | } | ||
| 72 | data = judgeSort(changeSort(data, bsmDict)); | ||
| 73 | } | ||
| 74 | // 获取所有父节点 | ||
| 75 | export function findParents (treeData, bsmDict) { | ||
| 76 | if (treeData.length == 0) return | ||
| 77 | for (let i = 0; i < treeData.length; i++) { | ||
| 78 | if (treeData[i].bsmDict == bsmDict) { | ||
| 79 | return [] | ||
| 80 | } else { | ||
| 81 | if (treeData[i].children) { | ||
| 82 | let res = findParents(treeData[i].children, bsmDict) | ||
| 83 | if (res !== undefined) { | ||
| 84 | return res.concat(treeData[i].bsmDict) | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
| 88 | } | ||
| 89 | } | ||
| 90 | // 上移下移 | ||
| 91 | export function upward (index, data) { | ||
| 92 | if (index > 0) { | ||
| 93 | let upData = data[index - 1]; | ||
| 94 | data.splice(index - 1, 1); | ||
| 95 | data.splice(index, 0, upData); | ||
| 96 | } else { | ||
| 97 | Message({ | ||
| 98 | message: '已经是第一条,上移失败' | ||
| 99 | }); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | export function down (index, data) { | ||
| 103 | if ((index + 1) == data.length) { | ||
| 104 | Message({ | ||
| 105 | message: '已经是最后一条,下移失败' | ||
| 106 | }); | ||
| 107 | } else { | ||
| 108 | let downData = data[index + 1]; | ||
| 109 | data.splice(index + 1, 1); | ||
| 110 | data.splice(index, 0, downData); | ||
| 111 | } | ||
| 112 | } |
| ... | @@ -6,21 +6,21 @@ class data extends filter { | ... | @@ -6,21 +6,21 @@ class data extends filter { |
| 6 | columns () { | 6 | columns () { |
| 7 | return [ | 7 | return [ |
| 8 | { | 8 | { |
| 9 | prop: "code", | 9 | prop: "DCODE", |
| 10 | label: "工号", | 10 | label: "工号", |
| 11 | width: 130 | 11 | width: 130 |
| 12 | }, | 12 | }, |
| 13 | { | 13 | { |
| 14 | prop: "name", | 14 | prop: "DNAME", |
| 15 | label: "姓名", | 15 | label: "姓名", |
| 16 | width: 300 | 16 | width: 300 |
| 17 | }, | 17 | }, |
| 18 | { | 18 | { |
| 19 | prop: "loginName", | 19 | prop: "PARENTID", |
| 20 | label: "用户名" | 20 | label: "用户名" |
| 21 | }, | 21 | }, |
| 22 | { | 22 | { |
| 23 | prop: "isDuty", | 23 | prop: "TYPEID", |
| 24 | width: 260, | 24 | width: 260, |
| 25 | label: "负责人" | 25 | label: "负责人" |
| 26 | }, | 26 | }, | ... | ... |
| ... | @@ -16,9 +16,17 @@ | ... | @@ -16,9 +16,17 @@ |
| 16 | </el-form> | 16 | </el-form> |
| 17 | </div> | 17 | </div> |
| 18 | <div class="from-clues-content"> | 18 | <div class="from-clues-content"> |
| 19 | <lb-table :page-size="pageData.size" :current-page.sync="pageData.current" :total="pageData.total" | 19 | <lb-table |
| 20 | @size-change="handleSizeChange" @p-current-change="handleCurrentChange" :column="tableData.columns" | 20 | :page-size="pageData.size" |
| 21 | :data="tableData.data"> | 21 | :current-page.sync="pageData.current" |
| 22 | :total="pageData.total" | ||
| 23 | @size-change="handleSizeChange" | ||
| 24 | @p-current-change="handleCurrentChange" | ||
| 25 | :column="tableData.columns" | ||
| 26 | :data="tableData.data" | ||
| 27 | :key="key" | ||
| 28 | :expand-row-keys="keyList" row-key="dictid" | ||
| 29 | > | ||
| 22 | </lb-table> | 30 | </lb-table> |
| 23 | </div> | 31 | </div> |
| 24 | <edit-dialog ref="dialogForm" /> | 32 | <edit-dialog ref="dialogForm" /> |
| ... | @@ -43,9 +51,10 @@ export default { | ... | @@ -43,9 +51,10 @@ export default { |
| 43 | components: { | 51 | components: { |
| 44 | EditDialog, | 52 | EditDialog, |
| 45 | }, | 53 | }, |
| 46 | data () { | 54 | data() { |
| 47 | return { | 55 | return { |
| 48 | taskData: null, | 56 | taskData: null, |
| 57 | keyList: [], | ||
| 49 | form: { | 58 | form: { |
| 50 | job_name: "", | 59 | job_name: "", |
| 51 | currentPage: 1, | 60 | currentPage: 1, |
| ... | @@ -57,7 +66,6 @@ export default { | ... | @@ -57,7 +66,6 @@ export default { |
| 57 | departmentId: "", // 部门ID | 66 | departmentId: "", // 部门ID |
| 58 | departmentList: [], // 部门列表 | 67 | departmentList: [], // 部门列表 |
| 59 | levelList: [], // 职务级别 | 68 | levelList: [], // 职务级别 |
| 60 | tableData: [], | ||
| 61 | sexList: [], | 69 | sexList: [], |
| 62 | typeOptions: [ | 70 | typeOptions: [ |
| 63 | { | 71 | { |
| ... | @@ -180,75 +188,76 @@ export default { | ... | @@ -180,75 +188,76 @@ export default { |
| 180 | }; | 188 | }; |
| 181 | }, | 189 | }, |
| 182 | methods: { | 190 | methods: { |
| 183 | handleAdd () { | 191 | // 添加索引 |
| 192 | // addIndexes (data = this.tableData.data, isAdd = true) { | ||
| 193 | // data.forEach((item, index) => { | ||
| 194 | // if (index == 0) { | ||
| 195 | // item.codeShow = true; | ||
| 196 | // item.nameShow = false; | ||
| 197 | // item.normcodeShow = false; | ||
| 198 | // item.normnameShow = false; | ||
| 199 | // } else { | ||
| 200 | // item.codeShow = false; | ||
| 201 | // item.nameShow = false; | ||
| 202 | // item.normcodeShow = false; | ||
| 203 | // item.normnameShow = false; | ||
| 204 | // } | ||
| 205 | // if (isAdd) { | ||
| 206 | // item.index = index + 1; | ||
| 207 | // } | ||
| 208 | // if (item.children) { | ||
| 209 | // this.addIndexes(item.children, false); | ||
| 210 | // } | ||
| 211 | // }); | ||
| 212 | // }, | ||
| 213 | handleAdd() { | ||
| 184 | this.taskData = null; | 214 | this.taskData = null; |
| 185 | this.$refs.dialogForm.add(); | 215 | this.$refs.dialogForm.add(); |
| 186 | this.$refs.dialogForm.title = "添加"; | 216 | this.$refs.dialogForm.title = "添加"; |
| 187 | }, | 217 | }, |
| 188 | featchData () { | 218 | featchData() { |
| 189 | this.tableData.data = [ | 219 | this.tableData.data = [ |
| 190 | { | 220 | { |
| 191 | id: "6a269fa4-49ee-40ed-be72-302ebdf7b9d6", | 221 | "dictid": "51b9f487861671f77782c5a23b5fe52e", |
| 192 | name: "组件开发模板测试用户", | 222 | "children": null, |
| 193 | sort: 67, | 223 | "TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF", |
| 194 | loginName: "wgs-template-test", | 224 | "PARENTID": "ouyds", |
| 195 | email: null, | 225 | "DCODE": "1223", |
| 196 | lastLoginTime: null, | 226 | "DNAME": "小红", |
| 197 | mobilePhone: null, | 227 | "SORT": null, |
| 198 | isLocked: false, | 228 | "index": 1, |
| 199 | status: "ACTIVE", | 229 | "isTop": true, |
| 200 | passwordChangeTime: "2022-06-29T01:59:18.123+0000", | 230 | "isBottom": false |
| 201 | idCard: null, | ||
| 202 | departmentId: "dcce05ff-7747-4c19-b31f-c018ec8d8f0c", | ||
| 203 | departmentName: "科室一", | ||
| 204 | organizationId: "e9e830f0-38f4-4fb2-90ad-496c4e1314aa", | ||
| 205 | sex: "0", | ||
| 206 | isDuty: null, | ||
| 207 | code: "adfasfd", | ||
| 208 | jobLevel: null, | ||
| 209 | telephone: null, | ||
| 210 | address: null, | ||
| 211 | _X_ROW_KEY: "row_42", | ||
| 212 | switch: true, | ||
| 213 | }, | 231 | }, |
| 214 | { | 232 | { |
| 215 | id: "acebbaf3-81d0-4b0f-a426-feafa7ea1bed", | 233 | "dictid": "2291d9e298274c1ea1f40df63fbcff47", |
| 216 | name: "饿肚肚", | 234 | "children": null, |
| 217 | sort: 36, | 235 | "TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF", |
| 218 | loginName: "吃饭", | 236 | "PARENTID": "wer", |
| 219 | email: null, | 237 | "DCODE": "124334", |
| 220 | lastLoginTime: null, | 238 | "DNAME": "小李", |
| 221 | mobilePhone: null, | 239 | "SORT": null, |
| 222 | isLocked: false, | 240 | "index": 2, |
| 223 | status: "ACTIVE", | 241 | "isTop": false, |
| 224 | passwordChangeTime: "2021-08-24T02:04:39.132+0000", | 242 | "isBottom": false |
| 225 | idCard: "43423441242134 ", | ||
| 226 | departmentId: "dcce05ff-7747-4c19-b31f-c018ec8d8f0c", | ||
| 227 | departmentName: "科室一", | ||
| 228 | organizationId: "e9e830f0-38f4-4fb2-90ad-496c4e1314aa", | ||
| 229 | sex: null, | ||
| 230 | isDuty: null, | ||
| 231 | code: "2323", | ||
| 232 | jobLevel: null, | ||
| 233 | telephone: null, | ||
| 234 | address: null, | ||
| 235 | _X_ROW_KEY: "row_43", | ||
| 236 | switch: true, | ||
| 237 | }, | 243 | }, |
| 238 | ]; | 244 | { |
| 245 | "dictid": "e6a5aeb8957b8029fa31586fb30dd5b8", | ||
| 246 | "children": null, | ||
| 247 | "TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF", | ||
| 248 | "PARENTID": "underf", | ||
| 249 | "DCODE": "2344", | ||
| 250 | "DNAME": "小田", | ||
| 251 | "SORT": null, | ||
| 252 | "index": 13, | ||
| 253 | "isTop": false, | ||
| 254 | "isBottom": true | ||
| 255 | } | ||
| 256 | ]; | ||
| 239 | }, | 257 | }, |
| 240 | // 重置搜索 | ||
| 241 | // resetSearch() { | ||
| 242 | // this.selectType = "0"; | ||
| 243 | // this.queryName = ""; | ||
| 244 | // this.queryParam = { | ||
| 245 | // organizationId: this.organizationId, | ||
| 246 | // departmentId: this.departmentId | ||
| 247 | // } | ||
| 248 | // }, | ||
| 249 | 258 | ||
| 250 | // 更新用户解锁状态 | 259 | // 更新用户解锁状态 |
| 251 | updateLock (id, name) { | 260 | updateLock(id, name) { |
| 252 | this.$confirm( | 261 | this.$confirm( |
| 253 | `<div class="customer-message-wrapper"> | 262 | `<div class="customer-message-wrapper"> |
| 254 | <h5 class="title">确定要更新用户解锁状态吗</h5> | 263 | <h5 class="title">确定要更新用户解锁状态吗</h5> |
| ... | @@ -275,25 +284,23 @@ export default { | ... | @@ -275,25 +284,23 @@ export default { |
| 275 | // } | 284 | // } |
| 276 | // }) | 285 | // }) |
| 277 | }) | 286 | }) |
| 278 | .catch(() => { }); | 287 | .catch(() => {}); |
| 279 | }, | 288 | }, |
| 280 | // 上移下移 | 289 | // 上移下移 |
| 281 | moveUpward (index, row) { | 290 | moveUpward(index, row) { |
| 282 | console.log("index", index); | 291 | realMove(row.dictid, "UP", this.tableData.data); |
| 283 | console.log("row", row); | ||
| 284 | realMove(row.bsmDict, "UP", this.tableData); | ||
| 285 | this.key++; | 292 | this.key++; |
| 286 | let id = findParents(this.tableData, row.bsmDict); | 293 | let id = findParents(this.tableData.data, row.dictid); |
| 287 | this.keyList = id; | 294 | this.keyList = id; |
| 288 | }, | 295 | }, |
| 289 | moveDown (index, row) { | 296 | moveDown(index, row) { |
| 290 | realMove(row.bsmDict, "DOWN", this.tableData); | 297 | realMove(row.dictid, "DOWN", this.tableData.data); |
| 291 | this.key++; | 298 | this.key++; |
| 292 | let id = findParents(this.tableData, row.bsmDict); | 299 | let id = findParents(this.tableData.data, row.dictid); |
| 293 | this.keyList = id; | 300 | this.keyList = id; |
| 294 | }, | 301 | }, |
| 295 | // 重置用户密码 | 302 | // 重置用户密码 |
| 296 | resetPassword (data) { | 303 | resetPassword(data) { |
| 297 | const ids = []; | 304 | const ids = []; |
| 298 | if (data instanceof Array) { | 305 | if (data instanceof Array) { |
| 299 | data.forEach((item) => { | 306 | data.forEach((item) => { |
| ... | @@ -302,7 +309,6 @@ export default { | ... | @@ -302,7 +309,6 @@ export default { |
| 302 | } else { | 309 | } else { |
| 303 | ids.push(data); | 310 | ids.push(data); |
| 304 | } | 311 | } |
| 305 | console.log(ids, "ids"); | ||
| 306 | if (ids.length === 0) { | 312 | if (ids.length === 0) { |
| 307 | this.$message({ | 313 | this.$message({ |
| 308 | message: "请选择需要重置密码的用户!", | 314 | message: "请选择需要重置密码的用户!", |
| ... | @@ -336,15 +342,15 @@ export default { | ... | @@ -336,15 +342,15 @@ export default { |
| 336 | // } | 342 | // } |
| 337 | // }) | 343 | // }) |
| 338 | }) | 344 | }) |
| 339 | .catch(() => { }); | 345 | .catch(() => {}); |
| 340 | }, | 346 | }, |
| 341 | // 修改人员信息 | 347 | // 修改人员信息 |
| 342 | handleEdit (row) { | 348 | handleEdit(row) { |
| 343 | this.$refs.dialogForm.edit(row); | 349 | this.$refs.dialogForm.edit(row); |
| 344 | this.$refs.dialogForm.title = "修改"; | 350 | this.$refs.dialogForm.title = "修改"; |
| 345 | }, | 351 | }, |
| 346 | // 删除 | 352 | // 删除 |
| 347 | handleDelete (id, content) { | 353 | handleDelete(id, content) { |
| 348 | this.$confirm("此操将进行删除操作, 是否继续?", "提示", { | 354 | this.$confirm("此操将进行删除操作, 是否继续?", "提示", { |
| 349 | confirmButtonText: "确定", | 355 | confirmButtonText: "确定", |
| 350 | cancelButtonText: "取消", | 356 | cancelButtonText: "取消", |
| ... | @@ -360,7 +366,7 @@ export default { | ... | @@ -360,7 +366,7 @@ export default { |
| 360 | // this.getTableList() | 366 | // this.getTableList() |
| 361 | // }) | 367 | // }) |
| 362 | }) | 368 | }) |
| 363 | .catch(() => { }); | 369 | .catch(() => {}); |
| 364 | }, | 370 | }, |
| 365 | }, | 371 | }, |
| 366 | }; | 372 | }; |
| ... | @@ -368,7 +374,7 @@ export default { | ... | @@ -368,7 +374,7 @@ export default { |
| 368 | <style scoped lang="scss"> | 374 | <style scoped lang="scss"> |
| 369 | @import "~@/styles/mixin.scss"; | 375 | @import "~@/styles/mixin.scss"; |
| 370 | @import "~@/styles/public.scss"; | 376 | @import "~@/styles/public.scss"; |
| 371 | .btnColRight{ | 377 | .btnColRight { |
| 372 | margin-top: 20px; | 378 | margin-top: 20px; |
| 373 | } | 379 | } |
| 374 | </style> | 380 | </style> | ... | ... |
-
Please register or sign in to post a comment