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

1547 lines
63 KiB

<template>
<basic-container style="max-height: 800px;overflow: hidden;">
<avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" v-model="form"
:permission="permissionList" :before-open="beforeOpen" :before-close="beforeClose"
@selection-change="selectionChange" @search-change="searchChange" @search-reset="searchReset"
@current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
<template slot-scope="{ row }" slot="repairStatus">
<el-tag :type="getStatus('inspectionMaintenance', userInfo.role_id, row.repairStatus).type">{{
getStatus('inspectionMaintenance', userInfo.role_id, row.repairStatus).name }}</el-tag>
</template>
<template slot-scope="scope" slot="menuLeft">
<!-- <el-button size="small" type="primary" @click="handleAdd">确认</el-button> -->
<!-- <el-button size="small" @click="clickInvoice">开具发票</el-button> -->
</template>
<template slot-scope="{ row }" slot="menu">
<el-button @click="handleView(row)" v-show="permission.repairDetails">查看</el-button>
<el-button @click="handleSubmit(row)"
v-show="permission.repairsubmit && (row.repairStatus == 1 || row.repairStatus == 101)">提交</el-button>
<el-button @click="handleCheck(row)"
v-show="permission.repairapprove && (row.repairStatus == 2 || row.repairStatus == 102)">审核</el-button>
<el-button v-show="permission.repairconfirm && row.repairStatus == 3" @click="handleAccept(row)">确认</el-button>
<el-button v-show="permission.repaircomplete && row.repairStatus == 4"
@click="handleRepairFinishUpload(row)">维修完成</el-button>
<el-button v-show="permission.repairevaluate && row.repairStatus == 5"
@click="handleEvaluate(row)">评价</el-button>
<el-button v-show="permission.confirmpayment && row.repairStatus == 6"
@click="paymentFinish(row)">确认付款</el-button>
<el-button @click="handleExport(row)"
v-show="row.repairStatus == 6 || row.repairStatus == 7 || row.repairStatus == 8">报告</el-button>
</template>
</avue-crud>
<el-dialog title="巡检异常维修" :visible.sync="dialogerror" :append-to-body="true" width="70%"
:close-on-click-modal="false">
<div style="height: 500px; overflow: auto">
<el-form ref="errorForm" :model="errorForm" :rules="addRules" label-width="120px" label-position="left">
<div>
<div style="
color: #101010;
font-size: 20px;
font-weight: 550;
margin-bottom: 20px;
">
基本信息
</div>
<el-form-item label="单位名称" prop="deptName">
<el-input placeholder="请输入单位名称" readonly v-model="errorForm.deptName" disabled
style="width: 98%;"></el-input>
</el-form-item>
</div>
<div>
<div style="
color: #101010;
font-size: 20px;
font-weight: 550;
margin-bottom: 20px;
">
巡检异常清单
</div>
<el-form-item label="异常清单">
<el-table row-key="id" :span-method="errorSpanMethod" :data="errorForm.tableData" border
style="width: 98%" :summary-method="getSummaries" show-summary :row-class-name="tableRowClassName"
:expand-row-keys="expandedKeys">
<el-table-column type="expand" fixed="left">
<template slot-scope="props">
<el-table :data="props.row.detailGoodsList" stripe style="width: 100%">
<el-table-column prop="goodsName" align="center" label="物料名称">
</el-table-column>
<el-table-column prop="warehouseId" label="库存ID" align="center">
</el-table-column>
<el-table-column prop="rule" align="center" label="规格" width="80">
</el-table-column>
<el-table-column prop="xh" align="center" label="型号" width="120">
</el-table-column>
<el-table-column prop="number" align="center" label="数量">
</el-table-column>
<el-table-column prop="unit" align="center" label="单位" width="80">
</el-table-column>
<el-table-column prop="price" align="center" label="价格" width="200">
<template slot-scope="scope">{{ scope.row.price }}元
</template>
</el-table-column>
</el-table>
</template>
</el-table-column>
<el-table-column type="index" width="50" label="序号" fixed="left">
</el-table-column>
<el-table-column label="楼层" prop="floorName" width="150"></el-table-column>
<el-table-column label="房间名称" prop="deptName" width="150"></el-table-column>
<el-table-column label="专业/设备" prop="deviceName" width="150"></el-table-column>
<el-table-column label="巡检内容" prop="checkContent" width="150"></el-table-column>
<el-table-column label="工艺要求" prop="craft" width="150"></el-table-column>
<el-table-column label="状态" prop="status" v-if="errorForm.repairStatus != 1" width="100">
<template slot-scope="scope">
{{ scope.row.status == 1 ? '异常' : '正常' }}
</template>
</el-table-column>
<el-table-column label="异常原因" prop="remark" width="100"></el-table-column>
<el-table-column prop="isRepair" align="center" label="是否维修"
v-if="(errorForm.repairStatus >= 3) && (errorForm.repairStatus != 101)" width="150">
<template slot-scope="scope">
<el-radio-group v-model="scope.row.isRepair" fill="red">
<el-radio :disabled="viewType == 'view' || viewType == 'evaluate' || dataTypes != 1"
:label="1">是</el-radio>
<el-radio :disabled="viewType == 'view' || viewType == 'evaluate' || dataTypes != 1"
class="error_radio" :label="0">否</el-radio>
</el-radio-group>
</template>
</el-table-column>
<el-table-column prop="repairOption" align="center" label="维修方案" width="150"
v-if="(viewType != 'view') || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)">
<template slot-scope="scope">
<el-input placeholder="请输入维修方案"
:disabled="viewType == 'view' || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)"
v-model="scope.row.repairOption" style="width: 98%;"></el-input>
</template>
</el-table-column>
<el-table-column prop="isNeed" align="center" label="是否需要物料" width="120"
v-if="(viewType != 'view') || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)">
<template slot-scope="scope">
<el-radio-group v-model="scope.row.isNeed" fill="red">
<el-radio
:disabled="viewType == 'view' || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)"
:label="'1'">是</el-radio>
<el-radio
:disabled="viewType == 'view' || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)"
class="error_radio" :label="'0'">否</el-radio>
</el-radio-group>
</template>
</el-table-column>
<el-table-column align="center" label="物料配置" width="120"
v-if="(viewType != 'view') || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)">
<template slot-scope="scope">
<el-button @click="setMaterial(scope.row)" :disabled="scope.row.isNeed == 0"
size="mini">物料配置</el-button>
</template>
</el-table-column>
<!-- 维修完成 -->
<el-table-column align="center" label="维修完成图片" width="200"
v-if="(viewType != 'view') && (errorForm.repairStatus == 4 || errorForm.repairStatus == 5 || errorForm.repairStatus == 6 || errorForm.repairStatus == 7 || errorForm.repairStatus == 8)">
<template slot-scope="scope">
<div v-if="errorForm.repairStatus == 4">
<el-upload action="/api/blade-resource/oss/endpoint/put-file" list-type="picture-card"
:headers="headers" accept=".jpeg,.jpg,.png,.pdf" :file-list="scope.row.completeImgList"
:on-success="handleSuccess(scope.$index)" :on-remove="handleRemove(scope.$index)"
:before-upload="beforeAvatarUpload(scope.$index)">
<i class="el-icon-plus"></i>
</el-upload>
</div>
<div v-else>
<img v-for="item in scope.row.completeImgList" :key="item" :src="item.url" alt=""
style="width: 148px; height: 148px;margin-right:10px;">
</div>
</template>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item label="差旅费"
v-if="(viewType != 'view') || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)">
<el-input placeholder="请输入差旅费" v-model="errorForm.travelExpense" style="width:98%;"
:disabled="viewType == 'view' || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)"><template
slot="append">元</template></el-input>
</el-form-item>
<el-form-item label="处理结果"
v-if="(viewType != 'view') || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)">
<el-input placeholder="请输入处理结果" type="textarea" v-model="errorForm.processingResult" style="width:98%;"
:disabled="viewType == 'view' || (errorForm.repairStatus != 1 && errorForm.repairStatus != 101)"></el-input>
</el-form-item>
<el-form-item label="维修总计"
v-if="viewType != 'view' && (errorForm.repairStatus == 2 || errorForm.repairStatus == 3 || errorForm.repairStatus == 4 || errorForm.repairStatus == 5 || errorForm.repairStatus == 6 || errorForm.repairStatus == 7 || errorForm.repairStatus == 8 || errorForm.repairStatus == 102)">
<el-input placeholder="请输入" v-model="errorForm.actualAmount" style="width:98%;"
:disabled="viewType == 'view' || (errorForm.repairStatus != 2 && errorForm.repairStatus != 102)"><template
slot="append">元</template></el-input>
</el-form-item>
</div>
<!-- 主管审核 -->
<div
v-show="((errorForm.repairStatus == 2 || errorForm.repairStatus == 102) || ((errorForm.repairStatus == 1 || errorForm.repairStatus == 101) && errorForm.approvePoint == '主管审核维修方案')) && viewType != 'view'">
<div style="
color: #101010;
font-size: 20px;
font-weight: 550;
margin-bottom: 20px;
">
主管审核
</div>
<el-form-item label="审核结果">
<el-select placeholder="请选择审核结果" v-model="errorForm.approveResultManager" style="width: 98%;"
:disabled="(errorForm.repairStatus == 1 || errorForm.repairStatus == 101) && errorForm.approvePoint == '主管审核维修方案'">
<el-option label="通过" :value="1"></el-option>
<el-option label="驳回" :value="0"></el-option>
</el-select>
</el-form-item>
<el-form-item label="审核意见">
<el-input type="textarea" v-model="errorForm.approveRemarkManager" style="width: 98%;"
:disabled="(errorForm.repairStatus == 1 || errorForm.repairStatus == 101) && errorForm.approvePoint == '主管审核维修方案'"></el-input>
</el-form-item>
<el-form-item
v-if="(errorForm.repairStatus == 1 || errorForm.repairStatus == 101) && errorForm.approvePoint == '主管审核维修方案'"
label="审批时间">
<el-input v-model="errorForm.approveTime" style="width: 98%;"
:disabled="(errorForm.repairStatus == 1 || errorForm.repairStatus == 101) && errorForm.approvePoint == '主管审核维修方案'"></el-input>
</el-form-item>
</div>
<!-- 客户确认方案 -->
<div v-show="errorForm.repairStatus == 3 && viewType != 'view'">
<div style="
color: #101010;
font-size: 20px;
font-weight: 550;
margin-bottom: 20px;
">
客户确认
</div>
<el-form-item label="审核结果">
<el-select placeholder="请选择审核结果" v-model="errorForm.approveResult" style="width: 98%;"
:disabled="viewType == 'view'">
<el-option label="通过" :value="1"></el-option>
<el-option label="驳回" :value="0"></el-option>
</el-select>
</el-form-item>
<el-form-item label="审核意见">
<el-input type="textarea" v-model="errorForm.approveRemark" style="width: 98%;"
:disabled="viewType == 'view'"></el-input>
</el-form-item>
</div>
<!-- 维修效果确认 -->
<div
v-show="viewType != 'view' && (errorForm.repairStatus == 5 || errorForm.repairStatus == 6 || errorForm.repairStatus == 7 || errorForm.repairStatus == 8)">
<div style="
color: #101010;
font-size: 20px;
font-weight: 550;
margin-bottom: 20px;
">
维修效果确认
</div>
<el-form-item label="是否维修完成">
<el-select placeholder="请确认是否维修完成" style="width: 98%;" v-model="errorForm.approveResult1"
@change="changeResult" :disabled="viewType == 'view'">
<el-option label="是" :value="1"></el-option>
<el-option label="否" :value="0"></el-option>
</el-select>
</el-form-item>
<el-form-item label="维修未完成原因" v-show="rowStatus == 5 && errorForm.approveResult1 == 0">
<el-input type="textarea" v-model="errorForm.approveRemark" placeholder="请输入维修未完成原因"
style="width: 98%;"></el-input>
</el-form-item>
<div v-show="errorForm.approveResult1 == 1">
<div style="
color: #101010;
font-size: 20px;
font-weight: 550;
margin-bottom: 20px;
">
评价
</div>
<div>
<p>1.您对本次维修的质量方面满意吗?</p>
<div style="display:flex;">
<div style="width: 150px;
border-radius: 5px;
height: 30px;
text-align: center;
line-height: 30px;
margin-right: 20px;
cursor:pointer;"
:style="{ background: errorForm.isOkQuality == '1' ? '#3a62d733' : 'rgb(239, 239, 239)', color: errorForm.isOkQuality == '1' ? '#3a62d7' : '#4f4f4f' }"
@click="clickQualityYes">满意</div>
<div style="width: 150px;
border-radius: 5px;
height: 30px;
background: rgb(239, 239, 239);
text-align: center;
line-height: 30px;
margin-right: 20px;cursor:pointer;"
:style="{ background: errorForm.isOkQuality == '0' ? '#3a62d733' : 'rgb(239, 239, 239)', color: errorForm.isOkQuality == '0' ? '#3a62d7' : '#4f4f4f' }"
@click="clickQualityNo">不满意</div>
</div>
</div>
<div>
<p>2.您对本次维修的安全方面满意吗?</p>
<div style="display:flex;">
<div style="width: 150px;
border-radius: 5px;
height: 30px;
background: rgb(239, 239, 239);
text-align: center;
line-height: 30px;
margin-right: 20px;cursor:pointer;"
:style="{ background: errorForm.isOkSecure == '1' ? '#3a62d733' : 'rgb(239, 239, 239)', color: errorForm.isOkSecure == '1' ? '#3a62d7' : '#4f4f4f' }"
@click="clickSafeYes">满意</div>
<div style="width: 150px;
border-radius: 5px;
height: 30px;
background: rgb(239, 239, 239);
text-align: center;
line-height: 30px;
margin-right: 20px;cursor:pointer;"
:style="{ background: errorForm.isOkSecure == '0' ? '#3a62d733' : 'rgb(239, 239, 239)', color: errorForm.isOkSecure == '0' ? '#3a62d7' : '#4f4f4f' }"
@click="clickSafeNo">不满意</div>
</div>
</div>
<div>
<p>3.您对本次维修的时效方面满意吗?</p>
<div style="display:flex;margin-bottom:30px;">
<div style="width: 150px;
border-radius: 5px;
height: 30px;
background: rgb(239, 239, 239);
text-align: center;
line-height: 30px;
margin-right: 20px;cursor:pointer;"
:style="{ background: errorForm.isOkValidity == '1' ? '#3a62d733' : 'rgb(239, 239, 239)', color: errorForm.isOkValidity == '1' ? '#3a62d7' : '#4f4f4f' }"
@click="clickTimeYes">满意</div>
<div style="width: 150px;
border-radius: 5px;
height: 30px;
background: rgb(239, 239, 239);
text-align: center;
line-height: 30px;
margin-right: 20px;cursor:pointer;"
:style="{ background: errorForm.isOkValidity == '0' ? '#3a62d733' : 'rgb(239, 239, 239)', color: errorForm.isOkValidity == '0' ? '#3a62d7' : '#4f4f4f' }"
@click="clickTimeNo">不满意</div>
</div>
</div>
<el-form-item label="意见" label-width="60px"
v-show="(!errorForm.isOkQuality || !errorForm.isOkSecure || !errorForm.isOkValidity)">
<el-input type="textarea" v-model="errorForm.evaluationRemarks" placeholder="意见" style="width: 98%;"
:disabled="dialogType == 'view' || (errorForm.repairStatus == 6 || errorForm.repairStatus == 7 || errorForm.repairStatus == 8)"></el-input>
</el-form-item>
</div>
<div
v-show="(rowStatus == 5 || errorForm.repairStatus == 6 || errorForm.repairStatus == 7 || errorForm.repairStatus == 8 || isEvalute) && errorForm.approveResult1 == 1">
<div style="
color: #101010;
font-size: 20px;
font-weight: 550;
margin-bottom: 20px;
">
签名
</div>
<div style="margin-bottom: 10px;cursor: pointer;" @click="clickAssign"
v-show="nameImg == '' && (errorForm.repairStatus == 5)">
<img src="@/assets/images/assign.png" alt="">
</div>
<div v-show="nameImg != '' && (errorForm.repairStatus == 5)" @click="clickAssign">
<img :src="nameImg" alt="">
</div>
<div
v-show="errorForm.signatureUrl != '' && (errorForm.repairStatus == 6 || errorForm.repairStatus == 7 || errorForm.repairStatus == 8)">
<img :src="errorForm.signatureUrl" alt="">
</div>
</div>
</div>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose">关 闭</el-button>
<el-button v-show="viewType != 'view'" type="primary" @click="handleConfirmError">提 交</el-button>
</span>
</el-dialog>
<el-dialog title="签名" :visible.sync="assignVisible" :append-to-body="true" width="50%"
:close-on-click-modal="false">
<div v-show="isEvalute">
<avue-sign ref="sign"></avue-sign>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="closeName">关闭</el-button>
<el-button @click="clearName">清空</el-button>
<el-button @click="confirmName" type="primary">确定</el-button>
</span>
</el-dialog>
<el-dialog :close-on-click-modal="false" title="物料配置" :visible.sync="materialVisible" :append-to-body="true"
width="70%" :key="Math.random()">
<el-table :data="materialData" border style="width: 98%">
<el-table-column width="50" align="center" v-if="viewType == 'submit'">
<template slot="header" slot-scope="scope">
<div @click="addColumn()"
style="width:30px;height: 30px;background: #409eff;border-radius: 50%;cursor: pointer;display: flex;align-items: center;justify-content: center;">
<i style="color:#fff;font-size: 20px;" class="el-icon-plus"></i>
</div>
</template>
<template slot-scope="scope">
<div @click="deleteColumn(scope.row, scope.$index)"
style="width:30px;height: 30px;background: #f56c6c;border-radius: 50%;cursor: pointer;display: flex;align-items: center;justify-content: center;">
<i style="color:#fff;font-size: 20px;" class="el-icon-delete"></i>
</div>
</template>
</el-table-column>
<el-table-column prop="productId" align="center" label="物料名称" width="150">
<template slot-scope="scope">
<el-select @change="((val) => { changeProduct(val, scope.$index) })"
@blur="((val) => { changeProduct(val, scope.$index) })" v-loadmore="loadmoreProduct"
v-model="scope.row.productId" filterable remote :remote-method="remoteMethodProduct" placeholder="请选择物品"
:disabled="viewType != 'submit'">
<el-option v-for="item in productLists" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="warehouseId" label="库存ID" align="center" width="150">
</el-table-column>
<el-table-column prop="rule" align="center" label="规格" width="150">
<template slot-scope="scope">
<el-input v-if="scope.row.goodsName == '其他'" v-model="scope.row.rule" placeholder="请输入规格" style="width:98%;"
size="mini"></el-input>
<span v-else>{{ scope.row.rule }}</span>
</template>
</el-table-column>
<el-table-column prop="xh" align="center" label="型号" width="150">
<template slot-scope="scope">
<el-input v-if="scope.row.goodsName == '其他'" v-model="scope.row.model" placeholder="请输入型号"
style="width:98%;" size="mini"></el-input>
<span v-else>{{ scope.row.model }}</span>
</template>
</el-table-column>
<el-table-column prop="number" align="center" label="数量" width="200">
<template slot-scope="scope">
<el-input-number style="width: 100%;" @change="((val) => { changeNumber(val, scope.row) })"
v-model="scope.row.number" placeholder="请输入数量" :min="1"
:disabled="viewType != 'submit'"></el-input-number>
</template>
</el-table-column>
<el-table-column prop="unit" align="center" label="单位" width="150">
<template slot-scope="scope">
<el-input v-if="scope.row.goodsName == '其他'" v-model="scope.row.unit" placeholder="请输入单位" style="width:98%;"
size="mini"></el-input>
<span v-else>{{ scope.row.unit }}</span>
</template>
</el-table-column>
<el-table-column prop="price" align="center" label="价格" width="200">
<!-- <template slot-scope="scope">
<el-input v-model="scope.row.price" disabled placeholder="请输入价格" style="width:98%;">
<template slot="append">元</template>
</el-input>
</template> -->
<template slot-scope="scope">
<el-input v-if="scope.row.goodsName == '其他'" v-model="scope.row.price" placeholder="请输入价格"
style="width:98%;" size="mini">
<template slot="append">元</template>
</el-input>
<el-input v-else v-model="scope.row.price" disabled placeholder="请输入价格" style="width:98%;" size="mini">
<template slot="append">元</template>
</el-input>
</template>
</el-table-column>
<!-- <template slot="append" v-if="tableData.length != 0">
<tr>
<td style="padding: 10px;padding-right: 0;font-size: 14px;color: #909399;font-weight: 600;">总计:</td>
<td>{{Math.trunc(tableData.reduce((acc, obj) => acc + ((Number(obj.price)) || 0), 0) * 100)
/ 100}} 元</td>
</tr>
</template> -->
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="materialVisible = false">取 消</el-button>
<el-button @click="handleCloneSub" type="primary"> </el-button>
</span>
</el-dialog>
</basic-container>
</template>
<script>
import website from '@/config/website';
import { getToken, removeToken, removeRefreshToken } from '@/util/auth';
import statusData from "@/assets/json/status.json"; // 引入状态数据
import { getRepairPage, solutionSave, solutionSubmit, supervisorConfirm, supervisorRefuse, customerConfirm, customerRefuse, servicemanSubmit, repairServiceConfirm, customerConfirmFinish, customerRefuseFinish, repairConfirmConfirm } from '@/api/labManagement/repair'
import { addFile } from '@/api/operation/hand'
import { getRepairDetail } from '@/api/labManagement/task'
import { mapGetters } from "vuex";
import routingInspection from '@/views/components/routingInspection.vue'
import { getGoodsList } from '@/api/goodsManagement/goods'
import { exportBlob1, zipDownload } from "@/api/common";
import { downloadXls } from "@/util/util";
import moment from "moment";
export default {
components: {
routingInspection
},
data() {
return {
isClear: false,
materialVisible: false,
assignVisible: false,
routingForm: {},
htmlTitle: '巡检维修报告',
option: {
selection: true,
height: "auto",
calcHeight: 30,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
dialogType: "dialog",
dialogClickModal: false,
addBtn: false,
viewBtn: false,
editBtn: false,
delBtn: false,
searchShowBtn: false,
refreshBtn: false,
columnBtn: false,
menuWidth: 300,
searchShowBtn: false,   // 栏目折叠显隐
refreshBtn: false,      // 刷新
columnBtn: false,       // 操作列显隐
gridBtn: false,
excelBtn: false,       // 导出Excel
printBtn: false,       // 表格打印导出
filterBtn: false,      // 筛选
searchEnter: true,
column: [
{
label: "任务单号",
labelWidth: 120,
prop: "taskCode",
overHidden: true,
},
{
label: "单位名称",
labelWidth: 120,
prop: "deptName",
search: true,
overHidden: true,
},
{
label: "巡检说明",
labelWidth: 120,
prop: "taskContent",
overHidden: true,
},
{
label: "巡检完成时间",
labelWidth: 120,
prop: "finishTime",
overHidden: true,
},
// {
// label: "项目地址",
// labelWidth: 120,
// prop: "projectAddr",
// overHidden: true,
// },
// {
// label: "巡检楼层",
// labelWidth: 120,
// prop: "inspectionFloor",
// overHidden: true,
// },
{
label: "状态",
labelWidth: 120,
prop: "repairStatus",
slot: true,
},
],
},
data: [],
errorForm: {
tableData: [
{ id: '001', floorName: "一层", deptName: '101', deviceName: "设备一", checkContent: '', status: '1', price: '' },
{ id: '002', floorName: "一层", deptName: '101', deviceName: "设备二", checkContent: '', status: '1', price: '' },
{ id: '003', floorName: "一层", deptName: '101', deviceName: "设备三", checkContent: '', status: '1', price: '' },
{ id: '004', floorName: "一层", deptName: '101', deviceName: "设备四", checkContent: '', status: '1', price: '' },
]
},
dialogerror: false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectedList: [],
viewType: '',
isEvalute: false,
rowStatus: '',
nameImg: '',
spanArr: [],
pos: '',
spanArr1: [],
pos1: '',
materialData: [],
materialId: '',
productCurrent: 1,
productSize: 100,
productTotals: 0,
productLists: [],
totalPrice: null,//物料金额总计
dataTypes: '',//数据
headers: {},
completeImgList: [],//维修完成上传图片
expandedKeys: [],//默认展开
}
},
computed: {
...mapGetters(["userInfo", "permission"]),
getStatus() {
return (type, id, status) => {
for (let i in statusData[type]) {
let val
statusData[type][id].map(item => {
if (item.status == status) {
val = item
}
})
return val ? val : ''
}
}
},
},
mounted() {
this.dataTypes = this.userInfo.dataType
this.headers = {
"Authorization": `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`,
'Blade-Auth': 'bearer ' + getToken(),
'Blade-Requested-With': 'BladeHttpRequest'
}
},
methods: {
tableRowClassName({ row, rowIndex }) {
if (row.repairStatus >= 4 && row.isRepair == 0 && this.dataTypes == 1) { // 假设你想要特殊颜色的行是第二行
return 'highlight-row';
}
return '';
},
deleteColumn(row, index) {
this.tableData.splice(index, 1);
},
// 物料总价
getSummaries(param) {
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
}
const values = data.map(item => {
let price = null
if (item.detailGoodsList.length > 0) {
price = item.detailGoodsList.reduce((sum, items) => sum + items.price, 0)
return price
}
});
if (!values.every(value => isNaN(value))) {
sums[columns.length - 1] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return Number(prev) + Number(curr);
} else {
return Number(prev);
}
}, 0);
sums[columns.length - 1] = sums[columns.length - 1] > 0 ? Math.round(sums[columns.length - 1] * 100) / 100 : 0
this.totalPrice = sums[columns.length - 1]
sums[columns.length - 1] += ' 元';
}
});
return sums;
},
closeName() {
if (this.nameImg == '') {
this.$refs.sign.clear()
}
this.assignVisible = false
},
clearName() {
this.$refs.sign.clear()
this.nameImg = ''
// this.isClear = true
},
confirmName() {
if (this.isClear) {
this.nameImg = ''
} else {
this.nameImg = this.$refs.sign.submit(80, 50);
}
this.assignVisible = false
},
// 点击签名
clickAssign() {
this.assignVisible = true
},
setMaterial(row) {
this.materialId = row.id
this.getProductLists()
this.materialData = row.detailGoodsList
this.materialVisible = true
},
addColumn() {
let arr = JSON.parse(JSON.stringify(this.materialData))
arr.push({ materialId: this.materialId, warehouseId: '', productId: '', goodsName: '', rule: '', xh: '', number: '', unit: '', price: '', productList: [] })
this.materialData = arr
},
// 物料选择
handleCloneSub() {
let data = []
this.materialData.forEach(item => {
data.push({
warehouseId: item.warehouseId,//物资id
goodsName: item.goodsName, //物资名称
unit: item.unit,//单位
xh: item.xh,//型号
rule: item.rule,//规格
price: item.price,
number: item.number,//领用数量
productId: item.productId,//物料id
hasChildren: true,
})
})
// 确定之后给每一条数据加上物料列表
this.errorForm.tableData.forEach(item => {
if (item.id == this.materialId) {
item.detailGoodsList = []
item.detailGoodsList = data
}
})
this.materialVisible = false
},
changeProduct(value, index) {
let newArr = this.productLists.find(item => item.id == value)
if (typeof value == 'string') {
if (newArr.length <= 0) {
return false
}
newArr.unifiedQuotation = newArr.unifiedQuotation == -1 ? 0 : newArr.unifiedQuotation
this.materialData[index].price = newArr.unifiedQuotation * 1
// this.materialData[index].productId = newArr.productId
this.materialData[index].number = 1
this.materialData[index].rule = newArr.rule
this.materialData[index].xh = newArr.xh
this.materialData[index].unit = newArr.unit
this.materialData[index].goodsName = newArr.name
this.materialData[index].unifiedQuotation = newArr.unifiedQuotation
this.materialData[index].warehouseId = newArr.inventoryId
} else if (typeof value == 'object' && value.target.value != '') {
this.productLists.find(item => item.id == value).unifiedQuotation = this.productLists.find(item => item.id == value).unifiedQuotation == -1 ? 0 : this.productLists.find(item => item.id == value).unifiedQuotation
this.materialData[index].price = this.productLists.find(item => item.id == value.target.value) ? this.productLists.find(item => item.id == value.target.value).unifiedQuotation * 1 : ''
this.materialData.filter(item => item.materialId == this.materialId)[index].number = 1
this.materialData.filter(item => item.materialId == this.materialId)[index].rule = this.productLists.find(item => item.id == value.target.value) ? this.productLists.find(item => item.id == value.target.value).rule : ''
this.materialData.filter(item => item.materialId == this.materialId)[index].xh = this.productLists.find(item => item.id == value.target.value) ? this.productLists.find(item => item.id == value.target.value).xh : ''
this.materialData.filter(item => item.materialId == this.materialId)[index].unit = this.productLists.find(item => item.id == value.target.value) ? this.productLists.find(item => item.id == value.target.value).unit : ''
this.materialData.filter(item => item.materialId == this.materialId)[index].goodsName = this.productLists.find(item => item.id == value.target.value) ? this.productLists.find(item => item.id == value.target.value).name : ''
this.materialData.filter(item => item.materialId == this.materialId)[index].unifiedQuotation = this.productLists.find(item => item.id == value.target.value) ? this.productLists.find(item => item.id == value.target.value).unifiedQuotation : ''
this.materialData.filter(item => item.materialId == this.materialId)[index].warehouseId = this.productLists.find(item => item.id == value.target.value) ? this.productLists.find(item => item.id == value.target.value).inventoryId : ''
}
},
changeNumber(val, row) {
// row.price = row.price * val
// row.price = row.unifiedQuotation * val
if (row.unifiedQuotation) {
row.price = (row.unifiedQuotation * val).toFixed(2)
} else {
}
},
loadmoreProduct() {
if (this.productCurrent * this.productSize >= this.productTotals) return
this.productCurrent++
this.getProductLists('more')
},
getProductLists(type, val, inventoryId) {
getGoodsList({ current: this.productCurrent, size: this.productSize, name: val ? val : null }).then(res => {
if (type == 'more') {
this.productLists = this.productLists.concat(res.data.data.records)
this.productTotals = res.data.data.total
} else {
this.productLists = res.data.data.records
this.productTotals = res.data.data.total
}
})
},
getSpanArr(data) {
for (var i = 0; i < data.length; i++) {
if (i === 0) {
this.spanArr.push(1);
this.pos = 0
} else {
// 判断当前元素与上一个元素是否相同
if (data[i].floorName === data[i - 1].floorName) {
this.spanArr[this.pos] += 1;
this.spanArr.push(0);
} else {
this.spanArr.push(1);
this.pos = i;
}
}
}
},
errorSpanMethod({ row, column, rowIndex, columnIndex }) {
// if (columnIndex === 0 && row.floorName != '') {
// if (this.spanArr.length != 0) {
// const _row = this.spanArr[rowIndex];
// const _col = _row > 0 ? 1 : 0;
// return {
// rowspan: _row,
// colspan: _col
// }
// }
// }
},
handleExport(row) {
let query = JSON.parse(JSON.stringify(row))
exportBlob1(`/api/lab-ops/maintenance/repair-output-service`, query).then(res => {
downloadXls(res.data, "巡检维修报告.xlsx");
})
},
beforeOpen(done, type) {
done();
},
beforeClose(done) {
done();
},
searchReset(params, done) {
// params.releaseTimeRange = dateFormat(new Date(), 'yyyy-MM-dd');
this.query = params;
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectedList = list
},
// 点击确认按钮
handleAdd() {
if (this.selectedList.length != 1) {
this.$message.warning('只能选择一条数据')
} else {
if (this.selectedList[0].status == 1) {
this.$message.warning('请选择状态为待确认的数据')
} else {
this.errorForm = this.selectedList[0]
this.dialogerror = true
}
}
},
// 点击查看按钮
handleView(row) {
this.viewType = 'view'
getRepairDetail({ id: row.id }).then(res => {
if (res.data.code == 200) {
this.errorForm = res.data.data
this.dialogerror = true
let data = this.checkDeepData(res.data.data.details)
if (this.errorForm.repairStatus > 1) {
data.forEach(item => {
item.completeImgList = item.completeImgList != '' ? JSON.parse(item.completeImgList) : []
if (item.detailGoodsList.length > 0) {
item.isNeed = '1'
} else {
item.isNeed = '0'
}
})
}
this.errorForm.tableData = []
this.errorForm.tableData = data
this.getExpandedKeys(data)
this.errorForm.tableData.map(item => {
item.price = item.price == -1 ? '' : item.price
})
this.errorForm.approveResult1 = this.errorForm.approveResult
this.nameImg = ''
this.getSpanArr(this.errorForm.tableData)
}
})
// this.errorForm = row
// this.dialogerror = true
},
// 点击行内的评价并签字按钮
handleEvaluate(row) {
getRepairDetail({ id: row.id }).then(res => {
this.rowStatus = res.data.data.repairStatus
this.viewType = 'evaluate'
this.errorForm = res.data.data
this.dialogerror = true
this.isEvalute = true
this.errorForm.isOkValidity = ''
this.errorForm.isOkQuality = ''
this.errorForm.isOkSecure = ''
let data = this.checkDeepData(res.data.data.details)
this.completeImgList = this.errorForm.completeImgList == '' ? [] : JSON.parse(this.errorForm.completeImgList)
if (this.errorForm.repairStatus > 1) {
data.forEach(item => {
item.completeImgList = JSON.parse(item.completeImgList)
if (item.detailGoodsList.length > 0) {
item.isNeed = '1'
} else {
item.isNeed = '0'
}
})
}
this.errorForm.tableData = data
this.getExpandedKeys(data)
})
},
// 客户选择是否维修完成
changeResult(val) {
this.isFinish = val
},
clickQualityYes() {
if (this.viewType == 'evaluate') {
this.errorForm.isOkQuality = 1
}
},
clickQualityNo() {
if (this.viewType == 'evaluate') {
this.errorForm.isOkQuality = 0
}
},
clickSafeYes() {
if (this.viewType == 'evaluate') {
this.errorForm.isOkSecure = 1
}
},
clickSafeNo() {
if (this.viewType == 'evaluate') {
this.errorForm.isOkSecure = 0
}
},
clickTimeYes() {
if (this.viewType == 'evaluate') {
this.errorForm.isOkValidity = 1
}
},
clickTimeNo() {
if (this.viewType == 'evaluate') {
this.errorForm.isOkValidity = 0
}
},
clearName() {
this.$refs.sign.clear()
this.nameImg = ''
},
// confirmName() {
// this.nameImg = this.$refs.sign.submit(80, 50);
// },
//维修人员提交方案
handleSubmit(row) {
this.viewType = 'submit'
getRepairDetail({ id: row.id }).then(res => {
if (res.data.code == 200) {
this.errorForm = res.data.data
this.dialogerror = true
let data = this.checkDeepData(res.data.data.details)
this.errorForm.tableData = data
this.errorForm.tableData.map(item => {
item.price = item.price == -1 ? '' : item.price
})
data.forEach(item => {
if (item.detailGoodsList.length > 0) {
item.isNeed = '1'
} else {
item.isNeed = '0'
}
})
this.errorForm.tableData = data
this.getExpandedKeys(data)
}
})
},
// 主管审批
handleCheck(row) {
this.viewType = 'check'
getRepairDetail({ id: row.id }).then(res => {
if (res.data.code == 200) {
this.errorForm = res.data.data
this.dialogerror = true
let data = this.checkDeepData(res.data.data.details)
if (this.errorForm.repairStatus > 1) {
data.forEach(item => {
if (item.detailGoodsList.length > 0) {
item.isNeed = '1'
} else {
item.isNeed = '0'
}
})
}
this.errorForm.tableData = data
this.getExpandedKeys(data)
this.errorForm.approveResultManager = ''
this.errorForm.approveRemarkManager = ''
// 处理维修总金额
let priceAll = this.errorForm.totalPrice ? this.errorForm.totalPrice + this.errorForm.travelExpense : 0
this.errorForm.actualAmount = Math.round(priceAll * 100) / 100
}
})
},
// 客户确认
handleAccept(row) {
this.viewType = 'confirm'
getRepairDetail({ id: row.id }).then(res => {
if (res.data.code == 200) {
this.errorForm = res.data.data
this.dialogerror = true
let data = this.checkDeepData(res.data.data.details)
this.errorForm.tableData = data
this.errorForm.tableData.map(item => {
item.isRepair = 1
})
this.getExpandedKeys(data)
this.errorForm.approveResult = ''
this.errorForm.approveRemark = ''
}
})
// this.errorForm = row
// this.dialogerror = true
},
// 评价并签字提交
handleConfirm() {
if (this.errorForm.approveResult1 == 0) {//否
if (this.errorForm.approveRemark == '') {
this.$message.error('请输入原因!')
return false
}
let query = {
id: this.errorForm.id,
approveResult: this.errorForm.approveResult1,
approvePerson: this.userInfo.user_id,
approveTime: moment().format('YYYY-MM-DD HH:mm:ss'),
approveRemark: this.errorForm.approveRemark,
}
customerRefuseFinish(query).then(res => {
if (res.data.code == 200) {
this.$message.success('提交成功')
this.dialogerror = false
this.onLoad()
}
})
} else {//是
if (this.nameImg != '') {
const formData = new FormData();
formData.append('file', this.base64toFile(this.nameImg));
if (this.errorForm.isOkValidity === '' || this.errorForm.isOkQuality === '' || this.errorForm.isOkSecure === '') {
this.$message.error('请填写满意度')
return false
}
addFile(formData).then(res => {
let query = {
id: this.errorForm.id,
isOkValidity: this.errorForm.isOkValidity,
isOkQuality: this.errorForm.isOkQuality,
isOkSecure: this.errorForm.isOkSecure,
signatureUrl: res.data.data.link,
signaturePerson: this.errorForm.signaturePerson,
signatureTime: this.errorForm.signatureTime,
approveResult: this.errorForm.approveResult1,
evaluationRemarks: this.errorForm.evaluationRemarks
}
customerConfirmFinish(query).then(res => {
if (res.data.code == 200) {
this.$message.success('评价成功')
this.dialogerror = false
this.onLoad()
}
})
})
} else {
this.$message.warning("请进行手写签名并点击确定按钮")
}
}
},
handleFinish(row) {
this.$confirm('请确认是否维修完成?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
servicemanSubmit({ id: row.id }).then(res => {
if (res.data.code == 200) {
this.$message.success('维修完成')
this.onLoad()
}
})
})
},
base64toFile(dataurl, filename = 'file') {
let arr = dataurl.split(',')
let mime = arr[0].match(/:(.*?);/)[1]
let suffix = mime.split('/')[1]
let bstr = atob(arr[1])
let n = bstr.length
let u8arr = new Uint8Array(n)
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
let file = new File([u8arr], `${filename}.${suffix}`, {
type: mime
})
return file
},
// 确认付款是否完成
paymentFinish(row) {
this.$confirm('请确认付款是否完成?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
repairServiceConfirm({ id: row.id }).then(res => {
if (res.data.code == 200) {
this.$message.success('维修完成')
this.onLoad()
}
})
})
},
//用于回调的函数
checkData(data, list) {
data.forEach((item) => {
if (item.details && item.details.length > 0) {
this.checkData(item.details, list);
} else {
list.push(item);
}
});
return list;
},
//调用此函数 返回的就是最底层的数据
checkDeepData(data) {
const list = [];
return this.checkData(data, list);
},
handleClose() {
this.viewType = ''
this.dialogerror = false
},
// 巡检维修单保存按钮
handleSaveError() {
this.$refs['errorForm'].validate((valid) => {
if (valid) {
this.$confirm('请确认是否保存当前数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message.success('保存成功')
this.viewType = ''
this.dialogerror = false
})
}
})
},
// 巡检维修单确定按钮
handleConfirmError() {
this.$refs['errorForm'].validate((valid) => {
if (valid) {
if (this.viewType == 'submit') {
// if (this.errorForm.tableData.find(item => item.price === '')) {
// this.$message.error("请对异常的数据填写价格")
// } else {
let query = []
this.errorForm.tableData.map(item => {
query.push({
id: item.id, // 明细id
status: item.status, //状态,0:正常,1:异常
taskId: this.errorForm.id, // 任务ID
floorName: item.floorName, //楼层
deptId: item.deptId, //房间
majorName: item.majorName, //专业名称
checkContent: item.checkContent, //巡检内容
craft: item.craft, //工艺要求
period: item.period, //巡检周期 1:月, 2:季, 3:半年
picUrl: item.picUrl, //现场图片地址
signUrl: item.signUrl, //签字图片地址
remark: item.remark, //备注
price: item.price, //价格
// isRepair 客户确认是否维修, 0:不维修, 1维修
startTime: item.startTime, //计划开始时间
isNeed: item.isNeed,//是否需要物料 0,1
detailGoodsList: item.detailGoodsList,//物料列表
repairOption: item.repairOption
})
})
let params = {
task: {
id: this.errorForm.id,
},
detailList: query,
faultDescribe: this.errorForm.faultDescribe,//故障现象
faultCause: this.errorForm.faultCause,//故障产生原因
processingResult: this.errorForm.processingResult,//处理结果
travelExpense: this.errorForm.travelExpense,// 差旅费
inspectionConclusion: this.errorForm.inspectionConclusion,//巡检结论
totalPrice: this.totalPrice,//总价
}
solutionSave(params).then(res => {
if (res.data.code == 200) {
solutionSubmit({ id: this.errorForm.id }).then(res => {
if (res.data.code == 200) {
this.$message.success('提交成功')
this.dialogerror = false
this.onLoad()
}
})
}
})
// }
} else if (this.viewType == 'check') {//主管审核
if (this.errorForm.approveResultManager == 1) {
let query = {
id: this.errorForm.id, //任务id
approvePerson: this.userInfo.user_id, //审核人
approveResultManager: this.errorForm.approveResultManager, //审核结果
approveRemarkManager: this.errorForm.approveRemarkManager, //备注
actualAmount: this.errorForm.actualAmount
}
supervisorConfirm(query).then(res => {
if (res.data.code == 200) {
this.$message.success('提交成功')
this.dialogerror = false
this.onLoad()
}
})
} else {
let query = {
id: this.errorForm.id, //任务id
approvePerson: this.userInfo.user_id, //审核人
approveResultManager: this.errorForm.approveResultManager, //审核结果
approveRemarkManager: this.errorForm.approveRemarkManager //备注
}
supervisorRefuse(query).then(res => {
if (res.data.code == 200) {
this.$message.success('提交成功')
this.dialogerror = false
this.onLoad()
}
})
}
} else if (this.viewType == 'confirm') {
if (this.errorForm.approveResult == 1) {
let query = []
this.errorForm.tableData.map(item => {
query.push({
id: item.id, // 明细id
status: item.status, //状态,0:正常,1:异常
taskId: this.errorForm.id, // 任务ID
floorName: item.floorName, //楼层
deptId: item.deptId, //房间
majorName: item.majorName, //专业名称
checkContent: item.checkContent, //巡检内容
craft: item.craft, //工艺要求
period: item.period, //巡检周期 1:月, 2:季, 3:半年
picUrl: item.picUrl, //现场图片地址
signUrl: item.signUrl, //签字图片地址
remark: item.remark, //备注
price: item.price, //价格
isRepair: item.isRepair, //客户确认是否维修, 0:不维修, 1维修
startTime: item.startTime, //计划开始时间
})
})
let params = {
task: {
id: this.errorForm.id,
},
detailList: query //维修明细列表
}
customerConfirm(params).then(res => {
if (res.data.code == 200) {
this.$message.success('提交成功')
this.dialogerror = false
this.onLoad()
}
})
} else {
let query = {
id: this.errorForm.id, //任务id
approvePerson: this.userInfo.user_id, //审核人
approveResult: this.errorForm.approveResult, //审核结果
approveRemark: this.errorForm.approveRemark //备注
}
customerRefuse(query).then(res => {
if (res.data.code == 200) {
this.$message.success('提交成功')
this.dialogerror = false
this.onLoad()
}
})
}
} else if (this.viewType == 'evaluate') {
this.handleConfirm()
}
else if (this.viewType == 'repairupload') {
let query = []
this.errorForm.tableData.map(item => {
query.push({
id: item.id, // 明细id
status: item.status, //状态,0:正常,1:异常
taskId: this.errorForm.id, // 任务ID
floorName: item.floorName, //楼层
deptId: item.deptId, //房间
majorName: item.majorName, //专业名称
checkContent: item.checkContent, //巡检内容
craft: item.craft, //工艺要求
period: item.period, //巡检周期 1:月, 2:季, 3:半年
picUrl: item.picUrl, //现场图片地址
signUrl: item.signUrl, //签字图片地址
remark: item.remark, //备注
price: item.price, //价格
startTime: item.startTime, //计划开始时间
isNeed: item.isNeed,//是否需要物料 0,1
detailGoodsList: item.detailGoodsList,//物料列表
repairOption: item.repairOption,
completeImgList: JSON.stringify(item.completeImgList)
})
})
// 维修完成
let dataTable = {
id: this.errorForm.id,
details: query,
}
servicemanSubmit(dataTable).then(res => {
if (res.data.code == 200) {
this.$message.success('维修完成')
this.dialogerror = false
this.onLoad()
}
})
}
}
})
},
onLoad(page, params = {}) {
getRepairPage({ current: this.page.currentPage, size: this.page.pageSize, deptName: params.deptName, taskStatus: 4 }).then(res => {
this.data = res.data.data.records
this.page.total = res.data.data.total
})
},
// 开具发票
clickInvoice() {
if (this.selectedList.length == 0) {
this.$message.warning('请至少选择一条数据')
} else {
let tmp = this.selectedList.find(item => item.repairStatus != 7)
if (tmp) {
this.$message.warning('请选择状态为待开发票的数据')
} else {
this.$confirm('请确认是否为已选择数据开具发票?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let queryData = []
this.selectedList.forEach(item => {
queryData.push({
id: item.id
})
})
repairConfirmConfirm(queryData).then(res => {
this.$message.success('发票开具成功')
this.onLoad()
})
}).catch(() => {
})
}
}
},
// 维修人员上传维修完成图片
handleRepairFinishUpload(row) {
this.viewType = 'repairupload'
getRepairDetail({ id: row.id }).then(res => {
if (res.data.code == 200) {
this.errorForm = res.data.data
let data = this.checkDeepData(res.data.data.details)
if (this.errorForm.repairStatus > 1) {
data.forEach(item => {
item.completeImgList = item.completeImgList == '' ? [] : JSON.parse(item.completeImgList)
if (item.detailGoodsList.length > 0) {
item.isNeed = '1'
} else {
item.isNeed = '0'
}
})
}
this.errorForm.tableData = data
this.getExpandedKeys(data)
this.dialogerror = true
}
})
},
// 附件上传成功
handleSuccess(index) {
return (response, file, fileList) => {
this.errorForm.tableData[index].completeImgList = []
fileList.map(item => {
this.errorForm.tableData[index].completeImgList.push({ name: item.name, url: item.response ? item.response.data.link : item.url })
})
}
},
// 附件删除
handleRemove(index) {
return (file, fileList) => {
this.errorForm.tableData[index].completeImgList = []
fileList.map(item => {
this.errorForm.tableData[index].completeImgList.push({ name: item.name, url: item.response ? item.response.data.link : item.url })
})
}
},
beforeAvatarUpload(index) {
return (file) => {
if (this.errorForm.tableData[index].completeImgList.length < 3) {
const isLt3M = file.size
const _this = this
return new Promise((resolve, reject) => {
const image = new Image()
let resultBlob = ''
image.src = URL.createObjectURL(file)
image.onload = () => {
// 调用方法获取blob格式,方法写在下边
resultBlob = _this.compressUpload(image, file)
const fs = new File([resultBlob], file.name, {
type: file.type,
width: 200,
height: 200
})
if (fs.size > 1024 * 1024 * 3) {
this.$message.warning('压缩后图片仍大于3Mb,请您手动压缩')
reject()
}
resolve(fs)
}
image.onerror = () => {
reject()
}
})
} else {
this.$message.error('故障视频与故障图片最多可上传3个')
return false
}
}
},
/* 图片压缩方法-canvas压缩 */
compressUpload(image, file) {
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
const width = image.width * 0.1 // 图片宽度 * 压缩比例
const height = image.height * 0.1 // 图片高度 * 压缩比例
canvas.width = width // 画布宽度
canvas.height = height // 画布宽度
ctx.fillRect(0, 0, canvas.width, canvas.height)
ctx.drawImage(image, 0, 0, width, height)
const dataUrl = canvas.toDataURL(file.type) //图片转路径
const blobData = this.dataURItoBlob(dataUrl, file.type) //图片转二进制
return blobData
},
/* base64转Blob对象 */
dataURItoBlob(data) {
let byteString
if (data.split(',')[0].indexOf('base64') >= 0) {
byteString = atob(data.split(',')[1])
} else {
byteString = unescape(data.split(',')[1])
}
const mimeString = data.split(',')[0].split(':')[1].split(';')[0]
const ia = new Uint8Array(byteString.length)
for (let i = 0; i < byteString.length; i += 1) {
ia[i] = byteString.charCodeAt(i)
}
return new Blob([ia], { type: mimeString })
},
getExpandedKeys(table) {
this.expandedKeys = []
table.forEach(item => {
if (item.detailGoodsList.length > 0) {
this.expandedKeys.push(item.id)
}
})
}
}
}
</script>
<style>
.highlight-row {
background-color: red !important;
/* 例如黄色背景 */
}
</style>