<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.HMaintainItem}}
|
</view>
|
<view>
|
<text>保养部位:</text>{{item.HMaintainPart}}
|
</view>
|
</view>
|
<view class="line">
|
<text>负责人:</text>{{item.HManagerName}}
|
</view>
|
</view>
|
</template>
|
<view class="table-detail">
|
<view class="detail">
|
<text>具体要求:</text>{{item.HClaim?item.HClaim:'暂无具体要求'}}
|
</view>
|
<view class="detail">
|
<text>是否合格:</text>{{ item.HMaintainResult ? '合格' : '不合格' }}
|
</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="arrayHMaintainItem" placeholder="请选择保养项目" v-model="hform.HMaintainItem"
|
@input="HMaintainItemInput"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="item-title">保养部位:</view>
|
<view class="item-right">
|
<input v-model="hform.HMaintainPart" placeholder="请输入保养部位" />
|
</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.HClaim" auto-height maxlength="-1" placeholder="请输入具体要求"></textarea>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="item-title">结果:</view>
|
<view class="right" style="display: flex; align-items: center; padding: 0 20rpx; border: none;">
|
<view style="display: flex; align-items: center;">
|
<checkbox-group @change="onResultChange">
|
<checkbox :value="'true'" :checked="hform.HMaintainResult"></checkbox>
|
</checkbox-group>
|
<text style="margin-left: 10rpx;">合格</text>
|
</view>
|
</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,
|
|
HMaintainItemList: [],
|
arrayHMaintainItem: [],
|
|
HManagerNameList: [],
|
arrayHManagerName: [],
|
|
hformList: [],
|
hform: {},
|
}
|
},
|
props: {
|
form1List: {
|
type: Array,
|
default () {
|
return []
|
}
|
},
|
},
|
created() {
|
this.getHMaintainItemList()
|
this.getHManagerNameList()
|
this.hformList = this.form1List
|
},
|
methods: {
|
// 新增:处理复选框变化事件
|
onResultChange(e) {
|
this.hform.HMaintainResult = e.detail.value.includes('true');
|
},
|
|
//保养项目
|
getHMaintainItemList() {
|
uni.request({
|
url: this.serverUrl + '/PublicPageMethod/MaintainList',
|
data: {
|
sWhere: "where HStopFlag=0 and HEndFlag=1"
|
},
|
success: (res) => {
|
console.log(1, res.data.data);
|
if (res.data.count == 1) {
|
this.HMaintainItemList = res.data.data
|
for (var i = 0; i < res.data.data.length; i++) {
|
this.arrayHMaintainItem[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'
|
})
|
},
|
});
|
},
|
HMaintainItemInput(e) {
|
console.log(e)
|
for (var i = 0; i < this.HMaintainItemList.length; i++) {
|
if (this.HMaintainItemList[i].HName == e) {
|
this.hform.HMaintainItemID = this.HMaintainItemList[i].HItemID
|
this.hform.HMaintainItemNumber = this.HMaintainItemList[i].HNumber
|
this.hform.HMaintainItem = this.HMaintainItemList[i].HName
|
}
|
}
|
},
|
|
//负责人
|
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.HManagerNumber = this.HManagerNameList[i].HNumber
|
this.hform.HManagerName = this.HManagerNameList[i].HName
|
}
|
}
|
},
|
|
creat() {
|
this.hform = {
|
HMaintainItemID: '',
|
HMaintainItemNumber: '',
|
HMaintainItem: '',
|
HMaintainPart: '',
|
HClaim: '',
|
HManagerID: '',
|
HManagerNumber: '',
|
HManagerName: '',
|
HMaintainResult: true, // 默认设为true,即默认勾选
|
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.HMaintainItemID) {
|
uni.showToast({
|
title: '请选择保养项目信息',
|
icon: 'none'
|
})
|
} else if (!this.hform.HMaintainPart) {
|
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>
|