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.