src/views/inventoryManagement/stockManagement/Unqualified.vue
@@ -7,7 +7,16 @@
                  style="width: 240px"
                  placeholder="请输入"
                  clearable/>
        <span class="search_title ml10">质检状态:</span>
        <el-select v-model="searchForm.type"
                  style="width: 240px"
                  placeholder="请选择"
                  clearable>
          <el-option label="合格" :value="0" />
          <el-option label="不合格" :value="1" />
        </el-select>
        <el-button type="primary" @click="handleQuery" style="margin-left: 10px">搜索</el-button>
        <el-button @click="handleReset">重置</el-button>
      </div>
      <div>
         <el-button type="primary" @click="isShowNewModal = true">新增库存</el-button>
@@ -20,16 +29,28 @@
        :row-class-name="tableRowClassName" height="calc(100vh - 18.5em)">
        <el-table-column align="center" type="selection" width="55" />
        <el-table-column align="center" label="序号" type="index" width="60" />
        <el-table-column label="入库日期" prop="createTime" show-overflow-tooltip />
        <el-table-column label="产品大类" prop="productName" show-overflow-tooltip />
        <el-table-column label="规格型号" prop="model" show-overflow-tooltip />
        <el-table-column label="单位" prop="unit" show-overflow-tooltip />
        <el-table-column label="库存数量" prop="qualitity" show-overflow-tooltip />
        <el-table-column label="库存预警数量" prop="warnNum"  show-overflow-tooltip />
        <el-table-column label="质检状态"
                         prop="type"
                         show-overflow-tooltip
                         width="100">
          <template #default="scope">
            <el-tag :type="scope.row.type == 0 ? 'success' : 'danger'" size="small">
              {{ scope.row.type == 0 ? '合格' : '不合格' }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="冻结数量" prop="lockedQuantity" show-overflow-tooltip />
        <el-table-column label="备注" prop="remark"  show-overflow-tooltip />
        <el-table-column label="最近更新时间" prop="updateTime" show-overflow-tooltip />
        <el-table-column fixed="right" label="操作" min-width="60" align="center">
          <template #default="scope">
            <el-button link type="primary" size="small" @click="showSubtractModal(scope.row)" :disabled="scope.row.qualitity === 0">领用</el-button>
            <el-button link type="primary" size="small" @click="showSubtractModal(scope.row)" :disabled="scope.row.unLockedQuantity === 0">领用</el-button>
            <el-button link type="primary" size="small" v-if="scope.row.unLockedQuantity > 0" @click="showFrozenModal(scope.row)">冻结</el-button>
            <el-button link type="primary" size="small" v-if="scope.row.lockedQuantity > 0" @click="showThawModal(scope.row)">解冻</el-button>
          </template>
        </el-table-column>
      </el-table>
@@ -44,19 +65,37 @@
    <subtract-stock-inventory v-if="isShowSubtractModal"
                 v-model:visible="isShowSubtractModal"
                 :record="record"
                 type="unqualified"
                 @completed="handleQuery" />
    <!-- 冻结/解冻库存-->
    <frozen-and-thaw-stock-inventory v-if="isShowFrozenAndThawModal"
                                     v-model:visible="isShowFrozenAndThawModal"
                                     :record="record"
                                     :operation-type="operationType"
                                     type="unqualified"
                                     @completed="handleQuery" />
  </div>
</template>
<script setup>
import pagination from '@/components/PIMTable/Pagination.vue'
import { ref, reactive, toRefs, onMounted, getCurrentInstance } from 'vue'
import { ref, reactive, toRefs, onMounted, getCurrentInstance, watch } from 'vue'
import { ElMessageBox } from "element-plus";
import { getStockUninventoryListPage } from "@/api/inventoryManagement/stockUninventory.js";
const NewStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/New.vue"));
const SubtractStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/Subtract.vue"));
const FrozenAndThawStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/FrozenAndThaw.vue"));
const { proxy } = getCurrentInstance()
const props = defineProps({
  type: {
    type: Number,
    required: true,
    default: 3
  }
})
const tableData = ref([])
const selectedRows = ref([])
const record = ref({})
@@ -70,9 +109,14 @@
const isShowNewModal = ref(false)
// 是否显示领用弹框
const isShowSubtractModal = ref(false)
// 是否显示冻结/解冻弹框
const isShowFrozenAndThawModal = ref(false)
// 操作类型
const operationType = ref('frozen')
const data = reactive({
  searchForm: {
    productName: '',
    type: '',
  }
})
const { searchForm } = toRefs(data)
@@ -83,6 +127,13 @@
  page.current = 1
  getList()
}
/** 重置按钮操作 */
const handleReset = () => {
  searchForm.value.productName = '';
  searchForm.value.type = '';
  handleQuery();
}
const paginationChange = (obj) => {
  page.current = obj.page;
  page.size = obj.limit;
@@ -90,7 +141,11 @@
}
const getList = () => {
  tableLoading.value = true
  getStockUninventoryListPage({ ...searchForm.value, ...page }).then(res => {
  const params = { ...searchForm.value, ...page, productType: props.type };
  if (searchForm.value.type !== "") {
    params.type = searchForm.value.type;
  }
  getStockUninventoryListPage(params).then(res => {
    tableLoading.value = false
    tableData.value = res.data.records
    total.value = res.data.total
@@ -107,6 +162,20 @@
  isShowSubtractModal.value = true
}
// 点击冻结
const showFrozenModal = (row) => {
  record.value = row
  isShowFrozenAndThawModal.value = true
  operationType.value = 'frozen'
}
// 点击解冻
const showThawModal = (row) => {
  record.value = row
  isShowFrozenAndThawModal.value = true
  operationType.value = 'thaw'
}
// 表格选择数据
const handleSelectionChange = (selection) => {
  // 过滤掉子数据
@@ -117,12 +186,12 @@
// 表格行类名
const tableRowClassName = ({ row }) => {
  const stock = Number(row?.inboundNum0 ?? 0);
  const warn = Number(row?.warnNum ?? 0);
  if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
    return '';
  }
  return stock < warn ? 'row-low-stock' : '';
  // const stock = Number(row?.unLockedQuantity ?? 0);
  // const warn = Number(row?.warnNum ?? 0);
  // if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
  //   return '';
  // }
  // return stock < warn ? 'row-low-stock' : '';
};
// 导出
@@ -135,7 +204,12 @@
    type: 'warning',
  }
  ).then(() => {
    proxy.download("/stockin/exportCopy", {}, '库存信息.xlsx')
    const fileNameMap = {
      1: '自制库存信息.xlsx',
      2: '外购库存信息.xlsx',
      3: '委外库存信息.xlsx'
    };
    proxy.download("/stockUninventory/exportStockUninventory", {productType: props.type}, fileNameMap[props.type] || '库存信息.xlsx')
  }).catch(() => {
    proxy.$modal.msg("已取消")
  })
@@ -144,6 +218,11 @@
onMounted(() => {
  getList()
})
watch(() => props.type, () => {
  page.current = 1
  getList()
})
</script>
<style scoped lang="scss">