style:字典
Showing
3 changed files
with
74 additions
and
28 deletions
... | @@ -34,7 +34,59 @@ export function getUuid (len, radix) { | ... | @@ -34,7 +34,59 @@ export function getUuid (len, radix) { |
34 | } | 34 | } |
35 | return uuid.join(""); | 35 | return uuid.join(""); |
36 | } | 36 | } |
37 | 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 | } | ||
38 | // 上移下移 | 90 | // 上移下移 |
39 | export function upward (index, data) { | 91 | export function upward (index, data) { |
40 | if (index > 0) { | 92 | if (index > 0) { | ... | ... |
... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
23 | </template> | 23 | </template> |
24 | 24 | ||
25 | <script> | 25 | <script> |
26 | import { getUuid, upward, down, removeTreeListItem } from '@/utils/operation' | 26 | import { getUuid, judgeSort, realMove, findParents, removeTreeListItem } from '@/utils/operation' |
27 | import { editDictNode } from '@/api/dict' | 27 | import { editDictNode } from '@/api/dict' |
28 | export default { | 28 | export default { |
29 | props: { | 29 | props: { |
... | @@ -180,7 +180,7 @@ export default { | ... | @@ -180,7 +180,7 @@ export default { |
180 | }, | 180 | }, |
181 | details: { | 181 | details: { |
182 | handler: function (newValue) { | 182 | handler: function (newValue) { |
183 | this.tableData = this.judgeSort(_.cloneDeep(newValue.dataList)) | 183 | this.tableData = judgeSort(_.cloneDeep(newValue.dataList)) |
184 | if (newValue.isenable == 2) { | 184 | if (newValue.isenable == 2) { |
185 | this.column = this.columns.slice(0, 3) | 185 | this.column = this.columns.slice(0, 3) |
186 | } else { | 186 | } else { |
... | @@ -193,28 +193,21 @@ export default { | ... | @@ -193,28 +193,21 @@ export default { |
193 | } | 193 | } |
194 | }, | 194 | }, |
195 | methods: { | 195 | methods: { |
196 | judgeSort (arr) { | ||
197 | if (arr.length) { | ||
198 | for (let i in arr) { | ||
199 | arr[i]["isTop"] = false; | ||
200 | arr[i]["isBottom"] = false; | ||
201 | arr[i] == arr[0] && (arr[i].isTop = true); | ||
202 | arr[i] == arr[arr.length - 1] && (arr[i].isBottom = true); | ||
203 | arr[i].children && arr[i].children.length && this.judgeSort(arr[i].children) | ||
204 | } | ||
205 | } | ||
206 | return arr | ||
207 | }, | ||
208 | // 添加索引 | 196 | // 添加索引 |
209 | addIndexes () { | 197 | addIndexes (data = this.tableData, isAdd = true) { |
210 | this.tableData.forEach((item, index) => { | 198 | data.forEach((item, index) => { |
211 | if (index == 0) { | 199 | if (index == 0) { |
212 | item.codeShow = true | 200 | item.codeShow = true |
213 | } else { | 201 | } else { |
214 | item.codeShow = false | 202 | item.codeShow = false |
215 | item.nameShow = false | 203 | item.nameShow = false |
216 | } | 204 | } |
205 | if (isAdd) { | ||
217 | item.index = index + 1 | 206 | item.index = index + 1 |
207 | } | ||
208 | if (item.children) { | ||
209 | this.addIndexes(item.children, false) | ||
210 | } | ||
218 | }) | 211 | }) |
219 | }, | 212 | }, |
220 | itemShowFalse () { | 213 | itemShowFalse () { |
... | @@ -259,7 +252,7 @@ export default { | ... | @@ -259,7 +252,7 @@ export default { |
259 | } | 252 | } |
260 | ) | 253 | ) |
261 | this.keyList = []; | 254 | this.keyList = []; |
262 | this.keyList.push(row.dictid) | 255 | this.keyList.push(row.bsmDict) |
263 | }, | 256 | }, |
264 | // 增加 | 257 | // 增加 |
265 | handleAdd () { | 258 | handleAdd () { |
... | @@ -283,12 +276,16 @@ export default { | ... | @@ -283,12 +276,16 @@ export default { |
283 | }, | 276 | }, |
284 | // 上移下移 | 277 | // 上移下移 |
285 | moveUpward (index, row) { | 278 | moveUpward (index, row) { |
286 | upward(index, this.tableData) | 279 | realMove(row.bsmDict, 'UP', this.tableData) |
287 | this.key++ | 280 | this.key++ |
281 | let id = findParents(this.tableData, row.bsmDict) | ||
282 | this.keyList = id | ||
288 | }, | 283 | }, |
289 | moveDown (index, row) { | 284 | moveDown (index, row) { |
290 | down(index, this.tableData) | 285 | realMove(row.bsmDict, 'DOWN', this.tableData) |
291 | this.key++ | 286 | this.key++ |
287 | let id = findParents(this.tableData, row.bsmDict) | ||
288 | this.keyList = id | ||
292 | } | 289 | } |
293 | } | 290 | } |
294 | } | 291 | } | ... | ... |
... | @@ -43,7 +43,7 @@ | ... | @@ -43,7 +43,7 @@ |
43 | </div> | 43 | </div> |
44 | <!-- 表格 --> | 44 | <!-- 表格 --> |
45 | <div class="from-clues-content"> | 45 | <div class="from-clues-content"> |
46 | <lb-table :page-size="pageData.pageSize" heightNum="400" :current-page.sync="pageData.currentPage" | 46 | <lb-table :page-size="pageData.pageSize" :heightNum="400" :current-page.sync="pageData.currentPage" |
47 | :total="tableData.total" @size-change="handleSizeChange" @p-current-change="handleCurrentChange" | 47 | :total="tableData.total" @size-change="handleSizeChange" @p-current-change="handleCurrentChange" |
48 | @selection-change="handleSelectionChange" :column="tableData.columns" :data="tableData.data"> | 48 | @selection-change="handleSelectionChange" :column="tableData.columns" :data="tableData.data"> |
49 | </lb-table> | 49 | </lb-table> |
... | @@ -78,10 +78,9 @@ export default { | ... | @@ -78,10 +78,9 @@ export default { |
78 | columns: datas.columns(), | 78 | columns: datas.columns(), |
79 | data: [], | 79 | data: [], |
80 | }, | 80 | }, |
81 | bdcdyid: '', | ||
82 | bdcdyh: '', | ||
83 | myValue: this.value, | 81 | myValue: this.value, |
84 | saveloding: false | 82 | saveloding: false, |
83 | bdcdysz: [] | ||
85 | }; | 84 | }; |
86 | }, | 85 | }, |
87 | mounted () { | 86 | mounted () { |
... | @@ -114,8 +113,7 @@ export default { | ... | @@ -114,8 +113,7 @@ export default { |
114 | this.saveloding = true | 113 | this.saveloding = true |
115 | startBusinessFlow({ | 114 | startBusinessFlow({ |
116 | bsmSqyw: this.bsmSqyw, | 115 | bsmSqyw: this.bsmSqyw, |
117 | bdcdyid: this.bdcdyid, | 116 | bdcdysz: this.bdcdysz |
118 | bdcdyh: this.bdcdyh | ||
119 | }).then(res => { | 117 | }).then(res => { |
120 | this.saveloding = false | 118 | this.saveloding = false |
121 | this.$emit('input', false) | 119 | this.$emit('input', false) |
... | @@ -128,8 +126,7 @@ export default { | ... | @@ -128,8 +126,7 @@ export default { |
128 | this.$emit("input", false); | 126 | this.$emit("input", false); |
129 | }, | 127 | }, |
130 | handleSelectionChange (val) { | 128 | handleSelectionChange (val) { |
131 | this.bdcdyid = val.map(item => item.dyhbsm ? item.dyhbsm : '').join(',') | 129 | this.bdcdysz = val |
132 | this.bdcdyh = val.map(item => item.bdcdyh ? item.bdcdyh : '').join(',') | ||
133 | } | 130 | } |
134 | }, | 131 | }, |
135 | }; | 132 | }; | ... | ... |
-
Please register or sign in to post a comment