4ee16be7 by 任超

style:字典

1 parent 6fd96f6b
......@@ -34,7 +34,59 @@ export function getUuid (len, radix) {
}
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) {
......
......@@ -23,7 +23,7 @@
</template>
<script>
import { getUuid, upward, down, removeTreeListItem } from '@/utils/operation'
import { getUuid, judgeSort, realMove, findParents, removeTreeListItem } from '@/utils/operation'
import { editDictNode } from '@/api/dict'
export default {
props: {
......@@ -180,7 +180,7 @@ export default {
},
details: {
handler: function (newValue) {
this.tableData = this.judgeSort(_.cloneDeep(newValue.dataList))
this.tableData = judgeSort(_.cloneDeep(newValue.dataList))
if (newValue.isenable == 2) {
this.column = this.columns.slice(0, 3)
} else {
......@@ -193,28 +193,21 @@ export default {
}
},
methods: {
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 && this.judgeSort(arr[i].children)
}
}
return arr
},
// 添加索引
addIndexes () {
this.tableData.forEach((item, index) => {
addIndexes (data = this.tableData, isAdd = true) {
data.forEach((item, index) => {
if (index == 0) {
item.codeShow = true
} else {
item.codeShow = false
item.nameShow = false
}
if (isAdd) {
item.index = index + 1
}
if (item.children) {
this.addIndexes(item.children, false)
}
})
},
itemShowFalse () {
......@@ -259,7 +252,7 @@ export default {
}
)
this.keyList = [];
this.keyList.push(row.dictid)
this.keyList.push(row.bsmDict)
},
// 增加
handleAdd () {
......@@ -283,12 +276,16 @@ export default {
},
// 上移下移
moveUpward (index, row) {
upward(index, this.tableData)
realMove(row.bsmDict, 'UP', this.tableData)
this.key++
let id = findParents(this.tableData, row.bsmDict)
this.keyList = id
},
moveDown (index, row) {
down(index, this.tableData)
realMove(row.bsmDict, 'DOWN', this.tableData)
this.key++
let id = findParents(this.tableData, row.bsmDict)
this.keyList = id
}
}
}
......
......@@ -43,7 +43,7 @@
</div>
<!-- 表格 -->
<div class="from-clues-content">
<lb-table :page-size="pageData.pageSize" heightNum="400" :current-page.sync="pageData.currentPage"
<lb-table :page-size="pageData.pageSize" :heightNum="400" :current-page.sync="pageData.currentPage"
:total="tableData.total" @size-change="handleSizeChange" @p-current-change="handleCurrentChange"
@selection-change="handleSelectionChange" :column="tableData.columns" :data="tableData.data">
</lb-table>
......@@ -78,10 +78,9 @@ export default {
columns: datas.columns(),
data: [],
},
bdcdyid: '',
bdcdyh: '',
myValue: this.value,
saveloding: false
saveloding: false,
bdcdysz: []
};
},
mounted () {
......@@ -114,8 +113,7 @@ export default {
this.saveloding = true
startBusinessFlow({
bsmSqyw: this.bsmSqyw,
bdcdyid: this.bdcdyid,
bdcdyh: this.bdcdyh
bdcdysz: this.bdcdysz
}).then(res => {
this.saveloding = false
this.$emit('input', false)
......@@ -128,8 +126,7 @@ export default {
this.$emit("input", false);
},
handleSelectionChange (val) {
this.bdcdyid = val.map(item => item.dyhbsm ? item.dyhbsm : '').join(',')
this.bdcdyh = val.map(item => item.bdcdyh ? item.bdcdyh : '').join(',')
this.bdcdysz = val
}
},
};
......