Commit c27deebc6a01ffe6d44fa44df94daba26c21086a
1 parent
744e168b
部件工时统计新增bom展开
Showing
4 changed files
with
658 additions
and
12 deletions
src/api/api.js
... | ... | @@ -175,6 +175,7 @@ export const getApiNameList = (params)=>getAction("/api_log/apiLog/getApiNameLis |
175 | 175 | export const queryProcess = (params)=>getAction('/plm/partlib/list', params); |
176 | 176 | export const queryPBom2 = (params)=>getAction('/plm/partlib/bomTree', params); |
177 | 177 | export const queryPBomByWms = (params)=>getAction('/pbom/pbom/treeList', params); |
178 | +export const partList = (params)=>getAction('/working/working/partList', params); | |
178 | 179 | export const queryOrderPBomByWms = (params)=>getAction('/pbom/pbom/orderTreeList', params); |
179 | 180 | export const queryCnoList = (params)=>getAction('/pbom/pbom/queryCnoList', params); |
180 | 181 | export const getWorkOrderList = (params)=>getAction('/workorder/workorder/getWorkOrderList', params); |
... | ... |
src/views/system/CostCalculate.vue
... | ... | @@ -55,6 +55,10 @@ |
55 | 55 | <a>成本核算</a> |
56 | 56 | </a-popconfirm> |
57 | 57 | </span> |
58 | + | |
59 | + <span slot="getNoPrece" slot-scope="text, record"> | |
60 | + <a @click="getNoPrece(record)">{{record.excel_flag}}</a> | |
61 | + </span> | |
58 | 62 | </a-table> |
59 | 63 | |
60 | 64 | |
... | ... | @@ -123,6 +127,15 @@ |
123 | 127 | <pbom-form ref="pbomForm"></pbom-form> |
124 | 128 | <materia-item-list ref="materiaFrom"></materia-item-list> |
125 | 129 | <PreparationList ref="modalForm2"></PreparationList> |
130 | + | |
131 | + <j-popup | |
132 | + v-show="showRentPrise" | |
133 | + ref="no_price" | |
134 | + code="getNoPrece" | |
135 | + :param="materialParam" | |
136 | + org-fields="username" | |
137 | + dest-fields="popup" | |
138 | + field="popup"/> | |
126 | 139 | </a-card> |
127 | 140 | </template> |
128 | 141 | |
... | ... | @@ -145,6 +158,7 @@ export default { |
145 | 158 | return { |
146 | 159 | selectIndex: null, |
147 | 160 | queryParam: {}, |
161 | + materialParam:{workno:''}, | |
148 | 162 | description: '项目C表信息', |
149 | 163 | // 表头 |
150 | 164 | url: { |
... | ... | @@ -220,7 +234,15 @@ export default { |
220 | 234 | title: '是否上传', |
221 | 235 | align: 'center', |
222 | 236 | dataIndex: 'excel_flag', |
223 | - key: 'excel_flag' | |
237 | + key: 'excel_flag', | |
238 | + scopedSlots:{ | |
239 | + customRender:'getNoPrece' | |
240 | + } | |
241 | + }, { | |
242 | + title: '核算次数', | |
243 | + align: 'center', | |
244 | + dataIndex: 'account', | |
245 | + key: 'account' | |
224 | 246 | }, |
225 | 247 | { |
226 | 248 | title: '操作', |
... | ... | @@ -287,14 +309,11 @@ export default { |
287 | 309 | } |
288 | 310 | }, |
289 | 311 | { |
290 | - title: '库存', | |
291 | - dataIndex: 'qty', | |
312 | + title: '成本(元)', | |
313 | + dataIndex: 'price', | |
292 | 314 | align: 'center', |
293 | - key: 'qty', | |
294 | - width: 70, | |
295 | - scopedSlots: { | |
296 | - customRender: 'checkQty' | |
297 | - }, | |
315 | + key: 'price', | |
316 | + width: 70 | |
298 | 317 | } |
299 | 318 | // , { |
300 | 319 | // title: '物料状态', |
... | ... | @@ -325,7 +344,16 @@ export default { |
325 | 344 | }, |
326 | 345 | }, |
327 | 346 | methods: { |
347 | + getNoPrece(data){ | |
348 | + this.materialParam['workno'] ="''"+data.field0056+"''"; | |
349 | + this.$refs.no_price.openModal(); | |
350 | + }, | |
328 | 351 | costCalcuate(record){ |
352 | + if (record.excel_flag==undefined){ | |
353 | + this.$message.warn("请先上传excel,再核算成本"); | |
354 | + return false; | |
355 | + } | |
356 | + this.$message.info("开始后台计算成本,计算完成会发送系统通知!!") | |
329 | 357 | let params = { |
330 | 358 | 'workno': record.field0056, |
331 | 359 | 'uuids': record.field0057 + ',' + record.field0054 + ',' + record.field0055 |
... | ... |
src/views/working/PartWorking.vue
1 | -<script src="../../permission.js"></script> | |
1 | +<script> | |
2 | +import PartBomList from "./modules/PartBomList"; | |
3 | +export default { | |
4 | + components: {PartBomList} | |
5 | +} | |
6 | +</script> | |
2 | 7 | <template> |
3 | 8 | <a-card :bordered="false"> |
4 | 9 | <!-- 查询区域 --> |
... | ... | @@ -58,6 +63,10 @@ |
58 | 63 | <span slot="processWorking" slot-scope="text, record"> |
59 | 64 | <a @click="processWorking(record)">{{record.time}}</a> |
60 | 65 | </span> |
66 | + | |
67 | + <span slot="partBom" slot-scope="text, record"> | |
68 | + <a @click="partBom(record)">{{record.partNo}}</a> | |
69 | + </span> | |
61 | 70 | </a-table> |
62 | 71 | |
63 | 72 | </div> |
... | ... | @@ -96,6 +105,8 @@ |
96 | 105 | dest-fields="popup" |
97 | 106 | field="popup"/> |
98 | 107 | <materia-item-list ref="materiaFrom"></materia-item-list> |
108 | + <part-bom-list ref="partBom"></part-bom-list> | |
109 | + | |
99 | 110 | </a-card> |
100 | 111 | </template> |
101 | 112 | |
... | ... | @@ -103,15 +114,15 @@ |
103 | 114 | import { getPartWorkList,getProjectSum} from '@api/api' |
104 | 115 | import {JeecgListMixin} from '@/mixins/JeecgListMixin' |
105 | 116 | import { downFile } from '@/api/manage' |
106 | -import {ajaxGetDictItems} from "../../api/api"; | |
107 | 117 | import MateriaItemList from "../system/modules/MateriaItemList"; |
118 | +import PartBomList from "./modules/PartBomList"; | |
108 | 119 | |
109 | 120 | |
110 | 121 | |
111 | 122 | export default { |
112 | 123 | name: 'PartWorking', |
113 | 124 | mixins: [JeecgListMixin], |
114 | - components: {MateriaItemList}, | |
125 | + components: {MateriaItemList,PartBomList}, | |
115 | 126 | data() { |
116 | 127 | return { |
117 | 128 | materialParam:{code:''}, |
... | ... | @@ -154,7 +165,10 @@ export default { |
154 | 165 | title: '部件号', |
155 | 166 | align: 'center', |
156 | 167 | dataIndex: 'partNo', |
157 | - ellipsis: true | |
168 | + ellipsis: true, | |
169 | + scopedSlots:{ | |
170 | + customRender:'partBom' | |
171 | + } | |
158 | 172 | }, |
159 | 173 | { |
160 | 174 | title: '进度', |
... | ... | @@ -221,6 +235,9 @@ export default { |
221 | 235 | this.loadFrom(); |
222 | 236 | }, |
223 | 237 | methods: { |
238 | + partBom(data){ | |
239 | + this.$refs.partBom.edit(data); | |
240 | + }, | |
224 | 241 | findCarNumberClick(row){ |
225 | 242 | this.field0056=row.field0056; |
226 | 243 | this.field0054=row.field0054; |
... | ... |
src/views/working/modules/PartBomList.vue
0 → 100644
1 | +<template> | |
2 | + <a-modal | |
3 | + title="部件BOM" | |
4 | + :width="1600" | |
5 | + :visible="visible" | |
6 | + :confirmLoading="confirmLoading" | |
7 | + @ok="handleOk" | |
8 | + @cancel="handleCancel" | |
9 | + cancelText="关闭" | |
10 | + wrapClassName="ant-modal-cust-warp" | |
11 | + style="top:5%;height: 85%;overflow-y: hidden"> | |
12 | + <a-card :bordered="false"> | |
13 | + | |
14 | + <!-- 查询区域 --> | |
15 | + | |
16 | + <p3>项目名称:{{projectName}}</p3> | |
17 | + <a-table | |
18 | + :scroll="{x: scrollXWidth, y: 720}" | |
19 | + ref="table" | |
20 | + size="middle" | |
21 | + rowKey="id" | |
22 | + :columns="planColumns" | |
23 | + :dataSource="bomSource" | |
24 | + :pagination="false" | |
25 | + :loading="loading2" | |
26 | + :expandedRowKeys="expandedRowKeys" | |
27 | + :rowSelection="{selectedRowKeys: selectedRowKeys,onChange: selectChanges}" | |
28 | + @change="handleTableChange" | |
29 | + @expand="handleExpand" | |
30 | + v-bind="tableProps" > | |
31 | + | |
32 | + | |
33 | + </a-table> | |
34 | + <!-- table区域-end --> | |
35 | + <pbom-form ref="pbomForm"></pbom-form> | |
36 | + <materia-item-list ref="materiaFrom"></materia-item-list> | |
37 | + </a-card> | |
38 | + </a-modal> | |
39 | +</template> | |
40 | + | |
41 | +<script> | |
42 | +import { JeecgListMixin } from '../../../mixins/JeecgListMixin' | |
43 | +import moment from 'moment' | |
44 | +import {ajaxGetDictItems, partList} from "../../../api/api"; | |
45 | +import { getAction } from '@/api/manage' | |
46 | +import '@/assets/less/TableExpand.less' | |
47 | + | |
48 | +export default { | |
49 | + name: 'PartBomList', | |
50 | + components: {}, | |
51 | + mixins: [JeecgListMixin], | |
52 | + data() { | |
53 | + return { | |
54 | + visible: false, | |
55 | + confirmLoading: false, | |
56 | + selectIndex: null, | |
57 | + queryParam: {}, | |
58 | + description: '项目C表信息', | |
59 | + loading2:false, | |
60 | + scrollXWidth: 1800, | |
61 | + headerId:'', | |
62 | + // 表头 | |
63 | + url: { | |
64 | + list:'1', | |
65 | + childList: "/working/working/childList", | |
66 | + }, | |
67 | + // 展开的行,受控属性 | |
68 | + expandedRowKeys: [], | |
69 | + dataSource: [], | |
70 | + bomSource: [], | |
71 | + pnoArray:[], | |
72 | + scolor:'', | |
73 | + pno:'', | |
74 | + pbom_status:'', | |
75 | + projectName:'', | |
76 | + /* 分页参数 */ | |
77 | + ipagination:{ | |
78 | + current: 1, | |
79 | + pageSize: 5, | |
80 | + pageSizeOptions: ['5', '10', '50'], | |
81 | + showTotal: (total, range) => { | |
82 | + return range[0] + "-" + range[1] + " 共" + total + "条" | |
83 | + }, | |
84 | + showQuickJumper: true, | |
85 | + showSizeChanger: true, | |
86 | + total: 0 | |
87 | + }, | |
88 | + hasChildrenField:"hasChild", | |
89 | + pidField:"pno", | |
90 | + workNo:'', | |
91 | + field0057:'', | |
92 | + projectNo:'', | |
93 | + pno_arr:'', | |
94 | + uuid:'', | |
95 | + dictOptions:{ | |
96 | + }, | |
97 | + subExpandedKeys:[], | |
98 | + planColumns: [ | |
99 | + { | |
100 | + title: '部件名称', | |
101 | + dataIndex: 'partName', | |
102 | + width: 100, | |
103 | + key: 'partName' | |
104 | + }, | |
105 | + { | |
106 | + title: '部件编码', | |
107 | + dataIndex: 'cno', | |
108 | + width: 130, | |
109 | + key: 'cno' | |
110 | + }, | |
111 | + { | |
112 | + title: '报工人数', | |
113 | + dataIndex: 'nums', | |
114 | + align: 'center', | |
115 | + width: 100, | |
116 | + key: 'nums' | |
117 | + }, { | |
118 | + title: '合格数量', | |
119 | + dataIndex: 'qty', | |
120 | + key: 'qty', | |
121 | + align: 'center', | |
122 | + width: 80 | |
123 | + }, | |
124 | + { | |
125 | + title: '总工时(小时)', | |
126 | + align: 'center', | |
127 | + dataIndex: 'hours', | |
128 | + scopedSlots:{ | |
129 | + customRender:'departWorking' | |
130 | + } | |
131 | + }, | |
132 | + { | |
133 | + title: '总工时(分钟)', | |
134 | + align: 'center', | |
135 | + dataIndex: 'time', | |
136 | + scopedSlots:{ | |
137 | + customRender:'processWorking' | |
138 | + } | |
139 | + }, | |
140 | + { | |
141 | + title: '重量(kg)', | |
142 | + align: 'center', | |
143 | + dataIndex: 'weight', | |
144 | + key: 'weight' | |
145 | + } | |
146 | + ], | |
147 | + } | |
148 | + }, | |
149 | + created() { | |
150 | + this.getOutSourceStatus() | |
151 | + this.getdata() | |
152 | + }, | |
153 | + computed:{ | |
154 | + tableProps() { | |
155 | + let _this = this | |
156 | + return { | |
157 | + // 列表项是否可选择 | |
158 | + rowSelection: { | |
159 | + selectedRowKeys: _this.selectedRowKeys, | |
160 | + onChange: (selectedRowKeys) => _this.selectedRowKeys = selectedRowKeys | |
161 | + } | |
162 | + } | |
163 | + }, | |
164 | + }, | |
165 | + methods: { | |
166 | + edit (record) { | |
167 | + this.projectName=record.projectName | |
168 | + this.visible = true; | |
169 | + this.onSelectChangeByBoom(record) | |
170 | + }, | |
171 | + handleCancel () { | |
172 | + this.visible = false; | |
173 | + }, | |
174 | + handleOk () { | |
175 | + this.visible = false; | |
176 | + }, | |
177 | + getdata(){ | |
178 | + let currColumns = this.planColumns | |
179 | + // res.result.columns表示接口获取的columns值,具体根据接口返回值修改 | |
180 | + for(let a=0;a<currColumns.length;a++){ | |
181 | + // 设置除最后一列的宽度,需要空一列自适应 | |
182 | + if(a < currColumns.length-1) { | |
183 | + currColumns[a].width = 150; | |
184 | + } | |
185 | + } | |
186 | + console.log("-------------------",currColumns) | |
187 | + // 横向滚动长度大于所有宽度,才能实现固定表头 | |
188 | + this.scrollXWidth = (currColumns.length) * 150 + 180; | |
189 | + this.planColumns = [...currColumns] | |
190 | + }, | |
191 | + searchQuery() { | |
192 | + this.loadData(1); | |
193 | + this.bomSource=[]; | |
194 | + }, | |
195 | + | |
196 | + rowClassName(record, index) { | |
197 | + return index === this.selectIndex ? 'Rowactive' : '' | |
198 | + }, | |
199 | + | |
200 | + | |
201 | + | |
202 | + onSelectChangeByBoom(data) { | |
203 | + this.headerId=data.headerId | |
204 | + this.loading2 = true | |
205 | + let params = { | |
206 | + 'headerId':data.headerId, | |
207 | + 'id':data.id, | |
208 | + 'projectName': data.projectName, | |
209 | + 'partName': data.partName, | |
210 | + 'nums': data.nums, | |
211 | + 'time': data.time, | |
212 | + 'qty': data.qty, | |
213 | + 'status1': data.status1, | |
214 | + 'status2': data.status2, | |
215 | + 'status3': data.status3, | |
216 | + 'hours': data.hours, | |
217 | + 'partNo': data.partNo, | |
218 | + 'progress': data.progress, | |
219 | + } | |
220 | + partList(params).then((res) => { | |
221 | + if (res.code==0) { | |
222 | + this.loading2 = false | |
223 | + this.bomSource=this.getDataByResult(res.result.records); | |
224 | + }else{ | |
225 | + this.loading2 = false | |
226 | + this.bomSource=[]; | |
227 | + this.$message.error(res.message) | |
228 | + } | |
229 | + }) | |
230 | + }, | |
231 | + | |
232 | + timeFormat(val) { | |
233 | + return moment(val).format('YYYY-MM-DD') | |
234 | + }, | |
235 | + handleExpandedRowsChange(expandedRows) { | |
236 | + this.expandedRowKeys = expandedRows | |
237 | + }, | |
238 | + handleBomChange(value) { | |
239 | + this.initBomTree(value) | |
240 | + }, | |
241 | + onSelectAll(selected) { | |
242 | + if (selected) { | |
243 | + const tabData = this.bomSource; | |
244 | + const arr = []; | |
245 | + setVal(tabData, arr); | |
246 | + this.selectedRowKeys = arr; | |
247 | + } else { | |
248 | + this.selectedRowKeys = []; | |
249 | + } | |
250 | + function setVal(list, arr) { | |
251 | + list.forEach(v => { | |
252 | + arr.push(v.key); | |
253 | + if (v.children) { | |
254 | + setVal(v.children, arr); | |
255 | + } | |
256 | + }); | |
257 | + } | |
258 | + }, | |
259 | + numFormat(qty){ | |
260 | + if(qty==undefined){ | |
261 | + return ''; | |
262 | + }else{ | |
263 | + return parseFloat(qty).toFixed(1); | |
264 | + } | |
265 | + }, | |
266 | + onSelect(record, selected) { | |
267 | + const set = new Set(this.selectedRowKeys); | |
268 | + const tabData = this.bomSource; | |
269 | + const key = record.key; | |
270 | + if (selected) { | |
271 | + set.add(key); | |
272 | + record.children && setChildCheck(record.children); | |
273 | + // setParentCheck(key); | |
274 | + } else { | |
275 | + set.delete(key); | |
276 | + record.children && setChildUncheck(record.children); | |
277 | + setParentUncheck(key); | |
278 | + } | |
279 | + | |
280 | + this.selectedRowKeys = Array.from(set); | |
281 | + // 设置父级选择 | |
282 | + function setParentCheck(key) { | |
283 | + let parent = getParent(key); | |
284 | + if (parent) { | |
285 | + set.add(parent.key); | |
286 | + setParentCheck(parent.key); | |
287 | + } | |
288 | + } | |
289 | + // 设置父级取消,如果父级的子集有选择,则不取消 | |
290 | + function setParentUncheck(key) { | |
291 | + let childHasCheck = false, | |
292 | + parent = getParent(key); | |
293 | + if (parent) { | |
294 | + let childlist = parent.children; | |
295 | + childlist.forEach(function(v) { | |
296 | + if (set.has(v.key)) { | |
297 | + childHasCheck = true; | |
298 | + } | |
299 | + }); | |
300 | + if (!childHasCheck) { | |
301 | + set.delete(parent.key); | |
302 | + setParentUncheck(parent.key); | |
303 | + } | |
304 | + } | |
305 | + } | |
306 | + // 获取当前对象的父级 | |
307 | + function getParent(key) { | |
308 | + for (let i = 0; i < tabData.length; i++) { | |
309 | + if (tabData[i].key === key) { | |
310 | + return null; | |
311 | + } | |
312 | + } | |
313 | + return _getParent(tabData); | |
314 | + function _getParent(list) { | |
315 | + let childlist, | |
316 | + isExist = false; | |
317 | + for (let i = 0; i < list.length; i++) { | |
318 | + if ((childlist = list[i].children)) { | |
319 | + childlist.forEach(function(v) { | |
320 | + if (v.key === key) { | |
321 | + isExist = true; | |
322 | + } | |
323 | + }); | |
324 | + if (isExist) { | |
325 | + return list[i]; | |
326 | + } | |
327 | + if (_getParent(childlist)) { | |
328 | + return _getParent(childlist); | |
329 | + } | |
330 | + } | |
331 | + } | |
332 | + } | |
333 | + } | |
334 | + // 设置child全选 | |
335 | + function setChildCheck(list) { | |
336 | + list.forEach(function(v) { | |
337 | + set.add(v.key); | |
338 | + v.children && setChildCheck(v.children); | |
339 | + }); | |
340 | + } | |
341 | + // 设置child取消 | |
342 | + function setChildUncheck(list) { | |
343 | + list.forEach(function(v) { | |
344 | + set.delete(v.key); | |
345 | + v.children && setChildUncheck(v.children); | |
346 | + }); | |
347 | + } | |
348 | + }, | |
349 | + | |
350 | + confirmHandle(record) { | |
351 | + var llqty=record.llqty; | |
352 | + if (llqty==undefined){ | |
353 | + llqty='0'; | |
354 | + } | |
355 | + var qty=record.qty; | |
356 | + if (qty==undefined){ | |
357 | + qty='0'; | |
358 | + } | |
359 | + var bnum=record.bnum; | |
360 | + if (bnum==undefined){ | |
361 | + bnum='0'; | |
362 | + } | |
363 | + var xnqty=parseInt(bnum)-parseInt(llqty) | |
364 | + var status=''; | |
365 | + if (parseInt(llqty) >= parseInt(bnum)) { | |
366 | + status= '2'; | |
367 | + } else { | |
368 | + if (parseInt(xnqty) <= parseInt(qty)) { | |
369 | + status= '1'; | |
370 | + } else { | |
371 | + status= '0'; | |
372 | + } | |
373 | + } | |
374 | + if(record.qty==undefined){ | |
375 | + status=''; | |
376 | + } | |
377 | + var actions = [] | |
378 | + Object.keys(this.outsourcingInStatusList).some((key) => { | |
379 | + if (this.outsourcingInStatusList[key].value == ('' + status)) { | |
380 | + actions.push(this.outsourcingInStatusList[key].text) | |
381 | + return true | |
382 | + } | |
383 | + }) | |
384 | + return actions.join('') | |
385 | + }, | |
386 | + | |
387 | + solutionColor(record) { | |
388 | + var llqty=record.llqty; | |
389 | + if (llqty==undefined){ | |
390 | + llqty='0'; | |
391 | + } | |
392 | + var qty=record.qty; | |
393 | + if (qty==undefined){ | |
394 | + qty='0'; | |
395 | + } | |
396 | + var bnum=record.bnum; | |
397 | + if (bnum==undefined){ | |
398 | + bnum='0'; | |
399 | + } | |
400 | + var xnqty=parseInt(bnum)-parseInt(llqty) | |
401 | + var status=''; | |
402 | + if (parseInt(llqty) >= parseInt(bnum)) { | |
403 | + status= '2'; | |
404 | + } else { | |
405 | + if (parseInt(xnqty) <= parseInt(qty)) { | |
406 | + status= '1'; | |
407 | + } else { | |
408 | + status= '0'; | |
409 | + } | |
410 | + } | |
411 | + var actions = '' | |
412 | + Object.keys(this.outsourcingInStatusList).some((key) => { | |
413 | + if (this.outsourcingInStatusList[key].value == ('' + status)) { | |
414 | + actions = this.outsourcingInStatusList[key].color | |
415 | + } | |
416 | + }) | |
417 | + return actions | |
418 | + }, | |
419 | + | |
420 | + getOutSourceStatus() { | |
421 | + ajaxGetDictItems('bom_inv_status').then((res) => { | |
422 | + if (res.success) { | |
423 | + this.outsourcingInStatusList = res.result | |
424 | + } | |
425 | + }) | |
426 | + }, | |
427 | + | |
428 | + | |
429 | + getDataByResult(result){ | |
430 | + return result.map(item=>{ | |
431 | + //判断是否标记了带有子节点 | |
432 | + if(item[this.hasChildrenField]=='1'){ | |
433 | + let loadChild = { cno: item.cno+'_loadChild', name: 'loading...', isLoading: true } | |
434 | + item.children = [loadChild] | |
435 | + } | |
436 | + return item | |
437 | + }) | |
438 | + }, | |
439 | + | |
440 | + handleExpand(expanded, record){ | |
441 | + // 判断是否是展开状态id | |
442 | + if (expanded) { | |
443 | + this.expandedRowKeys.push(record.id) | |
444 | + debugger | |
445 | + if (record.children.length>0 && record.children[0].isLoading === true) { | |
446 | + // let params = this.getQueryParams();//查询条件 | |
447 | + let params = { | |
448 | + "headerId":this.headerId, | |
449 | + "partNo":record.partNo, | |
450 | + "cno":record.cno, | |
451 | + "pno":record.cno | |
452 | + };//查询条件 | |
453 | + // params[this.pidField] = record.cno | |
454 | + // params['headerId'] = record.headerId | |
455 | + // params['partNo'] = record.partNo | |
456 | + // params['cno'] = record.cno | |
457 | + // params['cno'] = record.cno | |
458 | + getAction(this.url.childList,params).then((res)=>{ | |
459 | + if(res.success){ | |
460 | + if(res.result && res.result.length>0){ | |
461 | + record.children = this.getDataByResult(res.result) | |
462 | + this.bomSource = [...this.bomSource] | |
463 | + }else{ | |
464 | + record.children='' | |
465 | + record.hasChildrenField='0' | |
466 | + } | |
467 | + }else{ | |
468 | + this.$message.warning(res.message) | |
469 | + } | |
470 | + }) | |
471 | + | |
472 | + } | |
473 | + | |
474 | + }else{ | |
475 | + let keyIndex = this.expandedRowKeys.indexOf(record.id) | |
476 | + if(keyIndex>=0){ | |
477 | + this.expandedRowKeys.splice(keyIndex, 1); | |
478 | + } | |
479 | + } | |
480 | + }, | |
481 | + | |
482 | + // 添加子分类时获取所有父级id | |
483 | + getExpandKeysByPid(pid,arr,all){ | |
484 | + if(pid && arr && arr.length>0){ | |
485 | + for(let i=0;i<arr.length;i++){ | |
486 | + if(arr[i].cno==pid){ | |
487 | + this.subExpandedKeys.push(arr[i].cno) | |
488 | + this.getExpandKeysByPid(arr[i]['pid'],all,all) | |
489 | + }else{ | |
490 | + this.getExpandKeysByPid(pid,arr[i].children,all) | |
491 | + } | |
492 | + } | |
493 | + } | |
494 | + }, | |
495 | + getFormDataById(cno,arr){ | |
496 | + if(arr && arr.length>0){ | |
497 | + for(let i=0;i<arr.length;i++){ | |
498 | + if(arr[i].cno==cno){ | |
499 | + this.parentFormData = arr[i] | |
500 | + }else{ | |
501 | + this.getFormDataById(cno,arr[i].children) | |
502 | + } | |
503 | + } | |
504 | + } | |
505 | + }, | |
506 | + expandTreeNode(nodeId){ | |
507 | + return new Promise((resolve,reject)=>{ | |
508 | + this.getFormDataById(nodeId,this.bomSource) | |
509 | + let row = this.parentFormData | |
510 | + this.expandedRowKeys.push(nodeId) | |
511 | + let params = this.getQueryParams();//查询条件 | |
512 | + params[this.pidField] = nodeId | |
513 | + getAction(this.url.childList,params).then((res)=>{ | |
514 | + if(res.success){ | |
515 | + if(res.result && res.result.length>0){ | |
516 | + row.children = this.getDataByResult(res.result) | |
517 | + this.bomSource = [...this.bomSource] | |
518 | + resolve() | |
519 | + }else{ | |
520 | + row.children='' | |
521 | + row.hasChildrenField='0' | |
522 | + reject() | |
523 | + } | |
524 | + }else{ | |
525 | + reject() | |
526 | + } | |
527 | + }) | |
528 | + }) | |
529 | + }, | |
530 | + | |
531 | + // 根据已展开的行查询数据(用于保存后刷新时异步加载子级的数据) | |
532 | + loadDataByExpandedRows(dataList) { | |
533 | + if (this.expandedRowKeys.length > 0) { | |
534 | + return getAction(this.url.getChildListBatch,{ parentIds: this.expandedRowKeys.join(',') }).then(res=>{ | |
535 | + if (res.success && res.result.records.length>0) { | |
536 | + //已展开的数据批量子节点 | |
537 | + let records = res.result.records | |
538 | + const listMap = new Map(); | |
539 | + for (let item of records) { | |
540 | + let pid = item[this.pidField]; | |
541 | + if (this.expandedRowKeys.join(',').includes(pid)) { | |
542 | + let mapList = listMap.get(pid); | |
543 | + if (mapList == null) { | |
544 | + mapList = []; | |
545 | + } | |
546 | + mapList.push(item); | |
547 | + listMap.set(pid, mapList); | |
548 | + } | |
549 | + } | |
550 | + let childrenMap = listMap; | |
551 | + let fn = (list) => { | |
552 | + if(list) { | |
553 | + list.forEach(data => { | |
554 | + if (this.expandedRowKeys.includes(data.cno)) { | |
555 | + data.children = this.getDataByResult(childrenMap.get(data.cno)) | |
556 | + fn(data.children) | |
557 | + } | |
558 | + }) | |
559 | + } | |
560 | + } | |
561 | + fn(dataList) | |
562 | + } | |
563 | + }) | |
564 | + } else { | |
565 | + return Promise.resolve() | |
566 | + } | |
567 | + }, | |
568 | + | |
569 | + selectChanges(selectedRowKeys, selectionRows) { | |
570 | + this.selectedRowKeys = selectedRowKeys; | |
571 | + this.selectionRows = selectionRows; | |
572 | + var array=''; | |
573 | + var uid=''; | |
574 | + this.selectionRows.forEach(function (row) { | |
575 | + array += row.cno + ","; | |
576 | + }); | |
577 | + this.pno_arr=array | |
578 | + }, | |
579 | + | |
580 | + | |
581 | + /** 点击a-table中的行后,展开或关闭其子行 */ | |
582 | + tableClick(record, index){ | |
583 | + return { | |
584 | + style:{ | |
585 | + cursor:'pointer', | |
586 | + }, | |
587 | + on: { | |
588 | + click: () => { | |
589 | + this.expandRowByClick = !this.expandRowByClick; | |
590 | + } | |
591 | + } | |
592 | + } | |
593 | + }, | |
594 | + } | |
595 | +} | |
596 | +</script> | |
597 | + | |
598 | +<style scoped> | |
599 | + | |
600 | +</style> | |
0 | 601 | \ No newline at end of file |
... | ... |