yuyu
2023-08-10 6c496684e92d7d0d90b50de55f77e3ee93bbabe1
src/views/rawMaterials/reportForInspection/index.vue
@@ -60,43 +60,49 @@
              style="width: 100%"
            >
              <el-table-column
                prop="applicationOrdernumber"
                label="申请单号"
                min-width="200"
              />
              <el-table-column
                prop="typeofInspection"
                prop="type"
                label="检验类型"
                min-width="200"
              />
              >
                <template slot-scope="scope">
                  <span v-if="scope.row.type===0">原材料检验</span>
                  <span v-else-if="scope.row.type===1">半成品检验</span>
                  <span v-else-if="scope.row.type===2">成品检验</span>
                </template>
              </el-table-column>
              <el-table-column
                prop="objectofInspection"
                label="检验对象"
                prop="createTime"
                label="创建时间"
                min-width="200"
              />
              <el-table-column
                prop="palceofObject"
                label="对象位置"
                prop="userName"
                label="申请人"
                min-width="200"
              />
              <el-table-column
                prop="name"
                label="对象名称"
                prop="inspectUserId"
                label="检验人"
                min-width="200"
              />
              <el-table-column
                prop="date"
                label="登记日期"
                prop="inspectionStatus"
                label="检验状态"
                min-width="200"
              />
              <el-table-column
                prop="registrant"
                label="登记人"
                prop="qualifiedState"
                label="合格状态"
                min-width="200"
              />
              <el-table-column
                prop="applicationTime"
                label="申请时间"
                prop="inspectStartTime"
                label="检验开始时间"
                min-width="200"
              />
              <el-table-column
                prop="inspectEndTime"
                label="检验结束时间"
                min-width="200"
              />
              <el-table-column
@@ -117,7 +123,7 @@
                :page-sizes="[100, 200, 300, 400]"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="this.inspectionTable.length"
                :total="total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
@@ -131,7 +137,7 @@
            width="40%"
          >
            <div class="check-box">
              <el-radio-group v-model="type">
              <el-radio-group v-model="addInspectionType">
                <el-radio :label="0" border>原材料检验</el-radio>
                <el-radio :label="1" border>半成品检验</el-radio>
                <el-radio :label="2" border>成品检验</el-radio>
@@ -152,6 +158,7 @@
</template>
<script>
import { getInspectionList, addInspection } from '@/api/rawMaterials/reportForInspection'
export default {
  data() {
    return {
@@ -160,21 +167,25 @@
        keyword: ''
      },
      inspectionTable: [{
        applicationOrdernumber: 'QC22-09155',
        typeofInspection: '采购入库',
        objectofInspection: 'MI202207032-1',
        palceofObject: '---',
        name: '这是一条测试数据',
        date: '2022-09-23',
        registrant: '管理员',
        applicationTime: '111'
        'id': '1681215775833042945',
        'type': 0,
        'inspectionStatus': 0,
        'qualifiedState': null,
        'state': 1,
        'createTime': '2023-07-18 16:14:11',
        'updateTime': null,
        'version': null,
        'userName': '测试人员',
        'inspectUserId': null,
        'inspectStartTime': null,
        'inspectEndTime': null
      }],
      currentPage: 1,
      total: 20, // 总条数
      pageSize: 100, // 每页的数据条数
      pageSize: 10, // 每页的数据条数
      radioValue: '全部',
      checkTypeVisible: false,
      type: 0
      addInspectionType: 0
    }
  },
  watch: {
@@ -187,35 +198,37 @@
      deep: true
    }
  },
  // beforeRouteEnter(to, from, next) {
  //   console.log(to, from)
  //   next()
  //   // 在渲染该组件的对应路由被 confirm 前调用
  //   // 不!能!获取组件实例 `this`
  //   // 因为当钩子执行前,组件实例还没被创建
  // },
  // beforeRouteUpdate(to, from, next) {
  //   console.log(to, from)
  //   if (to.name === 'ForInspectionDetail') this.showDetail = true
  //   this.$nextTick(() => {
  //     console.log(1)
  //     this.showDetail = true
  //   })
  //   next()
  //   // 在当前路由改变,但是该组件被复用时调用
  //   // 举例来说,对于一个带有动态参数的路径 /foo/:id,在 /foo/1 和 /foo/2 之间跳转的时候,
  //   // 由于会渲染同样的 Foo 组件,因此组件实例会被复用。而这个钩子就会在这个情况下被调用。
  //   // 可以访问组件实例 `this`
  // },
  created() {
    this.getInspectionTableData()
  },
  updated() {
    if (this.$route.name === 'ForInspectionDetail') this.showDetail = true
  },
  methods: {
    goToForInspectionDetail() {
      this.$router.push('/rawMaterials/reportForInspection/forInspectionDetail')
    async getInspectionTableData() {
      const res = await getInspectionList({ pageSize: this.currentPage, countSize: this.pageSize })
      // this.inspectionTable = data
      console.log(res)
      this.inspectionTable = res.data
    },
    async goToForInspectionDetail() {
      try {
        //
        const form = new FormData()
        form.append('type', this.addInspectionType)
        let { data: inspectionDetail } = await addInspection(form)
        // console.log(res)
        inspectionDetail = JSON.stringify(inspectionDetail)
        this.$message.success('添加成功')
        this.$router.push({ path: '/rawMaterials/reportForInspection/forInspectionDetail', query: { inspectionDetail }})
      } catch (error) {
        this.$message.error('添加失败')
      }
    },
    // 查看对应申请单详情
    handleClick(row) {
      console.log(row)
      const inspectionDetail = JSON.stringify(row)
      this.$router.push({ path: '/rawMaterials/reportForInspection/forInspectionDetail', query: { inspectionDetail }})
    },
    // 每页条数改变时触发 选择一页显示多少行
    handleSizeChange(val) {
@@ -268,6 +281,8 @@
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 88px);
    padding: 15px;
  }
  .top-bar{
    margin: -25px;
@@ -320,6 +335,11 @@
          flex-direction: column;
          .el-table {
            flex: 1;
            display: flex;
            flex-direction: column;
            ::v-deep .el-table__body-wrapper{
              flex: 1;
            }
          }
          >div:nth-child(2){
            display: flex;