How to use checkRecords method in wpt

Best JavaScript code snippet using wpt

Applicationfeedbacksent.js

Source:Applicationfeedbacksent.js Github

copy

Full Screen

1import React, { Component } from 'react';2import { Link , Redirect } from 'react-router-dom';3import { Label, Button, Card, CardBody, CardHeader, FormGroup,ListGroup,ListGroupItem, CardGroup,Modal,ModalBody,ModalFooter, Col, Container, Form, Input, InputGroup, InputGroupAddon, InputGroupText, Row } from 'reactstrap';4import axios from 'axios';5import { Scrollbars } from 'react-custom-scrollbars';6import { ToastContainer, toast } from 'react-toastify';7import 'react-toastify/dist/ReactToastify.css';8import config from '../../config.json';9import backarrow from '../../assets/img/university/back_arrow.svg';10import Offerletter from '../../assets/img/offer-letter.jpg';11import deakinlogo from '../../assets/img/university/deakin_logo.jpg';12import downloadicon from '../../assets/img/university/download.png';13// Files required for multidownload14import JSZip from 'jszip';15import JSZipUtils from "jszip-utils";16import saveAs from 'save-as';17import './style.css';18import $ from "jquery";19import { element } from 'prop-types';20var baseurl = `${config.baseurl}`;21//API Base Url22//Download multiple file funcitonality23global.jQuery = require('jquery')24require('jquery-multidownload')25//for subsection store 26function submitForm1(contentType, data, setResponse, path) {27 axios({28 url: baseurl+`/insertdocument`,29 method: 'POST',30 data: data,31 headers: {32 'Content-Type': contentType33 }34 }).then((response) => {35 setResponse(response.data);36 }).catch((error) => {37 setResponse("error");38 })39}40// Multiple file download functionality41function multipleFileDownloadZip(files){ 42 var zip = new JSZip();43 var count = 0;44 var zipFilename = "Application feedbac doc.zip";45 files.forEach(function({link, name}){46 var filename = "filename.jpeg";47 // loading a file and add it in a zip file48 JSZipUtils.getBinaryContent(link, function (err, data) {49 if(err) {50 throw err; // or handle the error51 }52 zip.file(name, data, {binary:true});53 count++;54 if (count == files.length) {55 zip.generateAsync({type:'blob'}).then(function(content) {56 saveAs(content, zipFilename);57 });58 }59 });60 });61} 62class Applicationfeedbacksent extends Component {63 constructor(props) {64 super(props);65 this.validate = this.validate.bind(this);66 this.onSubmit1 = this.onSubmit1.bind(this);67 this.state = {68 university_id: '',69 docdetails:[],70 checkrecords: [],71 totalrecords:'',72 fileLength:'',73 disabled:localStorage.getItem("fromApplicationType")==="Sent"?true:false,74 opt:'',75 universitydetails:[],76 coursedetails:[],77 docname: [],78 docid: [],79 optionid: [],80 formData: new FormData()81 };82 //alert(localStorage.getItem('studentid'));83 84 85 var param = localStorage.getItem('applicationid');86 87 axios.get(baseurl+'/getapppersonal/'+localStorage.getItem('applicationid')).then(response => 88 {89 console.log(response);90 this.setState({91 universitydetails: response.data.universitydetails,92 coursedetails: response.data.coursedetails,93 });94 })95 96 axios.get(baseurl+'/get_requireddoc/'+param).then(response => { 97 //alert(response.data.length);98 console.log("req-doc", response);99 let doc_items = response.data.docdetails.filter(obj => obj.optionid == 3 || obj.optionid == 2);100 let checkrecords_items = [];101 if (response.data.checkrecords.length > 0){102 response.data.checkrecords.filter(e => e !== null).forEach(elem => {103 console.log('check-item', elem);104 let doc_item = doc_items.filter(d => elem.docid === d.id);105 elem["optionid"] = doc_item[0].optionid;106 checkrecords_items.push(elem);107 });108 this.setState({checkrecords: checkrecords_items.sort((a,b)=> b.optionid-a.optionid),});109 console.log("check-records", checkrecords_items);110 }111 if((response.data.totalrecords > '0')) {112 113 this.setState({114 docdetails: doc_items,115 totalrecords: doc_items.length - checkrecords_items.length,116 });117 console.log(typeof this.state.checkrecords, this.state.checkrecords);118 }else{119 this.setState({ totalrecords: 0, });120 }121 })122 }123 124validate() {125 const errors = {};126 var minmax = /^.{0,15}$/127 128 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/129 const email = this.state.emailst;130 if(this.state.name_st === ''){131 errors.name_st = 'Name is required';132 }else if(this.state.lastname_st === ''){133 errors.lastname_st = 'Last Name is required';134 }else if(this.state.emailst === ''){135 errors.emailst = 'Email is required';136 }else if(!email.match(re)) {137 errors.emailst = 'Invalid email';138 }else if(this.state.account_type_st === '') {139 errors.account_type_st = 'Select campus';140 }else{141 this.onSubmit(); 142 } 143 144 145 this.setState({ errors });146};147backbtn() {148 window.location.href= "/#/sendapplicationinprocess";149}150onFileChange1 = param => event => {151 //hide missing icon after adding file152 if (event.target.files.length > 0) {153 $(event.target).parent().parent().children("td")[2].innerHTML = "";154 }155 this.setState({fileLength: event.target.files.length});156 if(event.target.files.length < 3 ){157 for(let i = 0; i < event.target.files.length; i++) {158 this.state.formData.append('upload_photo[]', event.target.files[i], event.target.files[i].name);159 this.state.formData.append("docid[]", param);160 }161 }162 }163 164 165 onSubmit1 = e => {166 // e.preventDefault()167 168 //console.log(this.state.formData);169 this.state.formData.append("studentid", localStorage.getItem('studentid'));170 this.state.formData.append("applicationid", localStorage.getItem('applicationid'));171 172 submitForm1("multipart/form-data", this.state.formData, (msg) => { toast.success(msg.message); setTimeout(function () { 173 window.location.reload(true); 174 }, 5000); }, 'savedocument');175 176 }177 multiFilesDownload = e => {178 e.preventDefault();179 const filesInfo = [];180 this.state.checkrecords.map(({filename, orgfilename}) => {181 // let link = URL.createObjectURL(new Blob([baseurl + filename], {type: 'text/plain'}));182 let fileName = orgfilename;183 let fileLink = filename;184 let fileDetail = {185 link: fileLink,186 name: fileName,187 }188 filesInfo.push(fileDetail);189 });190 console.log("download btn is clicked", filesInfo);191 multipleFileDownloadZip(filesInfo) 192 }193 render() {194 const imgpath = `${config.baseurl}`;195 const { errors } = this.state;196 const { showhide } = this.state;197 return (198 <div className="foe-studen-container app-feedback-page pt-5">199 <div className="foe-student-box pt-5">200 <ToastContainer/>201 <Container>202 <Row>203 <Col xs="12" sm="12" xl="8" md="8" lg="8" className="mx-auto" >204 <div className="row mb-3">205 <div className="col-md-2 col-lg-2">206 <div className="mb-4"> <a onClick={this.backbtn} className="col-12 backarrow mt-3" style={{cursor:"pointer"}} ><span className="pr-1"> <img src={backarrow} alt="" /></span> Back </a></div>207 </div>208 <div className="col-md-9 col-lg-9">209 <h3 className="app-title">View Response</h3>210 </div>211 </div>212 <Card className="uni-right-card app-inprogress">213 <div className="offer-header p-3">214 <Row>215 <div className="col-md-3">216 <img src={imgpath+this.state.universitydetails.logo_image} alt="" width="50px" />217 </div>218 <div className="col-md-9">219 {this.state.coursedetails.heading}220 </div>221 </Row>222 <Row className="mt-2">223 <div className="col-md-8">224 <p><b>Please attach files to complete your application</b></p>225 <span>* {this.state.totalrecords} requirements to be completed</span>226 </div>227 <div className=" text-right col-md-4 app-download" onClick = {this.multiFilesDownload}>228 <span>Download All</span> <img src={downloadicon} alt="" width="14" />229 </div>230 </Row>231 <Row>232 <div class="card-body table-responsive univ-new-table">233 {this.state.docdetails.length > 0 ?234 <table class="draft-table table table-responsive-sm display nowrap dataTable dtr-inline collapsed">235 236 {this.state.docdetails.sort((a,b)=> b.optionid-a.optionid).map((docdetails, index) => (237 <tr>238 {239 docdetails.optionid == "3" ? (240 <td className="req-feild">Required</td> 241 ): <td className="req-feild greyfield">Optional</td>242 }243 244 <td className="des-detail"><div><b>{docdetails.doc_name}</b></div>245 246 </td>247 {248 docdetails.optionid == "3" ? 249 (this.state.checkrecords[index] == "" || this.state.checkrecords[index] == undefined ? <td className="i-style"><span>i</span><div className="pt-1">Missing</div></td> : <td></td>) : <td></td>250 }251 252 {/*<td className="add-filebtn"><button class="btn btn-outline-primary">+ Add file</button></td>*/}253 <td className="add-filebtn">254 {255 this.state.checkrecords[index] !== undefined && this.state.checkrecords[index].orgfilename !== "" ? <span>256 <a257 href={258 baseurl +259 this.state.checkrecords[index].filename260 }261 target="_blank"262 download263 >264 {this.state.checkrecords[index].orgfilename}265 </a>266 </span>267 : 268 <Input type="file" id="about_upload_photo" name="upload_photo[]" accept="image/*" multiple onChange={this.onFileChange1(docdetails.id)} ref={ref=> this.fileInput = ref}/>269 }270 271 272 </td>273 </tr>274 275 276 277 ) ) }278 </table>279 : null}280 281 {/* Download links for attachments */}282 <div id="download-links" className="d-none"></div>283 </div>284 </Row>285 {286 this.state.totalrecords !== 0 ? <Button color="success" onClick={this.onSubmit1.bind(this)} className="px-4 save-btn">Save</Button> : null287 } 288 289 </div>290 291 292 </Card>293 </Col>294 </Row>295 </Container> 296 </div> 297 </div>298 );299 }300}...

