You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
283 lines
5.3 KiB
283 lines
5.3 KiB
10 months ago
|
<template>
|
||
|
<!-- 设备 -->
|
||
|
<view class="add-form-container">
|
||
|
<Form :form='form' :data='data' ref="form1"></Form>
|
||
|
<SparePartsCard :subForm='subForm' :data='data' @addSubForm='addSubForm' @delSubFormItem='delSubFormItem'>
|
||
|
</SparePartsCard>
|
||
|
<view class="footer">
|
||
|
<view class="btns">
|
||
|
<button class="sure" @click="submit">提交</button>
|
||
|
</view>
|
||
|
<view style="height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom);"></view>
|
||
|
</view>
|
||
|
<u-popup v-model="isPopupShow" mode="center" border-radius="14">
|
||
|
<view class="popup-title">添加备件</view>
|
||
|
<view class="popup">
|
||
|
<Form :form='subForm' :data='data' ref="form2"></Form>
|
||
|
</view>
|
||
|
<view class="popup-footer">
|
||
|
<view @click="cancle">取消</view>
|
||
|
<view class="sure" @click="addSpare">确认</view>
|
||
|
</view>
|
||
|
</u-popup>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import Form from '@/components/form/index.vue'
|
||
|
import SparePartsCard from '@/components/sparePartsCard/index.vue'
|
||
|
export default {
|
||
|
components: {
|
||
|
Form,
|
||
|
SparePartsCard
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
form: {
|
||
|
disabled: false,
|
||
|
visible: true,
|
||
|
loading: false,
|
||
|
labelWidth: '180rpx',
|
||
|
border: true,
|
||
|
errorType: ['toast'],
|
||
|
formData: [{
|
||
|
type: 'text',
|
||
|
field: 'code',
|
||
|
label: '申请主题',
|
||
|
disabled: false,
|
||
|
required: true,
|
||
|
value: ''
|
||
|
}, {
|
||
|
type: 'singleColumn',
|
||
|
field: 'type',
|
||
|
label: '申请类型',
|
||
|
disabled: false,
|
||
|
required: true,
|
||
|
list: [{
|
||
|
label: '类型1',
|
||
|
value: 1
|
||
|
}, {
|
||
|
label: '类型2',
|
||
|
value: 2
|
||
|
}, {
|
||
|
label: '类型3',
|
||
|
value: 3
|
||
|
}]
|
||
|
}],
|
||
|
},
|
||
|
data: {
|
||
|
name: '',
|
||
|
subList: [{
|
||
|
name: '备件111111',
|
||
|
stork: '1',
|
||
|
number: '30',
|
||
|
}, {
|
||
|
name: '备件111111',
|
||
|
stork: '1',
|
||
|
number: '30',
|
||
|
}]
|
||
|
},
|
||
|
subForm: {
|
||
|
formLabel: '申请备件',
|
||
|
formField: 'subList',
|
||
|
required: true,
|
||
|
isShowButton: true,
|
||
|
disabled: false,
|
||
|
visible: true,
|
||
|
loading: false,
|
||
|
labelWidth: '180rpx',
|
||
|
border: true,
|
||
|
errorType: ['toast'],
|
||
|
formData: [{
|
||
|
type: 'singleColumn',
|
||
|
field: 'name',
|
||
|
label: '备件名称',
|
||
|
disabled: false,
|
||
|
required: true,
|
||
|
span: 12,
|
||
|
list: [{
|
||
|
label: '类型1',
|
||
|
value: 1
|
||
|
}, {
|
||
|
label: '类型2',
|
||
|
value: 2
|
||
|
}, {
|
||
|
label: '类型3',
|
||
|
value: 3
|
||
|
}]
|
||
|
}, {
|
||
|
type: 'text',
|
||
|
field: 'stork',
|
||
|
label: '库存',
|
||
|
disabled: false,
|
||
|
required: true,
|
||
|
isList: true,
|
||
|
span: 6
|
||
|
}, {
|
||
|
type: 'text',
|
||
|
field: 'number',
|
||
|
label: '数量',
|
||
|
disabled: false,
|
||
|
required: true,
|
||
|
isList: true,
|
||
|
span: 6
|
||
|
}],
|
||
|
},
|
||
|
isPopupShow: false,
|
||
|
|
||
|
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
// 触发提交表单
|
||
|
submit() {
|
||
|
console.log('表单数据信息1:', this.data);
|
||
|
this.$refs.form1.$refs.form.validate().then(res => {
|
||
|
console.log('表单数据信息:', res);
|
||
|
}).catch(err => {
|
||
|
console.log('表单错误信息:', err);
|
||
|
})
|
||
|
console.log(this.data.subList)
|
||
|
let isTrue = this.data.subList.some(item => {
|
||
|
return !item.name || item.number === ''
|
||
|
})
|
||
|
if (isTrue) {
|
||
|
this.$modal.showToast('申请备件信息请填写完全')
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
},
|
||
|
// 重置
|
||
|
reset() {
|
||
|
console.log('表单数据信息1:', this.data);
|
||
|
this.data = {}
|
||
|
},
|
||
|
// 添加表格表单
|
||
|
addSubForm() {
|
||
|
console.log(5)
|
||
|
this.isPopupShow = true
|
||
|
// this.data.subList.push({
|
||
|
// name:1,
|
||
|
// stork:2,
|
||
|
// number:'300'
|
||
|
// })
|
||
|
},
|
||
|
// 添加备件
|
||
|
addSpare(){
|
||
|
// this.data.subList
|
||
|
this.$refs.form2.$refs.form.validate().then(res => {
|
||
|
console.log('表单数据信息:', res);
|
||
|
}).catch(err => {
|
||
|
console.log('表单错误信息:', err);
|
||
|
})
|
||
|
},
|
||
|
// 取消添加备件
|
||
|
cancle(){
|
||
|
this.isPopupShow = false
|
||
|
},
|
||
|
delTableFormItem(index) {
|
||
|
this.data.subList.splice(index, 1)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
.add-form-container {
|
||
|
min-height: calc(100vh - 140rpx);
|
||
|
background: white;
|
||
|
padding: 0px 30rpx 140rpx;
|
||
|
}
|
||
|
|
||
|
.list {
|
||
|
padding-bottom: 20rpx;
|
||
|
|
||
|
.item {
|
||
|
margin-top: 20rpx;
|
||
|
background: white;
|
||
|
padding: 30rpx;
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
|
||
|
image {
|
||
|
width: 160rpx;
|
||
|
height: 160rpx;
|
||
|
margin-right: 20rpx;
|
||
|
}
|
||
|
|
||
|
.title {
|
||
|
font-size: 32rpx;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
|
||
|
.dec1 {
|
||
|
font-size: 28rpx;
|
||
|
margin-top: 16rpx;
|
||
|
color: #acacac;
|
||
|
}
|
||
|
|
||
|
.dec2 {
|
||
|
font-size: 28rpx;
|
||
|
margin-top: 6rpx;
|
||
|
color: #acacac;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.footer {
|
||
|
position: fixed;
|
||
|
bottom: 0px;
|
||
|
left: 0px;
|
||
|
width: 100%;
|
||
|
background: white;
|
||
|
}
|
||
|
|
||
|
.btns {
|
||
|
display: flex;
|
||
|
|
||
|
padding: 20rpx;
|
||
|
box-shadow: 0px -2rpx 20rpx rgba(0, 0, 0, 0.1);
|
||
|
|
||
|
|
||
|
button {
|
||
|
flex: 1;
|
||
|
}
|
||
|
|
||
|
.sure {
|
||
|
background: #409eff;
|
||
|
color: white;
|
||
|
border-radius: 8rpx;
|
||
|
|
||
|
&::after {
|
||
|
border: 1px solid #409eff;
|
||
|
border-radius: 0px;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.popup-title {
|
||
|
text-align: center;
|
||
|
font-size: 32rpx;
|
||
|
font-weight: bold;
|
||
|
color: #409eff;
|
||
|
padding: 30rpx
|
||
|
}
|
||
|
|
||
|
.popup {
|
||
|
width: 600rpx;
|
||
|
padding: 0rpx 60rpx 0rpx;
|
||
|
|
||
|
}
|
||
|
.popup-footer{
|
||
|
display: flex;
|
||
|
border-top: 1px solid #e4e4e4;
|
||
|
view{
|
||
|
line-height: 100rpx;
|
||
|
flex: 1;
|
||
|
text-align: center;
|
||
|
&.sure{
|
||
|
color: #409eff;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|