fromCheck1.vue 9.46 KB
<template>
  <a-modal
    :width="modalWidth"
    :style="modalStyle"
    :visible="visible"
    :maskClosable="false"
    @cancel="handleCancel">
    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
      <a-button @click="printContent">打印</a-button>
    </template>

    <div class="content" id="dyContent1">
      <div style="width: 100%;text-align: center;"><h1 style="font-size:55px">每日电梯安全检查记录</h1></div>
      <table>
        <tr>
          <th style="width: 10%;">序号</th>
          <th style="width: 15%;">检查因素</th>
          <th style="width: 20%;">检查项目</th>
          <th style="width: 40%;">检查内容</th>
          <th style="width: 10%;">结果</th>
        </tr>
        <tr v-for="(item, index) in people" :key="index">
          <td class="font">{{ index + 1 }}</td>
          <td class="font">{{ item.checkFactors }}</td>
          <td class="font">{{ item.inspectionItems }}</td>
          <td class="font">{{ item.inspectionContent }}</td>

          <td :class="'text-center'">
          <th v-if="item.ischeck==1"></th>
          <th v-if="item.ischeck==0"></th>
          </td>

        </tr>

        <tr>
          <td colspan="5">
            检查情况记录:
            <br/>
            <textarea style="width: 98%;" name="" id="" cols="30" rows="10" v-model="record" disabled> </textarea>
          </td>
        </tr>
        <tr>
          <td colspan="3">设备编号:
            <j-dict-select-tag style="width: 60%" v-model="cloum20" title="编号" dictCode="device_number"
                               placeholder="请选择设备编号" disabled/>
          </td>
          <td colspan="3">特种设备安全员:
            <a-input v-model="recorder" style="width: 40%" disabled></a-input>
          </td>
        </tr>
        <tr>
          <td colspan="6">检查日期:
            <a-input v-model="recordDate" style="width: 40%" disabled></a-input>
          </td>
        </tr>
        <tr style="height: 5px;">
          <td colspan="5" style="text-align: center;">
            <!--            <button style="width: 20rem;height: 3rem;" @click="submit">提交</button>-->
          </td>
        </tr>
      </table>
    </div>


  </a-modal>
</template>


<script>


