webpackJsonp([107],{PYjp:function(e,t){},WEy7:function(e,t,a){"use strict";var i=a("bzuE"),s={name:"ChooseProjects",props:{id:{type:String,default:""},visible:{type:Boolean,default:!1}},watch:{visible:function(e,t){e!==t&&(e&&this.initData(),this.innerVisible=e)},innerVisible:function(e,t){e!==t&&this.$emit("update:visible",e)}},data:function(){return{ruleForm:{name:[{required:!0,message:"请填写保养项目",trigger:"blur"}],function:[{required:!0,message:"请填写保养方法",trigger:"blur"}]},form:{code:"",deviceTepy:"",name:"",function:""},subsetList:[],subsetAll:[],subsetTotal:0,searchData_Subset:{pageno:1,pagesize:5},callBackData:[],innerVisible:this.visible,loading:!1,dialogLoading:!1,deviceType:[],addVisible:!1,config:i.a}},computed:{},methods:{clickRow:function(e){this.$refs.tb.toggleRowSelection(e)},initData:function(){var e=this;this.$api.dictAPI.getDictsByType("device_type").then(function(t){0===t.code&&(e.deviceType=t.datas)}),this.searchSubset()},searchSubset:function(e){var t=this;e&&(this.searchData_Subset.pageno=1),this.dialogLoading=!0,this.$api.upkeepPlanAPI.findProjects(this.searchData_Subset).then(function(e){console.log(e),t.dialogLoading=!1,0===e.code&&(t.subsetList=e.data?e.data.datas:[],t.subsetTotal=e.data?e.data.totalRows:0)})},addProject:function(){this.form={},this.addVisible=!0,this.resetFields()},save:function(e){var t=this;this.$refs[e].validate(function(e){if(!e)return!1;t.$api.upkeepPlanAPI.addProjects(t.form).then(function(e){0===e.code?(t.$message({message:e.msg,type:"success"}),t.addVisible=!1,t.searchSubset()):t.$message({message:e.msg,type:"error"})})})},ckSubsetAll:function(e){this.subsetAll=e},subsetSizeChange:function(e){this.searchData_Subset.pagesize=e,this.searchSubset()},subsetCurrentChange:function(e){this.searchData_Subset.pageno=e,this.searchSubset()},submit:function(e){var t=[];this.subsetAll.length>0&&this.subsetAll.forEach(function(e){t.push(e)}),console.log(t),this.$emit("change",t),this.innerVisible=!1},resetFields:function(){this.$refs.form&&this.$refs.form.resetFields()}}},r={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",[a("el-dialog",{attrs:{center:"",title:"选择保养项目",visible:e.innerVisible,width:"900px"},on:{"update:visible":function(t){e.innerVisible=t}}},[a("div",[a("el-form",{attrs:{inline:""}},[a("el-form-item",{attrs:{label:"保养项目"}},[a("el-input",{attrs:{placeholder:"保养项目"},model:{value:e.searchData_Subset.name,callback:function(t){e.$set(e.searchData_Subset,"name",t)},expression:"searchData_Subset.name"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"保养方法"}},[a("el-input",{attrs:{placeholder:"保养方法"},model:{value:e.searchData_Subset.function,callback:function(t){e.$set(e.searchData_Subset,"function",t)},expression:"searchData_Subset.function"}})],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.searchSubset(1)}}},[e._v("查询")])],1)],1)],1),e._v(" "),a("div",{staticClass:"sys-table"},[a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:e.dialogLoading,expression:"dialogLoading"}],ref:"tb",attrs:{data:e.subsetList,"header-cell-style":{fontWeight:"normal",textAlign:"center",backgroundColor:"#eceff4",color:"#222"}},on:{"row-click":e.clickRow,"selection-change":e.ckSubsetAll}},[a("el-table-column",{attrs:{type:"selection",width:"50",align:"center"}}),e._v(" "),a("el-table-column",{attrs:{prop:"name",label:"保养项目",align:"center"}}),e._v(" "),a("el-table-column",{attrs:{prop:"function","show-overflow-tooltip":"",label:"保养方法",align:"center"}})],1)],1),e._v(" "),a("div",{staticClass:"sys-pagination"},[a("el-pagination",{attrs:{"current-page":e.searchData_Subset.pageno,"page-sizes":[5,10,20],"page-size":e.searchData_Subset.pagesize,layout:"total, sizes, prev, pager, next, jumper",total:e.subsetTotal},on:{"update:currentPage":function(t){return e.$set(e.searchData_Subset,"pageno",t)},"update:current-page":function(t){return e.$set(e.searchData_Subset,"pageno",t)},"size-change":e.subsetSizeChange,"current-change":e.subsetCurrentChange}})],1),e._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{type:"primary",loading:e.loading},on:{click:function(t){return e.submit()}}},[e._v("确定")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){e.innerVisible=!1}}},[e._v(e._s(e.config.cancelText))]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.addProject()}}},[e._v("增加项目")])],1)]),e._v(" "),a("el-dialog",{attrs:{center:"",title:"添加保养项目",visible:e.addVisible,width:"600px"},on:{"update:visible":function(t){e.addVisible=t}}},[a("el-form",{ref:"form",attrs:{"label-width":"90px",model:e.form,rules:e.ruleForm}},[a("el-form-item",{attrs:{label:"编号"}},[a("el-input",{attrs:{placeholder:"请填写编号"},model:{value:e.form.code,callback:function(t){e.$set(e.form,"code",t)},expression:"form.code"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"保养项目",prop:"name"}},[a("el-input",{attrs:{placeholder:"请填写保养项目"},model:{value:e.form.name,callback:function(t){e.$set(e.form,"name",t)},expression:"form.name"}})],1),e._v(" "),a("el-form-item",{attrs:{label:"保养方法",prop:"function"}},[a("el-input",{attrs:{placeholder:"请填写保养方法",autosize:{minRows:4},type:"textarea"},model:{value:e.form.function,callback:function(t){e.$set(e.form,"function",t)},expression:"form.function"}})],1)],1),e._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.save("form")}}},[e._v("保存")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){e.addVisible=!1}}},[e._v(e._s(e.config.cancelText))])],1)],1)],1)},staticRenderFns:[]},o=a("VU/8")(s,r,!1,null,null,null);t.a=o.exports},ppcr:function(e,t){},wKOJ:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,s=a("bOdI"),r=a.n(s),o=a("mvHQ"),n=a.n(o),l=a("d7EF"),c=a.n(l),u=a("//Fk"),d=a.n(u),f=a("BO1k"),m=a.n(f),h=a("Gu7T"),p=a.n(h),b=a("Dd8w"),g=a.n(b),v=(a("GKmE"),a("ysqt")),D=a("OG67"),y=a("WEy7"),_=a("G9gL"),w=a("3MlD"),$=a("NYxO"),x=a("bzuE"),k="/apis/mdh/scgg/add",P="/apis/mdh/scgg/edit",I="/apis/mdh/scgg/detail",C={name:"upkeep_plan_add",components:{btnInput:v.a,ChooseProjects:y.a,ChooseDevices:_.a,DialogChooseSingleUser:w.a,dialogChooseSingleParts:D.a},data:function(){return{kz:"",depOptions:[],selectDeptId:[],formData:{zbList:[]},start_datetime:{disabledDate:function(e){return e.getTime()2&&void 0!==arguments[2]?arguments[2]:[];if(!e)return[];var i=!0,s=!1,r=void 0;try{for(var o,n=m()(e);!(i=(o=n.next()).done);i=!0){var l=o.value;if(a.push(l.id),t(l))return a;if(l.children){var c=this.treeFindPath(l.children,t,a);if(c.length)return c}a.pop()}}catch(e){s=!0,r=e}finally{try{!i&&n.return&&n.return()}finally{if(s)throw r}}return[]},setDeptList:function(e){var t=!0,a=!1,i=void 0;try{for(var s,r=m()(e);!(t=(s=r.next()).done);t=!0){var o=s.value;o.hasChildren?this.setDeptList(o.children):o.children=void 0}}catch(e){a=!0,i=e}finally{try{!t&&r.return&&r.return()}finally{if(a)throw i}}},handleChange:function(e){this.formData.deptId=e.length>=1?e[e.length-1]:"",this.selectDeptId=e},getDevice:function(e){e&&(this.formData.deviceId=e.id,this.formData.deviceModel=e.model,this.formData.deviceUser=e.userName,this.formData.deviceSite=e.site,this.formData.deviceDept=e.deptName,this.formData.deviceName=e.name)},getUser:function(e){var t=this;e&&(this.$set(this.formData,"engineerId",e.id),this.$set(this.formData,"engineerName",e.name),this.$set(this.formData,"cellphone",e.mobile),this.getUserList.forEach(function(a){if(e.id===a.id)return t.formData.selectDeptId=a.deptId,void(t.formData.deptId=a.deptId)}),this.setDefaultDept())},getProject:function(e){var t=this;e&&e.forEach(function(e){t.formData.zbList.push(e)})},removeProject:function(){var e=this;this.formData.zbList&&this.formData.zbList.forEach(function(t){var a=e.formData.zbList.findIndex(function(e){if(e.id==t.id)return!0});e.formData.zbList.splice(a,1)})},handleProjectChange:function(e){this.chooseProjects=e}},r()(i,"getPart",function(e){var t=this;e&&e.forEach(function(e){t.parts.push(e)})}),r()(i,"removePart",function(){var e=this;this.chooseParts&&this.chooseParts.forEach(function(t){var a=e.parts.findIndex(function(e){if(e.id==t.id)return!0});e.parts.splice(a,1)})}),r()(i,"handlePartChange",function(e){this.chooseParts=e}),r()(i,"currentIndex",function(e){this.currentChildIndex=e}),r()(i,"getMaterial",function(e){e&&(this.$set(this.formData.zbList[this.currentChildIndex],"wlmc",e.name),this.$set(this.formData.zbList[this.currentChildIndex],"wlid",e.id),this.$set(this.formData.zbList[this.currentChildIndex],"wlbm",e.serialNo),this.$set(this.formData.zbList[this.currentChildIndex],"ggxh",e.specification),this.$set(this.formData.zbList[this.currentChildIndex],"kz",e.imageNo))}),r()(i,"getEquipment",function(e){console.log(e),e&&(this.$set(this.formData.zbList[this.currentChildIndex],"sbmc",e.name),this.$set(this.formData.zbList[this.currentChildIndex],"sbid",e.id))}),r()(i,"initialize",function(){var e=this;d.a.all([this.$api.commonAPI.getUsers(),this.$api.commonAPI.getDeptsTree(),this.$api.dictAPI.getDictsByType("qy")]).then(function(t){var a=c()(t,3),i=a[0],s=a[1],r=a[2];0===i.code&&(e.getUserList=i.datas),0===s.code&&(e.depOptions=s.data.children,e.setDeptList(e.depOptions),e.setDefaultDept()),0===r.code&&(e.levelList=r.datas)}).catch(function(e){console.log(e)})}),r()(i,"back",function(){this.removeTagNav({path:this.$route.path,title:this.$route.meta.name}),this.$router.push({path:"/basic/scgg",query:{t:Date.now()}})}),r()(i,"getDetail",function(){var e=this;this.loading=!0,this.$api.yxkAPI.yxkGet(I,{id:this.formData.id}).then(function(t){0==t.code&&(e.formData=g()({},t.data)),e.loading=!1}).catch(function(t){e.loading=!1})}),r()(i,"setDefaultDept",function(){if(this.depOptions.length>0&&this.formData.selectDeptId){var e=n()(this.formData.selectDeptId),t=this.treeFindPath(this.depOptions,function(t){return t.id===e});this.selectDeptId=JSON.parse(n()(t))}}),r()(i,"tempSave",function(e){var t=this;this.$refs[e].validate(function(e){if(!e)return!1;if(new Date(t.formData.endTime).getTime()-new Date(t.formData.startTime).getTime()<0)t.$alert("计划完成时间必须大于计划开始时间!","提示",{confirmButtonText:"知道啦"});else if(0!=t.projects.length){if(t.projects){var a="";t.projects.forEach(function(e){a+=e.id+","}),a=","==a.substring(a.length-1)?a.substring(0,a.length-1):a,t.formData.projectIds=a}if(t.parts){var i=[];t.parts.forEach(function(e){e.salePrice=e.salePrice?e.salePrice:0;var t=parseInt(e.num)?parseInt(e.num):0,a=t*e.salePrice,s={partId:e.id,amount:t,remark:e.remark,spartPrice:e.salePrice,spartSum:a};i.push(s)});var s={dataList:i};t.formData.partIdArray=n()(s)}t.isDisabled||(t.isDisabled=!0,t.$api.upkeepPlanAPI.newPlanAndChangePlan(t.formData).then(function(e){t.isDisabled=!1,0===e.code?(t.$message({message:e.data,type:"success"}),t.back()):t.$message({message:e.data,type:"error"})}))}else t.$message({message:"请至少选择一项保养项目",type:"error"})})}),r()(i,"save",function(e){var t=this;this.$refs[e].validate(function(e){if(!e)return!1;var a=JSON.parse(n()(t.formData));a.zbList&&a.zbList.length>0?a.zbList.some(function(e){return!e.sbmc||!e.wlmc})?t.$message({message:"请完善设备/物料信息",type:"error"}):t.$api.yxkAPI.yxkPost(t.formData.id?P:k,t.formData).then(function(e){t.isDisabled=!1,console.log(e),0==e.code?(t.$message({message:e.msg,type:"success"}),t.back()):t.$message({message:e.msg,type:"error"})}):t.$message({message:"请至少新增一条设备数据",type:"error"})})}),i))},S={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"sys-box plan-box"},[a("div",{staticClass:"sys-operate"},[a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.back()}}},[e._v(e._s(e.config.cancelText))]),e._v(" "),a("el-button",{attrs:{type:"primary",disabled:e.isDisabled},on:{click:function(t){return e.save("form")}}},[e._v("提交")])],1),e._v(" "),a("div",{staticClass:"sys-form"},[a("el-form",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],ref:"form",attrs:{"label-width":"120px",model:e.formData,rules:e.ruleForm}},[a("div",{staticClass:"flex"},[a("el-form-item",{staticClass:"form-inline",attrs:{label:"生产规格单号"}},[a("el-input",{attrs:{placeholder:"生产规格单号系统自动生成",disabled:""},model:{value:e.formData.scggdh,callback:function(t){e.$set(e.formData,"scggdh",t)},expression:"formData.scggdh"}})],1),e._v(" "),a("el-form-item",{staticClass:"form-inline",attrs:{label:"日期",prop:"rq"}},[a("el-date-picker",{attrs:{format:"yyyy-MM-dd HH:mm:ss","value-format":"yyyy-MM-dd HH:mm:ss",type:"datetime",clearable:"",placeholder:"选择日期"},model:{value:e.formData.rq,callback:function(t){e.$set(e.formData,"rq",t)},expression:"formData.rq"}})],1),e._v(" "),a("el-form-item",{staticClass:"form-inline",attrs:{label:"区域",prop:"qy"}},[a("el-select",{attrs:{clearable:"",placeholder:"请选择区域"},on:{change:function(t){e.formData.qy=e.levelList.filter(function(e){return e.id==t})[0].name}},model:{value:e.formData.qyid,callback:function(t){e.$set(e.formData,"qyid",t)},expression:"formData.qyid"}},e._l(e.levelList,function(e){return a("el-option",{key:e.id,attrs:{label:e.name,value:e.id}})}),1)],1)],1),e._v(" "),a("el-form-item",{attrs:{label:"备注"}},[a("el-input",{attrs:{type:"textarea",autosize:{minRows:4},placeholder:"请简要填写备注内容"},model:{value:e.formData.remarks,callback:function(t){e.$set(e.formData,"remarks",t)},expression:"formData.remarks"}})],1),e._v(" "),a("el-form-item",{attrs:{required:""}},[a("div",{staticClass:"sys-operate"},[a("el-button",{attrs:{type:"primary"},on:{click:function(){e.formData.zbList.push(JSON.parse(JSON.stringify({})))}}},[e._v("新增行")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.removeProject()}}},[e._v("删除行")]),e._v(" "),a("el-button",{attrs:{type:"primary",disabled:1!=e.chooseProjects.length},on:{click:function(){var t=e.chooseProjects[0];t.id=(new Date).getTime()+"-"+Math.random().toString(36).substr(2.9),e.formData.zbList.push(JSON.parse(JSON.stringify(t)))}}},[e._v("复制行")])],1),e._v(" "),a("el-table",{attrs:{data:e.formData.zbList,"header-cell-style":{fontWeight:"normal",textAlign:"center",backgroundColor:"#eceff4",color:"#222"},border:"","show-summary":""},on:{"selection-change":e.handleProjectChange}},[a("el-table-column",{attrs:{type:"selection",width:"55",align:"center"}}),e._v(" "),a("el-table-column",{attrs:{prop:"wlbm",label:"物料编码",align:"center","show-overflow-tooltip":""}}),e._v(" "),a("el-table-column",{attrs:{prop:"wlmc",label:"物料名称",align:"center",width:"200","show-overflow-tooltip":""},scopedSlots:e._u([{key:"default",fn:function(t){return[a("btn-input",{attrs:{valueText:t.row.wlmc,valueId:t.row.wlid,index:t.$index,chooseVisible:e.chooseMaterielVisible},on:{"update:valueText":function(a){return e.$set(t.row,"wlmc",a)},"update:value-text":function(a){return e.$set(t.row,"wlmc",a)},"update:valueId":function(a){return e.$set(t.row,"wlid",a)},"update:value-id":function(a){return e.$set(t.row,"wlid",a)},currentIndex:e.currentIndex,"update:chooseVisible":function(t){e.chooseMaterielVisible=t},"update:choose-visible":function(t){e.chooseMaterielVisible=t}}})]}}])}),e._v(" "),a("el-table-column",{attrs:{prop:"ggxh",label:"规格型号",align:"center","show-overflow-tooltip":""}}),e._v(" "),a("el-table-column",{attrs:{prop:"kz",label:"克重(g/m²)",align:"center","show-overflow-tooltip":"",sortable:""}}),e._v(" "),a("el-table-column",{attrs:{prop:"zbmc",label:"设备名称",align:"center",width:"200","show-overflow-tooltip":""},scopedSlots:e._u([{key:"default",fn:function(t){return[a("btn-input",{attrs:{valueText:t.row.sbmc,valueId:t.row.sbid,index:t.$index,chooseVisible:e.chooseDevicesVisible},on:{"update:valueText":function(a){return e.$set(t.row,"sbmc",a)},"update:value-text":function(a){return e.$set(t.row,"sbmc",a)},"update:valueId":function(a){return e.$set(t.row,"sbid",a)},"update:value-id":function(a){return e.$set(t.row,"sbid",a)},currentIndex:e.currentIndex,"update:chooseVisible":function(t){e.chooseDevicesVisible=t},"update:choose-visible":function(t){e.chooseDevicesVisible=t}}})]}}])}),e._v(" "),a("el-table-column",{attrs:{prop:"dl",label:"电流(KA)",align:"center","show-overflow-tooltip":""},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-input-number",{attrs:{size:"small"},model:{value:t.row.dl,callback:function(a){e.$set(t.row,"dl",a)},expression:"scope.row.dl"}})]}}])}),e._v(" "),a("el-table-column",{attrs:{prop:"xs",label:"线速(m/min)",align:"center","show-overflow-tooltip":""},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-input-number",{attrs:{size:"small"},model:{value:t.row.xs,callback:function(a){e.$set(t.row,"xs",a)},expression:"scope.row.xs"}})]}}])})],1)],1)],1)],1),e._v(" "),a("dialogChooseSingleParts",{attrs:{visible:e.chooseMaterielVisible},on:{"update:visible":function(t){e.chooseMaterielVisible=t},change:e.getMaterial}}),e._v(" "),a("ChooseProjects",{attrs:{visible:e.chooseVisible},on:{"update:visible":function(t){e.chooseVisible=t},change:e.getProject}}),e._v(" "),a("ChooseDevices",{attrs:{visible:e.chooseDevicesVisible,canUsed:"canUsed"},on:{"update:visible":function(t){e.chooseDevicesVisible=t},change:e.getEquipment}}),e._v(" "),a("DialogChooseSingleUser",{attrs:{visible:e.chooseUserVisible},on:{"update:visible":function(t){e.chooseUserVisible=t},change:e.getUser}})],1)},staticRenderFns:[]};var z=a("VU/8")(C,S,!1,function(e){a("PYjp"),a("ppcr")},"data-v-0dcb9b81",null);t.default=z.exports}});