gaoluyang
2025-02-25 8bf1c8f0a5681df03b35ff7762e2946574188ebb
抽样信息搬迁
已添加3个文件
1038 ■■■■■ 文件已修改
src/api/business/productSamplingInfo.js 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/productSamplingInfo/components/addQuarterItem.vue 290 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/productSamplingInfo/index.vue 647 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/business/productSamplingInfo.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,101 @@
// æŠ½æ ·ä¿¡æ¯è¯¦æƒ…页面相关接口
import request from '@/utils/request'
// æŠ½æ ·ä¿¡æ¯-季度查询
export function getQuarterPage(query) {
  return request({
    url: '/finishProductSpotCheck/getQuarterPage',
    method: 'get',
    params: query
  })
}
// æŠ½æ ·ä¿¡æ¯-年度查询
export function getSpotCheckYearPage(query) {
  return request({
    url: '/finishProductSpotCheck/getSpotCheckYearPage',
    method: 'get',
    params: query
  })
}
// åˆ é™¤å­£åº¦æŠ½æ£€
export function deleteQuarter(query) {
  return request({
    url: '/finishProductSpotCheck/deleteQuarter',
    method: 'delete',
    params: query
  })
}
// ç”Ÿæˆå­£åº¦æŠ¥å‘Š
export function finalReportQuarter(query) {
  return request({
    url: '/finishProductSpotCheck/finalReportQuarter',
    method: 'get',
    params: query,
    responseType: "blob"
  })
}
// ç”Ÿæˆå¹´åº¦æŠ¥å‘Š
export function finalReportSpotCheckYear(query) {
  return request({
    url: '/finishProductSpotCheck/finalReportSpotCheckYear',
    method: 'get',
    params: query,
    responseType: "blob"
  })
}
// åˆ é™¤å¹´åº¦æŠ½æ£€
export function deleteSpotCheckYear(query) {
  return request({
    url: '/finishProductSpotCheck/deleteSpotCheckYear',
    method: 'delete',
    params: query,
  })
}
// å¹´åº¦æŠ½æ£€æŸ¥çœ‹è¯¦æƒ…
export function getSpotCheckYear(query) {
  return request({
    url: '/finishProductSpotCheck/getSpotCheckYear',
    method: 'get',
    params: query,
  })
}
// æäº¤å¹´åº¦æŠ½æ ·
export function addSpotCheckYear(query) {
  return request({
    url: '/finishProductSpotCheck/addSpotCheckYear',
    method: 'post',
    data: query,
  })
}
// ç¼–辑年度抽样
export function updateSpotCheckYear(query) {
  return request({
    url: '/finishProductSpotCheck/updateSpotCheckYear',
    method: 'post',
    data: query,
  })
}
// å­£åº¦æŠ½æ£€æŸ¥çœ‹è¯¦æƒ…
export function getQuarter(query) {
  return request({
    url: '/finishProductSpotCheck/getQuarter',
    method: 'get',
    params: query,
  })
}
// æäº¤å­£åº¦æŠ½æ ·
export function addQuarter(query) {
  return request({
    url: '/finishProductSpotCheck/addQuarter',
    method: 'post',
    data : query,
  })
}
// ç¼–辑季度检验
export function updateQuarterOnOrder(query) {
  return request({
    url: '/finishProductSpotCheck/updateQuarterOnOrder',
    method: 'post',
    data : query,
  })
}
src/views/business/productSamplingInfo/components/addQuarterItem.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,290 @@
<template>
  <div>
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="quarterSampleDia" title="季度抽样" width="90%" @close="quarterSampleDia = false">
      <div style="display: flex;align-items: center;justify-content: space-between;margin-bottom: 10px">
        <div style="width: 30%;display: flex;align-items: center;" >
          <span style="width: 50px">编号:</span>
          <el-input v-model="quarterSampleForm.quarterNo" :disabled="operationType !== 'add'" size="small"></el-input>
        </div>
        <div v-if="operationType === 'add'">
          <el-button size="small" type="primary" @click="addQuarter">添加</el-button>
          <el-button size="small" type="danger" @click="clearTable">清空</el-button>
        </div>
      </div>
      <div>
        <el-table v-loading="tableLoading" :data="quarterItems" border height="400" style="width: 100%">
          <el-table-column label="产品类型" prop="productType" width="200">
            <template slot-scope="{row}">
              <template>
                <el-input v-model="row.productType" size="small"/>
              </template>
            </template>
          </el-table-column>
          <el-table-column label="责任人" prop="dutyUser" width="100"></el-table-column>
          <el-table-column label="型号" prop="productModel" width="120">
            <template slot-scope="{row}">
              <template>
                <el-input v-model="row.productModel" size="small" :disabled="operationType === 'view'"/>
              </template>
            </template>
          </el-table-column>
          <el-table-column label="抽样数量" min-width="340" prop="spotCheckNumber">
            <template slot-scope="{row}">
              <template>
                <el-input v-model="row.spotCheckNumber" size="small" :disabled="operationType === 'view'"/>
              </template>
            </template>
          </el-table-column>
          <el-table-column v-if="operationType === 'add'" label="数量" min-width="120" prop="number">
            <template slot-scope="{row}">
              <template>
                <el-input v-model="row.number" size="small" :disabled="operationType === 'view'"/>
              </template>
            </template>
          </el-table-column>
          <el-table-column v-if="operationType !== 'add'" label="抽样时间" prop="spotCheckTime" width="160">
            <template slot-scope="{row}">
              <template>
                <el-date-picker v-model="row.spotCheckTime"
                                format="yyyy-MM-dd"
                                :disabled="operationType === 'view'"
                                placeholder="选择日期"
                                size="small"
                                clearable
                                style="width:100%"
                                type="date"
                                value-format="yyyy-MM-dd">
                </el-date-picker>
              </template>
            </template>
          </el-table-column>
          <el-table-column v-if="operationType !== 'add'" label="试样结论" prop="result" width="130">
            <template v-slot="scope">
              <el-select v-model="scope.row.result" placeholder="请选择" size="small" clearable :disabled="operationType === 'view'">
                <el-option label="合格" value="合格"></el-option>
                <el-option label="不合格" value="不合格"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column v-if="operationType !== 'add'" label="取样人员" prop="samplingUser" width="120">
            <template slot-scope="{row}">
              <template>
                <el-input v-model="row.samplingUser" size="small" :disabled="operationType === 'view'"/>
              </template>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="itemRemark" width="200">
            <template slot-scope="{row}">
              <template>
                <el-input v-model="row.itemRemark" size="small" :disabled="operationType === 'view'"/>
              </template>
            </template>
          </el-table-column>
          <el-table-column v-if="operationType !== 'view'" fixed="right" label="操作" width="100">
            <template slot-scope="scope">
              <el-button size="small" style="color: #f56c6c" type="text" @click="deleteScope(scope.$index)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div style="display: flex;align-items: center;margin: 10px 0">
        <span style="width: 70px">备注:</span>
        <el-input v-model="quarterSampleForm.remark" :disabled="operationType === 'view'" size="small" style="width: 43%" type="textarea"></el-input>
      </div>
      <div v-if="operationType !== 'add'">
        <el-form ref="form" :model="editForm" label-width="70px">
          <el-col :span="12">
            <el-form-item label="编制人:">
              <el-select v-model="editForm.writeUser" :disabled="operationType !=='edit'" placeholder="请选择" size="small" style="width: 100%">
                <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="会签人:">
              <el-select v-model="editForm.countersignUser" :disabled="operationType !=='edit'" multiple placeholder="请选择" size="small" style="width: 100%">
                <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核人:">
              <el-select v-model="editForm.examineUser" :disabled="operationType !=='edit'" placeholder="请选择" size="small" style="width: 100%">
                <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="批准人:">
              <el-select v-model="editForm.ratifyUser" :disabled="operationType !=='edit'" placeholder="请选择" size="small" style="width: 100%">
                <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="quarterSampleDia = false">取 æ¶ˆ</el-button>
        <el-button v-if="operationType === 'add'" @click="quarterSampleDia = false">保 å­˜</el-button>
        <el-button v-if="operationType !== 'add' && operationType !== 'view'" type="primary" @click="handleSample">ç¡® å®š</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {addQuarter, getQuarter, updateQuarterOnOrder} from "@/api/business/productSamplingInfo";
