2023-12-20 15:15:23 +08:00
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<view class="form-area">
|
|
|
|
|
<uni-forms
|
2024-03-21 15:42:08 +08:00
|
|
|
v-for="(item, index) in allForm"
|
|
|
|
|
:key="index"
|
|
|
|
|
:modelValue="allForm[index]"
|
2023-12-20 15:15:23 +08:00
|
|
|
label-position="top"
|
|
|
|
|
style="border: 1px solid #A9A9A9; box-sizing: border-box; padding: 30rpx; margin-bottom: 3vh;"
|
|
|
|
|
>
|
|
|
|
|
<uni-forms-item
|
|
|
|
|
label="维修数量"
|
|
|
|
|
v-show="ifNo == 0"
|
|
|
|
|
>
|
2024-03-21 15:42:08 +08:00
|
|
|
<uni-easyinput type="number" placeholder="请输入" v-model="allForm[index].repairNum"></uni-easyinput>
|
2023-12-20 15:15:23 +08:00
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item
|
2024-03-21 15:42:08 +08:00
|
|
|
label="是否收费"
|
2023-12-20 15:15:23 +08:00
|
|
|
>
|
|
|
|
|
<uni-data-select
|
2024-03-21 15:42:08 +08:00
|
|
|
v-model="allForm[index].partType"
|
|
|
|
|
:localdata="ifFeeRange"
|
|
|
|
|
:clear="false"
|
2023-12-20 15:15:23 +08:00
|
|
|
></uni-data-select>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item
|
|
|
|
|
label="选择配件"
|
|
|
|
|
>
|
2024-03-21 15:42:08 +08:00
|
|
|
<custom-tree-select
|
|
|
|
|
:listData="deptList"
|
|
|
|
|
v-model="allForm[index].partId"
|
|
|
|
|
:search="true"
|
|
|
|
|
:choseParent="false"
|
|
|
|
|
:pathMode="true"
|
|
|
|
|
@selectChange="treeChange($event, index)"
|
|
|
|
|
></custom-tree-select>
|
2023-12-20 15:15:23 +08:00
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item
|
|
|
|
|
label="配件数量"
|
|
|
|
|
>
|
2024-03-21 15:42:08 +08:00
|
|
|
<uni-number-box v-model="allForm[index].partNum"/>
|
2023-12-20 15:15:23 +08:00
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item
|
|
|
|
|
label="维修人员"
|
|
|
|
|
>
|
|
|
|
|
<uni-data-select
|
2024-03-21 15:42:08 +08:00
|
|
|
v-model="allForm[index].repairer"
|
2023-12-20 15:15:23 +08:00
|
|
|
:localdata="repairerRange"
|
|
|
|
|
></uni-data-select>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item
|
|
|
|
|
label="维修内容"
|
|
|
|
|
>
|
2024-03-21 15:42:08 +08:00
|
|
|
<uni-easyinput type="textarea" placeholder="请输入内容" v-model="allForm[index].repairContent"></uni-easyinput>
|
2023-12-20 15:15:23 +08:00
|
|
|
</uni-forms-item>
|
|
|
|
|
</uni-forms>
|
|
|
|
|
<view class="btn-area">
|
|
|
|
|
<view
|
|
|
|
|
@click="addForm"
|
|
|
|
|
style="background-color: #3788FF; color: #fff;"
|
|
|
|
|
>
|
|
|
|
|
添加配件
|
|
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
@click="subForm"
|
|
|
|
|
style="border: 1px solid #EBEBEB;"
|
|
|
|
|
>
|
|
|
|
|
维修完成
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2024-03-21 15:42:08 +08:00
|
|
|
<!-- <custom-tree-select
|
|
|
|
|
:listData="deptList"
|
|
|
|
|
v-model="testArr"
|
|
|
|
|
:search="true"
|
|
|
|
|
></custom-tree-select> -->
|
2023-12-20 15:15:23 +08:00
|
|
|
<u-loading-page :loading="showLoading" color="#000" loading-text="表单提交中,请稍后..."></u-loading-page>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { basePath } from '../../public'
|
|
|
|
|
import form from '../../uni_modules/uview-ui/libs/config/props/form';
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2024-03-21 15:42:08 +08:00
|
|
|
testArr: [],
|
2023-12-20 15:15:23 +08:00
|
|
|
ifNo: '',
|
|
|
|
|
showLoading: false,
|
|
|
|
|
allForm: [
|
|
|
|
|
{
|
|
|
|
|
repairNum: 1,
|
2024-03-21 15:42:08 +08:00
|
|
|
partType: 0,
|
|
|
|
|
partId: [],
|
2023-12-20 15:15:23 +08:00
|
|
|
partNum: '',
|
|
|
|
|
repairer: '',
|
|
|
|
|
repairContent: ''
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
repairerRange: [
|
|
|
|
|
|
2024-03-21 15:42:08 +08:00
|
|
|
],
|
|
|
|
|
ifFeeRange: [
|
|
|
|
|
{ value: 1, text: '是' },
|
|
|
|
|
{ value: 0, text: '否' }
|
2023-12-20 15:15:23 +08:00
|
|
|
],
|
|
|
|
|
deptList: [],
|
|
|
|
|
submitForm: [],
|
|
|
|
|
totalSub: {},
|
|
|
|
|
id: '',
|
|
|
|
|
taskId: '',
|
|
|
|
|
maId: '',
|
|
|
|
|
typeId: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2024-03-21 15:42:08 +08:00
|
|
|
treeChange (e, index) {
|
|
|
|
|
let that = this
|
2023-12-20 15:15:23 +08:00
|
|
|
console.log(e, index);
|
|
|
|
|
},
|
|
|
|
|
addForm () {
|
2024-03-21 15:42:08 +08:00
|
|
|
this.allForm.push({
|
|
|
|
|
repairNum: 1,
|
|
|
|
|
partType: 0,
|
|
|
|
|
partId: [],
|
|
|
|
|
partNum: '',
|
|
|
|
|
repairer: '',
|
|
|
|
|
repairContent: ''
|
|
|
|
|
})
|
2023-12-20 15:15:23 +08:00
|
|
|
},
|
|
|
|
|
subForm () {
|
|
|
|
|
let that = this
|
2024-03-21 15:42:08 +08:00
|
|
|
this.submitForm = this.allForm
|
|
|
|
|
for (let i = 0; i < this.submitForm.length; i++) {
|
|
|
|
|
this.submitForm[i].partId = this.submitForm[i].partId[0]
|
|
|
|
|
}
|
2023-12-20 15:15:23 +08:00
|
|
|
console.log(this.submitForm);
|
|
|
|
|
this.totalSub.partStrList = JSON.stringify(this.submitForm)
|
|
|
|
|
this.totalSub.id = this.id
|
|
|
|
|
this.totalSub.taskId = this.taskId
|
|
|
|
|
this.totalSub.maId = this.maId
|
|
|
|
|
this.totalSub.typeId = this.typeId
|
|
|
|
|
this.totalSub.companyId = uni.getStorageSync('userInfo').sysUser.companyId
|
|
|
|
|
this.totalSub.userId = uni.getStorageSync('userInfo').userid
|
|
|
|
|
this.totalSub.repairType = 1
|
|
|
|
|
console.log(this.totalSub);
|
|
|
|
|
this.showLoading = true
|
2024-01-08 17:41:15 +08:00
|
|
|
that.$api.fix.submitFix(that.totalSub).then(res => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: res.data.msg,
|
|
|
|
|
success: () => {
|
|
|
|
|
that.showLoading = false
|
2024-03-21 15:42:08 +08:00
|
|
|
uni.navigateBack({
|
|
|
|
|
delta: 2
|
|
|
|
|
})
|
2024-01-08 17:41:15 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
that.showLoading = false
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: res.data.msg
|
|
|
|
|
})
|
2023-12-20 15:15:23 +08:00
|
|
|
}
|
2024-01-08 17:41:15 +08:00
|
|
|
}).catch(err => {
|
|
|
|
|
console.log(err);
|
2023-12-20 15:15:23 +08:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleTree (data, id, parentId, children) {
|
|
|
|
|
let config = {
|
|
|
|
|
id: id || 'id',
|
|
|
|
|
parentId: parentId || 'parentId',
|
|
|
|
|
childrenList: children || 'children'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var childrenListMap = {};
|
|
|
|
|
var nodeIds = {};
|
|
|
|
|
var tree = [];
|
|
|
|
|
|
|
|
|
|
for (let d of data) {
|
|
|
|
|
let parentId = d[config.parentId];
|
|
|
|
|
if (childrenListMap[parentId] == null) {
|
|
|
|
|
childrenListMap[parentId] = [];
|
|
|
|
|
}
|
|
|
|
|
nodeIds[d[config.id]] = d;
|
|
|
|
|
childrenListMap[parentId].push(d);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let d of data) {
|
|
|
|
|
let parentId = d[config.parentId];
|
|
|
|
|
if (nodeIds[parentId] == null) {
|
|
|
|
|
tree.push(d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let t of tree) {
|
|
|
|
|
adaptToChildrenList(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function adaptToChildrenList(o) {
|
|
|
|
|
if (childrenListMap[o[config.id]] !== null) {
|
|
|
|
|
o[config.childrenList] = childrenListMap[o[config.id]];
|
|
|
|
|
}
|
|
|
|
|
if (o[config.childrenList]) {
|
|
|
|
|
for (let c of o[config.childrenList]) {
|
|
|
|
|
adaptToChildrenList(c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tree;
|
|
|
|
|
},
|
|
|
|
|
veri (data) {
|
|
|
|
|
let that = this
|
|
|
|
|
if (!data || data.length <= 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return data.map(x => {
|
|
|
|
|
/* let model
|
|
|
|
|
if (x.id.includes('u')) {
|
|
|
|
|
model = {
|
|
|
|
|
name: x.name,
|
|
|
|
|
id: x.userId,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
model = {
|
|
|
|
|
name: x.name,
|
|
|
|
|
id: x.id
|
|
|
|
|
};
|
|
|
|
|
} */
|
|
|
|
|
const model = {
|
|
|
|
|
name: x.paName,
|
|
|
|
|
id: x.paId
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const children = that.veri(x.children);
|
|
|
|
|
|
|
|
|
|
if (children) {
|
|
|
|
|
model.children = children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
let that = this
|
|
|
|
|
// 获取维修人员
|
2024-01-08 17:41:15 +08:00
|
|
|
that.$api.fix.fixCrew().then(res => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
|
that.repairerRange = res.data.data.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
text: item['nickName'],
|
|
|
|
|
value: item['userId']
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-12-20 15:15:23 +08:00
|
|
|
}
|
2024-01-08 17:41:15 +08:00
|
|
|
}).catch(err => {
|
|
|
|
|
console.log(err);
|
2023-12-20 15:15:23 +08:00
|
|
|
})
|
|
|
|
|
// 获取配件树
|
2024-01-08 17:41:15 +08:00
|
|
|
that.$api.fix.maList().then(res => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
|
that.deptList = that.veri(that.handleTree(res.data.data, 'paId'))
|
2023-12-20 15:15:23 +08:00
|
|
|
}
|
2024-01-08 17:41:15 +08:00
|
|
|
console.log(that.deptList);
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.log(err);
|
2023-12-20 15:15:23 +08:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onLoad(params) {
|
|
|
|
|
console.log(params);
|
|
|
|
|
this.id = params.id
|
|
|
|
|
this.taskId = params.taskId
|
|
|
|
|
this.maId = params.maId
|
|
|
|
|
this.typeId = params.typeId
|
|
|
|
|
this.ifNo = params.ifNo
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.form-area{
|
|
|
|
|
width: 90%;
|
|
|
|
|
margin: 2vh auto;
|
|
|
|
|
.btn-area{
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin: 3vh auto;
|
|
|
|
|
view{
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
padding: 15rpx 40rpx;
|
|
|
|
|
border-radius: 15rpx;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|