spring
2025-03-03 840de9662167b1d7758208b9c88adda806ed8fec
src/views/business/productSamplingInfo/index.vue
@@ -3,9 +3,8 @@
    <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 v-model="entity.quarterNo" clearable placeholder="请输入" size="small"
            @keyup.enter.native="refreshTable">
          </el-input>
        </el-form-item>
        <el-form-item>
@@ -20,26 +19,25 @@
    <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>
          <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="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>
        <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">
    <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 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'">
        <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>
@@ -49,174 +47,181 @@
          <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"/>
                <el-input v-model="row.yearType" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.yearType}}</span>
                <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"/>
                <el-input v-model="row.january" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.january}}</span>
                <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"/>
                <el-input v-model="row.february" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.february}}</span>
                <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"/>
                <el-input v-model="row.march" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.march}}</span>
                <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"/>
                <el-input v-model="row.april" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.april}}</span>
                <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"/>
                <el-input v-model="row.may" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.may}}</span>
                <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"/>
                <el-input v-model="row.june" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.june}}</span>
                <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"/>
                <el-input v-model="row.july" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.july}}</span>
                <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"/>
                <el-input v-model="row.august" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.august}}</span>
                <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"/>
                <el-input v-model="row.september" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.september}}</span>
                <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"/>
                <el-input v-model="row.october" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.october}}</span>
                <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"/>
                <el-input v-model="row.november" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.november}}</span>
                <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"/>
                <el-input v-model="row.december" size="small" type="textarea" :rows="4" />
              </template>
              <template v-else>
                <span size="small">{{row.december}}</span>
                <span size="small">{{ row.december }}</span>
              </template>
            </template>
          </el-table-column>
          <el-table-column v-if="operationType !== 'view'" fixed="right" label="操作"  width="100">
          <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>
              <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>
        <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>
        <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-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-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-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-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>
