dbd-meeting-html/src/views/admin/RepairList.vue

522 lines
16 KiB
Vue
Raw Normal View History

2024-01-23 17:05:40 +08:00
<template>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-row :gutter="48">
2024-08-29 13:36:34 +08:00
<a-col :md="5" :sm="15">
<a-form-item label="报修单号">
<a-input placeholder="请输入关键词" v-model="queryParam.sn" />
</a-form-item>
</a-col>
2024-01-23 17:05:40 +08:00
<a-col :md="5" :sm="15">
<a-form-item label="关键词">
<a-input placeholder="请输入关键词" v-model="queryParam.explain" />
2024-01-23 17:05:40 +08:00
</a-form-item>
</a-col>
2024-08-20 16:35:26 +08:00
<a-col :md="5" :sm="15">
2024-08-29 13:36:34 +08:00
<a-form-item label="报修来源">
<a-select v-model="queryParam.remark"
v-decorator="['remark']">
<a-select-option v-for="item in remarkOption" :key="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :md="5" :sm="15">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="故障类型">
<a-select :label-in-value="true"
2024-08-29 13:36:34 +08:00
v-decorator="['typeId', {rules: [{ required: true, message: '请选择故障类型' }]}]"
@change="selectDevice">
<a-select-option v-for="item in typeList" :key="item.id" :value="item.id">{{ item.name }}
</a-select-option>
</a-select>
2024-08-20 16:35:26 +08:00
</a-form-item>
</a-col>
<a-col :md="5" :sm="15">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="报修设备">
<a-select :label-in-value="true"
v-decorator="['deviceId', {rules: [{ required: true, message: '请选择所属设备' }]}]"
@change="getDeviceName">
<a-select-option v-for="item in deviceList" :key="item.id" :value="item.id">{{ item.name }}
</a-select-option>
</a-select>
2024-08-20 16:35:26 +08:00
</a-form-item>
</a-col>
<a-col :md="5" :sm="15">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="请选择状态">
2024-08-30 00:42:34 +08:00
<a-select v-model="queryParam.type"
v-decorator="['status']">
<a-select-option v-for="item in options" :key="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :md="5" :sm="15">
<a-form-item label="故障等级">
<a-select v-model="queryParam.repairLevel"
v-decorator="['repairLevel']">
<a-select-option v-for="item in repairLevelOptions" :key="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
2024-08-30 00:42:34 +08:00
<a-col :md="5" :sm="15">
<a-form-item label="评价">
<a-select v-model="queryParam.evalService"
v-decorator="['evalService']">
<a-select-option v-for="item in evalOptions" :key="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :md="5" :sm="15">
<a-form-item label="时间范围">
2024-08-29 00:04:46 +08:00
<a-range-picker v-model="dateRange" @change="onChange" />
2024-08-20 16:35:26 +08:00
</a-form-item>
</a-col>
2024-01-23 17:05:40 +08:00
<a-col :md="8" :sm="24">
<span class="table-page-search-submitButtons">
2024-08-29 13:36:34 +08:00
<a-button type="primary" @click="selectRepairList()">查询</a-button>
2024-08-30 00:42:34 +08:00
<a-button style="margin-left: 8px" @click="reset()">重置</a-button>
2024-08-29 00:04:46 +08:00
<a-button style="margin-left: 8px" type="primary" @click="exportRepair()">导出工单模版</a-button>
<a-button style="margin-left: 8px" type="primary" @click="importDataVisible()">导入</a-button>
2024-08-29 00:04:46 +08:00
<a-button style="margin-left: 8px" type="primary" @click="exportRepairList()">导出工单数据</a-button>
2024-01-23 17:05:40 +08:00
</span>
</a-col>
</a-row>
</a-form>
</div>
2024-08-05 15:32:46 +08:00
<div class="table-operator">
<a-button v-if="addEnable" type="primary" icon="plus" @click="$refs.modal.add()">新建</a-button>
</div>
<a-table
2024-01-23 17:05:40 +08:00
size="default"
ref="table"
rowKey="id"
:columns="columns"
:data-source="loadData"
2024-01-23 17:05:40 +08:00
>
<span slot="status" slot-scope="text">
{{ text | statusFilter }}
</span>
<span slot="remark" slot-scope="text">
<a-tag v-if="text == '5110'" color="blue">
{{ text }}
</a-tag>
<a-tag v-else color="cyan">
普通报修
</a-tag>
</span>
2024-01-23 17:05:40 +08:00
<span slot="action" slot-scope="text, record">
<a v-if="editEnabel" @click="handleView(record.id)">详情</a>
2024-08-29 13:36:34 +08:00
<a-divider type="vertical" />
<a v-if="editEnabel" @click="handleEdit(record)">编辑</a>
<a-divider type="vertical" />
<a type="danger" @click="delByIds(record.id)">删除</a>
2024-01-23 17:05:40 +08:00
</span>
</a-table>
<repair-modal ref="modal" @ok="handleOk" />
2024-08-29 00:04:46 +08:00
<a-modal v-model="visible" title="导入工单">
<div style="display: flex">
<a-upload
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
@change="customChange"
:customRequest="customRequest">
2024-08-29 00:04:46 +08:00
<a-button type="primary">导入工单</a-button>
</a-upload>
</div>
</a-modal>
2024-01-23 17:05:40 +08:00
</a-card>
2024-01-23 17:05:40 +08:00
</template>
<script>
import { STable } from '@/components'
2024-08-29 13:36:34 +08:00
import { getRepairList, complete, delRepair } from '@/api/admin/repair'
import { oneWorkerList, oneFloorList, oneFloorCreateList } from '@/api/admin/repair/repairStats'
2024-01-23 17:05:40 +08:00
import RepairModal from './modules/RepairModal.vue'
import { checkPermission } from '@/utils/permissions'
import { getRepairDeviceList } from '@/api/admin/repair/repairDevice'
import { getRepairTypeList } from '@/api/admin/repair/repairDeviceType'
import { exportRepair, exportTemplate, importData } from '@/api/admin/repair/repairIo'
import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'
2024-08-29 13:36:34 +08:00
import { message } from 'ant-design-vue'
2024-01-23 17:05:40 +08:00
export default {
name: 'TableList',
components: {
STable,
RepairModal
},
data () {
return {
2024-08-29 00:04:46 +08:00
dateRange: [],
2024-01-23 17:05:40 +08:00
labelCol: {
xs: { span: 24 },
sm: { span: 5 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
},
form: this.$form.createForm(this),
mdl: {},
visible: false,
headers: {
Authorization: 'Bearer ' + storage.get(ACCESS_TOKEN)
},
2024-01-23 17:05:40 +08:00
// 高级搜索 展开/关闭
advanced: false,
// 查询参数
queryParam: {},
loadData: [],
typeList: [],
deviceList: [],
repairLevelOptions: [{
value: '一级',
label: '一级'
}, {
value: '二级',
label: '二级'
}, {
value: '三级',
label: '三级'
}, {
value: '四级',
label: '四级'
}, {
value: '五级',
label: '五级'
}
],
2024-08-30 00:42:34 +08:00
evalOptions: [{
value: '1',
label: '好评'
}, {
value: '2',
label: '中评'
}, {
value: '3',
label: '差评'
}
],
2024-08-29 13:36:34 +08:00
remarkOption: [{
2024-08-30 00:42:34 +08:00
value: 'no',
2024-08-29 13:36:34 +08:00
label: '普通报修'
}, {
2024-08-30 00:42:34 +08:00
value: 'yes',
2024-08-29 13:36:34 +08:00
label: '5110'
}
],
options: [{
2024-08-30 00:42:34 +08:00
value: 'wait',
label: '待派单'
}, {
2024-08-30 00:42:34 +08:00
value: 'anew',
label: '重新派单'
}, {
2024-08-30 00:42:34 +08:00
value: 'already',
label: '已派单'
}, {
2024-08-30 00:42:34 +08:00
value: 'process',
label: '处理中'
}, {
2024-08-30 00:42:34 +08:00
value: 'evaling',
label: '已完成,待评价'
}, {
2024-08-30 00:42:34 +08:00
value: 'invalid',
label: '无效申请'
}, {
2024-08-30 00:42:34 +08:00
value: 'evaled',
label: '已评价'
}
],
2024-01-23 17:05:40 +08:00
// 表头
columns: [
{
title: '维修单号',
dataIndex: 'sn'
},
{
2024-08-07 09:56:31 +08:00
title: '所属分类',
dataIndex: 'typeName'
2024-01-23 17:05:40 +08:00
},
{
2024-08-05 15:32:46 +08:00
title: '设备名称',
dataIndex: 'deviceName'
2024-01-23 17:05:40 +08:00
},
{
title: '报修来源',
dataIndex: 'remark',
scopedSlots: { customRender: 'remark' }
},
2024-01-23 17:05:40 +08:00
{
2024-08-05 15:32:46 +08:00
title: '工单状态',
dataIndex: 'status',
scopedSlots: { customRender: 'status' }
},
{
title: '故障等级',
2024-08-07 09:56:31 +08:00
dataIndex: 'repairLevel'
2024-01-23 17:05:40 +08:00
},
2024-08-05 15:32:46 +08:00
{
title: '提交人',
dataIndex: 'name'
2024-08-05 15:32:46 +08:00
},
2024-01-23 17:05:40 +08:00
{
title: '报修时间',
dataIndex: 'createTime',
2024-01-23 17:05:40 +08:00
sorter: true
},
{
title: '操作',
width: '200px',
dataIndex: 'action',
scopedSlots: { customRender: 'action' }
}
],
// 加载数据方法 必须为 Promise 对象
// loadData: parameter => {
// return getRepairList(Object.assign(parameter, this.queryParam))
// },
2024-01-23 17:05:40 +08:00
addEnable: checkPermission('admin:repair:add'),
editEnabel: checkPermission('admin:repair:edit'),
removeEnable: checkPermission('admin:repair:list')
}
},
filters: {
// 状态:1 待派单,3 重新派单,5 已派单,7 处理中, 9已完成 待评价, 11 已关闭 13 已评价
2024-01-23 17:05:40 +08:00
statusFilter (status) {
const statusMap = {
'1': '待分配',
'3': '重新派单',
'5': '已派单',
'7': '处理中',
'9': '已完成,待评价',
'11': '已关闭',
'13': '已评价'
2024-01-23 17:05:40 +08:00
}
return statusMap[status]
}
},
created () {
2024-08-30 00:42:34 +08:00
console.log('this.$route.query', this.$route.query.evalService)
this.queryParam.evalService = this.$route.query.evalService
this.queryParam.timeout = this.$route.query.timeout
2024-08-29 13:36:34 +08:00
this.selectRepairList()
this.selectType()
2024-01-23 17:05:40 +08:00
},
methods: {
customChange () {
2024-08-30 00:42:34 +08:00
},
reset () {
this.queryParam = {}
this.selectRepairList()
},
customRequest (file) {
// file 是上传的文件 其内容会在放在下面截图中
// 后端需要接受的参数是 formData数据
// uploadFile 我自己的接口
const formData = new FormData()
formData.append('file', file.file)
console.log(file)
importData(formData).then(res => {
if (res.code == 0) {
// 调用组件内方法, 设置为成功状态
file.onSuccess(res, file.file)
file.status = 'done'
this.visible = false
this.$message.success('导入成功')
} else {
this.$message.error(res.msg)
file.onError()
file.status = 'error'
}
})
},
// 导入工单
importDataVisible () {
this.visible = true
},
// 导出工单模板
exportRepair () {
exportTemplate().then(res => {
2024-08-29 00:04:46 +08:00
this.exportExcel('工单模版', res)
})
},
// 导出工单
exportRepairList () {
2024-08-29 00:04:46 +08:00
if (this.dateRange.length < 2) {
2024-08-29 13:36:34 +08:00
message.error('请先设置时间范围,系统将根据时间范围导出工单数据')
return
2024-08-29 00:04:46 +08:00
}
2024-08-29 13:36:34 +08:00
const startDate = this.dateRange[0].format('YYYY-MM-DD')
const endDate = this.dateRange[1].format('YYYY-MM-DD')
2024-08-29 00:04:46 +08:00
exportRepair({ startDate: startDate, endDate: endDate }).then(res => {
this.exportExcel('工单数据', res)
})
},
exportExcel (filename, res) {
const link = document.createElement('a')
let blob = new Blob([res], { type: 'application/vnd.ms-excel;charset=UTF-8' })
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
let num = ''
for (let i = 0; i < 10; i++) {
num += Math.ceil(Math.random() * 10)
}
link.setAttribute('download', filename + '.xls')
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
// 切换时间
onChange (value, dateString) {
this.queryParam.startTime = dateString[0]
this.queryParam.endTime = dateString[1]
},
// 查询分类
selectType () {
getRepairTypeList().then(res => {
this.typeList = res.rows
})
},
// 查询设备
selectDevice (item) {
getRepairDeviceList({ 'typeId': item.key }).then(res => {
this.deviceList = res.rows
})
this.queryParam.typeId = item.key
console.log(this.queryParam.typeId)
},
getDeviceName (item) {
this.deviceName = item.label
this.queryParam.deviceId = item.key
},
// 查询工单列表
2024-08-29 13:36:34 +08:00
selectRepairList () {
2024-08-30 00:42:34 +08:00
let type = 'all'
if (this.queryParam.type != null) {
type = this.queryParam.type
}
if (this.$route.query.status != null) {
type = this.$route.query.status
}
2024-08-17 16:31:37 +08:00
if (this.$route.query.repairUserId != null) {
oneWorkerList({ workerId: this.$route.query.repairUserId }).then(res => {
2024-08-17 16:31:37 +08:00
this.loadData = res.rows
})
} else if (this.$route.query.floorId != null) {
2024-08-29 12:36:50 +08:00
oneFloorList({ floorerId: this.$route.query.floorId }).then(res => {
2024-08-17 16:31:37 +08:00
this.loadData = res.rows
})
2024-08-29 00:04:46 +08:00
} else if (this.$route.query.floorCreateId != null) {
2024-08-29 12:36:50 +08:00
oneFloorCreateList({ floorerId: this.$route.query.floorCreateId }).then(res => {
2024-08-29 00:04:46 +08:00
this.loadData = res.rows
})
} else {
2024-08-30 00:42:34 +08:00
2024-08-17 16:31:37 +08:00
let datas = {
2024-08-26 10:41:44 +08:00
'role': 7,
2024-08-30 00:42:34 +08:00
'type': type,
'repair': {
'explain': this.queryParam.explain,
'typeId': this.queryParam.typeId,
'deviceId': this.queryParam.deviceId,
'status': this.queryParam.status,
'repairLevel': this.queryParam.repairLevel,
'beginTime': this.queryParam.startTime,
2024-08-30 00:42:34 +08:00
'endTime': this.queryParam.endTime,
'evalService': this.queryParam.evalService,
'timeout': this.queryParam.timeout,
'remark': this.queryParam.remark
}
}
2024-08-17 16:31:37 +08:00
getRepairList(datas).then(res => {
this.loadData = res.rows
})
}
2024-08-29 13:36:34 +08:00
},
delByIds (ids) {
const _this = this
this.$confirm({
title: '警告',
content: '确认要删除工单吗?',
okText: '是',
okType: 'warning',
cancelText: '否',
onOk () {
delRepair({ id: ids }).then(res => {
if (res.code === 0) {
console.log(res.code)
message.success('删除成功')
_this.selectRepairList()
} else {
message.error(res.msg)
}
})
},
onCancel () {
}
})
},
2024-01-23 17:05:40 +08:00
handleAdd () {
this.$refs.modal.add()
},
handleView (repairId) {
this.$router.push({ name: 'repairView', query: { repairId: repairId } })
},
handleEdit (record) {
this.$refs.modal.edit(record)
},
handleOk () {
this.$refs.table.refresh(true)
console.log('handleSaveOk')
},
handleComplete (id) {
const _this = this
this.$confirm({
title: '警告',
content: '确认要完成工单吗?',
okText: '是',
okType: 'warning',
cancelText: '否',
onOk () {
complete(id).then(res => {
if (res.code === 0) {
_this.$message.success('操作成功')
_this.$refs.table.refresh(true)
} else {
_this.$message.error(res.msg)
}
}).catch(() => {
this.$message.error('系统错误,请稍后再试')
})
},
onCancel () {
}
2024-01-23 17:05:40 +08:00
})
}
},
watch: {}
2024-01-23 17:05:40 +08:00
}
</script>