Full Screen

Full Screen

check-record-detail.js

Source:check-record-detail.js Github

copy

Full Screen

1import React, { useRef, useEffect, useState } from 'react';2import ProForm, { ProFormText, ProFormDependency } from '@ant-design/pro-form';3import { Form, Row, Col } from 'antd';4import moment from 'moment';5import { connect } from 'react-redux';6import { LayoutContent } from '@peace/components';7import { Func } from '$utils';8import { getCheckRecords } from '../actions/record';9const FormItem = Form.Item;10function RecordDetail(props) {11 const {12 checkrecords, match, dispatch,13 actions, myStructList, authorData, user,14 } = props;15 const formRef = useRef();16 const [visible, setVisible] = useState({});17 useEffect(() => {18 dispatch(getCheckRecords());19 dispatch(actions.damCheck.getAuthorList(user?.orgId));20 dispatch(actions.damCheck.getMyStructList(user?.orgId)).then((res) => {21 if (res.success) {22 if (res.payload.data.length > 0) {23 dispatch(actions.damCheck.getStructUsers(res?.payload?.data[0]?.id));24 }25 }26 });27 }, []);28 useEffect(() => () => {29 formRef.current?.resetFields();30 });31 let initialValues = {};32 const id = match?.params?.id;33 let form1 = []; let form2 = []; const34 form3 = [];35 if (id && checkrecords?.length > 0) {36 // 查询所属结构物名称和巡检人名称37 checkrecords.map((s, index) => {38 s.index = index + 1;39 s.name = myStructList.find((x) => x.id == parseInt(s?.DamCheckPlan.structId))?.name; // 查询结构物名称40 authorData.forEach((x) => {41 if (x.members.find((v) => v.id == parseInt(s?.DamCheckPlan.userId))) {42 s.departmentName = x.members.find((v) => v.id == parseInt(s?.DamCheckPlan.userId))?.departmentName;// 查询部门名称43 s.user = x.members.find((v) => v.id == parseInt(s?.DamCheckPlan.userId))?.name; // 查询巡检人名称44 }45 });46 return s;47 });48 const detail = checkrecords.find((s) => s.id == parseInt(id));49 const index = checkrecords.findIndex((s) => s.id == parseInt(id));50 initialValues = {51 ...detail,52 ...detail?.DamCheckPlan,53 start: moment(detail?.DamCheckPlan?.start).format('YYYY-MM-DD HH:mm:ss dddd'),54 end: moment(detail?.DamCheckPlan?.end).format('YYYY-MM-DD HH:mm:ss dddd'),55 time: moment(detail?.time).format('YYYY-MM-DD HH:mm:ss dddd'),56 lastTime: index > 0 && checkrecords[index - 1] ? moment(checkrecords[index - 1].time).format('YYYY-MM-DD HH:mm:ss dddd') : '-',57 };58 form1 = [59 [{ name: 'name', text: '结构物名称' }],60 [{ name: 'start', text: '开始时间' }, { name: 'end', text: '结束时间' }],61 [{ name: 'way', text: '巡检方式' }, { name: 'frequency', text: '巡检频次' }],62 [{ name: 'user', text: '巡检人' }, { name: 'departmentName', text: '巡检单位' }],63 ];64 form2 = [65 [{ name: 'lastTime', text: '上次巡检日期' }, { name: 'time', text: '本次巡检日期' }],66 ];67 Object.keys(detail?.extra).forEach((key) => {68 form3.push({69 name: key,70 ...detail?.extra[key],71 });72 initialValues[`${key}desc`] = detail?.extra[key]?.desc;73 initialValues[key] = detail?.extra[key]?.state;74 });75 }76 return (77 <div perfectScroll={false} style={{ margin: 15, padding: 15, background: '#fff' }}>78 <ProForm79 title=""80 initialValues={initialValues}81 formRef={formRef}82 layout="horizontal"83 // // grid={true}84 // labelCol={{ span: 6 }}85 // wrapperCol={{ span: 14 }}86 submitter={{ render: () => '' }}87 >88 <div className="record-detail-title">巡检要求</div>89 {90 form1.map((s, index) => (91 <ProForm.Group key={`form1${index}`}>92 {93 s.map((x) => (94 <ProFormText95 width="lg"96 key={x.name}97 name={x.name}98 label={x.text}99 disabled100 colProps={{101 span: 12,102 }}103 />104 ))105 }106 </ProForm.Group>107 ))108 }109 <div className="record-detail-title">巡检结果</div>110 {111 form2.map((s, index) => (112 <ProForm.Group key={`form2${index}`}>113 {114 s.map((x) => (115 <ProFormText116 width="lg"117 key={x.name}118 name={x.name}119 label={x.text}120 disabled121 colProps={{122 span: 12,123 }}124 />125 ))126 }127 </ProForm.Group>128 ))129 }130 {131 form3.map((s, index) => (132 <div key={`form3-group${index}`}>133 <ProForm.Group>134 <ProFormText135 width="lg"136 key={s.name}137 name={s.name}138 addonAfter={s.images || s.desc ? (139 <a onClick={() => {140 const visibleToSave = { ...visible };141 visibleToSave[s.name] = !visible[s.name];142 setVisible(visibleToSave);143 }}144 >145 {visible[s.name] ? '收起详情' : '展开详情'}146 </a>147 ) : null}148 label={s.name}149 disabled150 colProps={{151 span: 12,152 }}153 />154 </ProForm.Group>155 <ProFormDependency key={`form3-ProFormDependency${index}`} name={[s.name]}>156 {({ item1 }) => {157 if (visible[s.name]) {158 return (159 <>160 <ProFormText161 width="lg"162 name={`${s.name}desc`}163 key={`${s.name}desc`}164 disabled165 label="问题描述"166 />167 <FormItem168 label="现场图片"169 >170 <Row style={{ width: '70%' }}>171 {172 s.images && s.images.map((v) => {173 const src = Func.downloadFile(v);174 return (175 <Col span={8}>176 {' '}177 <img style={{ height: 150, marginTop: 15 }} src={src} />178 {' '}179 </Col>180 );181 })182 }183 </Row>184 </FormItem>185 </>186 );187 }188 }}189 </ProFormDependency>190 </div>191 ))192 }193 </ProForm>194 </div>195 );196}197function mapStateToProps(state) {198 const {199 checkrecords, myDamStructList, global, damAuthorData, auth,200 } = state;201 return {202 loading: checkrecords.isRequesting,203 checkrecords: checkrecords?.data || [],204 myStructList: myDamStructList?.data || [],205 authorData: damAuthorData?.data || [],206 actions: global.actions,207 user: auth.user,208 };209}...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1// pages/record/index.js2import * as logger from '../../utils/log';3import Toast from '@vant/weapp/toast/toast';4import BizError from '../../utils/bizError';5import functionTemplate from '../../utils/functionTemplate';6const app = getApp();7Page({8 data: {9 userOptions:[],10 userOptionValue: -1,11 statusOptions: [12 { text: "全部状态", value: -1 },13 ],14 statusOptionValue: -1,15 checkRecords: [],16 isRefreshing: false17 },18 onLoad(options) {19 app.watchUserLogin((user) => {20 Toast.clear();21 this.loadData();22 this.initDropDown();23 });24 25 if (app.globalData.hasUser) {26 this.loadData();27 this.initDropDown();28 } else {// user not login29 Toast.loading({ message: '正在加载', forbidClick: true, });30 }31 },32 onShow() {33 this.getTabBar().onPageShow();34 },35 onShareAppMessage() {36 return {37 title: '出入记录'38 }39 },40 onScrollRefresh() {41 this.loadData()42 },43 initDropDown() {44 const defaultUserOption = [{ text: '全部住户', value: -1 }];45 const user = app.globalData.loginUser;46 functionTemplate.send({47 request: {48 service: 'userService',49 method: 'findByCertificate',50 args: user?.certificate?._id,51 },52 action: async (result) => {53 const users = result.data;54 const userOptions = users.map(u => {55 return { text: u.name, value: u._id, disabled: true };56 });57 this.setData({58 userOptions: [...defaultUserOption, ...userOptions],59 });60 },61 });62 },63 onUserChange() {64 Toast('暂不支持按住户进行筛选,仅供展示');65 this.setData({66 userOptionValue: -1,67 });68 },69 loadData() {70 const certId = app.globalData.loginUser?.certificate?._id;71 if (!certId) {72 return;73 }74 functionTemplate.send({75 message: '正在加载...',76 errorMessage: '加载失败,请联系管理员',77 request: {78 service: 'checkRecordService',79 method: 'findByCertificate',80 args: certId81 },82 action: async (result) => {83 const data = result.data;84 const certificate = data.certificate;85 const checkRecords = data.checkRecords;86 app.globalData.loginUser.certificate = certificate;87 this.getTabBar().refreshOutingCount(certificate);88 this.processCheckRecord(checkRecords);89 this.setData({90 checkRecords: checkRecords,91 isRefreshing: false92 });93 },94 });95 },96 processCheckRecord(records) {97 records.forEach(record => {98 const outDateTime = record.out?.checked_at;99 if (outDateTime) {100 record.out.checked_at = new Date(outDateTime).toLocaleString('zh-CN');101 }102 const inDateTime = record.in?.checked_at;103 if (inDateTime) {104 record.in.checked_at = new Date(inDateTime).toLocaleString('zh-CN');105 }106 });107 return records;108 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.checkRecords('test', function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var fs = require('fs');3var wpt = new wpt();4wpt.checkRecords(url, function(data){5 fs.writeFile('test.json', JSON.stringify(data, null, 4), function(err){6 console.log('File successfully written! - Check your project directory for the test.json file');7 })8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var args = process.argv.slice(2);3var url = args[0];4var key = args[1];5var runs = args[2];6var wait = args[3];7var timeout = args[4];8wpt.checkRecords(url, key, runs, wait, timeout);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful