How to use addBody method in wpt

Best JavaScript code snippet using wpt

recovery-form.js

Source:recovery-form.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

teststeps.js

Source:teststeps.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

Grid.js

Source:Grid.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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)

Full Screen

Using AI Code Generation

copy

Full Screen

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});

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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)`

Full Screen

Using AI Code Generation

copy

Full Screen

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});

Full Screen

Using AI Code Generation

copy

Full Screen

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});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('webpagetest');2const client = wpt('A.6d3b7b3e1a8c1e3d3d3e3a3f3e3b3e3a');3 if (err) {4 return console.error(err);5 }6 console.log(data);7});

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run wpt automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful