马宇豪
2024-11-12 77737f4e73f7267170b9b06fc73d1610c29c0661
src/views/newSpecialWorkSystem/workTicket/sqjl/index.vue
@@ -4,39 +4,74 @@
<!--            <el-tab-pane label="申请中" name="1">-->
                <div style="height: 100%">
                    <el-row class="homeCard">
                     <div class="basic-line" style="display:flex;white-space:nowrap;line-height: 40px">
                        <span>时间筛选:</span>
                        <el-date-picker v-model="timeRange" value-format="YYYY-MM-DD" type="daterange" @change="giveTime()" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
                      </div>
                      <div class="basic-line" style="display:flex;white-space:nowrap;line-height: 40px">
                        <span>负责人:</span>
                        <el-input v-model.trim="searPara.headUserName" placeholder="负责人"/>
                      </div>
                      <div class="basic-line">
                        <span>事业部:</span>
                        <el-select v-model="searPara.secondDepId">
                          <el-option
                              v-for="item in dep4List"
                              :key="item.id"
                              :label="item.name"
                              :value="item.id"
                          />
                        </el-select>
                      </div>
                      <div class="basic-line">
                        <span>作业类型:</span>
                        <el-col :span="10">
                            <div class="grid-content topInfo">
                                <el-select v-model="searchWord">
                                    <el-option
                                            v-for="item in workType"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                    />
                                </el-select>
                                <el-button type="primary" @click="searchRecord">查询</el-button>
                                <el-button plain @click="clearSearch">重置</el-button>
                            </div>
                        </el-col>
                        <el-select v-model="searPara.workType">
                          <el-option
                              v-for="item in workType"
                              :key="item.id"
                              :label="item.name"
                              :value="item.id"
                          />
                        </el-select>
                      </div>
                      <div class="basic-line" style="display:flex;white-space:nowrap;line-height: 40px">
                        <span>作业票编号:</span>
                        <el-input
                            v-model.trim="searPara.workPermitNo"
                            placeholder="请输入作业票编号"
                        />
                      </div>
                      <div style="margin-left: 20px">
                        <el-button type="primary" @click="searchRecord">查询</el-button>
                        <el-button plain @click="clearSearch">重置</el-button>
                      </div>
                    </el-row>
                    <div class="homeCard">
                        <div class="main-card">
                            <el-row class="cardTop">
                                <el-col :span="12" class="mainCardBtn">
                                    <el-button type="primary" :icon="Plus" size="default" @click="toApply()">申请</el-button>
                                    <el-button type="primary" :icon="Plus" size="default" @click="toApply()">新增申报</el-button>
                                    <!--                           <el-button type="danger" :icon="Delete" size="default">删除</el-button>-->
                                    <!--                           <el-button type="success" size="default">设置分类</el-button>-->
                                </el-col>
                                <el-button type="primary" :icon="Refresh" size="default" @click="reLoadData()" />
                            </el-row>
                            <el-table ref="multipleTableRef" :data="applyData" style="width: 100%" height="calc(100% - 100px)" :header-cell-style="{ background: '#fafafa' }">
                              <el-table-column property="workPermitNo" label="作业编号" align="center">
                                <template #default="scope">
                                  {{scope.row.workPermitNo?scope.row.workPermitNo:'—'}}
                                </template>
                              </el-table-column>
                                <el-table-column property="seDepName" label="事业部" align="center"/>
                                <el-table-column property="applyDepName" label="作业所在车间" align="center"/>
                                <el-table-column property="workContent" label="作业内容" align="center"/>
                                <el-table-column property="workTypeDesc" label="作业类型" align="center"/>
                                <el-table-column property="workDepName" label="作业单位" align="center"/>
                                <el-table-column label="作业单位" align="center">
                                  <template #default="scope">
                                    <span v-if="scope.row.workDepList && scope.row.workDepList.length>0">{{scope.row.workDepList.map(i=>i.workDepName).join(',')}}</span>
                                    <span v-else>{{scope.row.workDepName }}</span>
                                  </template>
                                </el-table-column>
                                <el-table-column property="headList" label="负责人及电话" align="center">
                                  <template #default="scope">
                                    {{scope.row.headList.map(i=>{return i.userName + '(' + i.phone+ ')' }).join(',')}}