export default {
  data() {
    return {
      visible: false,
      querySource: {},
      loading: false,
      drawno: '',
      modalWidth: '90%',
      modalStyle: {'top': '20px'},
      record: '',
      recorder: '',
      recordDate: '',
      dynamicModels: {},
      people: [
        {
          checkFactors: '人的因素',
          inspectionItems: '工具保管',
          inspectionContent: '妥善保管电梯专用钥匙和工具',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '运行情况',
          inspectionContent: '电梯运行无异常噪声和振动',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '轿厢通风及照明',
          inspectionContent: '轿厢正常照明和通风有效',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '门防夹装置',
          inspectionContent: '防止门夹人的保护装置功能',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '层门和轿门',
          inspectionContent: '电梯层门和轿门应有效锁紧和闭合,无明显变形',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '楼层显示及按钮',
          inspectionContent: '楼层显示及按钮功能与指示',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '通道',
          inspectionContent: '保持电梯应急救援通道畅通,自动扶梯与自动人行道出入口畅通',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '梳齿板或踏面齿',
          inspectionContent: '自动扶梯与自动人行道梳齿板梳齿或者踏面齿应当完好,不得缺损',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '使用须知',
          inspectionContent: '自动扶梯与自动人行道使用须知',
          ischeck: 1,
        },
        {
          checkFactors: '设备因素',
          inspectionItems: '标志、标识',
          inspectionContent: `1) 机房门外侧有下述或者类似的警示标志:"电梯机器—危险;
                                        2) 轿厢内的铭牌和"特种设备使用标志"标识;
                                        3) 设有IC卡系统的电梯轿厢内的出口层选层按钮标志;
                                        4) 超面积载货电梯、杂物电梯层站处的额定载重量标志;
                                        5) 自动扶梯与自动人行道"急停"指示标记;
                                        6) 消防员电梯象形图标志;
                                        7) 其他安全标志`,
          ischeck: 1,
        },
        {
          checkFactors: '环境因素',
          inspectionItems: '自然环境',
          inspectionContent: '防火、防爆、防雷、防风、防雨、防冻、防腐等设施齐全、完好',
          ischeck: 1,
        },
      ],
    }
  },
  methods: {
    handleCancel() {
      this.visible = false
    },
    ck(record) {
      this.visible = true;
      this.people[0].ischeck = record.cloum1;
      this.people[1].ischeck = record.cloum2;
      this.people[2].ischeck = record.cloum3;
      this.people[3].ischeck = record.cloum4;
      this.people[4].ischeck = record.cloum5;
      this.people[5].ischeck = record.cloum6;
      this.people[6].ischeck = record.cloum7;
      this.people[7].ischeck = record.cloum8;
      this.people[8].ischeck = record.cloum9;
      this.people[9].ischeck = record.cloum10;
      this.people[10].ischeck = record.cloum11;
      this.record = record.record;
      this.recorder = record.recorder;
      this.recordDate = record.recordDate;
      this.cloum20 = record.cloum20;
    },
    printContent() {
      // 获取你想打印的内容
      let content = document.getElementById('dyContent1').innerHTML;

      // 获取所有的 input 和 textarea 元素
      let inputs = document.querySelectorAll('#dyContent1 input');
      let textareas = document.querySelectorAll('#dyContent1 textarea');

      // 存储 input 和 textarea 的值
      let inputValues = [];
      let textareaValues = [];

      // 处理 input 元素,将它们的值替换为普通文本
      inputs.forEach((input, index) => {
        inputValues[index] = input.value;
        let span = document.createElement('span');
        span.textContent = input.value;
        input.parentNode.replaceChild(span, input);
      });

      // 处理 textarea 元素,将它们的值替换为普通文本
      textareas.forEach((textarea, index) => {
        textareaValues[index] = textarea.value;
        let span = document.createElement('span');
        span.textContent = textarea.value.replace(/\n/g, '<br>'); // 保持换行
        textarea.parentNode.replaceChild(span, textarea);
      });

      // 创建一个新的窗口用于打印
      let printWindow = window.open('', '', 'height=500,width=800');

      // 添加表格和边框样式
      let style = `
    <style>
      table {
        border-collapse: collapse;
        width: 100%;
      }
      table, th, td {
        border: 1px solid black;
      }
    </style>
  `;

      // 写入内容到新窗口
      printWindow.document.write('<html><head><title>每日电梯安全检查记录</title>');
      printWindow.document.write(style); // 确保表格样式生效
      printWindow.document.write('</head><body>');
      printWindow.document.write(document.getElementById('dyContent1').innerHTML);
      printWindow.document.write('</body></html>');
      printWindow.document.close(); // 必须关闭文档流才能触发打印
      printWindow.focus(); // 使打印窗口成为焦点

      // 触发打印
      printWindow.print();

      // 关闭打印窗口
      printWindow.close();

      // 恢复原来的 input 和 textarea 元素
      inputs.forEach((input, index) => {
        input.value = inputValues[index];
      });

      textareas.forEach((textarea, index) => {
        textarea.value = textareaValues[index];
      });
    }


  }
  ,
  mounted() {
  }
  ,
}
</script>


<style scoped>
.app-body {
  width: 100%;
  height: 100%;
}

.content {
  width: 99.1%;
  height: 100%;
  border: 1px solid yellowgreen;
  margin: 0 auto;
  overflow: auto;
}

body {
  font-size: 1rem;
}

table,
td,
th {
  border-collapse: collapse;
  border-spacing: 0;
}

table {
  width: 100%;
  margin-top: 10px;
}

td,
th {
  border: 2px solid #000000;
  padding: 5px 10px;
}

th {
  background: #42b983;
  font-size: 3vw;
  font-weight: 400;
  color: #fff;
  cursor: pointer;
}

.font {
  font-size: 2.8vw;
}

tr:nth-of-type(odd) {
  background: #fff;
}

tr:nth-of-type(even) {
  background: #eee;
}

button {
  outline: none;
  padding: 5px 8px;
  color: #fff;
  border: 1px solid #bcbcbc;
  border-radius: 3px;
  background-color: #009a61;
  cursor: pointer;
}

button:hover {
  opacity: 0.8;
}

.text-center {
  text-align: center;
}
</style>

<style lang="less">
.app_container {
  width: 100%;
  height: 100%;
  background: #ffff !important;
}
</style>