Explorar o código

feat(仓库管理): 新增二维码功能及优化货位生成逻辑

- 在库区管理页面添加二维码生成功能,展示库区详细信息
- 优化货位生成逻辑,按行列规则生成货位编号
- 添加白名单路由/fromQRCode/designDrawing.html
- 在库存台账搜索组件中增加颜色搜索字段
liujt hai 1 mes
pai
achega
d190291b72

+ 105 - 0
public/fromQRCode/designDrawing.html

@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+        <meta http-equiv="X-UA-Compatible" content="IE=edge">
+        <meta name="viewport" content="width=device-width,initial-scale=1.0">
+        <meta name="apple-mobile-web-app-capable" content="yes">
+        <meta name="apple-mobile-web-app-status-bar-style" content="black">
+        <meta name="format-detection" content="telephone=no">
+        <meta http-equiv="X-UA-Compatible" content="chrome=1" >
+        <style>
+            *{
+                outline: 0;
+                padding: 0;
+                margin: 0;
+                border: none;
+                box-sizing: border-box;
+                background-size: contain;
+                background-position: center;
+                background-repeat: no-repeat;
+            }
+            ul,ol{
+                list-style: none outside none;
+            }
+            ul.product-info {
+                padding: 20px;
+            }
+                ul.product-info > li {
+                    line-height: 30px;
+                    font-size: 14px;
+                }
+        </style>
+    </head>
+
+    <body>
+        <ul class="product-info">
+            <li>
+                <label for="">库区名称:</label>
+                <span id="name">-</span>
+            </li>
+    
+            <li>
+                <label for="">库区编码:</label>
+                <span id="code">-</span>
+            </li>
+            <li>
+                <label for="">库区类型:</label>
+                <span id="areaType">-</span>
+            </li>
+            <li>
+                <label for="">库区属性:</label>
+                <span id="attribute">-</span>
+            </li>
+            <li>
+                <label for="">库区位置:</label>
+                <span id="address">-</span>
+            </li>
+            <li>
+                <label for="">库区长(cm):</label>
+                <span id="areaLength">-</span>
+            </li>
+            <li>
+                <label for="">库区宽(cm):</label>
+                <span id="areaWidth">-</span>
+            </li>
+            <li>
+                <label for="">库区高(cm):</label>
+                <span id="areaHigh">-</span>
+            </li>
+            <li>
+                <label for="">货架数量:</label>
+                <span id="subCount">-</span>
+            </li>
+            <li>
+                <label for="">货架编码:</label>
+                <span id="codeList">-</span>
+            </li>
+            <li>
+                <label for="">备注:</label>
+                <span id="remark">-</span>
+            </li>
+        </ul>
+    </body>
+    <script>
+        function str_to_obj(str){
+            var obj = {};
+            var temp = str.split('&');
+            for(var i = 0; i < temp .length;i++) {
+                var t  =  temp[i].split('=');
+                obj[t[0]]=t[1];
+            }
+            return obj
+        }
+  
+        var queryObj = str_to_obj(window.location.search.substring(1));
+        let ids=['name','code','areaType','attribute','address','areaLength','areaWidth','areaHigh','subCount','codeList','remark']
+        ids.forEach(id=>{
+            if(queryObj[id]){
+                document.querySelector('#'+id).innerHTML = decodeURIComponent(queryObj[id]);
+            }
+        })
+
+     
+    </script>
+</html>

+ 1 - 1
src/config/setting.js

