<template>
|
<view>
|
<view class="form">
|
<view class="form-item">
|
<view class="title">单据号:</view>
|
<view class="righton">
|
<input v-model="hform.HBillNo" disabled placeholder="请输入单据号" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">日期:</view>
|
<view class="righton">
|
<!-- <picker mode="date" v-model="hform.HDate" @change="HDateChange"> -->
|
<input name="HDate" disabled v-model="hform.HDate" placeholder="请选择日期" />
|
<!-- </picker> -->
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">内部单据号:</view>
|
<view class="right">
|
<input name="HInnerBillNo" v-model="hform.HInnerBillNo" placeholder="请输入内部单据号" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>设备:</view>
|
<view class="right" style="width: 380rpx;">
|
<uni-combox :candidates="arrayCandidates" placeholder="请选择设备" v-model="hform.HEquipName" @input="candidatesInput"></uni-combox>
|
</view>
|
<uni-icons type="scan" style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;font-weight: 500;" size="20" @click="toScanCode"></uni-icons>
|
</view>
|
|
<view class="tab_area"></view>
|
|
<view class="form-item">
|
<view class="title">周期单位:</view>
|
<radio-group name="HCycleUnit" style="padding: 8rpx 0;">
|
<label @tap="hform.HCycleUnit = '天'">
|
<radio v-model="hform.HCycleUnit" :checked="hform.HCycleUnit == '天'" style="transform:scale(0.8); margin-left: 40rpx;"/>天
|
</label>
|
<label @tap="hform.HCycleUnit = '周'">
|
<radio v-model="hform.HCycleUnit" :checked="hform.HCycleUnit == '周'" style="transform:scale(0.8); margin-left: 50rpx;"/>周
|
</label>
|
<label @tap="hform.HCycleUnit = '月'">
|
<radio v-model="hform.HCycleUnit" :checked="hform.HCycleUnit == '月'" style="transform:scale(0.8); margin-left: 50rpx;"/>月
|
</label>
|
</radio-group>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>保养周期:</view>
|
<view class="right">
|
<input type="number" name="HCheckCycle" v-model="hform.HCheckCycle" placeholder="请输入保养周期" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>保养开始:</view>
|
<view class="right">
|
<picker mode="date" v-model="hform.HBeginDate" @change="HBeginDateChange">
|
<input name="HBeginDate" disabled v-model="hform.HBeginDate" placeholder="请选择保养开始日期" />
|
</picker>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>保养结束:</view>
|
<view class="right">
|
<picker mode="date" v-model="hform.HEndDate" @change="HEndDateChange">
|
<input name="HEndDate" disabled v-model="hform.HEndDate" placeholder="请选择保养结束日期" />
|
</picker>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>设备保养规程:</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHEquipMaintainRuleInterNo" placeholder="请选择设备保养规程" v-model="hform.HEquipMaintainRuleInterNo" @input="HEquipMaintainRuleInterNoChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item" style="align-items: flex-start;">
|
<view class="title">摘要:</view>
|
<view class="right" style="min-height: 150rpx;">
|
<textarea name="HExplanation" v-model="hform.HExplanation" auto-height maxlength="-1" placeholder="请输入摘要"></textarea>
|
</view>
|
</view>
|
|
<view class="tab_area"></view>
|
|
<view class="form-item" style="align-items: flex-start;">
|
<view class="title">备注:</view>
|
<view class="right" style="min-height: 150rpx;">
|
<textarea name="HRemark" v-model="hform.HRemark" auto-height maxlength="-1" placeholder="请输入备注"></textarea>
|
</view>
|
</view>
|
|
<view class="form-item">
|
<view class="tip"><text>*</text>注: 请点击下方绿色新增按钮添加保养项信息(必填)</view>
|
</view>
|
|
<!-- <view class="btns">
|
<button class="btn1" size="mini">保养项信息</button>
|
<button class="btn2" size="mini">配件信息</button>
|
</view> -->
|
|
<!-- <view class="form-item">
|
<view class="title">单据日期:</view>
|
<view class="right">
|
<uni-datetime-picker v-model="ticketTime">
|
<input name="ticketTime" disabled v-model="ticketTime" placeholder="请选择时间" />
|
</uni-datetime-picker>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">部门:</view>
|
<view class="right" style="width: 380rpx;">
|
<input name="input" placeholder="请输入条码" />
|
</view>
|
<uni-icons type="list" style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;" size="20"></uni-icons>
|
</view>
|
<view class="form-item">
|
<view class="title">负责人:</view>
|
<view class="right" style="width: 380rpx;">
|
<input name="input" placeholder="请输入条码" />
|
</view>
|
<uni-icons type="list" style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;" size="20"></uni-icons>
|
</view>
|
<view class="form-item">
|
<view class="title">保养项目:</view>
|
<view class="right" style="width: 380rpx;">
|
<input name="input" placeholder="请输入条码" />
|
</view>
|
<uni-icons type="list" style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;" size="20"></uni-icons>
|
</view>
|
<view class="form-item">
|
<view class="title">保养部位:</view>
|
<view class="right">
|
<input name="input" placeholder="请输入条码" />
|
</view>
|
</view> -->
|
|
<view class="bottom-btn">
|
<button class="btn-a" size="mini" @tap="submit">提交</button>
|
<button class="btn-b" size="mini" @tap="showMask = true">新增</button>
|
<button class="btn-c" size="mini" @tap="goBack">退出</button>
|
</view>
|
|
<form1 :form1List='form1List' @hformList='hformList' v-if="showMask"></form1>
|
</view>
|
</view>
|
</template>
|
<script>
|
import form1 from './form1.vue';
|
import getDateTime from '@/utils/getdateTime.js';
|
|
export default {
|
components: {form1},
|
data() {
|
return {
|
serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API',
|
arrayHEquipName:[],
|
arrayCandidates:[],
|
|
arrayHEquipMaintainRuleInterNo:[],//规程
|
HEquipMaintainRuleInterNoList:[],
|
|
hform:{
|
HInterID:0,
|
HBillNo:'',
|
HDate:getDateTime.dateTimeStr('y-m-d'),
|
HInnerBillNo:'',
|
HEquipName:'',
|
HEquipID:'',
|
HCycleUnit:'天',
|
HCheckCycle:'1',
|
HBeginDate:'',
|
HEndDate:'',
|
HExplanation:'',
|
HRemark:'',
|
},
|
|
showMask:false,
|
form1List:[],
|
form2List:[],
|
}
|
},
|
onLoad(e) {
|
if(e.hmainid){
|
this.getEditData(e.hmainid)
|
}else{
|
this.getNewData()
|
}
|
this.getHEquipList()
|
this.getHEquipMaintainRuleInterList()
|
},
|
methods: {
|
//选择单据日期
|
HDateChange(e){
|
// console.log(e.detail.value)
|
this.hform.HDate = e.detail.value
|
},
|
//保养开始选择
|
HBeginDateChange(e){
|
// console.log(e.detail.value)
|
this.hform.HBeginDate = e.detail.value
|
},
|
//保养结束选择
|
HEndDateChange(e){
|
// console.log(e.detail.value)
|
this.hform.HEndDate = e.detail.value
|
},
|
//获取设备分类数据
|
getHEquipList(){
|
uni.request({
|
url: this.serverUrl + '/PublicPageMethod/EqpList',
|
data: { sWhere: '' },
|
success: (res) => {
|
console.log(res.data.data);
|
if(res.data.count == 1){
|
this.arrayHEquipName = res.data.data
|
for(var i=0;i<res.data.data.length;i++){
|
this.arrayCandidates[i] = res.data.data[i].HName
|
}
|
this.$forceUpdate();
|
}else{
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
},
|
//选择设备分类
|
candidatesInput(e){
|
for(var i=0;i<this.arrayHEquipName.length;i++){
|
if(this.arrayHEquipName[i].HName == e){
|
this.hform.HEquipID = this.arrayHEquipName[i].HInterID
|
}
|
}
|
console.log(e,this.hform)
|
},
|
//扫码选择设备
|
toScanCode(){
|
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
|
mpaasScanModule.mpaasScan({
|
'hideAlbum': true,
|
'timeoutInterval':'10', //超时时间
|
'timeoutText':'未识别到二维码' //超时提醒
|
},(ret) => {
|
console.log(ret.resp_result)
|
uni.request({
|
url: this.serverUrl + '/Gy_EquipFileMain/Gy_MouldFileBillBarCodeInfo',
|
data: { HBarCode: ret.resp_result },
|
success: (res) => {
|
console.log(res.data);
|
if(res.data.count == 1){
|
var data = res.data.list[0][0]
|
this.hform.HEquipID = data.hmainid
|
this.hform.HEquipName = data.设备名称
|
}
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
})
|
},
|
|
//获取设备保养规程数据
|
getHEquipMaintainRuleInterList(){
|
uni.request({
|
url: this.serverUrl + '/Sb_EquipMaintainRuleBill/GetEquipMaintainRuleList',
|
data: { sWhere: '', user: uni.getStorageSync('HUserName') },
|
success: (res) => {
|
if(res.data.count == 1){
|
this.HEquipMaintainRuleInterNoList = res.data.data
|
for(var i=0;i<res.data.data.length;i++){
|
this.arrayHEquipMaintainRuleInterNo[i] = res.data.data[i].单据号
|
}
|
this.$forceUpdate();
|
}else{
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
},
|
//选择设备保养规程
|
HEquipMaintainRuleInterNoChange(e){
|
for(var i=0;i<this.HEquipMaintainRuleInterNoList.length;i++){
|
if(this.HEquipMaintainRuleInterNoList[i].单据号 == e){
|
this.hform.HEquipMaintainRuleInterID = this.HEquipMaintainRuleInterNoList[i].hmainid
|
//子表
|
uni.request({
|
url: this.serverUrl + '/Sb_EquipMaintainRuleBill/Sb_EquipMaintainRuleBillSubAndSubItem',
|
data: { HInterID: this.hform.HEquipMaintainRuleInterID },
|
success: (res) => {
|
if(res.data.count == 1){
|
this.form1List = res.data.list[0];
|
console.log(2,res.data.list[0]);
|
}else{
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
}
|
}
|
},
|
|
hformList(e){
|
console.log(e)
|
this.form1List = e
|
this.showMask = false
|
},
|
|
//编辑
|
getEditData(hmainid){
|
//主表
|
uni.request({
|
url: this.serverUrl + '/Sb_EquipMaintainPlanBill/Sb_EquipMaintainPlanBillListCheckDetai',
|
data: { HID: hmainid },
|
success: (res) => {
|
console.log(res.data.data.h_v_Sb_EquipMaintainPlanBill_Edit);
|
if(res.data.code == 1){
|
var data = res.data.data.h_v_Sb_EquipMaintainPlanBill_Edit[0]
|
this.hform = {
|
HInterID:hmainid,
|
HBillNo:data.单据号,
|
HDate:data.日期.substr(0,10),
|
HInnerBillNo:data.内部单据号,
|
HEquipName:data.设备名称,
|
HEquipID:data.设备ID,
|
HCycleUnit:data.周期单位,
|
HCheckCycle:data.保养周期,
|
HBeginDate:data.开始日期.substr(0,10),
|
HEndDate:data.结束日期.substr(0,10),
|
HExplanation:data.摘要,
|
HRemark:data.表头备注,
|
}
|
}else{
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
//子表
|
uni.request({
|
url: this.serverUrl + '/Sb_EquipMaintainPlanBill/Sb_EquipMaintainPlanBillListProjectDetaiNew',
|
data: { HInterID: hmainid },
|
success: (res) => {
|
if(res.data.count == 1){
|
this.form1List = res.data.list[0];
|
console.log(res.data.list[0]);
|
}else{
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
},
|
//新增
|
getNewData(){
|
uni.request({
|
url: this.serverUrl + '/Web/GetMAXNum',
|
data: { HBillType: '3902' },
|
success: (res) => {
|
// console.log(res.data)
|
if(res.data.count == 1){
|
this.hform.HInterID = 0
|
this.hform.HBillNo = res.data.data[0].HBillNo
|
}else{
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
},
|
|
submit() {
|
if(!this.hform.HDate){
|
uni.showToast({
|
title:'请选择日期',
|
icon:'none'
|
})
|
}else if(!this.hform.HEquipID){
|
uni.showToast({
|
title:'请选择设备',
|
icon:'none'
|
})
|
}else if(!this.hform.HCheckCycle || this.hform.HCheckCycle == '0'){
|
uni.showToast({
|
title:'请输入有效的保养周期',
|
icon:'none'
|
})
|
}else if(!this.hform.HBeginDate){
|
uni.showToast({
|
title:'请选择保养开始日期',
|
icon:'none'
|
})
|
}else if(!this.hform.HEndDate){
|
uni.showToast({
|
title:'请选择保养结束日期',
|
icon:'none'
|
})
|
}else if(!this.hform.HEquipMaintainRuleInterID){
|
uni.showToast({
|
title:'请选择设备保养规程',
|
icon:'none'
|
})
|
}else if(this.form1List.length == 0){
|
uni.showToast({
|
title:'请新增保养项信息,保养项不可为空',
|
icon:'none'
|
})
|
}else{
|
uni.showLoading({
|
title:'请稍候'
|
})
|
var sMainStr = JSON.stringify(this.hform);
|
var sSubStr = JSON.stringify(this.form1List);
|
this.form2List = [{
|
HManagerID: 0,
|
HManagerName: '',
|
HManagerNumber: '',
|
HMaterID: 0,
|
HMaterName: '',
|
HMaterNumber: '',
|
HQty: 0,
|
HQtyMust: 0,
|
HRemark: "",
|
HUnitID: 0,
|
HUnitName: '',
|
HUnitNumber: '',
|
}]
|
var sSubStr1 = JSON.stringify(this.form2List);
|
var sMainSub = sMainStr + ';' + sSubStr + ";" + sSubStr1 + ";" + uni.getStorageSync('HUserName');
|
console.log(sMainSub);
|
uni.request({
|
url: this.serverUrl + '/Sb_EquipMaintainPlanBill/SaveEquipMaintainPlanBillList',
|
method:'POST',
|
dataType:"json",
|
data:{ msg: sMainSub },
|
success: (res) => {
|
console.log(1,res);
|
uni.hideLoading()
|
if(res.data.count == 1){
|
let pages = getCurrentPages();
|
let prePage = pages[pages.length - 2];
|
prePage.$vm.getList()
|
setTimeout(()=>{
|
uni.navigateBack()
|
},1000)
|
}
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
}
|
},
|
goBack(){
|
uni.navigateBack()
|
}
|
// reset() {
|
// console.log('清空数据')
|
// this.hform = {
|
// HInterID:'',
|
// HBillNo:'',
|
// HDate:'',
|
// HInnerBillNo:'',
|
// HEquipName:'',
|
// HEquipID:'',
|
// HCycleUnit:'天',
|
// HCheckCycle:'1',
|
// HBeginDate:'',
|
// HEndDate:'',
|
// HExplanation:'',
|
// HRemark:'',
|
// }
|
// this.form1List = []
|
// }
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.form{
|
width: 650rpx;
|
margin: 20rpx auto;
|
padding-bottom: 240rpx;
|
}
|
.tab_area{
|
width: 100%;
|
height: 50rpx;
|
}
|
.form-item{
|
display: flex;
|
align-items: center;
|
font-size: 30rpx;
|
padding: 6rpx 0;
|
.title{
|
width: 208rpx;
|
}
|
.right{
|
width: 450rpx;
|
border-radius: 22rpx;
|
border: 1px solid #acacac;
|
}
|
.righton{
|
width: 450rpx;
|
border-radius: 22rpx;
|
border: 1px solid #e4e4e4;
|
background-color: #e4e4e4;
|
}
|
text{
|
color: red;
|
font-weight: bold;
|
}
|
input{
|
width: 100%;
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
}
|
textarea{
|
width: 98%;
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
}
|
.tip{
|
color: #da9100;
|
margin-top: 20rpx;
|
}
|
}
|
.btns{
|
display: flex;
|
justify-content: space-around;
|
margin-top: 80rpx;
|
button{
|
width: 240rpx;
|
height: 72rpx;
|
line-height: 72rpx;
|
font-size: 28rpx;
|
}
|
.btn1{
|
background-color: #b9deff;
|
color: #4d637c;
|
}
|
.btn2{
|
background-color: #ffe098;
|
color: #6c4800;
|
}
|
}
|
.bottom-btn{
|
width: 100%;
|
// height: 120rpx;
|
position: fixed;
|
bottom: 0;
|
left: 0;
|
background-color: #fff;
|
box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
|
padding: 30rpx 40rpx 40rpx 40rpx;
|
button{
|
border-radius: 50rpx;
|
width: 180rpx;
|
height: 66rpx;
|
line-height: 66rpx;
|
font-size: 28rpx;
|
}
|
.btn-a{
|
background-color: #3A78FF;
|
color: #fff;
|
}
|
.btn-b{
|
background-color: #41a863;
|
color: #fff;
|
margin-left: 30rpx;
|
}
|
.btn-c{
|
background-color: #acacac;
|
color: #fff;
|
position: absolute;
|
right: 120rpx;
|
}
|
}
|
</style>
|