| | |
| | | <el-card shadow="hover"> |
| | | <div class="system-user-search mb15"> |
| | | <div class="basic-line"> |
| | | <div style="display: inline-block">整改编号:</div> |
| | | |
| | | <div style="display: inline-block"> |
| | | <el-autocomplete :fetch-suggestions="querySearch" v-model="rectifyData.params.serialCode" v-on:input="checkDate($event)" placeholder="整改编号(前八位日期)"> </el-autocomplete> |
| | | <i class="el-icon-date"></i> |
| | | </div> |
| | | <!-- <div style="display: inline-block">--> |
| | | <!-- <el-button>--> |
| | | <!-- <el-date-picker value-format="YYYY-MM-DD" :disabled-date="disabledDate" v-model="dateTime" @change="getSerialCodeList" placeholder="选择日期"> </el-date-picker>--> |
| | | <!-- </el-button>--> |
| | | <!-- </div>--> |
| | | </div> |
| | | <div class="basic-line"> |
| | | <span>整改类型:</span> |
| | | <el-select class="input-box" v-model="rectifyData.params.rectifyType" placeholder="整改类型" filterable> |
| | | <el-option v-for="item in rectifyTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option> |
| | |
| | | <el-option v-for="item in dangerStatusList" :key="item.id" :label="item.name" :value="item.id"></el-option> |
| | | </el-select> |
| | | </div> |
| | | <div class="basic-line"> |
| | | <span>创建时间范围:</span> |
| | | <el-date-picker v-model="dateTimeRange" @change="giveTime" value-format="YYYY-MM-DD HH:mm:ss" type="datetimerange" range-separator="To" start-placeholder="开始时间" end-placeholder="结束时间" /> |
| | | </div> |
| | | <i class="el-icon-date"></i> |
| | | <el-button size="default" type="primary" class="ml10" v-throttle @click="handleSearch"> |
| | | <el-icon> |
| | | <ele-Search /> |
| | |
| | | </div> |
| | | <el-table :data="rectifyData.data" style="width: 100%" fit highlight-current-row> |
| | | <el-table-column type="index" label="序号" width="60" /> |
| | | <el-table-column prop="reportTime" label="上报时间" show-overflow-tooltip width="170px"></el-table-column> |
| | | <el-table-column prop="dangerCode" label="隐患名称" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="rectifyDesc" label="整改内容说明" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="rectifyTime" label="整改期限" min-width="130px" show-overflow-tooltip> |
| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue'; |
| | | import { toRefs, reactive, onMounted, ref, defineComponent, computed } from 'vue'; |
| | | import { ElMessageBox, ElMessage } from 'element-plus'; |
| | | import rectifyDialog from './components/rectifyDialog.vue'; |
| | | import { Edit, Delete, Check, View } from '@element-plus/icons-vue'; |
| | |
| | | interface TableDataState { |
| | | rectifyData: { |
| | | data: Array<TableData>; |
| | | |
| | | total: number; |
| | | disabled: boolean; |
| | | loading: boolean; |
| | | params: { |
| | | pageIndex: number; |
| | |
| | | rectifyType: number | null; |
| | | rectifyDepId: number | null; |
| | | dangerStatus: number | null; |
| | | serialCode: string; |
| | | startTime: string; |
| | | endTime: string; |
| | | }; |
| | | }; |
| | | rectifyTypeList: Array<enumType>; |
| | | dangerStatusList: Array<enumType>; |
| | | departmentList: []; |
| | | disabledDate: any; |
| | | serialCodeList: Array<type>; |
| | | dateTime: string; |
| | | dateTimeRange: Array<string>; |
| | | } |
| | | interface enumType { |
| | | id: number; |
| | | name: string; |
| | | } |
| | | interface type { |
| | | id: number; |
| | | value: number; |
| | | } |
| | | |
| | | export default defineComponent({ |
| | |
| | | rectifyData: { |
| | | data: [], |
| | | total: 0, |
| | | disabled: true, |
| | | loading: false, |
| | | params: { |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | rectifyType: null, |
| | | rectifyDepId: null, |
| | | dangerStatus: null |
| | | dangerStatus: null, |
| | | serialCode: '', |
| | | startTime: '', |
| | | endTime: '' |
| | | } |
| | | }, |
| | | dateTime: '', |
| | | dateTimeRange: [], |
| | | disabledDate: (time: any) => { |
| | | return time.getTime() > new Date().getTime(); |
| | | }, |
| | | departmentList: [], |
| | | serialCodeList: [], |
| | | rectifyTypeList: [ |
| | | { id: 1, name: '即查即改' }, |
| | | { id: 2, name: '限期整改' } |
| | |
| | | ] |
| | | }); |
| | | |
| | | const giveTime = () => { |
| | | if (state.dateTimeRange && state.dateTimeRange !== null) { |
| | | state.rectifyData.params.startTime = state.dateTimeRange[0]; |
| | | state.rectifyData.params.endTime = state.dateTimeRange[1]; |
| | | } else { |
| | | state.rectifyData.params.startTime = ''; |
| | | state.rectifyData.params.endTime = ''; |
| | | } |
| | | }; |
| | | |
| | | const querySearch = () => { |
| | | return state.serialCodeList.filter((item) => item.value.toString().indexOf(state.rectifyData.params.serialCode) !== -1); |
| | | }; |
| | | const handleChange = (value: string): Boolean => { |
| | | let year = value.substr(0, 4); |
| | | let month = value.substr(4, 2); |
| | | let day = value.substr(6, 2); |
| | | if (Number(year) < 1000 || Number(year) > new Date().getFullYear()) { |
| | | return false; |
| | | } |
| | | if (Number(month) > 12 || month === '00') { |
| | | return false; |
| | | } |
| | | let leapYearTab = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; |
| | | let notLeapYearTab = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; |
| | | if (isLeapYear(year)) { |
| | | const maxDay = leapYearTab[Number(month) - 1]; |
| | | if (Number(day) > maxDay) { |
| | | return false; |
| | | } |
| | | } else { |
| | | const maxDay = notLeapYearTab[Number(month) - 1]; |
| | | if (Number(day) > maxDay) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | }; |
| | | |
| | | const isLeapYear = (value: string) => { |
| | | return Number(value) % 4 === 0; |
| | | }; |
| | | |
| | | const checkDate = async (value: string) => { |
| | | if (value.length >= 8) { |
| | | if (handleChange(value.substr(0, 8))) { |
| | | let res = await hiddenRectifyApi().getCodeByTime(value.substr(0, 4) + '-' + value.substr(4, 2) + '-' + value.substr(6, 2)); |
| | | if (res.data.code === '200' && res.data.data > 0) { |
| | | state.serialCodeList = []; |
| | | let date = parseInt(value.substr(0, 8) + '0000'); |
| | | for (let i = 0; i < res.data.data; i++) { |
| | | state.serialCodeList.push({ value: date + 1 + i, id: i }); |
| | | } |
| | | } else if (res.data.code === '200' && res.data.data === 0) { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '当天无隐患上报' |
| | | }); |
| | | } |
| | | } else { |
| | | state.rectifyData.params.serialCode = ''; |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '前八位请输入正确得日期格式' |
| | | }); |
| | | } |
| | | } else { |
| | | } |
| | | // if (state.dateTime === '' || state.dateTime === null) { |
| | | // state.serialCodeList = []; |
| | | // state.rectifyData.params.serialCode = ''; |
| | | // } else { |
| | | // state.serialCodeList = []; |
| | | // state.rectifyData.params.serialCode = ''; |
| | | // let res = await hiddenRectifyApi().getCodeByTime(state.dateTime); |
| | | // if (res.data.code === '200' && res.data.data > 0) { |
| | | // state.rectifyData.disabled = false; |
| | | // let date = parseInt(state.dateTime.replaceAll('-', '') + '0000'); |
| | | // for (let i = 0; i < res.data.data; i++) { |
| | | // state.serialCodeList.push({ value: date + 1 + i, id: i }); |
| | | // } |
| | | // state.rectifyData.params.serialCode = state.dateTime.replaceAll('-', ''); |
| | | // } else if (res.data.code === '200' && res.data.data === 0) { |
| | | // state.rectifyData.disabled = true; |
| | | // ElMessage({ |
| | | // type: 'warning', |
| | | // message: '当天无隐患上报' |
| | | // }); |
| | | // } |
| | | // } |
| | | }; |
| | | |
| | | // 初始化表格数据 |
| | | const initRectifyTableData = async () => { |
| | | let res = await hiddenRectifyApi().getHiddenRectifyList(state.rectifyData.params); |
| | | if (res.data.code === '200') { |
| | | state.rectifyData.data = res.data.data; |
| | | state.rectifyData.total = res.data.count; |
| | | } else { |
| | | debugger; |
| | | if (state.rectifyData.params.serialCode.toString().length === 0) { |
| | | let res = await hiddenRectifyApi().getHiddenRectifyList(state.rectifyData.params); |
| | | if (res.data.code === '200') { |
| | | state.rectifyData.data = res.data.data; |
| | | state.rectifyData.total = res.data.count; |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } else if (state.rectifyData.params.serialCode.toString().length !== 12) { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | message: '请输入或选择正确的隐患编号' |
| | | }); |
| | | } else { |
| | | state.rectifyData.params.serialCode = state.rectifyData.params.serialCode.toString().substr(0, 8) + '-' + state.rectifyData.params.serialCode.toString().substr(8, 4); |
| | | let res = await hiddenRectifyApi().getHiddenRectifyList(state.rectifyData.params); |
| | | if (res.data.code === '200') { |
| | | state.rectifyData.params.serialCode = state.rectifyData.params.serialCode.replaceAll('-', ''); |
| | | state.rectifyData.data = res.data.data; |
| | | state.rectifyData.total = res.data.count; |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | |
| | |
| | | View, |
| | | Check, |
| | | Delete, |
| | | giveTime, |
| | | querySearch, |
| | | parseNumber, |
| | | handleSearch, |
| | | checkDate, |
| | | onOpenDialogRef, |
| | | onHandleSizeChange, |
| | | onDelHiddenRectify, |
| | |
| | | :deep(.el-input.is-disabled .el-input__wrapper) { |
| | | background-color: var(--el-card-bg-color); |
| | | } |
| | | :deep(.el-input-group__prepend) { |
| | | padding: 0; |
| | | } |
| | | </style> |