Best JavaScript code snippet using wpt
recovery-form.js
Source:recovery-form.js
1new Vue({2 el: '#recovery-form',3 data() {4 return {5 htHaveChange:false,6 openName: '',7 openTime: '',8 //跳转页é¢åæ°9 inParams: '',10 //ç»ç»11 organ: {12 currentOrganization: {13 orgName: ''14 },15 userCurrentOrganId: ''16 },17 //é件18 boeType: 'REPAIR_IN',19 isUpdateShow: false,//æ¥çæ¶æ¯å¦å¯ç¼è¾20 isAddShow: false,//ååæç»åå½è¡æ¯å¦æ¾ç¤º(æ°å¢æå é¤è¡,éææè²)21 isNotAddShow: true,//ååæç»åå½è¡æ¯å¦æ¾ç¤º22 productTypeList: [],//ååç±»åList23 goodList: [],24 isHint: true,25 isRemarkView: false,//å¤æ³¨æ¯å¦å¯ç¼è¾26 isDifference: false,//æ§å¶ç»ä»¶ç¬¬ä¸è¡æ¯å¦å¯ç¼è¾27 isDisable: true,//æ§å¶é¡µé¢å§ç»ç¦ç¨çé¨å28 isView: false,29 checkName: 'no',30 // isResource: false,31 isShow: true,32 isCustView: false,//客æ·æ¯å¦å¯ç¼è¾33 isSearchHide: true,//æå æé®34 isShowCust: false,//æ§å¶å®¢æ·å¼¹çª35 isShowSupplier: false,//æ§å¶ç»´ä¿®å家弹çªç»ä»¶36 isShowApprove: false,//æ§å¶å®¡æ ¸é©³åå¼¹çª37 resultDisable: false,//åå½è¡è´¨æ£ç»æä¸å¯ç¼è¾38 selectCustomerObj: null,39 tmpCheckItem: {},//临æ¶æ¾ç½®æ£éªç»æ40 tabName: 'detail',//页ç¾å称41 modalType: '',//审æ¹é©³åç±»å42 stepList: [], //审æ¹è¿åº¦æ¡43 approvalTableData: [],44 selectedRow: '',//åå½è¡è¢«éä¸çä¸æ 45 // åºæ¬ä¿¡æ¯åå§å46 employees: [],//ç»è®°äººä¸æé项47 commodityList: [],//åå½è¡ååä¸æé项48 goldColor: [],//åå½è¡éææè²ä¸æé项49 unitMap: {},//åå½è¡åä½map50 checkListData: {51 goodsCode: {52 name: 'ååç¼ç ',53 type: 'string',54 },55 repairFee: {56 name: 'å®é
维修费ç¨',57 type: 'number',58 floor: 2,59 },60 billFee: {61 name: 'ç»ç®è´¹ç¨',62 type: 'number',63 floor: 264 }65 },66 ruleValidate: {67 businessType: [68 { required: true }69 ],70 returnTime: [71 { required: true }72 ],73 saleMenId: [74 { required: true }75 ],76 },77 addBody: {78 id: '',//主é®ID79 businessType: '',//ä¸å¡ç±»åï¼1 å¤é¨ç»´ä¿®ï¼2 å
é¨ç»´ä¿®ï¼80 inOrderNo: '',//åæ®ç¼å·81 goodsTypeName: '',//ååç±»åå称82 goodsType: '',//ååç±»å83 groupPath: '',//å类路å¾84 goodsMainType: '',//åå主类å85 organizationId: '',//æå±ç»ç»id86 organizationName: '', //æå±ç»ç»å称87 supplierId: '',//ä¾åºåID88 supplierName: '',//ä¾åºåå称89 supplierCode: '',//ä¾åºåç¼ç 90 custNo: '',//客æ·ç¼å·91 custName: '',//客æ·å称92 custId: '',//客æ·å称ID93 returnTime: '',//æ¥æ94 saleMenId: '',//ä¸å¡åID95 saleMenName: '',//ä¸å¡äººåå称96 shipMethod: '',//ç©æµè¦æ±97 status: '',//åæ®ç¶æ(1 æåï¼2 å¾
å®¡æ ¸ï¼3 å®¡æ ¸ä¸ï¼4 å·²å®¡æ ¸ï¼5 驳å)98 totalPayable: 0,//åºä»å计99 totalReceivable: 0,//åºæ¶å计100 businessStatus: '',//ä¸å¡ç¶æ(1 å¾
è´¨æ£ï¼2 已质æ£)101 dataStatus: '',//æ°æ®ç¶æ(1 ä¸å¯æ交ï¼2 å¯æ交)102 createId: "",//å建人ID103 createName: "",//å建人å§å104 createTime: "",//å建æ¶é´105 updateId: "",//ä¿®æ¹äººID106 updateName: "",//ä¿®æ¹äººå§å107 updateTime: "", //ä¿®æ¹æ¶é´108 auditId: '',//å®¡æ ¸äºº109 auditTime: '',//å®¡æ ¸æ¶é´110 auditName: '',//å®¡æ ¸äººå§å111 isDel: '',//æ¯å¦å é¤ï¼1ï¼æªå é¤ï¼0ï¼å·²å é¤ï¼112 version: '', //çæ¬å·113 genDataMark: '',//çæä¸æ¸¸æ°æ®æ å¿(1 å¾
çæ ï¼2 å·²çæ)114 num: 0,//åå件æ°115 totalWeight: 0,//ååæ»é116 //ååæç»117 repairInOrderDetailList: []118 },119 oneList: {120 detailId: '',//å
³èid121 sourceId: '',//æºåID122 sourceType: '',//æºåç±»å123 sourceNo: '',//æºååå·124 repairRegisterId: '',//ç»è®°åID125 repairRegisterNo: '',//ç»è®°åå·126 id: '',//主é®ID127 goodsLineNo: '',//åååå½è¡128 goodsName: '',//ååå称129 goodsCode: '',//ååç¼ç 130 commodityId: '',//ååç¼ç ID131 goldColor: '',//éææè²132 goodsNum: '',//ååæ°é133 goodsNorm: '',//ååè§æ ¼134 styleCategoryId: '',//款å¼ç±»å«id135 custStyleCode: '',//款å¼ç±»å«136 custStyleName: '',//款å¼å称137 countingUnit: '',//计æ°åä½138 countingUnitId: '',//计æ°åä½id139 weightUnitId: '',//计éåä½id140 weightUnit: '',//计éåä½141 totalWeight: '',//æ»é142 goldWeight: '',//éé143 mainStoneName: '',//主ç³å称144 mainStoneWeight: '',//主ç³é145 mainStoneColor: '',//主ç³é¢è²146 mainStoneClarity: '',//主ç³å度147 viceStoneName: '',//å¯ç³å称148 viceStoneWeight: '',//å¯ç³é149 viceStoneNum: '',//å¯ç³ç²æ°150 certificateType: '',//è¯ä¹¦ç±»å151 certificateNo: '',//è¯ä¹¦ç¼å·152 checkStatus: '',//æ£éªç¶æ153 checkResult: '',//æ£éªç»æ154 repairType: '',//维修类å155 repairWay: '',//ç»´ä¿®æ¹å¼156 repairNum: '',//维修次æ°157 repairRemark: '',//ç»´ä¿®å
容åè¦æ±158 preRepairFee: '',//é¢ç»´ä¿®è´¹ç¨159 repairFee: '',//å®é
维修费ç¨160 billFee: '',//ç»ç®è´¹ç¨161 repairRegisterGoods: null, //ååç»è®°ä¿¡æ¯162 goodsCheckInfo: null,//ååç»´ä¿®åæ£éªä¿¡æ¯163 goodsCheckAfter: null//ååç»´ä¿®åæ£éªä¿¡æ¯164 },165 repairRegisterGoods: {166 id: '',//主é®ID167 goodsLineNo: '',//åååå½è¡168 goodsName: '',//ååå称169 goodsCode: '',//ååç¼ç 170 commodityId: '',//ååç¼ç ID171 goldColor: '',//éææè²172 goodsNum: '',//ååæ°é173 goodsNorm: '', //ååè§æ ¼174 custStyleCode: '',//款å¼ç±»å«175 custStyleName: '',//款å¼å称176 countingUnit: '',//计æ°åä½177 countingUnitId: '',//计æ°åä½id178 weightUnitId: '',//计éåä½id179 weightUnit: '',//计éåä½180 totalWeight: '',//æ»é181 goldWeight: '',//éé182 mainStoneName: '',//主ç³å称183 mainStoneWeight: '',//主ç³é184 mainStoneColor: '',//主ç³é¢è²185 mainStoneClarity: '',//主ç³å度186 viceStoneName: '',//å¯ç³å称187 viceStoneWeight: '',//å¯ç³é188 viceStoneNum: '',//å¯ç³ç²æ°189 },190 //ååç»´ä¿®åæ£éªä¿¡æ¯191 goodsCheckInfo: {192 id: '',//主é®ID193 repairGoodsId: '',//ç»´ä¿®ååä¿¡æ¯ID194 goodsLineNo: '',//åååå½è¡195 goodsName: '',//ååå称196 goodsCode: '',//ååç¼ç 197 commodityId: '',//ååç¼ç ID198 goldColor: '',//éææè²199 goodsNum: '',//ååæ°é200 goodsNorm: '',//ååè§æ ¼201 custStyleCode: '',//款å¼ç±»å«202 custStyleName: '',//款å¼å称203 countingUnit: '',//计æ°åä½204 countingUnitId: '',//计æ°åä½id205 weightUnitId: '',//计éåä½id206 weightUnit: '',//计éåä½207 totalWeight: '',//æ»é208 goldWeight: '',//éé209 mainStoneName: '',//主ç³å称210 mainStoneWeight: '',//主ç³é211 mainStoneColor: '',//主ç³é¢è²212 mainStoneClarity: '',//主ç³å度213 viceStoneName: '',//å¯ç³å称214 viceStoneWeight: '',//å¯ç³é215 viceStoneNum: '',//å¯ç³ç²æ°216 certificateType: '',//è¯ä¹¦ç±»å217 certificateNo: '',//è¯ä¹¦ç¼å·218 checkStatus: '',//æ£éªç¶æ219 checkResult: '',//æ£éªç»æ220 repairType: '',//维修类å221 repairWay: '',//ç»´ä¿®æ¹å¼222 repairNum: '',//维修次æ°223 repairRemark: '',//ç»´ä¿®å
容åè¦æ±224 preRepairFee: '',//é¢ç»´ä¿®è´¹ç¨225 repairFee: '',//å®é
维修费ç¨226 billFee: '',//ç»ç®è´¹ç¨227 checkType: '',//æ£éªç±»å(1 ç»´ä¿®åæ£éª ï¼2 ç»´ä¿®åæ£éª )228 checkTime: ''//æ£éªæ¶é´229 },230 //ååç»´ä¿®åæ£éªä¿¡æ¯231 goodsCheckAfter: {232 /*id: '',//主é®ID233 repairGoodsId: '',//ç»´ä¿®ååä¿¡æ¯ID234 goodsLineNo: '',//åååå½è¡235 goodsName: '',//ååå称236 goodsCode: '',//ååç¼ç 237 commodityId: '',//ååç¼ç ID238 goldColor: '',//éææè²239 goodsNum: '',//ååæ°é240 goodsNorm: '',//ååè§æ ¼241 custStyleCode: '',//款å¼ç±»å«242 custStyleName: '',//款å¼å称243 countingUnit: '',//计æ°åä½244 weightUnit: '',//计éåä½245 totalWeight: '',//æ»é246 goldWeight: '',//éé247 mainStoneName: '',//主ç³å称248 mainStoneWeight: '',//主ç³é249 mainStoneColor: '',//主ç³é¢è²250 mainStoneClarity: '',//主ç³å度251 viceStoneName: '',//å¯ç³å称252 viceStoneWeight: '',//å¯ç³é253 viceStoneNum: '',//å¯ç³ç²æ°254 certificateType: '',//è¯ä¹¦ç±»å255 certificateNo: '',//è¯ä¹¦ç¼å·256 checkStatus: '',//æ£éªç¶æ257 checkResult: '',//æ£éªç»æ258 repairType: '',//维修类å259 repairWay: '',//ç»´ä¿®æ¹å¼260 repairNum: '',//维修次æ°261 repairRemark: '',//ç»´ä¿®å
容åè¦æ±262 preRepairFee: '',//é¢ç»´ä¿®è´¹ç¨263 repairFee: '',//å®é
维修费ç¨264 billFee: '',//ç»ç®è´¹ç¨265 checkType: '',//æ£éªç±»å(1 ç»´ä¿®åæ£éª ï¼2 ç»´ä¿®åæ£éª )266 checkTime: '',//æ£éªæ¶é´*/267 }268 }269 },270 methods: {271 //é件ä¸ä¼ æé®æå¼272 isEdit: function (isEdit, on) {273 eventHub.$emit('isEdit', isEdit);274 },275 // ä¿åé件 ä¿åçæ¶åè°ç¨276 saveAccess: function (id, type, on) {277 eventHub.$emit('saveFile', id, type);278 },279 // æ¥æ¾é件 æ¥ççæ¶åè°ç¨280 getAccess: function (id, type, on) {281 eventHub.$emit('queryFile', id, type);282 },283 selectedTr(index) {284 this.selectedRow = index;285 },286 hideSearch() {287 },288 // æ ¡éªè¡¨åå¿
填项289 checkForm(obj, flag) {290 for (var key in obj) {291 if (!obj[key]) {292 if (flag) {293 this.$Modal.warning({294 title: "æ示",295 okText: "ç¡®å®",296 content: key + "ä¸è½ä¸ºç©º"297 });298 }299 return false;300 }301 }302 return true;303 },304 /*****************æé®æ å¼å§********************/305 //æ æºæ°å¢306 addByNoSource() {307 let This = this;308 $.ajax({309 type: "post",310 async: false,311 url: contextPath + '/repairInOrderController/saveByNoSource',312 data: JSON.stringify(This.addBody),313 contentType: 'application/json;charset=utf-8',314 dataType: "json",315 success(data) {316 if (data.code === "100100") {317 This.addBody = data.data;318 This.addBody.id = data.data.id;319 This.addBody.inOrderNo = data.data.inOrderNo;320 This.$Modal.success({321 title: "æ示",322 content: "ä¿åæå!"323 });324 // è°ç¨æ¹æ³ä¿åé件325 This.saveAccess(data.data.id, This.boeType);326 //设置å建人åæ¥æ327 This.addBody.createId = data.data.createId;328 This.addBody.createName = data.data.createName;329 This.addBody.createTime = data.data.createTime;330 This.htHaveChange = false;331 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;332 } else {333 This.$Modal.error({334 title: "æ示",335 content: "ä¿å失败!"336 });337 }338 },339 error() {340 This.$Modal.error({341 title: "æ示",342 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',343 });344 }345 })346 },347 //ææºæ°å¢348 addBySource() {349 let This = this;350 $.ajax({351 type: "post",352 async: false,353 url: contextPath + '/repairInOrderController/save',354 data: JSON.stringify(This.addBody),355 contentType: 'application/json;charset=utf-8',356 dataType: "json",357 success(data) {358 if (data.code === "100100") {359 This.addBody.id = data.data.id;360 This.addBody.inOrderNo = data.data.inOrderNo;361 This.$Modal.success({362 title: "æ示",363 content: "ä¿åæå!"364 });365 // è°ç¨æ¹æ³ä¿åé件366 This.saveAccess(data.data.id, This.boeType);367 //设置å建人åæ¥æ368 This.addBody.createId = data.data.createId;369 This.addBody.createName = data.data.createName;370 This.addBody.createTime = data.data.createTime;371 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;372 This.htHaveChange = false;373 } else {374 This.$Modal.error({375 title: "æ示",376 content: "ä¿å失败!"377 });378 }379 },380 error() {381 This.$Modal.error({382 title: "æ示",383 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',384 });385 }386 })387 },388 //æ æºä¿®æ¹389 updateByNoSource() {390 let This = this;391 $.ajax({392 type: "post",393 async: false,394 url: contextPath + '/repairInOrderController/updateByNoSource',395 data: JSON.stringify(This.addBody),396 contentType: 'application/json;charset=utf-8',397 dataType: "json",398 success(data) {399 if (data.code === "100100") {400 // è°ç¨æ¹æ³ä¿åé件401 This.saveAccess(data.data.id, This.boeType);402 //ä¿®æ¹äººåæ¥æ403 //设置å建人åæ¥æ404 This.addBody.createId = data.data.createId;405 This.addBody.createName = data.data.createName;406 This.addBody.createTime = data.data.createTime;407 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;408 This.htHaveChange = false;409 This.$Modal.success({410 title: "æ示",411 content: "ä¿åæå!"412 });413 } else {414 This.$Modal.error({415 title: "æ示",416 content: "ä¿å失败!"417 });418 }419 },420 error() {421 This.$Modal.error({422 title: "æ示",423 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',424 });425 }426 })427 },428 //ææºä¿®æ¹429 updateBySource() {430 let This = this;431 $.ajax({432 type: "post",433 async: false,434 url: contextPath + '/repairInOrderController/update',435 data: JSON.stringify(This.addBody),436 contentType: 'application/json;charset=utf-8',437 dataType: "json",438 success(data) {439 if (data.code === "100100") {440 // è°ç¨æ¹æ³ä¿åé件441 This.saveAccess(data.data.id, This.boeType);442 //ä¿®æ¹äººåæ¥æ443 //设置å建人åæ¥æ444 This.addBody.createId = data.data.createId;445 This.addBody.createName = data.data.createName;446 This.addBody.createTime = data.data.createTime;447 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;448 This.htHaveChange = false;449 This.$Modal.success({450 title: "æ示",451 content: "ä¿åæå!"452 });453 } else {454 This.$Modal.error({455 title: "æ示",456 content: "ä¿å失败!"457 });458 }459 },460 error() {461 This.$Modal.error({462 title: "æ示",463 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',464 });465 }466 })467 },468 // ä¿å469 save() {470 // æ ¡éªå¿
填项471 let obj = {472 "ä¸å¡ç±»å": this.addBody.businessType,473 "ååç±»å": this.addBody.goodsType,474 "æ¥æ": this.addBody.returnTime,475 "ç»´ä¿®å家": this.addBody.supplierName,476 "ä¸å¡å": this.addBody.saleMenId,477 };478 if (this.addBody.businessType == 2) {479 delete this.checkListData.billFee;480 } else {481 this.checkListData.billFee = {482 name: 'ç»ç®è´¹ç¨',483 type: 'number',484 floor: 2485 }486 }487 if ((!this.checkForm(obj, false))) {488 this.addBody.dataStatus = 1489 } else if (htValidateRow(this.addBody.repairInOrderDetailList, this.checkListData, false,this)) {490 this.addBody.dataStatus = 1491 } else if (this.addBody.repairInOrderDetailList.length === 0) {492 this.addBody.dataStatus = 1493 } else if(this.addBody.businessType===1&&(this.addBody.custName===null||this.addBody.custName==="")){494 this.addBody.dataStatus = 1;495 }else{496 this.addBody.dataStatus = 2;497 }498 console.log(this.addBody);499 this.addBody.status = 1;500 if (this.addBody.repairInOrderDetailList === null || this.addBody.repairInOrderDetailList === undefined) {501 //æ æº502 if (this.addBody.id === "") {503 //æ°å¢504 this.addByNoSource();505 } else {506 //ä¿®æ¹507 this.updateByNoSource();508 }509 } else {510 let sourceNo;511 this.addBody.repairInOrderDetailList.forEach((item) => {512 sourceNo = item.sourceNo;513 });514 if (sourceNo !== null && sourceNo !== undefined && sourceNo !== "") {515 //ææº516 if (this.addBody.id === "") {517 //æ°å¢518 this.addBySource();519 } else {520 //ä¿®æ¹521 this.updateBySource();522 }523 }524 else {525 //æ æº526 if (this.addBody.id === "") {527 //æ°å¢528 this.addByNoSource();529 } else {530 //ä¿®æ¹531 this.updateByNoSource();532 }533 }534 }535 },536 // æ交537 submit(name) {538 let isCommodityPass = this.$refs.commodityType.submit();539 let isSupplierPass = this.$refs.supplier.submit();540 let isCustomerPass = '';541 let isFormPass = '';542 this.$refs[name].validate((valid) => {543 if (valid) {544 isFormPass = true;545 } else {546 isFormPass = false;547 }548 })549 if (this.addBody.businessType == 1) {550 isCustomerPass = this.$refs.customerRef.submit();551 } else {552 isCustomerPass = true;553 }554 if (!isCommodityPass || !isSupplierPass || !isCustomerPass || !isFormPass) {555 return;556 }557 // let obj = {558 // "ä¸å¡ç±»å": this.addBody.businessType,559 // "ååç±»å": this.addBody.goodsType,560 // "æ¥æ": this.addBody.returnTime,561 // "ç»´ä¿®å家": this.addBody.supplierName,562 // "ä¸å¡å": this.addBody.saleMenId,563 // };564 // if ($('form').valid() === false) {565 // this.$Modal.warning({566 // title: 'æ示信æ¯',567 // content: '<p>请填åå¿
填项!</p >'568 // });569 // return;570 // } else {571 // if (!this.checkForm(obj, true)) return;572 // }573 // if (this.addBody.businessType == 1 && this.addBody.custName == "") {574 // this.$Modal.warning({575 // title: 'æ示信æ¯',576 // content: '客æ·ä¿¡æ¯ä¸è½ä¸ºç©ºï¼'577 // });578 // return false;579 // }580 // åå½è¡éªè¯é¨å581 if (this.addBody.businessType == 2) {582 delete this.checkListData.billFee;583 } else {584 this.checkListData.billFee = {585 name: 'ç»ç®è´¹ç¨',586 type: 'number',587 floor: 2588 }589 }590 if (htValidateRow(this.addBody.repairInOrderDetailList, this.checkListData, true,this)) return;591 if (this.addBody.repairInOrderDetailList.length === 0) {592 this.$Modal.warning({593 title: 'æ示信æ¯',594 content: '<p>åå½è¡ä¸è½ä¸ºç©º!</p >'595 });596 return;597 }598 this.addBody.status = 2;599 this.addBody.dataStatus = 2;600 if (this.addBody.repairInOrderDetailList === null || this.addBody.repairInOrderDetailList === undefined) {601 //æ æº602 if (this.addBody.id === "") {603 //æ°å¢604 this.submitOfSubmitByNoSource();605 } else {606 //ä¿®æ¹607 this.updateOfSubmitByNoSource();608 }609 } else {610 let sourceNo;611 this.addBody.repairInOrderDetailList.forEach((item) => {612 sourceNo = item.sourceNo;613 });614 if (sourceNo !== null && sourceNo !== undefined && sourceNo !== "") {615 //ææº616 if (this.addBody.id === "") {617 //æ°å¢618 this.submitOfSubmitBySource();619 } else {620 //ä¿®æ¹621 this.updateOfSubmitBySource();622 }623 }624 else {625 //æ æº626 if (this.addBody.id === "") {627 //æ°å¢628 this.submitOfSubmitByNoSource();629 } else {630 //ä¿®æ¹631 this.updateOfSubmitByNoSource();632 }633 }634 }635 },636 //æ æºæ交(æ°å¢)637 submitOfSubmitByNoSource() {638 let This = this;639 $.ajax({640 type: "post",641 url: contextPath + '/repairInOrderController/saveByNoSource',642 data: JSON.stringify(This.addBody),643 contentType: 'application/json;charset=utf-8',644 dataType: "json",645 success(data) {646 if (data.code === "100100") {647 This.addBody = data.data;648 This.addBody.id = data.data.id;649 This.addBody.inOrderNo = data.data.inOrderNo;650 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;651 This.$Modal.success({652 title: "æ示",653 content: "æ交æå!"654 });655 // è°ç¨æ¹æ³ä¿åé件656 This.saveAccess(data.data.id, This.boeType);657 This.isEdit(This.addBody.status === 1 ? 'Y' : 'N');658 //设置å¤æ³¨,ä¸å¡äººå,æ¥æä¸å¯ç¼è¾659 This.isUpdateShow = true;660 This.isAddShow = false;661 This.isView = true;662 This.htHaveChange = false;663 //设置å建人åæ¥æ664 This.addBody.createId = data.data.createId;665 This.addBody.createName = data.data.createName;666 This.addBody.createTime = data.data.createTime;667 } else {668 This.addBody.status = 1;669 This.$Modal.error({670 title: "æ示",671 content: "æ交失败!"672 });673 }674 },675 error() {676 This.$Modal.error({677 title: "æ示",678 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',679 });680 }681 })682 },683 //ææºæ交(æ°å¢)684 submitOfSubmitBySource() {685 let This = this;686 $.ajax({687 type: "post",688 url: contextPath + '/repairInOrderController/save',689 data: JSON.stringify(This.addBody),690 contentType: 'application/json;charset=utf-8',691 dataType: "json",692 success(data) {693 if (data.code === "100100") {694 This.addBody.id = data.data.id;695 This.addBody.inOrderNo = data.data.inOrderNo;696 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;697 This.$Modal.success({698 title: "æ示",699 content: "æ交æå!"700 });701 // è°ç¨æ¹æ³ä¿åé件702 This.saveAccess(data.data.id, This.boeType);703 This.isEdit(This.addBody.status === 1 ? 'Y' : 'N');704 //设置å¤æ³¨,ä¸å¡äººå,æ¥æä¸å¯ç¼è¾705 This.isUpdateShow = true;706 This.isAddShow = false;707 This.isView = true;708 This.htHaveChange = false;709 //设置å建人åæ¥æ710 This.addBody.createId = data.data.createId;711 This.addBody.createName = data.data.createName;712 This.addBody.createTime = data.data.createTime;713 } else {714 This.addBody.status = 1;715 This.$Modal.error({716 title: "æ示",717 content: "æ交失败!"718 });719 }720 },721 error() {722 This.$Modal.error({723 title: "æ示",724 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',725 });726 }727 })728 },729 //æ æºæ交(ä¿®æ¹)730 updateOfSubmitByNoSource() {731 let This = this;732 $.ajax({733 type: "post",734 url: contextPath + '/repairInOrderController/updateByNoSource',735 data: JSON.stringify(This.addBody),736 contentType: 'application/json;charset=utf-8',737 dataType: "json",738 success(data) {739 if (data.code === "100100") {740 // è°ç¨æ¹æ³ä¿åé件741 This.saveAccess(data.data.id, This.boeType);742 This.isEdit(This.addBody.status === 1 ? 'Y' : 'N');743 //ä¿®æ¹äººåæ¥æ744 //设置å¤æ³¨,ä¸å¡äººå,æ¥æä¸å¯ç¼è¾745 This.isUpdateShow = true;746 This.isAddShow = false;747 This.isView = true;748 This.htHaveChange = false;749 This.addBody.updateId = data.data.updateId;750 This.addBody.updateName = data.data.updateName;751 This.addBody.updateTime = data.data.updateTime;752 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;753 This.$Modal.success({754 title: "æ示",755 content: "æ交æå!"756 });757 } else {758 This.addBody.status = 1;759 This.$Modal.error({760 title: "æ示",761 content: "æ交失败!"762 });763 }764 },765 error() {766 This.$Modal.error({767 title: "æ示",768 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',769 });770 }771 })772 },773 //ææºæ交(ä¿®æ¹)774 updateOfSubmitBySource() {775 let This = this;776 $.ajax({777 type: "post",778 url: contextPath + '/repairInOrderController/update',779 data: JSON.stringify(This.addBody),780 contentType: 'application/json;charset=utf-8',781 dataType: "json",782 success(data) {783 if (data.code === "100100") {784 // è°ç¨æ¹æ³ä¿åé件785 This.saveAccess(data.data.id, This.boeType);786 This.isEdit(This.addBody.status === 1 ? 'Y' : 'N');787 //设置å¤æ³¨,ä¸å¡äººå,æ¥æä¸å¯ç¼è¾788 This.isUpdateShow = true;789 This.isAddShow = false;790 This.isView = true;791 This.htHaveChange = false;792 //ä¿®æ¹äººåæ¥æ793 This.addBody.updateId = data.data.updateId;794 This.addBody.updateName = data.data.updateName;795 This.addBody.updateTime = data.data.updateTime;796 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;797 This.$Modal.success({798 title: "æ示",799 content: "æ交æå!"800 });801 } else {802 This.addBody.status = 1;803 This.$Modal.error({804 title: "æ示",805 content: "æ交失败!"806 });807 }808 },809 error() {810 This.$Modal.error({811 title: "æ示",812 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',813 });814 }815 })816 },817 //åæ®åæ£éªå¤æ818 approvalCheck() {819 let This = this;820 let checkInfo = true;821 $.ajax({822 type: "post",823 async: false,824 url: contextPath + '/repairInOrderController/info',825 data: JSON.stringify(This.addBody),826 contentType: 'application/json;charset=utf-8',827 dataType: "json",828 success(data) {829 if (data.code === "100100") {830 if (data.data.repairInOrderDetailList != null) {831 data.data.repairInOrderDetailList.forEach((item) => {832 if (item.checkStatus == 1) {833 checkInfo = false;834 }835 })836 }837 } else {838 This.$Modal.error({839 title: "æ示",840 content: "ç³»ç»ç¹å¿ï¼"841 });842 }843 },844 error() {845 This.$Modal.error({846 title: "æ示",847 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',848 });849 }850 })851 return checkInfo;852 },853 // å®¡æ ¸854 approval() {855 //åæ®åæ£éªå¤æ856 let checkInfo = this.approvalCheck();857 if (checkInfo === false && this.stepList[1].currentLevel === 3) {858 this.$Modal.warning({859 title: "æ示",860 content: '请å
å®æææç»´ä¿®åæ£éªï¼',861 });862 return false;863 }864 this.modalType = 'approve';865 this.isShowApprove = !this.isShowApprove;866 },867 // 驳å868 reject() {869 this.modalType = 'reject';870 this.isShowApprove = !this.isShowApprove;871 },872 // å表跳转873 toList() {874 },875 //æ£éªä¿å876 saveCheck() {877 this.addBody.repairInOrderDetailList.map(el => {878 if (el.goodsCheckInfoAfter) {879 el.goodsCheckInfoAfter.checkResult = el.checkResult;880 }881 });882 let This = this;883 $.ajax({884 type: "post",885 url: contextPath + '/repairInOrderController/saveByCheck',886 data: JSON.stringify(This.addBody),887 contentType: 'application/json;charset=utf-8',888 dataType: "json",889 success(data) {890 if (data.code === "100100") {891 //ä¿®æ¹äººåæ¥æ892 This.addBody.updateId = data.data.updateId;893 This.addBody.updateName = data.data.updateName;894 This.addBody.updateTime = data.data.updateTime;895 This.addBody.repairInOrderDetailList = data.data.repairInOrderDetailList;896 This.tmpCheckItem = This.addBody.repairInOrderDetailList[This.selectedRow];897 //设置å½ååå½è¡æ£éªä¿¡æ¯ä¿®æ¹æ å¿898 This.goodsCheckAfter.isAdd = 2;899 This.addBody.repairInOrderDetailList.map(el => {900 if (el.goodsCheckInfoAfter) {901 el.checkResult = el.goodsCheckInfoAfter.checkResult;902 el.goodsCheckInfoAfter.isAdd = 2;903 }904 });905 This.$Modal.success({906 title: "æ示",907 content: "ä¿åæå!"908 });909 } else {910 This.$Modal.error({911 title: "æ示",912 content: "ä¿å失败!"913 });914 }915 },916 error() {917 This.$Modal.error({918 title: "æ示",919 content: 'ç½ç»é误ï¼è¯·èç³»ææ¯äººå',920 });921 }922 })923 },924 /*****************æé®æ ç»æ********************/925 /****************** åºæ¬ä¿¡æ¯é¨åå¼å§***************/926 changeType(e) {927 console.log(e);928 if (e == 2) {929 this.addBody.custName = '';930 this.addBody.custId = '';931 this.addBody.custNo = '';932 this.checkName = 'no'933 this.$refs.customerRef.clear();934 this.addBody.repairInOrderDetailList.map(el => {935 el.billFee = "";936 })937 } else {938 this.checkName = 'customerModel'939 }940 },941 // éæ©ååç±»å942 changeProductType(e) {943 if (this.isView) return;944 let res = e.value === this.addBody.goodsType;945 if (!res) {946 this.addBody.repairInOrderDetailList = [];947 }948 this.addBody.goodsType = e.value;949 this.addBody.goodsTypeName = e.label;950 this.htTestChange();951 this.addBody.groupPath = e.__value.replace(/\,/g, '-');952 },953 // éåä¸å¡å954 getSaleMan(e) {955 let le = e.label;956 this.addBody.saleMenName = le.substring(le.lastIndexOf("-") + 1, le.length);957 this.addBody.saleMenId = e.value;958 },959 closeSupplier(id, code, name) {960 this.addBody.supplierId = id;961 this.addBody.supplierName = name;962 this.addBody.supplierCode = code;963 },964 closeCustomer() {965 if (this.selectCustomerObj) {966 this.addBody.custId = this.selectCustomerObj.id;967 this.addBody.custName = this.selectCustomerObj.name;968 this.addBody.custNo = this.selectCustomerObj.code;969 }970 },971 /****************** åºæ¬ä¿¡æ¯é¨åç»æ***************/972 /*******************å®¡æ ¸ä¿¡æ¯å¼å§***********/973 //å®¡æ ¸æè
驳ååè°974 approvalOrRejectCallBack(res) {975 if (res.result.code === '100515') {976 if (this.modalType === 'reject') {977 // ä¿®æ¹è®¢åç¶æ为 1978 this.updateData(this.addBody.inOrderNo, 1);979 } else {980 // ä¿®æ¹è®¢åç¶æ为 4981 this.updateData(this.addBody.inOrderNo, 4);982 }983 }984 if (res.result.code === '100100') {985 let data = res.result.data;986 this.addBody.status = data.status;987 this.addBody.updateName = data.updateName;988 this.addBody.updateTime = data.updateTime;989 //åæ®å·²å®¡æ ¸990 if (this.addBody.status === 4) {991 this.addBody.auditName = data.auditName;992 this.addBody.auditTime = data.auditTime;993 this.isDifference = true;994 }995 //åæ®é©³åå°æå996 if (this.addBody.status === 1) {997 if (this.addBody.repairInOrderDetailList[0].sourceNo != null && this.addBody.repairInOrderDetailList[0].sourceNo != "") {998 //ææº999 this.isView = true;1000 } else {1001 //æ æº1002 this.isView = false;1003 this.isAddShow = true;1004 }1005 this.addBody.dataStatus = 1;1006 this.showTab();1007 }1008 }1009 //æ¥æ¾é件1010 this.isEdit(this.addBody.status === 1 ? 'Y' : 'N');1011 },1012 //æ´æ°æ°æ®1013 updateData(code, status) {1014 let This = this;1015 $.ajax({1016 type: "POST",1017 contentType: 'application/json',1018 url: contextPath + "/repairInOrderController/updateInOrder",1019 data: JSON.stringify({ inOrderNo: code, status: status }),1020 dataType: "json",1021 success: function (data) {1022 var msg = "å®¡æ ¸"1023 if (status === 1) {1024 msg = "驳å";1025 }1026 if (data.code === "100100") {1027 This.$Modal.success({1028 title: "æ示",1029 content: msg + "æå!"1030 });1031 This.addBody.status = data.data.status;1032 This.addBody.updateName = data.data.updateName;1033 This.addBody.updateTime = data.data.updateTime;1034 This.addBody.auditName = data.data.auditName;1035 This.addBody.auditTime = data.data.auditTime;1036 //驳åå°æå1037 if (This.addBody.status === 1) {1038 //é件1039 This.isEdit('Y');1040 if (This.addBody.repairInOrderDetailList[0].sourceNo != null && This.addBody.repairInOrderDetailList[0].sourceNo != "") {1041 //ææº1042 This.isView = true;1043 } else {1044 //æ æº1045 This.isView = false;1046 This.isAddShow = true;1047 }1048 This.showTab();1049 }1050 } else {1051 This.$Modal.error({1052 title: "æ示",1053 content: msg + "失败!"1054 });1055 }1056 },1057 error: function (err) {1058 This.$Modal.warning({1059 title: "æ示",1060 content: "æå¡å¨åºé"1061 });1062 }1063 })1064 },1065 /*******************å®¡æ ¸ä¿¡æ¯ç»æ***********/1066 /*******************åå½è¡é¨åå¼å§*********************/1067 // åå½è¡éä¸è¡1068 selectedTr(index) {1069 this.selectedRow = index;1070 },1071 // æ°åæ ¡éª1072 clearNoNum(item, type, floor) {1073 return htInputNumber(item, type, floor);1074 },1075 // ååç»ä»¶ä¸ææ¡æ ·å¼1076 repositionDropdown() {1077 return repositionDropdownOnSroll('testTableWrap', 'goods');1078 },1079 // 计ç®åå计1080 sum(list, key) {1081 return list.reduce((total, el) => {1082 if (el[key] === '' || el[key] === null || el[key] == undefined) {1083 return 0 + total;1084 };1085 if (isNaN(el[key])) {1086 this.$Modal.warning({1087 content: '请è¾å
¥æ°å'1088 });1089 el[key] = ''1090 return 0 + total;1091 }1092 return parseFloat(el[key]) + total;1093 }, 0)1094 },1095 // æ°å¢è¡1096 addRow(list, obj) {1097 if (!this.addBody.goodsType) {1098 this.$Modal.warning({1099 title: "æ示",1100 okText: "ç¡®å®",1101 content: "请éæ©ååç±»å!"1102 });1103 return;1104 }1105 list.push(Object.assign({}, obj, { options: this.commodityList }))1106 },1107 // å é¤è¡1108 delRow(list, selected) {1109 list.splice(selected, 1);1110 this.htHaveChange = true;1111 this.selectedRow = '';1112 },1113 // éæ©ååè¾å
¥ç¼ç 1114 getInputValue(value, index) {//è·åè¾å
¥æ¡è¾å
¥çå¼1115 let that = this;1116 let params = {1117 categoryCustomCode: that.addBody.goodsType,1118 field: value, //value, A11 AABc0091119 limit: ''1120 };1121 $.ajax({1122 type: "post",1123 url: contextPath + '/tbasecommodity/findByType',1124 data: params,1125 dataType: "json",1126 success: function (data) {1127 if (data.code === '100100' && data.data) {1128 that.$set(that.addBody.repairInOrderDetailList[index], 'options', data.data);1129 }1130 },1131 error: function () {1132 this.$Modal.error({1133 content: 'æå¡å¨åºéå¦'1134 });1135 }1136 })1137 },1138 getSelectedItem(data, index) {1139 let that = this;1140 console.log(data);1141 let res = data.data;1142 res.countUnit = that.unitMap[res.countUnitId];1143 res.weightUnit = that.unitMap[res.weightUnitId];1144 Object.assign(that.addBody.repairInOrderDetailList[index], {1145 goodsCode: res.code,//ååç¼ç 1146 goodsName: res.name,//ååå称1147 commodityId: res.id,//ååid1148 pictureUrl: res.frontPic && res.frontPic.fdUrl,//å¾çè·¯å¾1149 goodsTypeName: res.categoryName,// ååç±»åå称1150 goodsType: res.categoryCustomCode,//ååç±»åcode1151 custStyleCode: res.styleCustomCode,//åå款å¼code1152 custStyleName: res.styleName,//款å¼ç±»å«å称1153 styleCategoryId: res.styleCategoryId,//款å¼ç±»å«id1154 goodsMainType: res.mainType,//åå主类å1155 specification: res.specification,//è§æ ¼1156 countingUnit: res.countUnit,//计æ°åä½1157 countingUnitId: res.countUnitId,//计æ°åä½id1158 weightUnitId: res.weightUnitId,//计éåä½id1159 weightUnit: res.weightUnit,//计éåä½1160 warehouseId: res.repertoryPositionId,//é»è®¤å¾
æ£ä»1161 pricingMethod: res.pricingType,1162 });1163 that.$forceUpdate();1164 },1165 //åå½è¡å·®å¼å¯¹æ¯è·³è½¬é¡µç¾1166 changeTab(item, index) {1167 if (this.addBody.status === 1 || this.addBody.status === '') {1168 return false;1169 }1170 this.tabName = "difference";1171 // åå½è¡æ£éªç»æ1172 this.tmpCheckItem = item;1173 //设置差å¼å¯¹æ¯ä¿¡æ¯1174 this.repairRegisterGoods = Object.assign({}, item.repairRegisterGoods);1175 if (item.sourceType !== null && item.sourceType != "") {1176 //ææº1177 if (item.goodsCheckInfo !== null) {1178 //ç»´ä¿®åæ£éªä¿¡æ¯ææ°æ®1179 this.isShow = true;1180 this.goodsCheckInfo = Object.assign({}, item.goodsCheckInfo);1181 } else {1182 //ç»´ä¿®åæ£éªä¿¡æ¯æ²¡ææ°æ®1183 this.isShow = false;1184 this.goodsCheckInfo = Object.assign({}, item);1185 }1186 } else {1187 this.isShow = false;1188 this.goodsCheckInfo = Object.assign({}, item);1189 }1190 if (item.goodsCheckInfoAfter !== null) {1191 if ($.isEmptyObject(item.goodsCheckInfoAfter)) {1192 //æ交æ¶1193 this.goodsCheckAfter = item;1194 this.goodsCheckAfter.isAdd = 1;1195 } else {1196 //éæ°è¿å
¥æ¶1197 this.goodsCheckAfter = item.goodsCheckInfoAfter;1198 if (this.goodsCheckAfter.id === null || this.goodsCheckAfter.id === "") {1199 this.goodsCheckAfter.isAdd = 1;1200 } else {1201 this.goodsCheckAfter.isAdd = 2;1202 }1203 //è´¨æ£ç»ææå¼,é£ä¹å·®å¼å¯¹æ¯ææä¸å¯ç¼è¾1204 if (this.goodsCheckAfter.checkResult === 1) {1205 this.resultDisable = true;1206 }1207 }1208 } else {1209 this.goodsCheckAfter = Object.assign({}, item);1210 this.goodsCheckAfter.id = null;1211 this.goodsCheckAfter.isAdd = 1;1212 item.goodsCheckInfoAfter = this.goodsCheckAfter;1213 }1214 },1215 //åå½è¡é¡µç¾è·³è½¬1216 showTab() {1217 if (this.tabName = "difference") {1218 this.tabName = "detail";1219 }1220 this.resultDisable = false;1221 },1222 //éæ°å½å
¥ç»´ä¿®åæ£éªä¿¡æ¯1223 reSetCheckInfo() {1224 console.log(this.addBody.repairInOrderDetailList[this.selectedRow]);1225 let obj = Object.assign({}, this.addBody.repairInOrderDetailList[this.selectedRow])1226 delete obj.goodsCheckInfoAfter;1227 this.goodsCheckAfter = obj;1228 this.addBody.repairInOrderDetailList[this.selectedRow].goodsCheckInfoAfter = this.goodsCheckAfter;1229 this.goodsCheckAfter.isAdd = 1;1230 this.addBody.repairInOrderDetailList[this.selectedRow].checkResult = '';1231 this.addBody.repairInOrderDetailList[this.selectedRow].goodsCheckInfoAfter.checkResult = '';1232 },1233 //1234 getCheckResult(e) {1235 console.log(e);1236 if (e === undefined) {1237 this.addBody.repairInOrderDetailList[this.selectedRow].checkResult = '';1238 this.addBody.repairInOrderDetailList[this.selectedRow].checkStatus = 1;1239 this.addBody.repairInOrderDetailList[this.selectedRow].goodsCheckInfoAfter.checkResult = '';1240 this.addBody.repairInOrderDetailList[this.selectedRow].goodsCheckInfoAfter.checkStatus = 1;1241 } else {1242 this.addBody.repairInOrderDetailList[this.selectedRow].goodsCheckInfoAfter.checkResult = this.addBody.repairInOrderDetailList[this.selectedRow].checkResult;1243 this.addBody.repairInOrderDetailList[this.selectedRow].checkStatus = 2;1244 this.addBody.repairInOrderDetailList[this.selectedRow].goodsCheckInfoAfter.checkStatus = 2;1245 this.addBody.repairInOrderDetailList[this.selectedRow].checkResult = 1;1246 this.addBody.repairInOrderDetailList[this.selectedRow].goodsCheckInfoAfter.checkResult = 1;1247 }1248 },1249 /*******************åå½è¡é¨åç»æ*********************/1250 /*******************åå§åæ°æ®å¼å§******************/1251 //跳转维修ååºå1252 jumpOutOrder(documentNo) {1253 window.parent.activeEvent({1254 name: 'ç»´ä¿®ååºå-æ¥ç',1255 url: contextPath + '/repair/sendout/sendout-form.html',1256 params: { outOrderNo: documentNo, type: 'update' }1257 });1258 },1259 //跳转维修ç»è®°å1260 jumpRegister(documentNo) {1261 window.parent.activeEvent({1262 name: 'ç»´ä¿®ååºå-æ¥ç',1263 url: contextPath + '/repair/registration/registration-form.html',1264 params: { repairRegisterNo: documentNo, type: 'view' }1265 });1266 },1267 // è·ååºæ¬ä¿¡æ¯ç»è®°äºº1268 getEmployees() {1269 var This = this;1270 $.ajax({1271 type: "post",1272 url: contextPath + '/tpurchasecollectgoods/data',1273 dataType: "json",1274 success: function (r) {1275 if (r.code === "100100") {1276 This.employees = r.data.employees; //å è½½å½åå
¬å¸ä¸é¢ææçåå·¥1277 }1278 },1279 error: function (err) {1280 This.$Modal.error({1281 context: "ç³»ç»åºç°å¼å¸¸,请è系管ç人å"1282 });1283 },1284 })1285 },1286 // åå§ååååä½1287 getUnit() {1288 let that = this;1289 $.ajax({1290 type: 'post',1291 url: contextPath + '/tbaseunit/list',1292 dataType: 'json',1293 success(res) {1294 if (res.code === '100100') {1295 let data = res.data;1296 data.map(item => {1297 let keyStr = item.id;1298 let value = item.name;1299 that.unitMap[keyStr] = value;1300 })1301 }1302 },1303 error() {1304 that.$Message.error('æå¡å¨æ¥é')1305 }1306 })1307 },1308 // åå§ååå½è¡ååä¸æçå¼1309 getCommodityList() {1310 let This = this;1311 let params = {1312 categoryCustomCode: This.addBody.goodsType,1313 field: '',1314 limit: ''1315 };1316 $.ajax({1317 type: "post",1318 url: contextPath + '/tbasecommodity/findByType',1319 data: params,1320 dataType: "json",1321 success: function (data) {1322 if (data.code !== "100100") {1323 this.$Modal.error({1324 content: data.msg,1325 });1326 return;1327 }1328 This.commodityList = data.data;1329 },1330 error: function () {1331 this.$Modal.error({1332 content: "ç½ç»å¼å¸¸,请èç³»ææ¯äººåï¼",1333 })1334 }1335 })1336 },1337 // éåº1338 exit(close) {1339 if(close === true){1340 window.parent.closeCurrentTab({exit: true, openTime: this.openTime});1341 return;1342 }1343 if(this.handlerClose()){1344 window.parent.closeCurrentTab({exit: true, openTime: this.openTime});1345 }1346 },1347 //æ¥æ¶ä¼ å
¥çåæ°1348 getInputParams() {1349 this.inParams = window.parent.params.params;1350 this.openName = window.parent.params.name;1351 this.openTime = window.parent.params.openTime;1352 },1353 //è·å并设置å½åç»ç»1354 getOrganization() {1355 let This = this;1356 $.ajax({1357 type: "POST",1358 async: false,1359 url: contextPath + "/saleBillController/getOrganization",1360 contentType: 'application/json',1361 dataType: "json",1362 success: function (data) {1363 if (data.code === "100100") {1364 This.organ = data.data;1365 } else {1366 This.$Modal.error({1367 title: "æ示",1368 content: "è·åç»ç»ä¿¡æ¯å¼å¸¸,请è系管çå!"1369 });1370 }1371 },1372 error: function (err) {1373 This.$Modal.error({1374 title: "æ示",1375 content: "æå¡å¨åºé!"1376 });1377 }1378 });1379 },1380 //æ ¹æ®æºåç¼å·è·åååæç»1381 getDetailBySource() {1382 let This = this;1383 let outOrderNos = [];1384 this.inParams.data.forEach((item) => {1385 outOrderNos.push(item.outOrderNo);1386 });1387 console.log(outOrderNos, "ååºåç¼å·list=========");1388 $.ajax({1389 type: "POST",1390 async: false,1391 url: contextPath + "/repairInOrderController/getDetailBySource",1392 contentType: 'application/json',1393 data: JSON.stringify(outOrderNos),1394 dataType: "json",1395 success: function (data) {1396 if (data.code === "100100") {1397 This.addBody.repairInOrderDetailList = data.data;1398 This.addBody.repairInOrderDetailList.forEach((item) => {1399 if (item.sourceNo !== null && item.sourceNo !== undefined) {1400 item.sourceType = 'ç»´ä¿®ååºå';1401 }1402 });1403 } else {1404 This.$Modal.error({1405 title: "æ示",1406 content: "ç³»ç»å¼å¸¸,请ç¨ååè¯!"1407 });1408 }1409 },1410 error: function (err) {1411 This.$Modal.error({1412 title: "æ示",1413 content: "æå¡å¨åºé!"1414 });1415 }1416 });1417 },1418 //è·åæ°æ®1419 getInfo() {1420 let This = this;1421 $.ajax({1422 type: "POST",1423 async: false,1424 url: contextPath + "/repairInOrderController/info",1425 contentType: 'application/json',1426 data: JSON.stringify({ inOrderNo: This.inParams.inOrderNo }),1427 dataType: "json",1428 success: function (data) {1429 if (data.code === "100100") {1430 This.addBody = data.data;1431 if(This.addBody.repairInOrderDetailList!=null){1432 This.addBody.repairInOrderDetailList.forEach((item) => {1433 if (item.sourceNo !== null && item.sourceNo !== undefined) {1434 item.sourceType = 'ç»´ä¿®ååºå';1435 }1436 if (item.goodsCheckInfoAfter !== null) {1437 item.goodsCheckInfoAfter.isAdd = 2;1438 }1439 });1440 }1441 } else {1442 This.$Modal.error({1443 title: "æ示",1444 content: "ç³»ç»å¼å¸¸,请ç¨ååè¯!"1445 });1446 }1447 },1448 error: function (err) {1449 This.$Modal.error({1450 title: "æ示",1451 content: "æå¡å¨åºé!"1452 });1453 }1454 });1455 },1456 /*******************åå§åæ°æ®ç»æ******************/1457 handlerClose(){1458 if((!this.addBody.status || this.addBody.status == 1)&& (this.htHaveChange || accessVm.htHaveChange)){1459 this.$nextTick(()=>{1460 this.$refs.closeModalRef.showCloseModal();1461 });1462 return false;1463 }1464 return true;1465 },1466 htTestChange(){1467 this.htHaveChange = true;1468 console.log(333)1469 },1470 closeModal(type){1471 if(type === 'yes'){//æ交æ°æ®1472 this.save();1473 this.exit(true);1474 }else if(type === 'no'){//å
³é页é¢1475 this.exit(true);1476 }1477 }1478 },1479 computed: {1480 typeValue: function () {1481 let temp = this.addBody.goodsType;1482 let arr = [];1483 this.typeInit(this.productTypeList, arr, temp);1484 return arr.reverse();1485 },1486 totalPayable: function () {1487 return this.addBody.totalPayable = this.sum(this.addBody.repairInOrderDetailList, 'repairFee')1488 },1489 totalReceivable: function () {1490 return this.addBody.totalReceivable = this.sum(this.addBody.repairInOrderDetailList, 'billFee')1491 },1492 totalNum: function () {1493 return this.addBody.num = this.sum(this.addBody.repairInOrderDetailList, 'goodsNum')1494 },1495 totalWeight: function () {1496 return this.addBody.totalWeight = this.sum(this.addBody.repairInOrderDetailList, 'totalWeight')1497 },1498 },1499 created() {1500 window.handlerClose = this.handlerClose;1501 },1502 mounted() {1503 this.repositionDropdown();1504 // $('form').validate();1505 //æ¥æ¶ä¼ å
¥çåæ°1506 this.getInputParams();1507 this.getEmployees();//è·ååºæ¬ä¿¡æ¯ç»è®°äºº1508 this.getUnit();//è·ååå½è¡åååä½1509 this.goldColor = getCodeList('base_Condition');//è·ååå½è¡éææè²ä¸ææ°æ®1510 this.getCommodityList();//è·ååå½è¡ååä¸ææ°æ®1511 //æ¥çæä¿®æ¹1512 if (this.inParams.type === "update") {1513 //è·åæ°æ®1514 this.getInfo();1515 //æ¯å¦æ¾ç¤ºé件ä¸ä¼ æé®1516 this.isEdit(this.addBody.status === 1 ? 'Y' : 'N');1517 this.getAccess(this.addBody.id, this.boeType);1518 this.$refs.supplier.haveInitValue(this.addBody.supplierName, this.addBody.supplierId);1519 this.$refs.customerRef.loadCustomerList(this.addBody.custName, this.addBody.custId);1520 if (this.addBody.status !== 1) {1521 this.isView = true;1522 this.isDifference = this.addBody.status === 4 ? true : false;1523 } else {1524 //æ¾ç¤ºæ°å¢è¡1525 this.isAddShow = true;1526 if (this.addBody.repairInOrderDetailList !== null) {1527 let sourceNo;1528 this.addBody.repairInOrderDetailList.forEach((item) => {1529 sourceNo = item.sourceNo;1530 if (item.goodsCheckInfoAfter !== null) {1531 item.checkResult = item.goodsCheckInfoAfter.checkResult;1532 item.checkStatus = item.goodsCheckInfoAfter.checkStatus;1533 }1534 });1535 if (sourceNo !== null && sourceNo !== undefined && sourceNo !== "") {1536 this.isView = true;1537 this.isAddShow = false;1538 this.isRemarkView = true;1539 }1540 }1541 }1542 }1543 //æ°å¢1544 if (this.inParams.type === "add") {1545 //è·å并设置å½åç»ç»1546 this.getOrganization();1547 //æ¾ç¤ºé件ä¸ä¼ æé®1548 this.isEdit('Y');1549 //æ¥æ设置é»è®¤å½åæ¥æ1550 this.addBody.returnTime = new Date().format("yyyy-MM-dd HH:mm:ss");1551 //æå¨æ°å¢(æ æº)1552 if (this.inParams.data === null || this.inParams.data === undefined) {1553 //æ¾ç¤ºæ°å¢åå é¤è¡1554 this.isAddShow = true;1555 this.$refs.customerRef.loadCustomerList('', '');1556 this.$refs.supplier.noInitValue();1557 } else {1558 //ææº1559 console.log(this.inParams.data);1560 //ååç±»å1561 this.addBody.goodsType = this.inParams.data[0].goodsType;1562 this.addBody.goodsTypeName = this.inParams.data[0].goodsTypeName;1563 this.addBody.groupPath = this.inParams.data[0].groupPath;1564 //客æ·1565 this.isCustView = true;1566 this.addBody.custId = this.inParams.data[0].custId;1567 this.addBody.custName = this.inParams.data[0].custName;1568 this.addBody.custNo = this.inParams.data[0].custNo;1569 //ç»´ä¿®å家1570 this.addBody.supplierId = this.inParams.data[0].supplierId;1571 this.addBody.supplierName = this.inParams.data[0].supplierName;1572 this.addBody.supplierCode = this.inParams.data[0].supplierCode;1573 this.$refs.supplier.haveInitValue(this.addBody.supplierName, this.addBody.supplierId);1574 this.$refs.customerRef.loadCustomerList(this.addBody.custName, this.addBody.custId);1575 //ä¸å¡ç±»å1576 this.addBody.businessType = this.inParams.data[0].businessType;1577 this.isView = true;1578 this.isRemarkView = true;1579 //æ ¹æ®æºåç¼å·è·åååæç»1580 this.getDetailBySource();1581 }1582 // æ°æ®åå§å1583 this.addBody.status = 1;1584 //设置å½åç»ç»1585 this.addBody.organizationName = this.organ.currentOrganization.orgName;1586 this.addBody.organizationId = this.organ.userCurrentOrganId;1587 }1588 }...
teststeps.js
Source:teststeps.js
1function TestStep (viewer, mode, step, info)2{3 var current = 0;4 ClearViewer (viewer, mode, info);5 6 if (step == current++) {7 var body = JSM.GenerateCuboid (1, 1, 1);8 AddBodyToViewer (viewer, mode, body, null, info);9 }10 11 if (step == current++) {12 var materials = new JSM.MaterialSet ();13 materials.AddMaterial (new JSM.Material ({ambient : 0x008ab8, diffuse : 0x008ab8}));14 var body = JSM.GenerateCuboid (1, 1, 1);15 body.SetPolygonsMaterialIndex (0); 16 AddBodyToViewer (viewer, mode, body, materials, info);17 }18 19 if (step == current++) {20 var materials = new JSM.MaterialSet ();21 materials.AddMaterial (new JSM.Material ({ambient : 0xffffff, diffuse : 0xffffff, specular : 0x000000, shininess : 0.0, opacity : 1.0, texture : 'testfiles/texture.png'}));22 var body = JSM.GenerateCuboid (1, 1, 1);23 body.SetPolygonsMaterialIndex (0); 24 AddBodyToViewer (viewer, mode, body, materials, info);25 }26 27 if (step == current++) {28 var materials = new JSM.MaterialSet ();29 materials.AddMaterial (new JSM.Material ({ambient : 0xffffff, diffuse : 0xffffff, specular : 0x000000, shininess : 0.0, opacity : 1.0, texture : 'testfiles/texture.png', textureWidth : 0.5, textureHeight : 0.3}));30 var body = JSM.GenerateCuboid (1, 1, 1);31 body.SetPolygonsMaterialIndex (0); 32 AddBodyToViewer (viewer, mode, body, materials, info);33 }34 35 if (step == current++) {36 var materials = new JSM.MaterialSet ();37 materials.AddMaterial (new JSM.Material ({ambient : 0x993333, diffuse : 0x993333}));38 materials.AddMaterial (new JSM.Material ({ambient : 0x008ab8, diffuse : 0x008ab8}));39 var body = JSM.GenerateCuboid (1, 1, 1);40 body.GetPolygon (3).SetMaterialIndex (0); 41 body.GetPolygon (5).SetMaterialIndex (1); 42 AddBodyToViewer (viewer, mode, body, materials, info);43 }44 45 if (step == current++) {46 var model = new JSM.Model ();47 model.AddMaterial (new JSM.Material ({ambient : 0x008ab8, diffuse : 0x008ab8}));48 var body1 = JSM.GenerateCuboid (1, 1, 1);49 var body2 = JSM.GenerateCuboid (1, 1, 1);50 body2.SetPolygonsMaterialIndex (0);51 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);52 model.AddBody (body1);53 model.AddBody (body2);54 AddModelToViewer (viewer, mode, model, info);55 }56 57 if (step == current++) {58 var model = new JSM.Model ();59 model.AddMaterial (new JSM.Material ({ambient : 0x008ab8, diffuse : 0x008ab8}));60 var body1 = JSM.GenerateCuboid (1, 1, 1);61 var body2 = JSM.GenerateCuboid (1, 1, 1);62 body2.SetPolygonsMaterialIndex (0);63 body2.Transform (new JSM.RotationTransformation (new JSM.Coord (1.0, 0.0, 0.0), 45.0 * JSM.DegRad));64 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);65 66 model.AddBody (body1);67 model.AddBody (body2);68 AddModelToViewer (viewer, mode, model, info);69 }70 71 if (step == current++) {72 var model = new JSM.Model ();73 model.AddMaterial (new JSM.Material ({ambient : 0x008ab8, diffuse : 0x008ab8}));74 model.AddMaterial (new JSM.Material ({ambient : 0xffffff, diffuse : 0xffffff, specular : 0x000000, shininess : 0.0, opacity : 1.0, texture : 'testfiles/texture.png'}));75 var body1 = JSM.GenerateCuboid (1, 1, 1);76 var body2 = JSM.GenerateCuboid (1, 1, 1);77 body2.SetPolygonsMaterialIndex (0);78 79 var body3 = JSM.GenerateCuboid (1, 1, 1);80 body3.SetPolygonsMaterialIndex (1); 81 OffsetTwoBodies (body1, body3, 1.2, 0.0, 0.0);82 model.AddBody (body1);83 model.AddBody (body2);84 model.AddBody (body3);85 AddModelToViewer (viewer, mode, model, info);86 }87 if (step == current++) {88 var model = new JSM.Model ();89 90 var body1 = JSM.GenerateCuboid (1, 1, 1);91 var body2 = JSM.GenerateCuboid (1.2, 1.4, 1.6);92 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);93 94 model.AddBody (body1);95 model.AddBody (body2);96 AddModelToViewer (viewer, mode, model, info);97 }98 99 if (step == current++) {100 var model = new JSM.Model ();101 102 var body1 = JSM.GenerateSphere (0.5, 20, true);103 var body2 = JSM.GenerateSphere (0.6, 6, false);104 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);105 106 model.AddBody (body1);107 model.AddBody (body2);108 AddModelToViewer (viewer, mode, model, info);109 }110 if (step == current++) {111 var model = new JSM.Model ();112 113 var body1 = JSM.GenerateTriangulatedSphere (0.5, 3, true);114 var body2 = JSM.GenerateTriangulatedSphere (0.6, 2, false);115 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);116 117 model.AddBody (body1);118 model.AddBody (body2);119 AddModelToViewer (viewer, mode, model, info);120 }121 if (step == current++) {122 var model = new JSM.Model ();123 124 var body1 = JSM.GenerateCylinder (0.5, 1.0, 20, true, true);125 var body2 = JSM.GenerateCylinder (0.6, 1.2, 15, false, false);126 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);127 128 model.AddBody (body1);129 model.AddBody (body2);130 AddModelToViewer (viewer, mode, model, info);131 }132 if (step == current++) {133 var model = new JSM.Model ();134 135 var body1 = JSM.GeneratePie (0.5, 0.2, 250.0 * JSM.DegRad, 20, true, true);136 var body2 = JSM.GeneratePie (0.6, 0.4, 220.0 * JSM.DegRad, 15, false, false);137 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);138 139 model.AddBody (body1);140 model.AddBody (body2);141 AddModelToViewer (viewer, mode, model, info);142 }143 if (step == current++) {144 var model = new JSM.Model ();145 146 var body1 = JSM.GenerateCone (0.2, 0.5, 1.0, 20, true, true);147 var body2 = JSM.GenerateCone (0.6, 0.3, 1.2, 15, false, false);148 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);149 150 model.AddBody (body1);151 model.AddBody (body2);152 AddModelToViewer (viewer, mode, model, info);153 }154 if (step == current++) {155 var model = new JSM.Model ();156 157 var body1 = JSM.GenerateCone (0.0, 0.5, 1.0, 20, true, true);158 var body2 = JSM.GenerateCone (0.6, 0.0, 1.2, 15, false, false);159 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);160 161 model.AddBody (body1);162 model.AddBody (body2);163 AddModelToViewer (viewer, mode, model, info);164 }165 if (step == current++) {166 var model = new JSM.Model ();167 168 var basePolygon = [169 new JSM.Coord (-0.5, -0.5, 0.0),170 new JSM.Coord (0.5, -0.5, 0.0),171 new JSM.Coord (0.5, 0.5, 0.0),172 new JSM.Coord (0.0, 0.5, 0.0),173 new JSM.Coord (0.0, 0.0, 0.0),174 new JSM.Coord (-0.5, 0.0, 0.0)175 ];176 var direction = new JSM.Coord (0.0, 0.0, 1.0);177 178 var body1 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null);179 var body2 = JSM.GeneratePrism (basePolygon, direction, 1.2, false, null);180 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);181 182 model.AddBody (body1);183 model.AddBody (body2);184 AddModelToViewer (viewer, mode, model, info);185 }186 187 if (step == current++) {188 var model = new JSM.Model ();189 var basePoints = [190 new JSM.Coord (0, 0, 0),191 new JSM.Coord (7, 0, 0),192 new JSM.Coord (7, 3, 0),193 new JSM.Coord (0, 3, 0),194 null,195 new JSM.Coord (1, 1, 0),196 new JSM.Coord (1, 2, 0),197 new JSM.Coord (2, 2, 0),198 null,199 new JSM.Coord (3, 1, 0),200 new JSM.Coord (3, 2, 0),201 new JSM.Coord (4, 2, 0),202 new JSM.Coord (4, 1, 0),203 null,204 new JSM.Coord (5, 1, 0),205 new JSM.Coord (5, 2, 0),206 new JSM.Coord (6, 2, 0),207 new JSM.Coord (6, 1, 0),208 new JSM.Coord (5.5, 1.5, 0)209 ];210 var basePoints = [211 new JSM.Coord (0, 0, 0),212 new JSM.Coord (3.5, 0, 0),213 new JSM.Coord (3.5, 1.5, 0),214 new JSM.Coord (0, 1.5, 0),215 null,216 new JSM.Coord (0.5, 0.5, 0),217 new JSM.Coord (0.5, 1, 0),218 new JSM.Coord (1, 1, 0),219 null,220 new JSM.Coord (1.5, 0.5, 0),221 new JSM.Coord (1.5, 1, 0),222 new JSM.Coord (2, 1, 0),223 new JSM.Coord (2, 0.5, 0),224 null,225 new JSM.Coord (2.5, 0.5, 0),226 new JSM.Coord (2.5, 1, 0),227 new JSM.Coord (3, 1, 0),228 new JSM.Coord (3, 0.5, 0),229 new JSM.Coord (2.75, 0.75, 0)230 ];231 232 var direction = new JSM.Vector (0.0, 0.0, 1.0);233 var body1 = JSM.GeneratePrismWithHole (basePoints, direction, 0.3, true);234 body1.OffsetToOrigo ();235 236 model.AddBody (body1);237 AddModelToViewer (viewer, mode, model, info);238 }239 if (step == current++) {240 var model = new JSM.Model ();241 242 var basePolygon = [243 new JSM.Coord (-0.5, -0.5, 0.0),244 new JSM.Coord (0.5, -0.5, 0.0),245 new JSM.Coord (0.5, 0.5, 0.0),246 new JSM.Coord (0.0, 0.5, 0.0),247 new JSM.Coord (0.0, 0.0, 0.0),248 new JSM.Coord (-0.5, 0.0, 0.0)249 ];250 var direction = new JSM.Coord (0.0, 0.0, 1.0);251 252 var body1 = JSM.GeneratePrismShell (basePolygon, direction, 1.0, 0.1, true);253 var body2 = JSM.GeneratePrismShell (basePolygon, direction, 1.2, 0.2, false);254 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);255 256 model.AddBody (body1);257 model.AddBody (body2);258 AddModelToViewer (viewer, mode, model, info);259 }260 if (step == current++) {261 var model = new JSM.Model ();262 263 var body1 = JSM.GenerateCylinderShell (0.5, 1.0, 0.1, 20, true, true);264 var body2 = JSM.GenerateCylinderShell (0.6, 1.2, 0.2, 15, false, false);265 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);266 267 model.AddBody (body1);268 model.AddBody (body2);269 AddModelToViewer (viewer, mode, model, info);270 }271 if (step == current++) {272 var model = new JSM.Model ();273 274 var basePolygon = [275 new JSM.Coord (-0.5, -0.5, 0.0),276 new JSM.Coord (0.5, -0.5, 0.0),277 new JSM.Coord (0.5, 0.5, 0.0),278 new JSM.Coord (0.0, 0.5, 0.0),279 new JSM.Coord (0.0, 0.0, 0.0),280 new JSM.Coord (-0.5, 0.0, 0.0)281 ];282 var direction = new JSM.Coord (0.0, 0.0, 1.0);283 284 var body1 = JSM.GenerateLineShell (basePolygon, direction, 1.0, 0.1, true, true);285 var body2 = JSM.GenerateLineShell (basePolygon, direction, 1.2, 0.2, false, false);286 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);287 288 model.AddBody (body1);289 model.AddBody (body2);290 AddModelToViewer (viewer, mode, model, info);291 }292 if (step == current++) {293 var model = new JSM.Model ();294 295 var body1 = JSM.GenerateTorus (0.3, 0.2, 25, 25, true);296 var body2 = JSM.GenerateTorus (0.4, 0.3, 15, 15, false);297 OffsetTwoBodies (body1, body2, 0.7, 0.0, 0.0);298 299 model.AddBody (body1);300 model.AddBody (body2);301 AddModelToViewer (viewer, mode, model, info);302 }303 304 if (step == current++) {305 var model = new JSM.Model ();306 var basePolygon = [307 new JSM.Coord (-0.2, -0.2, 0.0),308 new JSM.Coord (0.2, -0.2, 0.0),309 new JSM.Coord (0.2, 0.1, 0.0),310 new JSM.Coord (0.0, 0.1, 0.0),311 new JSM.Coord (0.0, 0.0, 0.0),312 new JSM.Coord (-0.2, 0.0, 0.0)313 ];314 315 var body1 = JSM.GeneratePolyTorus (basePolygon, 0.3, 25, true);316 var body2 = JSM.GeneratePolyTorus (basePolygon, 0.4, 15, false);317 OffsetTwoBodies (body1, body2, 0.7, 0.0, 0.0);318 319 model.AddBody (body1);320 model.AddBody (body2);321 AddModelToViewer (viewer, mode, model, info);322 }323 324 if (step == current++) {325 var model = new JSM.Model ();326 var basePolygon = [327 new JSM.Coord (-0.2, -0.2, 0.0),328 new JSM.Coord (0.2, -0.2, 0.0),329 new JSM.Coord (0.2, 0.1, 0.0),330 new JSM.Coord (0.0, 0.1, 0.0),331 new JSM.Coord (0.0, 0.0, 0.0),332 new JSM.Coord (-0.2, 0.0, 0.0)333 ];334 335 var aSector = new JSM.Sector (new JSM.Coord (-0.5, 0.0, 0.0), new JSM.Coord (0.5, 0.0, 0.0));336 var bSector = new JSM.Sector (new JSM.Coord (0.0, 1.0, -0.5), new JSM.Coord (0.0, 1.0, 0.5));337 var body1 = JSM.GenerateRuledFromSectors (aSector, bSector, 25, 25, true);338 var body2 = JSM.GenerateRuledFromSectors (aSector, bSector, 15, 15, false);339 OffsetTwoBodies (body1, body2, 0.7, 0.0, 0.0);340 341 model.AddBody (body1);342 model.AddBody (body2);343 AddModelToViewer (viewer, mode, model, info);344 }345 if (step == current++) {346 var model = new JSM.Model ();347 var basePolygon = [348 new JSM.Coord (-0.2, -0.2, 0.0),349 new JSM.Coord (0.2, -0.2, 0.0),350 new JSM.Coord (0.2, 0.1, 0.0),351 new JSM.Coord (0.0, 0.1, 0.0),352 new JSM.Coord (0.0, 0.0, 0.0),353 new JSM.Coord (-0.2, 0.0, 0.0)354 ];355 356 var aSector = new JSM.Sector (new JSM.Coord (-0.5, 0.0, 0.0), new JSM.Coord (0.5, 0.0, 0.0));357 var bSector = new JSM.Sector (new JSM.Coord (0.0, 1.0, -0.5), new JSM.Coord (0.0, 1.0, 0.5));358 var body1 = JSM.GenerateRuledFromSectorsWithHeight (aSector, bSector, 25, 25, true, 0.1);359 var body2 = JSM.GenerateRuledFromSectorsWithHeight (aSector, bSector, 15, 15, false, 0.2);360 OffsetTwoBodies (body1, body2, 0.7, 0.0, 0.0);361 362 model.AddBody (body1);363 model.AddBody (body2);364 AddModelToViewer (viewer, mode, model, info);365 }366 367 if (step == current++) {368 var model = new JSM.Model ();369 var polyLine = [370 new JSM.Coord (-0.5, 0.0, -0.5),371 new JSM.Coord (-0.1, 0.0, 0.0),372 new JSM.Coord (-0.3, 0.0, 0.5)373 ];374 375 var axis = new JSM.Sector (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));376 var body1 = JSM.GenerateRevolved (polyLine, axis, 200 * JSM.DegRad, 25, true, 'CurveSegments');377 var body2 = JSM.GenerateRevolved (polyLine, axis, 250 * JSM.DegRad, 15, false, 'None');378 OffsetTwoBodies (body1, body2, 0.7, 0.0, 0.0);379 380 model.AddBody (body1);381 model.AddBody (body2);382 AddModelToViewer (viewer, mode, model, info);383 }384 if (step == current++) {385 var model = new JSM.Model ();386 var polyLine = [387 new JSM.Coord (-0.5, 0.0, -0.5),388 new JSM.Coord (-0.1, 0.0, 0.0),389 new JSM.Coord (-0.3, 0.0, 0.5)390 ];391 392 var axis = new JSM.Sector (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));393 var body1 = JSM.GenerateRevolved (polyLine, axis, 360 * JSM.DegRad, 25, true, 'CurveSegments');394 var body2 = JSM.GenerateRevolved (polyLine, axis, 360 * JSM.DegRad, 15, false, 'None');395 OffsetTwoBodies (body1, body2, 0.7, 0.0, 0.0);396 397 model.AddBody (body1);398 model.AddBody (body2);399 AddModelToViewer (viewer, mode, model, info);400 }401 402 if (step == current++) {403 function TheFunction1 (x, y) {404 return x * x - y * y;405 }406 407 function TheFunction2 (x, y) {408 return x * x * x - y * y * y;409 }410 var model = new JSM.Model ();411 var intervalMin = new JSM.Coord2D (-0.5, -0.5);412 var intervalMax = new JSM.Coord2D (0.5, 0.5);413 var body1 = JSM.GenerateFunctionSurface (TheFunction1, intervalMin, intervalMax, 25, true); 414 var body2 = JSM.GenerateFunctionSurface (TheFunction2, intervalMin, intervalMax, 15, false);415 OffsetTwoBodies (body1, body2, 0.7, 0.0, 0.0);416 417 model.AddBody (body1);418 model.AddBody (body2);419 AddModelToViewer (viewer, mode, model, info);420 } 421 if (step == current++) {422 function TheFunction1 (x, y) {423 return x * x - y * y;424 }425 426 function TheFunction2 (x, y) {427 return x * x * x - y * y * y;428 }429 var model = new JSM.Model ();430 var intervalMin = new JSM.Coord2D (-0.5, -0.5);431 var intervalMax = new JSM.Coord2D (0.5, 0.5);432 var body1 = JSM.GenerateFunctionSurfaceSolid (TheFunction1, intervalMin, intervalMax, 25, true, 1.0);433 var body2 = JSM.GenerateFunctionSurfaceSolid (TheFunction2, intervalMin, intervalMax, 15, false, 1.5);434 OffsetTwoBodies (body1, body2, 0.7, 0.0, 0.0);435 436 model.AddBody (body1);437 model.AddBody (body2);438 AddModelToViewer (viewer, mode, model, info);439 } 440 if (step == current++) {441 var model = new JSM.Model ();442 443 var names = [444 'Tetrahedron',445 'Hexahedron',446 'Octahedron',447 'Dodecahedron',448 'Icosahedron',449 'TruncatedTetrahedron',450 'Cuboctahedron',451 'TruncatedCube',452 'TruncatedOctahedron',453 'Rhombicuboctahedron',454 'TruncatedCuboctahedron',455 'SnubCube',456 'Icosidodecahedron',457 'TruncatedDodecahedron',458 'TruncatedIcosahedron',459 'Rhombicosidodecahedron',460 'TruncatedIcosidodecahedron',461 'SnubDodecahedron',462 'SmallStellatedDodecahedron',463 'GreatDodecahedron',464 'GreatStellatedDodecahedron'465 ];466 467 var i, body;468 var offsetX = 0.0;469 var offsetY = 0.0;470 for (i = 1; i <= names.length; i++) {471 body = JSM.GenerateSolidWithRadius (names[i - 1], 1.0);472 OffsetOneBody (body, offsetX, offsetY, 0.0);473 model.AddBody (body);474 475 offsetX = offsetX + 2.5;476 if (i % 7 == 0) {477 offsetY = offsetY + 2.5;478 offsetX = 0.0;479 }480 }481 AddModelToViewer (viewer, mode, model, info);482 } 483 if (step == current++) {484 var model = new JSM.Model ();485 model.AddMaterial (new JSM.Material ({ambient : 0x993333, diffuse : 0x993333}));486 model.AddMaterial (new JSM.Material ({ambient : 0x008ab8, diffuse : 0x008ab8}));487 var body1 = JSM.GenerateCuboid (1, 1, 1);488 body1.GetPolygon (3).SetMaterialIndex (0); 489 body1.GetPolygon (5).SetMaterialIndex (1); 490 body1 = JSM.CatmullClarkSubdivision (body1, 1);491 var body2 = JSM.GenerateCuboid (1, 1, 1);492 body2.GetPolygon (3).SetMaterialIndex (0); 493 body2.GetPolygon (5).SetMaterialIndex (1);494 body2 = JSM.CatmullClarkSubdivision (body2, 2);495 var body3 = JSM.GenerateCuboid (1, 1, 1);496 body3.GetPolygon (3).SetMaterialIndex (0); 497 body3.GetPolygon (5).SetMaterialIndex (1); 498 body3 = JSM.CatmullClarkSubdivision (body3, 3);499 var body4 = JSM.GenerateCuboid (1, 1, 1);500 body4.GetPolygon (3).SetMaterialIndex (0); 501 body4.GetPolygon (5).SetMaterialIndex (1); 502 body4 = JSM.CatmullClarkSubdivision (body4, 4);503 OffsetTwoBodies (body2, body3, 0.6, 0.0, 0.0);504 OffsetTwoBodies (body1, body4, 1.8, 0.0, 0.0);505 model.AddBody (body1);506 model.AddBody (body2);507 model.AddBody (body3);508 model.AddBody (body4);509 AddModelToViewer (viewer, mode, model, info);510 }511 if (step == current++) {512 var model = new JSM.Model ();513 model.AddMaterial (new JSM.Material ({ambient : 0x993333, diffuse : 0x993333}));514 model.AddMaterial (new JSM.Material ({ambient : 0x008ab8, diffuse : 0x008ab8}));515 var body1 = JSM.GenerateCuboid (0.5, 1.0, 1.5);516 body1.GetPolygon (3).SetMaterialIndex (0); 517 body1.GetPolygon (5).SetMaterialIndex (1); 518 body1 = JSM.CatmullClarkSubdivision (body1, 1);519 var body2 = JSM.GenerateCuboid (0.5, 1.0, 1.5);520 body2.GetPolygon (3).SetMaterialIndex (0); 521 body2.GetPolygon (5).SetMaterialIndex (1);522 body2 = JSM.CatmullClarkSubdivision (body2, 2);523 var body3 = JSM.GenerateCuboid (0.5, 1.0, 1.5);524 body3.GetPolygon (3).SetMaterialIndex (0); 525 body3.GetPolygon (5).SetMaterialIndex (1); 526 body3 = JSM.CatmullClarkSubdivision (body3, 3);527 var body4 = JSM.GenerateCuboid (0.5, 1.0, 1.5);528 body4.GetPolygon (3).SetMaterialIndex (0); 529 body4.GetPolygon (5).SetMaterialIndex (1); 530 body4 = JSM.CatmullClarkSubdivision (body4, 4);531 OffsetTwoBodies (body2, body3, 0.6, 0.0, 0.0);532 OffsetTwoBodies (body1, body4, 1.8, 0.0, 0.0);533 model.AddBody (body1);534 model.AddBody (body2);535 model.AddBody (body3);536 model.AddBody (body4);537 AddModelToViewer (viewer, mode, model, info);538 }539 if (step == current++) {540 var model = new JSM.Model ();541 model.AddMaterial (new JSM.Material ({ambient : 0x993333, diffuse : 0x993333}));542 model.AddMaterial (new JSM.Material ({ambient : 0x008ab8, diffuse : 0x008ab8}));543 var basePolygon = [544 new JSM.Coord (-0.5, -0.5, 0.0),545 new JSM.Coord (0.5, -0.5, 0.0),546 new JSM.Coord (0.5, 0.5, 0.0),547 new JSM.Coord (0.0, 0.5, 0.0),548 new JSM.Coord (0.0, 0.0, 0.0),549 new JSM.Coord (-0.5, 0.0, 0.0)550 ];551 var direction = new JSM.Coord (0.0, 0.0, 1.0);552 var body1 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null);553 body1.GetPolygon (3).SetMaterialIndex (0); 554 body1.GetPolygon (5).SetMaterialIndex (1); 555 body1 = JSM.CatmullClarkSubdivision (body1, 1);556 var body2 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null);557 body2.GetPolygon (3).SetMaterialIndex (0); 558 body2.GetPolygon (5).SetMaterialIndex (1);559 body2 = JSM.CatmullClarkSubdivision (body2, 2);560 var body3 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null);561 body3.GetPolygon (3).SetMaterialIndex (0); 562 body3.GetPolygon (5).SetMaterialIndex (1); 563 body3 = JSM.CatmullClarkSubdivision (body3, 3);564 var body4 = JSM.GeneratePrism (basePolygon, direction, 1.0, true, null);565 body4.GetPolygon (3).SetMaterialIndex (0); 566 body4.GetPolygon (5).SetMaterialIndex (1); 567 body4 = JSM.CatmullClarkSubdivision (body4, 4);568 OffsetTwoBodies (body2, body3, 0.6, 0.0, 0.0);569 OffsetTwoBodies (body1, body4, 1.8, 0.0, 0.0);570 model.AddBody (body1);571 model.AddBody (body2);572 model.AddBody (body3);573 model.AddBody (body4);574 AddModelToViewer (viewer, mode, model, info);575 }576 if (step == current++) {577 var model = new JSM.Model ();578 579 var body = JSM.GenerateSegmentedRectangle (1, 1, 50, 50)580 JSM.SoftMoveBodyVertex (body, 1000, 1.0, new JSM.Vector (0.0, 0.0, 1.0), 0.2);581 JSM.SoftMoveBodyVertex (body, 1800, 0.5, new JSM.Vector (0.0, 0.0, -1.0), 0.1);582 model.AddBody (body);583 AddModelToViewer (viewer, mode, model, info);584 } 585 586 if (step == current++) {587 var model = new JSM.Model ();588 589 var body1 = JSM.GenerateSphere (0.5, 20, false);590 var plane1 = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.0, 0.0, 0.3), new JSM.Vector (0.0, 0.0, -1.0));591 body1 = JSM.CutBodyByPlane (body1, plane1);592 var body2 = JSM.GenerateSphere (0.6, 20, false);593 var plane2 = JSM.GetPlaneFromCoordAndDirection (new JSM.Coord (0.0, 0.0, 0.3), new JSM.Vector (0.0, -1.0, -1.0));594 body2 = JSM.CutBodyByPlane (body2, plane2);595 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);596 597 model.AddBody (body1);598 model.AddBody (body2);599 AddModelToViewer (viewer, mode, model, info);600 }601 602 if (step == current++) {603 function GenerateBodyFromHull (coords)604 {605 var body = new JSM.Body ();606 var hull = JSM.ConvexHull3D (coords);607 var i;608 for (i = 0; i < coords.length; i++) {609 body.AddVertex (new JSM.BodyVertex (coords[i]));610 }611 612 for (i = 0; i < hull.length; i++) {613 body.AddPolygon (new JSM.BodyPolygon (hull[i]));614 }615 return body;616 }617 var model = new JSM.Model ();618 var body1 = GenerateBodyFromHull ([619 new JSM.Coord (0.0, 0.0, 0.0),620 new JSM.Coord (1.0, 0.0, 0.0),621 new JSM.Coord (1.0, 1.0, 0.0),622 new JSM.Coord (0.0, 1.0, 0.0),623 new JSM.Coord (0.0, 0.0, 0.5),624 new JSM.Coord (0.5, 0.5, 0.75),625 new JSM.Coord (0.0, 1.0, 1.0)626 ]);627 var body2 = GenerateBodyFromHull ([628 new JSM.Coord (0.0, 0.0, 0.0),629 new JSM.Coord (1.0, 0.0, 0.0),630 new JSM.Coord (1.0, 1.0, 0.0),631 new JSM.Coord (0.0, 1.0, 0.0),632 new JSM.Coord (0.0, 0.0, 1.0),633 new JSM.Coord (1.0, 0.0, 1.0),634 new JSM.Coord (1.0, 1.0, 1.0),635 new JSM.Coord (0.0, 1.0, 1.0)636 ]);637 638 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);639 model.AddBody (body1);640 model.AddBody (body2);641 AddModelToViewer (viewer, mode, model, info);642 }643 if (step == current++) {644 var model = new JSM.Model ();645 model.AddMaterial (new JSM.Material ({ambient : 0xffffff, diffuse : 0xffffff, specular : 0x000000, shininess : 0.0, opacity : 1.0, texture : 'testfiles/texture.png'}));646 var body1 = JSM.GenerateCuboid (1, 1, 1);647 body1.SetPolygonsMaterialIndex (0);648 var body2 = JSM.GenerateCylinder (0.5, 1.0, 30, true, true);649 body2.SetPolygonsMaterialIndex (0);650 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);651 model.AddBody (body1);652 model.AddBody (body2);653 AddModelToViewer (viewer, mode, model, info);654 }655 656 if (step == current++) {657 var model = new JSM.Model ();658 model.AddMaterial (new JSM.Material ({ambient : 0xffffff, diffuse : 0xffffff, specular : 0x000000, shininess : 0.0, opacity : 1.0, texture : 'testfiles/texture.png'}));659 var body1 = JSM.GenerateCuboid (1, 1, 1);660 body1.Transform (new JSM.RotationXTransformation (-30.0 * JSM.DegRad));661 body1.SetPolygonsMaterialIndex (0);662 var body2 = JSM.GenerateCylinder (0.5, 1.0, 30, true, true);663 body2.Transform (new JSM.RotationXTransformation (-30.0 * JSM.DegRad));664 body2.SetPolygonsMaterialIndex (0);665 OffsetTwoBodies (body1, body2, 0.6, 0.0, 0.0);666 model.AddBody (body1);667 model.AddBody (body2);668 AddModelToViewer (viewer, mode, model, info);669 } 670 if (step == current++) {671 var model = new JSM.Model ();672 model.AddMaterial (new JSM.Material ({ambient : 0xffffff, diffuse : 0xffffff, specular : 0x000000, shininess : 0.0, opacity : 1.0, texture : 'testfiles/texture.png'}));673 var body1 = JSM.GenerateCuboid (1, 1, 1);674 body1.SetPlanarTextureProjection (675 new JSM.Coord (0.0, 0.0, 0.0),676 new JSM.Coord (1.0, 0.0, 0.0),677 new JSM.Coord (0.0, 0.0, 1.0)678 );679 body1.SetPolygonsMaterialIndex (0);680 var body2 = JSM.GenerateCuboid (1, 1, 1);681 body2.SetPlanarTextureProjection (682 new JSM.Coord (0.2, 0.3, 0.4),683 new JSM.Coord (1.0, 0.0, 0.0),684 new JSM.Coord (0.0, 0.0, 1.0)685 );686 body2.SetPolygonsMaterialIndex (0);687 688 var body3 = JSM.GenerateCuboid (1, 1, 1);689 body3.SetPlanarTextureProjection (690 new JSM.Coord (-0.5, -0.5, -0.5),691 new JSM.Coord (1.0, 0.0, 0.0),692 new JSM.Coord (0.0, 0.0, 1.0)693 );694 body3.SetPolygonsMaterialIndex (0); 695 OffsetTwoBodies (body1, body3, 1.2, 0.0, 0.0);696 model.AddBody (body1);697 model.AddBody (body2);698 model.AddBody (body3);699 AddModelToViewer (viewer, mode, model, info);700 }701 if (step == current++) {702 var model = new JSM.Model ();703 model.AddMaterial (new JSM.Material ({ambient : 0xffffff, diffuse : 0xffffff, specular : 0x000000, shininess : 0.0, opacity : 1.0, texture : 'testfiles/texture.png'}));704 var body1 = JSM.GenerateCuboid (1, 1, 1);705 body1.SetCubicTextureProjection (new JSM.Coord (0.0, 0.0, 0.0), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));706 body1.SetPolygonsMaterialIndex (0);707 var body2 = JSM.GenerateCuboid (1, 1, 1);708 body2.SetCubicTextureProjection (new JSM.Coord (0.2, 0.3, 0.4), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));709 body2.SetPolygonsMaterialIndex (0);710 711 var body3 = JSM.GenerateCuboid (1, 1, 1);712 body3.SetCubicTextureProjection (new JSM.Coord (-0.5, -0.5, -0.5), new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 1.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0)); 713 body3.SetPolygonsMaterialIndex (0); 714 OffsetTwoBodies (body1, body3, 1.2, 0.0, 0.0);715 model.AddBody (body1);716 model.AddBody (body2);717 model.AddBody (body3);718 AddModelToViewer (viewer, mode, model, info);719 }720 if (step == current++) {721 var model = new JSM.Model ();722 model.AddMaterial (new JSM.Material ({ambient : 0xffffff, diffuse : 0xffffff, specular : 0x000000, shininess : 0.0, opacity : 1.0, texture : 'testfiles/texture.png'}));723 var body1 = JSM.GenerateCylinder (0.5, 1.0, 30, true, true);724 body1.SetCylindricalTextureProjection (new JSM.Coord (0.0, 0.0, 0.0), 0.5, new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));725 body1.SetPolygonsMaterialIndex (0);726 var body2 = JSM.GenerateCylinder (0.5, 1.0, 30, true, true);727 body2.SetCylindricalTextureProjection (new JSM.Coord (0.0, 0.0, -0.5), 0.5, new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));728 body2.SetPolygonsMaterialIndex (0);729 730 var body3 = JSM.GenerateCylinder (0.5, 1.0, 30, true, true);731 body3.SetCylindricalTextureProjection (new JSM.Coord (0.0, 0.0, 0.0), 1.0, new JSM.Coord (1.0, 0.0, 0.0), new JSM.Coord (0.0, 0.0, 1.0));732 body3.SetPolygonsMaterialIndex (0); 733 OffsetTwoBodies (body1, body3, 1.2, 0.0, 0.0);734 model.AddBody (body1);735 model.AddBody (body2);736 model.AddBody (body3);737 AddModelToViewer (viewer, mode, model, info);738 }739 if (step == current++) {740 var model = new JSM.Model ();741 var body1 = JSM.GenerateLegoBrick (2, 3, true, true, true, 25, true);742 var body2 = JSM.GenerateLegoBrick (3, 4, false, true, true, 15, false);743 744 OffsetTwoBodies (body1, body2, 1.4, 0.0, 0.0);745 model.AddBody (body1);746 model.AddBody (body2);747 AddModelToViewer (viewer, mode, model, info);748 }749 750 if (step == current++) {751 var model = new JSM.Model ();752 var basePoints = [753 new JSM.Coord (0, 0, 0),754 new JSM.Coord (1, 0, 0),755 new JSM.Coord (1.1, 0.4, 0),756 new JSM.Coord (1.1, 0.6, 0),757 new JSM.Coord (1, 1, 0),758 new JSM.Coord (0, 1, 0),759 new JSM.Coord (-0.1, 0.6, 0),760 new JSM.Coord (-0.1, 0.4, 0)761 ];762 763 var direction = new JSM.Vector (0.0, 0.0, 1.0);764 var body1 = JSM.GeneratePrism (basePoints, direction, 0.3, true, 160 * JSM.DegRad);765 766 var basePoints = [767 new JSM.Coord (0, 0, 0),768 new JSM.Coord (1, 0, 0),769 new JSM.Coord (1.1, 0.4, 0),770 new JSM.Coord (1.1, 0.6, 0),771 new JSM.Coord (1, 1, 0),772 new JSM.Coord (0, 1, 0),773 new JSM.Coord (-0.1, 0.6, 0),774 new JSM.Coord (-0.1, 0.4, 0),775 null,776 new JSM.Coord (0.2, 0.2, 0),777 new JSM.Coord (0.1, 0.4, 0),778 new JSM.Coord (0.1, 0.6, 0),779 new JSM.Coord (0.2, 0.8, 0),780 new JSM.Coord (0.8, 0.8, 0),781 new JSM.Coord (0.9, 0.6, 0),782 new JSM.Coord (0.9, 0.4, 0),783 new JSM.Coord (0.8, 0.2, 0)784 ];785 786 var direction = new JSM.Vector (0.0, 0.0, 1.0);787 var body2 = JSM.GeneratePrismWithHole (basePoints, direction, 0.3, true, 150 * JSM.DegRad);788 OffsetTwoBodies (body1, body2, 0.8, 0.0, 0.0);789 model.AddBody (body1);790 model.AddBody (body2);791 AddModelToViewer (viewer, mode, model, info);792 }...
Grid.js
Source:Grid.js
1class Grid {2 constructor(rows, cols) {3 this.cols = cols;4 this.rows = rows;5 this.tiles = [];6 for (let i = 0; i < rows; i++) {7 this.tiles[i] = [];8 for (let j = 0; j < cols; j++) {9 this.tiles[i][j] = 0;10 }11 }12 // console.table(tiles);13 this.food = {};14 this.snake;15 this.gameOver = false;16 this.addBody = [false, 0, 0];17 this.score = 0;18 }19 show() {20 push()21 let w = width / this.cols;22 let r = height / this.rows;23 stroke(200);24 strokeWeight(1);25 for (let i = 0; i < width; i = i + r) {26 line(0, i, width, i);27 }28 for (let i = 0; i < height; i = i + w) {29 line(i, 0, i, height);30 }31 let fy = this.food.x * w + w / 2;32 let fx = this.food.y * r + r / 2;33 // console.log(fx, fy);34 fill(255, 0, 0);35 noStroke();36 ellipse(fx, fy, w * 1.5 / 2, r * 1.5 / 2);37 fill(0, 255, 0);38 for (let i = 0; i < this.snake.length; i++) {39 if (i == 0) fill(3, 98, 0);40 else fill(10, 190, 0);41 let body = this.snake[i];42 rect(body[0] * w + 2, body[1] * r + 2, w - 4, r - 4);43 }44 45 if (this.addBody[0]==true){46 let x = this.addBody[1];47 let y = this.addBody[2];48 fill(227, 79, 79)49 rect(x * w + 2, y* r + 2, w - 4, r - 4);50 }51 pop()52 }53 createSnake() {54 this.snake = [];55 let x = floor((this.cols - 1) / 2);56 let y = floor((this.rows - 1) / 2);57 console.log(x, y);58 // console.log(x, y);59 this.snake.push([x, y, 'u']);60 this.tiles[y][x] = 1;61 y = y + 1;62 this.snake.push([x, y, 'u'])63 this.tiles[y][x] = 1;64 y = y + 1;65 this.snake.push([x, y, 'u'])66 this.tiles[y][x] = 1;67 }68 update(dir) {69 for (let i = this.snake.length - 1; i > 0; i--) {70 this.snake[i][2] = this.snake[i - 1][2];71 }72 this.snake[0][2] = dir;73 }74 addFood() {75 let x = floor(random(this.cols));76 let y = floor(random(this.rows));77 if (this.tiles[y][x] == 0) {78 this.food = { y, x };79 } else {80 this.addFood();81 }82 }83 moveSnake() {84 if (!this.gameOver) {85 for (let i = 0; i < this.snake.length; i++) {86 let body = this.snake[i];87 let x = body[0];88 let y = body[1];89 let dir = body[2];90 this.tiles[y][x] = 091 if (dir == 'u') y = y - 1;92 if (dir == 'd') y = y + 1;93 if (dir == 'l') x = x - 1;94 if (dir == 'r') x = x + 1;95 if (x < 0) x = this.cols - 1;96 if (x > this.cols - 1) x = 0;97 if (y < 0) y = this.rows - 1;98 if (y > this.rows - 1) y = 0;99 if (this.tiles[y][x] == 1) {100 console.log("gameOver");101 this.gameOver = true;102 break;103 }104 this.snake[i] = [x, y, dir];105 this.tiles[y][x] = 1106 } 107 108 let head = this.snake[0];109 if (head[0] == this.food.y && head[1] == this.food.x) {110 let x = this.food.y;111 let y = this.food.x;112 this.addFood();113 this.score = this.score + 1;114 let tail = this.snake[this.snake.length - 1];115 let dir = tail[2];116 this.addBody = [true, x, y, dir];117 }118 119 // console.log(this.addBody);120 // console.log(this.tiles[this.addBody[2]][this.addBody[1]]);121 // console.table(this.tiles);122 if (this.addBody[0] == true && this.tiles[this.addBody[2]][this.addBody[1]] == 0) {123 this.snake.push([this.addBody[1], this.addBody[2], this.addBody[3]]);124 // this.tiles[this.addBody[2]][this.addBody[2]] = 1;125 this.addBody[0] = false;126 console.log("now");127 }128 129 }130 }...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5});6### WebPageTest(url, key)7### WebPageTest#runTest(url, options, callback)8### WebPageTest#getTestStatus(testId, callback)9### WebPageTest#getTestResults(testId, callback)10### WebPageTest#getLocations(callback)11### WebPageTest#getLocation(location, callback)12### WebPageTest#getTesters(callback)13### WebPageTest#getTesters(location, callback)
Using AI Code Generation
1var wptoolbox = require('wptoolbox');2wp.addBody('Test body', 'Test title', function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org','A.4d4a4a4a4a4a4a4a4a4a4a4a4a4a4a4');3 if (err) return console.error(err);4 console.log(data);5});6var wpt = require('webpagetest');7var wpt = new WebPageTest('www.webpagetest.org','A.4d4a4a4a4a4a4a4a4a4a4a4a4a4a4a');8 if (err) return console.error(err);9 console.log(data);10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org','A.4d4a4a4a4a4a4a4a4a4a4a4a4a4a4a');13 if (err) return console.error(err);14 console.log(data);15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org','A.4d4a4a4a4a4a4a4a4a4a4a4a4a4a4a');18 if (err) return console.error(err);19 console.log(data);20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org','A.4d4a4a4a4a4a4a4a
Using AI Code Generation
1var wpt = require('./wpt.js');2var options = {3};4wpt.addBody(options, 'test=1&test2=2');5wpt.runTest(options, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});12#### `wpt.runTest(options, callback)`13#### `wpt.addBody(options, body)`14#### `wpt.getLocations(callback)`15#### `wpt.getTestStatus(testId, callback)`16#### `wpt.getTestResults(testId, callback)`
Using AI Code Generation
1var wpt = require('./wpt.js');2var config = require('./config.js');3var wptOptions = {4};5wpt.addBody(wptOptions, 'body', 'This is a test');6wpt.runTest(wptOptions, function(err, data) {7 if (err) {8 console.log(err);9 } else {10 console.log(data);11 }12});
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if(err) return console.log(err);4 console.log(data);5});6 if(err) return console.log(err);7 console.log(data);8});9 if(err) return console.log(err);10 console.log(data);11});12 if(err) return console.log(err);13 console.log(data);14});
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!