devicesmgt/sgzb-ui/src/views/scrapManage/forecastWaste/auditing.vue

350 lines
13 KiB
Vue

<template>
<div class="app-container">
<!-- 预报废审核 -->
<TableModel
:tableProps="config.tableProps"
:sendApi="getForecastWasteListApi"
:formLabel="config.formLabel"
:exportShow="true"
:pageShow="true"
:isSelShow="true"
ref="tableRef"
@getTableSelectionChange="getTableSelChangeOuter"
>
<!-- 报废来源 -->
<template slot-scope="{ data }" slot="source">
<template v-if="data.scrapSource === 1">退料</template>
<template v-if="data.scrapSource === 2">维修审核</template>
<template v-if="data.scrapSource === 3">盘点</template>
</template>
<!-- 单号 1、退料单号 2、维修单号 3、盘点单号 -->
<template slot-scope="{ data }" slot="code">
<template v-if="data.scrapSource === 1">{{
data.repairCode
}}</template>
<template v-if="data.scrapSource === 2">{{
data.scrapNum
}}</template>
</template>
<!--审核状态 -->
<template slot-scope="{ data }" slot="type">
<el-tag v-if="data.taskStatus === 120" size="mini"
>待审核</el-tag
>
<el-tag
type="warning"
v-if="data.taskStatus === 121"
size="mini"
>审核中</el-tag
>
<el-tag type="danger" v-if="data.taskStatus === 123" size="mini"
>已驳回</el-tag
>
<el-tag
type="success"
v-if="data.taskStatus === 122"
size="mini"
>已通过</el-tag
>
</template>
<template slot-scope="{ data }">
<el-button type="text" size="mini" @click="handlePreview(data)"
>查看</el-button
>
<el-button
v-if="data.taskStatus === 121 || data.taskStatus === 120"
type="text"
size="mini"
@click="handleAuditing(data)"
>审核</el-button
>
</template>
</TableModel>
<DialogModel
:title="title"
:innerTitle="innerTitle"
:dialogVisible="dialogVisible"
:innerDialogVisible="innerDialogVisible"
:width="dialogWidth"
:innerWidth="`50%`"
@closeDialog="closeDialog"
@closeDialogInner="closeDialogInner"
>
<template slot="preview">
<TableModel
:tableProps="config.previewTableProps"
:sendApi="getDialogListApi"
:sendParams="sendParams"
:handleColShow="false"
:formLabel="config.previewFormLabel"
:isSelShow="isSelShow"
ref="auditingTableRef"
@getTableSelectionChange="getTableSelChangeInner"
>
<!--审核状态 -->
<template slot-scope="{ data }" slot="t_type">
<el-tag v-if="data.status == 0" size="mini"
>待审核</el-tag
>
<el-tag
type="success"
v-if="data.status == 1"
size="mini"
>通过</el-tag
>
<el-tag
type="warning"
v-if="data.status == 2"
size="mini"
>驳回</el-tag
> </template
>s
</TableModel>
</template>
<template slot="handleBtn" v-if="handleBtn">
<el-row class="handle-btn">
<el-button size="mini" type="primary" @click="auditingPass"
>通 过</el-button
>
<el-button
size="mini"
type="warning"
@click="auditingReject"
>驳 回</el-button
>
</el-row>
</template>
<template slot="innerContent">
<el-row>
<el-col :span="4">请输入驳回原因</el-col>
<el-col :span="20">
<el-input
v-model="rejectReason"
type="textarea"
:rows="6"
ref="rejectReasonRef"
/>
</el-col>
</el-row>
</template>
<template slot="innerHandleBtn">
<el-row class="handle-btn">
<el-button size="mini" plain @click="handleCancelInner"
> </el-button
>
<el-button
size="mini"
type="warning"
@click="handleSubmitInner"
> </el-button
>
</el-row>
</template>
</DialogModel>
</div>
</template>
<script>
import TableModel from '../component/tableModel.vue'
import DialogModel from '../component/dialogModel.vue'
import { getSelList, config } from './index.js'
import {
getForecastWasteListApi,
getDialogListApi,
auditingScrapApi,
} from '@/api/scrap/forecastWaste.js'
export default {
name: 'scrapAuditing',
components: {
TableModel,
DialogModel,
},
data() {
return {
config,
/* 主页列表接口 */
getForecastWasteListApi,
/* 弹框内列表接口 */
getDialogListApi,
/* 弹框标题 */
title: '查看',
/* 内层弹框标题 */
innerTitle: '',
/* 弹框显示隐藏 */
dialogVisible: false,
/* 内层弹框显示隐藏 */
innerDialogVisible: false,
/* 弹框宽度 */
dialogWidth: '70%',
/* 弹框内查询条件 */
typeName: '',
/* 审核通过与驳回按钮的控制显示 */
handleBtn: false,
/* 驳回原因 */
rejectReason: '',
/* 表格是否需要复选框 */
isSelShow: true,
/* 选中的审核数据 */
selAuditingList: [],
/* 请求参数 */
sendParams: {},
/* 当前登录的用户id */
userId: sessionStorage.getItem('userId'),
getSelList,
/* 审核参数 */
auditingParams: {
taskId: '',
scrapDetailList: [],
},
}
},
created() {
/* 获取表单的下拉数据 */
this.getSelList()
},
methods: {
/* 查看 */
async handlePreview(val) {
this.sendParams.taskId = this.auditingParams.taskId = val.taskId
this.title = '查看'
this.isSelShow = false
this.dialogVisible = true
this.$nextTick(() => {
this.$refs.auditingTableRef.getList()
})
},
/* 审核 */
handleAuditing(val) {
this.sendParams.taskId = this.auditingParams.taskId = val.taskId
this.title = '审核'
this.isSelShow = true
this.handleBtn = true
this.dialogVisible = true
this.$nextTick(() => {
this.$refs.auditingTableRef.getList()
})
},
/* 自定义事件关闭弹框 (外层) */
closeDialog(val) {
this.dialogVisible = val
},
/* 自定义事件关闭弹框 (内层) */
closeDialogInner(val) {
this.innerDialogVisible = val
},
/* 审核通过 */
async auditingPass() {
if (this.selAuditingList.length < 1) {
this.$message.error('请勾选审核设备')
return
}
this.selAuditingList.map((e) => {
/* 获取当前需要审核的设备数据 */
let deviceInfo = {
id: e.id, // 设备ID
auditBy: this.userId, // 审核人 ID
status: '1', // 1 通过 2 驳回
}
this.auditingParams.scrapDetailList.push(deviceInfo)
})
const res = await auditingScrapApi(this.auditingParams)
console.log(res, '审核结果')
if (res.code == 200) {
this.$message.success('审核通过!')
this.dialogVisible = false
}
},
/* 审核驳回 */
async auditingReject() {
if (this.selAuditingList.length < 1) {
this.$message.error('请勾选审核设备')
return
}
this.innerTitle = '驳回原因'
this.innerDialogVisible = true
},
/* 驳回原因弹框内取消按钮 */
handleCancelInner() {
/* 关闭内弹框 */
this.innerDialogVisible = false
},
/* 驳回弹框内保存按钮 */
async handleSubmitInner() {
if (!this.rejectReason) {
this.$message.error('驳回原因不能为空!')
this.$refs.rejectReasonRef.focus()
return
} else {
this.selAuditingList.map((e) => {
/* 获取当前需要审核的设备数据 */
let deviceInfo = {
id: e.id, // 设备ID
auditBy: this.userId, // 审核人 ID
status: '2', // 1 通过 2 驳回
auditRemark: this.rejectReason, // 驳回原因
}
this.auditingParams.scrapDetailList.push(deviceInfo)
})
const res = await auditingScrapApi(this.auditingParams)
if (res.code == 200) {
this.$message.success('已驳回!')
this.innerDialogVisible = false
}
}
},
/* 主页列表复选框勾选事件 */
getTableSelChangeOuter(list) {
console.log(list, '主页列表勾选数据')
},
/* 审核时列表复选框勾选事件 */
getTableSelChangeInner(list) {
console.log(list, '审核列表勾选数据')
this.selAuditingList = list
},
},
watch: {
/* 监听驳回原因弹框关闭 清空驳回原因内容 */
innerDialogVisible: {
handler(newVal) {
if (!newVal) {
this.rejectReason = ''
this.$refs.auditingTableRef.clearSelType()
this.$nextTick(() => {
this.$refs.auditingTableRef.getList()
})
}
},
},
/* 监听审核弹框关闭 清空列表的复选框选中状态 */
dialogVisible: {
handler(newVal) {
if (!newVal) {
this.$refs.auditingTableRef.clearSelType()
this.handleBtn = false
this.$nextTick(() => {
this.$refs.tableRef.getList()
})
}
},
deep: true,
},
},
}
</script>
<style scoped>
.handle-btn {
margin-top: 15px;
padding-top: 8px;
text-align: right;
border-top: 1px solid #393737;
}
</style>