<template>
|
<el-dialog :title="title" v-model="isShowDialog" width="80%">
|
<el-row style="margin-bottom: 20px">
|
<div class="basic-line" style="display:flex;white-space:nowrap;line-height: 40px">
|
<span>作业编号:</span>
|
<el-input v-model="searPara.searchParams.workPermitNo" placeholder="作业编号"/>
|
</div>
|
<div class="basic-line">
|
<span>作业类型:</span>
|
<el-select v-model="searPara.searchParams.workType">
|
<el-option
|
v-for="item in workType"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</div>
|
<div style="margin-left: 20px">
|
<el-button type="primary" @click="getData">查询</el-button>
|
<el-button plain @click="clearSearch">重置</el-button>
|
</div>
|
</el-row>
|
<el-table ref="TableRef" :data="otherWorks" style="width: 100%" border @selection-change="handleSelectionChange" :row-key="(row) => { return row.workApplyId }">
|
<el-table-column type="selection" width="55" :reserve-selection="true"/>
|
<!-- <el-table-column type="index" label="序号" width="60" />-->
|
<el-table-column prop="workTypeDesc" label="作业类型" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="workLevelDesc" label="作业等级" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="workPermitNo" label="作业编号" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="workLocation" label="作业地点" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="workContent" label="作业内容" show-overflow-tooltip></el-table-column>
|
<!-- <el-table-column label="操作" width="150">-->
|
<!-- <template #default="scope">-->
|
<!-- <el-button size="small" text type="primary" @click="onOpenDialogRef('新增', '')">新增</el-button>-->
|
<!-- <el-button size="small" text type="primary" @click="onOpenDialogRef('修改', scope.row)">修改</el-button>-->
|
<!-- <el-button size="small" style="color: red" text type="primary" @click="onRowDel(scope.row)">删除</el-button>-->
|
<!-- </template>-->
|
<!-- </el-table-column>-->
|
</el-table>
|
<el-pagination style="margin-top: 20px;display: flex;justify-content: right" v-model:currentPage="searPara.pageIndex" v-model:page-size="searPara.pageSize" :page-sizes="[10]" small="false" background layout="total, sizes, prev, pager, next, jumper" :total="totalSize" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="isShowDialog = !isShowDialog" size="default">取 消</el-button>
|
<el-button type="primary" v-throttle @click="onSubmit" size="default">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</template>
|
|
<script lang="ts">
|
import { reactive, toRefs, onMounted, defineComponent, ref } from 'vue';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
import { userApi } from '/@/api/systemManage/user';
|
import {workApplyApi} from "/@/api/specialWorkSystem/workApply";
|
|
// 定义接口来定义对象的类型
|
interface type {}
|
interface WorkSelectState {
|
title: string
|
isShowDialog: boolean
|
searPara: object
|
totalSize: number
|
otherWorks: []
|
workType: Array<any>
|
selected: Array<any>
|
}
|
interface User {
|
|
}
|
export default defineComponent({
|
name: 'workSelect',
|
setup(props, context) {
|
const userRef = ref()
|
const state = reactive<WorkSelectState>({
|
title: '',
|
isShowDialog: false,
|
searPara: {
|
pageSize: 10,
|
pageIndex: 1,
|
searchParams: {
|
workPermitNo: '',
|
workType: null
|
}
|
},
|
totalSize: 0,
|
otherWorks: [],
|
selected: [],
|
workType: [
|
{
|
label: "动火作业",
|
value: 1
|
},
|
{
|
label: "受限空间作业",
|
value: 2
|
},
|
{
|
label: "吊装作业",
|
value: 3
|
},
|
{
|
label: "动土作业",
|
value: 4
|
},
|
{
|
label: "断路作业",
|
value: 5
|
},
|
{
|
label: "高处作业",
|
value: 6
|
},
|
{
|
label: "临时用电作业",
|
value: 7
|
},
|
{
|
label: "盲板抽堵作业",
|
value: 8
|
}
|
]
|
});
|
const TableRef = ref()
|
const multipleSelection = ref<User[]>([])
|
// 打开弹窗
|
const openDialog = (works: Array<String>) => {
|
state.isShowDialog = true
|
getData().then(()=>refreshTableSelection(works))
|
};
|
|
const refreshTableSelection = (works) => {
|
state.selected = works
|
if (TableRef.value) {
|
for (let i = 0; i < state.otherWorks.length; i++) {
|
if (works.includes(state.otherWorks[i].workApplyId)){
|
TableRef.value.toggleRowSelection(state.otherWorks[i], true)
|
} else{
|
TableRef.value.toggleRowSelection(state.otherWorks[i], false)
|
}
|
}
|
}
|
}
|
|
// 获取相关作业列表
|
const getData = async () => {
|
let res = await workApplyApi().getOtherWork(state.searPara);
|
if (res.data.code === '200') {
|
state.otherWorks = JSON.parse(JSON.stringify(res.data.data))
|
state.totalSize = res.data.total
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
|
const clearSearch = ()=>{
|
state.searPara = {
|
pageSize: 10,
|
pageIndex: 1,
|
searchParams: {
|
workPermitNo: '',
|
workType: null
|
}
|
}
|
getData()
|
}
|
|
const handleSelectionChange = (val: User[]) => {
|
multipleSelection.value = val
|
state.selected = JSON.parse(JSON.stringify(val)).map(i=>i.workApplyId)
|
}
|
|
const onSubmit = ()=>{
|
console.log(state.selected,'sel')
|
context.emit('refreshWorks')
|
state.selected = []
|
clearSearch()
|
state.isShowDialog = false
|
}
|
|
// 分页改变
|
const handleSizeChange = (val: number) => {
|
state.searPara.pageSize = val;
|
getData()
|
};
|
// 分页改变
|
const handleCurrentChange = (val: number) => {
|
state.searPara.pageIndex = val;
|
getData()
|
};
|
|
// 页面加载时
|
onMounted(() => {});
|
return {
|
userRef,
|
TableRef,
|
handleSizeChange,
|
handleCurrentChange,
|
handleSelectionChange,
|
openDialog,
|
getData,
|
clearSearch,
|
onSubmit,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|