You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4645 lines
161 KiB

4 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
7 months ago
5 months ago
​
5 months ago
7 months ago
​
​
5 months ago
5 months ago
​
​
7 months ago
7 months ago
​
7 months ago
​
5 months ago
​
​
​
​
​
2 months ago
5 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
5 months ago
​
​
​
​
5 months ago
​
7 months ago
​
7 months ago
5 months ago
7 months ago
5 months ago
​
7 months ago
​
7 months ago
5 months ago
5 months ago
​
​
5 months ago
5 months ago
​
​
5 months ago
5 months ago
​
​
5 months ago
7 months ago
5 months ago
​
​
​
​
​
​
​
​
7 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
7 months ago
7 months ago
​
​
​
​
​
​
​
​
7 months ago
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
5 months ago
​
​
​
​
4 months ago
​
​
​
​
​
​
​
4 months ago
3 months ago
​
​
​
​
4 months ago
3 months ago
4 months ago
3 months ago
​
​
​
​
​
​
​
​
​
5 months ago
3 months ago
5 months ago
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
5 months ago
​
​
​
2 months ago
​
5 months ago
5 months ago
4 months ago
​
​
​
​
​
​
​
​
4 months ago
5 months ago
​
4 months ago
5 months ago
4 months ago
5 months ago
​
​
​
​
​
4 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
5 months ago
5 months ago
​
​
4 months ago
​
4 months ago
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
4 months ago
4 months ago
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
4 months ago
4 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
4 months ago
​
5 months ago
5 months ago
​
​
​
​
​
4 months ago
​
5 months ago
​
4 months ago
4 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
4 months ago
​
3 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
4 months ago
3 months ago
4 months ago
5 months ago
​
5 months ago
4 months ago
​
​
5 months ago
5 months ago
​
5 months ago
2 months ago
5 months ago
​
5 months ago
​
​
​
​
​
​
5 months ago
4 months ago
4 months ago
5 months ago
​
5 months ago
5 months ago
​
​
2 months ago
2 months ago
2 months ago
5 months ago
5 months ago
7 months ago
4 months ago
5 months ago
​
​
​
​
​
2 months ago
5 months ago
5 months ago
5 months ago
​
​
2 months ago
2 months ago
5 months ago
4 months ago
5 months ago
​
4 months ago
​
4 months ago
5 months ago
​
​
​
2 months ago
5 months ago
​
​
​
4 months ago
​
​
​
​
​
​
2 months ago
4 months ago
​
​
​
​
​
​
3 months ago
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
3 months ago
4 months ago
​
​
​
​
​
​
​
​
​
2 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
2 months ago
5 months ago
5 months ago
​
2 months ago
5 months ago
​
4 months ago
7 months ago
​
​
​
​
​
​
7 months ago
​
​
​
7 months ago
​
​
​
5 months ago
​
5 months ago
​
​
2 months ago
7 months ago
7 months ago
3 months ago
​
​
​
​
​
4 months ago
5 months ago
​
4 months ago
5 months ago
​
4 months ago
5 months ago
5 months ago
​
5 months ago
4 months ago
​
​
​
​
​
​
2 months ago
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
4 months ago
5 months ago
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
4 months ago
7 months ago
​
2 months ago
7 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
4 months ago
2 months ago
​
5 months ago
5 months ago
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
7 months ago
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
5 months ago
7 months ago
​
​
​
​
​
7 months ago
7 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
7 months ago
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
2 months ago
5 months ago
​
​
5 months ago
​
​
​
4 months ago
​
​
5 months ago
​
​
​
4 months ago
2 months ago
5 months ago
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
5 months ago
4 months ago
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
5 months ago
​
5 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
4 months ago
​
​
​
​
​
​
​
4 months ago
4 months ago
5 months ago
​
5 months ago
​
5 months ago
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
5 months ago
2 months ago
​
5 months ago
​
​
5 months ago
​
​
​
2 months ago
5 months ago
2 months ago
​
5 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
2 months ago
5 months ago
​
5 months ago
​
​
​
​
​
4 months ago
5 months ago
​
​
​
4 months ago
5 months ago
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
4 months ago
5 months ago
2 months ago
​
​
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
​
​
​
2 months ago
5 months ago
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
5 months ago
4 months ago
​
​
​
​
​
5 months ago
​
​
4 months ago
​
​
​
5 months ago
4 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
4 months ago
4 months ago
​
5 months ago
​
​
​
​
​
​
4 months ago
​
​
5 months ago
​
4 months ago
5 months ago
​
4 months ago
5 months ago
4 months ago
4 months ago
4 months ago
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
4 months ago
4 months ago
​
4 months ago
4 months ago
​
​
4 months ago
​
​
​
4 months ago
4 months ago
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
3 months ago
4 months ago
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
​
​
7 months ago
7 months ago
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
5 months ago
​
​
​
7 months ago
​
5 months ago
​
​
4 months ago
5 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
​
​
​
​
4 months ago
5 months ago
4 months ago
4 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
5 months ago
​
4 months ago
5 months ago
​
4 months ago
5 months ago
​
​
4 months ago
5 months ago
​
​
​
​
5 months ago
5 months ago
​
​
​
5 months ago
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
4 months ago
4 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
5 months ago
​
​
​
​
​
​
​
​
5 months ago
5 months ago
​
​
​
​
​
​
​
5 months ago
​
​
​
7 months ago
5 months ago
​
​
7 months ago
5 months ago
7 months ago
7 months ago
7 months ago
​
​
​
​
​
​
5 months ago
7 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
7 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
7 months ago
7 months ago
7 months ago
7 months ago
​
​
​
​
​
7 months ago
7 months ago
​
​
​
​
​
7 months ago
7 months ago
​
5 months ago
​
7 months ago
​
5 months ago
7 months ago
​
​
​
​
​
​
7 months ago
​
​
​
​
​
​
​
7 months ago
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
5 months ago
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
5 months ago
4 months ago
​
5 months ago
​
​
​
2 months ago
​
​
5 months ago
​
2 months ago
5 months ago
2 months ago
​
5 months ago
​
​
2 months ago
5 months ago
​
​
7 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
7 months ago
5 months ago
7 months ago
7 months ago
7 months ago
​
7 months ago
​
​
​
​
​
7 months ago
7 months ago
​
​
​
​
​
​
​
​
​
7 months ago
7 months ago
​
​
​
7 months ago
7 months ago
7 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 months ago
​
​
​
​
​
7 months ago
7 months ago
7 months ago
​
​
​
​
7 months ago
​
5 months ago
5 months ago
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
5 months ago
5 months ago
​
​
5 months ago
​
​
​
​
​
​
4 months ago
​
​
​
​
​
5 months ago
​
​
​
​
​
4 months ago
​
5 months ago
5 months ago
​
5 months ago
​
7 months ago
5 months ago
5 months ago
​
​
​
​
​
​
5 months ago
7 months ago
7 months ago
​
​
​
​
​
​
​
​
​
​
​
7 months ago
7 months ago
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
5 months ago
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
3 months ago
​
5 months ago
3 months ago
​
​
3 months ago
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
​
4 months ago
5 months ago
​
​
​
​
4 months ago
5 months ago
​
​
​
​
4 months ago
​
​
4 months ago
​
​
​
​
​
​
​
​
4 months ago
4 months ago
​
​
4 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
4 months ago
5 months ago
​
5 months ago
​
​
​
​
​
5 months ago
5 months ago
​
4 months ago
5 months ago
5 months ago
5 months ago
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
4 months ago
​
4 months ago
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
4 months ago
​
​
​
​
​
​
5 months ago
5 months ago
4 months ago
5 months ago
​
4 months ago
​
​
4 months ago
​
​
​
​
4 months ago
5 months ago
4 months ago
​
4 months ago
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
5 months ago
​
​
4 months ago
5 months ago
​
5 months ago
​
​
​
​
​
​
​
4 months ago
4 months ago
5 months ago
​
4 months ago
​
​
5 months ago
​
​
4 months ago
​
​
5 months ago
​
​
4 months ago
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
4 months ago
​
​
​
​
4 months ago
4 months ago
​
4 months ago
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
5 months ago
​
4 months ago
5 months ago
​
4 months ago
​
​
​
​
​
5 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
4 months ago
4 months ago
5 months ago
​
​
​
​
​
​
​
4 months ago
5 months ago
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
4 months ago
5 months ago
4 months ago
5 months ago
​
​
​
​
​
4 months ago
4 months ago
​
​
​
​
5 months ago
​
​
​
​
​
​
​
5 months ago
​
5 months ago
​
​
4 months ago
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
4 months ago
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
5 months ago
4 months ago
​
​
​
​
5 months ago
4 months ago
​
​
5 months ago
4 months ago
​
​
5 months ago
4 months ago
​
​
5 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
4 months ago
​
​
​
​
5 months ago
​
4 months ago
​
​
5 months ago
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
4 months ago
​
​
5 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
4 months ago
5 months ago
​
​
​
​
4 months ago
5 months ago
​
​
​
​
4 months ago
5 months ago
​
​
​
​
​
​
​
​
4 months ago
5 months ago
​
​
​
4 months ago
5 months ago
​
​
​
​
​
​
5 months ago
4 months ago
​
5 months ago
4 months ago
​
5 months ago
4 months ago
​
5 months ago
5 months ago
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
7 months ago
​
​
​
​
5 months ago
4 months ago
4 months ago
5 months ago
4 months ago
​
​
​
​
​
5 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <template>
  2. <div ref="pageRoot" class="mod-config">
  3. <com-po-order-search-bar
  4. :search-data="searchData"
  5. :ship-method-options="shipMethodOptions"
  6. :destination-options="destinationOptions"
  7. :status-options="poOrderStatusOptions"
  8. @search="handleSearch"
  9. @status-visible="onPoStatusDropdownVisible">
  10. <com-po-order-customer-picker
  11. slot="leading"
  12. embedded
  13. :site="searchData.site"
  14. v-model="searchData.customer"
  15. @change="onSessionCustomerChange" />
  16. </com-po-order-search-bar>
  17. <el-form :inline="true" label-position="top" style="margin-top:1px ">
  18. <el-form-item>
  19. <el-button type="primary" @click="handleSearch()" v-if="!editMode" :disabled="!searchData.customer">查询</el-button>
  20. <el-button type="primary" style="margin-left: 2px" @click="exportExcel" :disabled="editMode || !searchData.customer">导出</el-button>
  21. <el-button type="warning" plain @click="advancedQueryVisible = true" v-if="!editMode" style="margin-left: 2px">高级查询</el-button>
  22. <el-button type="primary" style="margin-left: 2px" @click="toggleEditMode">
  23. {{ editMode ? '确定' : '编辑' }}
  24. </el-button>
  25. <el-button v-if="editMode" style="margin-left: 2px" @click="cancelEditMode">取消</el-button>
  26. <el-button type="primary" style="margin-left: 2px" @click="openAddDialog" v-if="!editMode">新增</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-table
  30. ref="poTable"
  31. :height="height"
  32. :data="masterRows"
  33. border
  34. highlight-current-row
  35. style="width: 100%;"
  36. @current-change="onTableCurrentChange">
  37. <el-table-column
  38. v-if="!editMode"
  39. fixed="left"
  40. label="操作"
  41. header-align="center"
  42. align="center"
  43. width="100">
  44. <template slot-scope="scope">
  45. <div class="po-row-action-wrap">
  46. <el-link
  47. v-if="canIssuePoOrder(scope.row.status)"
  48. type="primary"
  49. @click.stop="handleIssuePoOrder(scope.row)">下达</el-link>
  50. <el-link
  51. v-if="canShipPoOrder(scope.row.status)"
  52. type="primary"
  53. @click.stop="handleShipPoOrder(scope.row)">shipped</el-link>
  54. <el-link
  55. v-if="canReceivePoOrder(scope.row)"
  56. type="primary"
  57. @click.stop="handleReceivePoOrder(scope.row)">收货</el-link>
  58. <el-link
  59. v-if="canClosePoOrder(scope.row.status)"
  60. type="primary"
  61. @click.stop="handleClosePoOrder(scope.row)">关闭</el-link>
  62. <el-link
  63. v-if="canOpenPoOrder(scope.row.status)"
  64. type="primary"
  65. @click.stop="handleOpenPoOrder(scope.row)">打开</el-link>
  66. </div>
  67. </template>
  68. </el-table-column>
  69. <el-table-column
  70. v-for="(item, index) in visibleColumns"
  71. :key="item.serialNumber || index"
  72. :sortable="item.columnSortable"
  73. :prop="item.columnProp"
  74. :header-align="item.headerAlign"
  75. :show-overflow-tooltip="item.showOverflowTooltip && (!editMode || (!item.editAble && !isChooserEditColumn(item.columnProp)))"
  76. :align="item.align"
  77. :fixed="item.fixed === '' ? false : item.fixed"
  78. :min-width="item.columnWidth"
  79. :label="item.columnLabel">
  80. <template slot-scope="scope">
  81. <template v-if="editMode && item.columnProp==='supplierName' && canEditCell(scope.row, item)">
  82. <el-input
  83. v-model="scope.row.supplierName"
  84. size="mini"
  85. style="width: 100%; cursor: pointer"
  86. readonly
  87. placeholder="请选择供应商"
  88. @click.native="openSupplierSelect(scope.row)">
  89. <i slot="suffix" class="el-icon-search" style="cursor: pointer" @click.stop="openSupplierSelect(scope.row)"></i>
  90. </el-input>
  91. </template>
  92. <template v-else-if="editMode && item.columnProp==='partNo' && canEditCell(scope.row, item)">
  93. <el-input
  94. v-model="scope.row.partNo"
  95. size="mini"
  96. style="width: 100%; cursor: pointer"
  97. readonly
  98. placeholder="请选择物料"
  99. @click.native="openPartNoSelect(scope.row)">
  100. <i slot="suffix" class="el-icon-search" style="cursor: pointer" @click.stop="openPartNoSelect(scope.row)"></i>
  101. </el-input>
  102. </template>
  103. <template v-else-if="editMode && item.columnProp==='departure' && canEditCell(scope.row, item)">
  104. <el-input
  105. v-model="scope.row.departure"
  106. size="mini"
  107. style="width: 100%; cursor: pointer"
  108. readonly
  109. placeholder="请选择始发港"
  110. @click.native="openDepartureSelect(scope.row)">
  111. <i slot="suffix" class="el-icon-search" style="cursor: pointer" @click.stop="openDepartureSelect(scope.row)"></i>
  112. </el-input>
  113. </template>
  114. <template v-else-if="editMode && item.columnProp==='destination' && canEditCell(scope.row, item)">
  115. <el-input
  116. v-model="scope.row.destination"
  117. size="mini"
  118. style="width: 100%; cursor: pointer"
  119. readonly
  120. placeholder="请选择目的港"
  121. @click.native="openDestinationSelect(scope.row)">
  122. <i slot="suffix" class="el-icon-search" style="cursor: pointer" @click.stop="openDestinationSelect(scope.row)"></i>
  123. </el-input>
  124. </template>
  125. <template v-else-if="editMode && item.columnProp==='shipVia' && canEditCell(scope.row, item)">
  126. <el-input
  127. v-model="scope.row.shipVia"
  128. size="mini"
  129. style="width: 100%; cursor: pointer"
  130. readonly
  131. placeholder="请选择运输方式"
  132. @click.native="openShipViaSelect(scope.row)">
  133. <i slot="suffix" class="el-icon-search" style="cursor: pointer" @click.stop="openShipViaSelect(scope.row)"></i>
  134. </el-input>
  135. </template>
  136. <template v-else-if="editMode && canEditCell(scope.row, item)">
  137. <!-- 对于 confirmed 和 wantReceiveDate 字段,仅在新增行时可编辑 -->
  138. <template v-if="(item.columnProp === 'confirmed' || item.columnProp === 'wantReceiveDate') && !isNewRow(scope.row)">
  139. <span>{{ scope.row[item.columnProp] }}</span>
  140. </template>
  141. <!-- 对于 inspection 和 realCrd 字段,仅在修改时(非新增行)可编辑 -->
  142. <template v-else-if="(item.columnProp === 'inspection' || item.columnProp === 'realCrd') && isNewRow(scope.row)">
  143. <span>{{ scope.row[item.columnProp] }}</span>
  144. </template>
  145. <template v-else>
  146. <!-- 下拉框 -->
  147. <el-select
  148. v-if="item.editType === 'select' || item.editType === 'dict-select'"
  149. v-model="scope.row[item.columnProp]"
  150. size="mini"
  151. style="width: 100%"
  152. clearable
  153. @change="onCellChange(scope.row)">
  154. <el-option
  155. v-for="opt in getSelectOptionsForColumn(item)"
  156. :key="String(opt.value)"
  157. :label="opt.label"
  158. :value="opt.value">
  159. </el-option>
  160. </el-select>
  161. <!-- 数字输入框 -->
  162. <el-input
  163. v-else-if="item.editType === 'num'"
  164. v-model="scope.row[item.columnProp]"
  165. type="number"
  166. size="mini"
  167. @change="onCellChange(scope.row)">
  168. </el-input>
  169. <!-- 时间控件 -->
  170. <el-date-picker
  171. v-else-if="item.editType === 'date'"
  172. v-model="scope.row[item.columnProp]"
  173. type="date"
  174. size="mini"
  175. style="width: 100%"
  176. value-format="yyyy-MM-dd"
  177. placeholder="选择日期"
  178. @change="onCellChange(scope.row)">
  179. </el-date-picker>
  180. <el-date-picker
  181. v-else-if="item.editType === 'datetime'"
  182. v-model="scope.row[item.columnProp]"
  183. type="datetime"
  184. size="mini"
  185. style="width: 100%"
  186. value-format="yyyy-MM-dd HH:mm:ss"
  187. placeholder="选择日期时间"
  188. @change="onCellChange(scope.row)">
  189. </el-date-picker>
  190. <!-- 普通文本输入框 -->
  191. <el-input
  192. v-else
  193. v-model="scope.row[item.columnProp]"
  194. size="mini"
  195. @change="onCellChange(scope.row)">
  196. </el-input>
  197. </template>
  198. </template>
  199. <span v-else>{{ formatColumnCell(scope.row, item) }}</span>
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. <el-pagination
  204. ref="mainPager"
  205. @size-change="sizeChangeHandle"
  206. @current-change="currentChangeHandle"
  207. :current-page="pageIndex"
  208. :page-sizes="[20, 50, 100, 200, 500]"
  209. :page-size="pageSize"
  210. :total="totalPage"
  211. layout="total, sizes, prev, pager, next, jumper">
  212. </el-pagination>
  213. <!--
  214. 模态框 #1:PO订单导入弹窗(按 customer 权限动态模板)
  215. 交互规则:
  216. 1) 模板第一行按当前 customer 可见字段顺序生成;
  217. 2) 上传后后端先校验第一行栏位,顺序允许调整,但栏位需匹配模板;
  218. 3) 导入执行中所有按钮与文件选择统一置灰,避免重复提交。
  219. 关联状态:
  220. importDialogVisible / importFile / importSubmitting / importLastResult
  221. -->
  222. <el-dialog
  223. title="PO订单导入"
  224. v-drag
  225. :visible.sync="importDialogVisible"
  226. width="560px"
  227. append-to-body
  228. :close-on-click-modal="false"
  229. :show-close="!importSubmitting"
  230. :close-on-press-escape="!importSubmitting"
  231. @closed="resetImportDialog">
  232. <el-alert
  233. type="info"
  234. :closable="false"
  235. show-icon
  236. title="请先下载模板并填写数据;导入时会先校验第一行栏位,顺序可以调整。"
  237. style="margin-bottom: 12px;" />
  238. <div style="display:flex;align-items:center;">
  239. <el-input
  240. v-model="importFileName"
  241. style="width:320px;margin-right:10px;"
  242. :disabled="importSubmitting"
  243. readonly
  244. placeholder="请选择导入文件" />
  245. <el-upload
  246. ref="importUpload"
  247. action="#"
  248. :show-file-list="false"
  249. :auto-upload="false"
  250. :disabled="importSubmitting"
  251. :on-change="handleImportFileChange">
  252. <el-button type="primary" :disabled="importSubmitting">选择文件</el-button>
  253. </el-upload>
  254. </div>
  255. <div v-if="importLastResult" style="margin-top: 14px; font-size: 13px; color: #606266;">
  256. <div>
  257. 导入结果:成功 {{ importLastResult.successCount || 0 }} 条,失败 {{ importLastResult.failCount || 0 }} 条
  258. </div>
  259. <div
  260. v-if="importLastResult.rowErrors && importLastResult.rowErrors.length"
  261. style="margin-top: 8px; max-height: 160px; overflow: auto;">
  262. <div
  263. v-for="item in importLastResult.rowErrors.slice(0, 20)"
  264. :key="`import-error-${item.rowNo}-${item.message}`"
  265. style="line-height: 1.6;">
  266. 第{{ item.rowNo }}行:{{ item.message }}
  267. </div>
  268. <div v-if="importLastResult.rowErrors.length > 20" style="color:#909399;">
  269. 仅展示前20条失败原因,请按失败提示分批修复后重试。
  270. </div>
  271. </div>
  272. </div>
  273. <div slot="footer" class="dialog-footer">
  274. <el-button @click="downloadImportTemplate" :disabled="importSubmitting">下载模板</el-button>
  275. <el-button
  276. type="primary"
  277. @click="submitImportCreatePoOrder"
  278. :loading="importSubmitting"
  279. :disabled="importSubmitting || !importFile">开始导入</el-button>
  280. <el-button @click="importDialogVisible = false" :disabled="importSubmitting">关闭</el-button>
  281. </div>
  282. </el-dialog>
  283. <!--
  284. 模态框:发货确认(shipped)
  285. 交互规则:
  286. 1) 第一行:订单数量(可编辑,回写 qty);
  287. 2) 第二行:可发货数量(inspect_approve_qty - c_ship_qty,仅读);
  288. 3) 第三行:本次发货数量(默认=可发货数量,可修改)。
  289. -->
  290. <el-dialog
  291. title="发货确认"
  292. v-drag
  293. :visible.sync="shipDialogVisible"
  294. width="360px"
  295. append-to-body
  296. :close-on-click-modal="false"
  297. @closed="resetShipDialog">
  298. <el-form label-position="top" class="ship-dialog-form">
  299. <el-row :gutter="10">
  300. <el-col :span="12" >
  301. <el-form-item label="订单数量">
  302. <el-input
  303. v-model="shipDialogForm.orderQty"
  304. disabled
  305. class="ship-dialog-input" />
  306. </el-form-item>
  307. </el-col>
  308. <el-col :span="12" >
  309. <el-form-item label="未发货数量">
  310. <el-input
  311. :value="formatShipDialogDisplay(shipDialogForm.canShipQty)"
  312. disabled
  313. class="ship-dialog-input" />
  314. </el-form-item>
  315. </el-col>
  316. <el-col :span="12" >
  317. <el-form-item label="本次发货数量">
  318. <el-input
  319. v-model="shipDialogForm.shipQty"
  320. type="number"
  321. class="ship-dialog-input" />
  322. </el-form-item>
  323. </el-col>
  324. <el-col :span="12" >
  325. <el-form-item label="发货单号">
  326. <el-input
  327. v-model="shipDialogForm.flexid"
  328. placeholder="选填"
  329. class="ship-dialog-input" />
  330. </el-form-item>
  331. </el-col>
  332. </el-row>
  333. </el-form>
  334. <div slot="footer" class="dialog-footer ship-dialog-footer">
  335. <el-button type="primary" :loading="shipDialogSaving" @click="submitShipDialog">保存</el-button>
  336. <el-button @click="shipDialogVisible = false">取消</el-button>
  337. </div>
  338. </el-dialog>
  339. <!-- 打样单收货确认弹窗:填写收货日期,确定后回写 c_po_actual_ready_date 并自动生成已排程验货申请 -->
  340. <el-dialog
  341. title="收货确认"
  342. v-drag
  343. :visible.sync="receiveDialogVisible"
  344. width="360px"
  345. append-to-body
  346. :close-on-click-modal="false"
  347. @closed="resetReceiveDialog">
  348. <el-form label-position="top">
  349. <el-row :gutter="10">
  350. <el-col :span="24">
  351. <el-form-item label="收货日期" required>
  352. <el-date-picker
  353. v-model="receiveDialogForm.receiveDate"
  354. type="date"
  355. value-format="yyyy-MM-dd"
  356. placeholder="选择收货日期"
  357. style="width: 100%" />
  358. </el-form-item>
  359. </el-col>
  360. </el-row>
  361. </el-form>
  362. <div slot="footer" class="dialog-footer ship-dialog-footer">
  363. <el-button type="primary" :loading="receiveDialogSaving" @click="submitReceiveDialog">确定</el-button>
  364. <el-button @click="receiveDialogVisible = false">取消</el-button>
  365. </div>
  366. </el-dialog>
  367. <ChooselistEam ref="eamList" @getBaseData="getEamData" />
  368. <po-order-advanced-query
  369. :visible.sync="advancedQueryVisible"
  370. :advanced-query-data="advancedQueryData"
  371. :status-options="poOrderStatusOptions"
  372. @refresh-status-options="loadPoStatusMappings"
  373. @query="handleSearch" />
  374. <!--
  375. 模态框 #2:新增PO订单弹窗(主记录 + 明细暂存区)
  376. 用途:
  377. 1) 维护主记录字段(动态schema);
  378. 2) 维护明细草稿列表(新增/复制/修改/删除);
  379. 3) 统一保存为正式PO单据。
  380. 关联状态:
  381. addDialogVisible / addForm / addDetailRows / addFormSchemaFields / addFormSaving
  382. -->
  383. <el-dialog title="新增 PO 订单" v-drag :visible.sync="addDialogVisible" width="1180px" top="4vh"
  384. :close-on-click-modal="false" append-to-body>
  385. <div class="po-add-form-wrap">
  386. <el-form ref="addMasterFormRef" :model="addForm" label-position="top" size="small">
  387. <el-row :gutter="15">
  388. <el-col v-for="field in addMasterBaseFields" :key="`master-${field.fieldCode}`" :span="getAddFieldSpan(field)">
  389. <el-form-item :label="field.fieldLabel" :required="field.requiredFlag === 'Y'">
  390. <template v-if="isAddChooserField(field)">
  391. <el-input
  392. v-model="addForm[getAddFieldProp(field)]"
  393. readonly
  394. :placeholder="getAddChooserPlaceholder(field)"
  395. @click.native="openAddChooserByField(field, 'master')">
  396. <i slot="suffix" class="el-icon-search" style="cursor:pointer" @click.stop="openAddChooserByField(field, 'master')"></i>
  397. </el-input>
  398. </template>
  399. <template v-else-if="isAddSelectField(field)">
  400. <el-select
  401. v-model="addForm[getAddFieldProp(field)]"
  402. :filterable="isAddFilterableSelectField(field)"
  403. clearable
  404. style="width:100%"
  405. :disabled="isAddFieldDisabled(field)">
  406. <el-option
  407. v-for="opt in getAddFieldSelectOptions(field)"
  408. :key="opt.value"
  409. :label="opt.label"
  410. :value="opt.value" />
  411. </el-select>
  412. </template>
  413. <template v-else-if="isAddDateField(field)">
  414. <el-date-picker
  415. v-model="addForm[getAddFieldProp(field)]"
  416. type="date"
  417. value-format="yyyy-MM-dd"
  418. style="width:100%"
  419. :disabled="isAddFieldDisabled(field)" />
  420. </template>
  421. <template v-else-if="isAddTextareaField(field)">
  422. <el-input
  423. v-model="addForm[getAddFieldProp(field)]"
  424. type="textarea"
  425. :rows="2"
  426. :disabled="isAddFieldDisabled(field)" />
  427. </template>
  428. <template v-else>
  429. <el-input
  430. v-model="addForm[getAddFieldProp(field)]"
  431. :type="isAddNumberField(field) ? 'number' : 'text'"
  432. :disabled="isAddFieldDisabled(field)"
  433. @input="onAddFieldInput(field, 'master')" />
  434. </template>
  435. </el-form-item>
  436. </el-col>
  437. </el-row>
  438. </el-form>
  439. <el-form :inline="true" label-position="top" style="text-align: right;margin-top:0px ">
  440. <el-form-item style="text-align: right;">
  441. <el-button type="primary" @click="openAddDetailDialog">新增</el-button>
  442. <el-button :disabled="!hasSelectedAddDetailRow" @click="openCopyAddDetailDialog">复制</el-button>
  443. <el-button :disabled="!hasSelectedAddDetailRow" @click="openEditAddDetailDialog">修改</el-button>
  444. <el-button :disabled="!hasSelectedAddDetailRow" @click="removeAddDetailRow">删除</el-button>
  445. </el-form-item>
  446. </el-form>
  447. <el-table
  448. ref="addDetailTable"
  449. :data="addDetailRows"
  450. :height="280"
  451. border
  452. stripe
  453. highlight-current-row
  454. empty-text="请点击新增维护明细"
  455. @current-change="onAddDetailCurrentChange"
  456. @row-click="onAddDetailRowClick">
  457. <el-table-column type="index" label="#" width="50" header-align="center" align="center" />
  458. <el-table-column
  459. v-for="field in addDetailTableFields"
  460. :key="`detail-col-${field.fieldCode}`"
  461. :label="field.fieldLabel"
  462. :min-width="getAddDetailTableColumnWidth(field)"
  463. header-align="center"
  464. :align="getAddDetailTableColumnAlign(field)"
  465. show-overflow-tooltip>
  466. <template slot-scope="{ row }">
  467. {{ getAddDetailTableCellDisplay(row, field) }}
  468. </template>
  469. </el-table-column>
  470. </el-table>
  471. </div>
  472. <div slot="footer" class="dialog-footer">
  473. <el-button type="primary" :loading="addFormSaving" @click="saveAddPoOrder">保存</el-button>
  474. <el-button @click="addDialogVisible = false">取消</el-button>
  475. </div>
  476. </el-dialog>
  477. <!--
  478. 模态框 #3:新增/编辑/复制 明细弹窗
  479. 用途:
  480. 1) 编辑单条明细草稿;
  481. 2) 支持主记录同款动态字段渲染;
  482. 3) 点击“暂存”回写到新增弹窗明细表。
  483. 关联状态:
  484. addDetailDialogVisible / addDetailDialogMode / addDetailForm / addDetailEditingDraftId
  485. -->
  486. <el-dialog
  487. v-drag
  488. :title="addDetailDialogTitle"
  489. :visible.sync="addDetailDialogVisible"
  490. width="1000px"
  491. top="6vh"
  492. append-to-body
  493. :close-on-click-modal="false">
  494. <div class="po-add-form-wrap">
  495. <el-form ref="addDetailFormRef" :model="addDetailForm" label-position="top" size="small">
  496. <el-row :gutter="15">
  497. <el-col v-for="field in addDetailBaseFields" :key="`detail-${field.fieldCode}`" :span="getAddFieldSpan(field)">
  498. <el-form-item :label="field.fieldLabel" :required="field.requiredFlag === 'Y'">
  499. <template v-if="isAddChooserField(field)">
  500. <el-input
  501. v-model="addDetailForm[getAddFieldProp(field)]"
  502. readonly
  503. :placeholder="getAddChooserPlaceholder(field)"
  504. @click.native="openAddChooserByField(field, 'detail')">
  505. <i slot="suffix" class="el-icon-search" style="cursor:pointer" @click.stop="openAddChooserByField(field, 'detail')"></i>
  506. </el-input>
  507. </template>
  508. <template v-else-if="isAddSelectField(field)">
  509. <el-select
  510. v-model="addDetailForm[getAddFieldProp(field)]"
  511. :filterable="isAddFilterableSelectField(field)"
  512. clearable
  513. style="width:100%"
  514. :disabled="isAddFieldDisabled(field)">
  515. <el-option
  516. v-for="opt in getAddFieldSelectOptions(field)"
  517. :key="opt.value"
  518. :label="opt.label"
  519. :value="opt.value" />
  520. </el-select>
  521. </template>
  522. <template v-else-if="isAddDateField(field)">
  523. <el-date-picker
  524. v-model="addDetailForm[getAddFieldProp(field)]"
  525. type="date"
  526. value-format="yyyy-MM-dd"
  527. style="width:100%"
  528. :disabled="isAddFieldDisabled(field)" />
  529. </template>
  530. <template v-else-if="isAddTextareaField(field)">
  531. <el-input
  532. v-model="addDetailForm[getAddFieldProp(field)]"
  533. type="textarea"
  534. :rows="2"
  535. :disabled="isAddFieldDisabled(field)" />
  536. </template>
  537. <template v-else>
  538. <el-input
  539. v-model="addDetailForm[getAddFieldProp(field)]"
  540. :type="isAddNumberField(field) ? 'number' : 'text'"
  541. :disabled="isAddFieldDisabled(field)"
  542. @input="onAddFieldInput(field, 'detail')" />
  543. </template>
  544. </el-form-item>
  545. </el-col>
  546. </el-row>
  547. <el-row v-if="addDetailExtFields.length" :gutter="24">
  548. <el-col v-for="field in addDetailExtFields" :key="`detail-ext-${field.fieldCode}`" :span="6">
  549. <el-form-item :label="field.fieldLabel" :required="field.requiredFlag === 'Y'">
  550. <com-po-order-dynamic-field-renderer
  551. :field="field"
  552. :site="searchData.site"
  553. :value="getAddDetailExtValue(field.fieldCode)"
  554. @input="val => setAddDetailExtValue(field.fieldCode, val)"
  555. />
  556. </el-form-item>
  557. </el-col>
  558. </el-row>
  559. </el-form>
  560. </div>
  561. <div slot="footer" class="dialog-footer">
  562. <el-button type="primary" @click="saveAddDetailDraft">暂存</el-button>
  563. <el-button @click="addDetailDialogVisible = false">取消</el-button>
  564. </div>
  565. </el-dialog>
  566. <!--
  567. 模态框 #4:Buyer 选择弹窗
  568. Buyer 数据按当前 Site + Customer 从 po_buyer 主数据获取,回填 buyer_code。
  569. -->
  570. <el-dialog
  571. title="选择 Buyer"
  572. v-drag
  573. :visible.sync="buyerDialogVisible"
  574. width="640px"
  575. top="10vh"
  576. append-to-body
  577. :close-on-click-modal="false"
  578. @closed="resetBuyerDialog">
  579. <div style="margin-bottom: 10px; color: #606266;">
  580. <span>Customer:{{ searchData.customer }}</span>
  581. </div>
  582. <el-table
  583. ref="buyerSelectTable"
  584. :data="buyerDialogRows"
  585. :height="360"
  586. border
  587. stripe
  588. highlight-current-row
  589. v-loading="buyerDialogLoading"
  590. empty-text="当前 Customer 未维护可用 Buyer"
  591. @current-change="onBuyerDialogCurrentChange"
  592. @row-dblclick="applyBuyerDialogSelection">
  593. <el-table-column prop="code" label="Buyer 编码" min-width="180" header-align="center" align="center" />
  594. <el-table-column prop="name" label="Buyer 名称" min-width="280" header-align="center" show-overflow-tooltip />
  595. </el-table>
  596. <div slot="footer" class="dialog-footer">
  597. <el-button
  598. type="primary"
  599. :disabled="!buyerDialogSelectedRow"
  600. @click="applyBuyerDialogSelection(buyerDialogSelectedRow)">确定</el-button>
  601. <el-button @click="buyerDialogVisible = false">取消</el-button>
  602. </div>
  603. </el-dialog>
  604. <!--
  605. 模态框 #5:供应商可供物料弹窗
  606. 用途:
  607. 1) 按供应商加载可供物料;
  608. 2) 双击选中后回填 Part No / Item / SKU / Category。
  609. 关联状态:
  610. supplierPartDialogVisible / supplierPartDialogRows / supplierPartDialogContext / supplierPartDialogTargetRow
  611. -->
  612. <el-dialog
  613. title="选择供应商可供物料"
  614. v-drag
  615. :visible.sync="supplierPartDialogVisible"
  616. width="820px"
  617. top="6vh"
  618. append-to-body
  619. :close-on-click-modal="false"
  620. @closed="resetSupplierPartDialog">
  621. <div style="margin-bottom: 10px; color: #606266;">
  622. <span>供应商:{{ supplierPartDialogSupplierNo }}</span>
  623. </div>
  624. <el-table
  625. :data="supplierPartDialogRows"
  626. :height="430"
  627. border
  628. stripe
  629. v-loading="supplierPartDialogLoading"
  630. empty-text="该供应商未维护供应商可供物料"
  631. @row-dblclick="handleSupplierPartRowDblClick">
  632. <el-table-column prop="partNo" label="物料编码" min-width="160" header-align="center" align="center" />
  633. <el-table-column prop="partDesc" label="物料描述" min-width="220" header-align="center" align="left" show-overflow-tooltip />
  634. <el-table-column prop="item" label="Item" min-width="120" header-align="center" align="center" show-overflow-tooltip />
  635. <el-table-column prop="sku" label="SKU" min-width="120" header-align="center" align="center" show-overflow-tooltip />
  636. </el-table>
  637. <div slot="footer" class="dialog-footer">
  638. <el-button @click="supplierPartDialogVisible = false">关闭</el-button>
  639. </div>
  640. </el-dialog>
  641. </div>
  642. </template>
  643. <script>
  644. import {
  645. searchPoDetailPage,
  646. searchPoDetailAdvancedPage,
  647. batchUpdatePoDetail,
  648. closePoDetail,
  649. openPoDetail,
  650. issuePoDetail,
  651. shipPoDetailPreview,
  652. shipPoDetail,
  653. receivePoDetail,
  654. createPoOrder,
  655. getPoCustomerOptions,
  656. getPoBuyerOptions,
  657. getPoFieldSchema,
  658. listPoSupplierPartOptions,
  659. listPoCurrentTierPrice
  660. } from '@/api/order/poOrder.js'
  661. import {
  662. createAdvancedQueryData,
  663. createAdvancedQueryDataFromSchema,
  664. createPoOrderSearchData,
  665. buildPoOrderQueryParams
  666. } from './poOrderAdvancedQueryHelper.js'
  667. import {
  668. applyFieldSchemaToColumns,
  669. getAdvancedQueryFieldsFromSchema,
  670. getEditableExtFieldsFromSchema,
  671. normalizeSchemaRowValues,
  672. buildExtValuesFromRow
  673. } from './poOrderFieldSchemaHelper.js'
  674. import {
  675. canIssuePoOrder,
  676. canShipPoOrder,
  677. canReceivePoOrder,
  678. canClosePoOrder,
  679. canOpenPoOrder,
  680. canEditPoColumnByStatus,
  681. resolvePoOrderStatusByInspectQty,
  682. buildPoDetailActionParams
  683. } from './poOrderStatusOptions.js'
  684. import { PO_ORDER_TYPE_FILTER_OPTIONS, formatPoOrderTypeLabel } from './poOrderTypeOptions.js'
  685. import poOrderStatusMappingMixin from './poOrderStatusMappingMixin.js'
  686. import poOrderSearchOptionsMixin from './poOrderSearchOptionsMixin.js'
  687. import { getPartList, searchPartInfo } from '@/api/part/partInfo.js'
  688. import excel from '@/utils/excel-util.js'
  689. import { checkSrmSupplierList } from '@/api/srm/srmSupplier.js'
  690. import { selectDictDataList } from '@/api/dict'
  691. import {
  692. SUPPLIER_CHOOSELIST_TAG,
  693. parseSupplierChooselistRow,
  694. fetchSupplierDetail,
  695. resolveSupplierShortFieldsFromDetail
  696. } from '@/utils/supplierChooselistHelper.js'
  697. import { searchTransportOptions } from '@/api/port/portTransit.js'
  698. import ComPoOrderSearchBar from './com_poOrderSearchBar.vue'
  699. import ChooselistEam from '@/views/modules/common/Chooselist_eam.vue'
  700. import PoOrderAdvancedQuery from './com_poOrderAdvancedQuery.vue'
  701. import ComPoOrderCustomerPicker from './com_poOrder_CustomerPicker.vue'
  702. import ComPoOrderDynamicFieldRenderer from './com_poOrder_DynamicFieldRenderer.vue'
  703. const ADD_CHOOSER_FIELD_CODES = new Set(['buyer', 'supplier_name', 'part_no', 'departure', 'destination', 'ship_via'])
  704. const ADD_DISPLAY_ONLY_FIELD_CODES = new Set(['short_office', 'short_npc', 'item', 'category_name', 'sku', 'value', 'status', 'planner', 'crd_ori', 'base_price'])
  705. const ADD_TEXTAREA_FIELD_CODES = new Set(['remark'])
  706. const ADD_FULL_ROW_FIELD_CODES = new Set(['remark'])
  707. const ADD_NUMBER_FIELD_CODES = new Set(['price', 'qty', 'ship_qty', 'sum_price'])
  708. const ADD_FILTERABLE_SELECT_FIELD_CODES = new Set(['customer', 'buyer'])
  709. const ADD_FORCE_DETAIL_FIELD_CODES = new Set(['part_no', 'price', 'qty'])
  710. const ADD_READONLY_DEFAULT_TODAY_FIELD_CODES = new Set(['create_date'])
  711. const ADD_EDITABLE_DEFAULT_TODAY_FIELD_CODES = new Set(['po_place_date'])
  712. const ADD_SELECT_OPTIONS_FIELD_CODE_MAP = {
  713. order_type: 'poOrderTypeOptions',
  714. customer: 'poCustomerOptions',
  715. buyer: 'poBuyerOptions',
  716. status: 'poOrderStatusValueOptions', // rqrq - 新增状态显示英文,值保留中文
  717. doc_sent: 'yesNoOptions',
  718. telex_release: 'yesNoOptions',
  719. advance_paid: 'yesNoOptions'
  720. }
  721. /**
  722. * PO订单页面(order-poOrder)说明
  723. *
  724. * 一、公共参数(data 顶层字段)说明
  725. * - loading: 页面级加载态(用于复杂异步流程时的全屏或局部控制)
  726. * - masterRows: 主表展示数据(来自 searchPoDetailPage / searchPoDetailAdvancedPage)
  727. * - currentRow: 当前选中主表行(行内编辑、联动选择时使用)
  728. * - searchData: 顶部筛选(Planner账号、Buyer、Supplier名称、PO、ITEM、LOGISTICS ID、Ship Method、Status、Destination、Telex Release、五个日期区间)
  729. * - advancedQueryData: 高级查询条件对象(由 schema 动态生成并参与最终查询)
  730. * - pageIndex/pageSize/totalPage: 分页三要素
  731. * - height: 主表动态高度(窗口变化时实时重算)
  732. * - editMode: 主表行内编辑模式开关
  733. * - fieldSchemaFields/baseColumnList/columnList: 字段schema与表格列配置(动态列渲染核心)
  734. * - dictSelectOptionsMap/addDictSelectOptionsMap: 字典下拉选项缓存(列表/新增分开缓存)
  735. * - columnSelectOptions: 常用下拉配置集合(客户、买手、状态、是/否、运输方式等)
  736. * - importDialogVisible/importFile/importSubmitting/importLastResult:
  737. * 导入流程状态(模板下载、导入执行、失败反馈)
  738. * - addDialogVisible/addForm/addFormSchemaFields/addFormSaving:
  739. * 新增主弹窗状态(主记录)
  740. * - addDetailDialogVisible/addDetailDialogMode/addDetailForm/addDetailRows/addDetailCurrentDraftId/addDetailEditingDraftId:
  741. * 新增明细弹窗与明细草稿列表状态
  742. * - supplierPartDialogVisible/supplierPartDialogRows/supplierPartDialogContext/supplierPartDialogTargetRow:
  743. * 供应商可供物料弹窗状态
  744. * - pickContext/eamTagNo/eamPickField: 通用 Chooselist 选择上下文(决定“选完回填到哪里”)
  745. * - selectedCustomerScope: 顶部客户选择器当前作用域(切换客户时决定是否重载schema和缓存)
  746. * - rowDeparture/rowDestination/rowShipVia/rowPartNo/rowSupplierNo:
  747. * 行编辑阶段的辅助暂存(用于复杂选择组件联动)
  748. *
  749. * 二、模态框与子弹层说明
  750. * - importDialogVisible: PO订单导入(动态模板 + 逐行导入)
  751. * - addDialogVisible: 新增PO订单(主记录 + 明细草稿)
  752. * - addDetailDialogVisible: 新增明细(新增/编辑/复制)
  753. * - supplierPartDialogVisible: 供应商可供物料选择
  754. * - advancedQueryVisible: 高级查询抽屉/弹层(由子组件 po-order-advanced-query 实现)
  755. *
  756. * 三、公共方法说明(按功能分组)
  757. * A. 页面与布局
  758. * - onWindowResize, updateTableHeight, refreshTableLayout
  759. *
  760. * B. 列渲染与编辑权限
  761. * - formatColumnCell, formatNumberDisplay, isChooserEditColumn, canEditCell
  762. * - getSelectOptionsForColumn, getSchemaDictType, preloadDictSelectOptions
  763. *
  764. * C. 新增弹窗schema与字段能力
  765. * - getAddFieldCode, getAddFieldProp, isExtSchemaField, normalizeAddFieldLabel
  766. * - isAddCreateDateField, isAddPoPlaceDateField, isAddMasterField
  767. * - getSchemaFieldByCode, getAddTableColumnLabel
  768. * - getAddDetailTableColumnAlign, getAddDetailTableColumnWidth, getAddDetailTableCellDisplay
  769. * - snakeToCamel, camelToSnake
  770. * - isAddChooserField, openAddChooserByField, getAddChooserPlaceholder
  771. * - getAddFieldSelectOptions, isAddDictSelectField, isAddSelectField, isAddFilterableSelectField
  772. * - isAddDateField, isAddTextareaField, isAddNumberField, isAddFieldDisabled, getAddFieldSpan
  773. * - onAddFieldInput, getAddTargetForm, getSupplierCodeForTargetForm
  774. *
  775. * D. 价格/金额联动与分段价
  776. * - scheduleAutoFillAddPriceByTierPrice, autoFillAddPriceByTierPrice, findCurrentTierPriceByQty
  777. * - normalizeAddNumericValue, calcPoValue, recalcAddFormValue, validatePriceAndQty
  778. * - 标准价格(basePrice)由后端创建时按价格表写入,新增弹窗不展示,列表只读
  779. *
  780. * E. 查询、分页、高级查询
  781. * - buildQueryRequest, handleSearch, loadFieldSchema, buildBatchUpdateRow
  782. * - getDataList, sizeChangeHandle, currentChangeHandle, buildQueryRequest
  783. *
  784. * F. 行操作(状态流转)
  785. * - handleIssuePoOrder, handleShipPoOrder, handleClosePoOrder, handleOpenPoOrder
  786. * - canIssuePoOrder, canShipPoOrder, canClosePoOrder, canOpenPoOrder, canEditPoColumnByStatus
  787. *
  788. * G. 行编辑与批量提交
  789. * - onCellChange, toggleEditMode, cancelEditMode, batchUpdatePoOrder, isNewRow
  790. *
  791. * H. 选择器与主数据加载
  792. * - openEamList, resetEamPick, openSearchBaseList, getEamData
  793. * - openSupplierSelect, openPartNoSelect, openDepartureSelect, openDestinationSelect, openShipViaSelect
  794. * - getPartNoOptions, getSupplierOptions, getPortOptions, getCustomerOptions, getBuyerOptions
  795. * - getTransportOptions, handleSupplierChange
  796. *
  797. * I. 导入导出
  798. * - openImportDialog, handleImportFileChange, submitImportCreatePoOrder
  799. * - downloadImportTemplate, resetImportDialog, exportExcel
  800. *
  801. * J. 新增流程(主记录 + 明细)
  802. * - resolveAddOrderTypeByCustomer, openAddDialog, loadAddFieldSchema
  803. * - getTodayDateYmd, applyAddDefaultDateBySchema, applyDefaultDateBySchemaToForm
  804. * - getFormExtValue, setFormExtValue, getAddExtValue, setAddExtValue, getAddDetailExtValue, setAddDetailExtValue
  805. * - createEmptyAddForm, createEmptyAddDetailForm, cloneAddDraftRow, buildAddDetailRowFromForm
  806. * - removeAddMasterFieldValuesFromDetailRow, getSelectedAddDetailRow
  807. * - onAddDetailCurrentChange, onAddDetailRowClick
  808. * - openAddDetailDialog, openEditAddDetailDialog, openCopyAddDetailDialog, removeAddDetailRow
  809. * - isAddFormFieldEmpty, validateRequiredFieldGroup, validateRequiredExtFieldGroup
  810. * - saveAddDetailDraft, buildMergedAddDetailForm, saveAddPoOrder, buildAddPayload
  811. *
  812. * K. 供应商可供物料联动
  813. * - openSupplierPartDialog, handleSupplierPartRowDblClick, resetSupplierPartDialog
  814. * - applySelectedPartToTarget, fillPartCategorySku
  815. * - applySupplierSelection, fillSupplierShortFields, autoFillDepartureBySupplier
  816. *
  817. * L. 新增弹窗内快捷选择入口
  818. * - openAddSupplierSelect, openAddPartNoSelect, openAddDepartureSelect, openAddDestinationSelect, openAddShipViaSelect
  819. *
  820. * M. 其它工具函数
  821. * - formatCodeOptionLabel, buildDeparturePortConSql, buildDestinationPortConSql
  822. */
  823. export default {
  824. mixins: [poOrderStatusMappingMixin, poOrderSearchOptionsMixin], // rqrq - 状态映射与顶部筛选下拉共用
  825. name: 'PoOrder',
  826. components: {
  827. ChooselistEam,
  828. PoOrderAdvancedQuery,
  829. ComPoOrderCustomerPicker,
  830. ComPoOrderSearchBar,
  831. ComPoOrderDynamicFieldRenderer
  832. },
  833. data () {
  834. return {
  835. // ===== 页面基础状态 =====
  836. loading: false,
  837. masterRows: [],
  838. /**
  839. * 需要单独写编辑 UI 的 columnProp 填在这里,才会走模板里「自定义」分支;不在此数组的仍用默认 select/num/text - rqrq
  840. * 示例:['mPlanner', 'comments']
  841. */
  842. rowDeparture: {}, // 存储每行选中的始发港
  843. rowDestination: {}, // 存储每行选中的目的港
  844. rowShipVia: {}, // 存储每行选中的运输方式
  845. transportOptions: [], // 运输方式选项
  846. rowPartNo: {}, //存储每行选中的物料编号
  847. currentSelectRow: null, // 当前正在选择供应商的行
  848. currentPartNoRow: null, // 当前正在选择物料的行
  849. currentDepartureRow: null, // 当前正在选择始发港的行
  850. currentDestinationRow: null, // 当前正在选择目的港的行
  851. currentShipViaRow: null, // 当前正在选择运输方式的行
  852. rowSupplierNo: {}, //存储每行选中的供应商编号
  853. poPartNoOptions: [],
  854. supplierOptions: [],
  855. poDepartureOptions: [],
  856. poDestinationOptions: [],
  857. poCustomerOptions: [],
  858. poBuyerOptions: [],
  859. /** Chooselist 弹窗选择列(editAble 可为 false,如供应商/物料) */
  860. chooserEditColumnProps: ['supplierName', 'partNo', 'departure', 'destination', 'shipVia'],
  861. /** 联表展示、不写入 PO 的列 */
  862. displayOnlyColumnProps: ['shortOffice', 'shortNpc', 'item', 'categoryName', 'sku', 'planner', 'basePrice'],
  863. customEditColumnProps: [],
  864. // ===== 导入弹窗状态(新导入:模板下载 + 直接执行)=====
  865. importDialogVisible: false,
  866. importFileName: '',
  867. importFile: null,
  868. importSubmitting: false,
  869. importLastResult: null,
  870. // ===== 新增主弹窗 + 明细弹窗状态 =====
  871. addDialogVisible: false,
  872. addFormSaving: false,
  873. addDialogSchemaLoading: false,
  874. addFormSchemaFields: [],
  875. /** 新增弹窗中「始发港」最近一次自动带出的值,切换供应商时只覆盖自动值,不冲掉用户手选 */
  876. addDepartureAutoValues: { add: '', addDetail: '' },
  877. addDictSelectOptionsMap: {},
  878. pickContext: '',
  879. eamTagNo: '',
  880. eamPickField: '',
  881. addForm: {},
  882. addDetailDialogVisible: false,
  883. addDetailDialogMode: 'create',
  884. addDetailForm: {},
  885. addDetailRows: [],
  886. addDetailCurrentDraftId: '',
  887. addDetailEditingDraftId: '',
  888. addDetailDraftSeq: 0,
  889. buyerDialogVisible: false,
  890. buyerDialogLoading: false,
  891. buyerDialogRows: [],
  892. buyerDialogSelectedRow: null,
  893. buyerDialogTarget: 'master',
  894. supplierPartDialogVisible: false,
  895. supplierPartDialogLoading: false,
  896. supplierPartDialogRows: [],
  897. supplierPartDialogContext: '',
  898. supplierPartDialogTargetRow: null,
  899. supplierPartDialogSupplierNo: '',
  900. supplierPartDialogSite: '',
  901. addPriceLookupTimer: null,
  902. addPriceLookupSeq: 0,
  903. selectedCustomerScope: null,
  904. // ===== 发货确认弹窗状态 =====
  905. shipDialogVisible: false,
  906. shipDialogSaving: false,
  907. shipDialogForm: {
  908. site: '',
  909. orderNo: '',
  910. itemNo: null,
  911. status: '',
  912. orderQty: 0,
  913. inspectQty: 0,
  914. inspectApproveQty: 0,
  915. currentShipQty: 0,
  916. canShipQty: 0,
  917. shipQty: 0,
  918. flexid: ''
  919. },
  920. // ===== 打样单收货确认弹窗状态 =====
  921. receiveDialogVisible: false,
  922. receiveDialogSaving: false,
  923. receiveDialogForm: {
  924. id: null,
  925. site: '',
  926. orderNo: '',
  927. itemNo: null,
  928. receiveDate: ''
  929. },
  930. // ===== 主表编辑与列渲染状态 =====
  931. currentRow: null,
  932. // 各列下拉:select 列通过 selectOptionsKey 指向此处;也可在列定义里写 selectOptions 数组 - rqrq
  933. columnSelectOptions: {
  934. poStatusOptions: [], // rqrq - 从全局状态对应表读取
  935. poPartNoOptions: [],
  936. poDepartureOptions: [],
  937. poCustomerOptions: [],
  938. poBuyerOptions: [],
  939. transportOptions: [
  940. { label: '海运 SEA', value: 'SEA' },
  941. { label: '空运 AIR', value: 'AIR' },
  942. { label: '陆运 ROAD', value: 'ROAD' }
  943. ],
  944. yesNoOptions: [
  945. { label: 'Y', value: 'Y' },
  946. { label: 'N', value: 'N' }
  947. ]
  948. },
  949. dictSelectOptionsMap: {},
  950. // 顶部筛选。Customer 仍由上方选择器写入,不选不能查询。
  951. searchData: createPoOrderSearchData(this.$store.state.user.site),
  952. advancedQueryVisible: false,
  953. /** 字段 schema(list 场景) */
  954. fieldSchemaFields: [],
  955. baseColumnList: null,
  956. /** 高级查询条件对象(查询均读取;仅弹窗内「重置」可清空) */
  957. advancedQueryData: createAdvancedQueryData(),
  958. poOrderTypeOptions: PO_ORDER_TYPE_FILTER_OPTIONS,
  959. height: 400,
  960. pageIndex: 1,
  961. pageSize: 20,
  962. totalPage: 0,
  963. dataList: [],
  964. editMode: false,
  965. columnList: [
  966. {
  967. userId: this.$store.state.user.name,
  968. functionId: 812003,
  969. serialNumber: '812003Table1Customer',
  970. tableId: '812003Table1',
  971. tableName: 'PO Order',
  972. columnProp: 'customer',
  973. headerAlign: 'center',
  974. align: 'center',
  975. columnLabel: 'Customer',
  976. columnHidden: false,
  977. columnImage: false,
  978. columnSortable: false,
  979. sortLv: 0,
  980. status: true,
  981. fixed: '',
  982. columnWidth: 90,
  983. showOverflowTooltip: true,
  984. editAble: true,
  985. editType: 'select',
  986. selectOptionsKey: 'poCustomerOptions',
  987. selectOptions: null
  988. },
  989. {
  990. userId: this.$store.state.user.name,
  991. functionId: 812003,
  992. serialNumber: '812003Table1Buyer',
  993. tableId: '812003Table1',
  994. tableName: 'PO Order',
  995. columnProp: 'buyer',
  996. headerAlign: 'center',
  997. align: 'center',
  998. columnLabel: 'Buyer',
  999. columnHidden: false,
  1000. columnImage: false,
  1001. columnSortable: false,
  1002. sortLv: 0,
  1003. status: true,
  1004. fixed: '',
  1005. columnWidth: 90,
  1006. showOverflowTooltip: true,
  1007. editAble: true,
  1008. editType: 'select',
  1009. selectOptionsKey: 'poBuyerOptions',
  1010. selectOptions: null
  1011. },
  1012. {
  1013. userId: this.$store.state.user.name,
  1014. functionId: 812003,
  1015. serialNumber: '812003Table1VendorName',
  1016. tableId: '812003Table1',
  1017. tableName: 'PO Order',
  1018. columnProp: 'supplierName',
  1019. headerAlign: 'center',
  1020. align: 'center',
  1021. columnLabel: 'Vendor Name',
  1022. columnHidden: false,
  1023. columnImage: false,
  1024. columnSortable: false,
  1025. sortLv: 0,
  1026. status: true,
  1027. fixed: '',
  1028. columnWidth: 180,
  1029. showOverflowTooltip: true,
  1030. editAble: false,
  1031. editType: 'select',
  1032. selectOptionsKey: 'supplierOptions',
  1033. selectOptions: null
  1034. },
  1035. {
  1036. userId: this.$store.state.user.name,
  1037. functionId: 812003,
  1038. serialNumber: '812003Table1VShortOffice',
  1039. tableId: '812003Table1',
  1040. tableName: 'PO Order',
  1041. columnProp: 'shortOffice',
  1042. headerAlign: 'center',
  1043. align: 'center',
  1044. columnLabel: 'V_Short_Office',
  1045. columnHidden: false,
  1046. columnImage: false,
  1047. columnSortable: false,
  1048. sortLv: 0,
  1049. status: true,
  1050. fixed: '',
  1051. columnWidth: 110,
  1052. showOverflowTooltip: true,
  1053. editAble: false,
  1054. editType: 'text',
  1055. selectOptionsKey: '',
  1056. selectOptions: null
  1057. },
  1058. {
  1059. userId: this.$store.state.user.name,
  1060. functionId: 812003,
  1061. serialNumber: '812003Table1VShortNpc',
  1062. tableId: '812003Table1',
  1063. tableName: 'PO Order',
  1064. columnProp: 'shortNpc',
  1065. headerAlign: 'center',
  1066. align: 'center',
  1067. columnLabel: 'V_Short_NPC',
  1068. columnHidden: false,
  1069. columnImage: false,
  1070. columnSortable: false,
  1071. sortLv: 0,
  1072. status: true,
  1073. fixed: '',
  1074. columnWidth: 100,
  1075. showOverflowTooltip: true,
  1076. editAble: false,
  1077. editType: 'text',
  1078. selectOptionsKey: '',
  1079. selectOptions: null
  1080. },
  1081. {
  1082. userId: this.$store.state.user.name,
  1083. functionId: 812003,
  1084. serialNumber: '812003Table1PoNo',
  1085. tableId: '812003Table1',
  1086. tableName: 'PO Order',
  1087. columnProp: 'poNo',
  1088. headerAlign: 'center',
  1089. align: 'center',
  1090. columnLabel: 'PO_No',
  1091. columnHidden: false,
  1092. columnImage: false,
  1093. columnSortable: false,
  1094. sortLv: 0,
  1095. status: true,
  1096. fixed: '',
  1097. columnWidth: 120,
  1098. showOverflowTooltip: true,
  1099. editAble: true,
  1100. editType: 'text',
  1101. selectOptionsKey: '',
  1102. selectOptions: null
  1103. },
  1104. {
  1105. userId: this.$store.state.user.name,
  1106. functionId: 812003,
  1107. serialNumber: '812003Table1OrderType',
  1108. tableId: '812003Table1',
  1109. tableName: 'PO Order',
  1110. columnProp: 'orderType',
  1111. headerAlign: 'center',
  1112. align: 'center',
  1113. columnLabel: '订单类型',
  1114. columnHidden: false,
  1115. columnImage: false,
  1116. columnSortable: false,
  1117. sortLv: 0,
  1118. status: true,
  1119. fixed: '',
  1120. columnWidth: 100,
  1121. showOverflowTooltip: true,
  1122. editAble: false,
  1123. editType: 'text',
  1124. selectOptionsKey: '',
  1125. selectOptions: null
  1126. },
  1127. {
  1128. userId: this.$store.state.user.name,
  1129. functionId: 812003,
  1130. serialNumber: '812003Table1PartNo',
  1131. tableId: '812003Table1',
  1132. tableName: 'PO Order',
  1133. columnProp: 'partNo',
  1134. headerAlign: 'center',
  1135. align: 'center',
  1136. columnLabel: 'Part No',
  1137. columnHidden: false,
  1138. columnImage: false,
  1139. columnSortable: false,
  1140. sortLv: 0,
  1141. status: true,
  1142. fixed: '',
  1143. columnWidth: 120,
  1144. showOverflowTooltip: true,
  1145. editAble: false,
  1146. editType: 'select',
  1147. selectOptionsKey: 'poPartNoOptions',
  1148. selectOptions: null
  1149. },
  1150. {
  1151. userId: this.$store.state.user.name,
  1152. functionId: 812003,
  1153. serialNumber: '812003Table1Item',
  1154. tableId: '812003Table1',
  1155. tableName: 'PO Order',
  1156. columnProp: 'item',
  1157. headerAlign: 'center',
  1158. align: 'center',
  1159. columnLabel: 'Item',
  1160. columnHidden: false,
  1161. columnImage: false,
  1162. columnSortable: false,
  1163. sortLv: 0,
  1164. status: true,
  1165. fixed: '',
  1166. columnWidth: 120,
  1167. showOverflowTooltip: true,
  1168. editAble: false,
  1169. editType: 'text',
  1170. selectOptionsKey: '',
  1171. selectOptions: null
  1172. },
  1173. {
  1174. userId: this.$store.state.user.name,
  1175. functionId: 812003,
  1176. serialNumber: '812003Table1Category',
  1177. tableId: '812003Table1',
  1178. tableName: 'PO Order',
  1179. columnProp: 'categoryName',
  1180. headerAlign: 'center',
  1181. align: 'center',
  1182. columnLabel: 'Category',
  1183. columnHidden: false,
  1184. columnImage: false,
  1185. columnSortable: false,
  1186. sortLv: 0,
  1187. status: true,
  1188. fixed: '',
  1189. columnWidth: 90,
  1190. showOverflowTooltip: true,
  1191. editAble: false,
  1192. editType: 'text',
  1193. selectOptionsKey: '',
  1194. selectOptions: null
  1195. },
  1196. {
  1197. userId: this.$store.state.user.name,
  1198. functionId: 812003,
  1199. serialNumber: '812003Table1Sku',
  1200. tableId: '812003Table1',
  1201. tableName: 'PO Order',
  1202. columnProp: 'sku',
  1203. headerAlign: 'center',
  1204. align: 'center',
  1205. columnLabel: 'SKU',
  1206. columnHidden: false,
  1207. columnImage: false,
  1208. columnSortable: false,
  1209. sortLv: 0,
  1210. status: true,
  1211. fixed: '',
  1212. columnWidth: 100,
  1213. showOverflowTooltip: true,
  1214. editAble: false,
  1215. editType: 'text',
  1216. selectOptionsKey: '',
  1217. selectOptions: null
  1218. },
  1219. {
  1220. userId: this.$store.state.user.name,
  1221. functionId: 812003,
  1222. serialNumber: '812003Table1UnitPrice',
  1223. tableId: '812003Table1',
  1224. tableName: 'PO Order',
  1225. columnProp: 'price',
  1226. headerAlign: 'center',
  1227. align: 'center',
  1228. columnLabel: 'Unit Price',
  1229. columnHidden: false,
  1230. columnImage: false,
  1231. columnSortable: false,
  1232. sortLv: 0,
  1233. status: true,
  1234. fixed: '',
  1235. columnWidth: 90,
  1236. showOverflowTooltip: true,
  1237. editAble: true,
  1238. editType: 'num',
  1239. selectOptionsKey: '',
  1240. selectOptions: null
  1241. },
  1242. {
  1243. userId: this.$store.state.user.name,
  1244. functionId: 812003,
  1245. serialNumber: '812003Table1BasePrice',
  1246. tableId: '812003Table1',
  1247. tableName: 'PO Order',
  1248. columnProp: 'basePrice',
  1249. headerAlign: 'center',
  1250. align: 'center',
  1251. columnLabel: '标准价格',
  1252. columnHidden: false,
  1253. columnImage: false,
  1254. columnSortable: false,
  1255. sortLv: 0,
  1256. status: true,
  1257. fixed: '',
  1258. columnWidth: 100,
  1259. showOverflowTooltip: true,
  1260. editAble: false,
  1261. editType: 'num',
  1262. selectOptionsKey: '',
  1263. selectOptions: null
  1264. },
  1265. {
  1266. userId: this.$store.state.user.name,
  1267. functionId: 812003,
  1268. serialNumber: '812003Table1PQty',
  1269. tableId: '812003Table1',
  1270. tableName: 'PO Order',
  1271. columnProp: 'qty',
  1272. headerAlign: 'center',
  1273. align: 'center',
  1274. columnLabel: 'PO Qty',
  1275. columnHidden: false,
  1276. columnImage: false,
  1277. columnSortable: false,
  1278. sortLv: 0,
  1279. status: true,
  1280. fixed: '',
  1281. columnWidth: 80,
  1282. showOverflowTooltip: true,
  1283. editAble: true,
  1284. editType: 'num',
  1285. selectOptionsKey: '',
  1286. selectOptions: null
  1287. },
  1288. {
  1289. userId: this.$store.state.user.name,
  1290. functionId: 812003,
  1291. serialNumber: '812003Table1PValue',
  1292. tableId: '812003Table1',
  1293. tableName: 'PO Order',
  1294. columnProp: 'value',
  1295. headerAlign: 'center',
  1296. align: 'center',
  1297. columnLabel: 'PO Value',
  1298. columnHidden: false,
  1299. columnImage: false,
  1300. columnSortable: false,
  1301. sortLv: 0,
  1302. status: true,
  1303. fixed: '',
  1304. columnWidth: 90,
  1305. showOverflowTooltip: true,
  1306. editAble: false,
  1307. editType: 'num',
  1308. selectOptionsKey: '',
  1309. selectOptions: null
  1310. },
  1311. {
  1312. userId: this.$store.state.user.name,
  1313. functionId: 812003,
  1314. serialNumber: '812003Table1AQty',
  1315. tableId: '812003Table1',
  1316. tableName: 'PO Order',
  1317. columnProp: 'shipQty',
  1318. headerAlign: 'center',
  1319. align: 'center',
  1320. columnLabel: 'A-Qty',
  1321. columnHidden: false,
  1322. columnImage: false,
  1323. columnSortable: false,
  1324. sortLv: 0,
  1325. status: true,
  1326. fixed: '',
  1327. columnWidth: 80,
  1328. showOverflowTooltip: true,
  1329. // A-Qty(c_ship_qty)为检验流程回写字段,按业务要求前端仅展示不可直接改写。
  1330. editAble: false,
  1331. editType: 'text',
  1332. selectOptionsKey: '',
  1333. selectOptions: null
  1334. },
  1335. {
  1336. userId: this.$store.state.user.name,
  1337. functionId: 812003,
  1338. serialNumber: '812003Table1AValue',
  1339. tableId: '812003Table1',
  1340. tableName: 'PO Order',
  1341. columnProp: 'sumPrice',
  1342. headerAlign: 'center',
  1343. align: 'center',
  1344. columnLabel: 'A-Value',
  1345. columnHidden: false,
  1346. columnImage: false,
  1347. columnSortable: false,
  1348. sortLv: 0,
  1349. status: true,
  1350. fixed: '',
  1351. columnWidth: 90,
  1352. showOverflowTooltip: true,
  1353. editAble: true,
  1354. editType: 'text',
  1355. selectOptionsKey: '',
  1356. selectOptions: null
  1357. },
  1358. {
  1359. userId: this.$store.state.user.name,
  1360. functionId: 812003,
  1361. serialNumber: '812003Table1PDeparture',
  1362. tableId: '812003Table1',
  1363. tableName: 'PO Order',
  1364. columnProp: 'departure',
  1365. headerAlign: 'center',
  1366. align: 'center',
  1367. columnLabel: 'Departure Port',
  1368. columnHidden: false,
  1369. columnImage: false,
  1370. columnSortable: false,
  1371. sortLv: 0,
  1372. status: true,
  1373. fixed: '',
  1374. columnWidth: 100,
  1375. showOverflowTooltip: true,
  1376. editAble: true,
  1377. editType: 'select',
  1378. selectOptionsKey: 'departureOptions',
  1379. selectOptions: null
  1380. },
  1381. {
  1382. userId: this.$store.state.user.name,
  1383. functionId: 812003,
  1384. serialNumber: '812003Table1PDestination',
  1385. tableId: '812003Table1',
  1386. tableName: 'PO Order',
  1387. columnProp: 'destination',
  1388. headerAlign: 'center',
  1389. align: 'center',
  1390. columnLabel: 'Destination Port',
  1391. columnHidden: false,
  1392. columnImage: false,
  1393. columnSortable: false,
  1394. sortLv: 0,
  1395. status: true,
  1396. fixed: '',
  1397. columnWidth: 110,
  1398. showOverflowTooltip: true,
  1399. editAble: true,
  1400. editType: 'select',
  1401. selectOptionsKey: 'destinationOptions',
  1402. selectOptions: null
  1403. },
  1404. {
  1405. userId: this.$store.state.user.name,
  1406. functionId: 812003,
  1407. serialNumber: '812003Table1SMethod',
  1408. tableId: '812003Table1',
  1409. tableName: 'PO Order',
  1410. columnProp: 'shipVia',
  1411. headerAlign: 'center',
  1412. align: 'center',
  1413. columnLabel: 'Method',
  1414. columnHidden: false,
  1415. columnImage: false,
  1416. columnSortable: false,
  1417. sortLv: 0,
  1418. status: true,
  1419. fixed: '',
  1420. columnWidth: 90,
  1421. showOverflowTooltip: true,
  1422. editAble: true,
  1423. editType: 'select',
  1424. selectOptionsKey: 'transportOptions',
  1425. selectOptions: null
  1426. },
  1427. {
  1428. userId: this.$store.state.user.name,
  1429. functionId: 812003,
  1430. serialNumber: '812003Table1DIssue',
  1431. tableId: '812003Table1',
  1432. tableName: 'PO Order',
  1433. columnProp: 'orderDate',
  1434. headerAlign: 'center',
  1435. align: 'center',
  1436. columnLabel: 'Buyer Release Date',
  1437. columnHidden: false,
  1438. columnImage: false,
  1439. columnSortable: false,
  1440. sortLv: 0,
  1441. status: true,
  1442. fixed: '',
  1443. columnWidth: 130,
  1444. showOverflowTooltip: true,
  1445. editAble: false,
  1446. editType: 'date',
  1447. selectOptionsKey: '',
  1448. selectOptions: null
  1449. },
  1450. {
  1451. userId: this.$store.state.user.name,
  1452. functionId: 812003,
  1453. serialNumber: '812003Table1DEnquiry',
  1454. tableId: '812003Table1',
  1455. tableName: 'PO Order',
  1456. columnProp: 'enquiry',
  1457. headerAlign: 'center',
  1458. align: 'center',
  1459. columnLabel: 'Planner Release Date',
  1460. columnHidden: false,
  1461. columnImage: false,
  1462. columnSortable: false,
  1463. sortLv: 0,
  1464. status: true,
  1465. fixed: '',
  1466. columnWidth: 140,
  1467. showOverflowTooltip: true,
  1468. editAble: false,
  1469. editType: 'date',
  1470. selectOptionsKey: '',
  1471. selectOptions: null
  1472. },
  1473. {
  1474. userId: this.$store.state.user.name,
  1475. functionId: 812003,
  1476. serialNumber: '812003Table1Status',
  1477. tableId: '812003Table1',
  1478. tableName: 'PO Order',
  1479. columnProp: 'status',
  1480. headerAlign: 'center',
  1481. align: 'center',
  1482. columnLabel: 'Status',
  1483. columnHidden: false,
  1484. columnImage: false,
  1485. columnSortable: false,
  1486. sortLv: 0,
  1487. status: true,
  1488. fixed: '',
  1489. columnWidth: 80,
  1490. showOverflowTooltip: true,
  1491. editAble: false,
  1492. editType: 'select',
  1493. selectOptionsKey: 'poStatusOptions',
  1494. selectOptions: null
  1495. },
  1496. {
  1497. userId: this.$store.state.user.name,
  1498. functionId: 812003,
  1499. serialNumber: '812003Table1DConfirmed',
  1500. tableId: '812003Table1',
  1501. tableName: 'PO Order',
  1502. columnProp: 'confirmed',
  1503. headerAlign: 'center',
  1504. align: 'center',
  1505. columnLabel: 'PI Confirmed Date',
  1506. columnHidden: false,
  1507. columnImage: false,
  1508. columnSortable: false,
  1509. sortLv: 0,
  1510. status: true,
  1511. fixed: '',
  1512. columnWidth: 120,
  1513. showOverflowTooltip: true,
  1514. editAble: true,
  1515. editType: 'date',
  1516. selectOptionsKey: '',
  1517. selectOptions: null
  1518. },
  1519. {
  1520. userId: this.$store.state.user.name,
  1521. functionId: 812003,
  1522. serialNumber: '812003Table1DNeed',
  1523. tableId: '812003Table1',
  1524. tableName: 'PO Order',
  1525. columnProp: 'wantReceiveDate',
  1526. headerAlign: 'center',
  1527. align: 'center',
  1528. columnLabel: 'Original Arrival Date',
  1529. columnHidden: false,
  1530. columnImage: false,
  1531. columnSortable: false,
  1532. sortLv: 0,
  1533. status: true,
  1534. fixed: '',
  1535. columnWidth: 130,
  1536. showOverflowTooltip: true,
  1537. editAble: true,
  1538. editType: 'date',
  1539. selectOptionsKey: '',
  1540. selectOptions: null
  1541. },
  1542. {
  1543. userId: this.$store.state.user.name,
  1544. functionId: 812003,
  1545. serialNumber: '812003Table1DNarrival',
  1546. tableId: '812003Table1',
  1547. tableName: 'PO Order',
  1548. columnProp: 'narrival',
  1549. headerAlign: 'center',
  1550. align: 'center',
  1551. columnLabel: 'Final Confirmed Arrival Date',
  1552. columnHidden: false,
  1553. columnImage: false,
  1554. columnSortable: false,
  1555. sortLv: 0,
  1556. status: true,
  1557. fixed: '',
  1558. columnWidth: 110,
  1559. showOverflowTooltip: true,
  1560. editAble: true,
  1561. editType: 'date',
  1562. selectOptionsKey: '',
  1563. selectOptions: null
  1564. },
  1565. {
  1566. userId: this.$store.state.user.name,
  1567. functionId: 812003,
  1568. serialNumber: '812003Table1DCrd',
  1569. tableId: '812003Table1',
  1570. tableName: 'PO Order',
  1571. columnProp: 'crd',
  1572. headerAlign: 'center',
  1573. align: 'center',
  1574. columnLabel: 'PI Confirmed CRD',
  1575. columnHidden: false,
  1576. columnImage: false,
  1577. columnSortable: false,
  1578. sortLv: 0,
  1579. status: true,
  1580. fixed: '',
  1581. columnWidth: 120,
  1582. showOverflowTooltip: true,
  1583. editAble: true,
  1584. editType: 'date',
  1585. selectOptionsKey: '',
  1586. selectOptions: null
  1587. },
  1588. {
  1589. userId: this.$store.state.user.name,
  1590. functionId: 812003,
  1591. serialNumber: '812003Table1DCrdOri',
  1592. tableId: '812003Table1',
  1593. tableName: 'PO Order',
  1594. columnProp: 'crdOri',
  1595. headerAlign: 'center',
  1596. align: 'center',
  1597. columnLabel: 'Original CRD',
  1598. columnHidden: false,
  1599. columnImage: false,
  1600. columnSortable: false,
  1601. sortLv: 0,
  1602. status: true,
  1603. fixed: '',
  1604. columnWidth: 120,
  1605. showOverflowTooltip: true,
  1606. editAble: false,
  1607. editType: 'date',
  1608. selectOptionsKey: '',
  1609. selectOptions: null
  1610. },
  1611. {
  1612. userId: this.$store.state.user.name,
  1613. functionId: 812003,
  1614. serialNumber: '812003Table1DInspection',
  1615. tableId: '812003Table1',
  1616. tableName: 'PO Order',
  1617. columnProp: 'inspection',
  1618. headerAlign: 'center',
  1619. align: 'center',
  1620. columnLabel: 'Inspection Date',
  1621. columnHidden: false,
  1622. columnImage: false,
  1623. columnSortable: false,
  1624. sortLv: 0,
  1625. status: true,
  1626. fixed: '',
  1627. columnWidth: 100,
  1628. showOverflowTooltip: true,
  1629. editAble: true,
  1630. editType: 'date',
  1631. selectOptionsKey: '',
  1632. selectOptions: null
  1633. },
  1634. {
  1635. userId: this.$store.state.user.name,
  1636. functionId: 812003,
  1637. serialNumber: '812003Table1ACrd',
  1638. tableId: '812003Table1',
  1639. tableName: 'PO Order',
  1640. columnProp: 'realCrd',
  1641. headerAlign: 'center',
  1642. align: 'center',
  1643. columnLabel: 'Actual Completion Date',
  1644. columnHidden: false,
  1645. columnImage: false,
  1646. columnSortable: false,
  1647. sortLv: 0,
  1648. status: true,
  1649. fixed: '',
  1650. columnWidth: 150,
  1651. showOverflowTooltip: true,
  1652. editAble: true,
  1653. editType: 'date',
  1654. selectOptionsKey: '',
  1655. selectOptions: null
  1656. },
  1657. {
  1658. userId: this.$store.state.user.name,
  1659. functionId: 812003,
  1660. serialNumber: '812003Table1Eta',
  1661. tableId: '812003Table1',
  1662. tableName: 'PO Order',
  1663. columnProp: 'eta',
  1664. headerAlign: 'center',
  1665. align: 'center',
  1666. columnLabel: 'ETA',
  1667. columnHidden: false,
  1668. columnImage: false,
  1669. columnSortable: false,
  1670. sortLv: 0,
  1671. status: true,
  1672. fixed: '',
  1673. columnWidth: 100,
  1674. showOverflowTooltip: true,
  1675. editAble: false,
  1676. editType: 'date',
  1677. selectOptionsKey: '',
  1678. selectOptions: null
  1679. },
  1680. {
  1681. userId: this.$store.state.user.name,
  1682. functionId: 812003,
  1683. serialNumber: '812003Table1Flexid',
  1684. tableId: '812003Table1',
  1685. tableName: 'PO Order',
  1686. columnProp: 'flexid',
  1687. headerAlign: 'center',
  1688. align: 'center',
  1689. columnLabel: 'Flexport Id',
  1690. columnHidden: false,
  1691. columnImage: false,
  1692. columnSortable: false,
  1693. sortLv: 0,
  1694. status: true,
  1695. fixed: '',
  1696. columnWidth: 90,
  1697. showOverflowTooltip: true,
  1698. editAble: true,
  1699. editType: 'text',
  1700. selectOptionsKey: '',
  1701. selectOptions: null
  1702. },
  1703. {
  1704. userId: this.$store.state.user.name,
  1705. functionId: 812003,
  1706. serialNumber: '812003Table1AObd',
  1707. tableId: '812003Table1',
  1708. tableName: 'PO Order',
  1709. columnProp: 'obd',
  1710. headerAlign: 'center',
  1711. align: 'center',
  1712. columnLabel: 'On Board Date',
  1713. columnHidden: false,
  1714. columnImage: false,
  1715. columnSortable: false,
  1716. sortLv: 0,
  1717. status: true,
  1718. fixed: '',
  1719. columnWidth: 100,
  1720. showOverflowTooltip: true,
  1721. editAble: true,
  1722. editType: 'date',
  1723. selectOptionsKey: '',
  1724. selectOptions: null
  1725. },
  1726. {
  1727. userId: this.$store.state.user.name,
  1728. functionId: 812003,
  1729. serialNumber: '812003Table1DocSent',
  1730. tableId: '812003Table1',
  1731. tableName: 'PO Order',
  1732. columnProp: 'docSent',
  1733. headerAlign: 'center',
  1734. align: 'center',
  1735. columnLabel: 'Doc Sent',
  1736. columnHidden: false,
  1737. columnImage: false,
  1738. columnSortable: false,
  1739. sortLv: 0,
  1740. status: true,
  1741. fixed: '',
  1742. columnWidth: 90,
  1743. showOverflowTooltip: true,
  1744. editAble: true,
  1745. editType: 'select',
  1746. selectOptionsKey: 'yesNoOptions',
  1747. selectOptions: null
  1748. },
  1749. {
  1750. userId: this.$store.state.user.name,
  1751. functionId: 812003,
  1752. serialNumber: '812003Table1TelexRelease',
  1753. tableId: '812003Table1',
  1754. tableName: 'PO Order',
  1755. columnProp: 'telexRelease',
  1756. headerAlign: 'center',
  1757. align: 'center',
  1758. columnLabel: 'Telex Release',
  1759. columnHidden: false,
  1760. columnImage: false,
  1761. columnSortable: false,
  1762. sortLv: 0,
  1763. status: true,
  1764. fixed: '',
  1765. columnWidth: 100,
  1766. showOverflowTooltip: true,
  1767. editAble: true,
  1768. editType: 'select',
  1769. selectOptionsKey: 'yesNoOptions',
  1770. selectOptions: null
  1771. },
  1772. {
  1773. userId: this.$store.state.user.name,
  1774. functionId: 812003,
  1775. serialNumber: '812003Table1AdvancePayment',
  1776. tableId: '812003Table1',
  1777. tableName: 'PO Order',
  1778. columnProp: 'advancePayment',
  1779. headerAlign: 'center',
  1780. align: 'center',
  1781. columnLabel: 'Advance Payment',
  1782. columnHidden: false,
  1783. columnImage: false,
  1784. columnSortable: false,
  1785. sortLv: 0,
  1786. status: true,
  1787. fixed: '',
  1788. columnWidth: 120,
  1789. showOverflowTooltip: true,
  1790. editAble: true,
  1791. editType: 'text',
  1792. selectOptionsKey: '',
  1793. selectOptions: null
  1794. },
  1795. {
  1796. userId: this.$store.state.user.name,
  1797. functionId: 812003,
  1798. serialNumber: '812003Table1AdvancePaid',
  1799. tableId: '812003Table1',
  1800. tableName: 'PO Order',
  1801. columnProp: 'advancePaid',
  1802. headerAlign: 'center',
  1803. align: 'center',
  1804. columnLabel: 'Advanc Paid',
  1805. columnHidden: false,
  1806. columnImage: false,
  1807. columnSortable: false,
  1808. sortLv: 0,
  1809. status: true,
  1810. fixed: '',
  1811. columnWidth: 100,
  1812. showOverflowTooltip: true,
  1813. editAble: true,
  1814. editType: 'select',
  1815. selectOptionsKey: 'yesNoOptions',
  1816. selectOptions: null
  1817. },
  1818. {
  1819. userId: this.$store.state.user.name,
  1820. functionId: 812003,
  1821. serialNumber: '812003Table1DCreate',
  1822. tableId: '812003Table1',
  1823. tableName: 'PO Order',
  1824. columnProp: 'createTime',
  1825. headerAlign: 'center',
  1826. align: 'center',
  1827. columnLabel: 'Create Date',
  1828. columnHidden: false,
  1829. columnImage: false,
  1830. columnSortable: false,
  1831. sortLv: 0,
  1832. status: true,
  1833. fixed: '',
  1834. columnWidth: 100,
  1835. showOverflowTooltip: true,
  1836. editAble: false,
  1837. editType: 'date',
  1838. selectOptionsKey: '',
  1839. selectOptions: null
  1840. },
  1841. {
  1842. userId: this.$store.state.user.name,
  1843. functionId: 812003,
  1844. serialNumber: '812003Table1MPlanner',
  1845. tableId: '812003Table1',
  1846. tableName: 'PO Order',
  1847. columnProp: 'planner',
  1848. headerAlign: 'center',
  1849. align: 'center',
  1850. columnLabel: 'M-Planner',
  1851. columnHidden: false,
  1852. columnImage: false,
  1853. columnSortable: false,
  1854. sortLv: 0,
  1855. status: true,
  1856. fixed: '',
  1857. columnWidth: 100,
  1858. showOverflowTooltip: true,
  1859. editAble: true,
  1860. editType: 'text',
  1861. selectOptionsKey: '',
  1862. selectOptions: null
  1863. },
  1864. {
  1865. userId: this.$store.state.user.name,
  1866. functionId: 812003,
  1867. serialNumber: '812003Table1DEdit',
  1868. tableId: '812003Table1',
  1869. tableName: 'PO Order',
  1870. columnProp: 'edit',
  1871. headerAlign: 'center',
  1872. align: 'center',
  1873. columnLabel: 'Edit Date',
  1874. columnHidden: false,
  1875. columnImage: false,
  1876. columnSortable: false,
  1877. sortLv: 0,
  1878. status: true,
  1879. fixed: '',
  1880. columnWidth: 100,
  1881. showOverflowTooltip: true,
  1882. editAble: false,
  1883. editType: 'date',
  1884. selectOptionsKey: '',
  1885. selectOptions: null
  1886. },
  1887. {
  1888. userId: this.$store.state.user.name,
  1889. functionId: 812003,
  1890. serialNumber: '812003Table1EPlanner',
  1891. tableId: '812003Table1',
  1892. tableName: 'PO Order',
  1893. columnProp: 'endPlanner',
  1894. headerAlign: 'center',
  1895. align: 'center',
  1896. columnLabel: 'Last Editor',
  1897. columnHidden: false,
  1898. columnImage: false,
  1899. columnSortable: false,
  1900. sortLv: 0,
  1901. status: true,
  1902. fixed: '',
  1903. columnWidth: 100,
  1904. showOverflowTooltip: true,
  1905. editAble: false,
  1906. editType: 'text',
  1907. selectOptionsKey: '',
  1908. selectOptions: null
  1909. },
  1910. {
  1911. userId: this.$store.state.user.name,
  1912. functionId: 812003,
  1913. serialNumber: '812003Table1RemarkDelay',
  1914. tableId: '812003Table1',
  1915. tableName: 'PO Order',
  1916. columnProp: 'remarkDelay',
  1917. headerAlign: 'center',
  1918. align: 'center',
  1919. columnLabel: 'Remark Delay',
  1920. columnHidden: false,
  1921. columnImage: false,
  1922. columnSortable: false,
  1923. sortLv: 0,
  1924. status: true,
  1925. fixed: '',
  1926. columnWidth: 110,
  1927. showOverflowTooltip: true,
  1928. editAble: true,
  1929. editType: 'text',
  1930. selectOptionsKey: '',
  1931. selectOptions: null
  1932. },
  1933. {
  1934. userId: this.$store.state.user.name,
  1935. functionId: 812003,
  1936. serialNumber: '812003Table1Comments',
  1937. tableId: '812003Table1',
  1938. tableName: 'PO Order',
  1939. columnProp: 'remark',
  1940. headerAlign: 'center',
  1941. align: 'center',
  1942. columnLabel: 'Comments',
  1943. columnHidden: false,
  1944. columnImage: false,
  1945. columnSortable: false,
  1946. sortLv: 0,
  1947. status: true,
  1948. fixed: '',
  1949. columnWidth: 180,
  1950. showOverflowTooltip: true,
  1951. editAble: true,
  1952. editType: 'text',
  1953. selectOptionsKey: '',
  1954. selectOptions: null
  1955. },
  1956. {
  1957. userId: this.$store.state.user.name,
  1958. functionId: 812003,
  1959. serialNumber: '812003Table1InspectionCompletedQty',
  1960. tableId: '812003Table1',
  1961. tableName: 'PO Order',
  1962. columnProp: 'inspectionCompletedQty',
  1963. headerAlign: 'center',
  1964. align: 'center',
  1965. columnLabel: 'Inspection Completed Qty',
  1966. columnHidden: false,
  1967. columnImage: false,
  1968. columnSortable: false,
  1969. sortLv: 0,
  1970. status: true,
  1971. fixed: '',
  1972. columnWidth: 140,
  1973. showOverflowTooltip: true,
  1974. editAble: false,
  1975. editType: 'text',
  1976. selectOptionsKey: '',
  1977. selectOptions: null
  1978. }
  1979. ]
  1980. }
  1981. },
  1982. computed: {
  1983. visibleColumns () {
  1984. const source = this.baseColumnList || this.columnList
  1985. const applied = applyFieldSchemaToColumns(source, this.fieldSchemaFields)
  1986. const cols = applied.filter(c => !c.columnHidden)
  1987. const leadProps = ['poNo', 'status', 'orderType']
  1988. const leading = leadProps.map(p => cols.find(c => c.columnProp === p)).filter(Boolean)
  1989. const rest = cols.filter(c => !leadProps.includes(c.columnProp))
  1990. return [...leading, ...rest]
  1991. },
  1992. addExtFields () {
  1993. return getEditableExtFieldsFromSchema(this.addFormSchemaFields)
  1994. },
  1995. addDetailExtFields () {
  1996. return this.addExtFields
  1997. },
  1998. addBaseFields () {
  1999. if (!Array.isArray(this.addFormSchemaFields)) {
  2000. return []
  2001. }
  2002. const sortedFields = this.addFormSchemaFields
  2003. .filter(f => f && f.visibleFlag === 'Y' && !this.isExtSchemaField(f) && this.getAddFieldCode(f) !== 'crd_ori' && this.getAddFieldCode(f) !== 'base_price')
  2004. .slice()
  2005. .sort((a, b) => {
  2006. const sa = Number(a && a.sortNo)
  2007. const sb = Number(b && b.sortNo)
  2008. const left = Number.isFinite(sa) ? sa : Number.MAX_SAFE_INTEGER
  2009. const right = Number.isFinite(sb) ? sb : Number.MAX_SAFE_INTEGER
  2010. return left - right
  2011. })
  2012. const tailFields = []
  2013. const normalFields = []
  2014. sortedFields.forEach(field => {
  2015. if (ADD_FULL_ROW_FIELD_CODES.has(this.getAddFieldCode(field))) {
  2016. tailFields.push(field)
  2017. return
  2018. }
  2019. normalFields.push(field)
  2020. })
  2021. return [...normalFields, ...tailFields]
  2022. },
  2023. addMasterBaseFields () {
  2024. return this.addBaseFields.filter(field => this.isAddMasterField(field))
  2025. },
  2026. addDetailBaseFields () {
  2027. return this.addBaseFields.filter(field => !this.isAddMasterField(field))
  2028. },
  2029. addDetailTableFields () {
  2030. const merged = []
  2031. const seen = new Set()
  2032. const pushField = (field) => {
  2033. if (!field) {
  2034. return
  2035. }
  2036. const code = this.getAddFieldCode(field)
  2037. if (!code || seen.has(code)) {
  2038. return
  2039. }
  2040. seen.add(code)
  2041. merged.push({
  2042. ...field,
  2043. fieldLabel: field.fieldLabel || this.getAddTableColumnLabel(code, code)
  2044. })
  2045. }
  2046. this.addDetailBaseFields.forEach(pushField)
  2047. this.addDetailExtFields.forEach(pushField)
  2048. return merged
  2049. },
  2050. hasSelectedAddDetailRow () {
  2051. if (!this.addDetailCurrentDraftId) {
  2052. return false
  2053. }
  2054. return this.addDetailRows.some(row => row && row._draftId === this.addDetailCurrentDraftId)
  2055. },
  2056. addDetailDialogTitle () {
  2057. if (this.addDetailDialogMode === 'edit') {
  2058. return '修改明细'
  2059. }
  2060. if (this.addDetailDialogMode === 'copy') {
  2061. return '复制明细'
  2062. }
  2063. return '新增明细'
  2064. }
  2065. },
  2066. created () {
  2067. this.baseColumnList = JSON.parse(JSON.stringify(this.columnList))
  2068. this.getPartNoOptions()
  2069. this.getSupplierOptions()
  2070. this.getCustomerOptions()
  2071. this.getBuyerOptions()
  2072. },
  2073. mounted () {
  2074. this.updateTableHeight()
  2075. window.addEventListener('resize', this.onWindowResize)
  2076. },
  2077. activated () {
  2078. this.updateTableHeight()
  2079. this.refreshTableLayout()
  2080. },
  2081. deactivated () {
  2082. this.refreshTableLayout()
  2083. },
  2084. beforeDestroy () {
  2085. window.removeEventListener('resize', this.onWindowResize)
  2086. if (this.addPriceLookupTimer) {
  2087. clearTimeout(this.addPriceLookupTimer)
  2088. this.addPriceLookupTimer = null
  2089. }
  2090. },
  2091. /**
  2092. * 方法实现区
  2093. * 维护建议:
  2094. * 1) 查询链路(handleSearch/getDataList/buildQueryRequest)改动需同步检查高级查询;
  2095. * 2) schema相关方法改动需同步检查新增主弹窗+明细弹窗;
  2096. * 3) 选择器回填(getEamData/applySupplierSelection/applySelectedPartToTarget)改动要验证联动字段;
  2097. * 4) 状态流转(handleIssue/Ship/Close/Open)改动要校验按钮显隐与后端规则一致。
  2098. */
  2099. methods: {
  2100. canIssuePoOrder,
  2101. canShipPoOrder,
  2102. canReceivePoOrder,
  2103. canClosePoOrder,
  2104. canOpenPoOrder,
  2105. canEditPoColumnByStatus,
  2106. onWindowResize () {
  2107. this.updateTableHeight()
  2108. },
  2109. updateTableHeight () {
  2110. // 主表按可视区动态高度计算,扣除分页与底部预留,避免超出或留白 - rqrq
  2111. this.$nextTick(() => {
  2112. const pageRootEl = this.$refs.pageRoot || this.$el
  2113. const tableVm = this.$refs.poTable
  2114. const tableEl = tableVm && tableVm.$el
  2115. if (!pageRootEl || !tableEl) {
  2116. return
  2117. }
  2118. const pagerVm = this.$refs.mainPager
  2119. const pagerEl = (pagerVm && pagerVm.$el) || pageRootEl.querySelector('.el-pagination')
  2120. let pagerOuterHeight = 0
  2121. if (pagerEl) {
  2122. const pagerRect = pagerEl.getBoundingClientRect()
  2123. const pagerStyle = window.getComputedStyle(pagerEl)
  2124. pagerOuterHeight = pagerRect.height +
  2125. (parseFloat(pagerStyle.marginTop) || 0) +
  2126. (parseFloat(pagerStyle.marginBottom) || 0)
  2127. }
  2128. const rootStyle = window.getComputedStyle(pageRootEl)
  2129. const rootPaddingBottom = parseFloat(rootStyle.paddingBottom) || 0
  2130. const tableTop = tableEl.getBoundingClientRect().top
  2131. const viewportBottomGap = 16
  2132. const availableHeight = window.innerHeight - tableTop - pagerOuterHeight - rootPaddingBottom - viewportBottomGap
  2133. const nextHeight = Number.isFinite(availableHeight) ? Math.floor(availableHeight) : 240
  2134. this.height = nextHeight > 240 ? nextHeight : 240
  2135. this.refreshTableLayout()
  2136. })
  2137. },
  2138. refreshTableLayout () {
  2139. this.$nextTick(() => {
  2140. if (this.$refs.poTable && this.$refs.poTable.doLayout) {
  2141. this.$refs.poTable.doLayout()
  2142. }
  2143. })
  2144. },
  2145. formatColumnCell (row, item) {
  2146. // rqrq - 仅改变显示,原始 row.status 继续供按钮和保存逻辑使用。
  2147. if (item.columnProp === 'status') return this.formatPoStatus(row)
  2148. if (item.columnProp === 'orderType') {
  2149. return formatPoOrderTypeLabel(row.orderType)
  2150. }
  2151. const prop = item && item.columnProp
  2152. if (!prop || !row) {
  2153. return ''
  2154. }
  2155. let value
  2156. if (row[prop] !== undefined && row[prop] !== null) {
  2157. value = row[prop]
  2158. } else if (row.extValues && typeof row.extValues === 'object' &&
  2159. Object.prototype.hasOwnProperty.call(row.extValues, prop)) {
  2160. value = row.extValues[prop]
  2161. } else {
  2162. return ''
  2163. }
  2164. // 标准价格等数值列去尾零,空值保持空白
  2165. if (prop === 'basePrice') {
  2166. return this.formatNumberDisplay(value)
  2167. }
  2168. return value
  2169. },
  2170. /**
  2171. * 数值展示去尾零。空值返回空字符串,避免把 null 显示成 0。
  2172. */
  2173. formatNumberDisplay (value) {
  2174. if (value === null || value === undefined || value === '') {
  2175. return ''
  2176. }
  2177. const num = Number(value)
  2178. if (Number.isNaN(num)) {
  2179. return value
  2180. }
  2181. if (Number.isInteger(num)) {
  2182. return String(num)
  2183. }
  2184. return String(num).replace(/(\.\d*?[1-9])0+$/, '$1').replace(/\.0+$/, '')
  2185. },
  2186. /** Chooselist 选择列 */
  2187. isChooserEditColumn (columnProp) {
  2188. return this.chooserEditColumnProps.includes(columnProp)
  2189. },
  2190. /**
  2191. * 当前行该列是否可编辑:列配置 editAble + 状态限制(Part No、Vendor Name、Customer、Buyer、PO_No 草稿/已下达)
  2192. */
  2193. canEditCell (row, item) {
  2194. if (!this.editMode || !item) return false
  2195. const prop = item.columnProp
  2196. if (prop === 'customer') return false
  2197. if (this.displayOnlyColumnProps.includes(prop)) return false
  2198. if (this.isChooserEditColumn(prop)) {
  2199. return canEditPoColumnByStatus(row.status, prop)
  2200. }
  2201. if (!item.editAble) return false
  2202. return canEditPoColumnByStatus(row.status, prop)
  2203. },
  2204. getAddFieldCode (field) {
  2205. if (!field) return ''
  2206. if (field.fieldCode) {
  2207. return String(field.fieldCode).trim().toLowerCase()
  2208. }
  2209. return this.camelToSnake(this.getAddFieldProp(field))
  2210. },
  2211. getAddFieldProp (field) {
  2212. if (!field) return ''
  2213. if (field.fieldProp) {
  2214. return String(field.fieldProp).trim()
  2215. }
  2216. if (field.fieldCode) {
  2217. return this.snakeToCamel(field.fieldCode)
  2218. }
  2219. return ''
  2220. },
  2221. isExtSchemaField (field) {
  2222. const code = this.getAddFieldCode(field)
  2223. return code.indexOf('ext_') === 0
  2224. },
  2225. normalizeAddFieldLabel (field) {
  2226. return String((field && field.fieldLabel) || '').trim().toLowerCase().replace(/\s+/g, ' ')
  2227. },
  2228. isAddCreateDateField (field) {
  2229. const code = this.getAddFieldCode(field)
  2230. if (ADD_READONLY_DEFAULT_TODAY_FIELD_CODES.has(code)) {
  2231. return true
  2232. }
  2233. return this.normalizeAddFieldLabel(field) === 'create date'
  2234. },
  2235. isAddPoPlaceDateField (field) {
  2236. const code = this.getAddFieldCode(field)
  2237. if (ADD_EDITABLE_DEFAULT_TODAY_FIELD_CODES.has(code)) {
  2238. return true
  2239. }
  2240. return this.normalizeAddFieldLabel(field) === 'po place date'
  2241. },
  2242. isAddMasterField (field) {
  2243. const code = this.getAddFieldCode(field)
  2244. if (ADD_FORCE_DETAIL_FIELD_CODES.has(code)) {
  2245. return false
  2246. }
  2247. const mandatoryFlag = String((field && field.mandatoryFlag) || '').trim().toUpperCase()
  2248. if (mandatoryFlag === 'Y') {
  2249. return true
  2250. }
  2251. // 与 PO_No 同口径:优先走字段元数据分层,不做单字段特判。
  2252. const bizLevel = String((field && field.bizLevel) || '').trim().toUpperCase()
  2253. if (bizLevel === 'HEADER') {
  2254. return true
  2255. }
  2256. // VIRTUAL 中位于 Part No 之前的字段(如供应商简称)归入主记录区。
  2257. if (bizLevel === 'VIRTUAL') {
  2258. const virtualSortNo = Number(field && field.sortNo)
  2259. const partField = this.getSchemaFieldByCode('part_no')
  2260. const partSortNo = Number(partField && partField.sortNo)
  2261. if (Number.isFinite(virtualSortNo) && Number.isFinite(partSortNo) && virtualSortNo < partSortNo) {
  2262. return true
  2263. }
  2264. }
  2265. return false
  2266. },
  2267. getSchemaFieldByCode (fieldCode) {
  2268. const normalizedCode = String(fieldCode || '').trim().toLowerCase()
  2269. if (!normalizedCode || !Array.isArray(this.addFormSchemaFields)) {
  2270. return null
  2271. }
  2272. return this.addFormSchemaFields.find(field => this.getAddFieldCode(field) === normalizedCode) || null
  2273. },
  2274. getAddTableColumnLabel (fieldCode, fallback) {
  2275. const field = this.getSchemaFieldByCode(fieldCode)
  2276. return (field && field.fieldLabel) || fallback || fieldCode
  2277. },
  2278. getAddDetailTableColumnAlign (field) {
  2279. if (this.isAddNumberField(field)) {
  2280. return 'right'
  2281. }
  2282. if (this.isAddDateField(field)) {
  2283. return 'center'
  2284. }
  2285. return 'left'
  2286. },
  2287. getAddDetailTableColumnWidth (field) {
  2288. const code = this.getAddFieldCode(field)
  2289. if (ADD_FULL_ROW_FIELD_CODES.has(code)) {
  2290. return 220
  2291. }
  2292. if (this.isAddDateField(field)) {
  2293. return 140
  2294. }
  2295. if (this.isAddNumberField(field)) {
  2296. return 120
  2297. }
  2298. if (code === 'part_no') {
  2299. return 150
  2300. }
  2301. return 140
  2302. },
  2303. getAddDetailTableCellDisplay (row, field) {
  2304. if (!row || !field) {
  2305. return ''
  2306. }
  2307. const code = this.getAddFieldCode(field)
  2308. let value = ''
  2309. if (this.isExtSchemaField(field)) {
  2310. value = this.getFormExtValue(row, code)
  2311. } else {
  2312. const prop = this.getAddFieldProp(field)
  2313. value = prop ? row[prop] : ''
  2314. }
  2315. if (value === null || value === undefined || value === '') {
  2316. return ''
  2317. }
  2318. if (this.isAddDateField(field)) {
  2319. if (value instanceof Date) {
  2320. const pad = (num) => String(num).padStart(2, '0')
  2321. return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`
  2322. }
  2323. const text = String(value)
  2324. return text.length >= 10 ? text.substring(0, 10) : text
  2325. }
  2326. if (this.isAddNumberField(field)) {
  2327. const normalized = this.normalizeAddNumericValue(value)
  2328. if (normalized !== '') {
  2329. return normalized
  2330. }
  2331. }
  2332. return value
  2333. },
  2334. snakeToCamel (text) {
  2335. return String(text || '').replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase())
  2336. },
  2337. camelToSnake (text) {
  2338. return String(text || '').replace(/([A-Z])/g, '_$1').toLowerCase().replace(/^_/, '')
  2339. },
  2340. isAddChooserField (field) {
  2341. return ADD_CHOOSER_FIELD_CODES.has(this.getAddFieldCode(field))
  2342. },
  2343. openAddChooserByField (field, target = 'master') {
  2344. const code = this.getAddFieldCode(field)
  2345. if (code === 'buyer') {
  2346. this.openAddBuyerSelect(target)
  2347. } else if (code === 'supplier_name') {
  2348. this.openAddSupplierSelect(target)
  2349. } else if (code === 'part_no') {
  2350. this.openAddPartNoSelect(target)
  2351. } else if (code === 'departure') {
  2352. this.openAddDepartureSelect(target)
  2353. } else if (code === 'destination') {
  2354. this.openAddDestinationSelect(target)
  2355. } else if (code === 'ship_via') {
  2356. this.openAddShipViaSelect(target)
  2357. }
  2358. },
  2359. getAddChooserPlaceholder (field) {
  2360. const code = this.getAddFieldCode(field)
  2361. if (code === 'buyer') return '请选择 Buyer'
  2362. if (code === 'supplier_name') return '请选择供应商'
  2363. if (code === 'part_no') return '请选择物料'
  2364. if (code === 'departure') return '请选择始发港'
  2365. if (code === 'destination') return '请选择目的港'
  2366. if (code === 'ship_via') return '请选择运输方式'
  2367. return ''
  2368. },
  2369. getAddFieldSelectOptions (field) {
  2370. const code = this.getAddFieldCode(field)
  2371. const optionsKey = ADD_SELECT_OPTIONS_FIELD_CODE_MAP[code]
  2372. if (optionsKey) {
  2373. if (Array.isArray(this[optionsKey])) {
  2374. return this[optionsKey]
  2375. }
  2376. if (this.columnSelectOptions && Array.isArray(this.columnSelectOptions[optionsKey])) {
  2377. return this.columnSelectOptions[optionsKey]
  2378. }
  2379. }
  2380. if (this.isAddDictSelectField(field)) {
  2381. const dictType = String((field && field.dictType) || '').trim()
  2382. if (!dictType) {
  2383. return []
  2384. }
  2385. return this.addDictSelectOptionsMap[dictType] || []
  2386. }
  2387. return []
  2388. },
  2389. isAddDictSelectField (field) {
  2390. const editorType = String((field && field.editorType) || '').trim().toLowerCase()
  2391. return editorType === 'dict-select' || editorType === 'dict_select'
  2392. },
  2393. isAddSelectField (field) {
  2394. return this.isAddDictSelectField(field) || this.getAddFieldSelectOptions(field).length > 0
  2395. },
  2396. isAddFilterableSelectField (field) {
  2397. return ADD_FILTERABLE_SELECT_FIELD_CODES.has(this.getAddFieldCode(field))
  2398. },
  2399. isAddDateField (field) {
  2400. const editorType = String((field && field.editorType) || '').trim().toLowerCase()
  2401. const dataType = String((field && field.dataType) || '').trim().toLowerCase()
  2402. return editorType === 'date' || editorType === 'datetime' || dataType === 'date' || dataType === 'datetime'
  2403. },
  2404. isAddTextareaField (field) {
  2405. return ADD_TEXTAREA_FIELD_CODES.has(this.getAddFieldCode(field))
  2406. },
  2407. isAddNumberField (field) {
  2408. const code = this.getAddFieldCode(field)
  2409. if (ADD_NUMBER_FIELD_CODES.has(code)) {
  2410. return true
  2411. }
  2412. const dataType = String((field && field.dataType) || '').trim().toLowerCase()
  2413. return dataType === 'number' || dataType === 'num' || dataType === 'decimal' || dataType === 'int'
  2414. },
  2415. isAddFieldDisabled (field) {
  2416. const code = this.getAddFieldCode(field)
  2417. if (code === 'customer') {
  2418. return true
  2419. }
  2420. if (this.isAddCreateDateField(field)) {
  2421. return true
  2422. }
  2423. if (ADD_DISPLAY_ONLY_FIELD_CODES.has(code)) {
  2424. return true
  2425. }
  2426. const editorType = String((field && field.editorType) || '').trim().toLowerCase()
  2427. return editorType === 'readonly'
  2428. },
  2429. getAddFieldSpan (field) {
  2430. if (ADD_FULL_ROW_FIELD_CODES.has(this.getAddFieldCode(field))) {
  2431. return 24
  2432. }
  2433. return this.isAddTextareaField(field) ? 12 : 6
  2434. },
  2435. onAddFieldInput (field, target = 'master') {
  2436. const code = this.getAddFieldCode(field)
  2437. if (code === 'price' || code === 'qty') {
  2438. this.recalcAddFormValue(target)
  2439. }
  2440. if (code === 'qty') {
  2441. this.scheduleAutoFillAddPriceByTierPrice(target)
  2442. }
  2443. },
  2444. getAddTargetForm (target = 'master') {
  2445. return target === 'detail' ? this.addDetailForm : this.addForm
  2446. },
  2447. getSupplierCodeForTargetForm (form, target = 'master') {
  2448. const formSupplier = String((form && form.supplierNo) || '').trim()
  2449. if (formSupplier) {
  2450. return formSupplier
  2451. }
  2452. if (target === 'detail') {
  2453. return String((this.addForm && this.addForm.supplierNo) || '').trim()
  2454. }
  2455. return ''
  2456. },
  2457. scheduleAutoFillAddPriceByTierPrice (target = 'master') {
  2458. if (this.addPriceLookupTimer) {
  2459. clearTimeout(this.addPriceLookupTimer)
  2460. this.addPriceLookupTimer = null
  2461. }
  2462. this.addPriceLookupTimer = setTimeout(() => {
  2463. this.addPriceLookupTimer = null
  2464. this.autoFillAddPriceByTierPrice(target)
  2465. }, 250)
  2466. },
  2467. autoFillAddPriceByTierPrice (target = 'master') {
  2468. if (!this.addDialogVisible) {
  2469. return Promise.resolve()
  2470. }
  2471. const targetForm = this.getAddTargetForm(target)
  2472. if (!targetForm) {
  2473. return Promise.resolve()
  2474. }
  2475. const site = (this.searchData.site || this.$store.state.user.site || '').trim()
  2476. const supplierCode = this.getSupplierCodeForTargetForm(targetForm, target)
  2477. const partNo = String(targetForm.partNo || '').trim()
  2478. const qtyVal = targetForm.qty
  2479. if (!site || !supplierCode || !partNo || qtyVal === '' || qtyVal === null || qtyVal === undefined) {
  2480. return Promise.resolve()
  2481. }
  2482. const qty = Number(qtyVal)
  2483. if (Number.isNaN(qty) || qty < 0) {
  2484. return Promise.resolve()
  2485. }
  2486. const seq = ++this.addPriceLookupSeq
  2487. return listPoCurrentTierPrice({
  2488. site,
  2489. supplierCode,
  2490. partNo
  2491. }).then(({ data }) => {
  2492. if (seq !== this.addPriceLookupSeq) {
  2493. return
  2494. }
  2495. if (!(data && data.code === 0)) {
  2496. return
  2497. }
  2498. const matchedRow = this.findCurrentTierPriceByQty(data.rows || [], qty)
  2499. if (!matchedRow) {
  2500. return
  2501. }
  2502. const normalizedPrice = this.normalizeAddNumericValue(matchedRow.unitPrice)
  2503. if (normalizedPrice === '') {
  2504. return
  2505. }
  2506. this.$set(targetForm, 'price', normalizedPrice)
  2507. this.recalcAddFormValue(target)
  2508. }).catch(() => {})
  2509. },
  2510. findCurrentTierPriceByQty (rows, qty) {
  2511. if (!Array.isArray(rows) || rows.length === 0) {
  2512. return null
  2513. }
  2514. const qtyNum = Number(qty)
  2515. if (Number.isNaN(qtyNum)) {
  2516. return null
  2517. }
  2518. for (const row of rows) {
  2519. const start = Number(row.qtyStart)
  2520. const endRaw = row.qtyEnd
  2521. const end = (endRaw === '' || endRaw === null || endRaw === undefined)
  2522. ? Number.POSITIVE_INFINITY
  2523. : Number(endRaw)
  2524. if (Number.isNaN(start) || Number.isNaN(end)) {
  2525. continue
  2526. }
  2527. if (qtyNum >= start && qtyNum <= end) {
  2528. return row
  2529. }
  2530. }
  2531. return null
  2532. },
  2533. normalizeAddNumericValue (value) {
  2534. if (value === '' || value === null || value === undefined) {
  2535. return ''
  2536. }
  2537. const num = Number(value)
  2538. if (Number.isNaN(num)) {
  2539. return ''
  2540. }
  2541. if (Number.isInteger(num)) {
  2542. return String(num)
  2543. }
  2544. return String(Number(num.toFixed(4)))
  2545. },
  2546. handleClosePoOrder (row) {
  2547. const params = buildPoDetailActionParams(row, this.$store.state.user.site)
  2548. if (!params.id && !(params.orderNo && params.site && params.itemNo != null)) {
  2549. this.$message.error('无法识别订单行,请刷新后重试')
  2550. return
  2551. }
  2552. const poLabel = row.poNo ? `PO ${row.poNo}` : '该订单'
  2553. const itemLabel = row.itemNo != null ? ` 行 ${row.itemNo}` : ''
  2554. this.$confirm(`确定关闭${poLabel}${itemLabel}?`, '提示', { type: 'warning' }).then(() => {
  2555. closePoDetail(params).then(({ data }) => {
  2556. if (data && data.code === 0) {
  2557. this.$message.success('关闭成功')
  2558. this.getDataList()
  2559. } else {
  2560. this.$message.error((data && data.msg) || '关闭失败')
  2561. }
  2562. }).catch(err => {
  2563. this.$message.error((err && err.message) || '关闭失败')
  2564. })
  2565. }).catch(() => {})
  2566. },
  2567. handleIssuePoOrder (row) {
  2568. const params = buildPoDetailActionParams(row, this.$store.state.user.site)
  2569. if (!params.id && !(params.orderNo && params.site && params.itemNo != null)) {
  2570. this.$message.error('无法识别订单行,请刷新后重试')
  2571. return
  2572. }
  2573. const poLabel = row.poNo ? `PO ${row.poNo}` : '该订单'
  2574. const itemLabel = row.itemNo != null ? ` 行 ${row.itemNo}` : ''
  2575. this.$confirm(`确定下达${poLabel}${itemLabel}?`, '提示', { type: 'warning' }).then(() => {
  2576. issuePoDetail(params).then(({ data }) => {
  2577. if (data && data.code === 0) {
  2578. this.$message.success('下达成功')
  2579. this.getDataList()
  2580. } else {
  2581. this.$message.error((data && data.msg) || '下达失败')
  2582. }
  2583. }).catch(err => {
  2584. this.$message.error((err && err.message) || '下达失败')
  2585. })
  2586. }).catch(() => {})
  2587. },
  2588. /**
  2589. * 生成发货弹窗默认模型。
  2590. * 说明:所有数量字段默认按 0 初始化,避免出现 null 导致的显示/比较异常。
  2591. */
  2592. createEmptyShipDialogForm () {
  2593. return {
  2594. site: '',
  2595. orderNo: '',
  2596. itemNo: null,
  2597. status: '',
  2598. orderQty: 0,
  2599. inspectQty: 0,
  2600. inspectApproveQty: 0,
  2601. currentShipQty: 0,
  2602. canShipQty: 0,
  2603. shipQty: 0,
  2604. flexid: ''
  2605. }
  2606. },
  2607. /**
  2608. * 关闭发货弹窗时统一重置状态,避免上一次缓存数据污染下一次操作。
  2609. */
  2610. resetShipDialog () {
  2611. this.shipDialogSaving = false
  2612. this.shipDialogForm = this.createEmptyShipDialogForm()
  2613. },
  2614. /**
  2615. * 发货弹窗只读数量显示格式化。
  2616. * 规则:null/空字符串显示为0,其余保持原值,避免出现 "undefined"。
  2617. */
  2618. formatShipDialogDisplay (value) {
  2619. if (value === null || value === undefined || value === '') {
  2620. return '0'
  2621. }
  2622. return String(value)
  2623. },
  2624. /**
  2625. * 将发货弹窗数值输入统一转换为 Number。
  2626. * 规则:空值返回 NaN,便于后续统一走前端校验提示。
  2627. */
  2628. normalizeShipDialogNumber (value) {
  2629. if (value === '' || value === null || value === undefined) {
  2630. return Number.NaN
  2631. }
  2632. const num = Number(value)
  2633. return Number.isFinite(num) ? num : Number.NaN
  2634. },
  2635. /**
  2636. * 点击 shipped:
  2637. * 1) 先按 site + orderNo + itemNo 查询后端实时快照;
  2638. * 2) 弹出发货确认框并回填默认值(本次发货数量=可发货数量);
  2639. * 3) 由用户确认后再提交发货。
  2640. */
  2641. handleShipPoOrder (row) {
  2642. const params = buildPoDetailActionParams(row, this.$store.state.user.site)
  2643. if (!params.orderNo || !params.site || params.itemNo == null) {
  2644. this.$message.error('无法识别订单行,请刷新后重试')
  2645. return
  2646. }
  2647. shipPoDetailPreview({
  2648. site: params.site,
  2649. orderNo: params.orderNo,
  2650. itemNo: params.itemNo
  2651. }).then(({ data }) => {
  2652. if (!(data && data.code === 0 && data.data)) {
  2653. this.$message.error((data && data.msg) || '加载发货数据失败')
  2654. return
  2655. }
  2656. const preview = data.data
  2657. this.shipDialogForm = {
  2658. site: preview.site || params.site,
  2659. orderNo: preview.orderNo || params.orderNo,
  2660. itemNo: preview.itemNo != null ? preview.itemNo : params.itemNo,
  2661. status: preview.status || '',
  2662. orderQty: preview.orderQty != null ? Number(preview.orderQty) : 0,
  2663. inspectQty: preview.inspectQty != null ? Number(preview.inspectQty) : 0,
  2664. inspectApproveQty: preview.inspectApproveQty != null ? Number(preview.inspectApproveQty) : 0,
  2665. currentShipQty: preview.currentShipQty != null ? Number(preview.currentShipQty) : 0,
  2666. canShipQty: preview.canShipQty != null ? Number(preview.canShipQty) : 0,
  2667. shipQty: preview.shipQty != null ? Number(preview.shipQty) : 0
  2668. }
  2669. this.shipDialogVisible = true
  2670. }).catch(err => {
  2671. this.$message.error((err && err.message) || '加载发货数据失败')
  2672. })
  2673. },
  2674. /**
  2675. * 提交发货确认:
  2676. * 1) 仅校验本次发货数量 > 0 且 <= 未发货数量;
  2677. * 2) 提交后端回写 qty / c_ship_qty / status;
  2678. * 3) 成功后关闭弹窗并刷新列表。
  2679. */
  2680. submitShipDialog () {
  2681. const orderQty = this.normalizeShipDialogNumber(this.shipDialogForm.orderQty)
  2682. const unshippedQty = this.normalizeShipDialogNumber(this.shipDialogForm.canShipQty)
  2683. const shipQty = this.normalizeShipDialogNumber(this.shipDialogForm.shipQty)
  2684. if (!Number.isFinite(shipQty) || shipQty <= 0) {
  2685. this.$message.error('本次发货数量必须大于0')
  2686. return
  2687. }
  2688. if (!Number.isFinite(unshippedQty) || shipQty > unshippedQty) {
  2689. this.$message.error('本次发货数量不能大于未发货数量')
  2690. return
  2691. }
  2692. const payload = {
  2693. site: this.shipDialogForm.site,
  2694. orderNo: this.shipDialogForm.orderNo,
  2695. itemNo: this.shipDialogForm.itemNo,
  2696. orderQty,
  2697. shipQty,
  2698. flexid: (this.shipDialogForm.flexid || '').trim()
  2699. }
  2700. this.shipDialogSaving = true
  2701. shipPoDetail(payload).then(({ data }) => {
  2702. this.shipDialogSaving = false
  2703. if (data && data.code === 0) {
  2704. this.$message.success('发货成功')
  2705. this.shipDialogVisible = false
  2706. this.getDataList()
  2707. } else {
  2708. this.$message.error((data && data.msg) || '发货失败')
  2709. }
  2710. }).catch(err => {
  2711. this.shipDialogSaving = false
  2712. this.$message.error((err && err.message) || '发货失败')
  2713. })
  2714. },
  2715. /**
  2716. * 当天日期字符串(yyyy-MM-dd),收货日期默认值用。
  2717. */
  2718. getTodayDateStr () {
  2719. const d = new Date()
  2720. const month = String(d.getMonth() + 1).padStart(2, '0')
  2721. const day = String(d.getDate()).padStart(2, '0')
  2722. return d.getFullYear() + '-' + month + '-' + day
  2723. },
  2724. /**
  2725. * 点击收货(仅打样单+已下达):
  2726. * 1) 校验行标识后打开收货确认弹窗,收货日期默认当天;
  2727. * 2) 确认后由后端同事务回写 c_po_actual_ready_date、PO 转待验货并自动生成已排程验货申请。
  2728. */
  2729. handleReceivePoOrder (row) {
  2730. const params = buildPoDetailActionParams(row, this.$store.state.user.site)
  2731. if (!params.id && !(params.orderNo && params.site && params.itemNo != null)) {
  2732. this.$message.error('无法识别订单行,请刷新后重试')
  2733. return
  2734. }
  2735. this.receiveDialogForm = {
  2736. id: params.id != null ? params.id : null,
  2737. site: params.site,
  2738. orderNo: params.orderNo,
  2739. itemNo: params.itemNo,
  2740. receiveDate: this.getTodayDateStr()
  2741. }
  2742. this.receiveDialogVisible = true
  2743. },
  2744. /**
  2745. * 关闭收货弹窗时重置状态,避免上次缓存污染下一次操作。
  2746. */
  2747. resetReceiveDialog () {
  2748. this.receiveDialogSaving = false
  2749. this.receiveDialogForm = {
  2750. id: null,
  2751. site: '',
  2752. orderNo: '',
  2753. itemNo: null,
  2754. receiveDate: ''
  2755. }
  2756. },
  2757. /**
  2758. * 提交收货:仅校验收货日期必填;成功后提示并刷新列表(状态已联动为待验货)。
  2759. */
  2760. submitReceiveDialog () {
  2761. if (!this.receiveDialogForm.receiveDate) {
  2762. this.$message.error('请选择收货日期')
  2763. return
  2764. }
  2765. const payload = {
  2766. id: this.receiveDialogForm.id != null ? this.receiveDialogForm.id : undefined,
  2767. site: this.receiveDialogForm.site,
  2768. orderNo: this.receiveDialogForm.orderNo,
  2769. itemNo: this.receiveDialogForm.itemNo,
  2770. receiveDate: this.receiveDialogForm.receiveDate
  2771. }
  2772. this.receiveDialogSaving = true
  2773. receivePoDetail(payload).then(({ data }) => {
  2774. this.receiveDialogSaving = false
  2775. if (data && data.code === 0) {
  2776. this.$message.success('收货成功,已生成验货申请')
  2777. this.receiveDialogVisible = false
  2778. this.getDataList()
  2779. } else {
  2780. this.$message.error((data && data.msg) || '收货失败')
  2781. }
  2782. }).catch(err => {
  2783. this.receiveDialogSaving = false
  2784. this.$message.error((err && err.message) || '收货失败')
  2785. })
  2786. },
  2787. handleOpenPoOrder (row) {
  2788. const params = buildPoDetailActionParams(row, this.$store.state.user.site)
  2789. if (!params.id && !(params.orderNo && params.site && params.itemNo != null)) {
  2790. this.$message.error('无法识别订单行,请刷新后重试')
  2791. return
  2792. }
  2793. const poLabel = row.poNo ? `PO ${row.poNo}` : '该订单'
  2794. const itemLabel = row.itemNo != null ? ` 行 ${row.itemNo}` : ''
  2795. const targetStatus = resolvePoOrderStatusByInspectQty(row)
  2796. this.$confirm(`确定打开${poLabel}${itemLabel}?恢复状态为:${targetStatus}`, '提示', { type: 'warning' }).then(() => {
  2797. openPoDetail(params).then(({ data }) => {
  2798. if (data && data.code === 0) {
  2799. this.$message.success('打开成功')
  2800. this.getDataList()
  2801. } else {
  2802. this.$message.error((data && data.msg) || '打开失败')
  2803. }
  2804. }).catch(err => {
  2805. this.$message.error((err && err.message) || '打开失败')
  2806. })
  2807. }).catch(() => {})
  2808. },
  2809. /**
  2810. * 表格当前行变化:将选中行深拷贝到 currentRow;取消选中时为 null - rqrq
  2811. */
  2812. onTableCurrentChange (row) {
  2813. if (!row) {
  2814. this.currentRow = null
  2815. return
  2816. }
  2817. this.currentRow = row
  2818. },
  2819. /**
  2820. * 解析列对应的下拉选项:优先列上 selectOptions,其次 columnSelectOptions[selectOptionsKey]
  2821. */
  2822. getSelectOptionsForColumn (item) {
  2823. if (item && item.editType === 'dict-select') {
  2824. const dictType = this.getSchemaDictType(item)
  2825. if (!dictType) {
  2826. return []
  2827. }
  2828. return this.dictSelectOptionsMap[dictType] || []
  2829. }
  2830. if (item.selectOptions && item.selectOptions.length) {
  2831. return item.selectOptions
  2832. }
  2833. const key = item.selectOptionsKey
  2834. if (key && this.columnSelectOptions[key]) {
  2835. return this.columnSelectOptions[key]
  2836. }
  2837. return []
  2838. },
  2839. getSchemaDictType (item) {
  2840. if (!item) {
  2841. return ''
  2842. }
  2843. if (item.dictType) {
  2844. return String(item.dictType).trim()
  2845. }
  2846. const prop = item.columnProp
  2847. if (!prop) {
  2848. return ''
  2849. }
  2850. const field = (this.fieldSchemaFields || []).find(f => {
  2851. const code = String((f && f.fieldCode) || '').trim()
  2852. const fieldProp = String((f && f.fieldProp) || '').trim()
  2853. return fieldProp === prop || this.snakeToCamel(code) === prop
  2854. })
  2855. return field && field.dictType ? String(field.dictType).trim() : ''
  2856. },
  2857. preloadDictSelectOptions (schemaFields) {
  2858. const site = this.searchData.site || this.$store.state.user.site
  2859. if (!site || !Array.isArray(schemaFields) || schemaFields.length === 0) {
  2860. this.dictSelectOptionsMap = {}
  2861. return Promise.resolve()
  2862. }
  2863. const dictTypeSet = new Set()
  2864. schemaFields.forEach(field => {
  2865. const editorType = String((field && field.editorType) || '').trim().toLowerCase()
  2866. if (editorType !== 'dict-select' && editorType !== 'dict_select') {
  2867. return
  2868. }
  2869. const dictType = String((field && field.dictType) || '').trim()
  2870. if (dictType) {
  2871. dictTypeSet.add(dictType)
  2872. }
  2873. })
  2874. const dictTypes = Array.from(dictTypeSet)
  2875. if (dictTypes.length === 0) {
  2876. this.dictSelectOptionsMap = {}
  2877. return Promise.resolve()
  2878. }
  2879. const nextMap = {}
  2880. const loaders = dictTypes.map(dictType => {
  2881. return selectDictDataList({
  2882. site,
  2883. dictType,
  2884. dictTypeList: [],
  2885. status: 'Y'
  2886. }).then(({ data }) => {
  2887. if (data && data.code === 0) {
  2888. nextMap[dictType] = (data.rows || []).map(item => ({
  2889. label: item.dictLabel || item.dictValue,
  2890. value: item.dictValue
  2891. }))
  2892. } else {
  2893. nextMap[dictType] = []
  2894. this.$message.error((data && data.msg) || `字典加载失败: ${dictType}`)
  2895. }
  2896. }).catch(() => {
  2897. nextMap[dictType] = []
  2898. this.$message.error(`字典加载失败: ${dictType}`)
  2899. })
  2900. })
  2901. return Promise.all(loaders).then(() => {
  2902. this.dictSelectOptionsMap = nextMap
  2903. })
  2904. },
  2905. preloadAddDictSelectOptions (schemaFields) {
  2906. const site = this.searchData.site || this.$store.state.user.site
  2907. if (!site || !Array.isArray(schemaFields) || schemaFields.length === 0) {
  2908. this.addDictSelectOptionsMap = {}
  2909. return Promise.resolve()
  2910. }
  2911. const dictTypeSet = new Set()
  2912. schemaFields.forEach(field => {
  2913. if (!this.isAddDictSelectField(field)) {
  2914. return
  2915. }
  2916. const dictType = String((field && field.dictType) || '').trim()
  2917. if (dictType) {
  2918. dictTypeSet.add(dictType)
  2919. }
  2920. })
  2921. const dictTypes = Array.from(dictTypeSet)
  2922. if (dictTypes.length === 0) {
  2923. this.addDictSelectOptionsMap = {}
  2924. return Promise.resolve()
  2925. }
  2926. const nextMap = {}
  2927. const loaders = dictTypes.map(dictType => {
  2928. return selectDictDataList({
  2929. site,
  2930. dictType,
  2931. dictTypeList: [],
  2932. status: 'Y'
  2933. }).then(({ data }) => {
  2934. if (data && data.code === 0) {
  2935. nextMap[dictType] = (data.rows || []).map(item => ({
  2936. label: item.dictLabel || item.dictValue,
  2937. value: item.dictValue
  2938. }))
  2939. } else {
  2940. nextMap[dictType] = []
  2941. this.$message.error((data && data.msg) || `字典加载失败: ${dictType}`)
  2942. }
  2943. }).catch(() => {
  2944. nextMap[dictType] = []
  2945. this.$message.error(`字典加载失败: ${dictType}`)
  2946. })
  2947. })
  2948. return Promise.all(loaders).then(() => {
  2949. this.addDictSelectOptionsMap = nextMap
  2950. })
  2951. },
  2952. buildQueryRequest() {
  2953. return buildPoOrderQueryParams({
  2954. searchData: this.searchData,
  2955. advancedQueryData: this.advancedQueryData,
  2956. page: this.pageIndex,
  2957. limit: this.pageSize
  2958. })
  2959. },
  2960. onSessionCustomerChange (customer, customerOption) {
  2961. this.searchData.customer = customer
  2962. this.selectedCustomerScope = customerOption || null
  2963. this.dictSelectOptionsMap = {}
  2964. this.advancedQueryData.rows = []
  2965. this.getBuyerOptions(customer)
  2966. this.pageIndex = 1
  2967. this.masterRows = []
  2968. this.dataList = []
  2969. this.totalPage = 0
  2970. if (!customer) {
  2971. this.selectedCustomerScope = null
  2972. this.fieldSchemaFields = []
  2973. this.advancedQueryData.rows = []
  2974. this.poBuyerOptions = []
  2975. this.columnSelectOptions.poBuyerOptions = []
  2976. this.refreshTableLayout()
  2977. return
  2978. }
  2979. this.loadFieldSchema(customer).then(() => {
  2980. this.getDataList()
  2981. })
  2982. },
  2983. loadFieldSchema (customer) {
  2984. return getPoFieldSchema({
  2985. site: this.searchData.site,
  2986. customer,
  2987. scene: 'list'
  2988. }).then(({ data }) => {
  2989. if (data && data.code === 0 && data.data) {
  2990. this.fieldSchemaFields = data.data.fields || []
  2991. const queryFields = getAdvancedQueryFieldsFromSchema(this.fieldSchemaFields)
  2992. const nextAdvanced = createAdvancedQueryDataFromSchema(queryFields)
  2993. this.advancedQueryData.rows = nextAdvanced.rows
  2994. return this.preloadDictSelectOptions(this.fieldSchemaFields)
  2995. } else {
  2996. this.fieldSchemaFields = []
  2997. this.advancedQueryData.rows = []
  2998. this.$message.error((data && data.msg) || '加载字段权限失败')
  2999. }
  3000. }).then(() => {
  3001. this.refreshTableLayout()
  3002. }).catch(() => {
  3003. this.fieldSchemaFields = []
  3004. this.advancedQueryData.rows = []
  3005. this.$message.error('加载字段权限失败')
  3006. this.refreshTableLayout()
  3007. })
  3008. },
  3009. handleSearch() {
  3010. if (!this.searchData.customer) {
  3011. this.$message.warning('请先选择 Customer')
  3012. return
  3013. }
  3014. this.pageIndex = 1
  3015. this.getDataList()
  3016. },
  3017. openEamList (tagNo, strVal = '', conSql = '', context = 'row', pickField = '') {
  3018. this.eamTagNo = tagNo
  3019. this.pickContext = context
  3020. this.eamPickField = pickField
  3021. this.$nextTick(() => {
  3022. this.$refs.eamList.init(tagNo, strVal, conSql)
  3023. })
  3024. },
  3025. resetEamPick () {
  3026. this.pickContext = ''
  3027. this.eamTagNo = ''
  3028. this.eamPickField = ''
  3029. this.currentSelectRow = null
  3030. this.currentPartNoRow = null
  3031. this.currentDepartureRow = null
  3032. this.currentDestinationRow = null
  3033. this.currentShipViaRow = null
  3034. },
  3035. openSearchBaseList (val) {
  3036. let strVal = ''
  3037. let conSql = ''
  3038. if (val === 520) {
  3039. strVal = this.searchData.supplierNo || ''
  3040. conSql = " and supplier_no <> '' "
  3041. } else if (val === 2017) {
  3042. strVal = this.searchData.partNo || ''
  3043. conSql = " and part_no <> '' "
  3044. }
  3045. this.openEamList(val, strVal, conSql, 'search')
  3046. },
  3047. getEamData (data) {
  3048. if (!data) {
  3049. return
  3050. }
  3051. const tag = this.eamTagNo
  3052. const ctx = this.pickContext
  3053. if (ctx === 'search') {
  3054. if (tag === 520) {
  3055. this.searchData.supplierNo = data.supplier_no || data.code || ''
  3056. this.searchData.supplierName = data.supplier_name || data.name || ''
  3057. } else if (tag === 2017) {
  3058. this.searchData.partNo = data.part_no || data.code || ''
  3059. }
  3060. this.resetEamPick()
  3061. return
  3062. }
  3063. if (tag === SUPPLIER_CHOOSELIST_TAG || tag === 520) {
  3064. const { supplierNo, supplierName } = parseSupplierChooselistRow(data)
  3065. if (ctx === 'add') {
  3066. this.fillSupplierShortFields(this.addForm, supplierNo, supplierName, false, 'add').then(() => {
  3067. this.scheduleAutoFillAddPriceByTierPrice('master')
  3068. })
  3069. } else if (ctx === 'addDetail') {
  3070. this.fillSupplierShortFields(this.addDetailForm, supplierNo, supplierName, false, 'addDetail').then(() => {
  3071. this.scheduleAutoFillAddPriceByTierPrice('detail')
  3072. })
  3073. } else if (this.currentSelectRow) {
  3074. const row = this.currentSelectRow
  3075. this.fillSupplierShortFields(row, supplierNo, supplierName, true)
  3076. }
  3077. this.resetEamPick()
  3078. return
  3079. }
  3080. if (tag === 507 || tag === 2017) {
  3081. const partNo = data.part_no || data.partNo || data.code || ''
  3082. if (ctx === 'add') {
  3083. this.$set(this.addForm, 'partNo', partNo)
  3084. this.fillPartCategorySku(partNo, this.addForm)
  3085. this.scheduleAutoFillAddPriceByTierPrice('master')
  3086. } else if (ctx === 'addDetail') {
  3087. this.$set(this.addDetailForm, 'partNo', partNo)
  3088. this.fillPartCategorySku(partNo, this.addDetailForm)
  3089. this.scheduleAutoFillAddPriceByTierPrice('detail')
  3090. } else if (this.currentPartNoRow) {
  3091. this.$set(this.currentPartNoRow, 'partNo', partNo)
  3092. this.fillPartCategorySku(partNo, this.currentPartNoRow)
  3093. this.$set(this.currentPartNoRow, 'changeFlag', 1)
  3094. }
  3095. this.resetEamPick()
  3096. return
  3097. }
  3098. if (tag === 2018) {
  3099. const code = this.eamPickField === 'destination'
  3100. ? (data.port_code || data.portCode || data.destination || '')
  3101. : (data.port_code || data.portCode || data.departure || '')
  3102. const portName = data.port_name || data.portName || ''
  3103. if (ctx === 'add') {
  3104. if (this.eamPickField === 'departure') {
  3105. this.addForm.departure = code
  3106. } else if (this.eamPickField === 'destination') {
  3107. this.addForm.destination = code
  3108. }
  3109. } else if (ctx === 'addDetail') {
  3110. if (this.eamPickField === 'departure') {
  3111. this.addDetailForm.departure = code
  3112. } else if (this.eamPickField === 'destination') {
  3113. this.addDetailForm.destination = code
  3114. }
  3115. } else if (this.eamPickField === 'departure' && this.currentDepartureRow) {
  3116. this.$set(this.currentDepartureRow, 'departure', code)
  3117. this.$set(this.currentDepartureRow, 'departureName', portName)
  3118. this.$set(this.currentDepartureRow, 'changeFlag', 1)
  3119. } else if (this.eamPickField === 'destination' && this.currentDestinationRow) {
  3120. this.$set(this.currentDestinationRow, 'destination', code)
  3121. this.$set(this.currentDestinationRow, 'destinationName', portName)
  3122. this.$set(this.currentDestinationRow, 'changeFlag', 1)
  3123. }
  3124. this.resetEamPick()
  3125. return
  3126. }
  3127. if (tag === 2019) {
  3128. const via = data.method_desc || data.methodDesc || data.shipVia || ''
  3129. if (ctx === 'add') {
  3130. this.addForm.shipVia = via
  3131. } else if (ctx === 'addDetail') {
  3132. this.addDetailForm.shipVia = via
  3133. } else if (this.currentShipViaRow) {
  3134. this.$set(this.currentShipViaRow, 'shipVia', via)
  3135. this.$set(this.currentShipViaRow, 'shipViaCode', data.method_no || data.methodNo || '')
  3136. this.$set(this.currentShipViaRow, 'changeFlag', 1)
  3137. }
  3138. this.resetEamPick()
  3139. }
  3140. },
  3141. getDataList() {
  3142. if (!this.searchData.customer) {
  3143. this.loading = false
  3144. this.dataList = []
  3145. this.masterRows = []
  3146. this.totalPage = 0
  3147. this.refreshTableLayout()
  3148. return
  3149. }
  3150. this.loading = true
  3151. const { params, useAdvanced } = this.buildQueryRequest()
  3152. const request = useAdvanced ? searchPoDetailAdvancedPage(params) : searchPoDetailPage(params)
  3153. request.then(({ data }) => {
  3154. if (data.code === 0) {
  3155. const list = (data.page && data.page.list ? data.page.list : []).map(row => normalizeSchemaRowValues(row))
  3156. this.dataList = list
  3157. this.masterRows = list.map(row => ({
  3158. ...row,
  3159. changeFlag: 0
  3160. }))
  3161. this.pageIndex = data.page.currPage
  3162. this.pageSize = data.page.pageSize
  3163. this.totalPage = data.page.totalCount
  3164. } else {
  3165. this.$message.error((data && data.msg) || '获取列表失败')
  3166. }
  3167. this.loading = false
  3168. this.refreshTableLayout()
  3169. }).catch(() => {
  3170. this.loading = false
  3171. this.$message.error('请求失败')
  3172. this.refreshTableLayout()
  3173. })
  3174. },
  3175. sizeChangeHandle (val) {
  3176. this.pageSize = val
  3177. this.pageIndex = 1
  3178. this.getDataList()
  3179. },
  3180. currentChangeHandle (val) {
  3181. this.pageIndex = val
  3182. this.getDataList()
  3183. },
  3184. onCellChange (row) {
  3185. if (row.price !== undefined || row.qty !== undefined) {
  3186. this.$set(row, 'value', this.calcPoValue(row.price, row.qty))
  3187. }
  3188. this.$set(row, 'changeFlag', 1)
  3189. },
  3190. calcPoValue (price, qty) {
  3191. if (price === '' || price == null || qty === '' || qty == null) {
  3192. return ''
  3193. }
  3194. const p = Number(price)
  3195. const q = Number(qty)
  3196. if (isNaN(p) || isNaN(q)) {
  3197. return ''
  3198. }
  3199. const total = p * q
  3200. return Number.isInteger(total) ? String(total) : String(Number(total.toFixed(4)))
  3201. },
  3202. recalcAddFormValue (target = 'master') {
  3203. const form = this.getAddTargetForm(target)
  3204. if (!form) {
  3205. return
  3206. }
  3207. this.$set(form, 'value', this.calcPoValue(form.price, form.qty))
  3208. },
  3209. validatePriceAndQty (price, qty, label) {
  3210. if (price === '' || price == null) {
  3211. this.$message.warning((label ? label + ':' : '') + '请填写 Unit Price')
  3212. return false
  3213. }
  3214. if (qty === '' || qty == null) {
  3215. this.$message.warning((label ? label + ':' : '') + '请填写 PO Qty')
  3216. return false
  3217. }
  3218. return true
  3219. },
  3220. handleSupplierChange(row, supplierNo) {
  3221. console.log('供应商变更:', supplierNo, '行ID:', row.id)
  3222. const selectedOption = this.supplierOptions.find(opt => opt.value === supplierNo)
  3223. if (selectedOption) {
  3224. this.$set(row, 'supplierName', selectedOption.label)
  3225. this.$set(row, 'supplierNo', selectedOption.value)
  3226. this.$set(row, 'shortOffice', selectedOption.shortOffice || '')
  3227. this.$set(row, 'shortNpc', selectedOption.shortNpc || '')
  3228. this.$set(row, 'changeFlag', 1)
  3229. }
  3230. },
  3231. handlePartNoChange(row, partNo) {
  3232. console.log('物料变更:', partNo, '行ID:', row.id)
  3233. // 根据 partNo 找到对应的物料信息
  3234. const selectedOption = this.poPartNoOptions.find(opt => opt.value === partNo)
  3235. if (selectedOption) {
  3236. // 更新物料相关信息
  3237. this.$set(row, 'partNo', selectedOption.value)
  3238. this.$set(row, 'item', selectedOption.item || '')
  3239. //同时更新 category 和 sku
  3240. this.$set(row, 'category', selectedOption.category || '')
  3241. this.$set(row, 'categoryName', selectedOption.categoryName || '')
  3242. this.$set(row, 'sku', selectedOption.sku || '')
  3243. this.$set(row, 'changeFlag', 1)
  3244. }
  3245. },
  3246. handlePortChange(row, field, value) {
  3247. console.log(`${field}变更:`, value, '行ID:', row.id)
  3248. this.$set(row, field, value) // 直接设置字段值
  3249. this.$set(row, 'changeFlag', 1)
  3250. // 注意:这里还需要同步更新对应的 rowDeparture/rowDestination/rowShipVia
  3251. if (field === 'departure') {
  3252. this.$set(this.rowDeparture, row.id, value)
  3253. } else if (field === 'destination') {
  3254. this.$set(this.rowDestination, row.id, value)
  3255. } else if (field === 'shipVia') {
  3256. this.$set(this.rowShipVia, row.id, value)
  3257. }
  3258. // 如果三个字段都填写了,获取运输方式选项
  3259. if (row.departure && row.destination && row.shipVia) {
  3260. this.getTransportOptions(row.departure, row.destination, row.shipVia)
  3261. }
  3262. },
  3263. getTransportOptions(departure, destination, shipVia) {
  3264. console.log('获取运输方式选项:', departure, destination, shipVia)
  3265. //调用接口获取运输方式选项
  3266. searchTransportOptions({ departure, destination, shipVia }).then(({ data }) => {
  3267. if (data && data.code === 0) {
  3268. this.transportOptions = (data.rows || []).map(item => ({
  3269. label: item.shipVia,
  3270. value: item.shipVia,
  3271. eta: item.eta
  3272. }))
  3273. } else {
  3274. this.$message.error(data.msg || '获取运输方式选项失败')
  3275. }
  3276. }).catch(error => {
  3277. this.$message.error('获取运输方式选项失败: ' + error.message)
  3278. })
  3279. },
  3280. toggleEditMode () {
  3281. if (!this.editMode) {
  3282. this.editMode = true
  3283. return
  3284. }
  3285. const changed = this.masterRows.filter(r => r.changeFlag === 1)
  3286. this.batchUpdatePoOrder(changed)
  3287. },
  3288. cancelEditMode () {
  3289. this.editMode = false
  3290. this.resetEamPick()
  3291. this.getDataList()
  3292. },
  3293. formatCodeOptionLabel (code, name) {
  3294. if (!name) {
  3295. return code || ''
  3296. }
  3297. if (!code) {
  3298. return name
  3299. }
  3300. return `${code} - ${name}`
  3301. },
  3302. getCustomerOptions () {
  3303. return getPoCustomerOptions({
  3304. site: this.$store.state.user.site
  3305. }).then(({ data }) => {
  3306. if (data && data.code === 0) {
  3307. this.poCustomerOptions = (data.rows || []).map(item => ({
  3308. label: this.formatCodeOptionLabel(item.code, item.name),
  3309. value: item.code
  3310. }))
  3311. this.columnSelectOptions.poCustomerOptions = this.poCustomerOptions
  3312. } else {
  3313. this.$message.error(data.msg || '操作失败')
  3314. }
  3315. }).catch(error => {
  3316. this.$message.error('操作失败: ' + error.message)
  3317. })
  3318. },
  3319. getBuyerOptions (customer = this.searchData.customer) {
  3320. const customerCode = (customer || '').trim()
  3321. if (!customerCode) {
  3322. this.poBuyerOptions = []
  3323. this.columnSelectOptions.poBuyerOptions = []
  3324. return Promise.resolve([])
  3325. }
  3326. this.poBuyerOptions = []
  3327. this.columnSelectOptions.poBuyerOptions = []
  3328. return getPoBuyerOptions({
  3329. site: this.$store.state.user.site,
  3330. customer: customerCode
  3331. }).then(({ data }) => {
  3332. if (data && data.code === 0) {
  3333. this.poBuyerOptions = (data.rows || []).map(item => ({
  3334. label: this.formatCodeOptionLabel(item.code, item.name),
  3335. value: item.code,
  3336. code: item.code,
  3337. name: item.name || ''
  3338. }))
  3339. this.columnSelectOptions.poBuyerOptions = this.poBuyerOptions
  3340. return this.poBuyerOptions
  3341. } else {
  3342. this.$message.error((data && data.msg) || '操作失败')
  3343. return []
  3344. }
  3345. }).catch(error => {
  3346. this.$message.error('操作失败: ' + error.message)
  3347. return []
  3348. })
  3349. },
  3350. getPartNoOptions() {
  3351. console.log('获取分类选项')
  3352. getPartList(
  3353. {
  3354. site: this.$store.state.user.site
  3355. }
  3356. ).then(({data}) => {
  3357. if (data && data.code === 0) {
  3358. console.log('接口返回的rows:', data.rows) // 查看返回数据
  3359. this.poPartNoOptions = (data.rows || []).map(item => ({
  3360. label: item.partNo,
  3361. value: item.partNo,
  3362. item: item.item,
  3363. category: item.category,
  3364. categoryName: item.categoryName,
  3365. sku: item.sku
  3366. }))
  3367. } else {
  3368. this.$message.error(data.msg || '操作失败')
  3369. }
  3370. }).catch(error => {
  3371. this.$message.error('操作失败: ' + error.message)
  3372. })
  3373. },
  3374. getSupplierOptions(){
  3375. console.log('获取供应商选项')
  3376. checkSrmSupplierList(
  3377. {
  3378. site: this.$store.state.user.site
  3379. }
  3380. ).then(({data}) => {
  3381. if (data && data.code === 0) {
  3382. console.log('接口返回的rows:', data.rows) // 查看返回数据
  3383. this.supplierOptions = (data.rows || []).map(item => ({
  3384. label: item.supplierName,
  3385. value: item.supplierNo,
  3386. shortOffice: item.cshortOffice,
  3387. shortNpc: item.cshortNpc
  3388. }))
  3389. } else {
  3390. this.$message.error(data.msg || '操作失败')
  3391. }
  3392. }).catch(error => {
  3393. this.$message.error('操作失败: ' + error.message)
  3394. })
  3395. },
  3396. getPortOptions(){
  3397. console.log('获取港口选项')
  3398. searchTransportOptions(
  3399. {
  3400. site: this.$store.state.user.site
  3401. }
  3402. ).then(({data}) => {
  3403. if (data && data.code === 0) {
  3404. console.log('接口返回的rows:', data.rows) // 查看返回数据
  3405. this.transportOptions = (data.rows || []).map(item => ({
  3406. label: item.supplierName,
  3407. value: item.supplierNo,
  3408. destination: item.destination,
  3409. departure: item.departure,
  3410. shipVia: item.shipVia,
  3411. etc: item.eta
  3412. }))
  3413. } else {
  3414. this.$message.error(data.msg || '操作失败')
  3415. }
  3416. }).catch(error => {
  3417. this.$message.error('操作失败: ' + error.message)
  3418. })
  3419. },
  3420. // 保存订单信息
  3421. buildBatchUpdateRow (row) {
  3422. const value = this.calcPoValue(row.price, row.qty)
  3423. const extValues = buildExtValuesFromRow(row, this.fieldSchemaFields)
  3424. return {
  3425. orderNo: row.orderNo,
  3426. site: row.site,
  3427. itemNo: row.itemNo,
  3428. supplierNo: row.supplierNo,
  3429. supplierName: row.supplierName,
  3430. buyer: row.buyer,
  3431. customer: row.customer,
  3432. poNo: row.poNo,
  3433. departure: row.departure,
  3434. destination: row.destination,
  3435. shipVia: row.shipVia,
  3436. orderDate: row.orderDate,
  3437. enquiry: row.enquiry,
  3438. confirmed: row.confirmed,
  3439. partNo: row.partNo,
  3440. item: row.item,
  3441. status: row.status,
  3442. qty: row.qty === '' ? null : Number(row.qty),
  3443. price: row.price === '' ? null : Number(row.price),
  3444. value: value === '' ? null : Number(value),
  3445. shipQty: row.shipQty,
  3446. sumPrice: row.sumPrice,
  3447. wantReceiveDate: row.wantReceiveDate,
  3448. narrival: row.narrival,
  3449. crd: row.crd,
  3450. inspection: row.inspection,
  3451. realCrd: row.realCrd,
  3452. poPlaceDate: row.poPlaceDate,
  3453. poPromiseReadyDate: row.poPromiseReadyDate,
  3454. poActualReadyDate: row.poActualReadyDate,
  3455. chinaOfficeInspectionDate: row.chinaOfficeInspectionDate,
  3456. shipToNpcDate: row.shipToNpcDate,
  3457. inspectionResult: row.inspectionResult,
  3458. flexid: row.flexid,
  3459. obd: row.obd,
  3460. docSent: row.docSent,
  3461. telexRelease: row.telexRelease,
  3462. advancePayment: row.advancePayment,
  3463. advancePaid: row.advancePaid,
  3464. // 编辑状态下 Planner 不允许改,避免把显示名回写覆盖账号
  3465. planner: null,
  3466. remarkDelay: row.remarkDelay,
  3467. remark: row.remark,
  3468. extValues
  3469. }
  3470. },
  3471. batchUpdatePoOrder(changed) {
  3472. for (const row of changed) {
  3473. const label = row.orderNo ? `订单 ${row.orderNo}` : '订单'
  3474. if (!this.validatePriceAndQty(row.price, row.qty, label)) {
  3475. return
  3476. }
  3477. this.$set(row, 'value', this.calcPoValue(row.price, row.qty))
  3478. }
  3479. const updateData = changed.map(row => this.buildBatchUpdateRow(row))
  3480. // 调用批量修改接口
  3481. batchUpdatePoDetail(updateData)
  3482. .then(({ data }) => {
  3483. if (data && data.code === 0) {
  3484. this.$message({
  3485. message: `已提交 ${updateData.length} 行变更`,
  3486. type: 'success',
  3487. duration: 2000
  3488. })
  3489. changed.forEach(r => {
  3490. this.$set(r, 'changeFlag', 0)
  3491. })
  3492. this.editMode = false
  3493. this.getDataList()
  3494. } else {
  3495. this.$message.error(data.msg || '操作失败')
  3496. }
  3497. })
  3498. .catch(error => {
  3499. this.$message.error('操作失败: ' + error.message)
  3500. })
  3501. },
  3502. // ========== 导入功能(新实现) ==========
  3503. /**
  3504. * 打开导入弹窗并重置状态。
  3505. * 业务意图:
  3506. * 1) 每次打开都清空上一次文件与结果,避免误用历史数据;
  3507. * 2) 强制用户先选 customer,确保模板字段与导入权限与 customer 一致。
  3508. */
  3509. openImportDialog () {
  3510. if (!this.searchData.customer) {
  3511. this.$message.warning('请先选择 Customer')
  3512. return
  3513. }
  3514. this.resetImportDialog()
  3515. this.importDialogVisible = true
  3516. },
  3517. /**
  3518. * 导入弹窗关闭后的统一清理。
  3519. * 边界处理:导入进行中禁止被重置,避免中途清空文件状态导致重复提交。
  3520. */
  3521. resetImportDialog () {
  3522. if (this.importSubmitting) {
  3523. return
  3524. }
  3525. if (this.$refs.importUpload && this.$refs.importUpload.clearFiles) {
  3526. this.$refs.importUpload.clearFiles()
  3527. }
  3528. this.importFileName = ''
  3529. this.importFile = null
  3530. this.importLastResult = null
  3531. },
  3532. /**
  3533. * 记录用户选择的导入文件。
  3534. * 输入:el-upload change 事件文件对象。
  3535. * 输出:仅保留当前一次选择,后续由“开始导入”统一提交。
  3536. */
  3537. handleImportFileChange (file) {
  3538. this.importFile = file && file.raw ? file.raw : null
  3539. this.importFileName = file && file.name ? file.name : ''
  3540. this.importLastResult = null
  3541. },
  3542. exportExcel () {
  3543. if (this.editMode) {
  3544. this.$message.warning('快速编辑模式下不允许导出,请先点击取消或确定')
  3545. return
  3546. }
  3547. if (!this.searchData.customer) {
  3548. this.$message.warning('请先选择 Customer')
  3549. return
  3550. }
  3551. const now = new Date()
  3552. const year = now.getFullYear()
  3553. const month = String(now.getMonth() + 1).padStart(2, '0')
  3554. const day = String(now.getDate()).padStart(2, '0')
  3555. const hour = String(now.getHours()).padStart(2, '0')
  3556. const minute = String(now.getMinutes()).padStart(2, '0')
  3557. const second = String(now.getSeconds()).padStart(2, '0')
  3558. const exportName = `PO订单列表${year}${month}${day}${hour}${minute}${second}`
  3559. const { params, useAdvanced } = buildPoOrderQueryParams({
  3560. searchData: this.searchData,
  3561. advancedQueryData: this.advancedQueryData,
  3562. page: 1,
  3563. limit: 99999
  3564. })
  3565. try {
  3566. excel.exportTable({
  3567. url: useAdvanced ? 'pODetail/advancedPage' : 'pODetail/page',
  3568. columnMapping: this.poStatusExportColumns(this.visibleColumns), // rqrq - 导出英文状态
  3569. mergeSetting: [],
  3570. params,
  3571. fileName: exportName + '.xlsx',
  3572. rowFetcher: res => {
  3573. const page = res.data && res.data.page
  3574. const rows = ((page && page.list) || []).map(row => normalizeSchemaRowValues(row))
  3575. return { rows }
  3576. },
  3577. columnFormatter: [],
  3578. dropColumns: []
  3579. })
  3580. } catch (error) {
  3581. this.$message.error('导出失败: ' + error.message)
  3582. }
  3583. },
  3584. /**
  3585. * 下载导入模板。
  3586. * 业务规则:模板由后端按 site + customer 当前可见字段动态生成,第一行即校验基准栏位。
  3587. */
  3588. downloadImportTemplate () {
  3589. if (!this.searchData.customer) {
  3590. this.$message.warning('请先选择 Customer')
  3591. return
  3592. }
  3593. const loading = this.$loading({
  3594. lock: true,
  3595. text: '正在下载模板...',
  3596. spinner: 'el-icon-loading',
  3597. background: 'rgba(0, 0, 0, 0.7)'
  3598. })
  3599. this.$http({
  3600. url: this.$http.adornUrl('/pODetail/downloadTemplate'),
  3601. method: 'get',
  3602. params: {
  3603. site: this.searchData.site || this.$store.state.user.site,
  3604. customer: this.searchData.customer
  3605. },
  3606. responseType: 'blob'
  3607. }).then(response => {
  3608. loading.close()
  3609. // 创建下载文件
  3610. const blob = new Blob([response.data], {
  3611. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  3612. })
  3613. const url = window.URL.createObjectURL(blob)
  3614. const link = document.createElement('a')
  3615. link.href = url
  3616. link.download = `PO订单导入模板_${this.searchData.customer}.xlsx`
  3617. document.body.appendChild(link)
  3618. link.click()
  3619. document.body.removeChild(link)
  3620. window.URL.revokeObjectURL(url)
  3621. this.$message.success('模板下载成功')
  3622. }).catch(error => {
  3623. loading.close()
  3624. console.error('模板下载失败:', error)
  3625. this.$message.error('模板下载失败,请联系管理员')
  3626. })
  3627. },
  3628. /**
  3629. * 执行导入(后端逐行创建 header + detail)。
  3630. * 关键约束:
  3631. * 1) 导入期间统一禁用弹窗按钮,避免重复发起;
  3632. * 2) 请求超时时间单独提升为 10 分钟,兼容大批量(数千行)导入;
  3633. * 3) 返回成功/失败条数与行级错误,便于用户按行修复。
  3634. */
  3635. submitImportCreatePoOrder () {
  3636. if (!this.importFile) {
  3637. this.$message.warning('请先选择导入文件')
  3638. return
  3639. }
  3640. if (!this.searchData.customer) {
  3641. this.$message.warning('请先选择 Customer')
  3642. return
  3643. }
  3644. if (this.importSubmitting) {
  3645. return
  3646. }
  3647. const formData = new FormData()
  3648. formData.append('file', this.importFile)
  3649. formData.append('site', this.searchData.site || this.$store.state.user.site)
  3650. formData.append('customer', this.searchData.customer)
  3651. this.importSubmitting = true
  3652. this.importLastResult = null
  3653. this.$http({
  3654. url: this.$http.adornUrl('/pODetail/importCreatePoOrder'),
  3655. method: 'post',
  3656. data: formData,
  3657. timeout: 10 * 60 * 1000
  3658. }).then(({ data }) => {
  3659. if (!(data && data.code === 0)) {
  3660. this.$message.error((data && data.msg) || '导入失败')
  3661. return
  3662. }
  3663. const result = data.data || {}
  3664. this.importLastResult = result
  3665. const successCount = Number(result.successCount || 0)
  3666. const failCount = Number(result.failCount || 0)
  3667. let msg = `导入完成:成功 ${successCount} 条,失败 ${failCount} 条`
  3668. if (result.rowErrors && result.rowErrors.length) {
  3669. msg += ';' + result.rowErrors.slice(0, 3).map(item => `第${item.rowNo}行 ${item.message}`).join(';')
  3670. }
  3671. if (failCount > 0) {
  3672. this.$message.warning(msg)
  3673. } else {
  3674. this.$message.success(msg)
  3675. }
  3676. if (successCount > 0) {
  3677. this.getDataList()
  3678. }
  3679. }).catch((error) => {
  3680. const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
  3681. this.$message.error('导入失败: ' + errorMsg)
  3682. }).finally(() => {
  3683. this.importSubmitting = false
  3684. })
  3685. },
  3686. // 打开供应商选择弹窗
  3687. openSupplierSelect(row) {
  3688. this.currentSelectRow = row
  3689. const conSql = " and site = '" + this.$store.state.user.site + "'"
  3690. this.openEamList(SUPPLIER_CHOOSELIST_TAG, '', conSql, 'row', 'supplier')
  3691. },
  3692. applySupplierSelection (target, supplierNo, supplierName, shortOffice, shortNpc, planner, markChanged) {
  3693. if (!target) return
  3694. this.$set(target, 'supplierName', supplierName)
  3695. this.$set(target, 'supplierNo', supplierNo)
  3696. this.$set(target, 'shortOffice', shortOffice)
  3697. this.$set(target, 'shortNpc', shortNpc)
  3698. this.$set(target, 'planner', planner || '')
  3699. if (markChanged) {
  3700. this.$set(target, 'changeFlag', 1)
  3701. }
  3702. },
  3703. fillSupplierShortFields (target, supplierNo, supplierName, markChanged, departureAutoKey = '') {
  3704. if (!target || !supplierNo) {
  3705. return Promise.resolve()
  3706. }
  3707. this.applySupplierSelection(
  3708. target,
  3709. supplierNo,
  3710. supplierName,
  3711. target.shortOffice || '',
  3712. target.shortNpc || '',
  3713. target.planner || '',
  3714. markChanged
  3715. )
  3716. return fetchSupplierDetail(supplierNo, this.$store.state.user.site).then(detail => {
  3717. const { shortOffice, shortNpc, planner, defaultOriginPort } = resolveSupplierShortFieldsFromDetail(detail)
  3718. this.applySupplierSelection(target, supplierNo, supplierName, shortOffice, shortNpc, planner, markChanged)
  3719. if (departureAutoKey) {
  3720. this.autoFillDepartureBySupplier(target, defaultOriginPort, departureAutoKey)
  3721. }
  3722. }).catch(() => {})
  3723. },
  3724. /**
  3725. * 选完供应商后按供应商主数据的默认始发港预填「始发港」(存港口编码,与手工选择同口径)。
  3726. * 边界:用户手选的港口(不等于上次自动值)不覆盖;
  3727. * 当前值仍是自动带出的值时,跟随新供应商更新,新供应商未维护则清空避免残留旧港口。
  3728. */
  3729. autoFillDepartureBySupplier (target, defaultOriginPort, autoKey) {
  3730. if (!target || !autoKey) {
  3731. return
  3732. }
  3733. const current = String(target.departure || '').trim()
  3734. const lastAuto = String(this.addDepartureAutoValues[autoKey] || '').trim()
  3735. if (current && current !== lastAuto) {
  3736. return
  3737. }
  3738. const port = String(defaultOriginPort || '').trim()
  3739. this.$set(this.addDepartureAutoValues, autoKey, port)
  3740. if (current !== port) {
  3741. this.$set(target, 'departure', port)
  3742. }
  3743. },
  3744. fillPartCategorySku (partNo, target) {
  3745. if (!partNo || !target) return
  3746. const targetSite = String(target.site || this.$store.state.user.site || '').trim()
  3747. const apply = (item, category, categoryName, sku) => {
  3748. this.$set(target, 'item', item)
  3749. this.$set(target, 'category', category)
  3750. this.$set(target, 'categoryName', categoryName)
  3751. this.$set(target, 'sku', sku)
  3752. }
  3753. const fromList = this.poPartNoOptions.find(opt => opt.value === partNo)
  3754. if (fromList) {
  3755. apply(fromList.item || '', fromList.category || '', fromList.categoryName || '', fromList.sku || '')
  3756. return
  3757. }
  3758. searchPartInfo({ site: targetSite, partNo }).then(({ data }) => {
  3759. if (data && data.code === 0 && data.data) {
  3760. apply(data.data.item || '', data.data.category || '', data.data.categoryName || '', data.data.sku || '')
  3761. }
  3762. }).catch(() => {})
  3763. },
  3764. applySelectedPartToTarget (target, partRow, markChanged) {
  3765. if (!target || !partRow) {
  3766. return
  3767. }
  3768. const partNo = partRow.partNo || partRow.part_no || ''
  3769. if (!partNo) {
  3770. return
  3771. }
  3772. this.$set(target, 'partNo', partNo)
  3773. this.$set(target, 'partDesc', partRow.partDesc || '')
  3774. this.$set(target, 'item', partRow.item || '')
  3775. this.$set(target, 'sku', partRow.sku || '')
  3776. this.fillPartCategorySku(partNo, target)
  3777. if (markChanged) {
  3778. this.$set(target, 'changeFlag', 1)
  3779. }
  3780. },
  3781. openSupplierPartDialog (context, row = null) {
  3782. const site = String((context === 'row'
  3783. ? (row && row.site)
  3784. : (context === 'addDetail' ? this.addDetailForm.site : this.searchData.site)) || this.$store.state.user.site || '').trim()
  3785. const supplierNo = String((context === 'row'
  3786. ? (row && (row.supplierNo || row.supplier_no || row.supplierCode || row.supplier_code))
  3787. : (context === 'addDetail'
  3788. ? (this.addDetailForm.supplierNo || this.addForm.supplierNo || '')
  3789. : this.addForm.supplierNo)) || '').trim()
  3790. if (!site) {
  3791. this.$message.warning('请先选择site')
  3792. return
  3793. }
  3794. if (!supplierNo) {
  3795. this.$message.warning('请先选择供应商')
  3796. return
  3797. }
  3798. this.supplierPartDialogVisible = true
  3799. this.supplierPartDialogLoading = true
  3800. this.supplierPartDialogRows = []
  3801. this.supplierPartDialogContext = context
  3802. this.supplierPartDialogTargetRow = context === 'row' ? row : null
  3803. this.supplierPartDialogSupplierNo = supplierNo
  3804. this.supplierPartDialogSite = site
  3805. listPoSupplierPartOptions({
  3806. site,
  3807. supplierCode: supplierNo,
  3808. active: 'Y'
  3809. }).then(({ data }) => {
  3810. if (data && data.code === 0) {
  3811. this.supplierPartDialogRows = (data.rows || []).map(item => ({
  3812. partNo: item.partNo || '',
  3813. partDesc: item.partDesc || '',
  3814. item: item.item || '',
  3815. sku: item.sku || ''
  3816. }))
  3817. if (this.supplierPartDialogRows.length === 0) {
  3818. this.$message.warning('该供应商未维护供应商可供物料')
  3819. }
  3820. return
  3821. }
  3822. this.supplierPartDialogRows = []
  3823. this.$message.error((data && data.msg) || '获取供应商可供物料失败')
  3824. }).catch(() => {
  3825. this.supplierPartDialogRows = []
  3826. this.$message.error('获取供应商可供物料失败')
  3827. }).finally(() => {
  3828. this.supplierPartDialogLoading = false
  3829. })
  3830. },
  3831. handleSupplierPartRowDblClick (row) {
  3832. if (!row) {
  3833. return
  3834. }
  3835. if (this.supplierPartDialogContext === 'add') {
  3836. this.applySelectedPartToTarget(this.addForm, row, false)
  3837. this.scheduleAutoFillAddPriceByTierPrice('master')
  3838. } else if (this.supplierPartDialogContext === 'addDetail') {
  3839. this.applySelectedPartToTarget(this.addDetailForm, row, false)
  3840. this.scheduleAutoFillAddPriceByTierPrice('detail')
  3841. } else if (this.supplierPartDialogContext === 'row' && this.supplierPartDialogTargetRow) {
  3842. this.applySelectedPartToTarget(this.supplierPartDialogTargetRow, row, true)
  3843. }
  3844. this.supplierPartDialogVisible = false
  3845. },
  3846. resetSupplierPartDialog () {
  3847. this.supplierPartDialogLoading = false
  3848. this.supplierPartDialogRows = []
  3849. this.supplierPartDialogContext = ''
  3850. this.supplierPartDialogTargetRow = null
  3851. this.supplierPartDialogSupplierNo = ''
  3852. this.supplierPartDialogSite = ''
  3853. },
  3854. resolveAddOrderTypeByCustomer () {
  3855. const customerOrderType = this.selectedCustomerScope && this.selectedCustomerScope.orderType
  3856. ? this.selectedCustomerScope.orderType
  3857. : 'PO'
  3858. return formatPoOrderTypeLabel(customerOrderType) || '采购订单'
  3859. },
  3860. openAddDialog () {
  3861. if (!this.searchData.customer) {
  3862. this.$message.warning('请选择customer')
  3863. return
  3864. }
  3865. if (this.addDialogSchemaLoading) {
  3866. return
  3867. }
  3868. if (this.addPriceLookupTimer) {
  3869. clearTimeout(this.addPriceLookupTimer)
  3870. this.addPriceLookupTimer = null
  3871. }
  3872. this.addPriceLookupSeq += 1
  3873. this.addForm = this.createEmptyAddForm(this.resolveAddOrderTypeByCustomer())
  3874. this.addDepartureAutoValues = { add: '', addDetail: '' }
  3875. this.addForm.customer = this.searchData.customer
  3876. this.addFormSchemaFields = []
  3877. this.addDictSelectOptionsMap = {}
  3878. this.addDetailRows = []
  3879. this.addDetailCurrentDraftId = ''
  3880. this.addDetailDialogMode = 'create'
  3881. this.addDetailDialogVisible = false
  3882. this.addDetailEditingDraftId = ''
  3883. this.addDetailForm = this.createEmptyAddForm(this.addForm.orderType || this.resolveAddOrderTypeByCustomer())
  3884. this.addDialogVisible = false
  3885. this.addDialogSchemaLoading = true
  3886. this.loadAddFieldSchema(this.searchData.customer).then(success => {
  3887. if (!success) {
  3888. return
  3889. }
  3890. this.addDetailForm = this.createEmptyAddDetailForm()
  3891. this.addDialogVisible = true
  3892. }).finally(() => {
  3893. this.addDialogSchemaLoading = false
  3894. })
  3895. if (!this.poPartNoOptions.length) {
  3896. this.getPartNoOptions()
  3897. }
  3898. if (!this.poCustomerOptions.length) {
  3899. this.getCustomerOptions()
  3900. }
  3901. this.getBuyerOptions(this.searchData.customer)
  3902. },
  3903. loadAddFieldSchema (customer) {
  3904. return getPoFieldSchema({
  3905. site: this.searchData.site,
  3906. customer,
  3907. scene: 'add'
  3908. }).then(({ data }) => {
  3909. if (data && data.code === 0 && data.data) {
  3910. this.addFormSchemaFields = data.data.fields || []
  3911. this.applyAddDefaultDateBySchema()
  3912. this.applyAddDefaultShipViaBySchema(this.addForm)
  3913. return this.preloadAddDictSelectOptions(this.addFormSchemaFields).then(() => true)
  3914. } else {
  3915. this.addFormSchemaFields = []
  3916. this.addDictSelectOptionsMap = {}
  3917. this.$message.error((data && data.msg) || '加载新增字段权限失败')
  3918. return false
  3919. }
  3920. }).catch(() => {
  3921. this.addFormSchemaFields = []
  3922. this.addDictSelectOptionsMap = {}
  3923. this.$message.error('加载新增字段权限失败')
  3924. return false
  3925. })
  3926. },
  3927. getTodayDateYmd () {
  3928. if (this.dayjs) {
  3929. return this.dayjs().format('YYYY-MM-DD')
  3930. }
  3931. const now = new Date()
  3932. const pad = (num) => String(num).padStart(2, '0')
  3933. return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
  3934. },
  3935. applyAddDefaultDateBySchema () {
  3936. this.applyDefaultDateBySchemaToForm(this.addForm)
  3937. },
  3938. applyDefaultDateBySchemaToForm (targetForm) {
  3939. if (!targetForm || !Array.isArray(this.addFormSchemaFields) || !this.addFormSchemaFields.length) {
  3940. return
  3941. }
  3942. const today = this.getTodayDateYmd()
  3943. this.addFormSchemaFields.forEach(field => {
  3944. const prop = this.getAddFieldProp(field)
  3945. if (!prop) {
  3946. return
  3947. }
  3948. if (this.isAddCreateDateField(field) || this.isAddPoPlaceDateField(field)) {
  3949. this.$set(targetForm, prop, today)
  3950. }
  3951. })
  3952. },
  3953. // 新增 schema 中若展示运输方式(ship_via / S_Method),则默认填充为海运
  3954. applyAddDefaultShipViaBySchema (targetForm) {
  3955. if (!targetForm || !Array.isArray(this.addFormSchemaFields) || !this.addFormSchemaFields.length) {
  3956. return
  3957. }
  3958. const field = this.getSchemaFieldByCode('ship_via')
  3959. if (!field || String(field.visibleFlag || '').trim().toUpperCase() !== 'Y') {
  3960. return
  3961. }
  3962. const prop = this.getAddFieldProp(field)
  3963. if (!prop) {
  3964. return
  3965. }
  3966. const current = targetForm[prop]
  3967. if (current === undefined || current === null || String(current).trim() === '') {
  3968. this.$set(targetForm, prop, '海运')
  3969. }
  3970. },
  3971. getFormExtValue (targetForm, fieldCode) {
  3972. if (!targetForm || !targetForm.extValues) {
  3973. return ''
  3974. }
  3975. return targetForm.extValues[fieldCode] == null ? '' : targetForm.extValues[fieldCode]
  3976. },
  3977. setFormExtValue (targetForm, fieldCode, val) {
  3978. if (!targetForm) {
  3979. return
  3980. }
  3981. if (!targetForm.extValues) {
  3982. this.$set(targetForm, 'extValues', {})
  3983. }
  3984. this.$set(targetForm.extValues, fieldCode, val)
  3985. },
  3986. getAddExtValue (fieldCode) {
  3987. return this.getFormExtValue(this.addForm, fieldCode)
  3988. },
  3989. setAddExtValue (fieldCode, val) {
  3990. this.setFormExtValue(this.addForm, fieldCode, val)
  3991. },
  3992. getAddDetailExtValue (fieldCode) {
  3993. return this.getFormExtValue(this.addDetailForm, fieldCode)
  3994. },
  3995. setAddDetailExtValue (fieldCode, val) {
  3996. this.setFormExtValue(this.addDetailForm, fieldCode, val)
  3997. },
  3998. createEmptyAddForm (orderType = '采购订单') {
  3999. const today = this.getTodayDateYmd()
  4000. return {
  4001. customer: '',
  4002. buyer: '',
  4003. supplierName: '',
  4004. supplierNo: '',
  4005. shortOffice: '',
  4006. shortNpc: '',
  4007. poNo: '',
  4008. orderType: orderType || '采购订单',
  4009. partNo: '',
  4010. item: '',
  4011. category: '',
  4012. categoryName: '',
  4013. sku: '',
  4014. price: '',
  4015. qty: '',
  4016. value: '',
  4017. shipQty: '',
  4018. sumPrice: '',
  4019. departure: '',
  4020. destination: '',
  4021. shipVia: '',
  4022. orderDate: '',
  4023. enquiry: '',
  4024. status: '草稿',
  4025. confirmed: '',
  4026. wantReceiveDate: '',
  4027. narrival: '',
  4028. crd: '',
  4029. inspection: '',
  4030. realCrd: '',
  4031. poPlaceDate: '',
  4032. poPromiseReadyDate: '',
  4033. poActualReadyDate: '',
  4034. chinaOfficeInspectionDate: '',
  4035. shipToNpcDate: '',
  4036. inspectionResult: '',
  4037. flexid: '',
  4038. obd: '',
  4039. docSent: '',
  4040. telexRelease: '',
  4041. advancePayment: 'N',
  4042. advancePaid: '',
  4043. planner: '',
  4044. remarkDelay: '',
  4045. remark: '',
  4046. extValues: {}
  4047. }
  4048. },
  4049. createEmptyAddDetailForm () {
  4050. const form = this.createEmptyAddForm(this.addForm.orderType || this.resolveAddOrderTypeByCustomer())
  4051. form.customer = this.searchData.customer || form.customer
  4052. form.site = this.searchData.site || this.$store.state.user.site
  4053. this.applyDefaultDateBySchemaToForm(form)
  4054. this.applyAddDefaultShipViaBySchema(form)
  4055. return form
  4056. },
  4057. cloneAddDraftRow (row) {
  4058. const cloned = JSON.parse(JSON.stringify(row || {}))
  4059. if (!cloned.extValues || typeof cloned.extValues !== 'object') {
  4060. cloned.extValues = {}
  4061. }
  4062. return cloned
  4063. },
  4064. buildAddDetailRowFromForm () {
  4065. const row = this.cloneAddDraftRow(this.addDetailForm)
  4066. this.removeAddMasterFieldValuesFromDetailRow(row)
  4067. if (!row._draftId) {
  4068. this.addDetailDraftSeq += 1
  4069. row._draftId = `DRAFT_${Date.now()}_${this.addDetailDraftSeq}`
  4070. }
  4071. row.value = this.calcPoValue(row.price, row.qty)
  4072. return row
  4073. },
  4074. removeAddMasterFieldValuesFromDetailRow (row) {
  4075. if (!row || typeof row !== 'object') {
  4076. return
  4077. }
  4078. this.addMasterBaseFields.forEach(field => {
  4079. const prop = this.getAddFieldProp(field)
  4080. if (!prop) {
  4081. return
  4082. }
  4083. if (Object.prototype.hasOwnProperty.call(row, prop)) {
  4084. delete row[prop]
  4085. }
  4086. })
  4087. },
  4088. getSelectedAddDetailRow () {
  4089. if (!this.addDetailCurrentDraftId) {
  4090. return null
  4091. }
  4092. return this.addDetailRows.find(row => row && row._draftId === this.addDetailCurrentDraftId) || null
  4093. },
  4094. onAddDetailCurrentChange (row) {
  4095. this.addDetailCurrentDraftId = row && row._draftId ? row._draftId : ''
  4096. },
  4097. onAddDetailRowClick (row) {
  4098. this.addDetailCurrentDraftId = row && row._draftId ? row._draftId : ''
  4099. if (this.$refs.addDetailTable && this.$refs.addDetailTable.setCurrentRow) {
  4100. this.$refs.addDetailTable.setCurrentRow(row)
  4101. }
  4102. },
  4103. openAddDetailDialog () {
  4104. this.addDetailDialogMode = 'create'
  4105. this.addDetailEditingDraftId = ''
  4106. this.addDepartureAutoValues.addDetail = ''
  4107. this.addDetailForm = this.createEmptyAddDetailForm()
  4108. this.addDetailDialogVisible = true
  4109. },
  4110. openEditAddDetailDialog () {
  4111. const selected = this.getSelectedAddDetailRow()
  4112. if (!selected) {
  4113. this.$message.warning('请先选择一条明细')
  4114. return
  4115. }
  4116. this.addDetailDialogMode = 'edit'
  4117. this.addDetailEditingDraftId = selected._draftId
  4118. this.addDepartureAutoValues.addDetail = ''
  4119. this.addDetailForm = this.cloneAddDraftRow(selected)
  4120. this.addDetailDialogVisible = true
  4121. },
  4122. openCopyAddDetailDialog () {
  4123. const selected = this.getSelectedAddDetailRow()
  4124. if (!selected) {
  4125. this.$message.warning('请先选择一条明细')
  4126. return
  4127. }
  4128. const copied = this.cloneAddDraftRow(selected)
  4129. copied._draftId = ''
  4130. copied.partNo = ''
  4131. this.addDetailDialogMode = 'copy'
  4132. this.addDetailEditingDraftId = ''
  4133. this.addDepartureAutoValues.addDetail = ''
  4134. this.addDetailForm = copied
  4135. this.addDetailDialogVisible = true
  4136. },
  4137. removeAddDetailRow () {
  4138. const selected = this.getSelectedAddDetailRow()
  4139. if (!selected) {
  4140. this.$message.warning('请先选择一条明细')
  4141. return
  4142. }
  4143. this.addDetailRows = this.addDetailRows.filter(row => row && row._draftId !== selected._draftId)
  4144. this.addDetailCurrentDraftId = ''
  4145. this.$nextTick(() => {
  4146. if (this.$refs.addDetailTable && this.$refs.addDetailTable.setCurrentRow) {
  4147. this.$refs.addDetailTable.setCurrentRow(null)
  4148. }
  4149. })
  4150. },
  4151. isAddFormFieldEmpty (value) {
  4152. if (value === null || value === undefined) {
  4153. return true
  4154. }
  4155. if (typeof value === 'string') {
  4156. return value.trim() === ''
  4157. }
  4158. return false
  4159. },
  4160. validateRequiredFieldGroup (fields, form, prefixLabel = '') {
  4161. if (!Array.isArray(fields)) {
  4162. return true
  4163. }
  4164. for (const field of fields) {
  4165. if (!field || field.requiredFlag !== 'Y') {
  4166. continue
  4167. }
  4168. const prop = this.getAddFieldProp(field)
  4169. if (!prop) {
  4170. continue
  4171. }
  4172. const value = form ? form[prop] : null
  4173. if (this.isAddFormFieldEmpty(value)) {
  4174. this.$message.warning(`${prefixLabel}${field.fieldLabel}不能为空`)
  4175. return false
  4176. }
  4177. }
  4178. return true
  4179. },
  4180. validateRequiredExtFieldGroup (fields, form, prefixLabel = '') {
  4181. if (!Array.isArray(fields)) {
  4182. return true
  4183. }
  4184. for (const field of fields) {
  4185. if (!field || field.requiredFlag !== 'Y') {
  4186. continue
  4187. }
  4188. const fieldCode = String((field && field.fieldCode) || '').trim()
  4189. if (!fieldCode) {
  4190. continue
  4191. }
  4192. const value = this.getFormExtValue(form, fieldCode)
  4193. if (this.isAddFormFieldEmpty(value)) {
  4194. this.$message.warning(`${prefixLabel}${field.fieldLabel}不能为空`)
  4195. return false
  4196. }
  4197. }
  4198. return true
  4199. },
  4200. saveAddDetailDraft () {
  4201. if (!this.validateRequiredFieldGroup(this.addDetailBaseFields, this.addDetailForm, '明细:')) {
  4202. return
  4203. }
  4204. if (!this.validateRequiredExtFieldGroup(this.addDetailExtFields, this.addDetailForm, '明细:')) {
  4205. return
  4206. }
  4207. const nextRow = this.buildAddDetailRowFromForm()
  4208. if (this.addDetailDialogMode === 'edit' && this.addDetailEditingDraftId) {
  4209. const targetIndex = this.addDetailRows.findIndex(row => row && row._draftId === this.addDetailEditingDraftId)
  4210. if (targetIndex >= 0) {
  4211. nextRow._draftId = this.addDetailEditingDraftId
  4212. this.$set(this.addDetailRows, targetIndex, nextRow)
  4213. }
  4214. } else {
  4215. this.addDetailRows.push(nextRow)
  4216. }
  4217. this.addDetailCurrentDraftId = nextRow._draftId
  4218. this.addDetailDialogVisible = false
  4219. this.$nextTick(() => {
  4220. if (this.$refs.addDetailTable && this.$refs.addDetailTable.setCurrentRow) {
  4221. const selected = this.addDetailRows.find(row => row && row._draftId === nextRow._draftId) || null
  4222. this.$refs.addDetailTable.setCurrentRow(selected)
  4223. }
  4224. })
  4225. },
  4226. /**
  4227. * 打开 Buyer 选择弹窗。接口按当前 Site + Customer 查询 po_buyer,
  4228. * 因此弹窗不会混入其他 Customer 的 Buyer。
  4229. */
  4230. openAddBuyerSelect (target = 'master') {
  4231. const customer = String(this.searchData.customer || '').trim()
  4232. if (!customer) {
  4233. this.$message.warning('请先选择 Customer')
  4234. return
  4235. }
  4236. this.buyerDialogTarget = target === 'detail' ? 'detail' : 'master'
  4237. this.buyerDialogRows = []
  4238. this.buyerDialogSelectedRow = null
  4239. this.buyerDialogVisible = true
  4240. this.buyerDialogLoading = true
  4241. this.getBuyerOptions(customer).then(options => {
  4242. if (!this.buyerDialogVisible) {
  4243. return
  4244. }
  4245. this.buyerDialogRows = Array.isArray(options) ? options : []
  4246. const targetForm = this.getAddTargetForm(this.buyerDialogTarget)
  4247. const currentBuyer = String((targetForm && targetForm.buyer) || '').trim()
  4248. const selected = this.buyerDialogRows.find(row => row && row.code === currentBuyer) || null
  4249. this.buyerDialogSelectedRow = selected
  4250. this.$nextTick(() => {
  4251. if (this.$refs.buyerSelectTable && this.$refs.buyerSelectTable.setCurrentRow) {
  4252. this.$refs.buyerSelectTable.setCurrentRow(selected)
  4253. }
  4254. })
  4255. }).finally(() => {
  4256. this.buyerDialogLoading = false
  4257. })
  4258. },
  4259. onBuyerDialogCurrentChange (row) {
  4260. this.buyerDialogSelectedRow = row || null
  4261. },
  4262. /** Buyer 实际落库字段为 POHeader.buyer,因此回填主数据编码 buyer_code。 */
  4263. applyBuyerDialogSelection (row) {
  4264. if (!row || !row.code) {
  4265. return
  4266. }
  4267. const targetForm = this.getAddTargetForm(this.buyerDialogTarget)
  4268. if (targetForm) {
  4269. this.$set(targetForm, 'buyer', row.code)
  4270. }
  4271. this.buyerDialogVisible = false
  4272. },
  4273. resetBuyerDialog () {
  4274. this.buyerDialogLoading = false
  4275. this.buyerDialogRows = []
  4276. this.buyerDialogSelectedRow = null
  4277. this.buyerDialogTarget = 'master'
  4278. },
  4279. openAddSupplierSelect (target = 'master') {
  4280. const conSql = " and site = '" + this.$store.state.user.site + "'"
  4281. const context = target === 'detail' ? 'addDetail' : 'add'
  4282. this.openEamList(SUPPLIER_CHOOSELIST_TAG, '', conSql, context, 'supplier')
  4283. },
  4284. openAddPartNoSelect (target = 'master') {
  4285. this.openSupplierPartDialog(target === 'detail' ? 'addDetail' : 'add')
  4286. },
  4287. openAddDepartureSelect (target = 'master') {
  4288. const context = target === 'detail' ? 'addDetail' : 'add'
  4289. this.openEamList(2018, '', this.buildDeparturePortConSql(), context, 'departure')
  4290. },
  4291. openAddDestinationSelect (target = 'master') {
  4292. const context = target === 'detail' ? 'addDetail' : 'add'
  4293. this.openEamList(2018, '', this.buildDestinationPortConSql(), context, 'destination')
  4294. },
  4295. openAddShipViaSelect (target = 'master') {
  4296. const context = target === 'detail' ? 'addDetail' : 'add'
  4297. this.openEamList(2019, '', '', context, 'shipVia')
  4298. },
  4299. buildMergedAddDetailForm (detailRow) {
  4300. const merged = {}
  4301. this.addMasterBaseFields.forEach(field => {
  4302. const prop = this.getAddFieldProp(field)
  4303. if (!prop) return
  4304. merged[prop] = this.addForm[prop]
  4305. })
  4306. this.addDetailBaseFields.forEach(field => {
  4307. const prop = this.getAddFieldProp(field)
  4308. if (!prop) return
  4309. merged[prop] = detailRow ? detailRow[prop] : null
  4310. })
  4311. merged.customer = this.searchData.customer || this.addForm.customer || ''
  4312. merged.extValues = { ...(detailRow && detailRow.extValues ? detailRow.extValues : {}) }
  4313. return merged
  4314. },
  4315. saveAddPoOrder () {
  4316. if (!this.validateRequiredFieldGroup(this.addMasterBaseFields, this.addForm, '主记录:')) {
  4317. return
  4318. }
  4319. if (!this.addForm.poNo || String(this.addForm.poNo).trim() === '') {
  4320. this.$message.warning('主记录:请填写 PO No')
  4321. return
  4322. }
  4323. if ((!this.addForm.supplierName || String(this.addForm.supplierName).trim() === '') &&
  4324. (!this.addForm.supplierNo || String(this.addForm.supplierNo).trim() === '')) {
  4325. this.$message.warning('主记录:请填写 Vendor Name')
  4326. return
  4327. }
  4328. if (this.addDetailRows.length === 0) {
  4329. this.$message.warning('请至少新增一条明细')
  4330. return
  4331. }
  4332. const payloadList = []
  4333. for (let i = 0; i < this.addDetailRows.length; i++) {
  4334. const row = this.addDetailRows[i]
  4335. if (!this.validateRequiredFieldGroup(this.addDetailBaseFields, row, `第${i + 1}行明细:`)) {
  4336. return
  4337. }
  4338. if (!this.validateRequiredExtFieldGroup(this.addDetailExtFields, row, `第${i + 1}行明细:`)) {
  4339. return
  4340. }
  4341. const mergedForm = this.buildMergedAddDetailForm(row)
  4342. if (!mergedForm.partNo || String(mergedForm.partNo).trim() === '') {
  4343. this.$message.warning(`第${i + 1}行明细:请填写 Part No`)
  4344. return
  4345. }
  4346. if (!this.validatePriceAndQty(mergedForm.price, mergedForm.qty, `第${i + 1}行`)) {
  4347. return
  4348. }
  4349. const calculatedValue = this.calcPoValue(mergedForm.price, mergedForm.qty)
  4350. payloadList.push(this.buildAddPayload(calculatedValue, mergedForm, this.addBaseFields, this.addExtFields))
  4351. }
  4352. if (payloadList.length === 0) {
  4353. this.$message.warning('请至少新增一条明细')
  4354. return
  4355. }
  4356. this.addFormSaving = true
  4357. const runCreate = (idx) => {
  4358. if (idx >= payloadList.length) {
  4359. return Promise.resolve()
  4360. }
  4361. return createPoOrder(payloadList[idx]).then(({ data }) => {
  4362. if (data && data.code === 0) {
  4363. return runCreate(idx + 1)
  4364. }
  4365. const errMsg = (data && data.msg) || '新增失败'
  4366. throw new Error(`第${idx + 1}行:${errMsg}`)
  4367. })
  4368. }
  4369. runCreate(0).then(() => {
  4370. this.$message.success(`新增成功,共 ${payloadList.length} 条`)
  4371. this.addDialogVisible = false
  4372. this.addDetailDialogVisible = false
  4373. this.getDataList()
  4374. }).catch(err => {
  4375. this.$message.error((err && err.message) || '新增失败')
  4376. }).finally(() => {
  4377. this.addFormSaving = false
  4378. })
  4379. },
  4380. buildAddPayload (calculatedValue, sourceForm = this.addForm, baseFields = this.addBaseFields, extFields = this.addExtFields) {
  4381. const payload = {
  4382. site: this.$store.state.user.site,
  4383. customer: this.searchData.customer,
  4384. extValues: {}
  4385. }
  4386. baseFields.forEach(field => {
  4387. const prop = this.getAddFieldProp(field)
  4388. const code = this.getAddFieldCode(field)
  4389. if (!prop || !code) {
  4390. return
  4391. }
  4392. let value = sourceForm[prop]
  4393. if (code === 'customer') {
  4394. value = this.searchData.customer || value
  4395. } else if (code === 'value') {
  4396. value = calculatedValue === '' ? null : Number(calculatedValue)
  4397. } else if (code === 'price' || code === 'qty' || code === 'ship_qty' || code === 'sum_price') {
  4398. value = (value === '' || value === null || value === undefined) ? null : Number(value)
  4399. }
  4400. payload[prop] = value
  4401. })
  4402. extFields.forEach(field => {
  4403. const fieldCode = (field && field.fieldCode) ? String(field.fieldCode).trim() : ''
  4404. if (!fieldCode) {
  4405. return
  4406. }
  4407. const value = this.getFormExtValue(sourceForm, fieldCode)
  4408. if (value === '' || value === null || value === undefined) {
  4409. return
  4410. }
  4411. payload.extValues[fieldCode] = value
  4412. })
  4413. return payload
  4414. },
  4415. openPartNoSelect (row) {
  4416. this.openSupplierPartDialog('row', row)
  4417. },
  4418. openDepartureSelect (row) {
  4419. this.currentDepartureRow = row
  4420. this.openEamList(2018, '', this.buildDeparturePortConSql(), 'row', 'departure')
  4421. },
  4422. openDestinationSelect (row) {
  4423. this.currentDestinationRow = row
  4424. this.openEamList(2018, '', this.buildDestinationPortConSql(), 'row', 'destination')
  4425. },
  4426. openShipViaSelect (row) {
  4427. this.currentShipViaRow = row
  4428. this.openEamList(2019, '', '', 'row', 'shipVia')
  4429. },
  4430. /**
  4431. * 判断是否为新增行(没有 id 或 id 为空表示新增)
  4432. */
  4433. isNewRow(row) {
  4434. return !row.id || row.id === '' || row.id === null || row.id === undefined
  4435. },
  4436. buildDeparturePortConSql () {
  4437. return " and is_departure_port = 'Y'"
  4438. },
  4439. buildDestinationPortConSql () {
  4440. return " and is_destination_port = 'Y'"
  4441. }
  4442. }
  4443. }
  4444. </script>
  4445. <style scoped lang="scss">
  4446. .po-add-form-wrap {
  4447. max-height: calc(100vh - 210px);
  4448. overflow-y: auto;
  4449. overflow-x: hidden;
  4450. padding: 0 12px 8px;
  4451. }
  4452. /* 防止滚动条切换时标签换行,进一步降低布局抖动 */
  4453. .po-add-form-wrap /deep/ .el-form--label-top .el-form-item__label {
  4454. white-space: nowrap;
  4455. }
  4456. .po-add-detail-toolbar {
  4457. margin: 10px 0 8px;
  4458. display: flex;
  4459. justify-content: space-between;
  4460. align-items: center;
  4461. }
  4462. .po-add-detail-title {
  4463. font-size: 13px;
  4464. color: #606266;
  4465. }
  4466. .ship-dialog-form {
  4467. padding: 0 4px;
  4468. }
  4469. .ship-dialog-input {
  4470. width: 120px;
  4471. text-align: right;
  4472. }
  4473. .ship-dialog-footer {
  4474. text-align: center;
  4475. }
  4476. .el-table /deep/ .cell {
  4477. height: auto;
  4478. line-height: 1.5;
  4479. }
  4480. </style>