How to use jQuery.isEmptyObject method in Cypress

Best JavaScript code snippet using cypress

InvContractChild.js

Source:InvContractChild.js Github

copy

Full Screen

1import $ from '../../common/AjaxRequest';2import jquery from 'jquery';3import React from 'react';4import { message, Table, Popconfirm, Modal, Button, Input } from 'antd';5import moment from 'moment';6import API_URL from '../../common/url';7import AjaxRequest from '../../common/AjaxRequest';8import ContractSider from './ContractSider';9import ChildJde from './ChildJde';10import InvContractChildRelated from './InvContractChildRelated';11const initState = {12 sortParams: {},13 searchParams: {},14 data: [],15 loading: false,16 jdeData: {},17 addStatus: false,18 pagination:{19 pageSize: 15,20 current: 1,21 },22 dateFormat: "YYYY-MM-DD",23 jdeCode: '',24 mainJdeCode: '',25 showJde: true,26 relateCode: '',27 investigationJdeContractId: '',28 investigationJdeContractCode: ''29}30class InvContract extends React.Component {31 state= initState;32 getMainJde = (params = {}) =>{33 const options = {34 url: `${API_URL.investigation.queryInvJde}`,35 data: {36 ...params37 },38 dataType: 'json',39 doneResult: ( data => {40 if(data.data.jdeCode){41 this.setState({42 addStatus: true,43 mainJdeCode: data.data.jdeCode44 });45 }46 }),47 errorResult: ( data => {48 }),49 };50 AjaxRequest.sendRequest(options);51 }52 loadData = (params = {}) =>{53 this.setState({54 loading: true,55 });56 const {searchParams, pagination} = this.state;57 const options = {58 url: `${API_URL.investigation.listChildrenJde}`,59 data: {60 offset: pagination.current,61 ...params,62 ...searchParams,63 limit: pagination.pageSize - 1,64 },65 dataType: 'json',66 doneResult: ( data => {67 const pagination = { ...this.state.pagination };68 let ct = Number((data.totalCount / (pagination.pageSize -1)).toFixed(0)) + (data.totalCount % (pagination.pageSize -1) > 0 ? 1 : 0);69 pagination.total = data.totalCount + ct;70 this.setState({71 loading: false,72 data: data.datas,73 pagination,74 });75 }),76 errorResult: ( data => {77 this.setState({78 loading: false,79 });80 }),81 };82 AjaxRequest.sendRequest(options);83 }84 componentDidMount(){85 this.getMainJde();86 this.loadData();87 }88 getColumns = () => [{89 title: '序号',90 dataIndex: 'index',91 key: 'index',92 }, {93 title: 'JDE项目号',94 dataIndex: 'investigationJdeContractCode',95 key: 'jdeCode',96 sorter: true,97 }, {98 title: '合同额(元)',99 dataIndex: 'jdeContractAmount',100 key: 'jdeContractAmount',101 sorter: true,102 render:(text,record) => {103 return (record.jdeContractAmount.toLocaleString())104 }105 }, {106 title: '合同开始时间',107 dataIndex: 'startTime',108 key: 'startTime',109 sorter: true,110 }, {111 title: '合同结束时间',112 dataIndex: 'endTime',113 key: 'endTime',114 sorter: true,115 }, {116 title: '合同是否签署完成',117 dataIndex: 'investigationJdeContractIsSigned',118 key: 'investigationJdeContractIsSigned',119 sorter: true,120 render:(text,record) => {121 return (record.investigationJdeContractId > 0 ? record.investigationJdeContractIsSigned == "0" ? "否" : "是" : null)122 }123 }, {124 title: '操作',125 render: (text, record) => {126 const _reocrd = {...record};127 return (128 record.investigationJdeContractId > 0 ?129 <span>130 <a onClick={() => this.showRelate(_reocrd)}>中心关联</a>131 <span className="ant-divider" />132 <a onClick={() => this.editJde("edit",_reocrd)}>修改</a>133 <span className="ant-divider" />134 <Popconfirm title={'确定要删除吗?'} onConfirm={this.del.bind(this, record.investigationJdeContractId)} okText="确定" cancelText="取消">135 <a >删除</a>136 </Popconfirm>137 </span>138 :139 null140 );141 },142 }]143 getDataSource = () => {144 const dataResult = [];145 const {data, pagination, dateFormat} = this.state;146 data.map((dataItem, i) => {147 if(dataItem.investigationJdeContractId < 0){148 dataResult.push({149 index: "合计",150 jdeContractAmount: dataItem.jdeContractAmount,151 });152 }else{153 dataResult.push({154 index: i + 1,155 ...dataItem,156 startTime: moment(dataItem.startTime).format(dateFormat),157 endTime: moment(dataItem.endTime).format(dateFormat),158 });159 }160 161 });162 return dataResult;163 };164 handleChange = (e) => {165 const value = e.target.value;166 this.setState({ "jdeCode" : value });167 }168 169 handleTableChange = (pagination, filters, sorter) => {170 let sortType,171 direction,172 sort = sort = sorter.field;173 const pager = { ...this.state.pagination };174 if (pager.current == pagination.current){175 pager.current = 1;176 //排序则页码为1177 } else {178 pager.current = pagination.current;179 //获取当前页180 }181 if (!jquery.isEmptyObject(sorter) && sorter.column) {182 sortType = sorter.column.sortType;183 }184 if (sorter.order === 'descend') {185 direction = 'DESC';186 } else {187 direction = 'ASC';188 }189 this.setState({190 pagination: pager,//设置新的分页信息191 sortParams: {//设置排序信息192 direction,193 sort,194 sortType195 }196 });197 198 this.loadData({199 limit: pager.pageSize,200 offset: pager.current,201 direction,202 sort,203 sortType,204 ...this.state.searchParams,205 ...filters,206 });207 }208 209 reset = () =>{210 const pagination = { ...this.state.pagination, current: 1 };211 this.setState({212 pagination,213 searchParams: {}214 },function(){215 this.loadData();216 });217 }218 reload = (params = {}, type) => {219 const newParams = {};220 if(type == "search"){221 newParams.searchParams = params;222 newParams.pagination = { ...this.state.pagination, current: 1 };223 }224 this.setState({225 ...newParams226 },function(){227 const { pagination,searchParams,sortParams } = this.state;228 this.loadData({229 offset: pagination.current,230 ...sortParams,231 ...searchParams,232 });233 }) 234 }235 236 search = () => {237 const {searchParams, jdeCode} = this.state;238 const newSearch = {239 ...searchParams,240 jdeCode241 };242 this.setState({243 searchParams: newSearch244 },function(){245 this.reload(newSearch,"search");246 });247 }248 addJde = () => {249 this.ChildJde.show("add");250 }251 editJde = (type,record) => {252 this.ChildJde.show(type,record);253 }254 del = (jdeCodeId) => {255 this.setState({256 loading: true257 })258 const options = {259 url: `${API_URL.investigation.deleteChildrenJde}`,260 data: {261 jdeCodeId262 },263 dataType: 'json',264 doneResult: ( data => {265 this.setState({266 loading: false267 })268 message.success("删除成功");269 this.reload();270 }),271 errorResult: d => {272 this.setState({273 loading: false274 })275 }276 };277 AjaxRequest.sendRequest(options);278 };279 showRelate = (record = {}) => {280 const {investigationJdeContractId, investigationJdeContractCode} = record;281 console.log(record)282 this.setState({283 showJde: false,284 investigationJdeContractId,285 investigationJdeContractCode: investigationJdeContractCode286 })287 }288 returnRelate = () => {289 this.setState({290 showJde: true291 })292 }293 render() {294 const {loading, pagination, jdeData, data, addStatus, mainJdeCode, showJde, investigationJdeContractId, investigationJdeContractCode} = this.state;295 return (296 <div className="content">297 <ContractSider/>298 <div className="main" style={{minHeight:"400px",display: showJde ? "block" : "none"}}>299 <div className="filter-bar bar2">300 <div className="form-item">301 <label htmlFor="" className="ui-label">JDE项目号</label>302 <Input303 onChange={this.handleChange}304 onKeyPress={this.enterSearch}305 />306 </div>307 <div className="btn" style={{float: 'right'}}>308 309 310 <Button type="primary" onClick={this.addJde} disabled={!addStatus}>添加JDE项目号</Button>311 <Button type="primary" onClick={this.search}>搜索</Button>312 </div>313 </div>314 <Table315 columns={this.getColumns()}316 dataSource={this.getDataSource()}317 rowKey={record => record.investigationSiteCode}318 loading={loading}319 pagination={pagination}320 onChange={this.handleTableChange}321 />322 </div>323 324 <div className="main" style={{minHeight:"400px",display: !showJde ? "block" : "none"}}>325 <InvContractChildRelated 326 returnRelate={this.returnRelate}327 jdeCodeId={investigationJdeContractId}328 investigationJdeContractCode={investigationJdeContractCode}329 />330 {/* <div style={{textAlign:"center"}}>331 中心关联记录(244444444)332 </div>333 <div className="filter-bar bar2">334 <div className="form-item">335 <label htmlFor="" className="ui-label">中心编号\中心名称</label>336 <Input337 onChange={this.handleChangeSite}338 //onKeyPress={this.enterSearch}339 />340 </div>341 <div className="btn" style={{float: 'right'}}>342 343 <Button type="primary" onClick={this.searchSite}>搜索</Button>344 <Button type="primary" onClick={this.addRelate}>添加关联记录</Button>345 <Button type="primary" onClick={this.returnRelate}>返回</Button>346 </div>347 </div> */}348 {/* <Table349 columns={this.getSiteColumns()}350 dataSource={this.getSiteDataSource()}351 rowKey={record => record.investigationSiteCode}352 loading={loading}353 pagination={pagination}354 onChange={this.handleSiteTableChange}355 /> */}356 </div>357 <ChildJde ref={el => { this.ChildJde = el; }}358 reload={this.reload}359 mainJdeCode={mainJdeCode}360 />361 </div>362 );363 }364}...

Full Screen

Full Screen

InvestigationList.js

Source:InvestigationList.js Github

copy

Full Screen

1import $ from '../../common/AjaxRequest';2import jquery from 'jquery';3import React from 'react';4import { message, Table, Popconfirm, Modal, Button, Input } from 'antd';5import moment from 'moment';6import API_URL from '../../common/url';7import AjaxRequest from '../../common/AjaxRequest';8import ContractSider from './ContractSider';9import ChildJde from './ChildJde';10import InvContractChildRelated from './InvContractChildRelated';11const initState = {12 sortParams: {},13 searchParams: {},14 data: [],15 loading: false,16 jdeData: {},17 addStatus: false,18 pagination:{19 pageSize: 15,20 current: 1,21 },22 dateFormat: "YYYY-MM-DD",23 jdeCode: '',24 mainJdeCode: '',25 showJde: true,26 relateCode: '',27 investigationJdeContractId: '',28 investigationJdeContractCode: ''29}30class InvContract extends React.Component {31 state= initState;32 getMainJde = (params = {}) =>{33 const options = {34 url: `${API_URL.investigation.queryInvJde}`,35 data: {36 ...params37 },38 dataType: 'json',39 doneResult: ( data => {40 if(data.data.jdeCode){41 this.setState({42 addStatus: true,43 mainJdeCode: data.data.jdeCode44 });45 }46 }),47 errorResult: ( data => {48 }),49 };50 AjaxRequest.sendRequest(options);51 }52 loadData = (params = {}) =>{53 this.setState({54 loading: true,55 });56 const {searchParams, pagination} = this.state;57 const options = {58 url: `${API_URL.investigation.listChildrenJde}`,59 data: {60 offset: pagination.current,61 ...params,62 ...searchParams,63 limit: pagination.pageSize - 1,64 },65 dataType: 'json',66 doneResult: ( data => {67 const pagination = { ...this.state.pagination };68 let ct = Number((data.totalCount / (pagination.pageSize -1)).toFixed(0)) + (data.totalCount % (pagination.pageSize -1) > 0 ? 1 : 0);69 pagination.total = data.totalCount + ct;70 this.setState({71 loading: false,72 data: data.datas,73 pagination,74 });75 }),76 errorResult: ( data => {77 this.setState({78 loading: false,79 });80 }),81 };82 AjaxRequest.sendRequest(options);83 }84 componentDidMount(){85 this.getMainJde();86 this.loadData();87 }88 getColumns = () => [{89 title: '序号',90 dataIndex: 'index',91 key: 'index',92 }, {93 title: 'JDE项目号',94 dataIndex: 'investigationJdeContractCode',95 key: 'jdeCode',96 sorter: true,97 }, {98 title: '合同额(元)',99 dataIndex: 'jdeContractAmount',100 key: 'jdeContractAmount',101 sorter: true,102 render:(text,record) => {103 return (record.jdeContractAmount.toLocaleString())104 }105 }, {106 title: '合同开始时间',107 dataIndex: 'startTime',108 key: 'startTime',109 sorter: true,110 }, {111 title: '合同结束时间',112 dataIndex: 'endTime',113 key: 'endTime',114 sorter: true,115 }, {116 title: '合同是否签署完成',117 dataIndex: 'investigationJdeContractIsSigned',118 key: 'investigationJdeContractIsSigned',119 sorter: true,120 render:(text,record) => {121 return (record.investigationJdeContractId > 0 ? record.investigationJdeContractIsSigned == "0" ? "否" : "是" : null)122 }123 }, {124 title: '操作',125 render: (text, record) => {126 const _reocrd = {...record};127 return (128 record.investigationJdeContractId > 0 ?129 <span>130 <a onClick={() => this.showRelate(_reocrd)}>中心关联</a>131 <span className="ant-divider" />132 <a onClick={() => this.editJde("edit",_reocrd)}>修改</a>133 <span className="ant-divider" />134 <Popconfirm title={'确定要删除吗?'} onConfirm={this.del.bind(this, record.investigationJdeContractId)} okText="确定" cancelText="取消">135 <a >删除</a>136 </Popconfirm>137 </span>138 :139 null140 );141 },142 }]143 getDataSource = () => {144 const dataResult = [];145 const {data, pagination, dateFormat} = this.state;146 data.map((dataItem, i) => {147 if(dataItem.investigationJdeContractId < 0){148 dataResult.push({149 index: "合计",150 jdeContractAmount: dataItem.jdeContractAmount,151 });152 }else{153 dataResult.push({154 index: i + 1,155 ...dataItem,156 startTime: moment(dataItem.startTime).format(dateFormat),157 endTime: moment(dataItem.endTime).format(dateFormat),158 });159 }160 161 });162 return dataResult;163 };164 handleChange = (e) => {165 const value = e.target.value;166 this.setState({ "jdeCode" : value });167 }168 169 handleTableChange = (pagination, filters, sorter) => {170 let sortType,171 direction,172 sort = sort = sorter.field;173 const pager = { ...this.state.pagination };174 if (pager.current == pagination.current){175 pager.current = 1;176 //排序则页码为1177 } else {178 pager.current = pagination.current;179 //获取当前页180 }181 if (!jquery.isEmptyObject(sorter) && sorter.column) {182 sortType = sorter.column.sortType;183 }184 if (sorter.order === 'descend') {185 direction = 'DESC';186 } else {187 direction = 'ASC';188 }189 this.setState({190 pagination: pager,//设置新的分页信息191 sortParams: {//设置排序信息192 direction,193 sort,194 sortType195 }196 });197 198 this.loadData({199 limit: pager.pageSize,200 offset: pager.current,201 direction,202 sort,203 sortType,204 ...this.state.searchParams,205 ...filters,206 });207 }208 209 reset = () =>{210 const pagination = { ...this.state.pagination, current: 1 };211 this.setState({212 pagination,213 searchParams: {}214 },function(){215 this.loadData();216 });217 }218 reload = (params = {}, type) => {219 const newParams = {};220 if(type == "search"){221 newParams.searchParams = params;222 newParams.pagination = { ...this.state.pagination, current: 1 };223 }224 this.setState({225 ...newParams226 },function(){227 const { pagination,searchParams,sortParams } = this.state;228 this.loadData({229 offset: pagination.current,230 ...sortParams,231 ...searchParams,232 });233 }) 234 }235 236 search = () => {237 const {searchParams, jdeCode} = this.state;238 const newSearch = {239 ...searchParams,240 jdeCode241 };242 this.setState({243 searchParams: newSearch244 },function(){245 this.reload(newSearch,"search");246 });247 }248 addJde = () => {249 this.ChildJde.show("add");250 }251 editJde = (type,record) => {252 this.ChildJde.show(type,record);253 }254 del = (jdeCodeId) => {255 this.setState({256 loading: true257 })258 const options = {259 url: `${API_URL.investigation.deleteChildrenJde}`,260 data: {261 jdeCodeId262 },263 dataType: 'json',264 doneResult: ( data => {265 this.setState({266 loading: false267 })268 message.success("删除成功");269 this.reload();270 }),271 errorResult: d => {272 this.setState({273 loading: false274 })275 }276 };277 AjaxRequest.sendRequest(options);278 };279 showRelate = (record = {}) => {280 const {investigationJdeContractId, investigationJdeContractCode} = record;281 console.log(record)282 this.setState({283 showJde: false,284 investigationJdeContractId,285 investigationJdeContractCode: investigationJdeContractCode286 })287 }288 returnRelate = () => {289 this.setState({290 showJde: true291 })292 }293 render() {294 const {loading, pagination, jdeData, data, addStatus, mainJdeCode, showJde, investigationJdeContractId, investigationJdeContractCode} = this.state;295 return (296 <div className="content">297 <div className="main" style={{minHeight:"400px",display: showJde ? "block" : "none"}}>298 <div className="filter-bar bar2">299 <div className="form-item">300 <label htmlFor="" className="ui-label">JDE项目号</label>301 <Input302 onChange={this.handleChange}303 onKeyPress={this.enterSearch}304 />305 </div>306 <div className="btn" style={{float: 'right'}}>307 308 309 <Button type="primary" onClick={this.addJde} disabled={!addStatus}>添加JDE项目号</Button>310 <Button type="primary" onClick={this.search}>搜索</Button>311 </div>312 </div>313 <Table314 columns={this.getColumns()}315 dataSource={this.getDataSource()}316 rowKey={record => record.investigationSiteCode}317 loading={loading}318 pagination={pagination}319 onChange={this.handleTableChange}320 />321 </div>322 323 <div className="main" style={{minHeight:"400px",display: !showJde ? "block" : "none"}}>324 <InvContractChildRelated 325 returnRelate={this.returnRelate}326 jdeCodeId={investigationJdeContractId}327 investigationJdeContractCode={investigationJdeContractCode}328 />329 {/* <div style={{textAlign:"center"}}>330 中心关联记录(244444444)331 </div>332 <div className="filter-bar bar2">333 <div className="form-item">334 <label htmlFor="" className="ui-label">中心编号\中心名称</label>335 <Input336 onChange={this.handleChangeSite}337 //onKeyPress={this.enterSearch}338 />339 </div>340 <div className="btn" style={{float: 'right'}}>341 342 <Button type="primary" onClick={this.searchSite}>搜索</Button>343 <Button type="primary" onClick={this.addRelate}>添加关联记录</Button>344 <Button type="primary" onClick={this.returnRelate}>返回</Button>345 </div>346 </div> */}347 {/* <Table348 columns={this.getSiteColumns()}349 dataSource={this.getSiteDataSource()}350 rowKey={record => record.investigationSiteCode}351 loading={loading}352 pagination={pagination}353 onChange={this.handleSiteTableChange}354 /> */}355 </div>356 <ChildJde ref={el => { this.ChildJde = el; }}357 reload={this.reload}358 mainJdeCode={mainJdeCode}359 />360 </div>361 );362 }363}...

Full Screen

Full Screen

SiteList.js

Source:SiteList.js Github

copy

Full Screen

1import $ from '../../common/AjaxRequest';2import jquery from 'jquery';3import React from 'react';4import { message, Table, Popconfirm, Modal, Button, Input } from 'antd';5import API_URL from '../../common/url';6import AjaxRequest from '../../common/AjaxRequest';7class SiteList extends React.Component {8 state = {9 data: [],10 pagination: {11 pageSize: 15,12 current: 1,13 },14 loading: false,15 searchSiteCode: '',16 searchSiteName: '',17 dataList: [],18 tableheader:[],19 investigationJdeContractCode: '',20 };21 getheader = () => { //拿表头 22 const {selInvId} = this.props.match.params;23 const options ={24 method: 'POST',25 url: API_URL.investigation.getSiteHeader,26 data: {27 investigationId:selInvId,28 },29 dataType: 'json',30 doneResult: data => {31 if (!data.error) {32 const { headerList } = data.data;33 this.setState({34 tableheader: headerList, 35 });36 this.loadInvSiteList();37 } else {38 Modal.error({ title: data.error });39 }40 }41 }42 $.sendRequest(options)43 }44 loadInvSiteList = (params) => {45 const {searchSiteCode, searchSiteName, investigationJdeContractCode} = this.state;46 const { selRole, selInvId } = this.props.match.params;47 this.setState({loading: true,});48 const options = {49 url: `${API_URL.site.querySiteDetailList}`,50 data: {51 siteCode: searchSiteCode,52 siteName: searchSiteName,53 investigationId: selInvId,54 roleCode: selRole,55 ...params,56 investigationJdeContractCode: investigationJdeContractCode,57 transFlag: 1,58 },59 dataType: 'json',60 doneResult: ( data => {61 const { invSite } = data.data;62 const pagination = {...this.state.pagination};63 pagination.total = invSite.totalCount;64 this.setState({65 loading: false,66 dataList: invSite.datas,67 pagination,68 });69 }70 ),71 };72 $.sendRequest(options);73 };74 getColumns = () => {75 const {tableheader} = this.state76 const columnNames = [];77 columnNames.push({78 title: '序号',79 dataIndex: 'index',80 key: 'index',81 fixed: 'left',82 width: 40,83 });84 columnNames.push({85 title: '中心编号',86 dataIndex: 'investigationSiteCode',87 key: 'investigationSiteCode',88 sorter: true,89 sortType: 'COMMON',90 fixed: 'left',91 width:80,92 render: (text, record) => {93 return (94 <span>95 {96 record.allowedEnter && <a href="javascript:void(0)" onClick={() => this.selectSite(record.investigationSiteId, record.investigationSiteName, record.investigationSiteCode)}>{record.investigationSiteCode}</a>97 }98 {99 !record.allowedEnter && record.investigationSiteCode100 }101 </span>102 );103 },104 });105 columnNames.push({106 title: '中心名称',107 dataIndex: 'investigationSiteName',108 key: 'investigationSiteName',109 sorter: true,110 sortType: 'COMMON',111 fixed: 'left',112 width:200,113 });114 tableheader.map((d,i)=>{115 if(i>1){116 if(d.type == 'STATISTIC' || d.type == 'PLAN'){117 columnNames.push({118 title: d.displayName,119 dataIndex: d.field + d.type,120 key: d.field + d.type,121 sorter: d.sortable,122 sortType: d.type,123 sort : d.field,124 })125 }126 else{127 columnNames.push({128 title: d.displayName,129 dataIndex: d.field,130 key: d.field,131 sorter: d.sortable,132 sortType: d.type,133 sort : d.field,134 })135 }136 137 }138 139 })140 return columnNames;141 };142 /* 废弃 */143 /*getDataSource = () => {144 const sites = [];145 const {dataList, pagination,} = this.state;146 dataList.map((site, i) => {147 let chargePerson = {148 userName: '',149 doctorPosition: '',150 mobile: '',151 telephone: '',152 email: '',153 };154 if (site.chargePerson != null) {155 chargePerson = site.chargePerson;156 }157 sites.push({158 index: ((pagination.current - 1) || 0) * 15 + i + 1,159 investigationSiteId: site.investigationSiteId,160 investigationSiteName: site.investigationSiteName,161 investigationSiteCode: site.investigationSiteCode,162 allowedEnter: site.allowedEnter,163 });164 });165 return sites;166 };*/167 tableData = () => {168 const {dataList, pagination,tableheader} = this.state;169 let headers = tableheader; 170 let invList = dataList; 171 let dataSource = []; 172 invList.map((inv, i) =>{173 let row = {index: i+1, investigationId: inv.investigationId, investigationSiteId: inv.investigationSiteId, allowedEnter: inv.allowedEnter}; 174 headers.map((header,j) =>{175 let value; 176 let field = header.field;177 if(header.type == 'STATISTIC' || header.type == 'PLAN'){178 field = field + header.type;179 }180 inv.fields.map((invField,k) =>{181 if(invField.field == header.field){182 value = invField.value;183 }184 });185 inv.planFields.map((invField,k) =>{186 if(invField.field == header.field 187 && invField.type == header.type){188 value = invField.value;189 }190 });191 inv.roleFields.map((invField,k) =>{192 if(invField.field == header.field){193 value = invField.value;194 }195 });196 inv.executeFields.map((invField,k) =>{197 if(invField.field == header.field){198 value = invField.value;199 }200 });201 row[field] = value;202 });203 dataSource.push(row);204 })205 console.log(dataSource)206 return dataSource;207 }208 /**209 * 点击“中心汇总”按钮210 */211 clickSiteSummary = () => {212 const { selRole, selInvId } = this.props.match.params;213 sessionStorage.invId = selInvId;214 sessionStorage.curRole = selRole;215 sessionStorage.investigationSiteName = '中心汇总';216 location.href = `./#/summary/view/cumInfRan`;217 };218 /**219 * 点击某个项目时,获取角色列表,判断是单角色还是多角色220 */221 selectSite = (investigationSiteId, investigationSiteName, investigationSiteCode) => {222 const { selRole, selInvId } = this.props.match.params;223 sessionStorage.invId = selInvId;224 sessionStorage.siteId = investigationSiteId;225 sessionStorage.curRole = selRole;226 sessionStorage.investigationSiteCode = investigationSiteCode;227 sessionStorage.investigationSiteName = investigationSiteName;228 location.href = `./#/summary/view/cumInfRan`;229 }230 handleTableChange = (pagination, filters, sorter) => {231 let direction,sortType, sort = sorter.field;232 if (!jquery.isEmptyObject(sorter) && sorter.column) {233 sortType = sorter.column.sortType;234 if(sorter.column.sort)235 sort = sorter.column.sort;236 }237 const pager = {...this.state.pagination};238 pager.current = pagination.current;239 this.setState({240 pagination: pager,241 });242 if (sorter.order === 'descend' ) {243 direction = 'DESC';244 } else {245 direction = 'ASC';246 }247 if(sorter.column)248 this.loadInvSiteList({249 limit: pagination.pageSize,250 offset: pagination.current,251 direction,252 sort,253 sortType,254 ...filters,255 });256 };257 search = () => {258 this.loadInvSiteList();259 };260 /**261 * 输入中心编号搜索内容262 */263 onChangeSiteCode = e => {264 this.setState({searchSiteCode: e.target.value});265 };266 /**267 * 输入中心名称搜索内容268 */269 onChangeSiteName = e => {270 this.setState({searchSiteName: e.target.value});271 };272 onChangeJde = e => {273 this.setState({investigationJdeContractCode: e.target.value});274 };275 componentDidMount() {276 //const {selInvId } = this.props.match.params;277 //sessionStorage.invId = selInvId 278 this.getheader()279 280 }281 282 render() {283 const { loading, pagination, searchSiteCode, searchSiteName, investigationJdeContractCode } = this.state;284 const { selRole, selInvId } = this.props.match.params;285 const hasSiteSummary = selRole == "PM" || selRole == "CRCM" || selRole == "BO" || selRole == "BD" || selRole == "BDO";286 return (287 <div className="content-2 full">288 {/*<h1>临床项目》研究中心 进入列表角色={selRole} 进入列表项目={selInvId}</h1>*/}289 <div className='filter-bar'>290 {291 hasSiteSummary && <Button type="primary" onClick={this.clickSiteSummary}>中心汇总</Button>292 }293 <div className="form-item">294 <label className="ui-label">中心编号</label>295 <Input296 value={searchSiteCode}297 onChange={this.onChangeSiteCode}298 />299 </div>300 <div className="form-item">301 <label className="ui-label"> 中心名称</label>302 <Input303 value={searchSiteName}304 onChange={this.onChangeSiteName}305 />306 </div>307 <div className="form-item">308 <label className="ui-label"> JDE项目号</label>309 <Input310 value={investigationJdeContractCode}311 onChange={this.onChangeJde}312 />313 </div>314 <Button type="primary" icon="search" onClick={this.search}>搜索</Button>315 </div>316 <div className="main-content">317 <Table318 columns={this.getColumns()} 319 dataSource={this.tableData()}320 rowKey={record => record.investigationSiteId}321 loading={loading}322 scroll={{x:3000}}323 onChange={this.handleTableChange}324 pagination={ pagination }325 bordered={true}326 />327 </div>328 </div>329 );330 }331}...

Full Screen

Full Screen

ListContract.js

Source:ListContract.js Github

copy

Full Screen

1import $ from '../../common/AjaxRequest';2import jquery from 'jquery';3import React from 'react';4import { message, Table, Popconfirm, Modal, Button, Input } from 'antd';5import moment from 'moment';6import API_URL from '../../common/url';7import AjaxRequest from '../../common/AjaxRequest';8import ContractSider from './ContractSider';9import ChildJde from './ChildJde';10import InvContractChildRelated from './InvContractChildRelated';11import ExportUtil from '../../common/ExportUtil';12const initState = {13 sortParams: {},14 searchParams: {},15 data: [],16 loading: false,17 jdeData: {},18 addStatus: false,19 pagination:{20 pageSize: 15,21 current: 1,22 },23 dateFormat: "YYYY-MM-DD",24 jdeCode: '',25 mainJdeCode: '',26 showJde: true,27 relateCode: '',28 investigationJdeContractId: '',29 investigationJdeContractCode: '',30 keyword:''31}32class InvContract extends React.Component {33 state= initState;34 loadData = (params = {}) =>{35 this.setState({36 loading: true,37 });38 const {searchParams, pagination} = this.state;39 const options = {40 url: `${API_URL.investigation.listJdeContractSite}`,41 data: {42 offset: pagination.current,43 ...params,44 ...searchParams,45 limit: pagination.pageSize,46 },47 dataType: 'json',48 doneResult: ( data => {49 const pagination = { ...this.state.pagination };50 pagination.total = data.totalCount;51 this.setState({52 loading: false,53 data: data.datas,54 pagination,55 });56 }),57 errorResult: ( data => {58 this.setState({59 loading: false,60 });61 }),62 };63 AjaxRequest.sendRequest(options);64 }65 componentDidMount(){66 this.loadData();67 }68 getColumns = () => [{69 title: '序号',70 dataIndex: 'index',71 key: 'index',72 }, {73 title: 'JDE主项目号',74 dataIndex: 'mainInvestigationJdeContractCode',75 key: 'mainInvestigationJdeContractCode',76 }, {77 title: 'JDE项目号',78 dataIndex: 'childInvestigationJdeContractCode',79 key: 'childInvestigationJdeContractCode',80 }, {81 title: '合同额(元)',82 dataIndex: 'jdeContractAmount',83 key: 'jdeContractAmount',84 render: (value, row, index) => {85 const obj = {86 children: (row.jdeContractAmount && row.jdeContractAmount.toLocaleString()),87 props: {},88 };89 if(row.mergeFlag > 1){90 obj.props.rowSpan = row.mergeFlag;91 }92 if(row.mergeFlag == 0){93 obj.props.rowSpan = 0;94 }95 return obj;96 },97 }, {98 title: '合同开始时间',99 dataIndex: 'jdeContractStartTime',100 key: 'jdeContractStartTime',101 render: (value, row, index) => {102 const obj = {103 children: value,104 props: {},105 };106 if(row.mergeFlag > 1){107 obj.props.rowSpan = row.mergeFlag;108 }109 if(row.mergeFlag == 0){110 obj.props.rowSpan = 0;111 }112 return obj;113 },114 }, {115 title: '合同结束时间',116 dataIndex: 'jdeContractEndTime',117 key: 'jdeContractEndTime',118 render: (value, row, index) => {119 const obj = {120 children: value,121 props: {},122 };123 if(row.mergeFlag > 1){124 obj.props.rowSpan = row.mergeFlag;125 }126 if(row.mergeFlag == 0){127 obj.props.rowSpan = 0;128 }129 return obj;130 },131 }, {132 title: '合同是否签署完成',133 dataIndex: 'investigationJdeContractIsSigned',134 key: 'investigationJdeContractIsSigned',135 render: (value, row, index) => {136 const obj = {137 children: value,138 props: {},139 };140 if(row.mergeFlag > 1){141 obj.props.rowSpan = row.mergeFlag;142 }143 if(row.mergeFlag == 0){144 obj.props.rowSpan = 0;145 }146 return obj;147 },148 }, {149 title: '中心编号',150 dataIndex: 'investigationSiteCode',151 key: 'investigationSiteCode',152 }, {153 title: '中心名称',154 dataIndex: 'investigationSiteName',155 key: 'investigationSiteName',156 }, ]157 getDataSource = () => {158 const dataResult = [];159 const {data, pagination, dateFormat} = this.state;160 data.map((dataItem, i) => {161 dataResult.push({162 index: i + 1,163 key: i,164 ...dataItem,165 jdeContractStartTime: dataItem.jdeContractStartTimeShow,166 jdeContractEndTime: dataItem.jdeContractEndTimeShow,167 investigationJdeContractIsSigned: dataItem.investigationJdeContractIsSignedShow168 });169 });170 return dataResult;171 };172 handleChange = (e) => {173 const value = e.target.value;174 this.setState({ "jdeCode" : value });175 }176 177 handleKeyChange= (e) => {178 const value = e.target.value;179 this.setState({ "keyword" : value });180 }181 handleTableChange = (pagination, filters, sorter) => {182 let sortType,183 direction,184 sort = sort = sorter.field;185 const pager = { ...this.state.pagination };186 if (pager.current == pagination.current){187 pager.current = 1;188 //排序则页码为1189 } else {190 pager.current = pagination.current;191 //获取当前页192 }193 if (!jquery.isEmptyObject(sorter) && sorter.column) {194 sortType = sorter.column.sortType;195 }196 if (sorter.order === 'descend') {197 direction = 'DESC';198 } else {199 direction = 'ASC';200 }201 this.setState({202 pagination: pager,//设置新的分页信息203 sortParams: {//设置排序信息204 direction,205 sort,206 sortType207 }208 });209 210 this.loadData({211 limit: pager.pageSize,212 offset: pager.current,213 direction,214 sort,215 sortType,216 ...this.state.searchParams,217 ...filters,218 });219 }220 221 reset = () =>{222 const pagination = { ...this.state.pagination, current: 1 };223 this.setState({224 pagination,225 searchParams: {}226 },function(){227 this.loadData();228 });229 }230 reload = (params = {}, type) => {231 const newParams = {};232 if(type == "search"){233 newParams.searchParams = params;234 newParams.pagination = { ...this.state.pagination, current: 1 };235 }236 this.setState({237 ...newParams238 },function(){239 const { pagination,searchParams,sortParams } = this.state;240 this.loadData({241 offset: pagination.current,242 ...sortParams,243 ...searchParams,244 });245 })246 }247 248 search = () => {249 const {searchParams, jdeCode, keyword} = this.state;250 const newSearch = {251 ...searchParams,252 jdeCode: jdeCode,253 keyword254 };255 this.setState({256 searchParams: newSearch257 },function(){258 this.reload(newSearch,"search");259 });260 }261 export = () => {262 const { searchParams, pagination, sort, direction } = this.state;263 let url = `${API_URL.investigation.exportJdeContractSite}`;264 if(sort && direction){265 searchParams.sort = sort;266 searchParams.direction = direction;267 }268 ExportUtil.export(searchParams, pagination, url);269 }270 render() {271 const {loading, pagination, jdeData, data, addStatus, mainJdeCode} = this.state;272 return (273 <div className="content">274 <ContractSider/>275 <div className="main">276 <div className="filter-bar bar2">277 <div className="form-item">278 <label htmlFor="" className="ui-label">JDE项目号</label>279 <Input280 onChange={this.handleChange}281 //onKeyPress={this.enterSearch}282 />283 </div>284 <div className="form-item">285 <label htmlFor="" className="ui-label">中心编号\中心名称</label>286 <Input287 onChange={this.handleKeyChange}288 //onKeyPress={this.enterSearch}289 />290 </div>291 <div className="btn" style={{float: 'right'}}>292 <Button type="primary" onClick={this.export}>导出</Button>293 <Button type="primary" onClick={this.search}>搜索</Button>294 </div>295 </div>296 <Table297 columns={this.getColumns()}298 dataSource={this.getDataSource()}299 loading={loading}300 pagination={pagination}301 onChange={this.handleTableChange}302 scroll = {{x: "1100px"}}303 />304 </div>305 </div>306 );307 }308}...

Full Screen

Full Screen

InvContractChildRelated.js

Source:InvContractChildRelated.js Github

copy

Full Screen

1import $ from '../../common/AjaxRequest';2import jquery from 'jquery';3import React from 'react';4import { message, Table, Popconfirm, Modal, Button, Input } from 'antd';5import moment from 'moment';6import API_URL from '../../common/url';7import AjaxRequest from '../../common/AjaxRequest';8import AddSiteRelate from './AddSiteRelate';9const initState = {10 sortParams: {},11 searchParams: {},12 data: [],13 loading: false,14 jdeData: {},15 addStatus: false,16 pagination:{17 pageSize: 15,18 current: 1,19 },20 dateFormat: "YYYY-MM-DD",21 jdeCodeId: '',22 investigationJdeContractCode: '',23 mainJdeCode: '',24 showJde: true,25 relateCode: '',26 keyword: ''27}28class InvContractRelated extends React.Component {29 state= initState;30 loadData = (params = {}) =>{31 this.setState({32 loading: true,33 });34 const {searchParams, pagination, jdeCodeId} = this.state;35 const options = {36 url: `${API_URL.investigation.listJdeInvestigationSite}`,37 data: {38 offset: pagination.current,39 ...params,40 ...searchParams,41 limit: pagination.pageSize,42 jdeCodeId43 },44 dataType: 'json',45 doneResult: ( data => {46 const pagination = { ...this.state.pagination };47 pagination.total = data.totalCount;48 this.setState({49 loading: false,50 data: data.datas,51 pagination,52 });53 }),54 errorResult: ( data => {55 this.setState({56 loading: false,57 });58 }),59 };60 AjaxRequest.sendRequest(options);61 }62 componentDidMount(){63 }64 componentWillReceiveProps(nextProps){65 if(nextProps.jdeCodeId){66 console.log(nextProps.investigationJdeContractCode);67 this.setState({68 jdeCodeId: nextProps.jdeCodeId,69 investigationJdeContractCode: nextProps.investigationJdeContractCode70 },function(){71 this.loadData();72 })73 }74 }75 76 getColumns = () => [{77 title: '序号',78 dataIndex: 'index',79 key: 'index',80 }, {81 title: 'JDE项目号',82 dataIndex: 'investigationJdeContractCode',83 key: 'investigationJdeContractCode',84 sorter: true,85 }, {86 title: '中心编号',87 dataIndex: 'investigationSiteCode',88 key: 'investigationSiteCode',89 sorter: true,90 }, {91 title: '中心名称',92 dataIndex: 'investigationSiteName',93 key: 'investigationSiteName',94 sorter: true,95 }, {96 title: '操作',97 render: (text, record) => {98 return (99 <Popconfirm title={'确定要解除关联吗?'} onConfirm={this.del.bind(this, record.investigationJdeContractSiteId)} okText="确定" cancelText="取消">100 <a >解除关联</a>101 </Popconfirm>102 );103 },104 }]105 getDataSource = () => {106 const dataResult = [];107 const {data, pagination, dateFormat} = this.state;108 data.map((dataItem, i) => {109 if(dataItem.investigationJdeContractId < 0){110 dataResult.push({111 index: "合计",112 jdeContractAmount: dataItem.jdeContractAmount,113 });114 }else{115 dataResult.push({116 index: i + 1,117 ...dataItem,118 startTime: moment(dataItem.startTime).format(dateFormat),119 endTime: moment(dataItem.endTime).format(dateFormat),120 });121 }122 123 });124 return dataResult;125 };126 handleChange = (e) => {127 const value = e.target.value;128 this.setState({ "keyword" : value });129 }130 131 handleTableChange = (pagination, filters, sorter) => {132 let sortType,133 direction,134 sort = sort = sorter.field;135 const pager = { ...this.state.pagination };136 if (pager.current == pagination.current){137 pager.current = 1;138 //排序则页码为1139 } else {140 pager.current = pagination.current;141 //获取当前页142 }143 if (!jquery.isEmptyObject(sorter) && sorter.column) {144 sortType = sorter.column.sortType;145 }146 if (sorter.order === 'descend') {147 direction = 'DESC';148 } else {149 direction = 'ASC';150 }151 this.setState({152 pagination: pager,//设置新的分页信息153 sortParams: {//设置排序信息154 direction,155 sort,156 sortType157 }158 });159 160 this.loadData({161 limit: pager.pageSize,162 offset: pager.current,163 direction,164 sort,165 sortType,166 ...this.state.searchParams,167 ...filters,168 });169 }170 171 reset = () =>{172 const pagination = { ...this.state.pagination, current: 1 };173 this.setState({174 pagination,175 searchParams: {}176 },function(){177 this.loadData();178 });179 }180 reload = (params = {}, type) => {181 const newParams = {};182 if(type == "search"){183 newParams.searchParams = params;184 newParams.pagination = { ...this.state.pagination, current: 1 };185 }186 this.setState({187 ...newParams188 },function(){189 const { pagination,searchParams,sortParams } = this.state;190 this.loadData({191 offset: pagination.current,192 ...sortParams,193 ...searchParams,194 });195 }) 196 }197 198 search = () => {199 const {searchParams, keyword} = this.state;200 const newSearch = {201 ...searchParams,202 keyword203 };204 this.setState({205 searchParams: newSearch206 },function(){207 this.reload(newSearch,"search");208 });209 }210 addJde = () => {211 this.ChildJde.show("add");212 }213 editJde = (type,record) => {214 this.ChildJde.show(type,record);215 }216 del = (jdeSiteId) => {217 this.setState({218 loading: true219 })220 const options = {221 url: `${API_URL.investigation.relieveJdeInvestigationSite}`,222 data: {223 jdeSiteId224 },225 dataType: 'json',226 doneResult: ( data => {227 this.setState({228 loading: false229 })230 message.success("解除关联成功");231 this.reload();232 }),233 errorResult: d => {234 this.setState({235 loading: false236 })237 }238 };239 AjaxRequest.sendRequest(options);240 };241 returnRelate = () => {242 this.setState(initState)243 this.props.returnRelate();244 }245 addRelate = () => {246 const {jdeCodeId,investigationJdeContractCode} = this.state;247 this.AddSiteRelate.show(jdeCodeId,investigationJdeContractCode);248 }249 render() {250 const {loading, pagination, jdeData, data, addStatus, mainJdeCode, jdeCodeId, investigationJdeContractCode, keyword} = this.state;251 return (252 <div>253 <div style={{textAlign:"center",padding:"10px",fontSize:"16px"}}>254 中心关联记录({investigationJdeContractCode})255 </div>256 <div className="filter-bar bar2">257 <div className="form-item">258 <label htmlFor="" className="ui-label">中心编号\中心名称</label>259 <Input260 onChange={this.handleChange}261 value = {keyword}262 //onKeyPress={this.enterSearch}263 />264 </div>265 <div className="btn" style={{float: 'right'}}>266 <Button type="primary" style={{float:'right'}} onClick={this.returnRelate}>返回</Button>267 <Button type="primary" onClick={this.addRelate}>添加关联记录</Button>268 <Button type="primary" onClick={this.search}>搜索</Button>269 270 </div>271 </div>272 <Table273 columns={this.getColumns()}274 dataSource={this.getDataSource()}275 rowKey={record => record.investigationSiteCode}276 loading={loading}277 pagination={pagination}278 onChange={this.handleTableChange}279 />280 <AddSiteRelate ref={el => { this.AddSiteRelate = el; }}281 reload={this.reload}282 mainJdeCode={mainJdeCode}283 />284 </div>285 );286 }287}...

Full Screen

Full Screen

im.js

Source:im.js Github

copy

Full Screen

1import {output, isEmpty, getCookie} from "./util.js";2import {MessageActive} from './event.js';3import {4 user_ping_cmd,5 system_error_cmd,6 system_event_cmd,7 friend_get_unread_message_cmd,8 user_get_unread_application_count_cmd9} from "./api.js";10var Im;11var heartbeat;12var messageList = {};13function createSocketConnection(url, protocols) {14 output(url, 'createSocketConnection');15 Im = new WebSocket(url, protocols);16 return Im;17}18function createMessage(cmd, data = {}, ext = {}) {19 let msg = {20 cmd: cmd,21 data: data,22 ext: ext23 };24 output(msg);25 ack(msg);26 return JSON.stringify(msg);27}28function ack(msg, num = 1) {29 let data = msg.data;30 let message_id = data.message_id;31 if (isEmpty(message_id)) return false;32 messageList[message_id] = {33 msg: msg,34 num: num,35 timer: setTimeout(function () {36 output(num, message_id + '的发送次数');37 if (num > 3) {38 if (!isEmpty(data.content)) {39 output(num, '重试次数大于3进行提示');40 layui.layer.msg('消息发送失败:' + data.content, {41 time: 042 , btn: ['重试', '取消']43 , yes: function (index) {44 Im.send(JSON.stringify(msg));45 ack(messageList[message_id].msg, messageList[message_id]['num'] + 1);46 layui.layer.close(index);47 },48 btn2: function (index) {49 delete messageList[message_id];50 layui.layer.close(index);51 }52 });53 }54 } else {55 Im.send(JSON.stringify(msg));56 ack(messageList[message_id].msg, messageList[message_id]['num'] + 1);57 }58 }, 5000)59 };60 output(messageList);61}62function wsOpen(event) {63 output(event, 'onOpen');64 heartbeat = setInterval(function () {65 wsSend(createMessage(user_ping_cmd));66 }, 10000);67 infoInit();68}69function infoInit() {70 wsSend(createMessage(friend_get_unread_message_cmd, {}));71 wsSend(createMessage(user_get_unread_application_count_cmd, {}))72}73function wsReceive(event) {74 let result = eval('(' + event.data + ')');75 output(result, 'onMessage');76 if (layui.jquery.isEmptyObject(result)) {77 return false;78 }79 if (result.cmd && result.cmd === system_error_cmd) {80 layer.msg(result.cmd + ' : ' + result.msg);81 clearMessageListTimer(result);82 return false;83 }84 if (result.cmd && result.cmd === system_event_cmd) {85 let method = result.method;86 MessageActive[method] ? MessageActive[method](result.data) : '';87 return false;88 }89 if (result.cmd && result.cmd === user_ping_cmd) {90 return false;91 }92 clearMessageListTimer(result);93}94function clearMessageListTimer(result) {95 let message_id = result.data.message_id ?? '';96 if (message_id === '') return false;97 clearInterval(messageList[message_id].timer);98 delete messageList[message_id];99}100function wsError(event) {101 output(event, 'onError');102 clearInterval(heartbeat);103 reloadSocket(event);104}105function wsClose(event) {106 output(event, 'onClose');107 clearInterval(heartbeat);108 reloadSocket(event)109}110function reloadSocket(event) {111 layui.layer.msg(event.reason, {112 time: 0113 , title: '连接异常关闭'114 , btn: ['重试', '取消']115 , yes: function (index) {116 var wsUrl = layui.jquery(".wsUrl").val();117 Im = createSocketConnection(wsUrl, getCookie('IM_TOKEN'));118 socketEvent(Im);119 layui.layer.close(index);120 },121 btn2: function (index) {122 layui.layer.close(index);123 }124 });125}126function wsSend(data) {127 Im.send(data)128}129function socketEvent(webSocket) {130 webSocket.onopen = function (event) {131 wsOpen(event);132 };133 webSocket.onmessage = function (event) {134 wsReceive(event);135 };136 webSocket.onerror = function (event) {137 wsError(event)138 };139 webSocket.onclose = function (event) {140 wsClose(event)141 };142}143export {144 createSocketConnection,145 socketEvent,146 wsOpen,147 wsReceive,148 wsError,149 wsClose,150 wsSend,151 createMessage...

Full Screen

Full Screen

findClusterName.js

Source:findClusterName.js Github

copy

Full Screen

1var async = require('async');2var forEach = require('async-foreach').forEach;3var noun = require('./partOfSpeechAnalyzer');4var math = require('mathjs');5var jquery = require('jquery');6function clusterName (cluster, docFreq, terms){7 8 if(cluster.length == 0)9 {10 return "Empty";11 }12 //Array to store Document frequency of terms in cluster13 //Initialze array with 014 var clusterDocFreq = Array.apply(null, new Array(terms.length)).map(Number.prototype.valueOf,0);15 //16 forEach(cluster, 17 function(doc, docIndex, allDocs) {18 var pos;19 forEach(terms,20 function (term, termIndex, allTerms){21 //Check if the tfIdf weight is greater than 0 i.e it appears and that it is a noun22 if(doc.tfIdf[termIndex] > 0 && noun.nounTest(term)){23 clusterDocFreq[termIndex] += doc.tfIdf[termIndex];24 }25 });26 });27 var highestDF =0;28 var highestDFTerm;29 //Find term with highest tf-idf score30 //This will be the word that describes the cluster31 forEach(clusterDocFreq,32 function(df, index, arr){33 if(df > highestDF){34 highestDF = df;35 highestDFTerm = index;36 }37 });38 try{39 //Test if cluster name has length40 //If it doesn't it is undefined41 terms[highestDFTerm].length;42 }43 catch(e){44 //if cluster does not have a name it is an empty cluster so return false45 return false;46 }47 //If the word is a parial word due to preprocessing48 //This regex will find the full version of the word in the snippet49 //gi in regex means "g" search globally and "i" is ignore case which is very important here50 //due to stemming words that end with rry e.g jerry change to jerri if the words remove the i51 if(terms[highestDFTerm][terms[highestDFTerm].length - 1] === 'i')52 var regex = new RegExp(terms[highestDFTerm].slice(0, terms[highestDFTerm].length - 1) + '\\w*', 'gi');53 else54 var regex = new RegExp(terms[highestDFTerm] + '\\w*', 'gi');55 //Variable to store full word56 var fullTerm;57 //In parallel go through each doc and if the doc has that word (it will be > 0 in that words tfIdf position)58 //Assign the word match in the snippet59 forEach(cluster,60 function (doc, index, arr) {61 if(doc.tfIdf[highestDFTerm] > 0)62 //Google uses link for url63 if(doc.hasOwnProperty('link'))64 fullTerm = doc.snippet.toLowerCase().match(regex);65 else if(doc.hasOwnProperty('url'))66 //During preporcessing I left the main blekko snippet alone and used the string copy instead67 fullTerm = doc.strSnippet.toLowerCase().match(regex);68 //Bing snippets have the name Description69 else if(doc.hasOwnProperty('Description'))70 fullTerm = doc.Description.toLowerCase().match(regex);71 });72 //use jquery function to see if if object is empty 73 //If it is return the term if not return the parital as it is already a full word74 if(jquery.isEmptyObject(fullTerm) != true){75 return String(fullTerm[0]);76 }77 else{78 return terms[highestDFTerm];79 }80}81//Export function so it can be used in other modules...

Full Screen

Full Screen

TextInput.js

Source:TextInput.js Github

copy

Full Screen

1import React, { Component } from 'react'2import JQuery from 'jquery';3import {Input, Button, Form, Header, Card , Menu, Segment} from 'semantic-ui-react'4class TextInput extends Component {5 constructor(props) {6 super(props);7 this.state = {8 isEmpty: true,9 valid: false,10 errorMessage: "Input is invalid",11 errorVisible: false12 };13 this.validation = this.validation.bind(this);14 this.handleChange = this.handleChange.bind(this);15 this.handleBlur = this.handleBlur.bind(this);16 }17 handleChange(e) {18 this.validation(e.target.value);19 if(this.props.onChange) {20 this.props.onChange(e);21 }22 }23 validation(value, valid) {24 if(typeof valid === 'undefined') {25 valid = true;26 }27 let message = "";28 let errorVisible = false;29 this.props.releaseLock(this.props.lid);30 if(!valid) {31 message = this.props.errorMessage;32 valid = false;33 errorVisible = true;34 this.props.setLock(this.props.lid);35 } else if(this.props.required && JQuery.isEmptyObject(value)) {36 message = this.props.emptyMessage;37 valid = false;38 errorVisible = true;39 this.props.setLock(this.props.lid);40 } else if(value.length < this.props.minCharacters) {41 message = this.props.tooShortMessage;42 valid = false;43 errorVisible = true;44 this.props.setLock(this.props.lid);45 } else {46 }47 errorVisible = false;48 this.setState({49 isEmpty: JQuery.isEmptyObject(value),50 valid: valid,51 errorMessage: message,52 errorVisible: errorVisible53 }, () => {54 this.props.visible(this.state.errorVisible); // place functions in setState callback to make sure updates parent correctly55 this.props.setErrorMessage(this.state.errorMessage);56 });57 }58 handleBlur(e) {59 let valid = this.props.validate(e.target.value);60 this.validation(e.target.value, valid);61 // this.props.visible(this.state.errorVisible); // place functions in setState callback to make sure updates parent correctly62 // this.props.setErrorMessage(this.state.errorMessage);63 if(this.props.onChange) {64 this.props.onChange(e);65 }66 }67 render() {68 let styles = {69 marginBottom: 1570 }71 return (72 <div>73 <Form.Field style={styles}>74 <label>{this.props.label}</label>75 <Input76 placeholder={this.props.text}77 onChange={this.handleChange}78 onBlur={this.handleBlur}79 value={this.props.value}80 type={this.props.type} />81 </Form.Field>82 </div>83 )84 }85}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress Test', function() {2 it('Cypress Test', function() {3 cy.get('.query-btn').should('have.class', 'query-btn')4 cy.get('.query-btn').should('not.have.class', 'active')5 cy.get('.query-btn').click()6 cy.get('.query-btn').should('have.class', 'active')7 })8})9describe('Cypress Test', function() {10 it('Cypress Test', function() {11 cy.get('.query-btn').should('have.class', 'query-btn')12 cy.get('.query-btn').should('not.have.class', 'active')13 cy.get('.query-btn').click()14 cy.get('.query-btn').should('have.class', 'active')15 })16})17describe('Cypress Test', function() {18 it('Cypress Test', function() {19 cy.get('.query-btn').should('have.class', 'query-btn')20 cy.get('.query-btn').should('not.have.class', 'active')21 cy.get('.query-btn').click()22 cy.get('.query-btn').should('have.class', 'active')23 cy.get('.query-btn').should('have.class', 'query-btn active')24 })25})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2 it('test', () => {3 cy.window().then(win => {4 const obj = win.jQuery.isEmptyObject({})5 cy.log(obj)6 })7 })8})9Cypress.Commands.add('isEmptyObject', obj => {10 cy.window().then(win => {11 return win.jQuery.isEmptyObject(obj)12 })13})14describe('test', () => {15 it('test', () => {16 cy.isEmptyObject({}).then(obj => {17 cy.log(obj)18 })19 })20})21const webpack = require('webpack')22module.exports = {23 new webpack.DefinePlugin({24 }),25}26describe('test', () => {27 it('test', () => {28 cy.get('body').then($body => {29 const obj = $body.isEmptyObject({})30 cy.log(obj)31 })32 })33})34const webpack = require('webpack')35module.exports = {36 new webpack.DefinePlugin({37 }),38}39describe('test', () => {40 it('test', () => {41 cy.get('body').then($body => {42 const obj = $body.isEmptyObject({})43 cy.log(obj)44 })45 })46})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress jQuery', () => {2 it('should be able to use jQuery', () => {3 cy.get('#query-btn').click()4 cy.get('#querying .well>ul>li').should(($lis) => {5 expect(jQuery.isEmptyObject($lis)).to.be.false6 })7 })8})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test jQuery.isEmptyObject', () => {2 it('Check if empty object is empty', () => {3 expect(Cypress.$.isEmptyObject({})).to.be.true4 })5 it('Check if non empty object is empty', () => {6 expect(Cypress.$.isEmptyObject({ a: 1 })).to.be.false7 })8})9Cypress.Commands.add('isEmptyObject', (obj) => {10 return Cypress.$.isEmptyObject(obj)11})12describe('Test jQuery.isEmptyObject', () => {13 it('Check if empty object is empty', () => {14 expect(Cypress.isEmptyObject({})).to.be.true15 })16 it('Check if non empty object is empty', () => {17 expect(Cypress.isEmptyObject({ a: 1 })).to.be.false18 })19})20Cypress.Commands.add('isEmptyObject', (obj) => {21 return Cypress.$.isEmptyObject(obj)22})23describe('Test jQuery.isEmptyObject', () => {24 it('Check if empty object is empty', () => {25 expect(Cypress.isEmptyObject({})).to.be.true26 })27 it('Check if non empty object is empty', () => {28 expect(Cypress.isEmptyObject({ a: 1 })).to.be.false29 })30})31Cypress.Commands.add('isEmptyObject', (obj) => {32 return Cypress.$.isEmptyObject(obj)33})34describe('Test jQuery.isEmptyObject', () => {35 it('Check if empty object is empty', () => {36 expect(Cypress.isEmptyObject({})).to.be.true37 })38 it('Check if non empty object is empty', () => {39 expect(Cypress.isEmptyObject({ a: 1 })).to.be.false40 })41})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('jQuery.isEmptyObject method of Cypress', () => {2 it('should check if an object is empty or not', () => {3 cy.get('li').then((lis) => {4 expect(jQuery.isEmptyObject(lis)).to.be.false5 })6 })7})8Cypress.Commands.add('isEmptyObject', { prevSubject: true }, (subject) => {9 return jQuery.isEmptyObject(subject)10})11describe('jQuery.isEmptyObject method of Cypress', () => {12 it('should check if an object is empty or not', () => {13 cy.get('li').then((lis) => {14 cy.isEmptyObject(lis).should('be', false)15 })16 })17})18Cypress.Commands.add('isEmptyObject', { prevSubject: true }, (subject) => {19 return jQuery.isEmptyObject(subject)20})21describe('jQuery.isEmptyObject method of Cypress', () => {22 it('should check if an object is empty or not', () => {23 cy.get('li').then((lis) => {24 cy.isEmptyObject(lis).should('be', false)25 })26 })27})28Cypress.Commands.add('isEmptyObject', { prevSubject: true }, (subject) => {29 return jQuery.isEmptyObject(subject)30})31describe('jQuery.isEmptyObject method of Cypress', () => {32 it('should check if an object is empty or not', () => {33 cy.get('li').then((lis) => {34 cy.isEmptyObject(lis).should('be', false)35 })36 })37})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('isEmptyObject', () => {2 it('checks if the object is empty', () => {3 expect({}).to.be.empty;4 expect({}).to.be.empty;5 });6});7Cypress.Commands.add('isEmptyObject', (value) => {8 expect(value).to.be.empty;9});10describe('isEmptyObject', () => {11 it('checks if the object is empty', () => {12 cy.isEmptyObject({});13 });14});15Cypress.Commands.add('isEmptyObject', (value) => {16 expect(value).to.be.empty;17});18describe('isEmptyObject', () => {19 it('checks if the object is empty', () => {20 cy.isEmptyObject({});21 });22});23Cypress.Commands.add('isEmptyObject', (value) => {24 expect(value).to.be.empty;25});26describe('isEmptyObject', () => {27 it('checks if the object is empty', () => {28 cy.isEmptyObject({});29 });30});31Cypress.Commands.add('isEmptyObject', (value) => {32 expect(value).to.be.empty;33});34describe('isEmptyObject', () => {35 it('checks if the object is empty', () => {36 cy.isEmptyObject({});37 });38});39Cypress.Commands.add('isEmptyObject', (value) => {40 expect(value).to.be.empty;41});42describe('isEmptyObject', () => {43 it('checks if the object is empty', () => {44 cy.isEmptyObject({});45 });46});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('Test', function() {3 cy.get('input').type('Test')4 cy.get('button').click()5 cy.get('li').should('have.length', 1)6 cy.get('li').should('have.text', 'Test')7 cy.window().then((window) => {8 const obj = window.$('li').data()9 cy.log(obj)10 cy.wrap(obj).should('not.be.empty')11 })12 })13})14cy.get('li').then(($li) => {15 const obj = $li.data()16 cy.log(obj)17 cy.wrap(obj).should('not.be.empty')18})19describe('Test', function() {20 it('Test', function() {21 cy.get('input').type('Test')22 cy.get('button').click()23 cy.get('li').should('have.length', 1)24 cy.get('li').should('have.text', 'Test')25 cy.get('li').then(($li) => {26 const obj = $li.data()27 cy.log(obj)28 cy.wrap(obj).should('not.be.empty')29 })30 })31})

Full Screen

Using AI Code Generation

copy

Full Screen

1import $ from "jquery"2const obj = {}3const isEmpty = $.isEmptyObject(obj)4console.log(isEmpty)5import $ from "jquery"6const obj = {7}8const isEmpty = $.isEmptyObject(obj)9console.log(isEmpty)10import $ from "jquery"11const obj = {12}13const isEmpty = $.isEmptyObject(obj)14console.log(isEmpty)15import $ from "jquery"16const obj = {17}18const isEmpty = $.isEmptyObject(obj)19console.log(isEmpty)20import $ from "jquery"21const obj = {22}23const isEmpty = $.isEmptyObject(obj)24console.log(isEmpty)25import $ from "jquery"26const obj = {27}28const isEmpty = $.isEmptyObject(obj)29console.log(isEmpty)

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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