After a year of slumping sales and thousands of layoffs, Wang Laboratories Inc. yesterday announced the biggest contract in the computer company's history -- a State Department job that could be worth as much as $841.3 million.

The Lowell, Mass.-based company, which lost $715.9 million in the fiscal year ended June 30, portrayed the contract to supply computer systems and services as an indication that its turnaround bid is succeeding. "In our view, this significant contract is another example of the customer confidence in Wang and its technology on which we have been focusing the entire company's efforts for the past year," said Richard W. Miller, Wang's chairman and chief executive.

Wang's class B stock closed at $4.50, up $1.12 1/2, on volume of 783,600 shares. Its class C stock closed at $7, up 87 1/2 cents, on volume of 1,600 shares.

However, competition for the contract -- the largest State Department computer deal ever awarded -- was not intense, said Walter Cate, a State Department contracting officer. Cate said Wang's proposal was "the only viable proposal" that his department received, and that the new contract replaces another State Department computer contract that Wang won in 1979.

Although a wide range of computer companies expressed interest when the department first advertised for a supplier several years ago, many expected bidders did not come to the table, Cate said.

Many companies are growing increasingly wary of bidding for big computer equipment contracts. Although they can mean huge amounts of revenue, the competition is costly and bidders who lose can be out millions of dollars in proposal costs.

Analysts also theorized that the State Department contract was more attractive to Wang than other companies because Wang is a leading supplier of "Tempest" standard computer products, which are specially designed to handle classified data. The State Department needs a substantial amount of such computers.

The State Department contract also is a type known in government contracting circles as an "indefinite delivery, indefinite quantity" contract. That means that Wang is not guaranteed any level of sales. Instead, the department and four smaller foreign-affairs agencies are allowed to buy as much as $841.3 million worth of computers from Wang over five years. The contract can be extended up to 11 years, but that does not raise its dollar value.

Because the federal government can buy far less than the maximum amount called for in such contracts, many computer companies don't like the contracts. "Occasionally these contracts do not pan out," said Robert Dornan, vice president of Federal Sources Inc., a market research firm in Vienna.

But because the State Department has waited about four years for this particular contract, Dornan said, "there is probably a huge pent-up demand for computer systems."