import {selectUserCondition} from "@/api/performance/class";
export default {
  name: "addQuarterItem",
  // import å¼•入的组件需要注入到对象中才能使用
  components: {},
  data() {
    // è¿™é‡Œå­˜æ”¾æ•°æ®
    return {
      tableLoading: false,
      quarterSampleDia: false, // å­£åº¦æŠ½æ ·å¼¹æ¡†
      quarterSampleForm: {
        quarterNo: '', // ç¼–号
      },
      quarterItems: [],
      quarterTemItems: [],
      operationType: '',
      editForm: {
        quarterId: '',
        writeUser: '', // ç¼–制人
        countersignUser: [], // ä¼šç­¾äºº
        examineUser: '', // å®¡æ ¸äºº
        ratifyUser: '', // æ‰¹å‡†äºº
      },
      userList: [],
      quarterRow: {},
    }
  },
  mounted() {
    this.getUserList()
  },
  // æ–¹æ³•集合
  methods: {
    openDia (quarterTemItems, type) {
      this.quarterSampleDia = true
      this.operationType = type
      if (type === 'add') {
        if (quarterTemItems.length > 0) {
          this.quarterItems = quarterTemItems
        }
        this.quarterSampleForm.quarterNo = getCurrentMonthTwoDigits()
      } else {
        this.tableLoading = true
        this.quarterRow = quarterTemItems
        getQuarter({quarterId: quarterTemItems.quarterId}).then(res => {
          this.tableLoading = false
          if (res.code === 200) {
            this.quarterItems = res.data.quarterItems
            this.quarterSampleForm.quarterNo = res.data.quarterNo
            this.quarterSampleForm.remark = res.data.remark
            this.editForm.quarterId = res.data.quarterId
            this.editForm.writeUser = res.data.writeUser
            this.editForm.examineUser = res.data.examineUser
            this.editForm.ratifyUser = res.data.ratifyUser
            if (res.data.countersignUser) {
              this.editForm.countersignUser = res.data.countersignUser.split(",").map(Number)
            }
          }
        })
      }
    },
    // æ‰‹åŠ¨æ·»åŠ 
    addQuarter () {
      this.quarterItems.push({
        productType: '',
        dutyUser: JSON.parse(localStorage.getItem("user")).name,
        productModel: '',
        spotCheckNumber: '',
        number: '',
        spotCheckTime: '',
        result: '',
        samplingUser: '',
        itemRemark: '',
      })
    },
    // æäº¤å­£åº¦æŠ½æ ·
    handleSample () {
      this.$confirm('是否提交该数据', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (this.operationType === 'add') {
          this.quarterSampleForm.quarterItems = JSON.parse(JSON.stringify(this.quarterItems))
          this.quarterSampleForm.quarterItems.forEach(item => {
            item.spotCheckNumber = item.spotCheckNumber + ' ' + (item.number == null ? "" : item.number)
          })
          addQuarter(this.quarterSampleForm).then(res => {
            if (res.code == 200) {
              this.$message.success('提交成功')
              this.quarterItems = []
              this.$parent.quarterTemItems = []
              this.closeQuarterSampleDia()
            }
          })
        } else {
          const params = {...this.editForm}
          if (params.countersignUser.length > 0) {
            params.countersignUser = params.countersignUser.join(',')
          } else {
            params.countersignUser = ''
          }
          params.quarterItems = JSON.parse(JSON.stringify(this.quarterItems))
          updateQuarterOnOrder(params).then(res => {
            if (res.code == 200) {
              this.$message.success('提交成功')
              this.quarterItems = []
              this.closeQuarterSampleDia()
            }
          })
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    // æ¸…空抽样计划
    clearTable () {
      this.quarterItems = []
      this.$parent.quarterTemItems = []
    },
    // æ‰‹åŠ¨åˆ é™¤
    deleteScope (index) {
      this.quarterItems.splice(index, 1)
    },
    // å…³é—­å­£åº¦æŠ½æ ·å¼¹æ¡†
    closeQuarterSampleDia () {
      this.quarterSampleDia = false
      if (this.operationType === 'add') {
        this.$parent.handleStockList()
      } else {
        this.$parent.refreshTable()
      }
    },
    getUserList(){
      selectUserCondition({ type: 0 }).then((res) => {
        this.userList = res.data;
      })
    },
  },
}
function getCurrentMonthTwoDigits() {
  const currentDate = new Date();
  const year = currentDate.getFullYear();
  const currentMonth = currentDate.getMonth() + 1;
  return year + currentMonth.toString().padStart(2, '0');
}
</script>
<style scoped>
</style>
src/views/business/productSamplingInfo/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,647 @@
<template>
  <div class="capacity-scope">
    <div style="display: flex;justify-content: space-between">
      <el-form :model="entity" ref="entity" size="small" :inline="true">
        <el-form-item label="编号" prop="quarterNo" v-show="tabIndex === 0">
          <el-input v-model="entity.quarterNo" clearable placeholder="请输入"
                    size="small"
                    @keyup.enter.native="refreshTable">
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="refreshTable">查 è¯¢</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="refresh">重 ç½®</el-button>
        </el-form-item>
      </el-form>
      <div>
        <el-button v-if="tabIndex === 1" size="small" type="primary" @click="yearSample('add')">年度抽样</el-button>
      </div>
    </div>
    <div>
      <div class="table">
        <ul class="tab">
          <li v-for="(m,i) in tabList" :key="i" :class="{active:i===tabIndex}" @click="handleTab(m,i)">{{m.label}}</li>
        </ul>
        <!--季度-->
        <lims-table :tableData="tableData" :column="column" v-if="tabIndex === 0"
                    @pagination="pagination" :height="'calc(100vh - 290px)'"
                    :page="page" :tableLoading="tableLoading"></lims-table>
        <!--年度-->
        <lims-table :tableData="tableData1" :column="column1" v-if="tabIndex === 1"
                    @pagination="pagination1" :height="'calc(100vh - 290px)'"
                    key="tableData1" :page="page1" :tableLoading="tableLoading1"></lims-table>
      </div>
    </div>
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="yearSampleDia" title="年度抽样" width="70%"
               @close="closeYearSampleDia">
      <div style="display: flex;align-items: center;justify-content: space-between;margin-bottom: 10px">
        <div style="width: 30%;display: flex;align-items: center;" >
          <el-input v-if="operationType !=='view'" v-model="currentYear" size="small"/>
          <span v-if="operationType ==='view'" style="width: 160px;font-size: 18px;font-weight: 600">{{currentYear}}</span>
        </div>
        <div  v-if="operationType !== 'view'">
          <el-button size="small" type="primary" @click="addQuarter">添加</el-button>
          <el-button size="small" type="danger" @click="clearTable">清空</el-button>
        </div>
      </div>
      <div>
        <el-table :data="yearItems" border height="450" style="width: 100%">
          <el-table-column label="类别" prop="yearType" width="240">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.yearType" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.yearType}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="1" prop="january" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.january" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.january}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="2" prop="february" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.february" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.february}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="3" prop="march" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.march" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.march}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="4" prop="april" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.april" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.april}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="5" prop="may" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.may" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.may}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="6" prop="june" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.june" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.june}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="7" prop="july" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.july" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.july}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="8" prop="august" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.august" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.august}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="9" prop="september" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.september" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.september}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="10" prop="october" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.october" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.october}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="11" prop="november" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.november" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.november}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column header-align="center" label="12" prop="december" width="160">
            <template slot-scope="{row}">
              <template v-if="operationType !== 'view'">
                <el-input v-model="row.december" size="small" type="textarea" :rows="4"/>
              </template>
              <template v-else>
                <span size="small">{{row.december}}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column v-if="operationType !== 'view'" fixed="right" label="操作"  width="100">
            <template slot-scope="scope">
              <el-button size="small" style="color: #f56c6c" type="text" @click="deleteScope(scope.$index)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div style="display: flex;align-items: center;margin-top: 10px">
        <span style="width: 70px">注意事项:</span>
        <el-input v-model="yearSampleForm.tableRemark" :disabled="operationType === 'view'" size="small" style="width: 50%" type="textarea"></el-input>
      </div>
      <div style="display: flex;align-items: center;margin-top: 10px">
        <span style="width: 70px">备注:</span>
        <el-input v-model="yearSampleForm.remark" :disabled="operationType === 'view'" size="small" style="width: 50%" type="textarea"></el-input>
      </div>
      <div v-if="operationType !== 'add'">
        <el-form ref="form" :model="editYearFormRow" label-width="70px">
          <el-col :span="12">
            <el-form-item label="编制人:">
              <el-select v-model="editYearFormRow.writeUser" :disabled="operationType !=='edit'" placeholder="请选择" size="small" style="width: 100%">
                <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="会签人:">
              <el-select v-model="editYearFormRow.countersignUser" :disabled="operationType !=='edit'" multiple placeholder="请选择" size="small" style="width: 100%">
                <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核人:">
              <el-select v-model="editYearFormRow.examineUser" :disabled="operationType !=='edit'" placeholder="请选择" size="small" style="width: 100%">
                <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="批准人:">
              <el-select v-model="editYearFormRow.ratifyUser" :disabled="operationType !=='edit'" placeholder="请选择" size="small" style="width: 100%">
                <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeYearSampleDia">取 æ¶ˆ</el-button>
        <el-button v-if="operationType !== 'view'" type="primary" @click="handleSample">ç¡® å®š</el-button>
      </span>
    </el-dialog>
    <add-quarter-item ref="addQuarterItem"></add-quarter-item>
  </div>
