实验室运维app端
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.
 
 
 
 

1250 lines
52 KiB

<template>
<view class="page-css">
<view class="info">
<view class="info_title">基本信息</view>
<view class="info_item">
<text class="item_left_txt">单位名称</text>
<text class="item_right_txt">{{ detailForm.deptName }}</text>
</view>
<view class="info_item">
<text class="item_left_txt">巡检内容</text>
<text class="item_right_txt">{{ detailForm.taskContent }}</text>
</view>
</view>
<view class="info">
<view class="info_title">巡检配置</view>
<u-form labelPosition="left" ref="sendOrderForm" :model="detailForm" :label-width="200" class="repair_form">
<u-form-item label="巡检内容:" prop="dispatchTime" :border-bottom="false">
<u-input v-model="detailForm.taskContent" :disabled="true" :border="true"
class="sp-new-input-diabled" />
</u-form-item>
<u-form-item label="任务开始时间:" prop="dispatchTime" :border-bottom="false">
<u-input v-model="detailForm.startTime" :disabled="true" :border="true"
class="sp-new-input-diabled" />
</u-form-item>
<u-form-item label="预约上门时间:" prop="customerOpinion" :border-bottom="false">
<u-input v-if="reservationDisabled" v-model="reservationTime" type="select"
@click="calendarShow = true" :border="true" placeholder="请选择时间" />
<view v-else>{{ detailForm.reservationTime }}</view>
</u-form-item>
</u-form>
</view>
<!-- 巡检任务 只查看-->
<view class="info" v-if="reservationDisabled">
<view class="info_title">巡检任务</view>
<u-collapse :accordion="false">
<u-collapse-item v-for="(item, index) in detailForm.details" :key="index">
<view slot="title">
<text class="collapse-title">实验室楼层:{{ item.floorName }}</text>
</view>
<view v-for="(v, vindex) in item.details" :key="vindex" class="collapse-room">
<view>房间名称:{{ v.deptName }}</view>
<view v-for="(s, sindex) in v.details" :key="sindex" class="n-box">
<u-tag :text="sindex + 1" type="info" class="left-tag" />
<view class="info_item">
<text class="item_left_txt">设备:</text>
<text class="item_right_txt">
{{ s.deviceName }}
</text>
</view>
<view class="info_item">
<text class="item_left_txt">巡检内容:</text>
<text class="item_right_txt">
{{ s.checkContent }}
</text>
</view>
<view class="info_item">
<text class="item_left_txt">工艺要求:</text>
<text class="item_right_txt">
{{ s.craft }}
</text>
</view>
<view class="info_item">
<text class="item_left_txt">巡检周期:</text>
<text class="item_right_txt">
{{ periodName(s.period) }}
</text>
</view>
<view class="info_item">
<text class="item_left_txt">开始时间:</text>
<text class="item_right_txt">
{{ s.startTime }}
</text>
</view>
</view>
</view>
</u-collapse-item>
</u-collapse>
</view>
<view class="info"
v-if="detailForm.repairStatus == 100 || detailForm.repairStatus == 101 || detailForm.repairStatus == 102">
<view class="info_title" v-if="detailForm.repairStatus == 100">维修人员驳回</view>
<view class="info_title" v-if="detailForm.repairStatus == 101">主管驳回</view>
<view class="info_title" v-if="detailForm.repairStatus == 102">客户驳回</view>
<view class="info_item">
<text class="item_left_txt">驳回原因:</text>
<text class="item_right_txt">{{ detailForm.approveRemark }}</text>
</view>
</view>
<!-- 填写内容 -->
<view class="info" v-if="!reservationDisabled">
<view class="info_title">巡检任务</view>
<view class="info_search">
<u-search placeholder="请输入设备名称" v-model="deviceNameSearch" :clearabled="true"
@change="deviceNameSearchFn" :show-action="false"></u-search>
</view>
<u-collapse :accordion="false" ref="collapseTask"
v-if="detailForm.details && detailForm.details.length > 0">
<u-collapse-item v-for="(item, index) in detailForm.details" :key="index">
<view slot="title">
<text class="collapse-title">实验室楼层:{{ item.floorName }}</text>
</view>
<view v-for="(v, vindex) in item.details" :key="vindex" class="collapse-room">
<view>房间名称:{{ v.deptName }}</view>
<view v-for="(s, sindex) in v.details" :key="sindex" class="n-box">
<u-tag :text="sindex + 1" type="info" class="left-tag" />
<!-- <u-tag text="已检" type="success" class="right-tag" /> -->
<view class="n-box-title">设备: {{ s.deviceName }}</view>
<view class="n-box-title">内容: {{ s.checkContent }}</view>
<view class="n-box-info">工艺: {{ s.craft }}</view>
<view class="info_item">
<text class="item_left_txt">状态:</text>
<text class="item_right_txt">
<u-radio-group v-model="s.status" :disabled="taskDisabled">
<u-radio name="0">正常</u-radio>
<u-radio name="1">异常</u-radio>
</u-radio-group>
</text>
</view>
<view class="info_item">
<text class="item_left_txt">现场照片:</text>
<text class="item_right_txt" v-if="s.picUrl == ''">
<view class="btn" v-if="!taskDisabled" @click="uploadImg(index, vindex, sindex)">
上传照片</view>
<view v-else>无</view>
</text>
<text class="item_right_txt" v-else>
<image @click="uploadImg(index, vindex, sindex)" class="item_right_img"
:src="s.picUrl"></image>
</text>
</view>
<view class="info_item"
v-if="(dataTypes == 4 && (detailForm.repairStatus == 1 || detailForm.repairStatus == 101)) || (dataTypes == 3 && (detailForm.repairStatus == 2 || detailForm.repairStatus == 102))">
<text class="item_left_txt">申领物料:</text>
<text class="item_right_txt">
<u-radio-group v-model="s.isNeed" @change="materielChange" :disabled="!(detailForm.repairStatus == 1 && detailsType == 'repair')">
<u-radio name="1">是</u-radio>
<u-radio name="0">否</u-radio>
</u-radio-group>
</text>
</view>
<view class="info_item" v-if="s.isNeed == '1'">
<text class="item_left_txt">物料列表:</text>
<text class="item_right_txt">
<u-button v-if="detailForm.repairStatus == 1 && detailsType == 'repair'" size="medium" :plain="true" style="margin-right: 32rpx;width:100%"
type="primary" @click="goodsSelect(index, vindex, sindex)">{{
s.detailGoodsList.length > 0 ? '修改' : '添加' }}</u-button>
<u-button v-else size="medium" :plain="true" style="margin-right: 32rpx;width:100%"
type="primary" @click="goodsSelect(index, vindex, sindex)">查看</u-button>
</text>
</view>
<!-- <view class="info_item"
v-if="(dataTypes == 4 && (detailForm.repairStatus == 1 || detailForm.repairStatus == 101)) || (dataTypes == 3 && (detailForm.repairStatus == 2 || detailForm.repairStatus == 102))">
<text class="item_left_txt">价格:</text>
<text class="item_right_txt">
<u-input v-model="s.price" type="number" :border="true" :disabled="priceDisabled"
:class="priceDisabled ? 'sp-new-input-diabled' : ''" />
</text>
</view> -->
<view class="info_item" v-if="dataTypes == 1 && detailForm.repairStatus == 3">
<text class="item_left_txt">是否维修:</text>
<text class="item_right_txt">
<u-radio-group v-model="s.isRepair">
<u-radio name="1">是</u-radio>
<u-radio name="0">否</u-radio>
</u-radio-group>
</text>
</view>
</view>
</view>
</u-collapse-item>
</u-collapse>
<u-empty text="设备为空" mode="list" v-else></u-empty>
</view>
<view class="info" v-if="!reservationDisabled">
<u-form labelPosition="left" ref="sendOrderForm" :model="detailForm" :label-width="120" class="repair_form">
<u-form-item label="签字:" prop="signUrl" :border-bottom="false" :required="true">
<u-input :border="true" v-model="signUrl" :placeholder="'请输入'"
:class="taskDisabled ? 'sp-new-input-diabled' : ''" :disabled="taskDisabled" />
<!-- <image v-if="s.qianzi" :src="s.qianzi" style="width: 144px;height: 77rpx;"
mode="widthFix" @click="toPop1(index, vindex, sindex)"></image>
<view v-else class="btn" @click="toPop1(index, vindex, sindex)">签字</view> -->
</u-form-item>
<u-form-item label="备注:" prop="remark" :border-bottom="false">
<u-input :border="true" v-model="remark" :placeholder="'请输入'" type="textarea" :height="120"
class="taskDisabled?'sp-new-input-diabled':''" :disabled="taskDisabled" />
</u-form-item>
</u-form>
</view>
<!-- 客户巡检任务 确认审批 -->
<view class="info" v-if="dataTypes == 1 && detailForm.taskStatus == 3">
<view class="info_title">巡检确认</view>
<u-form labelPosition="left" ref="repairInfoForm" :model="approveInfo" :label-width="140"
class="repair_form">
<u-form-item label="结果:" prop="reportPeople" :border-bottom="false">
<betone-input-picker :label="''" :pickerData="approveType" :mode="'selector'" :keyName="'text'"
@changeSelect="changeApproveResult" v-model="approveInfo.approveText"></betone-input-picker>
</u-form-item>
<u-form-item label="意见:" prop="reportPeople" :border-bottom="false"
v-if="approveInfo.approveText == '未完成'">
<u-input v-model="approveInfo.approveRemark" :border="true" placeholder="请输入" type="textarea"
:height="120" />
</u-form-item>
</u-form>
</view>
<!-- 维修负责人 巡检维修方案审批 -->
<view class="info" v-if="dataTypes == 3 && (detailForm.repairStatus == 2 || detailForm.repairStatus == 102)">
<view class="info_title">维修方案审批</view>
<u-form labelPosition="left" ref="repairInfoForm" :model="repairApproveInfo" :label-width="140"
class="repair_form">
<u-form-item label="审批结果:" prop="reportPeople" :border-bottom="false">
<betone-input-picker :label="''" :pickerData="repairApproveType" :mode="'selector'"
:keyName="'text'" @changeSelect="changeRepairApproveResult"
v-model="repairApproveInfo.approveText"></betone-input-picker>
</u-form-item>
<u-form-item label="审批意见:" prop="reportPeople" :border-bottom="false"
v-if="repairApproveInfo.approveText == '驳回'">
<u-input v-model="repairApproveInfo.approveRemark" :border="true" placeholder="请输入" type="textarea"
:height="120" />
</u-form-item>
</u-form>
</view>
<view class="info" v-if="dataTypes == 1 && detailForm.repairStatus == 3">
<view class="info_title">客户确认</view>
<u-form labelPosition="left" ref="repairInfoForm" :model="customerApproveInfo" :label-width="140"
class="repair_form">
<u-form-item label="审批结果:" prop="reportPeople" :border-bottom="false">
<betone-input-picker :label="''" :pickerData="repairApproveType" :mode="'selector'"
:keyName="'text'" @changeSelect="changeCustomerApproveResult"
v-model="customerApproveInfo.approveText"></betone-input-picker>
</u-form-item>
<u-form-item label="审批意见:" prop="reportPeople" :border-bottom="false"
v-if="customerApproveInfo.approveText == '驳回'">
<u-input v-model="customerApproveInfo.approveRemark" :border="true" placeholder="请输入"
type="textarea" :height="120" />
</u-form-item>
</u-form>
</view>
<!-- 维修人员接收任务单 -->
<view class="repair-btn" style="margin-right: 32rpx;width:100%"
v-if="dataTypes == 4 && detailForm.taskStatus == 1 && detailsType == 'task'">
<u-button size="medium" @click="endOrderCancel()">取消</u-button>
<u-button size="medium" type="primary" @click="receiveQuest()">接单</u-button>
</view>
<!-- 维修人员提交巡检详情 -->
<view class="repair-btn" style="margin-right: 32rpx;width:100%"
v-if="dataTypes == 4 && detailForm.taskStatus == 2 && detailsType == 'task'">
<u-button size="medium" @click="endOrderCancel()">取消</u-button>
<u-button size="medium" type="primary" @click="openModel()">提交</u-button>
</view>
<!-- 客户 确认巡检任务是否完成提交 -->
<view class="repair-btn" style="margin-right: 32rpx;width:100%"
v-if="dataTypes == 1 && detailForm.taskStatus == 3 && detailsType == 'task'">
<u-button size="medium" @click="endOrderCancel()">取消</u-button>
<u-button size="medium" type="primary" @click="customerQuest()">提交</u-button>
</view>
<!-- 维修人员 提交维修方案 -->
<view class="repair-btn" style="margin-right: 32rpx;width:100%"
v-if="dataTypes == 4 && detailForm.repairStatus == 1 && detailsType == 'repair'">
<u-button size="medium" @click="endOrderCancel()">取消</u-button>
<u-button size="medium" type="primary" @click="solutionSubmit()">提交方案</u-button>
</view>
<!-- 维修主管审批 巡检 维修方案 -->
<view class="repair-btn" style="margin-right: 32rpx;width:100%"
v-if="dataTypes == 3 && detailForm.repairStatus == 2 && detailsType == 'repair'">
<u-button size="medium" @click="endOrderCancel()">取消</u-button>
<u-button size="medium" type="primary" @click="repairApproveSubmit()">提交</u-button>
</view>
<!-- 客户审批 巡检 维修方案 确认是否维修-->
<view class="repair-btn" style="margin-right: 32rpx;width:100%"
v-if="dataTypes == 1 && detailForm.repairStatus == 3 && detailsType == 'repair'">
<u-button size="medium" @click="endOrderCancel()">取消</u-button>
<u-button size="medium" type="primary" @click="customerApproveSubmit()">提交</u-button>
</view>
<u-calendar v-model="calendarShow" mode="date" @change="calendarChange" :min-date="minDate"
:max-date="maxDate"></u-calendar>
<betone-modal v-model="taskCompleteShow" :title="'提示'" @confirm="taskCompleteShowFn"
@cancel="taskCompleteShow = false">
<view class="modal-text">
请确认是否巡检完成!
</view>
</betone-modal>
<betone-loading ref="BetLoading" />
<!-- 维修人员物料选择 -->
<betone-dialog v-model="aterialShow" height="900rpx">
<view class="search-box">
<betone-new-input v-model="goodsearchInfo.goodsName" placeholder="搜索物品名称" icon="search"
style="margin-bottom: 32rpx" @changevalue="searchGoodsData()" />
</view>
<scroll-view class="scroll-Y" @scrolltolower="goodsLower" scroll-y="true"
style="max-height: 900rpx; width: auto; background-color: gainsboro;">
<view class="material-box">
<view class="material-item" v-for="(item, index) in goodsTableData" :key="index">
<view class="title-wrapper">
<u-checkbox v-model="item.checked" shape="circle"
:disabled="!(detailForm.repairStatus == 1 && detailsType == 'repair')"></u-checkbox>
</view>
<view class="item-right">
<view class="material-title">
<text class="material-title-name">{{ item.name }}</text>
<text class="material-title-code">{{ item.inventoryId }}</text>
<text>库存数:{{ item.num }}</text>
</view>
<view class="material-text">品牌:{{ item.brand }}</view>
<view class="material-text">型号:{{ item.xh }}</view>
<view class="material-num">
<text>参数:{{ item.rule }}</text><u-number-box v-model="item.goodsNum"
:step="1"></u-number-box>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="material-btn" >
<u-button size="medium" @click="aterialShow = false">取消</u-button>
<u-button v-if="detailForm.repairStatus == 1 && detailsType == 'repair'" size="medium" type="primary" @click="goodsSubmit()">确认</u-button>
</view>
</betone-dialog>
</view>
</template>
<script>
import website from '@/utils/website'
import { dateFormat } from '@/utils/util.js'
export default {
computed: {
dataTypes() {
return this.$store.state.dataType
},
reservationDisabled() {
return (this.dataTypes == 4 && this.detailForm.taskStatus == 1) || (this.type == 'view') ? true : false
},
taskDisabled() {
return (this.dataTypes == 4 && (this.detailForm.taskStatus == 2)) ? false : true
},
priceDisabled() {
return this.dataTypes == 4 && (this.detailForm.repairStatus == 1 || this.detailForm.repairStatus == 101) ? false : true
}
},
data() {
return {
detailForm: {},
orderId: '',//巡检任务id
detailsType: '',//详情类型
optionsType: '',//可操作类型
reservationTime: '',//预约上门时间
minDate: null,
maxDate: null,
calendarShow: false,//预约时间
collapseData: [],
signUrl: '',//签字
remark: '',//备注
approveInfo: {//维修负责人审批
approvePerson: '',//审批人 id
approveRemark: '',//审批备注
approveResult: null,//1通过 0驳回
approveText: '',//展示内容
approveTime: '',//当前时间
},
approveType: [
{
text: '已完成',
value: 1
},
{
text: '未完成',
value: 0
},
],
repairApproveInfo: {
approvePerson: '',//审批人 id
approveRemark: '',//审批备注
approveResult: null,//1通过 0驳回
approveText: '',//展示内容
approveTime: '',//当前时间
},
repairApproveType: [
{
text: '通过',
value: 1
},
{
text: '驳回',
value: 0
},
],
customerApproveInfo: {
approvePerson: '',//审批人 id
approveRemark: '',//审批备注
approveResult: null,//1通过 0驳回
approveText: '',//展示内容
approveTime: '',//当前时间
},
deviceNameSearch: '',//巡检任务 搜索设备名称
deviceList: [],//记录设备总数
taskCompleteShow: false,
aterialShow: false,//物料选择弹框
goodsearchInfo: {
goodsName: '',
},
goodsTableData: [],
goodspage: {
current: 1,
size: 10,
},
isGoodsNomore: false,
goodsIndex: [],//存放下标
}
},
onLoad(options) {
this.optionsType = options.type
this.orderId = options.id
this.detailsType = options.details
this.getDetails()
this.initDate()
this.userInfo = uni.getStorageSync("userinfo");
},
onShow() {
this.getGoodsList()
},
methods: {
getDetails() {
let query = {
id: this.orderId
}
if (this.detailsType == 'task') {
this.$u.api.getTaskDetail(query).then(res => {
if (res.code == 200) {
this.updateData(res.data.details)
this.detailForm = res.data
this.deviceList = this.detailForm.details
this.signUrl = res.data.signUrl
this.remark = res.data.remark
this.collapseData = JSON.parse(JSON.stringify(res.data.details))
}
})
} else {
this.$u.api.getRepairDetail(query).then(res => {
if (res.code == 200) {
this.updateData(res.data.details)
this.detailForm = res.data
this.deviceList = this.detailForm.details
this.signUrl = res.data.signUrl
this.remark = res.data.remark
this.collapseData = JSON.parse(JSON.stringify(res.data.details))
}
})
}
},
// 处理数据 更改数据价格为-1的数据
updateData(data) {
if (data.length > 0) {
for (let i = 0; i < data.length; i++) {
data[i].price = data[i].price < 0 ? null : data[i].price
if (data[i].details.length > 0) {
this.updateData(data[i].details)
} else {
data[0].isNeed = data[0].detailGoodsList.length > 0 ? '1' : '0'
console.log(5555, data)
}
}
}
},
endOrderCancel() {
uni.navigateBack({
delta: 1 // 默认值是1,表示回退一个页面
})
},
// 维修人员接收
receiveQuest() {
let query = {
id: this.detailForm.id
}
if (this.reservationTime == '') {
uni.showToast({ title: "请选择上门时间", icon: "none" });
return false
}
// // 接收成功之后更新上门时间
this.$u.api.taskServicemanreceive(query).then(res => {
if (res.code == 200) {
let query_ = {
id: this.detailForm.id,
reservationTime: this.reservationTime
}
this.$u.api.taskServicemanUpdateTime(query_).then(res => {
uni.showToast({ title: "接单成功", icon: "none" });
setTimeout(() => {
uni.navigateBack({
delta: 1 // 默认值是1,表示回退一个页面
})
}, 500)
})
}
})
},
uploadImg(index, vindex, sindex) {
uni.chooseImage({
count: 1, // 默认9
sizeType: ["original", "compressed"], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有
success: (res) => {
this.$refs.BetLoading.show()
// 成功选择图片后的回调
const tempFilePaths = res.tempFilePaths;
this.uploadFile(tempFilePaths[0], index, vindex, sindex);
},
});
},
uploadFile(filePath, index, vindex, sindex) {
const token = uni.getStorageSync("token")
uni.uploadFile({
url: website.baseUrl + "/blade-resource/oss/endpoint/put-file", // 服务器上传接口
filePath: filePath,
name: "file", // 必须填写,后台用来接收文件
header: {
'Blade-Auth': 'bearer ' + token,
'Authorization': `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`,
'blade-requested-with': 'BladeHttpRequest' //自定义请求头
},
formData: {},
success: (res) => {
let info = JSON.parse(res.data);
console.log("上传成功", info); // 上传成功后的操作
this.detailForm.details[index].details[vindex].details[sindex].picUrl = info.data.link
this.itemCollapseChange()
this.$refs.BetLoading.hide()
},
error: (uploadFileRes) => {
this.$refs.BetLoading.hide()
},
});
},
openModel() {
if (this.signUrl == '') {
uni.showToast({ title: "请填写使用人", icon: "none" });
return false
}
this.taskCompleteShow = true
},
taskCompleteShowFn() {
this.submitQuest()
},
// 维修人员提交明细
submitQuest() {
let newArr = this.handleData(this.deviceList)
let status = newArr.every((item) => {
return item.status != null
})
if (!status) {
uni.showToast({ title: "请选择设备状态", icon: "none" });
return false
}
let queryData = []
newArr.forEach(item => {
queryData.push({
id: item.id,
status: item.status,
// signUrl: item.signUrl,
// remark: item.remark,
picUrl: item.picUrl,
taskId: this.detailForm.id
})
})
this.$u.api.updateDetaile(queryData).then(res => {
if (res.code == 200) {
let signInfo = {
id: this.detailForm.id,
signUrl: this.signUrl,
remark: this.remark
}
this.$u.api.updateSign(signInfo).then(res => {
if (res.code == 200) {
let query = {
id: this.detailForm.id,
}
this.$u.api.taskServicemanSubmit(query).then(res => {
if (res.code == 200) {
uni.showToast({ title: "提交成功", icon: "none" });
setTimeout(() => {
uni.navigateBack({
delta: 1 // 默认值是1,表示回退一个页面
})
}, 500)
}
})
}
})
}
})
},
// 客户确认巡检任务
changeApproveResult(e) {
this.approveInfo.approveText = this.approveType[e].text
this.approveInfo.approveResult = this.approveType[e].value
},
customerQuest() {
if (this.approveInfo.approveResult == null) {
uni.showToast({ title: "请选择确认结果", icon: "none" });
return false
}
if (this.approveInfo.approveResult == 0 && this.approveInfo.approveRemark == '') {
uni.showToast({ title: "请填写未完成原因", icon: "none" });
return false
}
if (this.approveInfo.approveResult == 1) {
let query = {
id: this.detailForm.id
}
this.$u.api.taskCustomerConfirm(query).then(res => {
if (res.code == 200) {
uni.showToast({ title: "确认成功", icon: "none" });
setTimeout(() => {
this.endOrderCancel()
}, 500)
}
})
} else {
let query = {
id: this.detailForm.id,
approvePerson: this.userInfo.user_id,
appproveResult: this.approveInfo.approveResult,
approveTime: dateFormat("yyyy-MM-dd hh:mm:ss", new Date()),//当前时间
approveRemark: this.approveInfo.approveRemark,//审批备注
}
this.$u.api.taskCustomerRefuse(query).then(res => {
if (res.code == 200) {
uni.showToast({ title: "确认成功", icon: "none" });
this.submitTaskShow = false
// 指派成功 刷新列表
this.getRecordsList()
}
})
}
},
// 提交 方案
solutionSubmit() {
let newArr = this.handleData(this.detailForm.details)
let price = newArr.every((item) => {
return item.price > 0
})
// if (!price) {
// uni.showToast({ title: "请填写正确的维修价格", icon: "none" });
// return false
// }
// let queryData = []
let query_ = {
task: { id: this.detailForm.id },
detailList: newArr,
}
// 提交方案接口
this.$u.api.taskSolutionSave(query_).then(res => {
if (res.code == 200) {
let query = {
id: this.detailForm.id,
}
this.$u.api.taskSolutionSubmit(query).then(res => {
if (res.code == 200) {
uni.showToast({ title: "提交成功", icon: "none" });
setTimeout(() => {
uni.navigateBack({
delta: 1 // 默认值是1,表示回退一个页面
})
}, 500)
}
})
}
})
},
// 维修主管审批
changeRepairApproveResult(e) {
this.repairApproveInfo.approveText = this.repairApproveType[e].text
this.repairApproveInfo.approveResult = this.repairApproveType[e].value
},
// 主管审批
repairApproveSubmit() {
if (this.repairApproveInfo.approveResult == 1) {//通过
let query = {
id: this.detailForm.id
}
this.$u.api.repairSolutionSupervisor(query).then(res => {
if (res.code == 200) {
uni.showToast({ title: "审批成功", icon: "none" });
setTimeout(() => {
uni.navigateBack({
delta: 1 // 默认值是1,表示回退一个页面
})
}, 500)
}
})
} else {//驳回
let query_ = {
id: this.detailForm.id,
approvePerson: this.userInfo.user_id,
appproveResult: this.repairApproveInfo.approveResult,
approveTime: dateFormat("yyyy-MM-dd hh:mm:ss", new Date()),//当前时间
approveRemark: this.repairApproveInfo.approveRemark,//审批备注
}
this.$u.api.repairSolutionRefuse(query_).then(res => {
if (res.code == 200) {
uni.showToast({ title: "审批成功", icon: "none" });
setTimeout(() => {
uni.navigateBack({
delta: 1 // 默认值是1,表示回退一个页面
})
}, 500)
}
})
}
},
// 客户 审批
changeCustomerApproveResult(e) {
this.customerApproveInfo.approveText = this.repairApproveType[e].text
this.customerApproveInfo.approveResult = this.repairApproveType[e].value
},
// 客户 确认维修方案
customerApproveSubmit() {
let newArr = this.handleData(this.detailForm.details)
let isRepair = newArr.every((item) => {
return item.isRepair == -1
})
if (this.customerApproveInfo.approveResult == null) {
uni.showToast({ title: "请选择审核结果", icon: "none" });
return false
}
if (this.customerApproveInfo.approveResult == 1) {
if (isRepair) {
uni.showToast({ title: "请选择异常设备是否维修", icon: "none" });
return false
}
if (this.customerApproveInfo.approveResult == 0 && this.customerApproveInfo.approveRemark == '') {
uni.showToast({ title: "请填写驳回原因", icon: "none" });
return false
}
}
if (this.customerApproveInfo.approveResult == 1) {//通过
let query = {
task: {
id: this.detailForm.id
},
detailList: newArr
}
console.log(query)
this.$u.api.repairSolutionCustomer(query).then(res => {
if (res.code == 200) {
uni.showToast({ title: "审核成功", icon: "none" });
setTimeout(() => {
this.endOrderCancel()
}, 500)
}
})
} else {//驳回
let query_ = {
id: this.detailForm.id,
approvePerson: this.userInfo.user_id,
appproveResult: this.customerApproveInfo.approveResult,
approveTime: dateFormat("yyyy-MM-dd hh:mm:ss", new Date()),//当前时间
approveRemark: this.customerApproveInfo.approveRemark,//审批备注
}
this.$u.api.repairCustomerRefuse(query_).then(res => {
if (res.code == 200) {
uni.showToast({ title: "驳回成功", icon: "none" });
setTimeout(() => {
this.endOrderCancel()
}, 500)
}
})
}
},
// 处理提交明细的数据
handleData(arr) {
let result = [];
arr.forEach(subArray => {
if (Array.isArray(subArray.details)) {
subArray.details.forEach(item => {
if (Array.isArray(item.details)) {
item.details.forEach(v => {
result = result.concat(v);
})
//
} else {
result.push(item);
}
});
}
});
return result;
},
// 巡检周期
periodName(value) {
if (value == 1) {
return '月'
}
if (value == 2) {
return '季度'
}
if (value == 3) {
return '半年'
}
},
// 设置最大可选择时间
initDate() {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (month < 10) {
month = "0" + month;
}
if (day < 10) {
day = "0" + day;
}
let minyear = year;
this.minDate = minyear + "-" + month + "-" + day;
//let maxyear = year + 1;
this.maxDate = year + 1 + "-" + month + "-" + day; // 最大日期可选到一年后
//this.maxDate = year  + '-'+ month +'-' + day; // 最大日期可选到今天
},
calendarChange(e) {
this.reservationTime = e.result
},
// 更改 手风琴的高度
itemCollapseChange() {
this.$nextTick(() => {
this.$refs.collapseTask.init()
})
},
deviceNameSearchFn(val) {
this.detailForm.details = []
let newArr = this.filterByDeviceName(this.deviceList, val)
this.detailForm.details = newArr.details
this.itemCollapseChange()
},
// 过滤 搜索条件
filterByDeviceName(data, targetDeviceName) {
// 定义一个递归函数来处理多维数组
const recursiveFilter = (details) => {
return details
.map(item => {
// 过滤 item.details,保持设备名称匹配的项
const filteredDetails = item.details ? item.details.map(subItem => {
const matchingDetails = subItem.details
? subItem.details.filter(detail => detail.deviceName.includes(targetDeviceName))
: [];
console.log('matchingDetails', matchingDetails)
return {
...subItem,
details: matchingDetails.length > 0 ? matchingDetails : undefined, // 只保留有匹配项的 details
};
}).filter(subItem => subItem.details) : []; // 仅保留 details 不为空的项
return {
...item,
details: filteredDetails.length > 0 ? filteredDetails : undefined, // 只保留有匹配项的 details
};
})
.filter(item => item.details); // 过滤掉没有匹配 details 的项
};
return {
...data,
details: recursiveFilter(data)
};
},
// 是否选择物料
materielChange() {
this.itemCollapseChange()
},
// 物料搜索
searchGoodsData() {
// selectGoodsList
},
// 弹框滑到底部加载数据
goodsLower() {
if (this.isGoodsNomore) {
return;
}
this.goodspage.current++;
this.getGoodsList();
},
// 获取物料列表
getGoodsList() {
let query_ = {
...this.goodspage
}
this.$u.api.getGoodsList(query_).then(res => {
if (res.code == 200) {
var totalPage = res.data.total;
var newOrders = res.data.records;
newOrders.forEach(element => {
// element.rule = element.rule == '' ? 0 : Number(element.rule)
this.$set(element, 'goodsNum', 0)
this.$set(element, 'checked', false)
});
this.goodsTableData = [...this.goodsTableData, ...(res.data.records || [])];
if (newOrders.length == 0) {
// this.loadingState = "nomore";
this.isGoodsNomore = true;
}
if (totalPage == this.goodsTableData.length) {
// this.loadingState = "nomore";
this.isGoodsNomore = true;
}
}
})
},
// 物料选择确定
goodsSubmit() {
let selected = this.goodsTableData.filter(i => {
return i.checked
})
if (selected.find(item => item.goodsNum == 0)) {
uni.showToast({ title: "申领数量不能为0", icon: "none" });
return false
}
let data = []
selected.forEach(item => {
item.materialPrice = item.goodsNum * item.purchasePrice
data.push({
warehouseId: item.inventoryId,//物资id
goodsName: item.name, //物资名称
unit: item.unit,//单位
xh: item.xh,//型号
rule: item.rule,//规格
price: item.materialPrice,
number: item.goodsNum,//领用数量
productId: item.id,//物料id
})
})
this.detailForm.details[this.goodsIndex[0]].details[this.goodsIndex[1]].details[this.goodsIndex[2]].detailGoodsList = JSON.parse(JSON.stringify(data))
this.aterialShow = false
},
goodsSelect(index, vindex, sindex) {
this.goodsIndex = [index, vindex, sindex]
this.aterialShow = true
// 判断之前是否有选中的
// 默认给列表全部赋值非选中状态
// 如果有则对比数组 加载选中状态 this.goodsTableData
this.goodsTableData.forEach(i => {
i.checked = false
})
if (this.detailForm.details[index].details[vindex].details[sindex].detailGoodsList.length > 0) {
this.goodsTableData.forEach(i => {
this.detailForm.details[index].details[vindex].details[sindex].detailGoodsList.forEach(v => {
if (i.id == v.productId) {
i.checked = true
}
})
})
}
},
},
}
</script>
<style lang="scss" scoped>
.page-css {
width: 100%;
padding: 0;
padding-top: 26rpx;
padding-bottom: 160rpx;
.info {
margin: 0 24rpx 20rpx;
border-radius: 20rpx;
background-color: rgba(255, 255, 255, 1);
padding: 6rpx 0 34rpx;
.info_title {
line-height: 60rpx;
color: rgba(0, 0, 0, 1);
font-size: 32rpx;
text-align: left;
font-family: SourceHanSansSC-bold;
margin: 18rpx 0 0rpx 20rpx;
font-weight: bold;
}
.info_search {
padding: 0 32rpx
}
.info_item {
padding: 4rpx 20rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
.item_left_txt {
color: rgba(108, 108, 108, 1);
font-size: 28rpx;
text-align: left;
font-family: SourceHanSansSC-regular;
width: 210rpx;
margin-right: 20rpx;
line-height: 60rpx;
}
.item_right_txt {
max-width: calc(100% - 220rpx);
color: rgba(0, 0, 0, 1);
font-size: 28rpx;
// text-align: left;
text-align: justify;
font-family: SourceHanSansSC-regular;
}
.item_right_img {
width: 140rpx;
height: 140rpx;
border-radius: 8rpx;
}
}
}
.repair-btn {
width: 100%;
height: 150rpx;
display: flex;
justify-content: space-between;
/* 水平均匀分布 */
margin-top: 32rpx;
padding: 0 32rpx;
position: fixed;
bottom: 0;
background: #fff;
/deep/.u-btn {
width: 48%;
margin-top: 32rpx;
}
}
.repair_form {
padding: 0 18rpx;
}
.collapse-room {
margin: 0 32rpx 20rpx;
color: rgba(0, 0, 0, 1);
}
// .collapse-major {
// margin: 0 32rpx 20rpx;
// color: rgba(0, 0, 0, 1);
// margin: 12rpx 24rpx 12rpx;
.n-box {
border: 1px solid rgba(239, 239, 239, 1);
padding: 32rpx 54rpx 0;
margin-top: 24rpx;
margin-bottom: 24rpx;
position: relative;
.right-tag {
position: absolute;
right: 0;
top: 0;
}
.left-tag {
position: absolute;
left: 0;
top: 0;
padding-left: 10rpx;
padding-right: 10rpx;
}
.n-box-title {
color: rgba(0, 0, 0, 1);
font-size: 28rpx;
text-align: left;
}
.n-box-info {
line-height: 32rpx;
color: rgba(154, 154, 154, 1);
font-size: 24rpx;
padding-top: 12rpx;
padding-bottom: 12rpx;
}
.info_item {
width: 100%;
display: flex;
flex-direction: row;
margin: 24rpx 0 24rpx;
.item_left_txt {
color: rgba(108, 108, 108, 1);
font-size: 28rpx;
text-align: left;
width: 170rpx;
margin-right: 20rpx;
line-height: 60rpx;
}
.item_right_txt {
flex: 1;
max-width: calc(100% - 220rpx);
color: rgba(0, 0, 0, 1);
font-size: 28rpx;
// text-align: left;
text-align: justify;
font-family: SourceHanSansSC-regular;
/deep/.u-radio-group {
flex-wrap: nowrap;
padding-right: 48rpx;
}
.btn {
width: 260rpx;
height: 60rpx;
line-height: 60rpx;
border-radius: 8rpx;
background-color: rgba(255, 255, 255, 1);
color: rgba(58, 98, 215, 1);
font-size: 28rpx;
text-align: center;
border: 2rpx dashed rgba(58, 98, 215, 1);
}
}
}
}
/deep/.u-collapse {
padding: 0 16rpx;
}
/deep/.arrow {
top: 12rpx;
}
.material-box {
flex: 1;
background: #fff;
margin: 0;
overflow: auto;
// padding-bottom: 32rpx;
.material-item {
height: 300rpx;
border-radius: 20rpx;
background-color: rgba(249, 249, 249, 1);
margin: 32rpx 0 0;
padding: 32rpx;
display: flex;
flex-direction: row;
.title-wrapper {}
.item-right {
flex: 1;
.material-title {
display: flex;
flex-direction: row;
color: rgba(108, 108, 108, 1);
font-size: 28rpx;
line-height: 60rpx;
.material-title-name {
color: rgba(51, 51, 51, 1);
font-size: 36rpx;
font-weight: 550;
padding-right: 16rpx;
}
.material-title-code {
flex: 1;
}
}
.material-text {
line-height: 60rpx;
color: rgba(108, 108, 108, 1);
font-size: 28rpx;
}
.material-num {
display: flex;
flex-direction: row;
justify-content: space-between;
}
}
}
}
.material-btn {
width: 100%;
display: flex;
justify-content: space-between;
/* 水平均匀分布 */
margin-top: 32rpx;
padding: 0 32rpx;
/deep/.u-btn {
width: 48%;
}
}
}
</style>