I have changed my plans and I will probably not work in China, but I still have a Z visa and I would like to go there for a week as a tourist. But the duration of stay in the visa says 000 days which means I am required to get the residence permit within 30 days after entry. What if I fail to get the residence permit and want to leave China within 30 days?
Entering China with your Z visa will void it, and gives you 30 days to complete the residence procedure (medical checkup, etc).
It happens that some people fail to do so, whether because they're missing documents, have an issue with existing documents, etc. They then have to leave China, and apply again for a Z visa. There's no prejudice attached to leaving. It's generally classified under "shit happens".
However note that this depends a whole lot on where. While the law is pretty uniform in China, its application is very relative from region to region. Things that work ok in Guangdong may not be in Shanghai.
Once you entered into China, Immigration will void (just a strike with pen on the z-visa). When you get your residence house/hotel, you need to submit a residence form in nearest police station. They will give you a form that needs to be submitted to the Foreign affairs office along with your passport. After 14 days or so, you will get your passport and residence permit. Once you get it you can do whatever you want.
I am afraid, you cannot leave China as your passport will be with Foreign affairs. And you cannot even go out of province for those days.
Note: All documents handling will be done by your employer. It's not good on your part if they learn your intention. I advise just go on a visa after your Z visa has expired.