Optically Controlled Valley Filter and Transistor Based on Transition-Metal Dichalcogenide Planar Heterojunctions