yuyu
2023-08-08 0d452c10ee16e40a3ca3d176e5ebebcb4bd16a87
src/views/rawMaterials/reportForInspection/index.vue
@@ -63,7 +63,13 @@
                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="createTime"
                label="创建时间"
@@ -75,7 +81,7 @@
                min-width="200"
              />
              <el-table-column
                prop="registrant"
                prop="inspectUserId"
                label="检验人"
                min-width="200"
              />
@@ -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,7 +158,7 @@
</template>
<script>
import { getInspectionList } from '@/api/rawMaterials/reportForInspection'
import { getInspectionList, addInspection } from '@/api/rawMaterials/reportForInspection'
export default {
  data() {
    return {
@@ -179,7 +185,7 @@
      pageSize: 10, // 每页的数据条数
      radioValue: '全部',
      checkTypeVisible: false,
      type: 0
      addInspectionType: 0
    }
  },
  watch: {
@@ -192,26 +198,6 @@
      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()
  },
@@ -223,12 +209,26 @@
      const res = await getInspectionList({ pageSize: this.currentPage, countSize: this.pageSize })
      // this.inspectionTable = data
      console.log(res)
      this.inspectionTable = res.data
    },
    goToForInspectionDetail() {
      this.$router.push('/rawMaterials/reportForInspection/forInspectionDetail')
    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) {
@@ -281,6 +281,8 @@
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 88px);
    padding: 15px;
  }
  .top-bar{
    margin: -25px;
@@ -333,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;