Просмотр исходного кода

初步完成入库管理新增

shaogen1995 4 лет назад
Родитель
Сommit
c00cce2e77

+ 8 - 0
src/apis/holding1.js

@@ -22,3 +22,11 @@ export const getListTow = (data) => {
     data
   })
 }
+// 从第一层提交
+export const holding1submit = (data) => {
+  return axios({
+    method: 'post',
+    url: '/cms/storageIn/edit',
+    data
+  })
+}

+ 0 - 4
src/views/holding/holding0_add.vue

@@ -267,10 +267,6 @@ export default {
         v.goodsTypeId = this.category(v.goodsTypeId)
         v.integrity = this.spoil(v.integrity)
       })
-    },
-
-    skip (index) {
-      this.$router.push(`/layout/holding${index}`).catch(() => {})
     }
   },
   // 生命周期 - 创建完成(可以访问当前this实例)

+ 6 - 5
src/views/holding/holding1.vue

@@ -48,7 +48,7 @@
               </el-table-column>
               <el-table-column prop="realName" label="登记人" width="150">
               </el-table-column>
-              <el-table-column prop="reason" label="入库说明">
+              <el-table-column prop="description" label="入库说明">
               </el-table-column>
               <el-table-column prop="createTime" label="创建日期" width="180">
               </el-table-column>
@@ -57,10 +57,11 @@
               <el-table-column prop="status" label="状态" width="130">
               </el-table-column>
               <el-table-column label="操作" width="195">
-                <template #default>
-                  <el-button type="text" @click="$router.push('/layout/holding1_look')">查看</el-button>
-                  <el-button type="text" @click="$router.push('/layout/holding1_audit')">审核</el-button>
-                  <el-button type="text" @click="$router.push('/layout/holding1_add')">编辑</el-button>
+                <template #default='{row}'>
+                  <el-button type="text" v-if="row.status==='已完成'||row.status==='待入库'||row.status==='审核不通过'" @click="$router.push('/layout/holding1_look')">查看</el-button>
+                  <el-button type="text" v-if="row.status==='待审核'" @click="$router.push('/layout/holding1_audit')">审核</el-button>
+                  <el-button type="text" v-if="row.status==='待办理'" @click="$router.push('/layout/holding1_add')">编辑</el-button>
+                  <el-button type="text" v-if="row.status!=='已完成'">删除</el-button>
                 </template>
               </el-table-column>
             </el-table>

+ 12 - 12
src/views/holding/holding1_Dialog.vue

@@ -43,7 +43,7 @@
       </el-pagination>
     </div>
     <div slot="footer" class="dialog-footer">
-      <el-button type="primary" @click="cancel">确 定</el-button>
+      <el-button type="primary" @click="btnOK">确 定</el-button>
     </div>
   </el-dialog>
 </template>
@@ -58,9 +58,6 @@ export default {
     dialogFormVisible: {
       type: Boolean,
       default: false
-    },
-    bigId: {
-      type: Number
     }
   },
   data () {
@@ -77,7 +74,9 @@ export default {
       // 服务器前缀地址
       baseURL: '',
       // 表格数据
-      tableData: []
+      tableData: [],
+      // 传递给父元素的表格数据
+      fatabList: []
     }
   },
   // 监听属性 类似于data概念
