Browse Source

提交检修主子一起创建代码

master
ljlong_2630 4 months ago
parent
commit
ee87fe3b4c
  1. 7
      src/pages.json
  2. 207
      src/pages/overhaulOrder/addForm.vue
  3. 639
      src/pages/overhaulOrder/addSubItem.vue

7
src/pages.json

@ -265,6 +265,13 @@
"navigationBarBackgroundColor": "#409eff",
"navigationBarTextStyle": "white"
}
},
{
"path" : "pages/overhaulOrder/addSubItem",
"style" :
{
"navigationBarTitleText" : ""
}
}
],
"tabBar": {

207
src/pages/overhaulOrder/addForm.vue

@ -68,6 +68,82 @@
<u-icon name="arrow-right" color="#aaaaaa" size="28"></u-icon>
</view>
</u-form-item>
<view class="info" style="padding-bottom: 130rpx;">
<view class="tab">
<u-tabs :list="list" :is-scroll="false" bar-height="2" bar-width="250" v-model="current"
@change="change"></u-tabs>
</view>
<view class="list">
<view class="item " v-for="(item,index) in serviceList" :key="index"
@click="addSubForm('updata',item)">
<view class="item-box">
<view class="spare-title">
<view class="title-txt">
{{item.name}}
</view>
<view class="" @click.stop="delService(item)">
<u-icon name="trash" color="#aaaaaa" size="40"></u-icon>
</view>
</view>
<view class="dec2">
<view>预估人数</view>
<view>{{item.peoples}}</view>
</view>
<view class="dec2">
<view>预估分钟</view>
<view>{{item.estimatedMinutes}}分钟</view>
</view>
<view class="dec2">
<view>实际分钟</view>
<view>{{item.actualMinutes}}分钟</view>
</view>
<view class="dec2">
<view>责任人</view>
<view>{{item.chargePeoplesName}}</view>
</view>
<view class="dec2">
<view>完成情况</view>
<view>
{{item.status===0 || item.status === '0'? '完成':item.status===1 ||item.status === '1'?'未完成':''}}
</view>
</view>
<view class="dec2" v-if='item.status === 0 || item.status === "0"'>
<view>完成时间</view>
<view>{{$time.formatDate(item.completionTime)}}</view>
</view>
<view class="dec2">
<view>工程师确认</view>
<view>{{item.engineer}}</view>
</view>
<view class="dec2" v-if="item.status === 1 || item.status === '1'">
<view>未完成原因</view>
<view>{{item.uncompleted}}</view>
</view>
<view class="" v-show="item.items&&item.items.length>0">
<view class="dec2">
备件
</view>
<view class="items" v-for="(cur,key) in item.items" :key="key">
<view class="items-name">
{{cur.name}}
</view>
<view class="items-dec">
备件编号{{cur.number}}
</view>
<view class="items-dec">
数量{{cur.qty}}
</view>
</view>
</view>
</view>
<!-- <u-icon name="minus-circle" color="#aaaaaa" size="60" ></u-icon> -->
</view>
<view class="add-btn">
<u-button type="primary" @click="addSubForm('creat')"><u-icon name="plus-circle" color="#ffffff"
size="36"></u-icon>添加检修内容</u-button>
</view>
</view>
</view>
</u-form>
<!-- 选择维修人员 -->
<u-popup v-model="isShowSelecUser" mode="center" border-radius="14">
@ -96,6 +172,7 @@
<u-select v-model="singleColumnShow" mode="single-column" :default-value='singleColumnDefaultValue'
:list="singleColumnList" @confirm="chooseSingleColumn" @cancle='singleColumnShow = false'></u-select>
</view>
</template>
@ -127,7 +204,8 @@
deviceName: '',
deviceNumber: '',
faultTypeName: '',
maintenance:''
maintenance:'',
subList: []
})
@ -143,6 +221,10 @@
const selecUserList = ref([])//
const isShowSelecUser = ref(false)
const chooseUserInfo = ref(null)
const serviceList = ref([])
const list = ref([{
name: '检修内容'
}])
function submit() {
//
if (!form.value.describes) {
@ -174,7 +256,8 @@
factoryAreaNumber: form.value.factoryAreaNumber,
type: type.value,
faultType: form.value.faultType,
maintenance:form.value.maintenance
maintenance:form.value.maintenance,
subList: serviceList.value,
}
if (form.value.id) {
proxy.$modal.confirm('是否修改检修工单').then(() => {
@ -241,7 +324,8 @@
deviceName:'',
deviceNumber:'',
faultTypeName:'',
maintenance:''
maintenance:'',
subList: []
}
isDisabled.value = false
}
@ -355,6 +439,7 @@
deviceNumber: data.deviceNumber,
factoryAreaName: data.factoryAreaName,
faultType: data.faultType,
subList: data.subList,
}
isDisabled.value = form.value.maintenanceNumber || form.value.id ? true : false
};
@ -367,6 +452,7 @@
form.value.deviceName = data.name
form.value.factoryAreaName = data.factoryAreaName
form.value.factoryAreaNumber = data.factoryAreaNumber
form.value.subList= data.subList
isDisabled.value = true
} else {
form.value.maintenanceNumber = ''
@ -375,10 +461,25 @@
form.value.deviceName = ''
form.value.factoryAreaName = ''
form.value.factoryAreaNumber = ''
form.value.subList= []
isDisabled.value = false
}
})
//
uni.$on('handleSubmitForm', (formData) => {
// serviceList
if (formData.id) {
//
const index = serviceList.value.findIndex(item => item.id === formData.id);
if (index !== -1) {
serviceList.value.splice(index, 1, formData);
}
} else {
//
serviceList.value.push(formData);
}
});
})
//
@ -428,6 +529,35 @@
let str = array.filter(item => item.id == val)[0].name
return str
}
//
function addSubForm(clickType, item) {
if(!form.value.factoryAreaNumber){
proxy.$modal.showToast('请先选择维修工单或设备!')
return;
}
if (clickType == 'updata') {
proxy.$tab.navigateTo(
`/pages/overhaulOrder/addSubItem?type=${type.value}&number=${form.value.number}&factoryAreaNumber=${form.value.factoryAreaNumber}&data=${encodeURIComponent(JSON.stringify(item))}&deviceNumber=${form.value.deviceNumber}`
)
} else {
proxy.$tab.navigateTo(
`/pages/overhaulOrder/addSubItem?type=${type.value}&number=${form.value.number}&factoryAreaNumber=${form.value.factoryAreaNumber}&deviceNumber=${form.value.deviceNumber}`
)
}
}
//
function delService(item) {
proxy.$modal.confirm('确定删除维修内容吗?').then(() => {
serviceList.value = serviceList.value.filter(element=>{
return element.name != item.name
})
})
}
</script>
<style lang="scss" scoped>
@ -476,6 +606,9 @@
font-size: 28rpx;
margin-top: 6rpx;
color: #acacac;
uni-view {
display: inline-block;
}
}
}
}
@ -584,4 +717,72 @@
.item-dec{
color: #8f8f8f;
}
.sub-item-wrapper {
overflow-x: auto; /* 允许横向滚动 */
white-space: nowrap; /* 子项在同一行显示 */
}
.tab {
border-bottom: 1px solid #e4e4e4;
}
.left-align {
display: flex;
justify-content: flex-start; /* 将内容靠左对齐 */
}
.left-align-tabs {
flex-grow: 0; /* 防止 <u-tabs> 撑满父容器 */
}
.title {
display: flex;
align-items: center;
padding: 20rpx 30rpx;
border-bottom: 1px solid #e4e4e4;
view {
&:nth-child(1) {
flex: 1;
border-left: 10rpx solid #409eff;
padding-left: 20rpx;
font-weight: bold;
}
}
}
.list {
padding: 20rpx;
.item {
display: flex;
margin-bottom: 20rpx;
.item-box {
border-radius: 12rpx;
border: 1px solid #dedede;
border-radius: 12rpx;
flex: 1;
width: 0rpx;
}
.spare-title {
padding: 20rpx 30rpx;
border-bottom: 1px solid #e4e4e4;
display: flex;
.title-txt {
color: #409eff;
font-size: 30rpx;
font-weight: bold;
flex: 1;
}
}
.dec {
color: #9c9c9c;
padding: 0rpx 30rpx 20rpx;
}
}
}
</style>