@@ -242,12 +247,12 @@
  finalReportSpotCheckYear,
  getQuarterPage, getSpotCheckYear, getSpotCheckYearPage, updateSpotCheckYear
} from "@/api/business/productSamplingInfo";
import {selectUserCondition} from "@/api/performance/class";
import { selectUserCondition } from "@/api/performance/class";
export default {
  name: "b1-product-sampling-info",
  // import 引入的组件需要注入到对象中才能使用
  components: {limsTable, AddQuarterItem},
  components: { limsTable, AddQuarterItem },
  data() {
    // 这里存放数据
    return {
@@ -269,10 +274,10 @@
      tableData: [],
      tableLoading: false,
      column: [
        {label: '编号', prop: 'quarterNo'},
        {label: '备注', prop: 'remark'},
        {label: '创建人', prop: 'createUserName'},
        {label: '创建时间', prop: 'createTime'},
        { label: '编号', prop: 'quarterNo' },
        { label: '备注', prop: 'remark' },
        { label: '创建人', prop: 'createUserName' },
        { label: '创建时间', prop: 'createTime' },
        {
          dataType: 'action',
          label: '操作',
@@ -309,9 +314,9 @@
        }
      ],
      page: {
        total:0,
        size:10,
        current:1
        total: 0,
        size: 10,
        current: 1
      },
      tableData1: [],
      tableLoading1: false,
@@ -391,10 +396,10 @@
        this.getSpotCheckYearPageList()
      }
    },
    getQuarterPageList () {
    getQuarterPageList() {
      this.tableLoading = true
      getQuarterPage({
        ...this.page,...this.entity
        ...this.page, ...this.entity
      }).then(res => {
        this.tableLoading = false
        this.page.total = res.data.total
@@ -403,7 +408,7 @@
        this.tableLoading = false
      })
    },
    getSpotCheckYearPageList () {
    getSpotCheckYearPageList() {
      this.tableLoading1 = true
      getSpotCheckYearPage({
        ...this.page1
@@ -420,78 +425,76 @@
      this.resetForm('entity')
      this.refreshTable()
    },
    pagination (page) {
    pagination(page) {
      this.page.size = page.limit
      this.refreshTable()
    },
    pagination1 (page) {
    pagination1(page) {
      this.page1.size = page.limit
      this.refreshTable()
    },
    // 编辑季度抽样
    editForm (row) {
    editForm(row) {
      this.$refs.addQuarterItem.openDia(row, 'edit')
    },
    // 查看季度抽样
    viewQuarterInfo (row) {
    viewQuarterInfo(row) {
      this.$refs.addQuarterItem.openDia(row, 'view')
    },
    // 删除季度抽样
    deleteQuarterInfo (row) {
    deleteQuarterInfo(row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        deleteQuarter({quarterId: row.quarterId}).then(res => {
        deleteQuarter({ quarterId: row.quarterId }).then(res => {
          if (res.code === 200) {
            this.$message.success('删除成功')
            this.refreshTable()
          }
        })
      }).catch(() => {})
      }).catch(() => { })
    },
    // 导出
    handleDown (row) {
    handleDown(row) {
      let randomNum = Math.random();
      finalReportQuarter({quarterId: row.quarterId, random: randomNum}).then(res => {
      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 => {
      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) {
    deleteYearInfo(row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        deleteSpotCheckYear({yearId: row.yearId}).then(res => {
        deleteSpotCheckYear({ yearId: row.yearId }).then(res => {
          if (res.code === 200) {
            this.$message.success('删除成功')
            this.refreshTable()
          }
        })
      }).catch(() => {})
      }).catch(() => { })
    },
    // 查看年度详情
    viewYearInfo (row) {
    viewYearInfo(row) {
      this.operationType = 'view'
      this.getUserList()
      this.yearSampleDia = true
      this.yearRow = row
      getSpotCheckYear({yearId: row.yearId}).then(res => {
      getSpotCheckYear({ yearId: row.yearId }).then(res => {
        if (res.code === 200) {
          this.currentYear = res.data.yearHead
          this.yearItems = res.data.yearItems
@@ -508,11 +511,11 @@
      })
    },
    // 编辑年度抽样
    editYearForm (row) {
    editYearForm(row) {
      this.operationType = 'edit'
      this.getUserList()
      this.yearSampleDia = true
      getSpotCheckYear({yearId: row.yearId}).then(res => {
      getSpotCheckYear({ yearId: row.yearId }).then(res => {
        if (res.code === 200) {
          this.currentYear = res.data.yearHead
          this.yearItems = res.data.yearItems
@@ -529,7 +532,7 @@
      })
    },
    // 提交年度计划
    handleSample () {
    handleSample() {
      if (this.operationType === 'add') {
        this.yearSampleForm.yearItems = JSON.parse(JSON.stringify(this.yearItems))
        this.yearSampleForm.yearHead = this.currentYear
@@ -543,7 +546,7 @@
          }
        })
      } else {
        const params = {...this.editYearFormRow}
        const params = { ...this.editYearFormRow }
        if (params.countersignUser != null) {
          params.countersignUser = params.countersignUser.join(',')
        }
@@ -568,22 +571,22 @@
        })
      }
    },
    yearSample (type) {
    yearSample(type) {
      this.operationType = type
      const currentDate = new Date();
      this.yearSampleDia = true
      this.currentYear = currentDate.getFullYear() + '年年度抽检计划'
    },
    // 添加年度计划
    addQuarter () {
    addQuarter() {
      this.yearItems.push({})
    },
    // 清空抽样计划
    clearTable () {
    clearTable() {
      this.yearItems = []
    },
    // 手动删除
    deleteScope (index) {
    deleteScope(index) {
      this.yearItems.splice(index, 1)
    },
    // 切换下单tab表格
@@ -594,7 +597,7 @@
      }
      this.refreshTable()
    },
    closeYearSampleDia () {
    closeYearSampleDia() {
      this.yearSampleForm = {
        tableRemark: '',
        remark: ''
@@ -602,10 +605,10 @@
      this.yearItems = []
      this.yearSampleDia = false
    },
    getStyle(){
      return 'height: calc(100% - '+'44'+'px)'
    getStyle() {
      return 'height: calc(100% - ' + '44' + 'px)'
    },
    getUserList(){
    getUserList() {
      selectUserCondition({ type: 0 }).then((res) => {
        this.userList = res.data;
      })