Ver Fonte

1.0.0-4 盘点生成明细优化

liuyanpeng há 4 meses atrás
pai
commit
168a19cc01
6 ficheiros alterados com 146 adições e 36 exclusões
  1. 1 1
      README.md
  2. 1 1
      bat/install.bat
  3. 1 1
      bat/publish.bat
  4. 2 2
      package.json
  5. 27 11
      src/common/CommonTable.vue
  6. 114 20
      src/customer/RepertoryCheck.vue

+ 1 - 1
README.md

@@ -32,4 +32,4 @@ npm publish
 * 2、一定不要忘记在项目部署时更改 package.json 里的版本;
 
 ### 项目版本详情
-见 [Configuration Reference](http://wuzhixin.vip:4873).
+见 [Configuration Reference](https://npm.leanwo.com).

+ 1 - 1
bat/install.bat

@@ -1,5 +1,5 @@
 set current_path="%~dp0"
 cd %current_path%
 cd ..
-npm install --registry http://wuzhixin.vip:4873
+npm install --registry https://npm.leanwo.com
 pause

+ 1 - 1
bat/publish.bat

@@ -1,5 +1,5 @@
 set current_path="%~dp0"
 cd %current_path%
 cd ..
-npm publish --registry http://wuzhixin.vip:4873/
+npm publish --registry https://npm.leanwo.com/
 pause

+ 2 - 2
package.json

@@ -1,7 +1,7 @@
 {
   "name": "client-wms-cf",
   "description": "Leanwo Prodog Client",
-  "version": "1.0.0-2",
+  "version": "1.0.0-4",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
     "dev": "cross-env webpack serve --config ./webpack.dev.js",
@@ -48,7 +48,7 @@
   },
   "publishConfig": {
     "access": "public",
-    "registry": "http://wuzhixin.vip:4873/"
+    "registry": "https://npm.leanwo.com/"
   },
   "repository": {
     "type": "http",

+ 27 - 11
src/common/CommonTable.vue

@@ -36,7 +36,7 @@ import {
   watch,
   onMounted,
 } from 'vue';
-import { getTableScroll } from '../common/tableScroll.js';
+import { getTableScroll } from './tableScroll.js';
 // import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN';
 // const locale = ref(zhCN);
 
@@ -123,6 +123,8 @@ const pagination = reactive({
   position: props.topRight ? ['topRight'] : ['bottomRight'],
 });
 
+const isPageSizeChange = ref(false);
+
 const yScroll = ref(400); //默认滚动高度
 const extraHeight = ref(undefined); //表格距离底部值
 
@@ -160,17 +162,28 @@ const onResizeTable = () => {
 
 //点击页码事件
 const changePage = (current, size) => {
-  pagination.current = current;
-  emit('getPager', pagination.current, size);
+  // pagination.current = current;
+  // emit('getPager', pagination.current, size);
+
+  if (isPageSizeChange.value) {
+    pagination.current = 1;
+    isPageSizeChange.value = false;
+    emit('getPager', 1, size);
+  } else {
+    pagination.current = current;
+    emit('getPager', current, size);
+  }
+  pagination.pageSize = size;
 };
 
-// 改变每页数量时更新显示
+// 改变每页数量时更新显示,每页条数改变(会自动触发点击页码事件)
 const showSizeChange = (current, pageSize) => {
-  setTimeout(() => {
-    pagination.current = 1;
-    emit('getPager', pagination.current, pageSize);
-  });
-  pagination.pageSize = pageSize;
+  // setTimeout(() => {
+  //   pagination.current = 1;
+  //   emit('getPager', pagination.current, pageSize);
+  // });
+  // pagination.pageSize = pageSize;
+  isPageSizeChange.value = true;
 };
 
 // 回到第一页
@@ -224,10 +237,12 @@ const selectAllEvent = (selected, selectedRows, changeRows) => {
 };
 
 // 清空选择
-const clear = () => {
+const clear = (isClear = true) => {
   state.selectedRowKeys = [];
   state.selectedRows = [];
-  emit('getSelected', state);
+  if (isClear) {
+    emit('getSelected', state);
+  }
 };
 
 // 获取排序信息
@@ -273,6 +288,7 @@ watch(
   },
   { immediate: true, deep: true },
 );
+
 watch(
   () => props.selectedKeys,
   newData => {

+ 114 - 20
src/customer/RepertoryCheck.vue

@@ -3,8 +3,9 @@
     <Navbar :title="'选择工装设备生成盘点详情'" :is-go-back="false" />
     <div class="action-buttons">
       <a-button type="primary" @click="searchDatas">搜索</a-button>
-      <a-button type="dashed" @click="generateCheckVouchs">生成盘点明细</a-button>
-      <a-button danger @click="clear">清空</a-button>
+      <a-button type="dashed" @click="generateCheckVouchs">生成明细</a-button>
+      <a-button type="dashed" @click="showDetail = true">所选明细({{ selectedRowKeys.length }})</a-button>
+      <a-button danger @click="clearFilter">清除条件</a-button>
     </div>
     <div style="display: flex; gap: 10px;">
       <div style="width: 26%;">
@@ -12,13 +13,13 @@
           <div class="category-panel">
             <a-form layout="horizontal" :model="formState">
               <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="searchDatas" />
               </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="searchDatas" />
               </a-form-item>
               <a-form-item label="类型">
-                <a-select v-model:value="formState.inventoryType" placeholder="请选择类型" @change="getCurrentStock">
+                <a-select v-model:value="formState.inventoryType" placeholder="请选择类型" @change="searchDatas">
                   <a-select-option :value="undefined">全部工装设备</a-select-option>
                   <a-select-option value="Clamp">工装</a-select-option>
                   <a-select-option value="Instrument">设备</a-select-option>
@@ -32,7 +33,7 @@
       <div style="width: 74%;margin:10px 0 0 10px;">
         <CommonTable
           ref="tableRef" :columns="currentStockColumns" :data-source="currentStocks"
-          :total="currentStocks.length" :is-custom-row-click="true" @custom-row-click="openWindow"
+          :total="pagination.total" :is-select="true" @get-pager="getPageParams" @get-selected="getSelectParams"
         >
           <template #bodyCell="{ column, index }">
             <span v-if="column.dataIndex === 'index'">
@@ -43,6 +44,27 @@
       </div>
     </div>
 
+    <Modal v-model:show="showDetail" title="盘点明细" small="true" :show-canel-button="false" :show-ok-button="false">
+      <div>
+        <a-button :disabled="selectedRowKeys.length === 0" danger @click="clearSelected">清空所有选择</a-button>
+        <CommonTable :columns="detailColumns" :data-source="selectedRowData" :extra-height="320">
+          <template #bodyCell="{ column, record, index }">
+            <span v-if="column.dataIndex === 'index'">
+              {{ index + 1 }}
+            </span>
+            <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>
@@ -67,8 +89,8 @@ export default {
       currentStocks: [],
       pagination: {
         total: 0,
-        pageSize: 10,
-        current: 1,
+        per_page: 20,
+        current_page: 1,
       },
       isCurrentStock: true,
       uuid: Uuid.createUUID(),
@@ -80,6 +102,9 @@ export default {
         inventoryNo: '',
         inventoryType: undefined,
       },
+      showDetail: false,
+      selectedRowKeys: [],
+      selectedRowData: [],
     };
   },
   computed: {
@@ -96,6 +121,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() {
@@ -121,9 +157,21 @@ export default {
   methods: {
 
     searchDatas() {
+      this.$refs.tableRef.backFirstPage();
+    },
+
+    getPageParams(page, pageSize) {
+      this.pagination.current_page = page;
+      this.pagination.per_page = pageSize;
       this.getCurrentStock();
     },
 
+    // 获取选中的数据
+    getSelectParams(selected) {
+      this.selectedRowKeys = selected.selectedRowKeys;
+      this.selectedRowData = selected.selectedRows;
+    },
+
     getCurrentStock() {
       const _self = this;
 
@@ -132,9 +180,11 @@ export default {
         inventoryName: _self.formState.inventoryName,
         inventoryNo: _self.formState.inventoryNo,
         inventoryType: _self.formState.inventoryType,
+        start: (_self.pagination.current_page - 1) * _self.pagination.per_page,
+        length: _self.pagination.per_page,
       };
       $.ajax({
-        url: Common.getApiURL('InventoryResource/checkVouchFindInventoryByCondition'),
+        url: Common.getApiURL('InventoryResource/checkVouchFindInventoryByConditionPage'),
         type: 'post',
         dataType: 'json',
         contentType: 'application/json',
@@ -144,9 +194,17 @@ 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;
           }
           _self.loading = false;
         },
@@ -157,23 +215,39 @@ export default {
       });
     },
 
+    // 删除已选择的盘点清单
+    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;
+        }
+      }
+    },
+
     generateCheckVouchs() {
       const _self = this;
-      let information = '';
-      if (!_self.formState.inventoryType && _self.formState.inventoryName === '' && _self.formState.inventoryNo === '') {
-        information =
-          `您确定要将仓库:【${_self.warehouseName}】下所有物料生成盘点明细`;
-      } else {
-        information = '您确定要根据选择的过滤条件生成对应的盘点明细';
+      if (_self.selectedRowKeys.length === 0) {
+        message.warning('请先选择要生成盘点明细的物料');
+        return;
       }
+      // let information = '';
+      // if (!_self.formState.inventoryType && _self.formState.inventoryName === '' && _self.formState.inventoryNo === '') {
+      //   information =
+      //     `您确定要将仓库:【${_self.warehouseName}】下所有物料生成盘点明细`;
+      // } else {
+      //   information = '您确定要根据选择的过滤条件生成对应的盘点明细';
+      // }
       Modal.confirm({
         title: '确认生成盘点明细',
-        content: `${information} 吗?如果"是"的话,请点击"确定"按钮,否则点击"取消"按钮`,
+        content: '如果"是"的话,请点击"确定"按钮,否则点击"取消"按钮',
         onOk() {
           _self.loading = true;
           const obj = {
             checkVouchId: _self.checkVouchId,
-            inventoryIds: _self.currentStocks.map(item => item.id),
+            inventoryIds: _self.selectedRowKeys,
           };
           $.ajax({
             url: Common.getApiURL(
@@ -188,6 +262,7 @@ export default {
             },
             success: data => {
               if (data.errorCode === 0) {
+                _self.clear();
                 message.success(data.errorMessage);
               } else {
                 message.warning(data.errorMessage);
@@ -209,7 +284,24 @@ export default {
         inventoryNo: '',
         inventoryType: undefined,
       };
-      this.getCurrentStock();
+      this.selectedRowKeys = [];
+      this.selectedRowData = [];
+      this.$refs.tableRef.clear(true);
+      this.searchDatas();
+    },
+    clearFilter() {
+      this.formState = {
+        inventoryName: '',
+        inventoryNo: '',
+        inventoryType: undefined,
+      };
+      this.searchDatas();
+    },
+
+    clearSelected() {
+      this.selectedRowKeys = [];
+      this.selectedRowData = [];
+      this.$refs.tableRef.clear(true);
     },
     openWindow(item) {
       console.log(item);
@@ -268,9 +360,11 @@ export default {
   justify-content: space-between;
   align-items: center;
 }
-:deep(.ant-form-item){
+
+:deep(.ant-form-item) {
   margin-bottom: 10px !important;
 }
+
 :deep(.ant-form-item-label > label) {
   font-size: 14px !important;
   font-weight: 600 !important;