ADFGX Cipher Encryption

Pyth, 36 34 33 32 31 bytes

JwseMhDC,J.Tcsm@^"ADFGX"2xzdwlJ
Jw                                assign (z, J) to 2 lines of input
              m             w     map over each char of a 3rd input line...
                ^"ADFGX"2         generate ['AA', 'AD', 'AF', ...]
                         xzd      find the index of this char in z
               @                  index into ^^ with ^
             s                    join groups of 2 ch. into one string
            c                lJ   split ^ into groups of len(J) chars
          .T                      transpose
       C,J                        pair elems up with chars of J
     hD                           sort by chars of J (the key)
   eM                             get rid of the chars of J now
  s                               join

Thanks to Thomas Kwa for a byte!

Sample run, using the example from Wikipedia:

llama@llama:~$ pyth -c 'JwjdeMhDC,J.Tcsm@^"ADFGX"2xzdwlJ'
BTALPDHOZKQFVSNGJCUXMREWY
CARGO
ATTACKATONCE
FAXDF ADDDG DGFFF AFAX AFAFX

Pyth, 26 bytes

seMhDC,Q.TcsXwz^"ADFGX"2lQ

For this, the second line (columnar key) needs to be in quotes, which is acceptable by default.

Try it here.