</template>
<script>
import AddQuarterItem from "./components/addQuarterItem.vue";
import limsTable from "@/components/Table/lims-table.vue";
import {
  addSpotCheckYear,
  deleteQuarter, deleteSpotCheckYear,
  finalReportQuarter,
  finalReportSpotCheckYear,
  getQuarterPage, getSpotCheckYear, getSpotCheckYearPage, updateSpotCheckYear
} from "@/api/business/productSamplingInfo";
import {selectUserCondition} from "@/api/performance/class";
export default {
  name: "b1-product-sampling-info",
  // import å¼•入的组件需要注入到对象中才能使用
  components: {limsTable, AddQuarterItem},
  data() {
    // è¿™é‡Œå­˜æ”¾æ•°æ®
    return {
      upIndex: 0,
      tabIndex: 0,
      tabList: [
        {
          label: '季度',
          value: 0
        },
        {
          label: '年度',
          value: 1
        },
      ],
      entity: {
        quarterNo: null,
      },
      tableData: [],
      tableLoading: false,
      column: [
        {label: '编号', prop: 'quarterNo'},
        {label: '备注', prop: 'remark'},
        {label: '创建人', prop: 'createUserName'},
        {label: '创建时间', prop: 'createTime'},
        {
          dataType: 'action',
          label: '操作',
          operation: [
            {
              name: '编辑',
              type: 'text',
              clickFun: (row) => {
                this.editForm(row);
              },
            },
            {
              name: '查看',
              type: 'text',
              clickFun: (row) => {
                this.viewQuarterInfo(row);
              },
            },
            {
              name: '下载',
              type: 'text',
              clickFun: (row) => {
                this.handleDown(row);
              },
            },
            {
              name: '删除',
              type: 'text',
              clickFun: (row) => {
                this.deleteQuarterInfo(row);
              },
            }
          ]
        }
      ],
      page: {
        total:0,
        size:10,
        current:1
      },
      tableData1: [],
      tableLoading1: false,
      column1: [
        { label: '名称', prop: 'yearHead' },
        { label: '创建人', prop: 'createUserName' },
        { label: '创建时间', prop: 'createTime' },
        {
          dataType: 'action',
          label: '操作',
          operation: [
            {
              name: '编辑',
              type: 'text',
              clickFun: (row) => {
                this.editYearForm(row);
              },
            },
            {
              name: '查看',
              type: 'text',
              clickFun: (row) => {
                this.viewYearInfo(row);
              },
            },
            {
              name: '下载',
              type: 'text',
              clickFun: (row) => {
                this.download(row);
              },
            },
            {
              name: '删除',
              type: 'text',
              clickFun: (row) => {
                this.deleteYearInfo(row);
              },
            },
          ]
        }
      ],
      page1: {
        total: 0,
        size: 10,
        current: 1
      },
      yearSampleDia: false, // å¹´åº¦æŠ½æ ·
      yearSampleForm: {
        tableRemark: '',
        remark: ''
      },
      yearItems: [],
      currentYear: '',
      operationType: '',
      userList: [],
      yearRow: {},
      editYearFormRow: {
        yearId: '',
        writeUser: '', // ç¼–制人
        countersignUser: null, // ä¼šç­¾äºº
        examineUser: '', // å®¡æ ¸äºº
        ratifyUser: '', // æ‰¹å‡†äºº
      }
    }
  },
  mounted() {
    this.refreshTable()
  },
  // æ–¹æ³•集合
  methods: {
    // æŸ¥è¯¢å›žè°ƒ
    refreshTable(e) {
      if (this.tabIndex === 0) {
        this.getQuarterPageList()
      } else if (this.tabIndex === 1) {
        this.getSpotCheckYearPageList()
      }
    },
    getQuarterPageList () {
      this.tableLoading = true
      getQuarterPage({
        ...this.page,...this.entity
      }).then(res => {
        this.tableLoading = false
        this.page.total = res.data.total
        this.tableData = res.data.records
      }).catch(err => {
        this.tableLoading = false
      })
    },
    getSpotCheckYearPageList () {
      this.tableLoading1 = true
      getSpotCheckYearPage({
        ...this.page1
      }).then(res => {
        this.tableLoading1 = false
        this.page1.total = res.data.total
        this.tableData1 = res.data.records
      }).catch(err => {
        this.tableLoading1 = false
      })
    },
    // é‡ç½®
    refresh() {
      this.resetForm('entity')
      this.refreshTable()
    },
    pagination (page) {
      this.page.size = page.limit
      this.refreshTable()
    },
    pagination1 (page) {
      this.page1.size = page.limit
      this.refreshTable()
    },
    // ç¼–辑季度抽样
    editForm (row) {
      this.$refs.addQuarterItem.openDia(row, 'edit')
    },
    // æŸ¥çœ‹å­£åº¦æŠ½æ ·
    viewQuarterInfo (row) {
      this.$refs.addQuarterItem.openDia(row, 'view')
    },
    // åˆ é™¤å­£åº¦æŠ½æ ·
    deleteQuarterInfo (row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        deleteQuarter({quarterId: row.quarterId}).then(res => {
          if (res.code === 200) {
            this.$message.success('删除成功')
            this.refreshTable()
          }
        })
      }).catch(() => {})
    },
    // å¯¼å‡º
    handleDown (row) {
      let randomNum = Math.random();
      finalReportQuarter({quarterId: row.quarterId, random: randomNum}).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, '季度抽样信息导出.docx')
        this.$message.success('导出成功')
      })
    },
    // å¹´åº¦ä¸‹è½½
    download(row) {
      finalReportSpotCheckYear({yearId: row.yearId}).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, row.yearHead + '.docx')
        this.$message.success('导出成功')
      })
    },
    // åˆ é™¤å¹´åº¦æŠ½æ ·
    deleteYearInfo (row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        deleteSpotCheckYear({yearId: row.yearId}).then(res => {
          if (res.code === 200) {
            this.$message.success('删除成功')
            this.refreshTable()
          }
        })
      }).catch(() => {})
    },
    // æŸ¥çœ‹å¹´åº¦è¯¦æƒ…
    viewYearInfo (row) {
      this.operationType = 'view'
      this.getUserList()
      this.yearSampleDia = true
      this.yearRow = row
      getSpotCheckYear({yearId: row.yearId}).then(res => {
        if (res.code === 200) {
          this.currentYear = res.data.yearHead
          this.yearItems = res.data.yearItems
          this.yearSampleForm.tableRemark = res.data.tableRemark
          this.yearSampleForm.remark = res.data.remark
          this.editYearFormRow.yearId = res.data.yearId
          this.editYearFormRow.writeUser = res.data.writeUser
          this.editYearFormRow.examineUser = res.data.examineUser
          this.editYearFormRow.ratifyUser = res.data.ratifyUser
          if (res.data.countersignUser) {
            this.editYearFormRow.countersignUser = res.data.countersignUser.split(",").map(Number)
          }
        }
      })
    },
    // ç¼–辑年度抽样
    editYearForm (row) {
      this.operationType = 'edit'
      this.getUserList()
      this.yearSampleDia = true
      getSpotCheckYear({yearId: row.yearId}).then(res => {
        if (res.code === 200) {
          this.currentYear = res.data.yearHead
          this.yearItems = res.data.yearItems
          this.yearSampleForm.tableRemark = res.data.tableRemark
          this.yearSampleForm.remark = res.data.remark
          this.editYearFormRow.yearId = res.data.yearId
          this.editYearFormRow.writeUser = res.data.writeUser
          this.editYearFormRow.examineUser = res.data.examineUser
          this.editYearFormRow.ratifyUser = res.data.ratifyUser
          if (res.data.countersignUser) {
            this.editYearFormRow.countersignUser = res.data.countersignUser.split(",").map(Number)
          }
        }
      })
    },
    // æäº¤å¹´åº¦è®¡åˆ’
    handleSample () {
      if (this.operationType === 'add') {
        this.yearSampleForm.yearItems = JSON.parse(JSON.stringify(this.yearItems))
        this.yearSampleForm.yearHead = this.currentYear
        addSpotCheckYear(this.yearSampleForm).then(res => {
          if (res.code == 200) {
            this.$message.success('提交成功')
            this.yearSampleForm = {}
            this.yearItems = []
            this.closeYearSampleDia()
            this.refreshTable()
          }
        })
      } else {
        const params = {...this.editYearFormRow}
        if (params.countersignUser != null) {
          params.countersignUser = params.countersignUser.join(',')
        }
        params.yearItems = JSON.parse(JSON.stringify(this.yearItems))
        params.tableRemark = this.yearSampleForm.tableRemark
        params.remark = this.yearSampleForm.remark
        updateSpotCheckYear(params).then(res => {
          if (res.code == 200) {
            this.$message.success('修改成功')
            this.yearSampleForm = {}
            this.editYearFormRow = {
              yearId: '',
              writeUser: '', // ç¼–制人
              countersignUser: [], // ä¼šç­¾äºº
              examineUser: '', // å®¡æ ¸äºº
              ratifyUser: '', // æ‰¹å‡†äºº
            }
            this.yearItems = []
            this.closeYearSampleDia()
            this.refreshTable()
          }
        })
      }
    },
    yearSample (type) {
      this.operationType = type
      const currentDate = new Date();
      this.yearSampleDia = true
      this.currentYear = currentDate.getFullYear() + '年年度抽检计划'
    },
    // æ·»åŠ å¹´åº¦è®¡åˆ’
    addQuarter () {
      this.yearItems.push({})
    },
    // æ¸…空抽样计划
    clearTable () {
      this.yearItems = []
    },
    // æ‰‹åŠ¨åˆ é™¤
    deleteScope (index) {
      this.yearItems.splice(index, 1)
    },
    // åˆ‡æ¢ä¸‹å•tab表格
    handleTab(m, i) {
      this.tabIndex = i;
      if (this.tabIndex === 0) {
        this.componentData.entity.quarterNo = this.entity.quarterNo
      }
      this.refreshTable()
    },
    closeYearSampleDia () {
      this.yearSampleForm = {
        tableRemark: '',
        remark: ''
      }
      this.yearItems = []
      this.yearSampleDia = false
    },
    getStyle(){
      return 'height: calc(100% - '+'44'+'px)'
    },
    getUserList(){
      selectUserCondition({ type: 0 }).then((res) => {
        this.userList = res.data;
      })
    },
  },
}
</script>
<style scoped>
.tab {
  list-style-type: none;
  display: flex;
  margin-bottom: 12px;
  margin-top: 0;
  padding-left: 0;
}
.tab li {
  line-height: 24px;
  padding: 6px 14px;
  font-size: 14px;
  color: #333333;
  border: 1px solid #EEEEEE;
  cursor: pointer;
}
.tab li:nth-child(1) {
  border-radius: 8px 0 0 8px;
}
.tab li:nth-child(2) {
  border-radius: 0 8px 8px 0;
}
.tab li.active {
  border-color: #3A7BFA;
  color: #3A7BFA;
}
</style>