Quellcode durchsuchen

修改盘点流程接口等业务

liuyanpeng vor 7 Monaten
Ursprung
Commit
93e16c985c

+ 26 - 2
src/custom/api/asset/AssetInventoryResource.js

@@ -106,7 +106,7 @@ export default {
    * 全公司每个部门生成一张盘点单 
    */
   departmentGeneratesCountSheet: function (assetInventoryDepartmentRequest) {
-    var requestUrl = 'api/assetInventoryResource/departmentGeneratesCountSheet';
+    var requestUrl = 'api/CheckVouchResource/generateCheckVouchByWarehouse';
 
 
     return new Promise((resolve, reject) => {
@@ -201,7 +201,7 @@ export default {
    * 抽盘生成一张盘点单 
    */
   generateCountSheetBySampling: function (assetInventoryDrawingRequest) {
-    var requestUrl = 'api/assetInventoryResource/generateCountSheetBySampling';
+    var requestUrl = 'api/CheckVouchResource/generateSpotCheckCheckVouchs';
 
 
     return new Promise((resolve, reject) => {
@@ -608,4 +608,28 @@ x1 盘点单 (全部) x2 盘点单 (已完成) x3 盘点单 (未完成)
       });
     });
   },
+
+  // 获取仓库列表
+ getWarehouseList: function () {
+    var requestUrl = 'api/WarehouseResource/all';
+
+
+    return new Promise((resolve, reject) => {
+      $.ajax({
+        url: Common.getApiUrl2(requestUrl),
+        type: 'get',
+        contentType: 'application/json',
+
+        beforeSend: function (request) {
+          Common.addTokenToRequest(request);
+        },
+        success: function (data) {
+          resolve(data);
+        },
+        error: function (XMLHttpRequest, textStatus, errorThrown) {
+          reject(XMLHttpRequest);
+        },
+      });
+    });
+  },
 };

+ 37 - 5
src/custom/inventory/AssetInventoryStep2.vue

@@ -4,6 +4,9 @@
       <a-form-item label="盘点单名称" :rules="[{ required: true }]" class="m-form-item">
         <a-input v-model:value="inventorySheetName" placeholder="请输入盘点单名称" />
       </a-form-item>
+      <a-form-item label="仓库" :rules="[{ required: true }]" class="m-form-item">
+        <a-select v-model:value="warehouseId" :allow-clear="true" show-search option-filter-prop="label" :options="warehouseOptions" placeholder="请选择仓库" />
+      </a-form-item>
     </a-form>
     <a-divider style="margin:14px 0 20px 0 !important;" />
     <a-button type="primary" @click="previous">上一步</a-button>
@@ -13,6 +16,7 @@
 
 <script>
 import { Notify } from 'pc-component-v3';
+import AssetInventoryResource from '../api/asset/AssetInventoryResource.js';
 
 
 export default {
@@ -33,6 +37,8 @@ export default {
   data: function () {
     return {
       inventorySheetName: null,
+      warehouseId: undefined,
+      warehouseOptions: [],
       currentStepTempory: {},
     };
   },
@@ -43,6 +49,10 @@ export default {
         console.log(newVal);
         if (newVal != null) {
           this.currentStepTempory = JSON.parse(JSON.stringify(newVal));
+          if (newVal.assetInventoryStep2) {
+            this.inventorySheetName = newVal.assetInventoryStep2.inventorySheetName || null;
+            this.warehouseId = newVal.assetInventoryStep2.warehouseId;
+          }
         }
       },
       immediate: true,
@@ -59,18 +69,42 @@ export default {
       deep: true,
     },
   },
-  mounted: function () { },
+  mounted: function () {
+    this.getWarehouseList();
+  },
 
   methods: {
+    getWarehouseList: function () {
+      var _self = this;
+      AssetInventoryResource.getWarehouseList().then(
+        successData => {
+          if (successData && successData.length > 0) {
+            _self.warehouseOptions = successData.map(item => {
+              return {
+                value: item.id,
+                label: item.name,
+              };
+            });
+          }
+        },
+        errorData => {
+          console.log(errorData);
+        },
+      );
+    },
     next: function () {
       var _self = this;
       if (_self.inventorySheetName == null || _self.inventorySheetName == '') {
         Notify.error('错误', '请填写盘点单名称', 1000);
         return;
       }
-
+      if (_self.warehouseId == null || _self.warehouseId == undefined) {
+        Notify.error('错误', '请选择仓库', 1000);
+        return;
+      }
       var param = {
         inventorySheetName: _self.inventorySheetName,
+        warehouseId: _self.warehouseId,
       };
 
 
@@ -78,9 +112,7 @@ export default {
       var data = {
         currentStep: 2,
         showPage: 2,
-        assetInventoryStep3: param,
-        assetInventoryStep4: undefined,
-        assetInventoryStep5: undefined,
+        assetInventoryStep2: param,
       };
       this.$emit('next', data);
     },

+ 18 - 14
src/custom/inventory/AssetInventoryStep3.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <a-result v-if="isShow" status="success" title="操作成功!" sub-title="恭喜您,全盘生成盘点单成功.">
+    <a-result v-if="isShow" status="success" title="操作成功!" :sub-title="successText">
       <template #extra>
         <div style="text-align: left; margin-bottom: 20px;">
           <a-table :columns="columns" :data-source="organizationNames">
@@ -85,6 +85,7 @@ export default {
         dataIndex: 'operation',
         key: 'operation',
       }],
+      successText: '',
     };
   },
 
@@ -119,30 +120,33 @@ export default {
        * 打开资产盘点单的CURD窗口
        */
     openCurdWindow: function (data) {
-      let url = Common.getRedirectUrl('#/desktop/window1/window-read/view/041101/0/' + data +
+      let url = Common.getRedirectUrl('#/desktop/window1/window-read/view/081001/0/' + data +
         '?currPage=1&currIndex=1&totalCount=1&uuid=' + Uuid.createUUID());
       window.open(url);
     },
 
     end: function () {
       var _self = this;
-      var param = _self.currentStep.assetInventoryStep3;
+      var param = {
+        checkVouchName: _self.currentStep.assetInventoryStep2.inventorySheetName,
+        warehouseId: _self.currentStep.assetInventoryStep2.warehouseId,
+      };
       _self.loading = true;
       AssetInventoryResource.departmentGeneratesCountSheet(param).then(
         data => {
           if (data.errorCode != 0) {
             Notify.error('失败', data.errorMessage, false);
           } else {
-            data.datas.forEach(function (item) {
-              var organizationName = {
-                name: item.organizationName,
-                documentNo: item.documentNo,
-                documentName: item.name,
-                id: item.id,
-              };
-              _self.organizationNames.push(organizationName);
-            });
-            Notify.success('成功', '全单位生成盘点单成功', 2000);
+            Notify.success('成功', data.errorMessage, false);
+            _self.successText = data.errorMessage;
+            _self.organizationNames = [
+              {
+                name: data.data.organizationName,
+                documentNo: data.data.documentNo,
+                documentName: data.data.name,
+                id: data.data.id,
+              }
+            ]
           }
 
           _self.isShow = true;
@@ -157,7 +161,7 @@ export default {
       var data = {
         currentStep: 1,
         showPage: 1,
-        assetInventoryStep3: undefined,
+        assetInventoryStep2: this.currentStep.assetInventoryStep2,
       };
       this.$emit('previous', data);
     },

+ 165 - 26
src/custom/inventory/AssetInventoryStep4.vue

@@ -1,46 +1,51 @@
 <template>
   <div style="padding: 0 10px;">
     <div class="action-buttons">
-      <a-button type="primary" @click="searchDatas">搜索</a-button>
+      <a-button type="primary" @click="getDatas">搜索</a-button>
       <a-button danger @click="clear">清空</a-button>
       <div>
         <a-form-item label="盘点单名称" :rules="[{ required: true, message: '请输入盘点单名称' }]">
           <a-input v-model:value="inventorySheetName" placeholder="请输入盘点单名称" />
         </a-form-item>
       </div>
+      <a-button type="dashed" @click="showDetail = true">
+        查看盘点清单({{ selectedRowData.length }})
+      </a-button>
     </div>
     <div style="display: flex; gap: 10px;">
       <div style="width: 20%;">
         <div class="filter-section">
           <div class="category-panel">
-            <a-form layout="horizontal" :model="formState">
-
+            <a-form layout="horizontal" :model="formState" :label-col="{ style: 'width:60px' }">
+              <a-form-item label="仓库" :rules="[{ required: true }]">
+                <a-select v-model:value="formState.inventoryWarehouse" :options="warehouseOptions"
+                  option-filter-prop="label" show-search :allow-clear="true" placeholder="请选择仓库" @change="getDatas">
+                </a-select>
+              </a-form-item>
               <a-form-item label="名称">
-                <a-input v-model:value="formState.inventoryName" placeholder="请输入名称" @keyup.enter="getCurrentStock" />
+                <a-input v-model:value="formState.inventoryName" placeholder="请输入名称" @keyup.enter="getDatas" />
               </a-form-item>
               <a-form-item label="编号">
-                <a-input v-model:value="formState.inventoryNo" placeholder="请输入编号" @keyup.enter="getCurrentStock" />
+                <a-input v-model:value="formState.inventoryNo" placeholder="请输入编号" @keyup.enter="getDatas" />
               </a-form-item>
               <a-form-item label="类型">
-                <a-select v-model:value="formState.inventoryType" :allow-clear="true" placeholder="请选择类型" @change="getCurrentStock">
+                <a-select v-model:value="formState.inventoryType" :allow-clear="true" placeholder="请选择类型"
+                  @change="getDatas">
                   <a-select-option :value="undefined">全部</a-select-option>
                   <a-select-option value="Clamp">工装</a-select-option>
                   <a-select-option value="Instrument">设备</a-select-option>
                   <a-select-option value="FinishProduct">成品</a-select-option>
                 </a-select>
               </a-form-item>
-              <a-form-item label="仓库">
-                <a-select v-model:value="formState.inventoryWarehouse" :allow-clear="true" placeholder="请选择仓库" @change="getCurrentStock">
-                  <a-select-option :value="undefined">全部仓库</a-select-option>
-                </a-select>
-              </a-form-item>
             </a-form>
           </div>
         </div>
       </div>
       <div style="width: 80%;margin:10px 0 0 10px;">
         <CommonTable ref="tableRef" :extra-height="100" :columns="currentStockColumns" :data-source="currentStocks"
-          :total="currentStocks.length" :is-custom-row-click="true" @custom-row-click="openWindow">
+          :total="currentStocks.length" :is-select="true" :selectedKeys="selectedRowKeys"
+          @get-selected="getSelectParams" :is-custom-row-click="true" @custom-row-click="openWindow"
+          @getPager="getPageParams">
           <template #bodyCell="{ column, index }">
             <span v-if="column.dataIndex === 'index'">
               {{ index + 1 }}
@@ -55,6 +60,24 @@
         下一步
       </a-button>
     </div>
+
+    <Modal v-model:show="showDetail" title="盘点清单" small="true" :show-canel-button="false" :show-ok-button="false">
+      <div>
+        <CommonTable :columns="detailColumns" :data-source="selectedRowData" :selected-keys="selectedRowKeys"
+          :extra-height="300">
+          <template #bodyCell="{ column, record }">
+            <template v-if="column.dataIndex === 'operation'">
+              <a-button danger @click="deleteCountList(record.id)">
+                删除
+              </a-button>
+            </template>
+          </template>
+        </CommonTable>
+      </div>
+      <template #footer>
+        <a-button type="primary" @click="showDetail = false">关闭</a-button>
+      </template>
+    </Modal>
     <Loading v-if="loading" />
   </div>
 </template>
@@ -65,9 +88,18 @@ import { message } from 'ant-design-vue';
 import CommonTable from '../common/CommonTable.vue';
 import { UserStorageResource, Uuid, Notify } from 'pc-component-v3';
 import { DownOutlined, RightOutlined } from '@ant-design/icons-vue';
+import AssetInventoryResource from '../api/asset/AssetInventoryResource.js';
 
 export default {
   components: { CommonTable, DownOutlined, RightOutlined },
+  props: {
+    currentStep: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+  },
   emits: ['previous', 'next'],
   data() {
     return {
@@ -80,8 +112,10 @@ export default {
       currentStocks: [],
       pagination: {
         total: 0,
-        pageSize: 10,
+        pageSize: 20,
         current: 1,
+        start: 1,
+        length: 20,
       },
       isCurrentStock: true,
       uuid: Uuid.createUUID(),
@@ -95,6 +129,10 @@ export default {
         inventoryType: undefined,
         inventoryWarehouse: undefined,
       },
+      warehouseOptions: [],
+      selectedRowKeys: [],
+      selectedRowData: [],
+      showDetail: false,
     };
   },
   computed: {
@@ -111,6 +149,17 @@ export default {
         return { ...item, align: 'center' };
       });
     },
+    detailColumns() {
+      return [
+        { title: '序号', dataIndex: 'index', width: 50 },
+        { title: '名称', dataIndex: 'inventoryName', width: 100 },
+        { title: '编号', dataIndex: 'inventoryNo', width: 120 },
+        { title: '类型', dataIndex: 'inventoryType', width: 140 },
+        { title: '操作', dataIndex: 'operation', width: 100 },
+      ].map(item => {
+        return { ...item, align: 'center' };
+      });
+    },
   },
 
   created() {
@@ -130,45 +179,96 @@ export default {
       },
     );
   },
+
   mounted() {
+    if (this.currentStep && this.currentStep.assetInventoryStep4) {
+      const s4 = this.currentStep.assetInventoryStep4;
+      this.inventorySheetName = s4.checkVouchName || '';
+      if (s4.warehouseId !== undefined && s4.warehouseId !== null) {
+        this.formState.inventoryWarehouse = s4.warehouseId;
+      }
+      if (s4.detailList && s4.detailList.length > 0) {
+        this.selectedRowData = s4.detailList;
+        this.selectedRowKeys = s4.detailList.map(item => item.id);
+      }
+    }
+
     this.getCurrentStock();
+    this.getWarehouseList();
   },
   methods: {
 
+    // 获取分页参数
+    getPageParams(start, length) {
+      this.pagination.start = start;
+      this.pagination.length = length;
+      this.getCurrentStock();
+    },
+
+    // 获取选中的数据
+    getSelectParams(selected) {
+      this.selectedRowKeys = selected.selectedRowKeys;
+      this.selectedRowData = selected.selectedRows;
+    },
+
+    // 删除已选择的盘点清单
+    deleteCountList: function (data) {
+      var _self = this;
+      for (var i = 0; i < _self.selectedRowData.length; i++) {
+        if (_self.selectedRowData[i].id == data) {
+          _self.selectedRowData.splice(i, 1);
+          _self.selectedRowKeys.splice(i, 1);
+          break;
+        }
+      }
+    },
+
+    // 获取数据
+    getDatas() {
+      this.$refs.tableRef.backFirstPage();
+    },
+
+    // 上一步
     previous: function () {
       var data = {
         currentStep: 0,
         showPage: 0,
-        assetInventoryStep3: undefined,
+        assetInventoryStep4: undefined,
       };
       this.$emit('previous', data);
     },
+
+    // 下一步
     next: function () {
       var _self = this;
       if (_self.inventorySheetName == null || _self.inventorySheetName == '') {
         Notify.error('错误', '请填写盘点单名称', 1000);
         return;
       }
+      if (_self.formState.inventoryWarehouse == null || _self.formState.inventoryWarehouse == undefined) {
+        Notify.error('错误', '请选择仓库', 1000);
+        return;
+      }
+      if(!_self.selectedRowKeys || _self.selectedRowKeys.length == 0) {
+        Notify.error('错误', '请选择盘点清单', 1000);
+        return;
+      }
 
       var param = {
-        inventorySheetName: _self.inventorySheetName,
-        ..._self.formState,
+        checkVouchName: _self.inventorySheetName,
+        inventoryIds: _self.selectedRowKeys,
+        warehouseId: _self.formState.inventoryWarehouse,
+        detailList: _self.selectedRowData,
       };
       console.log(param, 'param');
       var data = {
         currentStep: 2,
         showPage: 4,
-        assetInventoryStep3: param,
-        assetInventoryStep4: undefined,
-        assetInventoryStep5: undefined,
+        assetInventoryStep4: param,
       };
       this.$emit('next', data);
     },
 
-    searchDatas() {
-      this.getCurrentStock();
-    },
-
 
     // 查询数据
     getCurrentStock() {
@@ -179,10 +279,14 @@ export default {
         inventoryName: _self.formState.inventoryName,
         inventoryNo: _self.formState.inventoryNo,
         inventoryType: _self.formState.inventoryType,
-        inventoryWarehouse: _self.formState.inventoryWarehouse,
+        warehouseId: _self.formState.inventoryWarehouse,
+        range: {
+          start: (_self.pagination.start - 1) * _self.pagination.length,
+          length: _self.pagination.length,
+        }
       };
       $.ajax({
-        url: Common.getApiURL('InventoryResource/checkVouchFindInventoryByCondition'),
+        url: Common.getApiURL('InventoryResource/findInventoryByWarehouse'),
         type: 'post',
         dataType: 'json',
         contentType: 'application/json',
@@ -192,9 +296,24 @@ export default {
         },
         success: data => {
           if (data.errorCode === 0) {
-            _self.currentStocks = data.datas
+            if (data.datas && data.datas.length > 0) {
+              _self.currentStocks = data.datas
+              _self.pagination.total = data.total
+            } else {
+              _self.currentStocks = []
+              _self.pagination.total = 0
+            }
           } else {
             message.warning(data.errorMessage);
+            _self.currentStocks = []
+            _self.pagination.total = 0
+          }
+          // 保留 selectedRowData 为 detailList 或当前选择,不在这里覆盖
+          if (_self.currentStep && _self.currentStep.assetInventoryStep4 && Array.isArray(_self.currentStep.assetInventoryStep4.inventoryIds)) {
+            const ids = _self.currentStep.assetInventoryStep4.inventoryIds;
+            if (!_self.selectedRowKeys.length) {
+              _self.selectedRowKeys = ids.slice();
+            }
           }
           _self.loading = false;
         },
@@ -220,6 +339,26 @@ export default {
       //   `#/desktop/window1/window-read/view/050405/0/${item.id}?currPage=1&currIndex=1&totalCount=1&uuid=${Uuid.createUUID()}`,
       // );
     },
+
+    // 获取仓库列表
+    getWarehouseList: function () {
+      var _self = this;
+      AssetInventoryResource.getWarehouseList().then(
+        successData => {
+          if (successData && successData.length > 0) {
+            _self.warehouseOptions = successData.map(item => {
+              return {
+                value: item.id,
+                label: item.name,
+              };
+            });
+          }
+        },
+        errorData => {
+          console.log(errorData);
+        },
+      );
+    },
   },
 };
 </script>

+ 18 - 11
src/custom/inventory/AssetInventoryStep5.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <a-result v-if="isShow" status="success" title="操作成功!" sub-title="恭喜您,抽盘生成盘点单成功.">
+    <a-result v-if="isShow" status="success" title="操作成功!" :sub-title="successText">
       <template #extra>
         <div style="text-align: left; margin-bottom: 20px;">
           <a-table :columns="columns" :data-source="organizationNames">
@@ -93,6 +93,7 @@ export default {
         key: 'operation',
       },
       ],
+      successText: '',
     };
   },
 
@@ -127,7 +128,7 @@ export default {
        * 打开资产盘点单的CURD窗口
        */
     openCurdWindow: function (data) {
-      let url = Common.getRedirectUrl('#/desktop/window1/window-read/view/041101/0/' + data +
+      let url = Common.getRedirectUrl('#/desktop/window1/window-read/view/081001/0/' + data +
         '?currPage=1&currIndex=1&totalCount=1&uuid=' + Uuid.createUUID());
       window.open(url);
     },
@@ -135,21 +136,27 @@ export default {
     // 确认生成抽盘盘点单
     end: function () {
       var _self = this;
-      var param = _self.currentStep.assetInventoryStep3;
+      var param = {
+        checkVouchName: _self.currentStep.assetInventoryStep4.checkVouchName,
+        inventoryIds: _self.currentStep.assetInventoryStep4.inventoryIds,
+        warehouseId: _self.currentStep.assetInventoryStep4.warehouseId,
+      };
       console.log(param, '抽盘参数---');
       _self.loading = true;
       AssetInventoryResource.generateCountSheetBySampling(param).then(
         data => {
           _self.loading = false;
           if (data.errorCode == 0) {
-            var organizationName = {
-              name: data.organizationName,
-              documentNo: data.documentNo,
-              documentName: data.name,
-              id: data.id,
-            };
-            _self.organizationNames.push(organizationName);
+            _self.organizationNames = [
+              {
+                name: data.data.organizationName,
+                documentNo: data.data.documentNo,
+                documentName: data.data.name,
+                id: data.data.id,
+              }
+            ];
             Notify.success('成功', '抽盘生成盘点单成功', 2000);
+            _self.successText = data.errorMessage;
             _self.isShow = true;
           } else {
             Notify.error('错误', data.errorMessage, 2000);
@@ -164,7 +171,7 @@ export default {
       var data = {
         currentStep: 1,
         showPage: 3,
-        assetInventoryStep3: undefined,
+        assetInventoryStep4: this.currentStep.assetInventoryStep4,
       };
       this.$emit('previous', data);
     },