@@ -69,18 +104,19 @@
                                    {{scope.row.guardianList.length}}
                                  </template>
                                </el-table-column>
                                <el-table-column label="风险研判" align="center">
                                <el-table-column label="作业状态" align="center">
                                    <template #default="scope">
                                        <el-tag>{{ statusList.find(i=>i.value === scope.row.status)?.label }}</el-tag>
                                    </template>
                                </el-table-column>
                                <el-table-column fixed="right" label="操作" align="center" width="300">
                                    <template #default="scope">
                                        <el-button link type="danger" size="small" :icon="Delete" @click="deleteRecordBtn(scope.row)">作废</el-button>
<!--                                        <el-button link type="danger" size="small" :icon="Delete" @click="deleteRecordBtn(scope.row)">作废</el-button>-->
                                        <el-button link type="primary" size="small" :icon="View" @click="viewRecord(scope.row)">查看</el-button>
                                        <el-button link type="success" size="small" :icon="Finished">修改</el-button>
                                        <el-button link type="success" size="small" :icon="Download">正式办票</el-button>
<!--                                        <el-button :disabled="scope.row.status == 7 ? false : true" link type="primary" size="small" :icon="Download" @click="downLoadBtn(scope.row)">导出作业票</el-button>-->
                                        <el-button v-if="(scope.row.working?.workAllStatus == 3 || scope.row.working?.workAllStatus == 4 || scope.row.working?.workAllStatus == 5)&&!scope.row.renewalWorkApplyId" link type="primary" size="small" :icon="Edit" @click="continueRecord(scope.row)">一键续票</el-button>
<!--                                        <el-button link type="success" size="small" :icon="Finished">修改</el-button>-->
<!--                                        <el-button link type="success" size="small" :icon="Download">正式办票</el-button>-->
                                        <el-button link type="primary" size="small" :icon="Download" @click="downLoadRecord(scope.row)">作业票预览</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
@@ -185,15 +221,24 @@
                        </span>
                    </template>
                </el-dialog>
                <el-dialog v-model="downLoadDialog" title="提示" width="30%" center>
                    <span>您确定要导出该条记录吗?</span>
                    <template #footer>
                                <span class="dialog-footer">
                                    <el-button @click="downLoadDialog = false" size="default">取消</el-button>
                                    <el-button type="primary" @click="conFirmDownLoad" size="default">确认</el-button>
                                </span>
                    </template>
                </el-dialog>
                <fire-dialog ref="fireRef" :lists="lists" @refresh="getListByPage"></fire-dialog>
                <plate-dialog ref="plateRef" :lists="lists" @refresh="getListByPage"></plate-dialog>
                <space-dialog ref="spaceRef" :lists="lists" @refresh="getListByPage"></space-dialog>
                <hoist-dialog ref="hoistRef" :lists="lists" @refresh="getListByPage"></hoist-dialog>
                <ground-dialog ref="groundRef" :lists="lists" @refresh="getListByPage"></ground-dialog>
                <broken-dialog ref="brokenRef" :lists="lists" @refresh="getListByPage"></broken-dialog>
                <height-dialog ref="heightRef" :lists="lists" @refresh="getListByPage"></height-dialog>
                <power-dialog ref="powerRef" :lists="lists" @refresh="getListByPage"></power-dialog>
                <open-dialog ref="openRef" :lists="lists" @refresh="getListByPage"></open-dialog>
<!--                <el-dialog v-model="downLoadDialog" title="提示" width="30%" center>-->
<!--                    <span>您确定要导出该条记录吗?</span>-->
<!--                    <template #footer>-->
<!--                                <span class="dialog-footer">-->
<!--                                    <el-button @click="downLoadDialog = false" size="default">取消</el-button>-->
<!--                                    <el-button type="primary" @click="conFirmDownLoad" size="default">确认</el-button>-->
<!--                                </span>-->
<!--                    </template>-->
<!--                </el-dialog>-->
<!--            </el-tab-pane>-->
<!--            <el-tab-pane label="已通过" name="2">-->
<!--                <div style="height: 100%">-->
@@ -258,14 +303,10 @@
    dialogDetails: boolean;
    dialogStatus: boolean;
    deleteDialog: boolean;
    downLoadDialog: boolean;
    pageIndex1: number;
    pageSize1: number;
    chosenIndex: null | number;
    deleteId: null | number;
    downLoadId: null | number;
    downLoadName: string;
    searchWord: string;
    totalSize1: number;
    activeName: string;
    addRecord: {};
