ソースを参照

10-15初步完成入库管理和出库管理

shaogen1995 4 年 前
コミット
977f9f61cf

+ 4 - 1
src/App.vue

@@ -1,6 +1,9 @@
 <template>
   <div id="app">
-    <Router-view/>
+               <keep-alive>
+                  <router-view v-if="$route.meta.keepAlive"></router-view>
+            </keep-alive>
+    <Router-view v-if="!$route.meta.keepAlive"/>
   </div>
 </template>
 

+ 8 - 0
src/apis/holding2.js

@@ -50,3 +50,11 @@ export const holding1Audit = (data) => {
     data
   })
 }
+// holding2_look点击归还
+export const goodsReturn = (data) => {
+  return axios({
+    method: 'post',
+    url: '/cms/storageOut/goodsReturn',
+    data
+  })
+}

+ 1 - 1
src/router/index.js

@@ -114,7 +114,7 @@ const router = new VueRouter({
         {
           name: 'holding3',
           path: 'holding3',
-          meta: { myInd: 1 },
+          meta: { myInd: 1, keepAlive: true },
           component: () => import('@/views/holding/holding3.vue')
         },
         {

+ 2 - 2
src/utils/request.js

@@ -1,8 +1,8 @@
 import axios from 'axios'
 // export const baseURL = '666初始地址'
 const service = axios.create({
-  baseURL: 'http://192.168.0.135:8006',
-  // baseURL: '',
+  // baseURL: 'http://192.168.0.135:8006',
+  baseURL: '',
   timeout: 5000
 })
 

+ 1 - 1
src/views/holding/holding2_audit.vue

@@ -56,7 +56,7 @@
             </el-table-column>
             <el-table-column prop="integrity" label="完残程度" width="180">
             </el-table-column>
-            <el-table-column prop="name" label="藏品位置" width="300">
+            <el-table-column prop="outPath" label="出库位置" width="300">
             </el-table-column>
           </el-table>
         </div>

+ 48 - 14
src/views/holding/holding2_look.vue

@@ -33,7 +33,7 @@
         <!-- 表格 -->
         <div class="table">
           <div class="title">
-            <h3>藏品信息<el-button >归 还</el-button></h3>
+            <h3>藏品信息<el-button @click="goodsReturn">归 还</el-button></h3>
           </div>
           <el-table
             @selection-change="handleSelectionChange"
@@ -63,7 +63,7 @@
             </el-table-column>
             <el-table-column prop="status" label="状态" width="180">
             </el-table-column>
-            <el-table-column prop="name" label="出库位置" width="300">
+            <el-table-column prop="outPath" label="出库位置" width="300">
             </el-table-column>
           </el-table>
         </div>
@@ -77,11 +77,11 @@
 </template>
 
 <script>
-import { getDetailById } from '@/apis/holding2'
+import { getDetailById, goodsReturn } from '@/apis/holding2'
 import axios from '@/utils/request'
 import TabList from '@/components/tabLeft.vue'
 export default {
-  name: 'holding2_result',
+  name: 'holding2_look',
   components: { TabList },
   data () {
     // 这里存放数据
@@ -89,6 +89,8 @@ export default {
       myData: {},
       // 服务器初始地址前缀
       baseURL: '',
+      // 小商品id集合数组
+      goodsIds: [],
       // 点击查看显示弹窗
       isShow: false,
       fromData: {
@@ -116,31 +118,63 @@ export default {
       ]
       return list.filter(v => id === v.id)[0].name
     },
+    // 点击归还
+    goodsReturn () {
+      if (this.goodsIds.length === 0) return this.$message.warning('至少选中一个!')
+      this.$confirm('确定归还吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(async () => {
+        const obj = { id: Number(this.myData.id), goodsIds: this.goodsIds.join(',') }
+        const res = await goodsReturn(obj)
+        // console.log(99999, res)
+        if (res.code === 0) {
+          this.$message.success('操作成功')
+          this.getDetailById()
+        } else this.$message.error('错误')
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消'
+        })
+      })
+    },
     // 表格的多选
     handleSelectionChange (rows) {
-      console.log(333, rows)
+      // console.log(333, rows)
+      const temp = []
+      rows.forEach(v => {
+        temp.push(v.id)
+      })
+      const temp2 = new Set(temp)
+      this.goodsIds = [...temp2]
     },
     selectable (row, index) {
-      console.log(row.status)
+      // console.log(row.status)
       if (row.status === '已归还') return false
       else return true
+    },
+    // 封装通过ID获取详情方法
+    async getDetailById () {
+      const res = await getDetailById(this.myData.id)
+      this.tableData = res.data.goods
+      this.tableData.forEach(v => {
+        v.integrity = this.spoil(v.integrity)
+        v.goodsTypeId = this.category(v.goodsTypeId)
+        v.status = this.myStatus(v.status)
+      })
     }
   },
   // 生命周期 - 创建完成(可以访问当前this实例)
   created () {},
   // 生命周期 - 挂载完成(可以访问DOM元素)
-  async mounted () {
+  mounted () {
     // 获取服务器前缀地址
     this.baseURL = axios.defaults.baseURL
     // 从第一层拿到传过来的数据
     this.myData = this.$route.query
-    const res = await getDetailById(this.myData.id)
-    this.tableData = res.data.goods
-    this.tableData.forEach(v => {
-      v.integrity = this.spoil(v.integrity)
-      v.goodsTypeId = this.category(v.goodsTypeId)
-      v.status = this.myStatus(v.status)
-    })
+    this.getDetailById()
   },
   beforeCreate () {}, // 生命周期 - 创建之前
   beforeMount () {}, // 生命周期 - 挂载之前

+ 4 - 3
src/views/holding/holding3.vue

@@ -78,7 +78,7 @@
               </el-table-column>
               <el-table-column prop="textureType" sortable label="质地" width="220">
               </el-table-column>
-              <el-table-column prop="isStorage" label="状态" width="130">
+              <el-table-column prop="status" label="状态" width="130">
               </el-table-column>
               <el-table-column label="操作" width="130">
                 <template #default="{row}">
@@ -182,8 +182,9 @@ export default {
       this.tableData.forEach(v => {
         if (v.textureType === 0) v.textureType = '单一质地'
         else v.textureType = '复合质地'
-        if (v.isStorage === 0) v.isStorage = '未入库'
-        else v.isStorage = '已入库'
+        if (v.status === 0) v.status = '待入库'
+        else if (v.status === 1) v.status = '已入库'
+        else v.status = '已出库'
         v.numTypeId = this.mycategory(v.numTypeId)
         v.integrity = this.spoil(v.integrity)
         v.repair = this.mySave(v.repair)

+ 2 - 2
src/views/holding/holding3_look.vue

@@ -18,8 +18,8 @@
         <div class="conten_right">
           <div class="title">
             <h3>{{ myObj.name }}</h3>
-            <div v-if="myObj.status==='1'">已入库</div>
-            <div v-else-if="myObj.status==='0'" style="background-color: #ccc;">待入库</div>
+            <div v-if="myObj.status==='已入库'">已入库</div>
+            <div v-else-if="myObj.status==='待入库'" style="background-color: #ccc;">待入库</div>
             <div v-else style="background-color: #85ce61;">已出库</div>
           </div>
           <div class="info">