|
@@ -0,0 +1,360 @@
|
|
|
+<template>
|
|
|
+ <el-container>
|
|
|
+ <el-header
|
|
|
+ class="gva-search-box"
|
|
|
+ style="line-height: 60px"
|
|
|
+ >
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-form
|
|
|
+ inline
|
|
|
+ style="margin-top: 10px"
|
|
|
+ >
|
|
|
+ <el-form-item label="名称">
|
|
|
+ <el-input
|
|
|
+ v-model="searchStorageArea.name"
|
|
|
+ placeholder="请输入名称"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="库区类型">
|
|
|
+ <el-select
|
|
|
+ v-model="searchStorageArea.genre"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 180px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in storageAreaGenreAllData"
|
|
|
+ :key="item.ID"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.ID"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="仓库">
|
|
|
+ <el-select
|
|
|
+ v-model="searchStorageArea.warehouseId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 180px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in warehouseAllData"
|
|
|
+ :key="item.ID"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.ID"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button @click="getData">搜索</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="isOpenStorageAreaAdd = true"
|
|
|
+ >新增仓区</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-header>
|
|
|
+ <el-main>
|
|
|
+ <el-table
|
|
|
+ :data="StorageAreaListData"
|
|
|
+ style="min-height: 550px;"
|
|
|
+ >
|
|
|
+ <el-table-column
|
|
|
+ prop="name"
|
|
|
+ label="库区名称"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ prop="storageAreaGenre.name"
|
|
|
+ label="库区类型"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ prop="warehouse.name"
|
|
|
+ label="所属仓库"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="是否启用"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <el-switch
|
|
|
+ v-model="scope.row.isEffective"
|
|
|
+ style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
|
|
|
+ @change="changeIsEffective(scope.row)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="openStorageAreaEdit(scope.row)"
|
|
|
+ >编辑</el-button>
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ @click="StorageAreaDelete(scope.row)"
|
|
|
+ >删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <!-- 分页-->
|
|
|
+ <div class="gva-pagination">
|
|
|
+ <el-pagination
|
|
|
+ :current-page="searchStorageArea.pageInfo.page"
|
|
|
+ :page-size="searchStorageArea.pageInfo.pageSize"
|
|
|
+ :page-sizes="[10, 30, 50, 100]"
|
|
|
+ :total="total"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <!-- 修改-->
|
|
|
+ <el-drawer
|
|
|
+ v-model="isOpenStorageAreaEdit"
|
|
|
+ title="修改仓库信息"
|
|
|
+ direction="rtl"
|
|
|
+ size="30%"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <el-form
|
|
|
+ v-model="StorageAreaEditData"
|
|
|
+ label-position="left"
|
|
|
+ label-width="auto"
|
|
|
+ style="max-width: 400px"
|
|
|
+ >
|
|
|
+ <el-form-item label="库区名称">
|
|
|
+ <el-input v-model="StorageAreaEditData.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="库区类型">
|
|
|
+ <el-select
|
|
|
+ v-model="StorageAreaEditData.genre"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 240px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in storageAreaGenreAllData"
|
|
|
+ :key="item.ID"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.ID"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="仓库">
|
|
|
+ <el-select
|
|
|
+ v-model="StorageAreaEditData.warehouseId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 240px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in warehouseAllData"
|
|
|
+ :key="item.ID"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.ID"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="StorageAreaEditSubmit"
|
|
|
+ >提交</el-button>
|
|
|
+ <el-button @click="isOpenStorageAreaEdit = false">关闭</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </el-drawer>
|
|
|
+ <el-drawer
|
|
|
+ v-model="isOpenStorageAreaAdd"
|
|
|
+ title="新增仓库信息"
|
|
|
+ direction="rtl"
|
|
|
+ size="30%"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <el-form
|
|
|
+ v-model="StorageAreaAddData"
|
|
|
+ label-position="left"
|
|
|
+ label-width="auto"
|
|
|
+ style="max-width: 400px"
|
|
|
+ >
|
|
|
+ <el-form-item label="库区名称">
|
|
|
+ <el-input v-model="StorageAreaAddData.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="库区类型">
|
|
|
+ <el-select
|
|
|
+ v-model="StorageAreaAddData.genre"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 240px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in storageAreaGenreAllData"
|
|
|
+ :key="item.ID"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.ID"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="仓库">
|
|
|
+ <el-select
|
|
|
+ v-model="StorageAreaAddData.warehouseId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 240px"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in warehouseAllData"
|
|
|
+ :key="item.ID"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.ID"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="StorageAreaAddSubmit"
|
|
|
+ >提交</el-button>
|
|
|
+ <el-button @click="isOpenStorageAreaAdd = false">关闭</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </el-drawer>
|
|
|
+ </el-main>
|
|
|
+ </el-container>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { ref, onMounted } from 'vue'
|
|
|
+import {
|
|
|
+ createStorageArea,
|
|
|
+ deleteStorageArea, queryAllStorageAreaGenre, queryAllWarehouse,
|
|
|
+ queryStorageAreaList,
|
|
|
+ switchStorageArea,
|
|
|
+ updateStorageArea
|
|
|
+} from '@/api/storehouse'
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+
|
|
|
+const searchStorageArea = ref({
|
|
|
+ pageInfo: {
|
|
|
+ page: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ },
|
|
|
+ name: '',
|
|
|
+ genre: '',
|
|
|
+ warehouseId: '',
|
|
|
+})
|
|
|
+
|
|
|
+const StorageAreaListData = ref([])
|
|
|
+const total = ref(0)
|
|
|
+const warehouseAllData = ref()
|
|
|
+const storageAreaGenreAllData = ref()
|
|
|
+
|
|
|
+const getData = async() => {
|
|
|
+ // 假设有接口来获取数据
|
|
|
+ await queryStorageAreaList(searchStorageArea.value).then(res => {
|
|
|
+ StorageAreaListData.value = res.data.list
|
|
|
+ total.value = res.data.total
|
|
|
+ })
|
|
|
+ await queryAllWarehouse().then(res => {
|
|
|
+ warehouseAllData.value = res.data
|
|
|
+ })
|
|
|
+ await queryAllStorageAreaGenre().then(res => {
|
|
|
+ storageAreaGenreAllData.value = res.data
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 分页
|
|
|
+const handleSizeChange = (val) => {
|
|
|
+ searchStorageArea.value.pageSize = val
|
|
|
+ getData()
|
|
|
+}
|
|
|
+
|
|
|
+const handleCurrentChange = (val) => {
|
|
|
+ searchStorageArea.value.page = val
|
|
|
+ getData()
|
|
|
+}
|
|
|
+
|
|
|
+const changeIsEffective = async(row) => {
|
|
|
+ await switchStorageArea(row).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const isOpenStorageAreaEdit = ref(false)
|
|
|
+const StorageAreaEditData = ref()
|
|
|
+const openStorageAreaEdit = (val) => {
|
|
|
+ isOpenStorageAreaEdit.value = true
|
|
|
+ StorageAreaEditData.value = val
|
|
|
+}
|
|
|
+
|
|
|
+const StorageAreaEditSubmit = async() => {
|
|
|
+ if (StorageAreaEditData.value.name === '') {
|
|
|
+ ElMessage.error('库房名称不能为空')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ await updateStorageArea(StorageAreaEditData.value).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success(res.msg)
|
|
|
+ } else {
|
|
|
+ ElMessage.error('编辑失败')
|
|
|
+ }
|
|
|
+ isOpenStorageAreaEdit.value = false
|
|
|
+ getData()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const StorageAreaDelete = (val) => {
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ '将永久删除该信息。是否继续?',
|
|
|
+ '删除',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(async() => {
|
|
|
+ await deleteStorageArea(val).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ getData()
|
|
|
+ } else {
|
|
|
+ ElMessage.error('删除失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ ElMessage({
|
|
|
+ type: 'info',
|
|
|
+ message: '删除已取消',
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const StorageAreaAddData = ref({
|
|
|
+ name: '',
|
|
|
+ location: '',
|
|
|
+ head: '',
|
|
|
+ remarks: '',
|
|
|
+})
|
|
|
+
|
|
|
+const isOpenStorageAreaAdd = ref(false)
|
|
|
+const StorageAreaAddSubmit = async() => {
|
|
|
+ if (StorageAreaAddData.value.name === '') {
|
|
|
+ ElMessage.error('库房名称不能为空')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ await createStorageArea(StorageAreaAddData.value).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success(res.msg)
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg)
|
|
|
+ }
|
|
|
+ isOpenStorageAreaAdd.value = false
|
|
|
+ getData()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getData()
|
|
|
+})
|
|
|
+</script>
|