@@ -276,6 +317,10 @@
    departmentList: Array<any>;
    departmentRecursionList: Array<DepartmentState>;
    statusList: Array<any>;
    dep4List: Array<type>;
    searPara: {}
    timeRange: Array<string>;
    lists: {}
}
interface type {
    id: number;
@@ -288,13 +333,31 @@
export default defineComponent({
    name: 'applys',
    components: {
      detailLog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/detailLog.vue'))
      detailLog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/detailLog.vue')),
      fireDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/fireDialog.vue')),
      plateDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/plateDialog.vue')),
      spaceDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/spaceDialog.vue')),
      hoistDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/hoistDialog.vue')),
      groundDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/groundDialog.vue')),
      brokenDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/brokenDialog.vue')),
      heightDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/heightDialog.vue')),
      powerDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/powerDialog.vue')),
      openDialog: defineAsyncComponent(() => import('/@/views/newSpecialWorkSystem/workTicket/wdsq/components/openDialog.vue'))
    },
    setup() {
        const userInfo = useUserInfo();
        const { userInfos } = storeToRefs(userInfo);
        const router = useRouter();
        const state = reactive<stateType>({
            lists: {
              workerList: [],
              departList: [],
              departList2: [],
              deviceList: [],
              otherWorks: [],
              spList: [],
              riskList: []
            },
            pageIndex1: 1,
            pageSize1: 10,
            totalSize1: 0,
@@ -303,7 +366,14 @@
            departmentList: [],
            departmentRecursionList: [],
            chosenIndex: null,
            searchWord: '',
            searPara:{
              startTime: '',
              endTime: '',
              workPermitNo: '',
              workType: null,
              headUserName: '',
              secondDepId: null
            },
            applyData: [],
            workTimeList: [],
            multipleSelection: [],
@@ -314,76 +384,162 @@
            dialogDetails: false,
            dialogStatus: false,
            deleteDialog: false,
            downLoadDialog: false,
            addRecord: {},
            details: {},
            statusInfo: {},
            deleteId: null,
            downLoadId: null,
            downLoadName: '',
            deleteArr: [],
            dep4List: [
              {id:49,name:'电石事业部'},
              {id:50,name:'电力事业部'},
              {id:48,name:'有机化工事业部'},
              {id:32,name:'甲醇事业部'},
              {id:10,name:'后勤中心'},
              {id:41,name:'安全环保部'},
              {id:46,name:'供销中心'},
              {id:47,name:'技术中心'}
            ],
            workType: [
                { id: 1, name: '动火作业' },
                { id: 2, name: '受限空间作业' },
                { id: 3, name: '吊装作业' },
                { id: 4, name: '动土作业' },
                { id: 5, name: '断路作业' },
                { id: 6, name: '高处作业' },
                { id: 7, name: '临时用电作业' },
                { id: 8, name: '盲板抽堵作业' }
              { id: 1, name: '动火作业' },
              { id: 2, name: '受限空间作业' },
              { id: 3, name: '吊装作业' },
              { id: 4, name: '动土作业' },
              { id: 5, name: '断路作业' },
              { id: 6, name: '高处作业' },
              { id: 7, name: '临时用电作业' },
              { id: 8, name: '盲板抽堵作业' }
            ],
          statusList: [
            {
              value: -1,
              label: '废止'
            },
            {
              value: 0,
              label: '风险研判中'
              label: '风险研判'
            },
            {
              value: 1,
              label: '票证办理中'
              label: '票证办理'
            },
            {
              value: 2,
              label: '安全措施确认中'
              label: '气体分析'
            },
            {
              value: 3,
              label: '培训交底中'
              label: '安全措施确认,培训交底'
            },
            {
              value: 4,
              label: '气体分析中'
              label: '安全措施确认'
            },
            {
              value: 5,
              label: '作业开始'
              label: '培训交底'
            },
            {
              value: 6,
              label: '作业监护'
              label: '部门审批'
            },
            {
              value: 7,
              label: '作业结束'
              label: '作业票填报结束'
            },
            {
              value: 8,
              label: '作业验收'
              label: '作业气体分析不合格'
            },
            {
              value: 9,
              label: '安全措施确认,培训交底中'
              label: '审批未通过'
            },
            {
              value: 10,
              label: '开始'
            },
            {
              value: 11,
              label: '监护'
            },
            {
              value: 12,
              label: '结束'
            },
            {
              value: 13,
              label: '待验收'
            },
            {
              value: 14,
              label: '验收完成'
            },
            {
              value: 15,
              label: '取消'
            },
            {
              value: 16,
              label: '废止作业票'
            }
          ]
          ],
          timeRange: []
        });
        interface User {
            name: string;
            list: [];
            info: string;
      const fireRef = ref()
      const plateRef = ref()
      const spaceRef = ref()
      const hoistRef = ref()
      const groundRef = ref()
      const brokenRef = ref()
      const heightRef = ref()
      const powerRef = ref()
      const openRef = ref()
      // 页面载入时执行方法
      onMounted(() => {
        getListByPage();
        getAllDepartment()
        spWorker()
        getOpList()
        getAll()
        getAllDevice()
        getAllRisks()
        getOtherWork()
      });
      const giveTime = () => {
        if (state.timeRange && state.timeRange !== null) {
          state.searPara.startTime = state.timeRange[0];
          state.searPara.endTime = state.timeRange[1];
        } else {
          state.searPara.startTime = '';
          state.searPara.endTime = '';
        }
      };
      const continueRecord = (row)=>{
        if(row.workType == 1){
          fireRef.value.openDialog(row,'continue')
        }
        if(row.workType == 2){
          spaceRef.value.openDialog(row,'continue')
        }
        if(row.workType == 3){
          hoistRef.value.openDialog(row,'continue')
        }
        if(row.workType == 4){
          groundRef.value.openDialog(row,'continue')
        }
        if(row.workType == 5){
          brokenRef.value.openDialog(row,'continue')
        }
        if(row.workType == 6){
          heightRef.value.openDialog(row,'continue')
        }
        if(row.workType == 7){
          powerRef.value.openDialog(row,'continue')
        }
        if(row.workType == 8){
          plateRef.value.openDialog(row,'continue')
        }
        if(row.workType == 9){
          openRef.value.openDialog(row,'continue')
        }
      }
        // 刷新
        const reLoadData = async () => {
@@ -406,6 +562,8 @@
            if (res.data.code === '200') {
                state.departmentList = JSON.parse(JSON.stringify(res.data.data))
                recursion(state.departmentList);
                state.lists.departList = state.departmentList
                state.lists.departList2 = JSON.parse(JSON.stringify(res.data.data))[0].children[0].children.filter(i=>i.depId == 32 || i.depId == 48 || i.depId == 49 || i.depId == 50 || i.depId == 10 || i.depId == 41 || i.depId == 46 || i.depId == 47)
            } else {
                ElMessage({
                    type: 'warning',
@@ -427,7 +585,7 @@
        // 分页获取
        const getListByPage = async () => {
            const data = { pageSize: state.pageSize1, pageIndex: state.pageIndex1, searchParams: { workType: state.searchWord } };
            const data = { pageSize: state.pageSize1, pageIndex: state.pageIndex1, searchParams: state.searPara };
            let res = await workApplyApi().getAllNewApplyListPage(data);
            if (res.data.code === '200') {
                state.applyData = JSON.parse(JSON.stringify(res.data.data));
@@ -465,20 +623,124 @@
            }
        };
      const spWorker = async ()=>{
        for(let id of ['18','19']){
          const res = await workApplyApi().getSpList({roleId: id})
          if(id == '18'){
            if (res.data.code === '200') {
              state.lists.spList.jhList = JSON.parse(JSON.stringify(res.data.data))
            } else {
              ElMessage({
                type: 'warning',
                message: res.data.msg
              });
            }
          }
          if(id == '19'){
            if (res.data.code === '200') {
              state.lists.spList.sfList = JSON.parse(JSON.stringify(res.data.data))
            } else {
              ElMessage({
                type: 'warning',
                message: res.data.msg
              });
            }
          }
        }
      }
      const getOpList = async()=>{
        const res = await workApplyApi().getOpList()
        if(res.data.code == '200'){
          if(res.data.data && res.data.data.length>0){
            state.lists.spList.opList = JSON.parse(JSON.stringify(res.data.data)).map(i=>{
              if(i.certList && i.certList.length>0){
                i.certList = i.certList.map(item=>{
                  item['realName'] = i.realName + '(' + item.certTypeName +':'+ item.certExpiredAt + ')'
                  item['uid'] = item.certNo + ',' + item.certExpiredAt
                  return item
                })
              }
              return i
            })
          }
        }else{
          ElMessage({
            type: 'warning',
            message: res.data.msg
          })
        }
      }
      // 获取用户列表
      const getAll = async ()=>{
        const res = await workApplyApi().getAllUsers()
        if (res.data.code === '200') {
          state.lists.workerList = JSON.parse(JSON.stringify(res.data.data))
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      };
      // 获取设备列表
      const getAllDevice = async ()=>{
        const res = await workApplyApi().getAllDevices()
        if (res.data.code === '200') {
          state.lists.deviceList = JSON.parse(JSON.stringify(res.data.data))
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      }
      // 获取设备列表
      const getAllRisks = async ()=>{
        const res = await workApplyApi().getAllRiskIdentity()
        if (res.data.code === '200') {
          // state.allDevices = JSON.parse(JSON.stringify(res.data.data))
          state.lists.riskList = JSON.parse(JSON.stringify(res.data.data))
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      }
      const getOtherWork = async () => {
        let res = await workApplyApi().getOtherWork({pageSize: 999, pageIndex: 1, searchParams: {workPermitNo: '', workType: null}})
        if (res.data.code === '200') {
          state.lists.otherWorks = JSON.parse(JSON.stringify(res.data.data))
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      };
        // 关键词查询记录
        const searchRecord = async () => {
            if (state.searchWord == '') {
                ElMessage({
                    type: 'warning',
                    message: '请输入查询关键词'
                });
            } else {
                getListByPage();
            }
            state.pageIndex1 = 1
            getListByPage();
        };
        // 重置搜索
        const clearSearch = async () => {
            state.searchWord = '';
            state.timeRange = []
            state.searPara = {
              startTime: '',
              endTime: '',
              workPermitNo: '',
              workType: null,
              headUserName: '',
              secondDepId: null
            };
            state.pageIndex1 = 1
            getListByPage();
        };
@@ -529,26 +791,20 @@
            state.deleteDialog = false;
        };
        // 导出图表
        const downLoadBtn = (row:any) =>{
            state.downLoadId = row.workApplyId;
            state.downLoadName = row.workTypeDesc + row.workPermitNo
            state.downLoadDialog = true;
        }
        // 导出方法
        const downLoadRecord = async (data: any) => {
        const downLoadRecord = (row: any) => {
            // let res = await workApplyApi().postPrinting(data);
            axios.post(import.meta.env.VITE_API_URL + `/work/apply/printingPdf`,data,{headers:{'Content-Type': 'application/json','Authorization': `${Cookies.get('token')}`,'uid':`${Cookies.get('uid')}`},responseType: 'blob'}).then(res=>{
            axios.post(import.meta.env.VITE_API_URL + `/specialwork9step/work/down/load/pdf`,{ id: row.id},{headers:{'Content-Type': 'application/json','Authorization': `${Cookies.get('token')}`,'uid':`${Cookies.get('uid')}`},responseType: 'blob'}).then(res=>{
                if (res) {
                    const link = document.createElement('a')
                    let blob = new Blob([res.data],{type: 'application/pdf'})
                    link.style.display = "none";
                    link.href = URL.createObjectURL(blob); // 创建URL
                    link.setAttribute("download", state.downLoadName + "作业证.pdf");
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);
                    link.setAttribute("download", row.workTypeDesc + row.workPermitNo + "作业证.pdf");
                    document.body.appendChild(link)
                    window.open(link.href)
                    document.body.removeChild(link)
                } else {
                    ElMessage({
                        type: 'warning',
@@ -557,11 +813,6 @@
                }
            })
        };
        const conFirmDownLoad = () => {
            downLoadRecord({ applyWorkId: state.downLoadId });
            state.downLoadDialog = false;
        };
        const handleSizeChange1 = (val: number) => {
@@ -587,12 +838,6 @@
            await initBackEndControlRoutes();
        };
        // 页面载入时执行方法
        onMounted(() => {
            getListByPage();
            getAllDepartment()
        });
        return {
            View,
            Edit,
@@ -601,6 +846,17 @@
            Plus,
            Finished,
            Download,
            fireRef,
            plateRef,
            spaceRef,
            hoistRef,
            groundRef,
            brokenRef,
            heightRef,
            powerRef,
            openRef,
          continueRecord,
            giveTime,
            reLoadData,
            toApply,
            handleClick,
@@ -610,9 +866,8 @@
            viewRecord,
            viewStatus,
            deleteRecordBtn,
            downLoadBtn,
            downLoadRecord,
            conFirmDelete,
            conFirmDownLoad,
            getListByPage,
            handleSizeChange1,
            handleCurrentChange1,
@@ -674,7 +929,7 @@
            }
        }
        &:last-of-type {
            height: calc(100% - 100px);
            height: calc(100% - 130px);
        }
    }
    .stepItem {