639
src/pages/overhaulOrder/addSubItem.vue

@ -0,0 +1,639 @@
<template>
<!-- 添加检修工单 -->
<view class="add-form-container">
<u-form :model="form" ref="formRef" label-width="160rpx">
<u-form-item label="检修描述" prop="name" required>
<u-input v-model="form.name" placeholder="请输入检修描述" maxlength="50" />
</u-form-item>
<u-form-item label="预估人数" prop="peoples" required>
<u-input v-model="form.peoples" type="number" placeholder="请输入预估人数" maxlength="50" />
</u-form-item>
<u-form-item label="预估分钟" prop="estimatedMinutes" required>
<u-input v-model="form.estimatedMinutes" type="number" placeholder="请输入预估分钟" maxlength="50" />
</u-form-item>
<u-form-item label="实际分钟" prop="actualMinutes">
<u-input v-model="form.actualMinutes" type="number" placeholder="请输入实际分钟" maxlength="50" />
</u-form-item>
<u-form-item label="责任人" prop="chargePeoples" >
<view class="select" @click="openSelecUser">
<view class="input" v-if='form.chargePeoples'>
{{selectFormatCheck(form.chargePeoples,selecUserList)}}
</view>
<view class="placeholder" v-else>
请选择维修人员
</view>
<u-icon name="arrow-right" color="#aaaaaa" size="28"></u-icon>
</view>
</u-form-item>
<u-form-item label="完成情况" prop="status" >
<view class="select" @click="openSingleColumn('status',form.status,jxDetailsStatus,'form')">
<view class="input" v-if='form.status'>
{{form.statusTxt}}
</view>
<view class="placeholder" v-else>
{{`请选择完成情况`}}
</view>
<u-icon name="arrow-right" color="#aaaaaa" size="28" v-if="!form.id"></u-icon>
</view>
</u-form-item>
<u-form-item label="完成时间" prop="completionTime" v-if='form.status === 0||form.status === "0"'>
<view class="select" @click="openDatetime('completionTime',formatDate,params,formatValue)">
<view class="input" v-if='formatDate'>
{{formatDate}}
</view>
<view class="placeholder" v-else>
{{`请选择完成时间`}}
</view>
<u-icon name="arrow-right" color="#aaaaaa" size="28"></u-icon>
</view>
</u-form-item>
<u-form-item label="未完成原因" prop="uncompleted" v-if='form.status === 1||form.status === "1"'>
<u-input type='textarea' v-model="form.uncompleted" placeholder="请输入未完成原因" maxlength="200" />
</u-form-item>
<u-form-item label="工程师确认" prop="engineer">
<u-input v-model="form.engineer" placeholder="请输入工程师确认" maxlength="50" />
</u-form-item>
</u-form>
<view class="list">
<view class="title">
<span></span>备件
</view>
<view class="item " v-for="(item,index) in form.itemNumbers" :key="index">
<view class="item-box">
<view class="spare-title">
<view class="title-txt">
{{item.name}}
</view>
</view>
<u-row gutter="16">
<u-col :span="12">
<view class="dec">
<view class="">
数量:{{item.qty}}
</view>
</view>
</u-col>
</u-row>
</view>
<u-icon name="minus-circle" color="#aaaaaa" size="60" @click="delSpareParts(index)"></u-icon>
</view>
<view class="add-btn">
<u-button type="primary" @click="open"><u-icon name="plus-circle" color="#ffffff"
size="36"></u-icon>添加备件</u-button>
</view>
</view>
<view class="footer">
<view class="btns">
<button class="reset" @click="reset">重置</button>
<button class="sure" @click="submit" :loading='loading' :disabled='loading'>确定</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">
<u-form :model="form1" ref="form1Ref" label-width="160rpx">
<u-form-item :label="`备件`" prop="number" required>
<view class="select" @click="openSingleColumn('number',form1.number,sparePartsList,'form1')">
<view class="input" v-if='form1.number'>
{{form1.name}}
</view>
<view class="placeholder" v-else>
请选择备件
</view>
<u-icon name="arrow-right" color="#aaaaaa" size="28"></u-icon>
</view>
</u-form-item>
<u-form-item label="数量" prop="qty" required>
<u-input v-model="form1.qty" type="number" placeholder="请输入数量" />
</u-form-item>
</u-form>
</view>
<view class="popup-footer">
<view @click="isPopupShow = false">取消</view>
<view class="sure" @click="addSpare">确认</view>
</view>
</u-popup>
<!-- 选择维修人员 -->
<u-popup v-model="isShowSelecUser" mode="center" border-radius="14">
<view class="popup-title">选择维修人员</view>
<view class="popup">
<u-checkbox-group @change="checkboxGroupChange">
<u-checkbox v-model="item.checked" v-for="(item, index) in selecUserList" :key="index"
:name="item.id">{{item.name}}</u-checkbox>
</u-checkbox-group>
</view>
<view class="popup-footer">
<view @click="isShowSelecUser = false">取消</view>
<view class="sure" @click="chooseUser">确认</view>
</view>
</u-popup>
<SelectItemList :isShowSelectItem=isShowSelectItem :singleColumnList=singleColumnList @searchItem='searchItem' @chooseItem1='chooseItem1'/>
<u-select v-model="singleColumnShow" mode="single-column" :default-value='singleColumnDefaultValue'
:list="singleColumnList" @confirm="chooseSingleColumn" @cancle='singleColumnShow = false'></u-select>
<u-picker mode="time" v-model="datetimeShow" :default-time='datetimeDefaultValue' :params="params"
@confirm='chooseDatetime'></u-picker>
</view>
</template>
<script setup lang="ts">
import {
onLoad
} from '@dcloudio/uni-app'
import {
ref,
getCurrentInstance
} from 'vue'
import * as overhaulOrderApi from "@/api/overhaulOrder"
import * as sparePartsApi from "@/api/spareParts"
import * as deptApi from "@/api/dept"
import * as dictApi from "@/api/dict"
import SelectItemList from "../../components/item/slectItemList.vue"
const { proxy} = getCurrentInstance()
const loading = ref(false)
const type = ref('')
//
const isPopupShow = ref(false)
const sparePartsList = ref([])
const isShowSelectItem = ref(false)//
const singleColumnShow = ref(false)
const singleColumnDefaultValue = ref([])
const singleColumnList = ref([])
const field = ref('')
const selecUserList = ref([])//
const isShowSelecUser = ref(false)
const jxDetailsStatus = ref([])//
const formatDate = ref('')//
const form = ref({
number: '',
name: '',
peoples: null,
estimatedMinutes: '',
actualMinutes: '',
chargePeoples: '',
status:null,
completionTime: '',
engineer: '',
uncompleted: '',
itemNumbers: []
})
const form1 = ref({
number: "",
name: "",
qty: 0
})
//
const datetimeShow = ref(false)
const params = ref({
year: true,
month: true,
day: true,
hour: true,
minute: true,
second: true,
timestamp: true,
})
const datetimeDefaultValue = ref('')
const formatValue = ref('YYYY-MM-DD hh:mm:ss')
const factoryAreaNumber = ref('')
const chooseUserList = ref([])
//
function validateInteger(value){
if (value) {
const integerReg = /^[+]{0,1}(\d+)$/
if (integerReg.test(value)) {
return true
} else {
return false
}
} else {
return false
}
}
//
function submit() {
//
if (!form.value.name) {
proxy.$modal.showToast('请输入检修描述')
return;
}
if (!form.value.peoples || form.value.peoples == 0) {
proxy.$modal.showToast('请输入预估人数')
return;
}
if (!validateInteger(form.value.peoples)) {
proxy.$modal.showToast('预估人数请输入正整数')
return;
}
if (form.value.peoples > 100) {
proxy.$modal.showToast('预估人数不得超出100')
return;
}
if (!form.value.estimatedMinutes || form.value.estimatedMinutes == 0) {
proxy.$modal.showToast(`请输入预估分钟`)
return;
}
if (!validateInteger(form.value.estimatedMinutes)) {
proxy.$modal.showToast('预估分钟请输入正整数')
return;
} else {
proxy.$modal.confirm('是否添加检修内容').then(() => {
uni.$emit("handleSubmitForm",form.value);
proxy.$tab.navigateBack()
// overhaulOrderApi.overhaulOrderDetailCreate(form.value,type.value).then((res) => {
// proxy.$modal.closeLoading()
// if (res.data) {
// proxy.$modal.showToast('')
// setTimeout(() => {
// proxy.$tab.navigateBack()
// loading.value = false
// }, 1500)
// } else {
// if(res.msg){
// proxy.$modal.showToast(res.msg)
// }else{
// proxy.$modal.showToast('')
// }
// loading.value = false
// }
// }).catch(() => {
// proxy.$modal.closeLoading()
// loading.value = false
// })
})
}
}
//
function reset() {
form.value.name = ''
form.value.peoples = null
form.value.estimatedMinutes = ''
form.value.actualMinutes = ''
form.value.chargePeoples = ''
form.value.status = null
form.value.completionTime = ''
form.value.engineer = ''
form.value.uncompleted = ''
form.value.itemNumbers = []
formatDate.value = ''
}
//
async function getSelecUser() {
let data = {
classType: type.value,
factoryAreaNumber: factoryAreaNumber.value,
flag: 0
}
let arr = []
if (form.value.chargePeoples) {
arr = form.value.chargePeoples.split(',')
}
await deptApi.getSelecUser(data).then(res => {
res.data.forEach(item => {
item.checked = false
arr.forEach(cur => {
if (item.id == cur) {
item.checked = true
}
})
})
selecUserList.value = res.data
}).catch(() => { })
}
//
function openSelecUser() {
isShowSelecUser.value = true
}
function checkboxGroupChange(e) {
chooseUserList.value = e
}
//
function selectFormatCheck(val, array) {
const arr = val.split(',').map(Number)
let str = array.filter(item => arr.includes(item.id)).map(item => item.name).join(',')
return str
}
//
function chooseUser() {
form.value.chargePeoples = chooseUserList.value.join(',')
isShowSelecUser.value = false
}
const whichForm = ref()
//
function openSingleColumn(fieldName, val, list, from) {
if (fieldName == 'deviceNumber' && form.value.id) return;
whichForm.value = from
singleColumnList.value = list
field.value = fieldName
if (val) {
singleColumnDefaultValue.value = [list.findIndex(item => item.value == val)]
} else {
singleColumnDefaultValue.value = []
}
if(fieldName == 'number'){
isShowSelectItem.value = true;
}else{
singleColumnShow.value = true
}
}
//
function chooseSingleColumn(e) {
if(whichForm.value == 'form'){
form.value[field.value] = e[0].value
if(field.value=='status'){
form.value.statusTxt = e[0].label
formatDate.value = ''
}
}else if(whichForm.value == 'form1'){
form1.value[field.value] = e[0].value
if(field.value=='number'){
form1.value.name = e[0].label
}
}
singleColumnShow.value = false
}
//
async function getSparePartsList(number,name) {
number =form.value.deviceNumber
let param = {
number:number,
name:name
}
await sparePartsApi.getSparePartsList(param).then(res => {
res.data.map(item => {
item.value = item.number
item.label = item.name
})
sparePartsList.value = res.data
singleColumnList.value = sparePartsList.value
}).catch(() => { })
}
//
function open() {
form1.value = {
number: "",
name:'',
qty: 0
}
isPopupShow.value = true
}
//
function addSpare() {
if (!form1.value.number) {
proxy.$modal.showToast('请选择备件')
return;
}
if (!form1.value.qty || form1.value.qty == 0) {
proxy.$modal.showToast('请输入数量')
return;
}
if (form.value.itemNumbers && form.value.itemNumbers.length > 0) {
let arr = form.value.itemNumbers.filter(item => item.number == form1.value.number)
if (arr && arr.length > 0) {
proxy.$modal.showToast('该备件已添加')
return;
}
}
form.value.itemNumbers.push(form1.value)
isPopupShow.value = false
}
//
function delSpareParts(index) {
form.value.itemNumbers.splice(index, 1)
}
function openDatetime(fieldName, val, params, format) {
params.value = params
formatValue.value = format
field.value = fieldName
form.value[field.value] = val ? val : ''
datetimeDefaultValue.value = val ? val : proxy.$time.formatDate()
datetimeShow.value = true
}
//
function chooseDatetime(e) {
let array1 = []
let array2 = []
if (formatValue.value.indexOf('YYYY') > -1) {
array1.push(e.year)
}
if (formatValue.value.indexOf('MM') > -1) {
array1.push(e.month)
}
if (formatValue.value.indexOf('DD') > -1) {
array1.push(e.day)
}
if (formatValue.value.indexOf('hh') > -1) {
array2.push(e.hour)
}
if (formatValue.value.indexOf('mm') > -1) {
array2.push(e.minute)
}
if (formatValue.value.indexOf('ss') > -1) {
array2.push(e.second)
}
let str = array1.join('-') + ' ' + array2.join(':')
formatDate.value = str
form.value[field.value] = e.timestamp*1000
}
onLoad(async(option) => {
if (option.type) type.value = option.type;
if (option.factoryAreaNumber) factoryAreaNumber.value = option.factoryAreaNumber;
if (option.number) form.value.number = option.number;
if (option.deviceNumber) form.value.deviceNumber = option.deviceNumber;
if (option.data && JSON.parse(decodeURIComponent(option.data)) && JSON.parse(decodeURIComponent(option
.data)).id) {
form.value = JSON.parse(decodeURIComponent(option.data))
form.value.itemNumbers = form.value.items
formatDate.value = form.value.completionTime ? proxy.$time.formatDate(form.value.completionTime) : ''
form.value.statusTxt = form.value.status == 0 ? '完成' :'未完成'
};
jxDetailsStatus.value = await dictApi.getDict('jx_details_status')
await getSelecUser()
await getSparePartsList()
})
async function searchItem(name){
await getSparePartsList(null,name);
}
async function chooseItem1(type,forms){
if(!forms.value.number&&type==1){
proxy.$modal.showToast('请选择备件')
return
}
if(type==1){
form1.value.number = forms.value.temporarilyNumber
form1.value.name =forms.value.temporarilyName
}
await getSparePartsList(null,null);
isShowSelectItem.value = false;
}
</script>
<style lang="scss" scoped>
.add-form-container {
min-height: calc(100vh - 140rpx);
background: white;
padding: 0px 30rpx 140rpx;
}
.footer {
position: fixed;
bottom: 0px;
left: 0px;
width: 100%;
z-index: 22;
}
.btns {
display: flex;
button {
flex: 1;
}
.sure {
background: #409eff;
color: white;
border-radius: 0px;
&::after {
border: 1px solid #409eff;
border-radius: 0px;
}
}
.reset {
background: #F5F5F5;
border-radius: 0px;
&::after {
border-radius: 0px;
}
}
}
.right-button {
background: #409eff;
color: white;
padding: 0rpx 30rpx;
border-radius: 16rpx;
text-align: center;
font-size: 28rpx;
}
.select {
display: flex;
align-items: center;
height: 72rpx;
width: 100%;
.input {
flex: 1;
font-size: 28rpx;
color: #000000;
}
.placeholder {
flex: 1;
font-size: 28rpx;
color: rgb(192, 196, 204);
}
}
.title {
padding: 32rpx 0px;
position: relative;
span {
position: absolute;
left: -16rpx;
color: #fa3534;
padding-top: 6rpx;
}
}
.list {
.item {
display: flex;
margin-bottom: 20rpx;
.item-box {
background: #F5F5F5;
border-radius: 12rpx;
flex: 1;
width: 0rpx;
}
.spare-title {
padding: 20rpx 30rpx;
border-bottom: 1px solid #e4e4e4;
.title-txt {
color: #409eff;
font-size: 30rpx;
font-weight: bold;
}
}
.dec {
color: #9c9c9c;
padding: 20rpx 30rpx 20rpx;
}
}
}
.add-btn {
display: flex;
justify-content: flex-start;
align-items: center;
}
.popup-title {
text-align: center;
font-size: 32rpx;
font-weight: bold;
color: #409eff;
padding: 30rpx 30rpx 0px
}
.popup {
width: 600rpx;
padding: 30rpx 60rpx 30rpx;
}
.popup-footer {
display: flex;
border-top: 1px solid #e4e4e4;
view {
line-height: 100rpx;
flex: 1;
text-align: center;
&.sure {
color: #409eff;
}
}
}
::v-deep .u-checkbox-group {
display: grid !important;
}
</style>
Loading…
Cancel
Save