spring
2025-09-17 265820c7f0df74a1c69308dcc2b1b61812ccd892
src/views/procurementManagement/arrivalManagement/index.vue
@@ -18,7 +18,6 @@
    <el-card class="table-card" shadow="never">
      <div class="table-header">
        <el-button type="primary" @click="openDialog('add')">新增到货</el-button>
        <el-button type="success" @click="handleBatchReceive">批量收货</el-button>
        <el-button type="danger" @click="handleBatchDelete">批量删除</el-button>
      </div>
@@ -37,23 +36,34 @@
        <el-table-column label="操作" width="200" align="center">
          <template #default="{ row }">
            <el-button type="primary" link @click="openDialog('edit', row)">编辑</el-button>
            <el-button type="success" link @click="handleReceive(row)">收货</el-button>
            <el-button type="success" v-if="row.status === 'pending'" link @click="handleReceive(row)">收货</el-button>
            <el-button type="danger" link @click="handleDelete(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <pagination
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          :page="pagination.current"
          :limit="pagination.size"
          @pagination="handleCurrentChange"
      />
    </el-card>
    <el-dialog v-model="dialogVisible" :title="dialogType === 'add' ? '新增到货' : '编辑到货'" width="600px">
      <el-form :model="formData" label-width="120px">
        <el-form-item label="到货单号">
          <el-input v-model="formData.arrivalNo" placeholder="到货单号" />
        </el-form-item>
        <el-form-item label="采购订单号">
          <el-select v-model="formData.orderNo" placeholder="请选择采购订单" style="width: 100%">
            <el-option label="PO20241201001" value="PO20241201001" />
            <el-option label="PO20241201002" value="PO20241201002" />
          </el-select>
          <el-input v-model="formData.orderNo" placeholder="采购订单号" />
        </el-form-item>
        <el-form-item label="供应商名称">
          <el-input v-model="formData.supplierName" placeholder="供应商名称" readonly />
          <el-input v-model="formData.supplierName" placeholder="供应商名称" />
        </el-form-item>
        <el-form-item label="到货数量">
          <el-input-number  :min="0" v-model="formData.arrivalQuantity" placeholder="到货数量" />
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="请输入备注信息" />
@@ -68,8 +78,40 @@
</template>
<script setup>
import { ref, reactive } from 'vue'
import { ref, reactive,onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {listPage,add,update,del} from "@/api/procurementManagement/arrivalManagement.js"
import Pagination from '@/components/PIMTable/Pagination.vue'
onMounted(() => {
    getList()
})
const tableData = ref([])
const getList = () => {
  loading.value = true
  listPage({...searchForm,...pagination}).then(res =>{
    if(res.code === 200){
      tableData.value = res.data.records
      total.value = res.data.total
      loading.value = false
    }
  })
}
const pagination = reactive({
  current: 1,
  size: 10
})
const total = ref(0)
const handleCurrentChange = (val) => {
  pagination.current = val.page
  pagination.size = val.limit
  getList()
}
const loading = ref(false)
const dialogVisible = ref(false)
@@ -82,25 +124,13 @@
})
const formData = reactive({
  arrivalNo: '',
  arrivalQuantity: 0,
  orderNo: '',
  supplierName: '',
  remark: ''
  remark: '',
  status: 'pending'
})
const mockData = [
  {
    id: 1,
    arrivalNo: 'AR20241201001',
    orderNo: 'PO20241201001',
    supplierName: '供应商A',
    status: 'received',
    arrivalQuantity: 250,
    arrivalTime: '2024-12-01 15:30:00',
    remark: '正常到货'
  }
]
const tableData = ref([...mockData])
const getStatusType = (status) => {
  const statusMap = { pending: 'warning', received: 'success', stored: 'info' }
@@ -114,7 +144,7 @@
const handleSearch = () => {
  loading.value = true
  setTimeout(() => { loading.value = false }, 500)
  getList()
}
const resetSearch = () => {
@@ -124,34 +154,45 @@
const openDialog = (type, row = {}) => {
  dialogType.value = type
  if (type === 'edit' && row.id) {
    Object.assign(formData, { orderNo: row.orderNo, supplierName: row.supplierName, remark: row.remark })
    obj.id = row.id
    Object.assign(formData, { orderNo: row.orderNo, supplierName: row.supplierName, remark: row.remark, arrivalQuantity: row.arrivalQuantity,arrivalNo: row.arrivalNo })
  } else {
    Object.assign(formData, { orderNo: '', supplierName: '', remark: '' })
    Object.assign(formData, { orderNo: '', supplierName: '', remark: '',arrivalQuantity: 0,arrivalNo: '' })
  }
  dialogVisible.value = true
}
const obj = reactive({
  id:''
})
const handleSubmit = () => {
  if (dialogType.value === 'add') {
    const newArrival = {
      id: Date.now(),
      arrivalNo: `AR${Date.now()}`,
      orderNo: formData.orderNo,
      supplierName: formData.supplierName,
      status: 'pending',
      arrivalQuantity: 0,
      arrivalTime: new Date().toLocaleString(),
      remark: formData.remark
    }
    tableData.value.unshift(newArrival)
    ElMessage.success('新增成功')
    add(formData).then(res => {
      if(res.code === 200){
        ElMessage.success('新增成功')
        getList()
      }
    })
  }else{
    update({...formData, ...obj}).then(res => {
      if(res.code === 200){
        ElMessage.success('编辑成功')
        getList()
      }
    })
  }
  dialogVisible.value = false
}
const handleReceive = (row) => {
  row.status = 'received'
  ElMessage.success('收货成功')
  update(row).then(res => {
    if(res.code === 200){
      ElMessage.success('收货成功')
      getList()
    }
  })
}
const handleDelete = (row) => {
@@ -160,20 +201,30 @@
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    const index = tableData.value.findIndex(item => item.id === row.id)
    if (index !== -1) {
      tableData.value.splice(index, 1)
      ElMessage.success('删除成功')
    }
    let ids = [row.id]
    del(ids).then(res => {
      if(res.code === 200){
        ElMessage.success('删除成功')
        getList()
      }
    })
  })
}
const handleBatchReceive = () => {
  ElMessage.success('批量收货成功')
}
const handleBatchDelete = () => {
  ElMessage.success('批量删除成功')
  ElMessageBox.confirm('确定要删除选中的记录吗?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    let ids = selectedRows.value.map(item => item.id)
    del(ids).then(res => {
      if(res.code === 200){
        ElMessage.success('删除成功')
        getList()
      }
    })
  })
}
const handleSelectionChange = (rows) => {