@@ -113,13 +112,14 @@ export default {
     },
     // 表格的多选
     handleSelectionChange (rows) {
-      const temp = []
-      rows.forEach(v => {
-        temp.push(v.id)
-      })
-      const temp2 = new Set(temp)
-      this.goodsIds = [...temp2]
-      console.log(666, this.goodsIds)
+      // console.log(666, rows)
+      this.fatabList = rows
+    },
+    // 点击确定
+    btnOK () {
+      // 把选中的数据传给父组件
+      this.$emit('getSonList', this.fatabList)
+      this.cancel()
     },
     // 点击取消
     cancel () {

+ 73 - 12
src/views/holding/holding1_add.vue

@@ -56,19 +56,19 @@
             >
               <el-table-column type="selection" width="40"> </el-table-column>
               <el-table-column label="缩略图" width="146">
-                <template #default>
+                <template #default='{row}'>
                   <div class="smimg">
-                    <img src="../../assets/img/user.png" alt="" />
+                    <img :src="baseURL+row.thumb" alt="" />
                   </div>
                 </template>
               </el-table-column>
-              <el-table-column prop="name" label="总登记号" width="235">
+              <el-table-column prop="registerNum" label="总登记号" width="235">
               </el-table-column>
-              <el-table-column prop="address" label="藏品名称">
+              <el-table-column prop="name" label="藏品名称">
               </el-table-column>
-              <el-table-column prop="name" label="类别" width="130">
+              <el-table-column prop="goodsTypeName" label="类别" width="130">
               </el-table-column>
-              <el-table-column prop="name" label="完残程度" width="220">
+              <el-table-column prop="integrity" label="完残程度" width="220">
               </el-table-column>
               <el-table-column label="藏品位置" width="230">
                 <template #default>
@@ -84,17 +84,19 @@
         </div>
         <!-- 最下面的2个按钮 -->
         <div class="bot_btn">
-          <el-button type="primary">提 交</el-button>
-          <el-button @click="$router.go(-1)">返 回</el-button>
+          <el-button type="primary" @click="submit">提 交</el-button>
+          <el-button @click="goBack">返 回</el-button>
         </div>
       </div>
     </div>
     <!-- 点击添加出现弹窗 -->
-    <Holding1Dialog :dialogFormVisible.sync="isShow" ref="myDialog" :bigId='mydata.id'/>
+    <Holding1Dialog :dialogFormVisible.sync="isShow" ref="myDialog" @getSonList='getSonList'/>
   </div>
 </template>
 
 <script>
+import { holding1submit } from '@/apis/holding1'
+import axios from '@/utils/request'
 import TabList from '@/components/tabLeft.vue'
 import Holding1Dialog from './holding1_Dialog.vue'
 export default {
@@ -105,6 +107,10 @@ export default {
   },
   data () {
     return {
+      // 处理从子组件拿到的数据的id集合数组
+      goodsIds: [],
+      // 服务器前缀地址
+      baseURL: '',
       mydata: {},
       value: [],
       options: [{
@@ -314,7 +320,7 @@ export default {
       rules: {
         number: [{ required: true, message: '不能为空', trigger: 'blur' }],
         people: [{ required: true, message: '不能为空', trigger: 'blur' }],
-        textarea: [{ max: 255, message: '不能超过255个字符', trigger: 'blur' }]
+        textarea: [{ required: true, message: '不能为空', trigger: 'blur' }, { max: 255, message: '不能超过255个字符', trigger: 'blur' }]
       },
       // 表格数据
       tableData: []
@@ -323,9 +329,31 @@ export default {
   // 监听属性 类似于data概念
   computed: {},
   // 监控data中的数据变化
-  watch: {},
+  watch: {
+    isShow (val) {
+      // if (!val) {
+      //   console.log(77777)
+      //   this.getSonList()
+      // }
+    }
+  },
   // 方法集合
   methods: {
+    // 从子组件哪里拿到选中的数据
+    getSonList (data) {
+      // console.log(666, data)
+      this.tableData = data
+      this.tableData.forEach(v => {
+        v.integrity = this.spoil(v.integrity)
+      })
+      const temp = []
+      data.forEach(v => {
+        temp.push(v.id)
+      })
+      const temp2 = new Set(temp)
+      this.goodsIds = [...temp2]
+      // console.log(999, this.goodsIds)
+    },
     // 多层选择器的事件
     handleChange (value) {
       console.log(value)
@@ -335,11 +363,44 @@ export default {
       // 调用子组件方法
       this.$refs.myDialog.getListTow({ pageNum: 1, pageSize: 10 })
       this.isShow = true
+    },
+    // 点击返回
+    goBack () {
+      const obj = { description: this.fromData.textarea, goodsIds: this.goodsIds.join(','), id: this.mydata.id, status: null }
+      // console.log(666, obj)
+      this.$confirm('您需要保存这条数据吗?', '提示', {
+        confirmButtonText: '保存',
+        cancelButtonText: '放弃',
+        type: 'warning'
+      }).then(async () => {
+        // 发请求
+        this.fromData.status = null
+        await holding1submit(obj)
+        this.$router.push('/layout/holding1')
+        this.$message({
+          type: 'success',
+          message: '保存成功!'
+        })
+      }).catch(() => {
+        this.$router.push('/layout/holding1')
+        this.$message({
+          type: 'info',
+          message: '放弃保存.'
+        })
+      })
+    },
+    // 点击提交
+    async submit () {
+      const obj = { description: this.fromData.textarea, goodsIds: this.goodsIds.join(','), id: this.mydata.id, status: 1 }
+      await holding1submit(obj)
+      this.$message.success('提交成功')
+      this.$router.push('/layout/holding1')
     }
-
   },
   // 生命周期 - 创建完成(可以访问当前this实例)
   created () {
+    // 获取服务器前缀地址
+    this.baseURL = axios.defaults.baseURL
     // 从第一层拿到传过来的数据
     this.mydata = this.$route.query
     this.mydata.id = Number(this.mydata.id)

+ 3 - 1
src/views/holding/holding3_look.vue

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