@@ -18,7 +18,7 @@ export const HIDE_FOOTERS = [
 export const REPEATABLE_TABS = [];
 
 // 不需要登录的路由
-export const WHITE_LIST = ['/login', '/forget'];
+export const WHITE_LIST = ['/login', '/forget','/fromQRCode/designDrawing.html'];
 
 // 开启 KeepAlive 后仍然不需要缓存的路由地址
 export const KEEP_ALIVE_EXCLUDES = [];

+ 9 - 0
src/views/warehouseManagement/stockLedger/components/item-search.vue

@@ -167,6 +167,15 @@
               placeholder="请输入"
             ></el-input>
           </el-form-item>
+        </el-col>  
+        <el-col :span="6">
+          <el-form-item label="颜色:" prop="colorKey">
+            <el-input
+              clearable
+              v-model="params.colorKey"
+              placeholder="请输入"
+            ></el-input>
+          </el-form-item>
         </el-col>
         <!-- <el-col v-if="dimension == 3 || dimension == 2" :span="6">
           <el-form-item label="销售订单号:" prop="saleOrderNos">

+ 112 - 39
src/views/warehouseManagement/warehouseDefinition/add.vue

@@ -41,6 +41,11 @@
               stripe
               :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
             >
+              <el-table-column label="二维码" prop="qrcode" min-width="100" align="center">
+                <template slot-scope="{ row, $index }">
+                  <el-link type="primary" @click="generateQrcode(row)">二维码</el-link>
+                </template>
+              </el-table-column>
               <el-table-column label="库区编号" prop="code" min-width="120">
                 <template slot-scope="{ row, $index }">
                   <el-form-item
@@ -327,6 +332,11 @@
               stripe
               :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
             >
+              <el-table-column label="二维码" prop="qrcode" min-width="100" align="center">
+                <template slot-scope="{ row, $index }">
+                  <el-link type="primary" @click="generateQrcode(row)">二维码</el-link>
+                </template>
+              </el-table-column>
               <el-table-column
                 label="库区编号"
                 prop="reservoirAreaCode"
@@ -738,13 +748,15 @@
         <el-button @click="handleMine" type="primary">确 定</el-button>
       </span>
     </el-dialog>
+    <!-- 二维码 -->
+    <qsCode ref="qsCodeRef"></qsCode>
   </div>
 </template>
 
 <script>
   // import selectTree from '@/components/selectTree';
   import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
-
+  import qsCode from './components/qsCode.vue'
   import {
     warehouseDefinition_areaType,
     warehouseDefinition_areaAttribute,
@@ -755,6 +767,9 @@
 
   // import { throttle } from 'lodash';
   export default {
+    components: {
+      qsCode
+    },
     // components: { selectTree },
     filters: {
       filterAreaType: useDictLabelFilter
@@ -1262,48 +1277,92 @@
       },
       generateAllocation(num, obj) {
         console.log(obj);
-        const pre =
-          this.areaForm.allocationReqList[
-            this.areaForm.allocationReqList.length - 1
-          ];
-
-        for (var i = 0; i < num; i++) {
-          this.areaForm.allocationReqList.push({
-            warehouseAreaCode: obj.reservoirAreaCode,
-            warehouseAreaGoodsCode: obj.code,
-            goodsAllocationCode: obj.code + '-' + (i + 1),
-            // allocationBarcode: '',
-            code: obj.code + '-' + (i + 1),
+        const rows = Number(obj.extInfo[0].line); // 行数
+        const cols = Number(obj.extInfo[0].column); // 列数
+        
+        // 按行优先遍历:行从1到rows,列从1到cols
+        for (let row = 1; row <= rows; row++) {
+          for (let col = 1; col <= cols; col++) {
+            // 货位编号规则:货架编号-行号-列号
+            const allocationCode = `${obj.code}-${row}-${col}`;
+            
+            this.areaForm.allocationReqList.push({
+              warehouseAreaCode: obj.reservoirAreaCode,
+              warehouseAreaGoodsCode: obj.code,
+              goodsAllocationCode: allocationCode,
+              // allocationBarcode: '',
+              code: allocationCode,
 
-            extInfo: [
-              {
-                goodsAllocationWide: Number(obj.extInfo[0].areaWidth),
-                goodsAllocationHigh: Number(
-                  obj.extInfo[0].areaHigh / Number(obj.extInfo[0].line)
-                ).toFixed(0),
-                goodsAllocationLength: Number(
-                  obj.extInfo[0].areaLength / Number(obj.extInfo[0].column)
-                ).toFixed(0),
-                weightLimit: '',
-                volumeUnit:
-                  Number(
-                    obj.extInfo[0].areaLength / Number(obj.extInfo[0].column)
-                  ).toFixed(0) *
-                  Number(
-                    obj.extInfo[0].areaHigh / Number(obj.extInfo[0].line)
-                  ).toFixed(0) *
-                  Number(obj.extInfo[0].areaWidth)
-              }
-            ],
-            goodsShelvesCode: obj.code,
-            reservoirAreaCode: obj.reservoirAreaCode,
-            warehouseId: this.formData.id, //?
+              extInfo: [
+                {
+                  goodsAllocationWide: Number(obj.extInfo[0].areaWidth),
+                  goodsAllocationHigh: Number(
+                    obj.extInfo[0].areaHigh / rows
+                  ).toFixed(0),
+                  goodsAllocationLength: Number(
+                    obj.extInfo[0].areaLength / cols
+                  ).toFixed(0),
+                  weightLimit: '',
+                  volumeUnit:
+                    Number(obj.extInfo[0].areaLength / cols).toFixed(0) *
+                    Number(obj.extInfo[0].areaHigh / rows).toFixed(0) *
+                    Number(obj.extInfo[0].areaWidth)
+                }
+              ],
+              goodsShelvesCode: obj.code,
+              reservoirAreaCode: obj.reservoirAreaCode,
+              warehouseId: this.formData.id,
 
-            type: 3,
-            isEdit: true
-          });
+              type: 3,
+              isEdit: true
+            });
+          }
         }
       },
+      // generateAllocation(num, obj) {
+      //   console.log(obj);
+      //   const pre =
+      //     this.areaForm.allocationReqList[
+      //       this.areaForm.allocationReqList.length - 1
+      //     ];
+
+      //   for (var i = 0; i < num; i++) {
+      //     this.areaForm.allocationReqList.push({
+      //       warehouseAreaCode: obj.reservoirAreaCode,
+      //       warehouseAreaGoodsCode: obj.code,
+      //       goodsAllocationCode: obj.code + '-' + (i + 1),
+      //       // allocationBarcode: '',
+      //       code: obj.code + '-' + (i + 1),
+
+      //       extInfo: [
+      //         {
+      //           goodsAllocationWide: Number(obj.extInfo[0].areaWidth),
+      //           goodsAllocationHigh: Number(
+      //             obj.extInfo[0].areaHigh / Number(obj.extInfo[0].line)
+      //           ).toFixed(0),
+      //           goodsAllocationLength: Number(
+      //             obj.extInfo[0].areaLength / Number(obj.extInfo[0].column)
+      //           ).toFixed(0),
+      //           weightLimit: '',
+      //           volumeUnit:
+      //             Number(
+      //               obj.extInfo[0].areaLength / Number(obj.extInfo[0].column)
+      //             ).toFixed(0) *
+      //             Number(
+      //               obj.extInfo[0].areaHigh / Number(obj.extInfo[0].line)
+      //             ).toFixed(0) *
+      //             Number(obj.extInfo[0].areaWidth)
+      //         }
+      //       ],
+      //       goodsShelvesCode: obj.code,
+      //       reservoirAreaCode: obj.reservoirAreaCode,
+      //       warehouseId: this.formData.id, //?
+
+      //       type: 3,
+      //       isEdit: true
+      //     });
+      //   }
+      // },
       saveArea(index) {
         this.hjForm = { code: '', type: 1 };
         if (
@@ -1812,6 +1871,20 @@
           newArr.push({ ...arr[key].extInfo[0], ...arr[key] });
         }
         return newArr;
+      },
+      generateQrcode(row) {
+        console.log(row);
+        if(row.isEdit){
+          this.$message.warning('请先保存库区');
+          return;
+        }
+        const codes = this.areaForm.areaGoodsshelvesList
+          .filter((item) => item.reservoirAreaCode === row.code)
+          .map((i) => i.code)
+          .join(',');
+        this.$nextTick(() => {
+          this.$refs.qsCodeRef.open(row, codes);
+        });
       }
     }
   };

+ 95 - 0
src/views/warehouseManagement/warehouseDefinition/components/qsCode.vue

@@ -0,0 +1,95 @@
+<template>
+  <el-dialog
+      class="ele-dialog-form"
+      :visible.sync="codeVisible"
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      center
+      width="200px"
+      append-to-body
+      title="二维码"
+    >
+      <div class="qr-code-container">
+        <ele-qr-code :value="text" :size="120" />
+      </div>
+    
+      <template v-slot:footer>
+        <el-button @click="codeVisible=false">返回</el-button>
+      </template>
+    </el-dialog>
+</template>
+
+<script>
+
+
+import EleQrCode from 'ele-admin/es/ele-qr-code';
+import {
+  warehouseDefinition_areaType,
+  warehouseDefinition_areaAttribute,
+} from '@/utils/dict/index';
+
+export default {
+
+  data() {
+    return {
+      codeVisible: false,
+      text:''
+
+
+    }
+  },
+  components: {
+
+    EleQrCode
+  },
+  watch: {},
+  methods: {
+    open(row, codes) {
+      this.codeVisible=true
+      // let addr =
+      //         '' + row.addressName ? row.addressName.replaceAll(',', '') : '';
+      //       addr += row.address ? row.address : '';
+      const paramsStr = this.obj_to_str({
+        name: encodeURIComponent(row.name),
+        areaType: encodeURIComponent(warehouseDefinition_areaType.find(item=>item.code==row.extInfo[0].areaType)?.label),
+        attribute: encodeURIComponent(warehouseDefinition_areaAttribute.find(item=>item.code==row.extInfo[0].attribute)?.label),
+        code: encodeURIComponent(row.code),
+        codeList: encodeURIComponent(codes),
+        address: encodeURIComponent(row.extInfo[0].address),
+        areaLength: encodeURIComponent(row.extInfo[0].areaLength),
+        areaWidth: encodeURIComponent(row.extInfo[0].areaWidth),
+        areaHigh: encodeURIComponent(row.extInfo[0].areaHigh),
+        subCount: encodeURIComponent(row.subCount),
+        remark: encodeURIComponent(row.remark),
+      });
+
+      console.log('二维码参数~~~', paramsStr);
+      this.text =
+        window.location.origin +
+        '/wms/fromQRCode/designDrawing.html' +
+        '?' +
+        paramsStr;
+
+        console.log('二维码~~~', window.location.origin, this.text);
+    },
+
+    obj_to_str(obj) {
+      var str = '';
+      for (var k in obj) {
+        str += `${k}=${obj[k]}&`;
+      }
+      return str;
+    },
+    
+
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.qr-code-container{
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+</style>