2545307760@qq.com 1 gadu atpakaļ
vecāks
revīzija
190f9cc305

+ 0 - 8
web/src/api/storehouse.js

@@ -335,14 +335,6 @@ export const updateGoods = (data) => {
   })
 }
 
-//删除货物
-export const deleteGoods = (id) => {
-  return service({
-    url: '/goods/deleteGoods?id=' + id,
-    method: 'DELETE'
-  })
-}
-
 // 查询所有货单
 export const queryAllManifest = () => {
   return service({

+ 71 - 90
web/src/view/storehouse/commodity/commodity.vue

@@ -5,39 +5,43 @@
       style="line-height: 60px"
     >
       <el-row>
-        <el-col :span="18">
+        <el-col :span="19">
           <el-form
             inline
             style="margin-top: 10px"
           >
             <el-form-item label="名称">
               <el-input
-                v-model="searchCommodity.name"
+                v-model="queryGoodsData.name"
                 placeholder="请输入名称"
               />
             </el-form-item>
             <el-form-item label="类型">
               <el-cascader
+                  clearable
+                  @clear="queryGoodsData.genre = 0"
                   :options="goodsTypeData"
+                  @change="changeQueryGoodsType"
                   :props="goodsTypeProps"/>
             </el-form-item>
             <el-form-item label="特征">
               <el-input
                   placeholder="请输入特征"
+                  v-model="queryGoodsData.characteristic"
               />
             </el-form-item>
-            <el-form-item label="特征">
+            <el-form-item label="规格">
               <el-input
-                  placeholder="请输入特征"
+                  placeholder="请输入规格"
+                  v-model="queryGoodsData.specifications"
               />
             </el-form-item>
             <el-form-item>
-              <el-button @click="getData" type="primary" icon="Search">搜索</el-button>
+              <el-button @click="searchData" type="primary" icon="Search">搜索</el-button>
             </el-form-item>
           </el-form>
-
         </el-col>
-        <el-col :span="6">
+        <el-col :span="5">
           <el-button
               @click="inboundDialog = true"
           >入库</el-button>
@@ -85,19 +89,14 @@
               type="primary"
               @click="openGoodsEdit(scope.row)"
             >编辑</el-button>
-            <el-button
-              size="small"
-              type="danger"
-              @click="goodsDelete(scope.row)"
-            >删除</el-button>
           </template>
         </el-table-column>
       </el-table>
       <!--      分页-->
       <div class="gva-pagination">
         <el-pagination
-          :current-page="searchCommodity.pageInfo.page"
-          :page-size="searchCommodity.pageInfo.pageSize"
+          :current-page="queryGoodsData.pageInfo.page"
+          :page-size="queryGoodsData.pageInfo.pageSize"
           :page-sizes="[10, 30, 50, 100]"
           :total="total"
           layout="total, sizes, prev, pager, next, jumper"
@@ -458,17 +457,17 @@
         </div>
       </el-drawer>
 <!--      出库-->
-      <el-drawer v-model="outboundDialog">
+      <el-drawer v-model="outboundDialog" size="50%" title="新建出库单">
         <el-header
             class="gva-search-box"
             style="height: 30px;line-height: 30px;"
         >
-          <el-button type="primary" @click="addGoods">添加货品</el-button>
-          <el-button type="danger" @click="reduceGoods">减少货品</el-button>
+          <el-button type="primary" @click="outAddGoods">添加货品</el-button>
+          <el-button type="danger" @click="outReduceGoods">减少货品</el-button>
         </el-header>
         <el-main>
           <el-table
-              :data="storeData.cargos"
+              :data="outboundData.cargos"
               height="500"
               border
               style="width: 100%;margin-bottom: 20px"
@@ -500,6 +499,11 @@
                 />
               </template>
             </el-table-column>
+            <el-table-column label="购买价格">
+              <template #default="{ row }">
+                <el-input v-model.number="row.buyingPrice" type="number"/>
+              </template>
+            </el-table-column>
           </el-table>
           <el-form inline>
             <el-form-item
@@ -507,7 +511,7 @@
                 prop="title"
             >
               <el-input
-                  v-model="storeData.title"
+                  v-model="outboundData.title"
                   style="width: 200px;"
               />
             </el-form-item>
@@ -516,7 +520,7 @@
                 prop="custodian"
             >
               <el-input
-                  v-model="storeData.custodian"
+                  v-model="outboundData.custodian"
                   style="width: 200px;"
               />
             </el-form-item>
@@ -525,15 +529,15 @@
                 prop="custodian"
             >
               <el-input
-                  v-model="storeData.remarks"
+                  v-model="outboundData.remarks"
                   style="width: 200px;"
               />
             </el-form-item>
             <el-form-item>
               <el-button
                   type="primary"
-                  @click="submitInboundForm"
-              >提交库</el-button>
+                  @click="submitOutboundForm"
+              >提交库</el-button>
             </el-form-item>
           </el-form>
         </el-main>
@@ -543,28 +547,22 @@
 </template>
 
 <script setup>
-import { ref, onMounted, computed, reactive } from 'vue'
+import { ref, onMounted, reactive } from 'vue'
 import {
-  createCommodity,
-  createCommodityGenre, deleteCommodity,
-  deleteCommodityGenre,
-  queryAllCommodityGenre,
-  queryGoodsType, updateCommodity,deleteGoodsType,
-  updateCommodityGenre,
+  queryGoodsType,deleteGoodsType,
   createGoodsType,
   updateGoodsType,
-  queryAllGoods,
   createGoods,
   queryGoodsList,
   updateGoods,
-  deleteGoods,
-  createInboundManifest
+  createInboundManifest,
+  createOutboundManifest
 } from '@/api/storehouse'
 import { ElMessage, ElMessageBox } from 'element-plus'
 
 const goodsTypeProps = {
   label: 'name',
-  value: 'ID'
+  value: 'ID',
 }
 
 const handleChange = (value) => {
@@ -599,7 +597,7 @@ const storeData = reactive({
   remarks: ''
 })
 const submitInboundForm = async () => {
-  if (!validateInboundForm()) return
+  if (!validateInboundForm(storeData)) return
   await createInboundManifest(storeData).then(res => {
     if (res.code === 0) {
       ElMessage.success('添加成功')
@@ -612,6 +610,18 @@ const submitInboundForm = async () => {
 //出库
 const outboundDialog = ref(false)
 
+const outAddGoods = () => {
+  outboundData.cargos.push({goodsId: null, number: 1, buyingPrice: 0})
+}
+
+const outReduceGoods = () => {
+  if (outboundData.cargos.length > 1) {
+    outboundData.cargos.pop()
+  } else {
+    console.log('只剩一项')
+  }
+}
+
 const outboundData = reactive({
   manifestGenre: '出库',
   title: '',
@@ -623,21 +633,19 @@ const outboundData = reactive({
 })
 
 const submitOutboundForm = async () => {
-  if (!validateInboundForm()) return
-  await createInboundManifest(storeData).then(res => {
+  if (!validateInboundForm(outboundData)) return
+  await createOutboundManifest(outboundData).then(res => {
     if (res.code === 0) {
-      ElMessage.success('添加成功')
+      ElMessage.success('出库成功')
       getData()
-      inboundDialog.value = false
+      outboundDialog.value = false
     }
   })
 }
 
-const validateInboundForm = () => {
-  const data = storeData
-
+const validateInboundForm = (data) => {
   if (!data.title.trim()) {
-    ElMessage.warning('请输入入库单标题')
+    ElMessage.warning('请输入标题')
     return false
   }
 
@@ -671,17 +679,9 @@ const validateInboundForm = () => {
 
 const goodsListData = reactive([])
 
-const searchCommodity = ref({
-  pageInfo: {
-    page: 1,
-    pageSize: 10,
-  },
-  name: ''
-})
-
 const total = ref(0)
 // 货物类型
-const goodsTypeData = reactive([])
+const goodsTypeData = ref([])
 // 新增货物类型
 const createGoodsTypeData = reactive({
   name: "",
@@ -757,9 +757,7 @@ const omitGoodsType = (val) => {
       }
   )
       .then(async() => {
-        console.log('删除id', val.ID)
         await deleteGoodsType(val.ID).then(res => {
-          console.log(res)
           if (res.code === 0) {
             ElMessage.success('删除成功')
             getData()
@@ -794,7 +792,6 @@ const goodsAddSubmit = async() => {
     return
   }
   await createGoods(goodsAddDate).then(res => {
-    console.log(res)
     if (res.code === 0) {
       ElMessage.success('新增成功')
       isOpenGoodsAdd.value = false
@@ -817,26 +814,38 @@ const queryGoodsData = reactive({
   specifications: ""
 })
 
+const changeQueryGoodsType = (val) => {
+  queryGoodsData.genre= val[1]
+}
+
 // 分页
 const handleSizeChange = (val) => {
-  searchCommodity.value.pageSize = val
+  queryGoodsData.pageSize = val
   getData()
 }
 
 const handleCurrentChange = (val) => {
-  searchCommodity.value.page = val
+  queryGoodsData.page = val
   getData()
 }
 
+const searchData = async () => {
+  queryGoodsData.page = 1
+  queryGoodsData.pageSize = 10
+  await queryGoodsList(queryGoodsData).then(res => {
+    if (res.code === 0) {
+      goodsListData.length = 0
+      goodsListData.push(...res.data.list)
+    }
+  })
+}
+
 // 获取数据
 const getData = async() => {
-  // await queryAllCommodityGenre().then(res => {
-  //   commodityGenreAllData.value = res.data
-  // })
   await queryGoodsType().then(res => {
     if (res.code === 0) {
-      goodsTypeData.length = 0
-      goodsTypeData.push(...res.data)
+      goodsTypeData.value.length = 0
+      goodsTypeData.value = res.data
     }
   })
   await queryGoodsList(queryGoodsData).then(res => {
@@ -891,34 +900,6 @@ const editGoodsSubmit = async() => {
   })
 }
 
-const goodsDelete = async(val) => {
-  ElMessageBox.confirm(
-    '将永久删除该信息。是否继续?',
-    '删除',
-    {
-      confirmButtonText: '确定',
-      cancelButtonText: '取消',
-      type: 'warning',
-    }
-  )
-    .then(async() => {
-      await deleteGoods(val.ID).then(res => {
-        if (res.code === 0) {
-          ElMessage.success('删除成功')
-          getData()
-        } else {
-          ElMessage.error('删除失败')
-        }
-      })
-    })
-    .catch(() => {
-      ElMessage({
-        type: 'info',
-        message: '删除已取消',
-      })
-    })
-}
-
 onMounted(() => {
   getData()
 })