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.

4237 lines
153 KiB

​
​
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
​
2 months ago
​
​
2 months ago
3 months ago
​
​
​
​
​
​
2 months ago
2 months ago
2 months ago
2 months ago
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
2 months ago
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
2 months ago
​
​
​
​
2 months ago
​
​
​
​
2 months ago
​
​
2 months ago
​
​
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
2 months ago
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
2 months ago
2 months ago
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
2 months ago
​
​
​
​
​
2 months ago
2 months ago
2 months ago
​
​
​
2 months ago
​
​
2 months ago
2 months ago
​
​
​
​
2 months ago
​
2 months ago
​
​
2 months ago
2 months ago
2 months ago
3 months ago
​
​
​
2 months ago
​
3 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
2 months ago
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
2 months ago
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
2 months ago
2 months ago
​
​
​
2 months ago
​
​
​
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
2 months ago
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
2 months ago
2 months ago
​
​
2 months ago
2 months ago
​
2 months ago
2 months ago
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
2 months ago
​
​
​
​
​
​
2 months ago
​
​
​
2 months ago
​
​
2 months ago
2 months ago
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
2 months ago
​
2 months ago
2 months ago
​
​
2 months ago
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
2 months ago
​
​
​
​
2 months ago
​
​
​
​
2 months ago
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
2 months ago
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
2 months ago
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
2 months ago
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
2 months ago
​
​
2 months ago
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
2 months ago
​
​
​
​
​
2 months ago
​
2 months ago
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
2 months ago
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
2 months ago
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
2 months ago
​
​
2 months ago
​
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
2 months ago
2 months ago
​
​
​
​
2 months ago
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
2 months ago
​
​
​
​
​
​
2 months ago
​
​
2 months ago
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <template>
  2. <div class="customer-css">
  3. <!-- 查询条件 -->
  4. <el-form :inline="true" label-position="top" class="search-form-inline">
  5. <div class="search-row">
  6. <el-form-item v-if="!isSupplierPageMode" class="search-item">
  7. <span style="cursor: pointer" slot="label" @click="getBaseList(520)"><a href="#">供应商编码</a></span>
  8. <el-input v-model="searchData.supplierNo" style="width: 120px" @keyup.enter.native="getMainData"/>
  9. </el-form-item>
  10. <el-form-item v-if="!isSupplierPageMode" label="供应商名称" class="search-item">
  11. <el-input v-model="searchData.supplierName" style="width: 250px" @keyup.enter.native="getMainData"/>
  12. </el-form-item>
  13. <el-form-item v-if="!isSupplierPageMode" class="search-item">
  14. <span style="cursor: pointer" slot="label" @click="getBaseList(530, 'mainPlanner')"><a href="#">Planner</a></span>
  15. <el-input v-model="searchData.planner" clearable style="width: 120px" @keyup.enter.native="getMainData"/>
  16. </el-form-item>
  17. <el-form-item label="申请日期" class="search-item">
  18. <div class="date-range">
  19. <el-date-picker v-model="searchData.requestDateStart" type="date" value-format="yyyy-MM-dd" placeholder="开始" style="width: 150px"/>
  20. <span class="split">-</span>
  21. <el-date-picker v-model="searchData.requestDateEnd" type="date" value-format="yyyy-MM-dd" placeholder="结束" style="width: 150px"/>
  22. </div>
  23. </el-form-item>
  24. <el-form-item label="状态" class="search-item">
  25. <el-select v-model="searchData.status" clearable placeholder="全部" style="width: 60%">
  26. <el-option label="全部" value="" />
  27. <el-option label="草稿" value="Draft" />
  28. <el-option label="待审核" value="Confirmed" />
  29. <el-option label="已下达" value="Audited" />
  30. <el-option label="已排程" value="Scheduled" />
  31. <el-option label="申请变更中" value="ChangeApplying" />
  32. <el-option label="验货中" value="Inspecting" />
  33. <el-option label="验货完成" value="InspectionCompleted" />
  34. <el-option label="已完成" value="Completed" />
  35. <el-option label="已取消" value="Cancelled" />
  36. </el-select>
  37. </el-form-item>
  38. </div>
  39. <div class="search-row">
  40. <el-form-item v-if="!isSupplierPageMode" class="search-item">
  41. <span style="cursor: pointer" slot="label" @click="getBaseList(2016, 'createBy')"><a href="#">申请人员</a></span>
  42. <el-input v-model="searchData.createBy" clearable style="width: 120px" @keyup.enter.native="getMainData"/>
  43. </el-form-item>
  44. <el-form-item v-if="!isSupplierPageMode" class="search-item">
  45. <span style="cursor: pointer" slot="label" @click="getBaseList(2016, 'qcOperator')"><a href="#">QC人员</a></span>
  46. <el-input v-model="searchData.qcOperator" clearable style="width: 120px" @keyup.enter.native="getMainData"/>
  47. </el-form-item>
  48. <el-form-item label="申请单号" class="search-item">
  49. <el-input v-model="searchData.requestNo" style="width: 120px" @keyup.enter.native="getMainData"/>
  50. </el-form-item>
  51. <el-form-item label="建议验货日期" class="search-item">
  52. <div class="date-range">
  53. <el-date-picker v-model="searchData.needInspectDateStart" type="date" value-format="yyyy-MM-dd" placeholder="开始" style="width: 150px"/>
  54. <span class="split">-</span>
  55. <el-date-picker v-model="searchData.needInspectDateEnd" type="date" value-format="yyyy-MM-dd" placeholder="结束" style="width: 150px"/>
  56. </div>
  57. </el-form-item>
  58. <el-form-item v-if="!isSupplierPageMode" label="计划验货日期" class="search-item">
  59. <div class="date-range">
  60. <el-date-picker v-model="searchData.planStartDate" type="date" value-format="yyyy-MM-dd" placeholder="开始" style="width: 150px"/>
  61. <span class="split">-</span>
  62. <el-date-picker v-model="searchData.planEndDate" type="date" value-format="yyyy-MM-dd" placeholder="结束" style="width: 150px"/>
  63. </div>
  64. </el-form-item>
  65. <el-form-item label=" " class="search-item search-btn-item">
  66. <el-button type="primary" @click="getMainData" style="">查询</el-button>
  67. <el-button type="primary" @click="addInspectionRequest" style="margin-left: 2px">新增</el-button>
  68. <el-button type="primary" @click="importExcel" style="margin-left: 2px">Excel导入</el-button>
  69. <el-button type="primary" @click="exportExcel" style="margin-left: 2px">导出</el-button>
  70. </el-form-item>
  71. </div>
  72. </el-form>
  73. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  74. <el-table
  75. :height="height"
  76. :data="mainDataList"
  77. border
  78. ref="mainTable"
  79. highlight-current-row
  80. @row-click="changeData"
  81. v-loading="dataListLoading"
  82. style="margin-top: 0px; width: 100%;">
  83. <el-table-column
  84. v-for="(item,index) in columnArray1" :key="index"
  85. :sortable="item.columnSortable"
  86. :prop="item.columnProp"
  87. :header-align="item.headerAlign"
  88. :show-overflow-tooltip="item.showOverflowTooltip"
  89. :align="item.align"
  90. :fixed="item.fixed==''?false:item.fixed"
  91. :min-width="item.columnWidth"
  92. :label="item.columnLabel">
  93. <template slot-scope="scope">
  94. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  95. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  96. style="width: 100px; height: 100px"/></span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column fixed="right" header-align="center" align="center" width="260" label="操作">
  100. <template slot-scope="scope">
  101. <a v-if="isRowStatus(scope.row, ['Draft'])"
  102. class="customer-a" @click="confirmInspection(scope.row)">确认</a>
  103. <a v-if="isRowStatus(scope.row, ['Draft', 'Confirmed'])"
  104. class="customer-a"
  105. :style="isRowStatus(scope.row, ['Draft']) ? 'margin-left: 3px;' : ''"
  106. @click="deleteInspectionRequest(scope.row)">删除</a>
  107. <a v-if="isRowStatus(scope.row, ['Draft'])"
  108. class="customer-a"
  109. :style="(isRowStatus(scope.row, ['Draft']) || isRowStatus(scope.row, ['Confirmed'])) ? 'margin-left: 3px;' : ''"
  110. @click="editInspectionRequest(scope.row)">编辑</a>
  111. <a v-if="isRowStatus(scope.row, ['Confirmed', 'Audited', 'Scheduled'])"
  112. class="customer-a"
  113. :style="(isRowStatus(scope.row, ['Draft']) || isRowStatus(scope.row, ['Confirmed'])) ? 'margin-left: 3px;' : ''"
  114. @click="applyChangeRequest(scope.row)">申请变更</a>
  115. <a class="customer-a" style="margin-left: 3px;" @click="exportRowExcel(scope.row)" v-if="isRowStatus(scope.row, [ 'Audited', 'Scheduled'])">导出验货通知</a>
  116. <a class="customer-a" style="margin-left: 3px;" @click="exportInspectionResultExcel(scope.row)" v-if="isRowStatus(scope.row, [ 'InspectionCompleted'])">导出验货结果</a>
  117. <!-- <span v-if="!isRowStatus(scope.row, ['Draft', 'Confirmed', 'Audited', 'Scheduled'])"-->
  118. <!-- class="customer-a"-->
  119. <!-- style="color: #909399; cursor: default;">{{ scope.row.status }}</span>-->
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. <el-dialog
  124. title="申请变更"
  125. :visible.sync="applyChangeDialogVisible"
  126. width="480px"
  127. v-drag
  128. append-to-body
  129. :close-on-click-modal="false">
  130. <el-form label-position="top">
  131. <el-form-item label="申请单号">
  132. <el-input v-model="applyChangeForm.requestNo" readonly />
  133. </el-form-item>
  134. <el-form-item label="变更备注">
  135. <el-input
  136. v-model="applyChangeForm.changeRemark"
  137. type="textarea"
  138. resize="none"
  139. :autosize="{ minRows: 3, maxRows: 3 }"
  140. placeholder="请填写变更备注" />
  141. </el-form-item>
  142. </el-form>
  143. <el-footer style="height:25px;margin-top: 45px;text-align:center">
  144. <el-button type="primary" :loading="applyChangeLoading" @click="submitApplyChangeRequest">保存</el-button>
  145. <el-button :disabled="applyChangeLoading" @click="applyChangeDialogVisible = false">取消</el-button>
  146. </el-footer>
  147. </el-dialog>
  148. <!-- 分页插件 -->
  149. <el-pagination style="margin-top: 0px"
  150. @size-change="sizeChangeHandle"
  151. @current-change="currentChangeHandle"
  152. :current-page="pageIndex"
  153. :page-sizes="[20, 50, 100, 200, 500]"
  154. :page-size="pageSize"
  155. :total="totalPage"
  156. layout="total, sizes, prev, pager, next, jumper">
  157. </el-pagination>
  158. <!-- 详情页签 -->
  159. <el-tabs v-model="activeTab" style="margin-top: 0px; width: 99%;" @tab-click="handleTabClick" class="customer-tab" type="border-card">
  160. <!-- 基本信息 -->
  161. <el-tab-pane label="基本信息" name="base">
  162. <div class="tab-pane-content" :style="tabPaneContentStyle">
  163. <inspection-request-detail ref="inspectionRequestDetail" :detail-data="currentRow" @update-success="getMainData"/>
  164. </div>
  165. </el-tab-pane>
  166. <!-- 验货明细 -->
  167. <el-tab-pane label="验货明细" name="detail">
  168. <div class="tab-pane-content" :style="tabPaneContentStyle">
  169. <inspection-request-detail-tab ref="inspectionDetailTab" :detail-data="currentRow" :table-height="tabTableHeight" />
  170. </div>
  171. </el-tab-pane>
  172. <!-- 验货关联PO明细 -->
  173. <el-tab-pane label="验货关联PO明细" name="poDetail">
  174. <div class="tab-pane-content" :style="tabPaneContentStyle">
  175. <inspection-request-po-detail-tab ref="poDetailTab" :detail-data="currentRow" :table-height="tabTableHeight" />
  176. </div>
  177. </el-tab-pane>
  178. <!-- 验货结果 -->
  179. <el-tab-pane label="验货结果" name="result">
  180. <div class="tab-pane-content" :style="tabPaneContentStyle">
  181. <inspection-result-tab ref="resultTab" :detail-data="currentRow" :table-height="tabTableHeight" />
  182. </div>
  183. </el-tab-pane>
  184. <!-- 费用明细(供应商专用页不展示) -->
  185. <el-tab-pane v-if="!isSupplierPageMode" label="费用明细" name="fee">
  186. <div class="tab-pane-content" :style="tabPaneContentStyle">
  187. <inspection-request-fee-tab ref="feeTab" :detail-data="currentRow" :table-height="tabTableHeight" />
  188. </div>
  189. </el-tab-pane>
  190. <!-- 附件管理(供应商专用页不展示) -->
  191. <el-tab-pane v-if="!isSupplierPageMode" label="附件管理" name="attachment">
  192. <div class="tab-pane-content" :style="tabPaneContentStyle">
  193. <inspection-request-attachment-tab ref="attachmentTab" :detail-data="currentRow" :table-height="tabTableHeight" />
  194. </div>
  195. </el-tab-pane>
  196. </el-tabs>
  197. <!-- 新增弹窗 -->
  198. <el-dialog
  199. :title="isEditDialogMode ? '编辑验货申请' : '新增验货申请'"
  200. v-drag
  201. :visible.sync="addDialogVisible"
  202. width="1050px"
  203. top="5vh"
  204. :close-on-click-modal="false"
  205. @close="handleCloseAddDialog">
  206. <el-form :model="addFormData" :rules="addRules" ref="addFormData" label-width="90px" size="mini" class="add-dialog-form">
  207. <div class="form-section">
  208. <el-row :gutter="10">
  209. <el-col :span="6">
  210. <el-form-item label="申请单号" prop="requestNo">
  211. <el-input v-model="addFormData.requestNo" :placeholder="isEditDialogMode ? '' : '自动生成'" disabled size="mini"></el-input>
  212. </el-form-item>
  213. </el-col>
  214. <el-col :span="6">
  215. <el-form-item label="申请日期" prop="requestDate">
  216. <el-date-picker
  217. v-model="addFormData.requestDate"
  218. type="date"
  219. value-format="yyyy-MM-dd"
  220. placeholder="选择日期"
  221. :disabled="isEditDialogMode"
  222. size="mini"
  223. style="width: 100%">
  224. </el-date-picker>
  225. </el-form-item>
  226. </el-col>
  227. <el-col :span="12">
  228. <el-form-item label=" " >
  229. <div style="height: 28px;"></div>
  230. </el-form-item>
  231. </el-col>
  232. </el-row>
  233. <el-row :gutter="10">
  234. <el-col :span="6">
  235. <el-form-item prop="supplierNo"><span slot="label" :class="{ 'choose-label': !isEditDialogMode && !isSupplierPageMode }" @click="!isEditDialogMode && !isSupplierPageMode && openPoSupplierDialog()">供应商编码</span>
  236. <el-input
  237. v-model="addFormData.supplierNo"
  238. readonly
  239. size="mini">
  240. </el-input>
  241. </el-form-item>
  242. </el-col>
  243. <el-col :span="10">
  244. <el-form-item label="供应商名称" prop="supplierName">
  245. <el-input v-model="addFormData.supplierName" disabled size="mini"></el-input>
  246. </el-form-item>
  247. </el-col>
  248. <el-col :span="8">
  249. <el-form-item label=" " >
  250. <el-button v-if="!isEditDialogMode && !isSupplierPageMode" type="primary" size="medium" style="margin-top:13px;" @click="openOrderSupplierDialog">从订单选择供应商</el-button>
  251. </el-form-item>
  252. </el-col>
  253. </el-row>
  254. <el-row :gutter="10">
  255. <el-col :span="6">
  256. <el-form-item label="建议验货日期" prop="needInspectDate">
  257. <el-date-picker
  258. v-model="addFormData.needInspectDate"
  259. type="date"
  260. value-format="yyyy-MM-dd"
  261. placeholder="选择日期"
  262. size="mini"
  263. style="width: 100%">
  264. </el-date-picker>
  265. </el-form-item>
  266. </el-col>
  267. <el-col :span="8">
  268. <el-form-item prop="inspectAddress">
  269. <span slot="label" class="choose-label" @click="openAddressDialog">验货地址</span>
  270. <el-input
  271. v-model="addFormData.inspectAddress"
  272. readonly
  273. @click.native="openAddressDialog"
  274. placeholder="点击标签选择验货地址"
  275. size="mini">
  276. </el-input>
  277. </el-form-item>
  278. </el-col>
  279. <el-col :span="4">
  280. <el-form-item label="城市简称">
  281. <el-input v-model="addFormData.inspectCityShort" readonly size="mini"></el-input>
  282. </el-form-item>
  283. </el-col>
  284. <el-col :span="6">
  285. <el-form-item label="联系人" prop="contact">
  286. <el-input v-model="addFormData.contact" placeholder="请输入联系人及电话" size="mini"></el-input>
  287. </el-form-item>
  288. </el-col>
  289. </el-row>
  290. </div>
  291. <!-- 步骤2:批量选择PO / 编辑态PO明细 -->
  292. <div class="po-section">
  293. <div class="section-title">
  294. <span>{{ isEditDialogMode ? 'PO明细' : '批量选择PO' }}</span>
  295. <el-button v-if="isEditDialogMode" type="success" style="margin-left: 5px" @click="openAddPoDialog">新增</el-button>
  296. </div>
  297. <!-- PO号筛选和排序工具栏 -->
  298. <div v-if="!isEditDialogMode" class="po-toolbar">
  299. <el-form :inline="true" label-width="70px" size="mini" class="add-po-search-form">
  300. <el-form-item label="PO">
  301. <el-input
  302. v-model="addPoFilter.orderNo"
  303. clearable
  304. style="width: 80px"
  305. @keyup.enter.native="filterAddPoList"/>
  306. </el-form-item>
  307. <!-- <el-form-item label="产品编码">-->
  308. <!-- <el-input-->
  309. <!-- v-model="addPoFilter.partNo"-->
  310. <!-- clearable-->
  311. <!-- style="width: 80px"-->
  312. <!-- @keyup.enter.native="filterAddPoList"/>-->
  313. <!-- </el-form-item>-->
  314. <!-- <el-form-item label="Item">-->
  315. <!-- <el-input-->
  316. <!-- v-model="addPoFilter.item"-->
  317. <!-- clearable-->
  318. <!-- style="width: 80px"-->
  319. <!-- @keyup.enter.native="filterAddPoList"/>-->
  320. <!-- </el-form-item>-->
  321. <el-form-item label="SKU">
  322. <el-input
  323. v-model="addPoFilter.sku"
  324. clearable
  325. style="width: 80px"
  326. @keyup.enter.native="filterAddPoList"/>
  327. </el-form-item>
  328. <el-form-item label="物料名称">
  329. <el-input
  330. v-model="addPoFilter.partDesc"
  331. clearable
  332. style="width: 80px"
  333. @keyup.enter.native="filterAddPoList"/>
  334. </el-form-item>
  335. <el-form-item v-if="!isSupplierPageMode" label="供应商名称">
  336. <el-input
  337. v-model="addPoFilter.supplierName"
  338. clearable
  339. style="width: 100px"
  340. @keyup.enter.native="filterAddPoList"/>
  341. </el-form-item>
  342. <el-form-item v-if="!isSupplierPageMode">
  343. <span style="cursor: pointer" slot="label" @click="getBaseList(530, 'addPoPlanner')"><a href="#">Planner</a></span>
  344. <el-input
  345. v-model="addPoFilter.planner"
  346. clearable
  347. style="width: 100px"
  348. @input="handleAddPoPlannerInput"
  349. @keyup.enter.native="filterAddPoList"
  350. />
  351. </el-form-item>
  352. <el-form-item label=" ">
  353. <el-button type="primary" size="medium" style="margin-top:13px;" @click="filterAddPoList">查询</el-button>
  354. </el-form-item>
  355. </el-form>
  356. </div>
  357. <el-table
  358. v-if="!isEditDialogMode"
  359. key="create-po-table"
  360. ref="addPoTable"
  361. :data="filteredPoList"
  362. border
  363. size="small"
  364. table-layout="fixed"
  365. height="350px"
  366. style="width: 100%; margin-top: -10px;"
  367. @selection-change="handleSelectionChange">
  368. <el-table-column v-if="!isEditDialogMode" type="selection" width="30" align="center" fixed="left" />
  369. <el-table-column prop="orderRef1" label="PO号" header-align="center" align="center" width="120"/>
  370. <el-table-column prop="orderRef2" label="PO行号" header-align="center" align="center" width="60"/>
  371. <el-table-column prop="partNo" label="产品编码" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  372. <el-table-column prop="item" label="Item" header-align="center" align="left" min-width="100" show-overflow-tooltip/>
  373. <el-table-column prop="sku" label="SKU" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  374. <el-table-column prop="partDesc" label="物料名称" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  375. <el-table-column prop="planner" label="Planner" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  376. <el-table-column prop="qty" label="订单数量" header-align="center" align="right" width="80"/>
  377. <el-table-column prop="waitInspectQty" label="未验货数量" header-align="center" align="right" width="80"/>
  378. <el-table-column label="此次验货数量" header-align="center" align="center" width="150">
  379. <template slot-scope="scope">
  380. <el-input-number
  381. v-model="scope.row.inspectQty"
  382. :min="0"
  383. :max="scope.row.waitInspectQty || 999999"
  384. size="mini"
  385. :controls="false"
  386. style="width: 100%; box-sizing: border-box;">
  387. </el-input-number>
  388. </template>
  389. </el-table-column>
  390. <el-table-column prop="shipMethod" label="运输方式" header-align="center" align="center" width="100">
  391. <template slot-scope="scope">
  392. <el-select v-model="scope.row.shipMethod" placeholder="请选择" size="mini" style="width: 100%; box-sizing: border-box;">
  393. <el-option label="空运" value="空运"></el-option>
  394. <el-option label="海运" value="海运"></el-option>
  395. <el-option label="陆运" value="陆运"></el-option>
  396. </el-select>
  397. </template>
  398. </el-table-column>
  399. <el-table-column
  400. prop="crd"
  401. label="CRD日期"
  402. header-align="center"
  403. align="center"
  404. width="160"
  405. sortable
  406. :sort-method="(a, b) => sortCrdDate(a, b)">
  407. <template slot-scope="scope">
  408. <el-date-picker
  409. v-model="scope.row.crd"
  410. type="date"
  411. value-format="yyyy-MM-dd"
  412. format="yyyy-MM-dd"
  413. placeholder="选择日期"
  414. size="mini"
  415. style="width: 100%;"
  416. />
  417. </template>
  418. </el-table-column>
  419. </el-table>
  420. <el-table
  421. v-else
  422. key="edit-po-table"
  423. :data="editPoDetailList"
  424. border
  425. size="small"
  426. table-layout="fixed"
  427. height="350px"
  428. v-loading="editPoDetailLoading"
  429. style="width: 100%; margin-top: -10px;">
  430. <el-table-column fixed="right" header-align="center" align="center" width="80" label="操作">
  431. <template slot-scope="scope">
  432. <el-link style="cursor: pointer" @click="deleteEditPoRow(scope.$index)">删除</el-link>
  433. </template>
  434. </el-table-column>
  435. <el-table-column prop="orderRef1" label="PO号" header-align="center" align="center" width="120"/>
  436. <el-table-column prop="orderRef2" label="PO行号" header-align="center" align="center" width="80"/>
  437. <el-table-column prop="partNo" label="产品编码" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  438. <el-table-column prop="item" label="Item" header-align="center" align="left" min-width="100" show-overflow-tooltip/>
  439. <el-table-column prop="sku" label="SKU" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  440. <el-table-column prop="partDesc" label="物料名称" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  441. <el-table-column prop="totalQty" label="未验货数量" header-align="center" align="right" width="90"/>
  442. <el-table-column label="验货数量" header-align="center" align="center" width="150">
  443. <template slot-scope="scope">
  444. <el-input-number
  445. v-if="editPoEditMode"
  446. v-model="scope.row.qty"
  447. :min="0"
  448. size="mini"
  449. :controls="false"
  450. style="width: 100%;">
  451. </el-input-number>
  452. <span v-else>{{ scope.row.qty }}</span>
  453. </template>
  454. </el-table-column>
  455. <el-table-column label="运输方式" header-align="center" align="center" width="120">
  456. <template slot-scope="scope">
  457. <el-select v-if="editPoEditMode" v-model="scope.row.shipMothod" placeholder="请选择" size="mini" style="width: 100%;">
  458. <el-option label="空运" value="空运"></el-option>
  459. <el-option label="海运" value="海运"></el-option>
  460. <el-option label="陆运" value="陆运"></el-option>
  461. </el-select>
  462. <span v-else>{{ scope.row.shipMothod }}</span>
  463. </template>
  464. </el-table-column>
  465. <el-table-column label="CRD日期" header-align="center" align="center" width="160">
  466. <template slot-scope="scope">
  467. <el-date-picker
  468. v-if="editPoEditMode"
  469. v-model="scope.row.crd"
  470. type="date"
  471. value-format="yyyy-MM-dd"
  472. format="yyyy-MM-dd"
  473. placeholder="选择日期"
  474. size="mini"
  475. style="width: 100%;">
  476. </el-date-picker>
  477. <span v-else>{{ scope.row.crd }}</span>
  478. </template>
  479. </el-table-column>
  480. </el-table>
  481. </div>
  482. </el-form>
  483. <div slot="footer" class="dialog-footer">
  484. <el-button type="primary" @click="handleSaveAdd">保存</el-button>
  485. <el-button @click="handleCloseAddDialog">关闭</el-button>
  486. </div>
  487. </el-dialog>
  488. <el-dialog
  489. title="选择供应商"
  490. :visible.sync="poSupplierDialogVisible"
  491. width="760px"
  492. append-to-body
  493. :close-on-click-modal="false">
  494. <el-form :inline="true" label-width="80px" label-position="top" size="mini" class="po-supplier-search-form">
  495. <el-form-item label="供应商编码">
  496. <el-input
  497. v-model="poSupplierSearch.supplierNo"
  498. clearable
  499. style="width: 120px"
  500. @keyup.enter.native="searchPoSupplierList"/>
  501. </el-form-item>
  502. <el-form-item label="供应商名称" >
  503. <el-input
  504. v-model="poSupplierSearch.supplierName"
  505. clearable
  506. style="width: 200px"
  507. @keyup.enter.native="searchPoSupplierList"/>
  508. </el-form-item>
  509. <el-form-item label=" ">
  510. <el-button type="primary" size="medium" @click="searchPoSupplierList">查询</el-button>
  511. <el-button size="medium" @click="resetPoSupplierSearch">重置</el-button>
  512. </el-form-item>
  513. </el-form>
  514. <el-table
  515. ref="poSupplierTable"
  516. :data="poSupplierList"
  517. border
  518. height="360px"
  519. v-loading="poSupplierLoading"
  520. highlight-current-row
  521. @current-change="onPoSupplierCurrentChange"
  522. @row-dblclick="onPoSupplierRowDblClick">
  523. <el-table-column prop="supplierNo" label="供应商编码" header-align="center" align="left" min-width="140" show-overflow-tooltip />
  524. <el-table-column prop="supplierName" label="供应商名称" header-align="center" align="left" min-width="220" show-overflow-tooltip />
  525. <el-table-column prop="poDetailCount" label="PO明细数" header-align="center" align="right" min-width="120" />
  526. <el-table-column prop="planner" label="Planner" header-align="center" align="left" min-width="120" show-overflow-tooltip />
  527. </el-table>
  528. <el-pagination
  529. style="margin-top: 10px; text-align: right"
  530. @size-change="onPoSupplierPageSizeChange"
  531. @current-change="onPoSupplierPageCurrentChange"
  532. :current-page="poSupplierPageIndex"
  533. :page-sizes="[20, 50, 100, 200]"
  534. :page-size="poSupplierPageSize"
  535. :total="poSupplierTotal"
  536. layout="total, sizes, prev, pager, next, jumper">
  537. </el-pagination>
  538. <div slot="footer" class="dialog-footer">
  539. <el-button type="primary" @click="confirmPoSupplierSelect">确认</el-button>
  540. <el-button @click="poSupplierDialogVisible = false">取消</el-button>
  541. </div>
  542. </el-dialog>
  543. <el-dialog
  544. title="选择验货地址"
  545. :visible.sync="addressDialogVisible"
  546. width="980px"
  547. append-to-body
  548. :close-on-click-modal="false">
  549. <el-form :inline="true" label-width="80px" label-position="top" size="mini" class="po-supplier-search-form">
  550. <el-form-item label="供应商编码">
  551. <el-input v-model="addFormData.supplierNo" readonly style="width: 140px" />
  552. </el-form-item>
  553. <el-form-item label="供应商名称">
  554. <el-input v-model="addFormData.supplierName" readonly style="width: 220px" />
  555. </el-form-item>
  556. <el-form-item label=" ">
  557. <el-button
  558. type="primary"
  559. size="medium"
  560. style="margin-top: 0px"
  561. @click="openAddressCreateDialog">新增地址</el-button>
  562. </el-form-item>
  563. <!-- <el-form-item label="地址关键词">-->
  564. <!-- <el-input-->
  565. <!-- v-model="addressSearch.keyword"-->
  566. <!-- clearable-->
  567. <!-- style="width: 260px"-->
  568. <!-- @keyup.enter.native="searchAddressList" />-->
  569. <!-- </el-form-item>-->
  570. <!-- <el-form-item label=" ">-->
  571. <!-- <el-button type="primary" size="medium" @click="searchAddressList">查询</el-button>-->
  572. <!-- <el-button size="medium" @click="resetAddressSearch">重置</el-button>-->
  573. <!-- </el-form-item>-->
  574. </el-form>
  575. <el-table
  576. ref="addressTable"
  577. :data="addressList"
  578. border
  579. height="360px"
  580. v-loading="addressLoading"
  581. highlight-current-row
  582. @current-change="onAddressCurrentChange"
  583. @row-dblclick="onAddressRowDblClick">
  584. <el-table-column prop="addressId" label="地址ID" header-align="center" align="left" min-width="120" show-overflow-tooltip />
  585. <el-table-column prop="companyName" label="公司名称" header-align="center" align="left" min-width="180" show-overflow-tooltip />
  586. <el-table-column prop="cityShort" label="城市简称" header-align="center" align="left" min-width="120" show-overflow-tooltip />
  587. <el-table-column prop="address" label="验货地址" header-align="center" align="left" min-width="280" show-overflow-tooltip />
  588. <el-table-column prop="contact" label="联系人" header-align="center" align="left" min-width="120" show-overflow-tooltip />
  589. <el-table-column prop="phoneNo" label="联系电话" header-align="center" align="left" min-width="140" show-overflow-tooltip />
  590. <el-table-column prop="email" label="邮箱" header-align="center" align="left" min-width="180" show-overflow-tooltip />
  591. <el-table-column v-if="hasAddressEditPermission" fixed="right" header-align="center" align="center" width="100" label="操作">
  592. <template slot-scope="scope">
  593. <el-link style="cursor: pointer" @click="editAddress(scope.row)">编辑</el-link>
  594. </template>
  595. </el-table-column>
  596. </el-table>
  597. <el-pagination
  598. style="margin-top: 10px; text-align: right"
  599. @size-change="onAddressPageSizeChange"
  600. @current-change="onAddressPageCurrentChange"
  601. :current-page="addressPageIndex"
  602. :page-sizes="[20, 50, 100, 200]"
  603. :page-size="addressPageSize"
  604. :total="addressTotal"
  605. layout="total, sizes, prev, pager, next, jumper">
  606. </el-pagination>
  607. <div slot="footer" class="dialog-footer">
  608. <el-button type="primary" @click="confirmAddressSelect">确认</el-button>
  609. <el-button @click="addressDialogVisible = false">取消</el-button>
  610. </div>
  611. </el-dialog>
  612. <!-- 新增供应商地址(与供应商主数据地址页签新增弹窗保持一致) -->
  613. <el-dialog
  614. title="供应商地址"
  615. :close-on-click-modal="false"
  616. v-drag
  617. :visible.sync="addressCreateDialogVisible"
  618. @closed="handleAddressCreateDialogClosed"
  619. width="600px"
  620. append-to-body>
  621. <el-form
  622. ref="addressCreateFormRef"
  623. :model="addressCreateForm"
  624. :rules="addressCreateRules"
  625. label-position="top"
  626. label-width="100px">
  627. <!-- 供应商ID / 城市简称 / 是否在用 -->
  628. <el-row :gutter="20">
  629. <el-col :span="8">
  630. <el-form-item label="供应商ID" prop="supplierId">
  631. <el-input v-model="addressCreateForm.supplierId" disabled />
  632. </el-form-item>
  633. </el-col>
  634. <el-col :span="8">
  635. <el-form-item label="所在城市简称" prop="cityShort">
  636. <el-input v-model="addressCreateForm.cityShort" />
  637. </el-form-item>
  638. </el-col>
  639. <el-col :span="8">
  640. <el-form-item label="是否在用" prop="active">
  641. <el-select v-model="addressCreateForm.active" style="width: 100%">
  642. <el-option label="Y" value="Y" />
  643. <el-option label="N" value="N" />
  644. </el-select>
  645. </el-form-item>
  646. </el-col>
  647. </el-row>
  648. <!-- 公司名称 -->
  649. <el-row :gutter="20">
  650. <el-col :span="24">
  651. <el-form-item label="公司名称" prop="companyName">
  652. <el-input v-model="addressCreateForm.companyName" />
  653. </el-form-item>
  654. </el-col>
  655. </el-row>
  656. <!-- 联系人 / 电话 / 地址类型 -->
  657. <el-row :gutter="20">
  658. <el-col :span="8">
  659. <el-form-item label="联系人" prop="contact">
  660. <el-input v-model="addressCreateForm.contact" />
  661. </el-form-item>
  662. </el-col>
  663. <el-col :span="8">
  664. <el-form-item label="联系电话" prop="phoneNo">
  665. <el-input v-model="addressCreateForm.phoneNo" />
  666. </el-form-item>
  667. </el-col>
  668. <el-col :span="8">
  669. <el-form-item label="地址类型" prop="addressType">
  670. <sys-dict-select
  671. v-model="addressCreateForm.addressType"
  672. dict-type="address_type"
  673. placeholder="请选择地址类型"
  674. width="100%"
  675. filterable
  676. />
  677. </el-form-item>
  678. </el-col>
  679. </el-row>
  680. <!-- 邮箱 -->
  681. <el-row :gutter="20">
  682. <el-col :span="24">
  683. <el-form-item label="邮箱" prop="email">
  684. <el-input v-model="addressCreateForm.email" />
  685. </el-form-item>
  686. </el-col>
  687. </el-row>
  688. <!-- 原产国 / 装运港 -->
  689. <el-row :gutter="20">
  690. <el-col :span="12">
  691. <el-form-item label="原产国" prop="originCountry">
  692. <el-input v-model="addressCreateForm.originCountry" />
  693. </el-form-item>
  694. </el-col>
  695. <el-col :span="12">
  696. <el-form-item prop="portOfLoading">
  697. <span slot="label" style="cursor: pointer" @click="getBaseList(2018, 'addressPortOfLoading')"><a href="#">装运港</a></span>
  698. <el-input v-model="addressCreateForm.portOfLoading" readonly />
  699. </el-form-item>
  700. </el-col>
  701. </el-row>
  702. <!-- 地址 -->
  703. <el-row :gutter="20">
  704. <el-col :span="24">
  705. <el-form-item label="地址" prop="address">
  706. <el-input v-model="addressCreateForm.address" />
  707. </el-form-item>
  708. </el-col>
  709. </el-row>
  710. <!-- 备注 -->
  711. <el-row :gutter="20">
  712. <el-col :span="24">
  713. <el-form-item label="备注" prop="memo">
  714. <el-input v-model="addressCreateForm.memo" type="textarea" :rows="1" />
  715. </el-form-item>
  716. </el-col>
  717. </el-row>
  718. </el-form>
  719. <span slot="footer" class="dialog-footer" style="margin-top: 10px; display: block">
  720. <el-button type="primary" :loading="addressCreateSaving" @click="saveCreatedAddress">保存</el-button>
  721. <el-button :disabled="addressCreateSaving" @click="addressCreateDialogVisible = false">关闭</el-button>
  722. </span>
  723. </el-dialog>
  724. <!-- 编辑供应商地址(与com_srmSupplier_Address.vue的修改弹窗保持一致) -->
  725. <el-dialog
  726. title="供应商地址"
  727. :close-on-click-modal="false"
  728. v-drag
  729. :visible.sync="addressEditDialogVisible"
  730. @closed="handleAddressEditDialogClosed"
  731. width="600px"
  732. append-to-body>
  733. <el-form
  734. ref="addressEditFormRef"
  735. :model="addressEditForm"
  736. :rules="addressCreateRules"
  737. label-position="top"
  738. label-width="100px">
  739. <!-- 供应商ID / 城市简称 / 是否在用 -->
  740. <el-row :gutter="20">
  741. <el-col :span="8">
  742. <el-form-item label="供应商ID" prop="supplierId">
  743. <el-input v-model="addressEditForm.supplierId" disabled />
  744. </el-form-item>
  745. </el-col>
  746. <el-col :span="8">
  747. <el-form-item label="所在城市简称" prop="cityShort">
  748. <el-input v-model="addressEditForm.cityShort" />
  749. </el-form-item>
  750. </el-col>
  751. <el-col :span="8">
  752. <el-form-item label="是否在用" prop="active">
  753. <el-select v-model="addressEditForm.active" style="width: 100%">
  754. <el-option label="Y" value="Y" />
  755. <el-option label="N" value="N" />
  756. </el-select>
  757. </el-form-item>
  758. </el-col>
  759. </el-row>
  760. <!-- 公司名称 -->
  761. <el-row :gutter="20">
  762. <el-col :span="24">
  763. <el-form-item label="公司名称" prop="companyName">
  764. <el-input v-model="addressEditForm.companyName" />
  765. </el-form-item>
  766. </el-col>
  767. </el-row>
  768. <!-- 联系人 / 电话 / 地址类型 -->
  769. <el-row :gutter="20">
  770. <el-col :span="8">
  771. <el-form-item label="联系人" prop="contact">
  772. <el-input v-model="addressEditForm.contact" />
  773. </el-form-item>
  774. </el-col>
  775. <el-col :span="8">
  776. <el-form-item label="联系电话" prop="phoneNo">
  777. <el-input v-model="addressEditForm.phoneNo" />
  778. </el-form-item>
  779. </el-col>
  780. <el-col :span="8">
  781. <el-form-item label="地址类型" prop="addressType">
  782. <sys-dict-select
  783. v-model="addressEditForm.addressType"
  784. dict-type="address_type"
  785. placeholder="请选择地址类型"
  786. width="100%"
  787. filterable
  788. />
  789. </el-form-item>
  790. </el-col>
  791. </el-row>
  792. <!-- 邮箱 -->
  793. <el-row :gutter="20">
  794. <el-col :span="24">
  795. <el-form-item label="邮箱" prop="email">
  796. <el-input v-model="addressEditForm.email" />
  797. </el-form-item>
  798. </el-col>
  799. </el-row>
  800. <!-- 原产国 / 装运港 -->
  801. <el-row :gutter="20">
  802. <el-col :span="12">
  803. <el-form-item label="原产国" prop="originCountry">
  804. <el-input v-model="addressEditForm.originCountry" />
  805. </el-form-item>
  806. </el-col>
  807. <el-col :span="12">
  808. <el-form-item prop="portOfLoading">
  809. <span slot="label" style="cursor: pointer" @click="getBaseList(2018, 'addressEditPortOfLoading')"><a href="#">装运港</a></span>
  810. <el-input v-model="addressEditForm.portOfLoading" readonly />
  811. </el-form-item>
  812. </el-col>
  813. </el-row>
  814. <!-- 地址 -->
  815. <el-row :gutter="20">
  816. <el-col :span="24">
  817. <el-form-item label="地址" prop="address">
  818. <el-input v-model="addressEditForm.address" />
  819. </el-form-item>
  820. </el-col>
  821. </el-row>
  822. <!-- 备注 -->
  823. <el-row :gutter="20">
  824. <el-col :span="24">
  825. <el-form-item label="备注" prop="memo">
  826. <el-input v-model="addressEditForm.memo" type="textarea" :rows="1" />
  827. </el-form-item>
  828. </el-col>
  829. </el-row>
  830. </el-form>
  831. <span slot="footer" class="dialog-footer" style="margin-top: 10px; display: block">
  832. <el-button type="primary" :loading="addressEditSaving" @click="saveEditedAddress">保存</el-button>
  833. <el-button :disabled="addressEditSaving" @click="addressEditDialogVisible = false">关闭</el-button>
  834. </span>
  835. </el-dialog>
  836. <!-- 新增PO明细弹窗 -->
  837. <el-dialog
  838. title="选择PO明细"
  839. :visible.sync="addPoDialogVisible"
  840. width="80%"
  841. append-to-body
  842. :close-on-click-modal="false">
  843. <div class="rq">
  844. <el-table
  845. class="po-edit-table"
  846. ref="addPoSelectTable"
  847. :data="addPoSelectList"
  848. border
  849. size="small"
  850. table-layout="fixed"
  851. height="450px"
  852. v-loading="addPoSelectLoading"
  853. style="width: 100%; margin-top: -10px;"
  854. @selection-change="handleAddPoSelectionChange">
  855. <el-table-column type="selection" width="40" align="center" fixed="left" />
  856. <el-table-column prop="orderRef1" label="PO号" header-align="center" align="center" width="120"/>
  857. <el-table-column prop="orderRef2" label="PO行号" header-align="center" align="center" width="80"/>
  858. <el-table-column prop="partNo" label="产品编码" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  859. <el-table-column prop="item" label="Item" header-align="center" align="left" min-width="100" show-overflow-tooltip/>
  860. <el-table-column prop="sku" label="SKU" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  861. <el-table-column prop="partDesc" label="物料名称" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
  862. <el-table-column prop="planner" label="Planner" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
  863. <el-table-column prop="qty" label="订单数量" header-align="center" align="right" width="90"/>
  864. <el-table-column prop="waitInspectQty" label="未验货数量" header-align="center" align="right" width="90"/>
  865. <el-table-column label="此次验货数量" header-align="center" align="center" width="150">
  866. <template slot-scope="scope">
  867. <el-input-number
  868. v-model="scope.row.inspectQty"
  869. :min="0"
  870. :max="scope.row.waitInspectQty || 999999"
  871. size="mini"
  872. :controls="false"
  873. style="width: 100%;">
  874. </el-input-number>
  875. </template>
  876. </el-table-column>
  877. <el-table-column label="运输方式" header-align="center" align="center" width="120">
  878. <template slot-scope="scope">
  879. <el-select v-model="scope.row.shipMethod" placeholder="请选择" size="mini" style="width: 100%;">
  880. <el-option label="空运" value="空运"></el-option>
  881. <el-option label="海运" value="海运"></el-option>
  882. <el-option label="陆运" value="陆运"></el-option>
  883. </el-select>
  884. </template>
  885. </el-table-column>
  886. <el-table-column label="CRD日期" header-align="center" align="center" width="160">
  887. <template slot-scope="scope">
  888. <el-date-picker
  889. v-model="scope.row.crd"
  890. type="date"
  891. value-format="yyyy-MM-dd"
  892. format="yyyy-MM-dd"
  893. placeholder="选择日期"
  894. size="mini"
  895. style="width: 80%;">
  896. </el-date-picker>
  897. </template>
  898. </el-table-column>
  899. </el-table>
  900. </div>
  901. <el-pagination
  902. style="margin-top: 10px; text-align: right"
  903. @size-change="onAddPoPageSizeChange"
  904. @current-change="onAddPoPageCurrentChange"
  905. :current-page="addPoSelectPageIndex"
  906. :page-sizes="[20, 50, 100, 200]"
  907. :page-size="addPoSelectPageSize"
  908. :total="addPoSelectTotal"
  909. layout="total, sizes, prev, pager, next, jumper">
  910. </el-pagination>
  911. <div slot="footer" class="dialog-footer">
  912. <el-button type="primary" @click="confirmAddPoSelect">确认添加</el-button>
  913. <el-button @click="addPoDialogVisible = false">取消</el-button>
  914. </div>
  915. </el-dialog>
  916. <el-dialog
  917. title="从订单选择供应商"
  918. :visible.sync="orderSupplierDialogVisible"
  919. width="1260px"
  920. append-to-body
  921. :close-on-click-modal="false">
  922. <el-form :inline="true" label-position="top" class="search-form-inline">
  923. <el-form-item label="PO">
  924. <el-input
  925. v-model="orderSupplierSearch.orderNo"
  926. clearable
  927. style="width: 150px"
  928. @keyup.enter.native="searchOrderSupplierByPo"/>
  929. </el-form-item>
  930. <el-form-item label="产品编码">
  931. <el-input
  932. v-model="orderSupplierSearch.partNo"
  933. clearable
  934. style="width: 150px"
  935. @keyup.enter.native="searchOrderSupplierByPo"/>
  936. </el-form-item>
  937. <el-form-item label="Item">
  938. <el-input
  939. v-model="orderSupplierSearch.item"
  940. clearable
  941. style="width: 140px"
  942. @keyup.enter.native="searchOrderSupplierByPo"/>
  943. </el-form-item>
  944. <el-form-item label="SKU">
  945. <el-input
  946. v-model="orderSupplierSearch.sku"
  947. clearable
  948. style="width: 140px"
  949. @keyup.enter.native="searchOrderSupplierByPo"/>
  950. </el-form-item>
  951. <el-form-item label="物料名称">
  952. <el-input
  953. v-model="orderSupplierSearch.partDesc"
  954. clearable
  955. style="width: 200px"
  956. @keyup.enter.native="searchOrderSupplierByPo"/>
  957. </el-form-item>
  958. <el-form-item label="供应商名称">
  959. <el-input
  960. v-model="orderSupplierSearch.supplierName"
  961. clearable
  962. style="width: 200px"
  963. @keyup.enter.native="searchOrderSupplierByPo"/>
  964. </el-form-item>
  965. <el-form-item>
  966. <span style="cursor: pointer" slot="label" @click="getBaseList(530, 'orderSupplierPlanner')"><a href="#">Planner</a></span>
  967. <el-input
  968. v-model="orderSupplierSearch.planner"
  969. clearable
  970. style="width: 140px"
  971. @keyup.enter.native="searchOrderSupplierByPo"
  972. />
  973. </el-form-item>
  974. <el-form-item label=" ">
  975. <el-button type="primary" @click="searchOrderSupplierByPo">查询</el-button>
  976. <el-button @click="resetOrderSupplierSearch">重置</el-button>
  977. </el-form-item>
  978. </el-form>
  979. <el-table
  980. ref="orderSupplierTable"
  981. :data="orderSupplierList"
  982. border
  983. height="430px"
  984. v-loading="orderSupplierLoading"
  985. highlight-current-row
  986. @current-change="onOrderSupplierCurrentChange"
  987. @row-dblclick="onOrderSupplierRowDblClick"
  988. :default-sort="{ prop: 'crd', order: 'descending' }">
  989. <el-table-column prop="supplierNo" label="供应商编码" header-align="center" align="left" min-width="120" fixed="left" show-overflow-tooltip />
  990. <el-table-column prop="supplierName" label="供应商名称" header-align="center" align="left" min-width="180" fixed="left" show-overflow-tooltip />
  991. <el-table-column prop="planner" label="Planner" header-align="center" align="left" min-width="120" show-overflow-tooltip />
  992. <el-table-column prop="orderRef1" label="PO号" header-align="center" align="center" min-width="120" show-overflow-tooltip />
  993. <el-table-column prop="orderRef2" label="PO行号" header-align="center" align="center" min-width="80" show-overflow-tooltip />
  994. <el-table-column prop="partNo" label="产品编码" header-align="center" align="left" min-width="140" show-overflow-tooltip />
  995. <el-table-column prop="item" label="Item" header-align="center" align="left" min-width="120" show-overflow-tooltip />
  996. <el-table-column prop="sku" label="SKU" header-align="center" align="left" min-width="140" show-overflow-tooltip />
  997. <el-table-column prop="partDesc" label="物料名称" header-align="center" align="left" min-width="170" show-overflow-tooltip />
  998. <el-table-column prop="waitInspectQty" label="未验货数量" header-align="center" align="right" min-width="100" />
  999. <el-table-column
  1000. prop="crd"
  1001. label="CRD日期"
  1002. header-align="center"
  1003. align="center"
  1004. min-width="120"
  1005. sortable
  1006. :sort-method="(a, b) => sortCrdDate(a, b)" />
  1007. </el-table>
  1008. <el-pagination
  1009. style="margin-top: 10px; text-align: right"
  1010. @size-change="onOrderSupplierPageSizeChange"
  1011. @current-change="onOrderSupplierPageCurrentChange"
  1012. :current-page="orderSupplierPageIndex"
  1013. :page-sizes="[20, 50, 100, 200]"
  1014. :page-size="orderSupplierPageSize"
  1015. :total="orderSupplierTotal"
  1016. layout="total, sizes, prev, pager, next, jumper">
  1017. </el-pagination>
  1018. <div slot="footer" class="dialog-footer">
  1019. <el-button type="primary" @click="confirmOrderSupplierSelect">确认</el-button>
  1020. <el-button @click="orderSupplierDialogVisible = false">取消</el-button>
  1021. </div>
  1022. </el-dialog>
  1023. <!-- 导入弹窗 -->
  1024. <el-dialog title="验货申请数据导入" :visible.sync="uploadDialogVisible" width="800px">
  1025. <!-- 选择文件 -->
  1026. <div style="margin-bottom:15px;display:flex;align-items:center">
  1027. <span style="margin-right:10px">请选择文件</span>
  1028. <el-input v-model="uploadFileName" style="width:400px;margin-right:10px" readonly></el-input>
  1029. <el-upload ref="upload" action="/api/inspection/upload"
  1030. :show-file-list="false" :on-change="handleFileChange"
  1031. :auto-upload="false">
  1032. <el-button type="primary">选择文件</el-button>
  1033. </el-upload>
  1034. <el-button type="success" style="margin-left:10px" @click="previewUpload">上传</el-button>
  1035. <el-button type="primary" @click="downloadTemplate" style="margin-left:10px">
  1036. <i class="el-icon-download"></i> 下载模板
  1037. </el-button>
  1038. </div>
  1039. <!-- 预览表格 -->
  1040. <el-table
  1041. :data="uploadPreviewList"
  1042. border
  1043. height="250"
  1044. style="width:100%;margin-top:10px"
  1045. >
  1046. <el-table-column prop="poNo" label="PO号" align="center" width="auto"></el-table-column>
  1047. <el-table-column prop="poItemNo" label="PO行号" align="center" width="auto"></el-table-column>
  1048. <el-table-column prop="partNo" label="产品编码" align="center" width="auto"></el-table-column>
  1049. <el-table-column prop="qty" label="验货数量" align="center" width="auto"></el-table-column>
  1050. <el-table-column prop="shipMethod" label="运输方式" align="center" width="auto"></el-table-column>
  1051. <el-table-column prop="crd" label="CRD" align="center" width="auto"></el-table-column>
  1052. <el-table-column prop="suggestInspectDate" label="建议验货日期" align="center" width="auto"></el-table-column>
  1053. <el-table-column prop="inspectAddress" label="验货地址" align="center" width="auto"></el-table-column>
  1054. <el-table-column prop="inspectContract" label="联系人" align="center" width="auto"></el-table-column>
  1055. </el-table>
  1056. <!-- 按钮 -->
  1057. <div style="margin-top:20px;text-align:center">
  1058. <el-button type="primary" @click="confirmUpload">保存</el-button>
  1059. <el-button @click="uploadDialogVisible=false" style="margin-right:30px">关闭</el-button>
  1060. </div>
  1061. </el-dialog>
  1062. </div>
  1063. </template>
  1064. <script>
  1065. import { searchInspectionRequestHeaderList, queryPoPage, queryPoPageExclude, queryPoSupplierPage, queryPoSupplierOrderPage, saveInspectionRequest, deleteInspectionRequest, confirmInspectionRequest, applyChangeInspectionRequest, getInspectionRequestDetailSubList, updateInspectionRequest, downloadTemplate, previewUpload, batchSave, addInspectionDetails, editInspectionDetails, deleteInspectionDetails, editSaveInspectionRequest } from '@/api/inspection/inspectionRequestHeader.js'
  1066. import { searchSrmSupplierAddressList, createSrmSupplierAddress, updateSrmSupplierAddress, searchSrmSupplierList } from '@/api/srm/srmSupplier.js'
  1067. import { getPermissionValue } from '@/api/sys/specialSecurity.js'
  1068. import Chooselist from '@/views/modules/common/Chooselist_eam'
  1069. import SysDictSelect from '@/components/dict/SysDictSelect.vue'
  1070. import ComInspectionRequestDetail from './com_inspectionRequestDetail.vue'
  1071. import ComInspectionRequestDetailTab from './com_inspectionRequestDetailTab.vue'
  1072. import ComInspectionRequestPoDetailTab from './com_inspectionRequestPoDetailTab.vue'
  1073. import ComInspectionResultTab from './com_inspectionResultTab.vue'
  1074. import ComInspectionRequestAttachmentTab from './com_inspectionRequestAttachmentTab.vue'
  1075. import ComInspectionRequestFeeTab from './com_inspectionRequestFeeTab.vue'
  1076. import { fetchSupplierDetail } from '@/utils/supplierChooselistHelper'
  1077. import excel from '@/utils/excel-util.js'
  1078. export default {
  1079. props: {
  1080. /**
  1081. * 供应商专用模式开关
  1082. * - false:通用验货申请页(默认,内部人员场景)
  1083. * - true :供应商专用页(由 inspectionRequestListSupplier.vue 传入)
  1084. *
  1085. * 打开后会触发:
  1086. * 1) 查询条件精简;
  1087. * 2) 查询强制按当前登录用户绑定供应商编码过滤;
  1088. * 3) 新增时供应商固定为当前登录用户供应商;
  1089. * 4) 隐藏从订单选择供应商入口及部分PO筛选项。
  1090. */
  1091. supplierMode: {
  1092. type: Boolean,
  1093. default: false
  1094. }
  1095. },
  1096. components: {
  1097. Chooselist,
  1098. SysDictSelect,
  1099. InspectionRequestDetail: ComInspectionRequestDetail,
  1100. InspectionRequestDetailTab: ComInspectionRequestDetailTab,
  1101. InspectionRequestPoDetailTab: ComInspectionRequestPoDetailTab,
  1102. InspectionResultTab: ComInspectionResultTab,
  1103. InspectionRequestAttachmentTab: ComInspectionRequestAttachmentTab,
  1104. InspectionRequestFeeTab: ComInspectionRequestFeeTab
  1105. },
  1106. data () {
  1107. return {
  1108. functionId: this.$route.meta.menuId,
  1109. height: 400,
  1110. detailHeight: 400,
  1111. currentRow: {},
  1112. tagNo: '',
  1113. searchType: '',
  1114. // 供应商模式上下文:来自 /sys/user/info(user.supplierNo / user.supplierName)
  1115. currentSupplierNo: '',
  1116. currentSupplierName: '',
  1117. activeTab: 'base',
  1118. // 新增弹窗相关数据
  1119. addDialogVisible: false,
  1120. addDialogMode: 'create',
  1121. addFormData: {
  1122. requestNo: '',
  1123. requestDate: '',
  1124. supplierNo: '',
  1125. supplierName: '',
  1126. inspectAddressId: '',
  1127. inspectAddress: '',
  1128. inspectCityShort: '',
  1129. contact: '',
  1130. needInspectDate: ''
  1131. },
  1132. addRules: {
  1133. requestDate: [
  1134. { required: true, message: '请选择申请日期', trigger: 'change' }
  1135. ],
  1136. supplierNo: [
  1137. { required: true, message: '请选择供应商', trigger: 'change' }
  1138. ],
  1139. inspectAddress: [
  1140. { required: true, message: '请选择验货地址', trigger: 'change' }
  1141. ],
  1142. needInspectDate: [
  1143. { required: true, message: '请选择建议验货日期', trigger: 'change' }
  1144. ]
  1145. },
  1146. poList: [],
  1147. filteredPoList: [],
  1148. editPoDetailList: [],
  1149. editPoDetailLoading: false,
  1150. editPoEditMode: false, // 编辑PO明细的编辑模式
  1151. addPoDialogVisible: false, // 新增PO弹窗
  1152. addPoSelectList: [], // 新增PO选择列表
  1153. addPoSelectLoading: false, // 新增PO加载状态
  1154. addPoSelectPageIndex: 1, // 新增PO当前页
  1155. addPoSelectPageSize: 20, // 新增PO每页条数
  1156. addPoSelectTotal: 0, // 新增PO总数
  1157. addPoSelectedRows: [], // 新增PO选中的行
  1158. addPoSearch: {
  1159. orderRef1: '',
  1160. partNo: '',
  1161. sku: '',
  1162. partDesc: ''
  1163. },
  1164. addPoFilter: {
  1165. orderNo: '',
  1166. partNo: '',
  1167. item: '',
  1168. sku: '',
  1169. partDesc: '',
  1170. supplierName: '',
  1171. planner: ''
  1172. },
  1173. addPoPlannerCodeFromChooser: '',
  1174. addPoPlannerDisplayFromChooser: '',
  1175. selectedPoList: [],
  1176. poSupplierDialogVisible: false,
  1177. poSupplierLoading: false,
  1178. poSupplierList: [],
  1179. poSupplierCurrentRow: null,
  1180. poSupplierPageIndex: 1,
  1181. poSupplierPageSize: 20,
  1182. poSupplierTotal: 0,
  1183. poSupplierSearch: {
  1184. supplierNo: '',
  1185. supplierName: ''
  1186. },
  1187. addressDialogVisible: false,
  1188. addressLoading: false,
  1189. addressList: [],
  1190. addressCurrentRow: null,
  1191. addressPageIndex: 1,
  1192. addressPageSize: 20,
  1193. addressTotal: 0,
  1194. addressSearch: {
  1195. keyword: ''
  1196. },
  1197. // 权限控制:SRM0002 - 是否允许编辑验货地址
  1198. hasAddressEditPermission: false,
  1199. // 新增供应商地址弹窗(用于验货地址弹窗内快速维护地址)
  1200. addressCreateDialogVisible: false,
  1201. addressCreateSaving: false,
  1202. addressCreateForm: {
  1203. supplierId: '',
  1204. site: this.$store.state.user.site || this.$store.state.user.currentSite || '',
  1205. addressId: '',
  1206. companyName: '',
  1207. cityShort: '',
  1208. contact: '',
  1209. phoneNo: '',
  1210. address: '',
  1211. addressType: '验货地址',
  1212. active: 'Y',
  1213. email: '',
  1214. originCountry: '',
  1215. portOfLoading: '',
  1216. memo: '',
  1217. createBy: this.$store.state.user.name,
  1218. updateBy: this.$store.state.user.name
  1219. },
  1220. // 编辑供应商地址弹窗
  1221. addressEditDialogVisible: false,
  1222. addressEditSaving: false,
  1223. addressEditForm: {
  1224. supplierId: '',
  1225. site: this.$store.state.user.site || this.$store.state.user.currentSite || '',
  1226. addressId: '',
  1227. companyName: '',
  1228. cityShort: '',
  1229. contact: '',
  1230. phoneNo: '',
  1231. address: '',
  1232. addressType: '验货地址',
  1233. active: 'Y',
  1234. email: '',
  1235. originCountry: '',
  1236. portOfLoading: '',
  1237. memo: '',
  1238. createBy: this.$store.state.user.name,
  1239. updateBy: this.$store.state.user.name
  1240. },
  1241. addressCreateRules: {
  1242. supplierId: [
  1243. { required: true, validator: this.validateAddressCreateField, trigger: 'blur' }
  1244. ],
  1245. site: [
  1246. { required: true, validator: this.validateAddressCreateField, trigger: 'blur' }
  1247. ],
  1248. cityShort: [
  1249. { required: true, validator: this.validateAddressCreateField, message: ' ', trigger: 'blur' }
  1250. ],
  1251. address: [
  1252. { required: true, validator: this.validateAddressCreateField, message: ' ', trigger: 'blur' }
  1253. ],
  1254. companyName: [
  1255. { required: true, validator: this.validateAddressCreateField, message: ' ', trigger: 'blur' }
  1256. ],
  1257. contact: [
  1258. { required: true, validator: this.validateAddressCreateField, message: ' ', trigger: 'blur' }
  1259. ],
  1260. phoneNo: [
  1261. { required: true, validator: this.validateAddressCreateField, message: ' ', trigger: 'blur' }
  1262. ],
  1263. addressType: [
  1264. { required: true, validator: this.validateAddressCreateField, message: ' ', trigger: 'change' }
  1265. ]
  1266. },
  1267. applyChangeDialogVisible: false,
  1268. applyChangeLoading: false,
  1269. applyChangeForm: {
  1270. requestNo: '',
  1271. statusDb: '',
  1272. changeRemark: ''
  1273. },
  1274. orderSupplierDialogVisible: false,
  1275. orderSupplierLoading: false,
  1276. orderSupplierList: [],
  1277. orderSupplierCurrentRow: null,
  1278. orderSupplierPageIndex: 1,
  1279. orderSupplierPageSize: 50,
  1280. orderSupplierTotal: 0,
  1281. orderSupplierSearch: {
  1282. orderNo: '',
  1283. partNo: '',
  1284. item: '',
  1285. sku: '',
  1286. partDesc: '',
  1287. supplierName: '',
  1288. planner: ''
  1289. },
  1290. pendingAutoSelectPoRow: null,
  1291. // 上传相关
  1292. uploadDialogVisible: false,
  1293. uploadFileName: '',
  1294. uploadFile: null,
  1295. uploadPreviewList: [],
  1296. searchData: {
  1297. requestNo: '',
  1298. supplierNo: '',
  1299. supplierName: '',
  1300. planner: '',
  1301. status: '',
  1302. qcOperator: '',
  1303. createBy: '',
  1304. requestDateStart: '',
  1305. requestDateEnd: '',
  1306. needInspectDateStart: '',
  1307. needInspectDateEnd: '',
  1308. planStartDate: '',
  1309. planEndDate: '',
  1310. planStartDateStr: '',
  1311. planEndDateStr: '',
  1312. page: 1,
  1313. limit: 50
  1314. },
  1315. pageIndex: 1,
  1316. pageSize: 50,
  1317. totalPage: 0,
  1318. mainDataList: [],
  1319. dataListLoading: false,
  1320. columnArray1: [
  1321. {
  1322. userId: this.$store.state.user.name,
  1323. functionId: this.functionId,
  1324. serialNumber: 'InspectionTable1RequestNo',
  1325. tableId: 'InspectionTable1',
  1326. tableName: '检验申请单',
  1327. columnProp: 'requestNo',
  1328. headerAlign: 'center',
  1329. align: 'left',
  1330. columnLabel: '申请单号',
  1331. columnWidth: '120',
  1332. columnHidden: false,
  1333. columnImage: false,
  1334. columnSortable: false,
  1335. sortLv: 0,
  1336. status: true,
  1337. fixed: false
  1338. },
  1339. {
  1340. userId: this.$store.state.user.name,
  1341. functionId: this.functionId,
  1342. serialNumber: 'InspectionTable1RequestDate',
  1343. tableId: 'InspectionTable1',
  1344. tableName: '检验申请单',
  1345. columnProp: 'requestDate',
  1346. headerAlign: 'center',
  1347. align: 'center',
  1348. columnLabel: '申请日期',
  1349. columnWidth: '120',
  1350. columnHidden: false,
  1351. columnImage: false,
  1352. columnSortable: false,
  1353. sortLv: 0,
  1354. status: true,
  1355. fixed: false
  1356. },
  1357. {
  1358. userId: this.$store.state.user.name,
  1359. functionId: this.functionId,
  1360. serialNumber: 'InspectionTable1PlanStartDate',
  1361. tableId: 'InspectionTable1',
  1362. tableName: '检验申请单',
  1363. columnProp: 'planStartDate',
  1364. headerAlign: 'center',
  1365. align: 'center',
  1366. columnLabel: '计划验货日期',
  1367. columnWidth: '120',
  1368. columnHidden: false,
  1369. columnImage: false,
  1370. columnSortable: false,
  1371. sortLv: 0,
  1372. status: true,
  1373. fixed: false
  1374. },
  1375. {
  1376. userId: this.$store.state.user.name,
  1377. functionId: this.functionId,
  1378. serialNumber: 'InspectionTable1SupplierNo',
  1379. tableId: 'InspectionTable1',
  1380. tableName: '检验申请单',
  1381. columnProp: 'supplierNo',
  1382. headerAlign: 'center',
  1383. align: 'left',
  1384. columnLabel: '供应商编码',
  1385. columnWidth: '120',
  1386. columnHidden: false,
  1387. columnImage: false,
  1388. columnSortable: false,
  1389. sortLv: 0,
  1390. status: true,
  1391. fixed: false
  1392. },
  1393. {
  1394. userId: this.$store.state.user.name,
  1395. functionId: this.functionId,
  1396. serialNumber: 'InspectionTable1SupplierName',
  1397. tableId: 'InspectionTable1',
  1398. tableName: '检验申请单',
  1399. columnProp: 'supplierName',
  1400. headerAlign: 'center',
  1401. align: 'left',
  1402. columnLabel: '供应商名称',
  1403. columnWidth: '150',
  1404. columnHidden: false,
  1405. columnImage: false,
  1406. columnSortable: false,
  1407. sortLv: 0,
  1408. status: true,
  1409. fixed: false
  1410. },
  1411. {
  1412. userId: this.$store.state.user.name,
  1413. functionId: this.functionId,
  1414. serialNumber: 'InspectionTable1Planner',
  1415. tableId: 'InspectionTable1',
  1416. tableName: '检验申请单',
  1417. columnProp: 'planner',
  1418. headerAlign: 'center',
  1419. align: 'left',
  1420. columnLabel: 'Planner',
  1421. columnWidth: '120',
  1422. columnHidden: false,
  1423. columnImage: false,
  1424. columnSortable: false,
  1425. sortLv: 0,
  1426. status: true,
  1427. fixed: false
  1428. },
  1429. {
  1430. userId: this.$store.state.user.name,
  1431. functionId: this.functionId,
  1432. serialNumber: 'InspectionTable1CreateBy',
  1433. tableId: 'InspectionTable1',
  1434. tableName: '检验申请单',
  1435. columnProp: 'createBy',
  1436. headerAlign: 'center',
  1437. align: 'left',
  1438. columnLabel: '申请人员',
  1439. columnWidth: '100',
  1440. columnHidden: false,
  1441. columnImage: false,
  1442. columnSortable: false,
  1443. sortLv: 0,
  1444. status: true,
  1445. fixed: false
  1446. },
  1447. {
  1448. userId: this.$store.state.user.name,
  1449. functionId: this.functionId,
  1450. serialNumber: 'InspectionTable1NeedInspectDate',
  1451. tableId: 'InspectionTable1',
  1452. tableName: '检验申请单',
  1453. columnProp: 'needInspectDate',
  1454. headerAlign: 'center',
  1455. align: 'center',
  1456. columnLabel: '建议验货日期',
  1457. columnWidth: '120',
  1458. columnHidden: false,
  1459. columnImage: false,
  1460. columnSortable: false,
  1461. sortLv: 0,
  1462. status: true,
  1463. fixed: false
  1464. },
  1465. {
  1466. userId: this.$store.state.user.name,
  1467. functionId: this.functionId,
  1468. serialNumber: 'InspectionTable1Status',
  1469. tableId: 'InspectionTable1',
  1470. tableName: '检验申请单',
  1471. columnProp: 'status',
  1472. headerAlign: 'center',
  1473. align: 'center',
  1474. columnLabel: '状态',
  1475. columnWidth: '100',
  1476. columnHidden: false,
  1477. columnImage: false,
  1478. columnSortable: false,
  1479. sortLv: 0,
  1480. status: true,
  1481. fixed: false
  1482. },
  1483. {
  1484. userId: this.$store.state.user.name,
  1485. functionId: this.functionId,
  1486. serialNumber: 'InspectionTable1QcOperator',
  1487. tableId: 'InspectionTable1',
  1488. tableName: '检验申请单',
  1489. columnProp: 'qcOperator',
  1490. headerAlign: 'center',
  1491. align: 'left',
  1492. columnLabel: 'QC人员',
  1493. columnWidth: '100',
  1494. columnHidden: false,
  1495. columnImage: false,
  1496. columnSortable: false,
  1497. sortLv: 0,
  1498. status: true,
  1499. fixed: false
  1500. },
  1501. {
  1502. userId: this.$store.state.user.name,
  1503. functionId: this.functionId,
  1504. serialNumber: 'InspectionTable1InspectAddress',
  1505. tableId: 'InspectionTable1',
  1506. tableName: '检验申请单',
  1507. columnProp: 'inspectAddress',
  1508. headerAlign: 'center',
  1509. align: 'left',
  1510. columnLabel: '验货地址',
  1511. columnWidth: '200',
  1512. columnHidden: false,
  1513. columnImage: false,
  1514. columnSortable: false,
  1515. sortLv: 0,
  1516. status: true,
  1517. fixed: false
  1518. },
  1519. {
  1520. userId: this.$store.state.user.name,
  1521. functionId: this.functionId,
  1522. serialNumber: 'InspectionTable1InspectCityShort',
  1523. tableId: 'InspectionTable1',
  1524. tableName: '检验申请单',
  1525. columnProp: 'inspectCityShort',
  1526. headerAlign: 'center',
  1527. align: 'left',
  1528. columnLabel: '城市简称',
  1529. columnWidth: '120',
  1530. columnHidden: false,
  1531. columnImage: false,
  1532. columnSortable: false,
  1533. sortLv: 0,
  1534. status: true,
  1535. fixed: false
  1536. },
  1537. {
  1538. userId: this.$store.state.user.name,
  1539. functionId: this.functionId,
  1540. serialNumber: 'InspectionTable1Contact',
  1541. tableId: 'InspectionTable1',
  1542. tableName: '检验申请单',
  1543. columnProp: 'inspectContract',
  1544. headerAlign: 'center',
  1545. align: 'left',
  1546. columnLabel: '联系人',
  1547. columnWidth: '150',
  1548. columnHidden: false,
  1549. columnImage: false,
  1550. columnSortable: false,
  1551. sortLv: 0,
  1552. status: true,
  1553. fixed: false
  1554. },
  1555. {
  1556. userId: this.$store.state.user.name,
  1557. functionId: this.functionId,
  1558. serialNumber: 'InspectionTable1Remark',
  1559. tableId: 'InspectionTable1',
  1560. tableName: '检验申请单',
  1561. columnProp: 'remark',
  1562. headerAlign: 'center',
  1563. align: 'left',
  1564. columnLabel: '备注',
  1565. columnWidth: '150',
  1566. columnHidden: false,
  1567. columnImage: false,
  1568. columnSortable: false,
  1569. sortLv: 0,
  1570. status: true,
  1571. fixed: false
  1572. },
  1573. ]
  1574. }
  1575. },
  1576. computed: {
  1577. isEditDialogMode () {
  1578. return this.addDialogMode === 'edit'
  1579. },
  1580. // 统一封装模式判断,避免模板与方法里反复写 this.supplierMode === true
  1581. isSupplierPageMode () {
  1582. return this.supplierMode === true
  1583. },
  1584. /**
  1585. * 统一页签内容容器高度(单位:px)。
  1586. * 业务意图:
  1587. * - 验货申请各页签切换时保持同一视觉高度,避免忽高忽低导致页面跳动;
  1588. * - 当窗口高度异常或未初始化时提供安全兜底,避免出现 0 高度导致内容不可见。
  1589. */
  1590. normalizedTabPaneHeight () {
  1591. const rawHeight = Number(this.detailHeight)
  1592. if (!rawHeight || rawHeight <= 0) {
  1593. return 300
  1594. }
  1595. return Math.floor(rawHeight)
  1596. },
  1597. /**
  1598. * 页签内容区内联样式(供所有 tab pane 复用)。
  1599. * 关键输出:
  1600. * - 固定高度:所有页签保持一致;
  1601. * - 自动滚动:当单个页签内容超出时在页签内部滚动,不撑高外层布局。
  1602. */
  1603. tabPaneContentStyle () {
  1604. return {
  1605. height: `${this.normalizedTabPaneHeight}px`
  1606. }
  1607. },
  1608. /**
  1609. * 表格类页签统一高度(单位:px)。
  1610. * 设计说明:
  1611. * - 预留少量内边距,避免表格底部与容器边框贴边;
  1612. * - 设置最小值,防止极端窗口尺寸下表格渲染异常。
  1613. */
  1614. tabTableHeight () {
  1615. return Math.max(this.normalizedTabPaneHeight - 10, 120)
  1616. }
  1617. },
  1618. mounted () {
  1619. this.$nextTick(() => {
  1620. // 统一计算主表格和详情页签的高度,确保一致
  1621. const calculatedHeight = (window.innerHeight - 250) / 2
  1622. this.height = calculatedHeight
  1623. this.detailHeight = calculatedHeight
  1624. this.initPageData()
  1625. // 页面首次渲染后绑定窗口变化监听,保障fixed列在窗口变化后自动重排 - rqrq
  1626. this.bindMainTableResizeListener()
  1627. })
  1628. },
  1629. beforeDestroy () {
  1630. // 组件销毁时及时解绑监听,避免重复绑定造成多次重排与性能浪费 - rqrq
  1631. this.removeMainTableResizeListener()
  1632. },
  1633. methods: {
  1634. // 统一处理主表布局重算:修复固定列与正文列在缩放/滚动后偶发错位 - rqrq
  1635. handleMainTableResize () {
  1636. this.$nextTick(() => {
  1637. if (this.$refs.mainTable) {
  1638. this.$refs.mainTable.doLayout()
  1639. }
  1640. })
  1641. },
  1642. // 绑定窗口尺寸监听:窗口变化后触发表格重排 - rqrq
  1643. bindMainTableResizeListener () {
  1644. window.addEventListener('resize', this.handleMainTableResize)
  1645. },
  1646. // 解绑窗口尺寸监听:防止组件重复创建后出现重复回调 - rqrq
  1647. removeMainTableResizeListener () {
  1648. window.removeEventListener('resize', this.handleMainTableResize)
  1649. },
  1650. /**
  1651. * 页面初始化入口:
  1652. * - 通用模式:直接查询;
  1653. * - 供应商模式:先加载当前用户供应商信息,再按供应商过滤查询。
  1654. */
  1655. async initPageData () {
  1656. if (!this.isSupplierPageMode) {
  1657. this.getMainData()
  1658. return
  1659. }
  1660. const loaded = await this.loadCurrentUserSupplierContext()
  1661. if (!loaded) {
  1662. this.mainDataList = []
  1663. this.changeData(null)
  1664. return
  1665. }
  1666. this.pageIndex = 1
  1667. this.getMainData()
  1668. },
  1669. /**
  1670. * 读取当前登录用户绑定的供应商信息。
  1671. * 数据来源:GET /sys/user/info
  1672. * 结果用途:
  1673. * - currentSupplierNo:查询强制过滤 + 新增固定回填
  1674. * - currentSupplierName:新增供应商名称展示
  1675. */
  1676. async loadCurrentUserSupplierContext () {
  1677. try {
  1678. const { data } = await this.$http({
  1679. url: this.$http.adornUrl('/sys/user/info'),
  1680. method: 'get',
  1681. params: this.$http.adornParams()
  1682. })
  1683. if (!data || data.code !== 0 || !data.user) {
  1684. this.$message.error((data && data.msg) || '获取当前用户信息失败')
  1685. return false
  1686. }
  1687. const supplierNo = String(data.user.supplierNo || '').trim()
  1688. if (!supplierNo) {
  1689. this.$message.warning('当前账号未维护供应商编码,请先在用户维护中配置')
  1690. return false
  1691. }
  1692. this.currentSupplierNo = supplierNo
  1693. this.currentSupplierName = String(data.user.supplierName || '').trim()
  1694. if (!this.currentSupplierName) {
  1695. const detail = await fetchSupplierDetail(supplierNo, this.$store.state.user.site)
  1696. this.currentSupplierName = detail
  1697. ? String(detail.supplierName || detail.supplier_name || '').trim()
  1698. : ''
  1699. }
  1700. this.applyCurrentSupplierToSearchFilters()
  1701. return true
  1702. } catch (error) {
  1703. console.error('获取当前用户供应商信息失败:', error)
  1704. this.$message.error('获取当前用户供应商信息失败')
  1705. return false
  1706. }
  1707. },
  1708. /**
  1709. * 将当前用户供应商写入查询条件。
  1710. * 说明:supplierName 这里清空,避免名称模糊匹配干扰 supplierNo 精准过滤。
  1711. */
  1712. applyCurrentSupplierToSearchFilters () {
  1713. if (!this.currentSupplierNo) {
  1714. return false
  1715. }
  1716. this.searchData.supplierNo = this.currentSupplierNo
  1717. this.searchData.supplierName = ''
  1718. return true
  1719. },
  1720. /**
  1721. * 将当前用户供应商写入新增表单(只读展示)。
  1722. */
  1723. applyCurrentSupplierToAddForm () {
  1724. if (!this.currentSupplierNo) {
  1725. return false
  1726. }
  1727. this.$set(this.addFormData, 'supplierNo', this.currentSupplierNo)
  1728. this.$set(this.addFormData, 'supplierName', this.currentSupplierName || '')
  1729. return true
  1730. },
  1731. // 统一状态判断,兼容中文和英文状态值 - rqrq
  1732. isRowStatus (row, statusDbList) {
  1733. if (!row || !Array.isArray(statusDbList) || statusDbList.length === 0) {
  1734. return false
  1735. }
  1736. const rowStatusDb = row.statusDb ? String(row.statusDb).trim() : ''
  1737. if (statusDbList.indexOf(rowStatusDb) !== -1) {
  1738. return true
  1739. }
  1740. const statusLabelMap = {
  1741. Draft: '草稿',
  1742. Confirmed: '待审核',
  1743. Audited: '已下达',
  1744. Scheduled: '已排程',
  1745. ChangeApplying: '申请变更中'
  1746. }
  1747. const rowStatusLabel = row.status ? String(row.status).trim() : ''
  1748. return statusDbList.some(item => statusLabelMap[item] === rowStatusLabel)
  1749. },
  1750. resolveUserCode (val, tagNo) {
  1751. if (!val) return ''
  1752. if (tagNo === 2016) {
  1753. // ChooseList 2016: username, user_display
  1754. return val.username || ''
  1755. }
  1756. if (tagNo === 528 || tagNo === 529 || tagNo === 530) {
  1757. // ChooseList 528/529/530: UserName, User_display
  1758. return val.UserName || ''
  1759. }
  1760. return ''
  1761. },
  1762. resolveUserDisplay (val, tagNo) {
  1763. if (!val) return ''
  1764. if (tagNo === 2016) {
  1765. return val.user_display || ''
  1766. }
  1767. if (tagNo === 528 || tagNo === 529 || tagNo === 530) {
  1768. return val.User_display || ''
  1769. }
  1770. return ''
  1771. },
  1772. // 获取基础数据列表
  1773. getBaseList (val, type) {
  1774. this.tagNo = val
  1775. this.searchType = type || ''
  1776. this.$nextTick(() => {
  1777. let strVal = ''
  1778. let conSql = ''
  1779. if (val === 520) {
  1780. // 判断是搜索条件还是新增弹窗
  1781. if (this.addDialogVisible) {
  1782. strVal = this.addFormData.supplierNo || ''
  1783. } else {
  1784. strVal = this.searchData.supplierNo || ''
  1785. }
  1786. conSql = " and site = '" + this.$store.state.user.site + "'"
  1787. }
  1788. if (val === 530) {
  1789. if (type === 'mainPlanner') {
  1790. strVal = this.searchData.planner || ''
  1791. } else if (type === 'addPoPlanner') {
  1792. strVal = this.addPoFilter.planner || ''
  1793. } else if (type === 'orderSupplierPlanner') {
  1794. strVal = this.orderSupplierSearch.planner || ''
  1795. }
  1796. // 530 已在 ChooseList 中限定 PLANNER,这里仅做空值防御
  1797. conSql = " and username <> '' "
  1798. }
  1799. if (val === 2016) {
  1800. if (type === 'createBy') {
  1801. strVal = this.searchData.createBy || ''
  1802. } else if (type === 'qcOperator') {
  1803. strVal = this.searchData.qcOperator || ''
  1804. }
  1805. // 防止 Druid 拦截 where 1=1
  1806. conSql = " and username <> '' "
  1807. }
  1808. if (val === 2018) {
  1809. if (type === 'addressPortOfLoading') {
  1810. strVal = this.addressCreateForm.portOfLoading || ''
  1811. }
  1812. conSql = " and port_name <> '' "
  1813. }
  1814. this.$refs.baseList.init(val, strVal, conSql)
  1815. })
  1816. },
  1817. /* 列表方法的回调 */
  1818. getBaseData (val) {
  1819. if (this.tagNo === 520) {
  1820. // 判断是搜索条件还是新增弹窗
  1821. if (this.addDialogVisible) {
  1822. // 新增弹窗:SQL返回: supplier_no, supplier_name
  1823. const supplierNoVal = val.supplier_no || ''
  1824. const supplierNameVal = val.supplier_name || ''
  1825. this.$set(this.addFormData, 'supplierNo', supplierNoVal)
  1826. this.$set(this.addFormData, 'supplierName', supplierNameVal)
  1827. this.$set(this.addFormData, 'inspectAddressId', '')
  1828. this.$set(this.addFormData, 'inspectAddress', '')
  1829. this.$set(this.addFormData, 'inspectCityShort', '')
  1830. this.$set(this.addFormData, 'contact', '')
  1831. console.log('供应商编码赋值:', supplierNoVal, '供应商名称赋值:', supplierNameVal)
  1832. this.loadPoList()
  1833. // 查询供应商地址获取验货地址和联系人
  1834. if (supplierNoVal) {
  1835. this.fetchSupplierAddress(supplierNoVal)
  1836. }
  1837. } else {
  1838. // 搜索条件:SQL返回: supplier_no, supplier_name
  1839. const supplierNoVal = val.supplier_no || ''
  1840. this.searchData.supplierNo = supplierNoVal
  1841. console.log('供应商编码赋值:', supplierNoVal)
  1842. }
  1843. }
  1844. if (this.tagNo === 2016) {
  1845. const userCode = this.resolveUserCode(val, 2016)
  1846. if (this.searchType === 'createBy') {
  1847. this.searchData.createBy = userCode
  1848. } else if (this.searchType === 'qcOperator') {
  1849. this.searchData.qcOperator = userCode
  1850. }
  1851. }
  1852. if (this.tagNo === 530) {
  1853. const plannerVal = this.resolveUserCode(val, 530)
  1854. const plannerDisplay = this.resolveUserDisplay(val, 530) || plannerVal
  1855. if (this.searchType === 'mainPlanner') {
  1856. this.searchData.planner = plannerVal
  1857. } else if (this.searchType === 'addPoPlanner') {
  1858. this.addPoFilter.planner = plannerVal
  1859. this.addPoPlannerCodeFromChooser = plannerVal
  1860. this.addPoPlannerDisplayFromChooser = plannerDisplay
  1861. this.filterAddPoList()
  1862. } else if (this.searchType === 'orderSupplierPlanner') {
  1863. this.orderSupplierSearch.planner = plannerVal
  1864. }
  1865. }
  1866. if (this.tagNo === 2018) {
  1867. if (this.searchType === 'addressPortOfLoading') {
  1868. this.addressCreateForm.portOfLoading = val.port_name || val.code || ''
  1869. }
  1870. }
  1871. },
  1872. // 查询数据
  1873. getMainData () {
  1874. if (this.isSupplierPageMode) {
  1875. if (!this.currentSupplierNo && !this.applyCurrentSupplierToSearchFilters()) {
  1876. this.mainDataList = []
  1877. this.totalPage = 0
  1878. this.changeData(null)
  1879. return
  1880. }
  1881. this.applyCurrentSupplierToSearchFilters()
  1882. }
  1883. this.searchData.limit = this.pageSize
  1884. this.searchData.page = this.pageIndex
  1885. // 后端查询字段使用 planStartDateStr/planEndDateStr - rqrq
  1886. this.searchData.planStartDateStr = this.searchData.planStartDate || ''
  1887. this.searchData.planEndDateStr = this.searchData.planEndDate || ''
  1888. this.dataListLoading = true
  1889. searchInspectionRequestHeaderList(this.searchData).then(({ data }) => {
  1890. if (data.code === 0) {
  1891. this.mainDataList = data.page.list
  1892. // 调试信息:打印第一条数据的 hasModifiedQty 字段
  1893. if (this.mainDataList.length > 0) {
  1894. console.log('=== 主表格数据调试 ===')
  1895. console.log('第一条数据:', this.mainDataList[0])
  1896. console.log('hasModifiedQty 值:', this.mainDataList[0].hasModifiedQty)
  1897. console.log('=====================')
  1898. }
  1899. this.pageIndex = data.page.currPage
  1900. this.pageSize = data.page.pageSize
  1901. this.totalPage = data.page.totalCount
  1902. this.$nextTick(() => {
  1903. if (this.$refs.mainTable) {
  1904. // 固定列与主表在数据刷新后偶发错位,先触发布局重算再处理选择态 - rqrq
  1905. this.$refs.mainTable.doLayout()
  1906. this.$refs.mainTable.clearSelection()
  1907. }
  1908. })
  1909. // 判断是否有数据
  1910. if (this.mainDataList.length > 0) {
  1911. this.$refs.mainTable.setCurrentRow(this.mainDataList[0])
  1912. this.changeData(this.mainDataList[0])
  1913. } else {
  1914. this.changeData(null)
  1915. }
  1916. }
  1917. this.dataListLoading = false
  1918. }).catch(() => {
  1919. this.dataListLoading = false
  1920. })
  1921. },
  1922. // 每页数
  1923. sizeChangeHandle (val) {
  1924. this.pageSize = val
  1925. this.pageIndex = 1
  1926. this.getMainData()
  1927. },
  1928. // 当前页
  1929. currentChangeHandle (val) {
  1930. this.pageIndex = val
  1931. this.getMainData()
  1932. },
  1933. // 页签点击事件
  1934. handleTabClick (tab) {
  1935. // 每次点击页签都触发对应页签的查询
  1936. if (tab.name === 'detail') {
  1937. // 验货明细页签 - 组件内部 watch 会自动触发
  1938. this.$nextTick(() => {
  1939. if (this.$refs.inspectionDetailTab) {
  1940. this.$refs.inspectionDetailTab.loadDetailList()
  1941. }
  1942. })
  1943. } else if (tab.name === 'poDetail') {
  1944. // 验货关联PO明细页签
  1945. this.$nextTick(() => {
  1946. if (this.$refs.poDetailTab) {
  1947. this.$refs.poDetailTab.loadDetailList()
  1948. }
  1949. })
  1950. } else if (tab.name === 'result') {
  1951. // 验货结果页签
  1952. this.$nextTick(() => {
  1953. if (this.$refs.resultTab) {
  1954. this.$refs.resultTab.loadDetailList()
  1955. }
  1956. })
  1957. } else if (tab.name === 'attachment') {
  1958. // 附件管理页签 - 组件内部 watch 会自动触发
  1959. this.$nextTick(() => {
  1960. if (this.$refs.attachmentTab) {
  1961. this.$refs.attachmentTab.loadAttachmentTypeList()
  1962. }
  1963. })
  1964. } else if (tab.name === 'fee') {
  1965. // 费用明细页签 - 组件内部 watch 会自动触发
  1966. this.$nextTick(() => {
  1967. if (this.$refs.feeTab) {
  1968. this.$refs.feeTab.loadFeeDetailList()
  1969. }
  1970. })
  1971. }
  1972. },
  1973. // 行点击事件
  1974. changeData (row) {
  1975. this.currentRow = row ? JSON.parse(JSON.stringify(row)) : {}
  1976. },
  1977. // 新增验货申请
  1978. addInspectionRequest () {
  1979. this.addDialogMode = 'create'
  1980. this.resetAddForm()
  1981. if (this.isSupplierPageMode) {
  1982. if (!this.applyCurrentSupplierToAddForm()) {
  1983. this.$message.warning('当前账号未维护供应商编码,请先在用户维护中配置')
  1984. return
  1985. }
  1986. this.loadPoList()
  1987. this.fetchSupplierAddress(this.addFormData.supplierNo)
  1988. }
  1989. this.addDialogVisible = true
  1990. },
  1991. // 关闭新增弹窗
  1992. handleCloseAddDialog () {
  1993. this.addDialogVisible = false
  1994. this.resetAddForm()
  1995. this.addDialogMode = 'create'
  1996. },
  1997. // 重置表单
  1998. resetAddForm () {
  1999. const today = new Date()
  2000. const year = today.getFullYear()
  2001. const month = String(today.getMonth() + 1).padStart(2, '0')
  2002. const day = String(today.getDate()).padStart(2, '0')
  2003. const todayStr = `${year}-${month}-${day}`
  2004. this.addFormData = {
  2005. requestNo: '',
  2006. requestDate: todayStr,
  2007. supplierNo: '',
  2008. supplierName: '',
  2009. inspectAddressId: '',
  2010. inspectAddress: '',
  2011. inspectCityShort: '',
  2012. contact: '',
  2013. needInspectDate: ''
  2014. }
  2015. this.poList = []
  2016. this.filteredPoList = []
  2017. this.editPoDetailList = []
  2018. this.originalEditPoDetailList = [] // 保存原始PO列表,用于区分新增和修改
  2019. this.deletedPoKeys = new Set() // 记录用户手动删除的PO key
  2020. this.editPoDetailLoading = false
  2021. this.editPoEditMode = false
  2022. this.addPoDialogVisible = false
  2023. this.addPoSelectList = []
  2024. this.addPoSelectLoading = false
  2025. this.addPoSelectPageIndex = 1
  2026. this.addPoSelectPageSize = 20
  2027. this.addPoSelectTotal = 0
  2028. this.addPoSelectedRows = []
  2029. this.addPoSearch = {
  2030. orderRef1: '',
  2031. partNo: '',
  2032. sku: '',
  2033. partDesc: ''
  2034. }
  2035. this.selectedPoList = []
  2036. this.addPoFilter = {
  2037. orderNo: '',
  2038. partNo: '',
  2039. item: '',
  2040. sku: '',
  2041. partDesc: '',
  2042. supplierName: '',
  2043. planner: ''
  2044. }
  2045. this.addPoPlannerCodeFromChooser = ''
  2046. this.addPoPlannerDisplayFromChooser = ''
  2047. this.poSupplierDialogVisible = false
  2048. this.poSupplierLoading = false
  2049. this.poSupplierList = []
  2050. this.poSupplierCurrentRow = null
  2051. this.poSupplierPageIndex = 1
  2052. this.poSupplierPageSize = 20
  2053. this.poSupplierTotal = 0
  2054. this.poSupplierSearch = {
  2055. supplierNo: '',
  2056. supplierName: ''
  2057. }
  2058. this.addressDialogVisible = false
  2059. this.addressLoading = false
  2060. this.addressList = []
  2061. this.addressCurrentRow = null
  2062. this.addressPageIndex = 1
  2063. this.addressPageSize = 20
  2064. this.addressTotal = 0
  2065. this.addressSearch = {
  2066. keyword: ''
  2067. }
  2068. this.addressCreateDialogVisible = false
  2069. this.addressCreateSaving = false
  2070. this.addressCreateForm = this.buildAddressCreateFormBySupplier('')
  2071. this.addressEditDialogVisible = false
  2072. this.addressEditSaving = false
  2073. this.addressEditForm = {
  2074. supplierId: '',
  2075. site: this.$store.state.user.site || this.$store.state.user.currentSite || '',
  2076. addressId: '',
  2077. companyName: '',
  2078. cityShort: '',
  2079. contact: '',
  2080. phoneNo: '',
  2081. address: '',
  2082. addressType: '验货地址',
  2083. active: 'Y',
  2084. email: '',
  2085. originCountry: '',
  2086. portOfLoading: '',
  2087. memo: '',
  2088. createBy: this.$store.state.user.name,
  2089. updateBy: this.$store.state.user.name
  2090. }
  2091. this.orderSupplierDialogVisible = false
  2092. this.orderSupplierLoading = false
  2093. this.orderSupplierList = []
  2094. this.orderSupplierCurrentRow = null
  2095. this.orderSupplierPageIndex = 1
  2096. this.orderSupplierPageSize = 50
  2097. this.orderSupplierTotal = 0
  2098. this.orderSupplierSearch = {
  2099. orderNo: '',
  2100. partNo: '',
  2101. item: '',
  2102. sku: '',
  2103. partDesc: '',
  2104. supplierName: '',
  2105. planner: ''
  2106. }
  2107. if (this.isSupplierPageMode) {
  2108. this.applyCurrentSupplierToAddForm()
  2109. }
  2110. this.pendingAutoSelectPoRow = null
  2111. if (this.$refs.addFormData) {
  2112. this.$refs.addFormData.clearValidate()
  2113. }
  2114. },
  2115. // 仅格式化到 yyyy-MM-dd,兼容 Date / 字符串 - rqrq
  2116. formatToDateOnly (value) {
  2117. if (!value) {
  2118. return ''
  2119. }
  2120. if (value instanceof Date) {
  2121. const year = value.getFullYear()
  2122. const month = String(value.getMonth() + 1).padStart(2, '0')
  2123. const day = String(value.getDate()).padStart(2, '0')
  2124. return `${year}-${month}-${day}`
  2125. }
  2126. const text = String(value).trim()
  2127. return text ? text.split(' ')[0] : ''
  2128. },
  2129. // 打开草稿编辑弹窗:仅允许修改建议验货日期/验货地址/联系人 - rqrq
  2130. async openEditInspectionDialog (row) {
  2131. this.resetAddForm()
  2132. this.addDialogMode = 'edit'
  2133. this.editPoEditMode = true // 直接进入编辑模式
  2134. this.addDialogVisible = true
  2135. this.addFormData = {
  2136. requestNo: row.requestNo || '',
  2137. requestDate: this.formatToDateOnly(row.requestDate),
  2138. supplierNo: row.supplierNo || '',
  2139. supplierName: row.supplierName || '',
  2140. inspectAddressId: row.inspectAddressId || '',
  2141. inspectAddress: row.inspectAddress || '',
  2142. inspectCityShort: row.inspectCityShort || '',
  2143. contact: row.inspectContract || '',
  2144. needInspectDate: this.formatToDateOnly(row.needInspectDate)
  2145. }
  2146. await this.loadEditPoDetailList(row.requestNo, row.site || this.$store.state.user.site)
  2147. },
  2148. // 加载编辑弹窗PO明细(只读展示)
  2149. async loadEditPoDetailList (requestNo, site) {
  2150. if (!requestNo) {
  2151. this.editPoDetailList = []
  2152. return
  2153. }
  2154. this.editPoDetailLoading = true
  2155. try {
  2156. // 获取验货申请明细列表
  2157. const { data } = await getInspectionRequestDetailSubList({
  2158. requestNo,
  2159. site: site || this.$store.state.user.site,
  2160. page: 1,
  2161. limit: 1000
  2162. })
  2163. if (data && data.code === 0) {
  2164. const rawList = (data.page && data.page.list) || []
  2165. const exactList = rawList.filter(item => {
  2166. const itemRequestNo = item.requestNo || item.request_no || ''
  2167. return !itemRequestNo || String(itemRequestNo) === String(requestNo)
  2168. })
  2169. // 直接使用后端返回的数据,不再调用 queryPoPage
  2170. this.editPoDetailList = exactList.map(item => ({
  2171. ...item,
  2172. totalQty: item.totalQty || 0, // 使用后端返回的 totalQty 作为未验货数量
  2173. crd: this.formatToDateOnly(item.crd),
  2174. qty: item.qty || 0 // 确保 qty 字段存在且为数字类型
  2175. }))
  2176. // 保存原始PO列表的副本,用于区分新增和修改
  2177. this.originalEditPoDetailList = this.editPoDetailList.map(item => ({...item}))
  2178. } else {
  2179. this.editPoDetailList = []
  2180. this.originalEditPoDetailList = []
  2181. this.$message.warning(data.msg || '加载PO明细失败')
  2182. }
  2183. } catch (error) {
  2184. this.editPoDetailList = []
  2185. this.originalEditPoDetailList = []
  2186. console.error('加载编辑PO明细失败:', error)
  2187. this.$message.error('加载PO明细失败,请稍后重试')
  2188. } finally {
  2189. this.editPoDetailLoading = false
  2190. }
  2191. },
  2192. // 启用编辑PO明细的编辑模式(已废弃,直接进入编辑模式)
  2193. enableEditPoEdit () {
  2194. this.editPoEditMode = true
  2195. },
  2196. // 删除编辑PO明细中的某一行(仅缓存,保存时一并提交)
  2197. deleteEditPoRow (index) {
  2198. this.$confirm('确定要删除这条PO明细吗?', '提示', {
  2199. confirmButtonText: '确定',
  2200. cancelButtonText: '取消',
  2201. type: 'warning'
  2202. }).then(() => {
  2203. const deletedRow = this.editPoDetailList[index]
  2204. // 记录被删除的PO的key和itemNo,用于保存时判断
  2205. const key = `${deletedRow.orderRef1 || ''}_${deletedRow.orderRef2 || ''}`
  2206. // 使用 poItemNo 或 itemNo 作为删除标识(对应后端 item_no)
  2207. const itemNo = deletedRow.poItemNo || deletedRow.po_item_no || deletedRow.itemNo || deletedRow.item_no || deletedRow.orderRef2 || ''
  2208. // 如果删除的是原有PO(在originalEditPoDetailList中存在),则记录到deletedPoKeys
  2209. const isOriginalPo = this.originalEditPoDetailList.some(item => {
  2210. const originalKey = `${item.orderRef1 || ''}_${item.orderRef2 || ''}`
  2211. return originalKey === key
  2212. })
  2213. if (isOriginalPo && itemNo) {
  2214. // 存储对象而非字符串,保留完整的itemNo信息
  2215. this.deletedPoKeys.add(JSON.stringify({ key, itemNo }))
  2216. }
  2217. // 从列表中移除该行(仅前端移除,不立即调用后端接口)
  2218. this.editPoDetailList.splice(index, 1)
  2219. this.$message.success('已标记删除,点击保存后生效')
  2220. }).catch(() => {
  2221. // 取消删除
  2222. })
  2223. },
  2224. // 打开新增PO弹窗
  2225. openAddPoDialog () {
  2226. if (!this.addFormData.supplierNo) {
  2227. this.$message.warning('请先选择供应商')
  2228. return
  2229. }
  2230. this.addPoDialogVisible = true
  2231. this.addPoSelectPageIndex = 1
  2232. this.addPoSelectedRows = []
  2233. this.resetAddPoSearch()
  2234. this.loadAddPoSelectList()
  2235. },
  2236. // 加载新增PO选择列表
  2237. loadAddPoSelectList () {
  2238. const params = {
  2239. site: this.$store.state.user.site,
  2240. supplierNo: this.addFormData.supplierNo,
  2241. orderRef1: this.addPoSearch.orderRef1 || '',
  2242. partNo: this.addPoSearch.partNo || '',
  2243. sku: this.addPoSearch.sku || '',
  2244. partDesc: this.addPoSearch.partDesc || '',
  2245. page: this.addPoSelectPageIndex,
  2246. limit: this.addPoSelectPageSize
  2247. }
  2248. // 如果是编辑模式且已有PO明细,构建排除列表
  2249. if (this.isEditDialogMode && this.editPoDetailList && this.editPoDetailList.length > 0) {
  2250. const excludePoItems = []
  2251. this.editPoDetailList.forEach(item => {
  2252. // 优先使用 poNo 和 poItemNo(对应后端 order_no 和 item_no)
  2253. const orderNo = item.poNo || item.orderNo || item.order_no || item.orderRef1 || ''
  2254. const itemNo = item.poItemNo || item.po_item_no || item.itemNo || item.item_no || item.orderRef2 || ''
  2255. if (orderNo && itemNo) {
  2256. excludePoItems.push(`${orderNo}:${itemNo}`)
  2257. }
  2258. })
  2259. if (excludePoItems.length > 0) {
  2260. params.excludePoItems = excludePoItems
  2261. }
  2262. }
  2263. this.addPoSelectLoading = true
  2264. // 根据是否有排除列表选择不同的API
  2265. const apiCall = params.excludePoItems ? queryPoPageExclude(params) : queryPoPage(params)
  2266. apiCall.then(({ data }) => {
  2267. if (data && data.code === 0) {
  2268. const pageData = data.page || {}
  2269. let list = pageData.list || []
  2270. // 为每条数据设置默认值
  2271. list = list.map(row => ({
  2272. ...row,
  2273. inspectQty: row.waitInspectQty || row.qty || 0, // 此次验货数量默认为未验货数量
  2274. shipMethod: row.shipMethod || row.shipMothod || '', // 运输方式默认为PO中的运输方式(兼容拼写错误)
  2275. crd: row.crd || '' // CRD日期默认为PO中的CRD日期
  2276. }))
  2277. this.addPoSelectList = list
  2278. this.addPoSelectTotal = pageData.totalCount || 0
  2279. this.addPoSelectPageIndex = pageData.currPage || this.addPoSelectPageIndex
  2280. this.addPoSelectPageSize = pageData.pageSize || this.addPoSelectPageSize
  2281. } else {
  2282. this.addPoSelectList = []
  2283. this.addPoSelectTotal = 0
  2284. this.$message.warning(data.msg || '加载PO列表失败')
  2285. }
  2286. }).catch(error => {
  2287. console.error('加载PO列表失败:', error)
  2288. this.addPoSelectList = []
  2289. this.addPoSelectTotal = 0
  2290. this.$message.error('加载PO列表失败')
  2291. }).finally(() => {
  2292. this.addPoSelectLoading = false
  2293. })
  2294. },
  2295. // 搜索新增PO列表
  2296. searchAddPoList () {
  2297. this.addPoSelectPageIndex = 1
  2298. this.loadAddPoSelectList()
  2299. },
  2300. // 重置新增PO搜索条件
  2301. resetAddPoSearch () {
  2302. this.addPoSearch = {
  2303. orderRef1: '',
  2304. partNo: '',
  2305. sku: '',
  2306. partDesc: ''
  2307. }
  2308. this.addPoSelectPageIndex = 1
  2309. this.loadAddPoSelectList()
  2310. },
  2311. // 新增PO分页大小变化
  2312. onAddPoPageSizeChange (val) {
  2313. this.addPoSelectPageSize = val
  2314. this.addPoSelectPageIndex = 1
  2315. this.loadAddPoSelectList()
  2316. },
  2317. // 新增PO页码变化
  2318. onAddPoPageCurrentChange (val) {
  2319. this.addPoSelectPageIndex = val
  2320. this.loadAddPoSelectList()
  2321. },
  2322. // 新增PO选择变化
  2323. handleAddPoSelectionChange (rows) {
  2324. this.addPoSelectedRows = rows
  2325. },
  2326. // 确认添加选中的PO(仅添加到表格,不立即保存)
  2327. confirmAddPoSelect () {
  2328. if (!this.addPoSelectedRows || this.addPoSelectedRows.length === 0) {
  2329. this.$message.warning('请至少选择一条PO明细')
  2330. return
  2331. }
  2332. if (!this.addFormData.requestNo) {
  2333. this.$message.warning('申请单号为空,无法添加PO明细')
  2334. return
  2335. }
  2336. // 允许重复添加,直接将选中的PO明细添加到编辑列表中
  2337. const newItems = this.addPoSelectedRows.map(row => ({
  2338. ...row,
  2339. orderNo: row.poNo || row.orderNo || row.order_ref1 || row.orderRef1 || '',
  2340. orderRef1: row.orderRef1 || row.order_ref1 || '',
  2341. orderRef2: row.orderRef2 || row.order_ref2 || '',
  2342. poItemNo: row.poItemNo || row.po_item_no || row.itemNo || row.item_no || row.orderRef2 || row.order_ref2 || '',
  2343. partNo: row.partNo || '',
  2344. qty: row.inspectQty || row.waitInspectQty || row.qty || 0,
  2345. shipMethod: row.shipMethod || row.shipMothod || '',
  2346. shipMothod: row.shipMethod || row.shipMothod || '', // 保持字段一致性
  2347. crd: row.crd || '',
  2348. waitInspectQty: row.waitInspectQty || 0,
  2349. totalQty: row.waitInspectQty || 0 // 新增明细的未验货数量取PO的可用待验数量
  2350. }))
  2351. // 将新PO明细添加到编辑列表中
  2352. this.editPoDetailList = [...this.editPoDetailList, ...newItems]
  2353. this.$message.success(`成功添加${newItems.length}条PO明细`)
  2354. // 关闭弹窗并清空选中状态
  2355. this.addPoDialogVisible = false
  2356. this.addPoSelectedRows = []
  2357. },
  2358. // 选择供应商
  2359. selectSupplier () {
  2360. this.tagNo = 520 // 设置tagNo,确保回调时能正确识别
  2361. this.$nextTick(() => {
  2362. const conSql = " and site = '" + this.$store.state.user.site + "'"
  2363. this.$refs.baseList.init(520, this.addFormData.supplierNo || '', conSql)
  2364. })
  2365. },
  2366. /**
  2367. * 新增供应商地址弹窗字段校验(与供应商地址页签新增逻辑保持一致)。
  2368. * 规则:必填字段不能为空字符串(仅空格也视为无效)。
  2369. */
  2370. validateAddressCreateField (rule, value, callback) {
  2371. const normalizedValue = value === null || value === undefined ? '' : String(value).trim()
  2372. if (!normalizedValue) {
  2373. callback(new Error())
  2374. return
  2375. }
  2376. callback()
  2377. },
  2378. /**
  2379. * 构建“新增供应商地址”弹窗的默认表单对象。
  2380. * supplierId 固定使用当前验货申请选中的供应商编码,避免录错供应商。
  2381. */
  2382. buildAddressCreateFormBySupplier (supplierId) {
  2383. const currentSite = String(this.$store.state.user.site || this.$store.state.user.currentSite || '').trim()
  2384. return {
  2385. supplierId: supplierId || '',
  2386. site: currentSite,
  2387. addressId: '',
  2388. companyName: '',
  2389. cityShort: '',
  2390. contact: '',
  2391. phoneNo: '',
  2392. address: '',
  2393. addressType: '验货地址',
  2394. active: 'Y',
  2395. email: '',
  2396. originCountry: '',
  2397. portOfLoading: '',
  2398. memo: '',
  2399. createBy: this.$store.state.user.name,
  2400. updateBy: this.$store.state.user.name
  2401. }
  2402. },
  2403. /**
  2404. * 在“选择验货地址”弹窗内快速新增供应商地址。
  2405. * 界面字段与 /srmSupplier-supplierList 地址页签新增弹窗保持一致。
  2406. */
  2407. openAddressCreateDialog () {
  2408. const supplierNo = (this.addFormData.supplierNo || '').trim()
  2409. if (!supplierNo) {
  2410. this.$message.warning('请先选择供应商')
  2411. return
  2412. }
  2413. this.addressCreateForm = this.buildAddressCreateFormBySupplier(supplierNo)
  2414. this.addressCreateDialogVisible = true
  2415. this.$nextTick(() => {
  2416. if (this.$refs.addressCreateFormRef) {
  2417. this.$refs.addressCreateFormRef.clearValidate()
  2418. }
  2419. })
  2420. this.fetchSupplierInfoForAddressCreate(supplierNo)
  2421. },
  2422. /**
  2423. * 根据供应商编码回填默认信息(公司名称/联系人/电话/邮箱/地址)。
  2424. * 仅在新增地址弹窗中用于提高录入效率,不覆盖用户已输入内容。
  2425. */
  2426. fetchSupplierInfoForAddressCreate (supplierNo) {
  2427. const normalizedSupplierNo = String(supplierNo || '').trim()
  2428. const currentSite = String(this.$store.state.user.site || this.$store.state.user.currentSite || '').trim()
  2429. if (!normalizedSupplierNo || !currentSite) {
  2430. return
  2431. }
  2432. searchSrmSupplierList({
  2433. site: currentSite,
  2434. supplierNo: normalizedSupplierNo,
  2435. page: 1,
  2436. limit: 1
  2437. }).then(({ data }) => {
  2438. if (!(data && data.code === 0)) {
  2439. return
  2440. }
  2441. const pageData = data.data || data.page
  2442. const supplierList = pageData && pageData.list ? pageData.list : (Array.isArray(pageData) ? pageData : [])
  2443. if (!supplierList || supplierList.length === 0) {
  2444. return
  2445. }
  2446. const supplierData = supplierList[0] || {}
  2447. this.addressCreateForm.companyName = supplierData.supplierName || supplierData.companyName || this.addressCreateForm.companyName || ''
  2448. if (!this.addressCreateForm.contact) {
  2449. this.addressCreateForm.contact = supplierData.contact || ''
  2450. }
  2451. if (!this.addressCreateForm.phoneNo) {
  2452. this.addressCreateForm.phoneNo = supplierData.phoneNo || supplierData.phoneNo1 || ''
  2453. }
  2454. if (!this.addressCreateForm.email) {
  2455. this.addressCreateForm.email = supplierData.email || supplierData.email1 || ''
  2456. }
  2457. if (!this.addressCreateForm.address) {
  2458. this.addressCreateForm.address = supplierData.address || ''
  2459. }
  2460. }).catch((error) => {
  2461. console.error('查询供应商信息失败:', error)
  2462. })
  2463. },
  2464. /**
  2465. * 保存新增供应商地址并刷新地址列表。
  2466. * 保存成功后不关闭“选择验货地址”弹窗,便于用户立即选择新地址。
  2467. */
  2468. saveCreatedAddress () {
  2469. if (!this.$refs.addressCreateFormRef) {
  2470. return
  2471. }
  2472. this.$refs.addressCreateFormRef.validate((valid) => {
  2473. if (!valid) {
  2474. return
  2475. }
  2476. this.addressCreateSaving = true
  2477. this.addressCreateForm.createBy = this.$store.state.user.name
  2478. this.addressCreateForm.updateBy = this.$store.state.user.name
  2479. createSrmSupplierAddress(this.addressCreateForm).then(({ data }) => {
  2480. if (data && data.code === 0) {
  2481. this.$message.success('新增供应商地址成功')
  2482. this.addressCreateDialogVisible = false
  2483. this.loadAddressList()
  2484. } else {
  2485. this.$alert(data.msg || '新增供应商地址失败', '错误', { confirmButtonText: '确定' })
  2486. }
  2487. }).catch((error) => {
  2488. console.error('保存供应商地址失败:', error)
  2489. this.$message.error('保存失败: ' + (error.message || '网络错误'))
  2490. }).finally(() => {
  2491. this.addressCreateSaving = false
  2492. })
  2493. })
  2494. },
  2495. /**
  2496. * 新增地址弹窗关闭后的收尾动作:
  2497. * - 清理校验状态
  2498. * - 重置为当前供应商默认表单,避免残留上次输入
  2499. */
  2500. handleAddressCreateDialogClosed () {
  2501. if (this.$refs.addressCreateFormRef) {
  2502. this.$refs.addressCreateFormRef.clearValidate()
  2503. }
  2504. this.addressCreateForm = this.buildAddressCreateFormBySupplier(this.addFormData.supplierNo || '')
  2505. this.addressCreateSaving = false
  2506. },
  2507. // 打开验货地址选择弹窗
  2508. openAddressDialog () {
  2509. if (!this.addFormData.supplierNo) {
  2510. this.$message.warning('请先选择供应商')
  2511. return
  2512. }
  2513. this.addressDialogVisible = true
  2514. this.addressPageIndex = 1
  2515. this.addressSearch.keyword = ''
  2516. this.addressCurrentRow = null
  2517. this.addressCreateForm = this.buildAddressCreateFormBySupplier(this.addFormData.supplierNo || '')
  2518. // 检查用户是否有编辑权限
  2519. this.checkAddressEditPermission()
  2520. this.loadAddressList()
  2521. },
  2522. // 检查用户是否有编辑验货地址的权限
  2523. checkAddressEditPermission () {
  2524. const username = this.$store.state.user.name || ''
  2525. if (!username) {
  2526. this.hasAddressEditPermission = false
  2527. return
  2528. }
  2529. getPermissionValue(username, 'SRM0002').then(({ data }) => {
  2530. if (data && data.code === 0) {
  2531. // value 为 'Y' 表示有权限
  2532. this.hasAddressEditPermission = String(data.value).trim() === 'Y'
  2533. } else {
  2534. this.hasAddressEditPermission = false
  2535. }
  2536. }).catch(error => {
  2537. console.error('查询权限失败:', error)
  2538. this.hasAddressEditPermission = false
  2539. })
  2540. },
  2541. // 编辑地址
  2542. editAddress (row) {
  2543. if (!row || !row.addressId) {
  2544. this.$message.warning('请选择要编辑的地址')
  2545. return
  2546. }
  2547. // 填充编辑表单
  2548. this.addressEditForm = {
  2549. supplierId: row.supplierId || row.supplier_id || '',
  2550. site: row.site || this.$store.state.user.site || '',
  2551. addressId: row.addressId || row.address_id || '',
  2552. companyName: row.companyName || row.company_name || '',
  2553. cityShort: row.cityShort || row.city_short || '',
  2554. contact: row.contact || '',
  2555. phoneNo: row.phoneNo || row.phone_no || '',
  2556. address: row.address || '',
  2557. addressType: row.addressType || row.address_type || '验货地址',
  2558. active: row.active || 'Y',
  2559. email: row.email || '',
  2560. originCountry: row.originCountry || row.origin_country || '',
  2561. portOfLoading: row.portOfLoading || row.port_of_loading || '',
  2562. memo: row.memo || '',
  2563. createBy: row.createBy || row.create_by || '',
  2564. updateBy: this.$store.state.user.name
  2565. }
  2566. this.addressEditDialogVisible = true
  2567. this.$nextTick(() => {
  2568. if (this.$refs.addressEditFormRef) {
  2569. this.$refs.addressEditFormRef.clearValidate()
  2570. }
  2571. })
  2572. },
  2573. // 保存编辑后的地址
  2574. saveEditedAddress () {
  2575. if (!this.$refs.addressEditFormRef) {
  2576. return
  2577. }
  2578. this.$refs.addressEditFormRef.validate((valid) => {
  2579. if (!valid) {
  2580. return
  2581. }
  2582. this.addressEditSaving = true
  2583. this.addressEditForm.updateBy = this.$store.state.user.name
  2584. updateSrmSupplierAddress(this.addressEditForm).then(({ data }) => {
  2585. if (data && data.code === 0) {
  2586. this.$message.success('更新供应商地址成功')
  2587. this.addressEditDialogVisible = false
  2588. // 刷新地址列表
  2589. this.loadAddressList()
  2590. } else {
  2591. this.$alert(data.msg || '更新供应商地址失败', '错误', { confirmButtonText: '确定' })
  2592. }
  2593. }).catch((error) => {
  2594. console.error('更新供应商地址失败:', error)
  2595. this.$message.error('更新失败: ' + (error.message || '网络错误'))
  2596. }).finally(() => {
  2597. this.addressEditSaving = false
  2598. })
  2599. })
  2600. },
  2601. // 编辑地址弹窗关闭后的收尾动作
  2602. handleAddressEditDialogClosed () {
  2603. if (this.$refs.addressEditFormRef) {
  2604. this.$refs.addressEditFormRef.clearValidate()
  2605. }
  2606. this.addressEditForm = {
  2607. supplierId: '',
  2608. site: this.$store.state.user.site || this.$store.state.user.currentSite || '',
  2609. addressId: '',
  2610. companyName: '',
  2611. cityShort: '',
  2612. contact: '',
  2613. phoneNo: '',
  2614. address: '',
  2615. addressType: '验货地址',
  2616. active: 'Y',
  2617. email: '',
  2618. originCountry: '',
  2619. portOfLoading: '',
  2620. memo: '',
  2621. createBy: this.$store.state.user.name,
  2622. updateBy: this.$store.state.user.name
  2623. }
  2624. this.addressEditSaving = false
  2625. },
  2626. // 标准化地址列表字段,兼容下划线和驼峰返回
  2627. normalizeAddressRows (list) {
  2628. return (list || []).map(item => ({
  2629. ...item,
  2630. supplierId: item.supplierId || item.supplier_id || '',
  2631. addressId: item.addressId || item.address_id || '',
  2632. cityShort: item.cityShort || item.city_short || '',
  2633. companyName: item.companyName || item.company_name || '',
  2634. contact: item.contact || '',
  2635. phoneNo: item.phoneNo || item.phone_no || '',
  2636. email: item.email || '',
  2637. address: item.address || '',
  2638. addressType: item.addressType || item.address_type || ''
  2639. }))
  2640. },
  2641. // 根据供应商加载验货地址列表
  2642. loadAddressList () {
  2643. if (!this.addFormData.supplierNo) {
  2644. this.addressList = []
  2645. this.addressTotal = 0
  2646. return
  2647. }
  2648. const params = {
  2649. site: this.$store.state.user.site,
  2650. supplierId: this.addFormData.supplierNo,
  2651. addressType: '验货地址',
  2652. page: this.addressPageIndex,
  2653. limit: this.addressPageSize
  2654. }
  2655. if (this.addressSearch.keyword) {
  2656. params.address = this.addressSearch.keyword
  2657. }
  2658. this.addressLoading = true
  2659. searchSrmSupplierAddressList(params).then(({ data }) => {
  2660. if (data && data.code === 0) {
  2661. const pageData = data.page || data.data || {}
  2662. const rawList = Array.isArray(pageData.list) ? pageData.list : (Array.isArray(pageData) ? pageData : [])
  2663. this.addressList = this.normalizeAddressRows(rawList)
  2664. this.addressTotal = pageData.totalCount || this.addressList.length
  2665. this.addressPageIndex = pageData.currPage || this.addressPageIndex
  2666. this.addressPageSize = pageData.pageSize || this.addressPageSize
  2667. this.$nextTick(() => {
  2668. if (this.addressList.length > 0) {
  2669. this.addressCurrentRow = this.addressList[0]
  2670. if (this.$refs.addressTable) {
  2671. this.$refs.addressTable.setCurrentRow(this.addressCurrentRow)
  2672. }
  2673. } else {
  2674. this.addressCurrentRow = null
  2675. if (this.$refs.addressTable) {
  2676. this.$refs.addressTable.setCurrentRow()
  2677. }
  2678. }
  2679. })
  2680. } else {
  2681. this.addressList = []
  2682. this.addressCurrentRow = null
  2683. this.addressTotal = 0
  2684. }
  2685. }).catch(error => {
  2686. this.addressList = []
  2687. this.addressCurrentRow = null
  2688. this.addressTotal = 0
  2689. console.error('查询供应商地址失败:', error)
  2690. this.$message.error('查询验货地址失败')
  2691. }).finally(() => {
  2692. this.addressLoading = false
  2693. })
  2694. },
  2695. searchAddressList () {
  2696. this.addressPageIndex = 1
  2697. this.loadAddressList()
  2698. },
  2699. resetAddressSearch () {
  2700. this.addressSearch.keyword = ''
  2701. this.addressPageIndex = 1
  2702. this.loadAddressList()
  2703. },
  2704. onAddressPageSizeChange (val) {
  2705. this.addressPageSize = val
  2706. this.addressPageIndex = 1
  2707. this.loadAddressList()
  2708. },
  2709. onAddressPageCurrentChange (val) {
  2710. this.addressPageIndex = val
  2711. this.loadAddressList()
  2712. },
  2713. onAddressCurrentChange (row) {
  2714. this.addressCurrentRow = row || null
  2715. },
  2716. onAddressRowDblClick (row) {
  2717. this.selectAddressRow(row)
  2718. },
  2719. confirmAddressSelect () {
  2720. this.selectAddressRow(this.addressCurrentRow)
  2721. },
  2722. selectAddressRow (row, overwriteContact = true) {
  2723. if (!row || !row.addressId) {
  2724. this.$message.warning('请选择验货地址')
  2725. return
  2726. }
  2727. this.$set(this.addFormData, 'inspectAddressId', row.addressId || '')
  2728. this.$set(this.addFormData, 'inspectAddress', row.address || '')
  2729. this.$set(this.addFormData, 'inspectCityShort', row.cityShort || '')
  2730. if (overwriteContact || !this.addFormData.contact) {
  2731. this.$set(this.addFormData, 'contact', row.contact || '')
  2732. }
  2733. this.addressDialogVisible = false
  2734. },
  2735. // 根据供应商ID预带默认验货地址(若存在)
  2736. fetchSupplierAddress (supplierId) {
  2737. if (!supplierId) {
  2738. return
  2739. }
  2740. const params = {
  2741. site: this.$store.state.user.site,
  2742. supplierId: supplierId,
  2743. addressType: '验货地址',
  2744. page: 1,
  2745. limit: 1
  2746. }
  2747. searchSrmSupplierAddressList(params).then(({ data }) => {
  2748. if (data && data.code === 0) {
  2749. const pageData = data.page || data.data || {}
  2750. const rawList = Array.isArray(pageData.list) ? pageData.list : (Array.isArray(pageData) ? pageData : [])
  2751. const addressList = this.normalizeAddressRows(rawList)
  2752. if (addressList.length > 0) {
  2753. this.selectAddressRow(addressList[0], true)
  2754. } else {
  2755. this.$set(this.addFormData, 'inspectAddressId', '')
  2756. this.$set(this.addFormData, 'inspectAddress', '')
  2757. this.$set(this.addFormData, 'inspectCityShort', '')
  2758. this.$set(this.addFormData, 'contact', '')
  2759. }
  2760. }
  2761. }).catch(error => {
  2762. console.error('查询供应商地址失败:', error)
  2763. })
  2764. },
  2765. // 打开新增弹窗专用供应商查询
  2766. openPoSupplierDialog () {
  2767. if (this.isSupplierPageMode) {
  2768. return
  2769. }
  2770. this.poSupplierDialogVisible = true
  2771. this.poSupplierPageIndex = 1
  2772. this.poSupplierCurrentRow = null
  2773. this.poSupplierSearch.supplierNo = this.addFormData.supplierNo || ''
  2774. this.poSupplierSearch.supplierName = ''
  2775. this.loadPoSupplierList()
  2776. },
  2777. // 查询新增弹窗专用供应商列表
  2778. loadPoSupplierList () {
  2779. const params = {
  2780. site: this.$store.state.user.site,
  2781. supplierNo: this.poSupplierSearch.supplierNo || '',
  2782. supplierName: this.poSupplierSearch.supplierName || '',
  2783. page: this.poSupplierPageIndex,
  2784. limit: this.poSupplierPageSize
  2785. }
  2786. this.poSupplierLoading = true
  2787. queryPoSupplierPage(params).then(({ data }) => {
  2788. if (data.code === 0 && data.page) {
  2789. this.poSupplierList = (data.page.list || []).map(item => ({
  2790. ...item,
  2791. supplierNo: item.supplierNo || item.supplier_no || '',
  2792. supplierName: item.supplierName || item.supplier_name || '',
  2793. planner: item.planner || ''
  2794. }))
  2795. this.poSupplierTotal = data.page.totalCount || 0
  2796. this.poSupplierPageIndex = data.page.currPage || this.poSupplierPageIndex
  2797. this.poSupplierPageSize = data.page.pageSize || this.poSupplierPageSize
  2798. this.$nextTick(() => {
  2799. if (this.poSupplierList.length > 0) {
  2800. this.poSupplierCurrentRow = this.poSupplierList[0]
  2801. if (this.$refs.poSupplierTable) {
  2802. this.$refs.poSupplierTable.setCurrentRow(this.poSupplierCurrentRow)
  2803. }
  2804. } else {
  2805. this.poSupplierCurrentRow = null
  2806. if (this.$refs.poSupplierTable) {
  2807. this.$refs.poSupplierTable.setCurrentRow()
  2808. }
  2809. }
  2810. })
  2811. } else {
  2812. this.poSupplierList = []
  2813. this.poSupplierTotal = 0
  2814. this.poSupplierCurrentRow = null
  2815. }
  2816. }).catch(() => {
  2817. this.poSupplierList = []
  2818. this.poSupplierTotal = 0
  2819. this.poSupplierCurrentRow = null
  2820. this.$message.error('加载供应商列表失败')
  2821. }).finally(() => {
  2822. this.poSupplierLoading = false
  2823. })
  2824. },
  2825. // 供应商弹框查询
  2826. searchPoSupplierList () {
  2827. this.poSupplierPageIndex = 1
  2828. this.loadPoSupplierList()
  2829. },
  2830. // 供应商弹框重置查询
  2831. resetPoSupplierSearch () {
  2832. this.poSupplierSearch.supplierNo = ''
  2833. this.poSupplierSearch.supplierName = ''
  2834. this.poSupplierPageIndex = 1
  2835. this.loadPoSupplierList()
  2836. },
  2837. // 供应商弹框页大小变化
  2838. onPoSupplierPageSizeChange (val) {
  2839. this.poSupplierPageSize = val
  2840. this.poSupplierPageIndex = 1
  2841. this.loadPoSupplierList()
  2842. },
  2843. // 供应商弹框页码变化
  2844. onPoSupplierPageCurrentChange (val) {
  2845. this.poSupplierPageIndex = val
  2846. this.loadPoSupplierList()
  2847. },
  2848. // 供应商弹框选中行变化
  2849. onPoSupplierCurrentChange (row) {
  2850. this.poSupplierCurrentRow = row || null
  2851. },
  2852. // 供应商弹框双击选择
  2853. onPoSupplierRowDblClick (row) {
  2854. this.selectPoSupplier(row)
  2855. },
  2856. // 供应商弹框点击确认
  2857. confirmPoSupplierSelect () {
  2858. this.selectPoSupplier(this.poSupplierCurrentRow)
  2859. },
  2860. // 回填供应商并刷新PO明细
  2861. selectPoSupplier (row) {
  2862. if (!row || !row.supplierNo) {
  2863. this.$message.warning('请选择供应商')
  2864. return
  2865. }
  2866. const supplierNoVal = row.supplierNo || ''
  2867. const supplierNameVal = row.supplierName || ''
  2868. this.$set(this.addFormData, 'supplierNo', supplierNoVal)
  2869. this.$set(this.addFormData, 'supplierName', supplierNameVal)
  2870. this.$set(this.addFormData, 'inspectAddressId', '')
  2871. this.$set(this.addFormData, 'inspectAddress', '')
  2872. this.$set(this.addFormData, 'inspectCityShort', '')
  2873. this.$set(this.addFormData, 'contact', '')
  2874. this.addPoFilter = {
  2875. orderNo: '',
  2876. partNo: '',
  2877. item: '',
  2878. sku: '',
  2879. partDesc: '',
  2880. supplierName: '',
  2881. planner: ''
  2882. }
  2883. this.addPoPlannerCodeFromChooser = ''
  2884. this.addPoPlannerDisplayFromChooser = ''
  2885. this.poSupplierDialogVisible = false
  2886. this.orderSupplierDialogVisible = false
  2887. this.loadPoList()
  2888. this.fetchSupplierAddress(supplierNoVal)
  2889. },
  2890. // 判断两条PO明细是否为同一行(优先用内部主键,再回退到展示字段)
  2891. isSamePoDetailRow (sourceRow, targetRow) {
  2892. if (!sourceRow || !targetRow) {
  2893. return false
  2894. }
  2895. const sourceOrderNo = String(sourceRow.orderNo || sourceRow.order_no || '')
  2896. const sourceItemNo = String(sourceRow.itemNo || sourceRow.item_no || '')
  2897. const targetOrderNo = String(targetRow.orderNo || targetRow.order_no || '')
  2898. const targetItemNo = String(targetRow.itemNo || targetRow.item_no || '')
  2899. if (sourceOrderNo && sourceItemNo && targetOrderNo && targetItemNo) {
  2900. return sourceOrderNo === targetOrderNo && sourceItemNo === targetItemNo
  2901. }
  2902. return String(sourceRow.orderRef1 || '') === String(targetRow.orderRef1 || '') &&
  2903. String(sourceRow.orderRef2 || '') === String(targetRow.orderRef2 || '') &&
  2904. String(sourceRow.partNo || '') === String(targetRow.partNo || '')
  2905. },
  2906. // 供应商回填后,自动勾选“从订单选择供应商”时选中的那条PO明细
  2907. applyPendingAutoSelectPoRow () {
  2908. if (!this.pendingAutoSelectPoRow) {
  2909. return
  2910. }
  2911. const targetRow = this.pendingAutoSelectPoRow
  2912. this.$nextTick(() => {
  2913. const tableRef = this.$refs.addPoTable
  2914. if (!tableRef) {
  2915. this.pendingAutoSelectPoRow = null
  2916. return
  2917. }
  2918. let matchedRow = null
  2919. for (let i = 0; i < this.filteredPoList.length; i++) {
  2920. if (this.isSamePoDetailRow(this.filteredPoList[i], targetRow)) {
  2921. matchedRow = this.filteredPoList[i]
  2922. break
  2923. }
  2924. }
  2925. if (matchedRow) {
  2926. tableRef.toggleRowSelection(matchedRow, true)
  2927. }
  2928. this.pendingAutoSelectPoRow = null
  2929. })
  2930. },
  2931. // 打开“从订单选择供应商”弹框(不默认筛供应商)
  2932. openOrderSupplierDialog () {
  2933. if (this.isSupplierPageMode) {
  2934. return
  2935. }
  2936. this.orderSupplierDialogVisible = true
  2937. this.orderSupplierCurrentRow = null
  2938. this.orderSupplierPageIndex = 1
  2939. this.orderSupplierTotal = 0
  2940. this.orderSupplierSearch = {
  2941. orderNo: '',
  2942. partNo: '',
  2943. item: '',
  2944. sku: '',
  2945. partDesc: '',
  2946. supplierName: '',
  2947. planner: ''
  2948. }
  2949. this.loadOrderSupplierList()
  2950. },
  2951. // 订单来源供应商弹框查询
  2952. searchOrderSupplierByPo () {
  2953. this.orderSupplierPageIndex = 1
  2954. this.loadOrderSupplierList()
  2955. },
  2956. // 加载订单来源供应商分页列表(专用后端方法)
  2957. loadOrderSupplierList () {
  2958. const params = {
  2959. site: this.$store.state.user.site,
  2960. page: this.orderSupplierPageIndex,
  2961. limit: this.orderSupplierPageSize,
  2962. orderNo: this.orderSupplierSearch.orderNo || '',
  2963. partNo: this.orderSupplierSearch.partNo || '',
  2964. item: this.orderSupplierSearch.item || '',
  2965. sku: this.orderSupplierSearch.sku || '',
  2966. partDesc: this.orderSupplierSearch.partDesc || '',
  2967. supplierName: this.orderSupplierSearch.supplierName || '',
  2968. planner: this.orderSupplierSearch.planner || ''
  2969. }
  2970. this.orderSupplierLoading = true
  2971. queryPoSupplierOrderPage(params).then(({ data }) => {
  2972. if (data.code === 0 && data.page) {
  2973. const list = (data.page.list || []).map(item => ({
  2974. ...item,
  2975. supplierNo: item.supplierNo || item.supplier_no || '',
  2976. supplierName: item.supplierName || item.supplier_name || '',
  2977. planner: item.planner || '',
  2978. crd: item.crd ? String(item.crd).split(' ')[0] : ''
  2979. }))
  2980. this.orderSupplierList = list
  2981. this.orderSupplierTotal = data.page.totalCount || 0
  2982. this.orderSupplierPageIndex = data.page.currPage || this.orderSupplierPageIndex
  2983. this.orderSupplierPageSize = data.page.pageSize || this.orderSupplierPageSize
  2984. this.$nextTick(() => {
  2985. if (this.orderSupplierList.length > 0) {
  2986. this.orderSupplierCurrentRow = this.orderSupplierList[0]
  2987. if (this.$refs.orderSupplierTable) {
  2988. this.$refs.orderSupplierTable.setCurrentRow(this.orderSupplierCurrentRow)
  2989. }
  2990. } else {
  2991. this.orderSupplierCurrentRow = null
  2992. if (this.$refs.orderSupplierTable) {
  2993. this.$refs.orderSupplierTable.setCurrentRow()
  2994. }
  2995. }
  2996. })
  2997. } else {
  2998. this.orderSupplierList = []
  2999. this.orderSupplierCurrentRow = null
  3000. this.orderSupplierTotal = 0
  3001. }
  3002. }).catch(() => {
  3003. this.orderSupplierList = []
  3004. this.orderSupplierCurrentRow = null
  3005. this.orderSupplierTotal = 0
  3006. this.$message.error('加载订单来源供应商失败')
  3007. }).finally(() => {
  3008. this.orderSupplierLoading = false
  3009. })
  3010. },
  3011. // 重置“从订单选择供应商”筛选条件
  3012. resetOrderSupplierSearch () {
  3013. this.orderSupplierSearch = {
  3014. orderNo: '',
  3015. partNo: '',
  3016. item: '',
  3017. sku: '',
  3018. partDesc: '',
  3019. supplierName: '',
  3020. planner: ''
  3021. }
  3022. this.orderSupplierPageIndex = 1
  3023. this.loadOrderSupplierList()
  3024. },
  3025. // 订单来源供应商弹框页大小变化
  3026. onOrderSupplierPageSizeChange (val) {
  3027. this.orderSupplierPageSize = val
  3028. this.orderSupplierPageIndex = 1
  3029. this.loadOrderSupplierList()
  3030. },
  3031. // 订单来源供应商弹框页码变化
  3032. onOrderSupplierPageCurrentChange (val) {
  3033. this.orderSupplierPageIndex = val
  3034. this.loadOrderSupplierList()
  3035. },
  3036. // “从订单选择供应商”选中行变化
  3037. onOrderSupplierCurrentChange (row) {
  3038. this.orderSupplierCurrentRow = row || null
  3039. },
  3040. // “从订单选择供应商”双击选择
  3041. onOrderSupplierRowDblClick (row) {
  3042. this.selectSupplierByOrderRow(row)
  3043. },
  3044. // “从订单选择供应商”点击确认
  3045. confirmOrderSupplierSelect () {
  3046. this.selectSupplierByOrderRow(this.orderSupplierCurrentRow)
  3047. },
  3048. // 从订单行回填供应商并触发原有后续流程
  3049. selectSupplierByOrderRow (row) {
  3050. if (!row) {
  3051. this.$message.warning('请选择订单行')
  3052. return
  3053. }
  3054. const supplierNo = row.supplierNo || row.supplier_no || ''
  3055. const supplierName = row.supplierName || row.supplier_name || ''
  3056. if (!supplierNo) {
  3057. this.$message.warning('所选订单行缺少供应商编码')
  3058. return
  3059. }
  3060. this.pendingAutoSelectPoRow = {
  3061. orderNo: row.orderNo || row.order_no || '',
  3062. itemNo: row.itemNo || row.item_no || '',
  3063. orderRef1: row.orderRef1 || '',
  3064. orderRef2: row.orderRef2 || '',
  3065. partNo: row.partNo || ''
  3066. }
  3067. this.selectPoSupplier({
  3068. supplierNo: supplierNo,
  3069. supplierName: supplierName
  3070. })
  3071. },
  3072. // 加载PO列表(选择供应商后调用)
  3073. loadPoList () {
  3074. if (!this.addFormData.supplierNo) {
  3075. this.$message.warning('请先选择供应商')
  3076. return
  3077. }
  3078. const params = {
  3079. supplierNo: this.addFormData.supplierNo,
  3080. site: this.$store.state.user.site,
  3081. page: 1,
  3082. limit: 1000
  3083. }
  3084. queryPoPage(params).then(({ data }) => {
  3085. if (data.code === 0 && data.page) {
  3086. this.poList = data.page.list.map(item => ({
  3087. ...item,
  3088. supplierNo: item.supplierNo || item.supplier_no || this.addFormData.supplierNo || '',
  3089. supplierName: item.supplierName || item.supplier_name || this.addFormData.supplierName || '',
  3090. planner: item.planner || '',
  3091. inspectQty: item.waitInspectQty || 0, // 默认值为未验货数量
  3092. shipMethod: item.shipMethod || '',// 运输方式
  3093. crd: item.crd ? item.crd.split(' ')[0] : ''
  3094. }))
  3095. this.filterAddPoList()
  3096. this.applyPendingAutoSelectPoRow()
  3097. } else {
  3098. this.poList = []
  3099. this.filteredPoList = []
  3100. this.pendingAutoSelectPoRow = null
  3101. this.$message.info('该供应商暂无可申请验货的PO')
  3102. }
  3103. }).catch(() => {
  3104. this.poList = []
  3105. this.filteredPoList = []
  3106. this.pendingAutoSelectPoRow = null
  3107. this.$message.error('加载PO列表失败')
  3108. })
  3109. },
  3110. // 表格选择变化
  3111. handleSelectionChange (selection) {
  3112. this.selectedPoList = selection
  3113. },
  3114. // Planner 输入若被手工改动,则清理双击选择时缓存的显示名映射
  3115. handleAddPoPlannerInput (value) {
  3116. const plannerKeyword = String(value || '').trim()
  3117. const chooserPlannerCode = String(this.addPoPlannerCodeFromChooser || '').trim()
  3118. if (!plannerKeyword || plannerKeyword !== chooserPlannerCode) {
  3119. this.addPoPlannerCodeFromChooser = ''
  3120. this.addPoPlannerDisplayFromChooser = ''
  3121. }
  3122. },
  3123. // 新增验货申请-PO明细筛选
  3124. filterAddPoList () {
  3125. let result = [...this.poList]
  3126. const filter = this.addPoFilter || {}
  3127. const orderNoKeyword = (filter.orderNo || '').toLowerCase().trim()
  3128. const partNoKeyword = (filter.partNo || '').toLowerCase().trim()
  3129. const itemKeyword = (filter.item || '').toLowerCase().trim()
  3130. const skuKeyword = (filter.sku || '').toLowerCase().trim()
  3131. const partDescKeyword = (filter.partDesc || '').toLowerCase().trim()
  3132. const supplierNameKeyword = (filter.supplierName || '').toLowerCase().trim()
  3133. const plannerKeyword = (filter.planner || '').toLowerCase().trim()
  3134. const chooserPlannerCode = String(this.addPoPlannerCodeFromChooser || '').toLowerCase().trim()
  3135. const chooserPlannerDisplay = String(this.addPoPlannerDisplayFromChooser || '').toLowerCase().trim()
  3136. const useChooserDisplayKeyword = plannerKeyword && chooserPlannerCode && plannerKeyword === chooserPlannerCode
  3137. ? chooserPlannerDisplay
  3138. : ''
  3139. if (orderNoKeyword) {
  3140. result = result.filter(item => {
  3141. const orderRef1 = String(item.orderRef1 || '').toLowerCase()
  3142. const orderNo = String(item.orderNo || item.order_no || '').toLowerCase()
  3143. return orderRef1.includes(orderNoKeyword) || orderNo.includes(orderNoKeyword)
  3144. })
  3145. }
  3146. if (partNoKeyword) {
  3147. result = result.filter(item => String(item.partNo || '').toLowerCase().includes(partNoKeyword))
  3148. }
  3149. if (itemKeyword) {
  3150. result = result.filter(item => String(item.item || '').toLowerCase().includes(itemKeyword))
  3151. }
  3152. if (skuKeyword) {
  3153. result = result.filter(item => String(item.sku || '').toLowerCase().includes(skuKeyword))
  3154. }
  3155. if (partDescKeyword) {
  3156. result = result.filter(item => String(item.partDesc || '').toLowerCase().includes(partDescKeyword))
  3157. }
  3158. if (supplierNameKeyword) {
  3159. result = result.filter(item => String(item.supplierName || '').toLowerCase().includes(supplierNameKeyword))
  3160. }
  3161. if (plannerKeyword) {
  3162. result = result.filter(item => {
  3163. const plannerText = String(item.planner || '').toLowerCase()
  3164. if (plannerText.includes(plannerKeyword)) {
  3165. return true
  3166. }
  3167. return useChooserDisplayKeyword ? plannerText.includes(useChooserDisplayKeyword) : false
  3168. })
  3169. }
  3170. this.filteredPoList = result
  3171. },
  3172. // 新增验货申请-PO筛选重置
  3173. resetAddPoFilter () {
  3174. this.addPoFilter = {
  3175. orderNo: '',
  3176. partNo: '',
  3177. item: '',
  3178. sku: '',
  3179. partDesc: '',
  3180. supplierName: '',
  3181. planner: ''
  3182. }
  3183. this.addPoPlannerCodeFromChooser = ''
  3184. this.addPoPlannerDisplayFromChooser = ''
  3185. this.filterAddPoList()
  3186. },
  3187. // CRD日期排序方法
  3188. sortCrdDate (a, b) {
  3189. const dateA = a.crd || ''
  3190. const dateB = b.crd || ''
  3191. if (!dateA && !dateB) return 0
  3192. if (!dateA) return -1
  3193. if (!dateB) return 1
  3194. return dateA.localeCompare(dateB)
  3195. },
  3196. // 验货数量变化
  3197. handleInspectQtyChange (row, value) {
  3198. console.log('验货数量变化:', row.orderRef1, value)
  3199. // 确保数据被正确更新
  3200. this.$set(row, 'inspectQty', value)
  3201. },
  3202. // 保存
  3203. handleSaveAdd () {
  3204. if (this.isEditDialogMode) {
  3205. this.handleSaveEdit()
  3206. return
  3207. }
  3208. console.log('开始保存,当前选择的PO列表:', this.selectedPoList)
  3209. console.log('表单数据:', this.addFormData)
  3210. this.$refs.addFormData.validate((valid) => {
  3211. console.log('表单验证结果:', valid)
  3212. if (valid) {
  3213. if (this.selectedPoList.length === 0) {
  3214. this.$message.warning('请至少选择一条PO明细')
  3215. return
  3216. }
  3217. // 检查验货数量
  3218. const hasInvalidQty = this.selectedPoList.some(item => !item.inspectQty || item.inspectQty <= 0)
  3219. if (hasInvalidQty) {
  3220. this.$message.warning('请填写有效的验货数量')
  3221. return
  3222. }
  3223. // 构建提交数据
  3224. const submitData = {
  3225. requestDate: this.addFormData.requestDate,
  3226. needInspectDate: this.addFormData.needInspectDate,
  3227. supplierNo: this.addFormData.supplierNo,
  3228. inspectAddress: this.addFormData.inspectAddressId || this.addFormData.inspectAddress,
  3229. inspectAddressId: this.addFormData.inspectAddressId || '',
  3230. inspectCityShort: this.addFormData.inspectCityShort || '',
  3231. inspectContract: this.addFormData.contact,
  3232. remark: '',
  3233. items: this.selectedPoList.map(item => ({
  3234. orderNo: item.orderNo || item.order_ref1 || item.orderRef1,
  3235. itemNo: item.itemNo || item.item_no || item.order_ref2 || item.orderRef2,
  3236. partNo: item.partNo,
  3237. orderRef1: item.orderRef1,
  3238. orderRef2: item.orderRef2,
  3239. qty: item.inspectQty,
  3240. shipMethod: item.shipMethod,
  3241. crd: item.crd
  3242. }))
  3243. }
  3244. console.log('提交的数据:', submitData)
  3245. saveInspectionRequest(submitData).then(({ data }) => {
  3246. console.log('保存接口返回:', data)
  3247. if (data.code === 0) {
  3248. this.$message.success('保存成功')
  3249. this.handleCloseAddDialog()
  3250. this.getMainData()
  3251. } else {
  3252. this.$message.error(data.msg || '保存失败')
  3253. }
  3254. }).catch((error) => {
  3255. console.error('保存接口错误:', error)
  3256. this.$message.error('保存失败,请稍后重试')
  3257. })
  3258. } else {
  3259. console.log('表单验证失败')
  3260. this.$message.warning('请填写完整的表单信息')
  3261. }
  3262. })
  3263. },
  3264. // 草稿编辑保存:将当前表格中所有PO明细(排除已删除的)作为最终状态一次性提交
  3265. handleSaveEdit () {
  3266. this.$refs.addFormData.validate((valid) => {
  3267. if (!valid) {
  3268. this.$message.warning('请填写完整的表单信息')
  3269. return
  3270. }
  3271. // 收集当前表格中所有PO明细(排除已删除的),作为最终状态
  3272. const allItems = []
  3273. this.editPoDetailList.forEach(row => {
  3274. const key = `${row.orderRef1 || ''}_${row.orderRef2 || ''}`
  3275. // 跳过已删除的
  3276. if (this.deletedPoKeys.has(key)) {
  3277. return
  3278. }
  3279. allItems.push({
  3280. orderNo: row.poNo || row.orderNo || row.order_ref1 || row.orderRef1 || '',
  3281. orderRef1: row.orderRef1 || row.order_ref1 || '',
  3282. orderRef2: row.orderRef2 || row.order_ref2 || '',
  3283. poItemNo: row.poItemNo || row.po_item_no || row.itemNo || row.item_no || row.orderRef2 || row.order_ref2 || '',
  3284. partNo: row.partNo || '',
  3285. qty: row.qty || 0,
  3286. shipMethod: row.shipMethod || row.shipMothod || '',
  3287. crd: row.crd || ''
  3288. })
  3289. })
  3290. console.log('=== 草稿编辑保存提交数据 ===', {
  3291. requestNo: this.addFormData.requestNo,
  3292. 明细数量: allItems.length,
  3293. 明细: allItems
  3294. })
  3295. // 一次性提交后端:全量替换明细 + 更新基础信息(事务保证原子性)
  3296. const submitData = {
  3297. requestNo: this.addFormData.requestNo,
  3298. site: this.$store.state.user.site,
  3299. items: allItems,
  3300. needInspectDate: this.addFormData.needInspectDate,
  3301. inspectAddress: this.addFormData.inspectAddressId || this.addFormData.inspectAddress,
  3302. inspectAddressId: this.addFormData.inspectAddressId || '',
  3303. inspectContract: this.addFormData.contact
  3304. }
  3305. editSaveInspectionRequest(submitData).then(({ data }) => {
  3306. if (data.code === 0) {
  3307. this.$message.success('修改成功')
  3308. this.handleCloseAddDialog()
  3309. this.getMainData()
  3310. } else {
  3311. this.$message.error(data.msg || '修改失败')
  3312. }
  3313. }).catch((error) => {
  3314. console.error('保存失败:', error)
  3315. this.$message.error(error.message || '保存失败,请稍后重试')
  3316. })
  3317. })
  3318. },
  3319. // Excel导入
  3320. importExcel () {
  3321. this.uploadDialogVisible = true
  3322. this.uploadFileName = ''
  3323. this.uploadFile = null
  3324. this.uploadPreviewList = []
  3325. },
  3326. // 文件选择变化
  3327. handleFileChange (file) {
  3328. this.uploadFile = file.raw
  3329. this.uploadFileName = file.name
  3330. },
  3331. // 预览上传数据
  3332. previewUpload () {
  3333. if (!this.uploadFile) {
  3334. this.$message.warning('请先选择文件')
  3335. return
  3336. }
  3337. const formData = new FormData()
  3338. formData.append('file', this.uploadFile)
  3339. // 调用后端预览接口
  3340. previewUpload(this.uploadFile).then(({ data }) => {
  3341. if (data && data.code === 0) {
  3342. this.uploadPreviewList = data.data || []
  3343. this.$message.success('文件解析成功,请确认数据后点击保存')
  3344. } else {
  3345. this.$message.error(data.msg || '文件解析失败')
  3346. }
  3347. }).catch((error) => {
  3348. console.error('文件解析失败:', error)
  3349. const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
  3350. this.$message.error('文件解析失败: ' + errorMsg)
  3351. })
  3352. },
  3353. // 确认上传
  3354. confirmUpload () {
  3355. if (this.uploadPreviewList.length === 0) {
  3356. this.$message.warning('没有可保存的数据')
  3357. return
  3358. }
  3359. this.$confirm(`确认保存 ${this.uploadPreviewList.length} 条数据吗?`, '提示', {
  3360. confirmButtonText: '确定',
  3361. cancelButtonText: '取消',
  3362. type: 'warning'
  3363. }).then(() => {
  3364. // 调用后端保存接口
  3365. batchSave(this.uploadFile).then(({ data }) => {
  3366. if (data && data.code === 0) {
  3367. this.$message.success('数据保存成功')
  3368. this.uploadDialogVisible = false
  3369. this.getMainData()
  3370. } else {
  3371. this.$message.error(data.msg || '数据保存失败')
  3372. }
  3373. }).catch((error) => {
  3374. console.error('数据保存失败:', error)
  3375. const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
  3376. this.$message.error('数据保存失败: ' + errorMsg)
  3377. })
  3378. }).catch(() => {})
  3379. },
  3380. // 下载模板
  3381. downloadTemplate () {
  3382. const loading = this.$loading({
  3383. lock: true,
  3384. text: '正在下载模板...',
  3385. spinner: 'el-icon-loading',
  3386. background: 'rgba(0, 0, 0, 0.7)'
  3387. })
  3388. this.$http({
  3389. url: this.$http.adornUrl('/inspection/downloadTemplate'),
  3390. method: 'post',
  3391. responseType: 'blob'
  3392. }).then(response => {
  3393. loading.close()
  3394. // 创建下载文件
  3395. const blob = new Blob([response.data], {
  3396. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  3397. })
  3398. const url = window.URL.createObjectURL(blob)
  3399. const link = document.createElement('a')
  3400. link.href = url
  3401. link.download = '验货申请导入模板.xlsx'
  3402. document.body.appendChild(link)
  3403. link.click()
  3404. document.body.removeChild(link)
  3405. window.URL.revokeObjectURL(url)
  3406. this.$message.success('模板下载成功')
  3407. }).catch(error => {
  3408. loading.close()
  3409. console.error('模板下载失败:', error)
  3410. this.$message.error('模板下载失败,请联系管理员')
  3411. })
  3412. },
  3413. // 导出
  3414. exportExcel () {
  3415. console.log('开始导出...')
  3416. // 生成文件名(使用原生 Date)
  3417. const now = new Date()
  3418. const year = now.getFullYear()
  3419. const month = String(now.getMonth() + 1).padStart(2, '0')
  3420. const day = String(now.getDate()).padStart(2, '0')
  3421. const hour = String(now.getHours()).padStart(2, '0')
  3422. const minute = String(now.getMinutes()).padStart(2, '0')
  3423. const second = String(now.getSeconds()).padStart(2, '0')
  3424. const exportName = `检验申请单${year}${month}${day}${hour}${minute}${second}`
  3425. console.log('导出参数:', this.searchData)
  3426. // 获取当前查询条件
  3427. const exportParams = {
  3428. ...this.searchData,
  3429. limit: 99999,
  3430. page: 1
  3431. }
  3432. try {
  3433. excel.exportTable({
  3434. url: 'inspection/searchInspectionRequestHeaderList',
  3435. columnMapping: this.columnArray1,
  3436. mergeSetting: [],
  3437. params: exportParams,
  3438. fileName: exportName + '.xlsx',
  3439. rowFetcher: res => {
  3440. console.log('导出数据响应:', res)
  3441. if (res.data && res.data.page && res.data.page.list) {
  3442. return res.data.page.list
  3443. }
  3444. console.error('响应数据结构异常:', res.data)
  3445. this.$message.error('导出数据格式异常,请查看控制台')
  3446. return []
  3447. },
  3448. columnFormatter: [],
  3449. dropColumns: []
  3450. })
  3451. console.log('导出请求已发送')
  3452. } catch (error) {
  3453. console.error('导出失败:', error)
  3454. this.$message.error('导出失败: ' + error.message)
  3455. }
  3456. },
  3457. // 确认验货申请
  3458. confirmInspection (row) {
  3459. this.$confirm('确定要确认该验货申请吗?', '提示', {
  3460. confirmButtonText: '确定',
  3461. cancelButtonText: '取消',
  3462. type: 'warning'
  3463. }).then(() => {
  3464. confirmInspectionRequest(row.requestNo).then(({ data }) => {
  3465. if (data.code === 0) {
  3466. this.$message.success('确认成功')
  3467. this.getMainData()
  3468. } else {
  3469. this.$message.error(data.msg || '确认失败')
  3470. }
  3471. }).catch((error) => {
  3472. console.error('确认接口错误:', error)
  3473. this.$message.error('确认失败,请稍后重试')
  3474. })
  3475. }).catch(() => {
  3476. this.$message.info('已取消确认')
  3477. })
  3478. },
  3479. // 删除验货申请
  3480. deleteInspectionRequest (row) {
  3481. if (!this.isRowStatus(row, ['Draft', 'Confirmed'])) {
  3482. this.$message.warning('只有草稿和待审核状态允许删除')
  3483. return
  3484. }
  3485. this.$confirm('确定要删除该验货申请吗?', '提示', {
  3486. confirmButtonText: '确定',
  3487. cancelButtonText: '取消',
  3488. type: 'warning'
  3489. }).then(() => {
  3490. deleteInspectionRequest(row.requestNo).then(({ data }) => {
  3491. if (data.code === 0) {
  3492. this.$message.success('删除成功')
  3493. this.getMainData()
  3494. } else {
  3495. this.$message.error(data.msg || '删除失败')
  3496. }
  3497. }).catch((error) => {
  3498. console.error('删除接口错误:', error)
  3499. this.$message.error('删除失败,请稍后重试')
  3500. })
  3501. }).catch(() => {
  3502. this.$message.info('已取消删除')
  3503. })
  3504. },
  3505. // 草稿编辑:仅可编辑建议验货日期、验货地址、联系人 - rqrq
  3506. editInspectionRequest (row) {
  3507. if (!this.isRowStatus(row, ['Draft'])) {
  3508. this.$message.warning('只有草稿状态允许编辑')
  3509. return
  3510. }
  3511. this.openEditInspectionDialog(row)
  3512. },
  3513. // 申请变更(待审核/已下达直接退回草稿;已排程进入变更审批)- rqrq
  3514. applyChangeRequest (row) {
  3515. if (!this.isRowStatus(row, ['Confirmed', 'Audited', 'Scheduled'])) {
  3516. this.$message.warning('只有待审核、已下达或已排程状态允许申请变更')
  3517. return
  3518. }
  3519. const isScheduled = this.isRowStatus(row, ['Scheduled'])
  3520. if (isScheduled) {
  3521. this.applyChangeForm = {
  3522. requestNo: row.requestNo || '',
  3523. statusDb: 'Scheduled',
  3524. changeRemark: ''
  3525. }
  3526. this.applyChangeDialogVisible = true
  3527. return
  3528. }
  3529. const tipText = `${this.isRowStatus(row, ['Confirmed']) ? '待审核' : '已下达'}申请单申请变更后将回到【草稿】,是否继续?`
  3530. this.$confirm(tipText, '提示', {
  3531. confirmButtonText: '确定',
  3532. cancelButtonText: '取消',
  3533. type: 'warning'
  3534. }).then(() => {
  3535. this.executeApplyChangeRequest(row.requestNo, '')
  3536. }).catch(() => {
  3537. this.$message.info('已取消申请变更')
  3538. })
  3539. },
  3540. // 提交已排程的变更申请(需填写备注)- rqrq
  3541. submitApplyChangeRequest () {
  3542. const requestNo = this.applyChangeForm.requestNo || ''
  3543. const changeRemark = this.applyChangeForm.changeRemark ? this.applyChangeForm.changeRemark.trim() : ''
  3544. if (!requestNo) {
  3545. this.$message.warning('申请单号不能为空')
  3546. return
  3547. }
  3548. if (!changeRemark) {
  3549. this.$message.warning('请填写变更备注')
  3550. return
  3551. }
  3552. this.$confirm('确定提交变更申请吗?', '提示', {
  3553. confirmButtonText: '确定',
  3554. cancelButtonText: '取消',
  3555. type: 'warning'
  3556. }).then(() => {
  3557. this.executeApplyChangeRequest(requestNo, changeRemark)
  3558. }).catch(() => {
  3559. this.$message.info('已取消提交')
  3560. })
  3561. },
  3562. // 操作列导出单条记录 - 调用后端接口生成带边框样式的Excel
  3563. exportRowExcel (row) {
  3564. if (!row || !row.requestNo) {
  3565. this.$message.warning('数据异常,无法导出')
  3566. return
  3567. }
  3568. this.$http({
  3569. url: this.$http.adornUrl(`/inspection/export/${row.requestNo}`),
  3570. method: 'get',
  3571. params: { site: row.site },
  3572. responseType: 'blob'
  3573. }).then(response => {
  3574. const blob = new Blob([response.data], {
  3575. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  3576. })
  3577. const url = window.URL.createObjectURL(blob)
  3578. const link = document.createElement('a')
  3579. link.href = url
  3580. link.download = '验货申请单_' + row.requestNo + '.xlsx'
  3581. document.body.appendChild(link)
  3582. link.click()
  3583. document.body.removeChild(link)
  3584. window.URL.revokeObjectURL(url)
  3585. this.$message.success('导出成功')
  3586. }).catch(error => {
  3587. console.error('导出失败:', error)
  3588. this.$message.error('导出失败,请稍后重试')
  3589. })
  3590. },
  3591. // 操作列导出验货结果Excel:后端按模板填充后直接下载xlsx - rqrq
  3592. async exportInspectionResultExcel (row) {
  3593. // 1) 基础参数校验:确保当前行存在有效申请单号 - rqrq
  3594. if (!row || !row.requestNo) {
  3595. this.$message.warning('数据异常,无法导出验货结果Excel')
  3596. return
  3597. }
  3598. // 2) site显式传参:业务唯一来源为前端登录态site,不再使用行数据兜底 - rqrq
  3599. const requestSite = this.$store.state.user.site
  3600. if (!requestSite) {
  3601. this.$message.warning('站点不能为空,无法导出验货结果Excel')
  3602. return
  3603. }
  3604. // 3) 调用后端Excel导出接口,返回blob并下载为xlsx - rqrq
  3605. try {
  3606. const response = await this.$http({
  3607. url: this.$http.adornUrl(`/inspection/exportInspectResultExcel/${row.requestNo}`),
  3608. method: 'get',
  3609. params: { site: requestSite },
  3610. responseType: 'blob'
  3611. })
  3612. const responseBlob = response.data
  3613. const responseContentType = String(
  3614. (response.headers && (response.headers['content-type'] || response.headers['Content-Type'])) || ''
  3615. ).toLowerCase()
  3616. // 4) 兼容后端异常响应:若是json/文本,读取错误信息并提示,不下载错误文件 - rqrq
  3617. if (responseContentType.includes('application/json') || responseContentType.includes('text/plain') || responseContentType.includes('text/html')) {
  3618. const errorText = await this.readBlobAsText(responseBlob)
  3619. const errorMessage = this.extractBlobErrorMessage(errorText)
  3620. this.$message.error(errorMessage || '导出验货结果Excel失败,请稍后重试')
  3621. return
  3622. }
  3623. // 5) 下载有效Excel文件 - rqrq
  3624. const blob = new Blob([responseBlob], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
  3625. const downloadUrl = window.URL.createObjectURL(blob)
  3626. const link = document.createElement('a')
  3627. link.href = downloadUrl
  3628. link.download = `验货结果_${row.requestNo}.xlsx`
  3629. document.body.appendChild(link)
  3630. link.click()
  3631. document.body.removeChild(link)
  3632. window.URL.revokeObjectURL(downloadUrl)
  3633. this.$message.success('导出验货结果Excel成功')
  3634. } catch (error) {
  3635. console.error('导出验货结果Excel失败:', error)
  3636. this.$message.error('导出验货结果Excel失败,请稍后重试')
  3637. }
  3638. },
  3639. // 读取Blob文本内容:用于解析后端错误响应 - rqrq
  3640. readBlobAsText (blob) {
  3641. return new Promise((resolve) => {
  3642. if (!blob) {
  3643. resolve('')
  3644. return
  3645. }
  3646. const fileReader = new FileReader()
  3647. fileReader.onload = () => resolve(String(fileReader.result || ''))
  3648. fileReader.onerror = () => resolve('')
  3649. fileReader.readAsText(blob, 'utf-8')
  3650. })
  3651. },
  3652. // 提取后端错误信息:兼容 {"msg":"..."} 或纯文本错误 - rqrq
  3653. extractBlobErrorMessage (rawText) {
  3654. if (!rawText) {
  3655. return ''
  3656. }
  3657. const normalizedText = String(rawText).trim()
  3658. if (!normalizedText) {
  3659. return ''
  3660. }
  3661. try {
  3662. const parsed = JSON.parse(normalizedText)
  3663. if (parsed && parsed.msg) {
  3664. return parsed.msg
  3665. }
  3666. } catch (e) {
  3667. // 非JSON文本按原样回传 - rqrq
  3668. }
  3669. return normalizedText.length > 200 ? normalizedText.substring(0, 200) : normalizedText
  3670. },
  3671. executeApplyChangeRequest (requestNo, changeRemark) {
  3672. this.applyChangeLoading = true
  3673. applyChangeInspectionRequest(requestNo, { changeRemark }).then(({ data }) => {
  3674. if (data && data.code === 0) {
  3675. this.$message.success('申请变更成功')
  3676. this.applyChangeDialogVisible = false
  3677. this.getMainData()
  3678. } else {
  3679. this.$message.error((data && data.msg) || '申请变更失败')
  3680. }
  3681. }).catch((error) => {
  3682. console.error('申请变更接口错误:', error)
  3683. this.$message.error('申请变更失败,请稍后重试')
  3684. }).finally(() => {
  3685. this.applyChangeLoading = false
  3686. })
  3687. }
  3688. }
  3689. }
  3690. </script>
  3691. <style scoped lang="scss">
  3692. .search-form-inline {
  3693. background: #fff;
  3694. padding: 0;
  3695. margin-bottom: 0;
  3696. }
  3697. .search-row {
  3698. display: flex;
  3699. align-items: flex-end;
  3700. flex-wrap: wrap;
  3701. gap: 0;
  3702. margin-bottom: 0;
  3703. }
  3704. .search-item {
  3705. flex: none;
  3706. margin-bottom: 0;
  3707. margin-right: 12px;
  3708. }
  3709. /* 使用 Element UI 默认字体大小,不再覆盖 */
  3710. .search-item /deep/ .el-form-item__label {
  3711. padding-bottom: 0;
  3712. line-height: 1.2;
  3713. }
  3714. .search-btn-item {
  3715. flex: none;
  3716. margin-bottom: 0;
  3717. margin-right: 0;
  3718. }
  3719. .search-item /deep/ .el-form-item__content {
  3720. line-height: normal;
  3721. }
  3722. .date-range {
  3723. display: flex;
  3724. align-items: center;
  3725. }
  3726. .split {
  3727. padding: 0 6px;
  3728. color: #606266;
  3729. font-size: 13px;
  3730. }
  3731. /**
  3732. * 验货申请详情页签统一高度容器:
  3733. * 1) 固定高度:保证“基本信息/明细/结果/费用/附件”视觉高度一致;
  3734. * 2) 内部滚动:内容超高时在当前页签滚动,避免整体布局抖动。
  3735. */
  3736. .tab-pane-content {
  3737. width: 100%;
  3738. overflow-y: auto;
  3739. overflow-x: hidden;
  3740. }
  3741. /* 主表固定列偶发“透明/叠层”修复:统一固定列背景并约束单元格单行,避免主表与fixed列行高漂移 - rqrq */
  3742. .customer-css /deep/ .el-table__fixed,
  3743. .customer-css /deep/ .el-table__fixed-right,
  3744. .customer-css /deep/ .el-table__fixed-right-patch {
  3745. background-color: #fff;
  3746. }
  3747. /* 固定列正文单元格始终白底,避免看到下层正文产生“透明”错觉 - rqrq */
  3748. .customer-css /deep/ .el-table__fixed-body-wrapper td,
  3749. .customer-css /deep/ .el-table__fixed-right .el-table__fixed-body-wrapper td {
  3750. background-color: #fff;
  3751. }
  3752. /* 主表与固定列统一单行展示,减少行高不一致导致的视觉错位 - rqrq */
  3753. .customer-css /deep/ .el-table__body-wrapper .cell,
  3754. .customer-css /deep/ .el-table__fixed-body-wrapper .cell {
  3755. white-space: nowrap;
  3756. overflow: hidden;
  3757. text-overflow: ellipsis;
  3758. }
  3759. /deep/ .customer-tab .el-tabs__content {
  3760. padding: 5px !important;
  3761. }
  3762. .form-section {
  3763. margin-bottom: 15px;
  3764. padding-bottom: 15px;
  3765. border-bottom: 1px solid #ebeef5;
  3766. padding: 5px 10px;
  3767. }
  3768. .add-dialog-form /deep/ .el-form-item {
  3769. margin-bottom: 10px;
  3770. }
  3771. .add-dialog-form /deep/ .el-form-item__label {
  3772. text-align: left;
  3773. float: none;
  3774. display: block;
  3775. padding: 0 0 5px 0;
  3776. line-height: 1;
  3777. font-size: 13px;
  3778. }
  3779. .add-dialog-form /deep/ .el-form-item__content {
  3780. margin-left: 0 !important;
  3781. }
  3782. .po-section {
  3783. .section-title {
  3784. font-size: 14px;
  3785. font-weight: bold;
  3786. color: #303133;
  3787. margin-bottom: 8px;
  3788. }
  3789. .section-desc {
  3790. font-size: 12px;
  3791. color: #909399;
  3792. margin-bottom: 10px;
  3793. }
  3794. }
  3795. .dialog-footer {
  3796. text-align: center;
  3797. }
  3798. /deep/ .el-input-number .el-input__inner {
  3799. text-align: right !important;
  3800. padding-right: 32px !important;
  3801. padding-left: 8px !important;
  3802. box-sizing: border-box;
  3803. }
  3804. /deep/ .el-input .el-input--mini {
  3805. line-height: 20px;
  3806. }
  3807. /deep/ .el-input-number .el-input--mini {
  3808. line-height: 20px;
  3809. }
  3810. /* PO表格输入控件防遮挡 */
  3811. .po-section {
  3812. /deep/ .el-table .cell {
  3813. height: auto;
  3814. line-height: 20px;
  3815. overflow: hidden !important;
  3816. text-overflow: ellipsis;
  3817. white-space: nowrap;
  3818. padding-left: 4px;
  3819. padding-right: 4px;
  3820. }
  3821. /deep/ .el-input,
  3822. /deep/ .el-select {
  3823. width: 100% !important;
  3824. }
  3825. /deep/ .el-input-number .el-input__inner {
  3826. padding-left: 8px !important;
  3827. padding-right: 35px !important;
  3828. text-align: right;
  3829. }
  3830. /deep/ .el-input-number {
  3831. width: 120px !important;
  3832. min-width: 120px !important;
  3833. }
  3834. /deep/ .el-select .el-input__inner {
  3835. padding-right: 25px !important;
  3836. }
  3837. }
  3838. // 数字输入框按钮样式修复
  3839. /deep/ .el-input-number {
  3840. position: relative;
  3841. .el-input-number__increase,
  3842. .el-input-number__decrease {
  3843. width: 28px;
  3844. height: 50%;
  3845. position: absolute;
  3846. right: 0;
  3847. display: flex;
  3848. align-items: center;
  3849. justify-content: center;
  3850. background-color: #f5f7fa;
  3851. border: none;
  3852. cursor: pointer;
  3853. transition: all 0.2s;
  3854. font-size: 12px;
  3855. &:hover {
  3856. background-color: #ecf5ff;
  3857. color: #409eff;
  3858. }
  3859. &:active {
  3860. background-color: #d9e1f0;
  3861. }
  3862. }
  3863. .el-input-number__increase {
  3864. top: 0;
  3865. bottom: auto;
  3866. border-bottom: 1px solid #dcdfe6;
  3867. border-top-right-radius: 4px;
  3868. }
  3869. .el-input-number__decrease {
  3870. top: auto;
  3871. bottom: 0;
  3872. border-bottom-right-radius: 4px;
  3873. }
  3874. // 确保输入框右边留出按钮空间
  3875. .el-input__inner {
  3876. padding-right: 32px !important;
  3877. }
  3878. }
  3879. // 数字输入框按钮样式修复
  3880. /deep/ .el-input-number {
  3881. position: relative;
  3882. .el-input-number__increase,
  3883. .el-input-number__decrease {
  3884. width: 28px;
  3885. height: 50%;
  3886. position: absolute;
  3887. right: 0;
  3888. display: flex;
  3889. align-items: center;
  3890. justify-content: center;
  3891. background-color: #f5f7fa;
  3892. border: none;
  3893. cursor: pointer;
  3894. transition: all 0.2s;
  3895. font-size: 12px;
  3896. &:hover {
  3897. background-color: #ecf5ff;
  3898. color: #409eff;
  3899. }
  3900. &:active {
  3901. background-color: #d9e1f0;
  3902. }
  3903. }
  3904. .el-input-number__increase {
  3905. top: 0;
  3906. bottom: auto;
  3907. border-bottom: 1px solid #dcdfe6;
  3908. border-top-right-radius: 4px;
  3909. }
  3910. .el-input-number__decrease {
  3911. top: auto;
  3912. bottom: 0;
  3913. border-bottom-right-radius: 4px;
  3914. }
  3915. .el-input__inner {
  3916. padding-right: 32px !important;
  3917. }
  3918. }
  3919. /deep/ .el-input-number--mini {
  3920. .el-input-number__increase,
  3921. .el-input-number__decrease {
  3922. width: 24px;
  3923. font-size: 10px;
  3924. }
  3925. .el-input__inner {
  3926. padding-right: 28px !important;
  3927. }
  3928. }
  3929. .po-section {
  3930. /deep/ .el-date-editor.el-input,
  3931. /deep/ .el-date-editor.el-input__inner {
  3932. width: 100%;
  3933. }
  3934. /deep/ .el-date-editor .el-input__inner {
  3935. height: 28px;
  3936. line-height: 28px;
  3937. padding-left: 10px;
  3938. padding-right: 10px;
  3939. font-size: 12px;
  3940. }
  3941. /deep/ .el-date-editor .el-input__prefix {
  3942. display: none;
  3943. }
  3944. /deep/ .el-date-editor .el-input__suffix {
  3945. right: 5px;
  3946. }
  3947. }
  3948. .choose-label {
  3949. color: #2ec7c9;
  3950. cursor: pointer;
  3951. font-weight: 500;
  3952. }
  3953. .choose-label:hover {
  3954. text-decoration: underline;
  3955. }
  3956. .po-supplier-search-form {
  3957. margin-bottom: 8px;
  3958. }
  3959. .order-supplier-search-form {
  3960. margin-bottom: 8px;
  3961. }
  3962. .add-po-search-form {
  3963. margin-bottom: 8px;
  3964. }
  3965. /* 新增PO明细弹窗表格单元格高度调整 */
  3966. /deep/ .el-dialog__body .el-table--small .el-table__row td {
  3967. padding: 8px 0;
  3968. }
  3969. /deep/ .el-dialog__body .el-table--small .cell {
  3970. line-height: 24px;
  3971. min-height: 36px;
  3972. }
  3973. /deep/ .el-dialog__body .el-table--small .el-input-number,
  3974. /deep/ .el-dialog__body .el-table--small .el-select,
  3975. /deep/ .el-dialog__body .el-table--small .el-date-editor {
  3976. height: 28px;
  3977. }
  3978. </style>