<template>
|
<view class="content">
|
<view class="mains" v-if="num==1">
|
<view class="title">故障登记信息</view>
|
<view class="table" >
|
<uni-collapse accordion>
|
<uni-collapse-item v-for="(item,index) in hformList" :key="index">
|
<template v-slot:title>
|
<view class="table-line">
|
<view class="line">
|
<view class="font">
|
<text>故障原因:</text>{{item.HConkReasonName}}
|
</view>
|
<view>
|
<text>负责人:</text>{{item.HManagerName}}
|
</view>
|
</view>
|
</view>
|
</template>
|
<view class="table-detail">
|
<view class="detail">
|
<text>故障原因描述:</text>{{item.HClaim?item.HClaim:'暂无描述'}}
|
</view>
|
<view class="detail" v-if="item.HRemark">
|
<text>备注:</text>{{item.HRemark}}
|
</view>
|
<view class="btns">
|
<button class="btnd" size="mini" @tap="edit(index)">编辑</button>
|
<button class="btne" size="mini" @tap="del(index)">删除</button>
|
</view>
|
</view>
|
</uni-collapse-item>
|
</uni-collapse>
|
</view>
|
<view class="foot">
|
<button class="btna" size="mini" @tap="creat">新增</button>
|
<button class="btnb" size="mini" @tap="over">确认</button>
|
</view>
|
</view>
|
|
<view class="mains" v-if="num == 2">
|
<view class="title">故障编辑</view>
|
<view class="form">
|
<view class="form-item">
|
<view class="item-title">故障原因:</view>
|
<view class="item-right">
|
<uni-combox :candidates="arrayHConkReasonName" placeholder="请选择故障原因" v-model="hform.HConkReasonName" @input="HConkReasonNameInput"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="item-title">负责人:</view>
|
<view class="item-right">
|
<uni-combox :candidates="arrayHManagerName" placeholder="请选择负责人" v-model="hform.HManagerName" @input="HManagerNameInput"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item" style="align-items: flex-start;">
|
<view class="item-title">故障原因描述:</view>
|
<view class="item-right" style="min-height: 150rpx;">
|
<textarea v-model="hform.HConkExplanation" auto-height maxlength="-1" placeholder="请输入故障原因描述"></textarea>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="item-title">备注:</view>
|
<view class="item-right">
|
<input v-model="hform.HRemark" placeholder="请输入备注" />
|
</view>
|
</view>
|
</view>
|
<view class="foot">
|
<button class="btnc" size="mini" @tap="back">返回</button>
|
<button class="btnb" size="mini" @tap="add">确认</button>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API',
|
num:1,
|
editIndex:-1,
|
|
HConkReasonNameList:[],
|
arrayHConkReasonName:[],
|
|
HManagerNameList:[],
|
arrayHManagerName:[],
|
|
hformList:[],
|
hform:{},
|
}
|
},
|
props: {
|
form1List: {
|
type: Array,
|
default () {
|
return []
|
}
|
},
|
},
|
created() {
|
this.getHConkReasonList()
|
this.getHManagerNameList()
|
this.hformList = this.form1List
|
},
|
methods: {
|
//故障原因
|
getHConkReasonList(){
|
uni.request({
|
url: this.serverUrl + '/PublicPageMethod/FaultReasonList',
|
data: { sWhere: '' },
|
success: (res) => {
|
console.log(1,res.data.data);
|
if(res.data.count == 1){
|
this.HConkReasonNameList = res.data.data
|
for(var i=0;i<res.data.data.length;i++){
|
this.arrayHConkReasonName[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'
|
})
|
},
|
});
|
},
|
HConkReasonNameInput(e){
|
console.log(e)
|
for(var i=0;i<this.HConkReasonNameList.length;i++){
|
if(this.HConkReasonNameList[i].HName == e){
|
this.hform.HConkReasonID = this.HConkReasonNameList[i].HItemID
|
this.hform.HConkReasonCode = this.HConkReasonNameList[i].HNumber
|
}
|
}
|
},
|
|
//负责人
|
getHManagerNameList(){
|
uni.request({
|
url: this.serverUrl + '/PublicPageMethod/UserList',
|
data: { sWhere: '' },
|
success: (res) => {
|
console.log(2,res.data.data);
|
if(res.data.count == 1){
|
this.HManagerNameList = res.data.data
|
for(var i=0;i<res.data.data.length;i++){
|
this.arrayHManagerName[i] = res.data.data[i].HName
|
}
|
}else{
|
uni.showToast({
|
title:res.data.Message,
|
icon:'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
},
|
HManagerNameInput(e){
|
console.log(e)
|
for(var i=0;i<this.HManagerNameList.length;i++){
|
if(this.HManagerNameList[i].HName == e){
|
this.hform.HManagerID = this.HManagerNameList[i].HItemID
|
this.hform.HManagerCode = this.HManagerNameList[i].HNumber
|
this.hform.HManagerName = this.HManagerNameList[i].HName
|
}
|
}
|
},
|
|
creat(){
|
this.hform={
|
HConkReasonID:'',
|
HConkReasonCode:'',
|
HConkReasonName:'',
|
HConkExplanation:'',
|
HManagerID:'',
|
HManagerCode:'',
|
HManagerName:'',
|
HRemark:'',
|
},
|
this.num = 2
|
},
|
back(){
|
this.hformList[this.editIndex] = uni.getStorageSync('hform')
|
uni.removeStorageSync('hform')
|
this.editIndex = -1
|
this.num = 1
|
},
|
edit(index){
|
this.hform = this.hformList[index]
|
uni.setStorageSync('hform', this.hformList[index]);
|
this.editIndex = index
|
this.num = 2
|
},
|
del(index){
|
this.hformList.splice(index, 1);
|
},
|
add(){
|
if(!this.hform.HConkReasonID){
|
uni.showToast({
|
title:'请选择故障原因',
|
icon:'none'
|
})
|
}else if(!this.hform.HManagerID){
|
uni.showToast({
|
title:'请选择负责人',
|
icon:'none'
|
})
|
}else{
|
uni.showModal({
|
title: '提示',
|
content: '是否确认提交故障原因,是的话将添加到故障原因信息中。',
|
success: (res) => {
|
if (res.confirm) {
|
if(this.editIndex > -1){
|
this.hformList.splice(this.editIndex, 1);
|
this.editIndex = -1
|
|
uni.showToast({
|
title:'修改完成',
|
icon:'none'
|
})
|
}
|
this.num = 1
|
this.hformList.unshift(this.hform)
|
}
|
}
|
});
|
}
|
},
|
|
over(){
|
this.$emit('hformList', this.hformList)
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.content{
|
width: 100%;
|
height: 100%;
|
position: fixed;
|
z-index: 999;
|
top: 0;
|
left: 0;
|
background-color: rgba(0, 0, 0, 0.5);
|
}
|
|
.mains{
|
width: 88%;
|
height: 88%;
|
background-color: #f5f5f5;
|
margin: 12% auto;
|
border-radius: 14rpx;
|
.title{
|
width: 100%;
|
height: 6%;
|
background-color: #fff;
|
border-bottom: 1px solid #acacac;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
border-radius: 14rpx 14rpx 0 0;
|
}
|
.foot{
|
padding: 0 40rpx;
|
height: 8%;
|
background-color: #fff;
|
border-top: 1px solid #eee;
|
display: flex;
|
align-items: center;
|
border-radius: 0 0 14rpx 14rpx;
|
button{
|
width: 180rpx;
|
}
|
}
|
.table{
|
width: 100%;
|
height: 86%;
|
overflow: hidden;
|
overflow-y: auto;
|
.table-line{
|
padding: 18rpx 10rpx 18rpx 20rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
.line{
|
font-size: 30rpx;
|
color: #555;
|
text{
|
color: #999;
|
font-size: 27rpx;
|
}
|
.font{
|
color: #333;
|
line-height: 150%;
|
}
|
}
|
}
|
.table-detail{
|
font-size: 30rpx;
|
color: #555;
|
padding: 0 10rpx 24rpx 20rpx;
|
text{
|
color: #999;
|
font-size: 27rpx;
|
}
|
.detail{}
|
.btns{
|
text-align: right;
|
margin-top: 14rpx;
|
button{
|
width: 150rpx;
|
margin-right: 30rpx;
|
}
|
}
|
}
|
}
|
.form{
|
height: 82%;
|
padding: 4%;
|
overflow: hidden;
|
overflow-y: auto;
|
.form-item{
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
font-size: 30rpx;
|
padding: 10rpx 0;
|
.item-title{
|
width: 140rpx;
|
text{
|
color: red;
|
font-weight: bold;
|
}
|
}
|
.item-right{
|
width: 450rpx;
|
border-radius: 22rpx;
|
border: 1px solid #acacac;
|
background-color: #fff;
|
}
|
input{
|
width: 100%;
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
}
|
textarea{
|
width: 98%;
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
}
|
}
|
}
|
}
|
|
.btna{
|
background-color: #41a863;
|
color: #fff;
|
}
|
.btnb{
|
background-color: #3A78FF;
|
color: #fff;
|
}
|
.btnc{
|
background-color: #acacac;
|
color: #fff;
|
}
|
.btnd{
|
background-color: #d98d00;
|
color: #fff;
|
}
|
.btne{
|
background-color: #da0000;
|
color: #fff;
|
}
|
</style>
|