Let $D$ be a subset in $\Bbb{R}^n$ and $f:D\to\Bbb{C}$. Prove that$|\int_{D}f(x)dx|\leq\int_{D}|f(x)|dx$.
If I can compare $\pm f$ with $|f|$, then the proof may be easy. But $f$ is a complex-valued function. Or I have to prove this by triangle inequality? I have no idea how to do this.

You can generalize that "compare $\pm f$ to $|f|$" thing to complex-valued functions: If $z\in\Bbb C$ then $z=re^{it}$ as usual; so there exists $\alpha$ with $|\alpha|=1$ and $\alpha z\ge0$.
Choose $\alpha$ with $|\alpha|=1$ and $\alpha \int f\ge0$; note that $\left|\int f\right|=\alpha\int f$. Let $$g=\Re(\alpha f).$$Then $g\le|f|$, so $$\left|\int f\right|=\int g\le\int|f|.$$