EasyUI verification extension and easyui Verification

Source: Internet
Author: User

EasyUI verification extension and easyui Verification

Problem description:

As shown above: when a user adds information, a team must have only one data record per day. Therefore, when you select a report date, you must check whether the data of the current team in the database exists on this day. If no data exists, that is, the current date team does not have data, you can add the data; otherwise, you cannot add the data.

As shown above, the front-end page is a table. The data-option attribute has its own verification: validType: 'reportdate '. This verification is written in js on the interface.

// Verify extended daily report verification (each team has only one daily report per day) $. extend ($. fn. validatebox. defaults. rules, {reportDate: {validator: function (value, param) {var response = $. ajax ({url: '/dh/rpt/fa/day/team/getdayteam', data: {reportDate: value}, async: false, type: 'get '}). responseText; var obj = JSON. parse (response); if (obj. length = 0) {return true;} else {return false ;}}, message: 'daily report of this date already exists '}});

In this js, we mainly want to get the date we entered and upload it to the map of the controller in the background. Query in the background and return the number of queried data records.

/*** Verification (each team can have only one daily report every day) * @ param user * @ return queryAll */@ RequestMapping (value = "/getDayTeam", method = {RequestMethod. GET}) @ ResponseBodypublic List <Map <String, Object> getDayTeam (@ RequestParam Map <String, Object> map, User user) {map. put ("orgCode", user. getOrg (). getOrgCode (); List <Map <String, Object> queryAll = queryService. queryAll ("DhRptFaDayTeamMapper", "selectDayTeamByDateAndOrgCode", map); return queryAll ;}

In the controller of the background, query queryAll by obtaining the date passed by the foreground.

<! -- Verify that each team can have only one daily report-team --> <select id = "selectDayTeamByDateAndOrgCode" parameterType = "hashmap" resultType = "hashmap"> <! [CDATA [select * from dh_rpt_fa_day_team dt where dt. bsflag = '0' and to_char (dt. report_date, 'yyyy-mm-dd') =#{ reportDate} and dt.org _ code =#{ orgCode}]> </select>

The number of data entries queried by the database.

As shown in the preceding figure, a data record of the 2-02-02 Date exists in the left-side database. When this date is selected for adding data to the right-side, the text box prompts that the daily report of this date already exists and cannot be reported.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.