<template>
|
<view class="body">
|
<view class="main_view">
|
<u-form :model="query" ref="query">
|
<u-form-item label="杂工事项" required :label-width="180" prop="handymanItemName">
|
<u-input v-model="query.handymanItemName" placeholder="请输入"/>
|
<!-- <u-icon name="arrow-right" @click="goPage(0)"></u-icon> -->
|
</u-form-item>
|
<u-form-item label="时长" required :label-width="180" prop="duration">
|
<u-input v-model="query.duration" placeholder="请输入"/>
|
</u-form-item>
|
<u-form-item label="生产人员" required :label-width="180" prop="prodUser">
|
<u-input v-model="query.prodUser" type="select" placeholder="请选择"/>
|
<u-icon name="arrow-right" @click="goPage(1)"></u-icon>
|
</u-form-item>
|
<u-form-item label="责任人" required :label-width="180" prop="principalName">
|
<u-input v-model="query.principalName" type="select" placeholder="请选择"/>
|
<u-icon name="arrow-right" @click="goPage(2)"></u-icon>
|
</u-form-item>
|
</u-form>
|
</view>
|
<view class="bottom">
|
<u-button class="u-button" type="primary" @click="submit" :loading="loading">提交</u-button>
|
</view>
|
<u-select v-model="handymanItemListShow" :list="handymanItemList" @confirm="confirmOperation"></u-select>
|
<u-select v-model="handymanRecordListShow" :list="handymanRecordList" @confirm="confirmHandymanRecord"></u-select>
|
</view>
|
</template>
|
|
<script>
|
import UIcon from "../../../uview-ui/components/u-icon/u-icon.vue";
|
|
export default {
|
name: "handyman",
|
// import 引入的组件需要注入到对象中才能使用
|
components: {UIcon},
|
data() {
|
// 这里存放数据
|
return {
|
query: {
|
duration: '', // 时长
|
dutyNo: '', // 日报编号
|
dutyTime: '', // 日报时间
|
handymanItem: '', // 杂工事项
|
principalId: '', // 负责人id
|
prodStaffNoList: '', // 关联的生产人员id[list]
|
prodUser: '', // 生产人员
|
principalName: '', // 负责人名称
|
handymanRecordApprover:'',
|
handymanRecordApproverName:'',
|
handymanRecordId:0,
|
handymanItemName: '', // 杂工事项名称
|
},
|
rules: {
|
handymanItemName: [
|
{
|
required: true,
|
message: '请选择杂工事项',
|
// 可以单个或者同时写两个触发验证方式
|
trigger: ['change'],
|
}
|
],
|
duration: [
|
{
|
required: true,
|
message: '请输入',
|
trigger: ['change','blur'],
|
},
|
// 正则判断数字
|
{
|
validator: (rule, value, callback) => {
|
return this.$u.test.amount(value);
|
},
|
message: '请输入正确',
|
// 触发器可以同时用blur和change
|
trigger: ['change','blur'],
|
}
|
],
|
prodUser: [
|
{
|
required: true,
|
message: '请选择生产人员',
|
// 可以单个或者同时写两个触发验证方式
|
trigger: ['change'],
|
}
|
],
|
principalName: [
|
{
|
required: true,
|
message: '请选择责任人',
|
// 可以单个或者同时写两个触发验证方式
|
trigger: ['change'],
|
}
|
],
|
},
|
handymanItemList: [],
|
handymanItemListShow: false,
|
handymanRecordList: [],
|
handymanRecordListShow: false,
|
loading: false
|
}
|
},
|
onReady() {
|
this.$refs.query.setRules(this.rules); // 复制校验
|
// 进入页面查询杂工事项列表
|
this.handymanItemList = []
|
this.getHandymanItem()
|
// 进入页面查询责任人列表
|
this.getHandymanRecord()
|
},
|
onLoad(e) {
|
let s = []
|
e.staffList.split(',').forEach(i => {
|
s.push(i)
|
})
|
console.log(s)
|
this.query.prodStaffNoList =s
|
this.query.prodUser =e.userList
|
this.query.dutyNo = e.dutyNo
|
this.query.dutyTime = e.updateTime
|
uni.$on('checkedList', (data) => {
|
let staffNameList = []
|
let staffNoList = []
|
data.forEach(i => {
|
staffNameList.push(i.staffName)
|
staffNoList.push(i.staffNo)
|
})
|
this.query.prodUser = staffNameList.join(',')
|
this.query.prodStaffNoList = staffNoList
|
});
|
},
|
// 方法集合
|
methods: {
|
goPage (index) {
|
switch (index) {
|
case 0:
|
this.handymanItemListShow = true
|
break
|
case 1:
|
const list = []
|
if(this.query.prodStaffNoList.length > 0) {
|
let staffList = this.query.prodUser.split(',')
|
let staffNoList = this.query.prodStaffNoList
|
for (const i in staffList) {
|
const obj = {
|
staffName: staffList[i],
|
staffNo: staffNoList[i]
|
}
|
list.push(obj)
|
}
|
}
|
uni.navigateTo({
|
url: '/pages/daily/production-person/production-person?list=' + encodeURIComponent(JSON.stringify(list))
|
})
|
break
|
case 2:
|
this.handymanRecordListShow = true
|
break
|
}
|
},
|
submit () {
|
this.$refs.query.validate(valid => {
|
if (valid) {
|
let params = JSON.parse(JSON.stringify(this.query))
|
params.dutyTime = params.dutyTime + ' 00:00:00'
|
console.log(params)
|
this.$u.api.dailyPaper.handymanRecord(params).then((res) => {
|
if (res.code === 0) {
|
this.loading = true;
|
uni.navigateBack({
|
//关闭当前页面,返回上一页面或多级页面。
|
delta:1
|
});
|
this.loading = false;
|
}
|
})
|
} else {
|
this.$u.toast('请填写完整数据')
|
}
|
});
|
},
|
getHandymanItem () {
|
this.$u.api.dictData({dictType: 'handyman_item'}).then((res) => {
|
if (res.code === 0 && res.data.length > 0) {
|
res.data.forEach(item => {
|
const obj = Object.assign({
|
label: item.label,
|
value: item.value,
|
})
|
this.handymanItemList.push(obj)
|
})
|
}
|
})
|
},
|
getHandymanRecord () {
|
this.$u.api.dailyPaper.principal().then((res) => {
|
if (res.code === 0 && res.data.length > 0) {
|
res.data.forEach(item => {
|
const obj = Object.assign({
|
label: item.fullName,
|
value: item.id,
|
})
|
this.handymanRecordList.push(obj)
|
})
|
console.log(res)
|
this.query.principalId = this.handymanRecordList[0].value
|
this.query.principalName = this.handymanRecordList[0].label
|
this.handymanRecordApprover = this.handymanRecordList[0].value
|
}
|
})
|
},
|
confirmOperation (e) {
|
this.query.handymanItem = e[0].value
|
this.query.handymanItemName = e[0].label
|
},
|
confirmHandymanRecord (e) {
|
this.query.principalId = e[0].value
|
this.query.principalName = e[0].label
|
}
|
},
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.body {
|
background: linear-gradient(to bottom, #E5F0FF, #F6F9FF);
|
box-sizing: border-box;
|
padding-top: 26rpx;
|
height: 100vh;
|
.main_view {
|
margin-top: 5rpx;
|
background: linear-gradient(180deg, #D8E8FF 0%, #FFFFFF 100%);
|
border-radius: 15rpx;
|
margin: 0 30rpx;
|
box-sizing: border-box;
|
padding: 37rpx 25rpx;
|
}
|
.bottom {
|
width: 100vw;
|
position:fixed;
|
bottom:60rpx;
|
.u-button {
|
width: 690rpx;
|
height: 80rpx;
|
background: #214DED;
|
border-radius: 8rpx;
|
font-weight: 500;
|
font-size: 34rpx;
|
color: #FFFFFF;
|
z-index: 99;
|
}
|
}
|
}
|
::v-deep.uicon-arrow-down-fill:before {
|
display: none;
|
}
|
::v-deep.u-form-item--left__content__label {
|
padding-left: 26rpx;
|
font-weight: 500;
|
font-size: 30rpx;
|
color: #4F4F4F;
|
line-height: 80rpx;
|
}
|
::v-deep.u-form-item--left__content--required {
|
left: 8rpx;
|
top: 0;
|
}
|
</style>
|