2ba22067 by xiaomiao

增加上移下移功能

1 parent b3354f29
import { Message } from "element-ui";
export function removeTreeListItem (treeList, dictId, idName = 'bsmDict') {
if (!treeList || !treeList.length) {
return
}
for (let i = 0; i < treeList.length; i++) {
if (treeList[i][idName] === dictId) {
treeList.splice(i, 1);
break;
}
removeTreeListItem(treeList[i].children, dictId)
}
}
// 创造id
export function getUuid (len, radix) {
var chars = "0123456789abcdefghijklmnopqrstuvwxyz".split(
""
);
var uuid = [],
i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-";
uuid[14] = "4";
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | (Math.random() * 16);
uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join("");
}
export function judgeSort (arr) {
if (arr.length) {
for (let i in arr) {
arr[i]["isTop"] = false;
arr[i]["isBottom"] = false;
arr[i] == arr[0] && (arr[i].isTop = true);
arr[i] == arr[arr.length - 1] && (arr[i].isBottom = true);
arr[i].children && arr[i].children.length && judgeSort(arr[i].children)
}
}
return arr
}
// 上下移动
export function realMove (bsmDict, operate, data) {
function changeSort (arr, bsmDict) {
if (arr.length) {
let flag = false;
for (let i in arr) {
if (arr[i].bsmDict == bsmDict) {
if (operate === "UP") {
arr[i] = arr.splice(i - 1, 1, arr[i])[0];
} else if (operate === "DOWN") {
let temp = arr.splice(i - 0 + 1, 1, arr[i])
arr[i] = temp[0];
}
flag = true;
break;
}
if (!flag && arr[i].children && arr[i].children.length) {
arr[i].children = changeSort(arr[i].children, bsmDict);
}
}
}
return arr;
}
data = judgeSort(changeSort(data, bsmDict));
}
// 获取所有父节点
export function findParents (treeData, bsmDict) {
if (treeData.length == 0) return
for (let i = 0; i < treeData.length; i++) {
if (treeData[i].bsmDict == bsmDict) {
return []
} else {
if (treeData[i].children) {
let res = findParents(treeData[i].children, bsmDict)
if (res !== undefined) {
return res.concat(treeData[i].bsmDict)
}
}
}
}
}
// 上移下移
export function upward (index, data) {
if (index > 0) {
let upData = data[index - 1];
data.splice(index - 1, 1);
data.splice(index, 0, upData);
} else {
Message({
message: '已经是第一条,上移失败'
});
}
}
export function down (index, data) {
if ((index + 1) == data.length) {
Message({
message: '已经是最后一条,下移失败'
});
} else {
let downData = data[index + 1];
data.splice(index + 1, 1);
data.splice(index, 0, downData);
}
}
......@@ -6,21 +6,21 @@ class data extends filter {
columns () {
return [
{
prop: "code",
prop: "DCODE",
label: "工号",
width: 130
},
{
prop: "name",
prop: "DNAME",
label: "姓名",
width: 300
},
{
prop: "loginName",
prop: "PARENTID",
label: "用户名"
},
{
prop: "isDuty",
prop: "TYPEID",
width: 260,
label: "负责人"
},
......
......@@ -16,9 +16,17 @@
</el-form>
</div>
<div class="from-clues-content">
<lb-table :page-size="pageData.size" :current-page.sync="pageData.current" :total="pageData.total"
@size-change="handleSizeChange" @p-current-change="handleCurrentChange" :column="tableData.columns"
:data="tableData.data">
<lb-table
:page-size="pageData.size"
:current-page.sync="pageData.current"
:total="pageData.total"
@size-change="handleSizeChange"
@p-current-change="handleCurrentChange"
:column="tableData.columns"
:data="tableData.data"
:key="key"
:expand-row-keys="keyList" row-key="dictid"
>
</lb-table>
</div>
<edit-dialog ref="dialogForm" />
......@@ -43,9 +51,10 @@ export default {
components: {
EditDialog,
},
data () {
data() {
return {
taskData: null,
keyList: [],
form: {
job_name: "",
currentPage: 1,
......@@ -57,7 +66,6 @@ export default {
departmentId: "", // 部门ID
departmentList: [], // 部门列表
levelList: [], // 职务级别
tableData: [],
sexList: [],
typeOptions: [
{
......@@ -180,75 +188,76 @@ export default {
};
},
methods: {
handleAdd () {
// 添加索引
// addIndexes (data = this.tableData.data, isAdd = true) {
// data.forEach((item, index) => {
// if (index == 0) {
// item.codeShow = true;
// item.nameShow = false;
// item.normcodeShow = false;
// item.normnameShow = false;
// } else {
// item.codeShow = false;
// item.nameShow = false;
// item.normcodeShow = false;
// item.normnameShow = false;
// }
// if (isAdd) {
// item.index = index + 1;
// }
// if (item.children) {
// this.addIndexes(item.children, false);
// }
// });
// },
handleAdd() {
this.taskData = null;
this.$refs.dialogForm.add();
this.$refs.dialogForm.title = "添加";
},
featchData () {
featchData() {
this.tableData.data = [
{
id: "6a269fa4-49ee-40ed-be72-302ebdf7b9d6",
name: "组件开发模板测试用户",
sort: 67,
loginName: "wgs-template-test",
email: null,
lastLoginTime: null,
mobilePhone: null,
isLocked: false,
status: "ACTIVE",
passwordChangeTime: "2022-06-29T01:59:18.123+0000",
idCard: null,
departmentId: "dcce05ff-7747-4c19-b31f-c018ec8d8f0c",
departmentName: "科室一",
organizationId: "e9e830f0-38f4-4fb2-90ad-496c4e1314aa",
sex: "0",
isDuty: null,
code: "adfasfd",
jobLevel: null,
telephone: null,
address: null,
_X_ROW_KEY: "row_42",
switch: true,
"dictid": "51b9f487861671f77782c5a23b5fe52e",
"children": null,
"TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF",
"PARENTID": "ouyds",
"DCODE": "1223",
"DNAME": "小红",
"SORT": null,
"index": 1,
"isTop": true,
"isBottom": false
},
{
id: "acebbaf3-81d0-4b0f-a426-feafa7ea1bed",
name: "饿肚肚",
sort: 36,
loginName: "吃饭",
email: null,
lastLoginTime: null,
mobilePhone: null,
isLocked: false,
status: "ACTIVE",
passwordChangeTime: "2021-08-24T02:04:39.132+0000",
idCard: "43423441242134 ",
departmentId: "dcce05ff-7747-4c19-b31f-c018ec8d8f0c",
departmentName: "科室一",
organizationId: "e9e830f0-38f4-4fb2-90ad-496c4e1314aa",
sex: null,
isDuty: null,
code: "2323",
jobLevel: null,
telephone: null,
address: null,
_X_ROW_KEY: "row_43",
switch: true,
"dictid": "2291d9e298274c1ea1f40df63fbcff47",
"children": null,
"TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF",
"PARENTID": "wer",
"DCODE": "124334",
"DNAME": "小李",
"SORT": null,
"index": 2,
"isTop": false,
"isBottom": false
},
];
{
"dictid": "e6a5aeb8957b8029fa31586fb30dd5b8",
"children": null,
"TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF",
"PARENTID": "underf",
"DCODE": "2344",
"DNAME": "小田",
"SORT": null,
"index": 13,
"isTop": false,
"isBottom": true
}
];
},
// 重置搜索
// resetSearch() {
// this.selectType = "0";
// this.queryName = "";
// this.queryParam = {
// organizationId: this.organizationId,
// departmentId: this.departmentId
// }
// },
// 更新用户解锁状态
updateLock (id, name) {
updateLock(id, name) {
this.$confirm(
`<div class="customer-message-wrapper">
<h5 class="title">确定要更新用户解锁状态吗</h5>
......@@ -275,25 +284,23 @@ export default {
// }
// })
})
.catch(() => { });
.catch(() => {});
},
// 上移下移
moveUpward (index, row) {
console.log("index", index);
console.log("row", row);
realMove(row.bsmDict, "UP", this.tableData);
moveUpward(index, row) {
realMove(row.dictid, "UP", this.tableData.data);
this.key++;
let id = findParents(this.tableData, row.bsmDict);
let id = findParents(this.tableData.data, row.dictid);
this.keyList = id;
},
moveDown (index, row) {
realMove(row.bsmDict, "DOWN", this.tableData);
moveDown(index, row) {
realMove(row.dictid, "DOWN", this.tableData.data);
this.key++;
let id = findParents(this.tableData, row.bsmDict);
let id = findParents(this.tableData.data, row.dictid);
this.keyList = id;
},
// 重置用户密码
resetPassword (data) {
resetPassword(data) {
const ids = [];
if (data instanceof Array) {
data.forEach((item) => {
......@@ -302,7 +309,6 @@ export default {
} else {
ids.push(data);
}
console.log(ids, "ids");
if (ids.length === 0) {
this.$message({
message: "请选择需要重置密码的用户!",
......@@ -336,15 +342,15 @@ export default {
// }
// })
})
.catch(() => { });
.catch(() => {});
},
// 修改人员信息
handleEdit (row) {
handleEdit(row) {
this.$refs.dialogForm.edit(row);
this.$refs.dialogForm.title = "修改";
},
// 删除
handleDelete (id, content) {
handleDelete(id, content) {
this.$confirm("此操将进行删除操作, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
......@@ -360,7 +366,7 @@ export default {
// this.getTableList()
// })
})
.catch(() => { });
.catch(() => {});
},
},
};
......@@ -368,7 +374,7 @@ export default {
<style scoped lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/public.scss";
.btnColRight{
.btnColRight {
margin-top: 20px;
}
}
</style>
......