From da5bd5596b1f0f7a27cd0791a17a7fc3b608f523 Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期三, 07 五月 2025 18:10:24 +0800
Subject: [PATCH] 工具管理-仓库管理页面开发

---
 src/views/tms/WarehouseList.vue |  206 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 156 insertions(+), 50 deletions(-)

diff --git a/src/views/tms/WarehouseList.vue b/src/views/tms/WarehouseList.vue
index d99540f..5a467a1 100644
--- a/src/views/tms/WarehouseList.vue
+++ b/src/views/tms/WarehouseList.vue
@@ -5,28 +5,47 @@
       <a-form layout="inline" @keyup.enter.native="searchQuery">
         <a-row :gutter="24">
             <a-col
-              :md="6"
+              :md="5"
               :sm="8"
             >
-              <a-form-item label="搴撴埧鍚嶇О">
+              <a-form-item label="浠撳簱鍚嶇О">
                 <a-input
-                  placeholder="璇疯緭鍏ュ簱鎴垮悕绉�"
+                  placeholder="璇疯緭鍏ヤ粨搴撳悕绉�"
                   v-model="queryParam.warehouseName"
                 ></a-input>
               </a-form-item>
             </a-col>
             <a-col
-              :md="6"
+              :md="7"
               :sm="8"
             >
-              <a-form-item label="闆朵欢缂栧彿">
-                <a-input
-                  placeholder="璇疯緭鍏ラ浂浠剁紪鍙锋煡璇�"
-                  v-model="queryParam.partNum"
-                ></a-input>
+              <a-form-item label="寮�濮嬫椂闂�">
+                <a-date-picker
+                  show-time
+                  placeholder="璇烽�夋嫨寮�濮嬫椂闂�"
+                  format="YYYY-MM-DD HH:mm"
+                  valueFormat="YYYY-MM-DD HH:mm"
+                  v-model="queryParam.beginTime"
+                ></a-date-picker>
                 <!-- :triggerChange="false" -->
               </a-form-item>
             </a-col>
+            <a-col
+              :md="7"
+              :sm="8"
+            >
+              <a-form-item label="缁撴潫鏃堕棿">
+                <a-date-picker
+                  show-time
+                  placeholder="璇烽�夋嫨缁撴潫鏃堕棿"
+                  format="YYYY-MM-DD HH:mm"
+                  valueFormat="YYYY-MM-DD HH:mm"
+                  v-model="queryParam.endTime"
+                ></a-date-picker>
+                <!-- :triggerChange="false" -->
+              </a-form-item>
+            </a-col>
+
 
           <a-col :md="4" :sm="4">
             <a-space>
@@ -41,27 +60,27 @@
 
     <!-- 鎿嶄綔鎸夐挳鍖哄煙 -->
     <div class="table-operator">
-      <a-button @click="handleAdd" type="primary" icon="plus">鏂板</a-button>
+      <a-button @click="handleAdd" :disabled="addFlag" type="primary" icon="plus">鏂板</a-button>
 <!--      <a-button type="primary" icon="download" @click="handleExportXls('tms_warehouse')">瀵煎嚭</a-button>-->
 <!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
 <!--        <a-button type="primary" icon="import">瀵煎叆</a-button>-->
 <!--      </a-upload>-->
       <!-- 楂樼骇鏌ヨ鍖哄煙 -->
 <!--      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
-      <a-dropdown v-if="selectedRowKeys.length > 0">
-        <a-menu slot="overlay">
-          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>鍒犻櫎</a-menu-item>
-        </a-menu>
-        <a-button style="margin-left: 8px"> 鎵归噺鎿嶄綔 <a-icon type="down" /></a-button>
-      </a-dropdown>
+<!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
+<!--        <a-menu slot="overlay">-->
+<!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>鍒犻櫎</a-menu-item>-->
+<!--        </a-menu>-->
+<!--        <a-button style="margin-left: 8px"> 鎵归噺鎿嶄綔 <a-icon type="down" /></a-button>-->
+<!--      </a-dropdown>-->
     </div>
 
     <!-- table鍖哄煙-begin -->
     <div>
-      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
-        <i class="anticon anticon-info-circle ant-alert-icon"></i> 宸查�夋嫨 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>椤�
-        <a style="margin-left: 24px" @click="onClearSelected">娓呯┖</a>
-      </div>
+<!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
+<!--        <i class="anticon anticon-info-circle ant-alert-icon"></i> 宸查�夋嫨 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>椤�-->
+<!--        <a style="margin-left: 24px" @click="onClearSelected">娓呯┖</a>-->
+<!--      </div>-->
 
       <a-table
         ref="table"
@@ -73,39 +92,34 @@
         :dataSource="dataSource"
         :pagination="ipagination"
         :loading="loading"
-        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
+        :rowSelection="null"
         class="j-table-force-nowrap"
         @change="handleTableChange">
 
-        <template slot="htmlSlot" slot-scope="text">
-          <div v-html="text"></div>
-        </template>
-        <template slot="imgSlot" slot-scope="text,record">
-          <span v-if="!text" style="font-size: 12px;font-style: italic;">鏃犲浘鐗�</span>
-          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
-        </template>
-        <template slot="fileSlot" slot-scope="text">
-          <span v-if="!text" style="font-size: 12px;font-style: italic;">鏃犳枃浠�</span>
-          <a-button
-            v-else
-            :ghost="true"
-            type="primary"
-            icon="download"
-            size="small"
-            @click="downloadFile(text)">
-            涓嬭浇
-          </a-button>
-        </template>
+        <span slot="status" slot-scope="text, record">
+          <span v-if="text === '1'" class='enable'>鍚敤</span>
+          <span v-if="text === '2'" class='disable'>鍋滅敤</span>
+        </span>
 
         <span slot="action" slot-scope="text, record">
-          <a @click="handleEdit(record)">缂栬緫</a>
+          <a @click="handleDetail(record)">璇︽儏</a>
 
           <a-divider type="vertical" />
           <a-dropdown>
             <a class="ant-dropdown-link">鏇村 <a-icon type="down" /></a>
             <a-menu slot="overlay">
               <a-menu-item>
-                <a @click="handleDetail(record)">璇︽儏</a>
+                <a @click="handleEdit(record)">缂栬緫</a>
+              </a-menu-item>
+              <a-menu-item v-if="record.status === '1'">
+                <a-popconfirm title="纭畾鍋滅敤鍚�?" @confirm="() => handleStatus(record)">
+                  <a>鍋滅敤</a>
+                </a-popconfirm>
+              </a-menu-item>
+              <a-menu-item v-if="record.status === '2'">
+                <a-popconfirm title="纭畾鍚敤鍚�?" @confirm="() => handleStatus(record)">
+                  <a>鍚敤</a>
+                </a-popconfirm>
               </a-menu-item>
               <a-menu-item>
                 <a-popconfirm title="纭畾鍒犻櫎鍚�?" @confirm="() => handleDelete(record.id)">
@@ -119,7 +133,7 @@
       </a-table>
     </div>
 
-    <warehouse-modal ref="modalForm" @ok="modalFormOk"></warehouse-modal>
+    <warehouse-modal ref="modalForm" :treeSelected="treeSelected" @ok="modalFormOk"></warehouse-modal>
   </a-card>
 </template>
 
@@ -129,6 +143,8 @@
   import { mixinDevice } from '@/utils/mixin'
   import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   import WarehouseModal from './modules/WarehouseModal'
+  import { getAction, putAction, deleteAction } from '../../api/manage'
+  import moment from 'moment'
 
   export default {
     name: 'WarehouseList',
@@ -137,8 +153,16 @@
       WarehouseModal
     },
     data () {
+      const now = moment()
+      const lastWeek = now.clone().subtract(7,'days')
       return {
         description: '浠撳簱绠$悊',
+        queryParam: {
+          beginTime: lastWeek.format('YYYY-MM-DD HH:mm'),
+          endTime: now.format('YYYY-MM-DD HH:mm'),
+          warehouseName: '',
+          parentId: ''
+        },
         // 琛ㄥご
         columns: [
           {
@@ -164,17 +188,18 @@
           {
             title:'鐖惰妭鐐圭紪鍙�',
             align:"center",
-            dataIndex: 'parentId'
+            dataIndex: 'parentWarehouseId'
           },
           {
             title:'鐖惰妭鐐瑰悕绉�',
             align:"center",
-            dataIndex: 'parentName'
+            dataIndex: 'parentWarehouseName'
           },
           {
             title:'鐘舵��',
             align:"center",
-            dataIndex: 'status_dictText'
+            dataIndex: 'status',
+            scopedSlots: { customRender: 'status' }
           },
           {
             title:'澶囨敞',
@@ -184,12 +209,12 @@
           {
             title:'鍒涘缓浜�',
             align:"center",
-            dataIndex: 'createdBy'
+            dataIndex: 'createBy'
           },
           {
             title:'鍒涘缓鏃堕棿',
             align:"center",
-            dataIndex: 'createdTime',
+            dataIndex: 'createTime',
             customRender:function (text) {
               return !text?"":(text.length>10?text.substr(0,10):text)
             }
@@ -206,6 +231,7 @@
         url: {
           list: "/tms/warehouse/list",
           delete: "/tms/warehouse/delete",
+          edit: "/tms/warehouse/edit",
           deleteBatch: "/tms/warehouse/deleteBatch",
           exportXlsUrl: "/tms/warehouse/exportXls",
           importExcelUrl: "tms/warehouse/importExcel",
@@ -213,6 +239,7 @@
         },
         dictOptions:{},
         superFieldList:[],
+        treeSelected: {},
       }
     },
     created() {
@@ -222,8 +249,81 @@
       importExcelUrl: function(){
         return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
       },
+      addFlag: function(){
+        return !(this.treeSelected.key && this.treeSelected.entity.leafFlag === '2');
+      }
+    },
+    mounted() {
+      this.$bus.$on('getCurrSelected', (data) => {
+        console.log(data)
+        this.treeSelected = data;
+        this.queryParam.parentId = data.key;
+        this.loadData();
+      });
+    },
+    beforeDestroy() {
+      this.$bus.$off('getCurrSelected', {});
     },
     methods: {
+      handleStatus(record) {
+        const params = {
+          id: record.id,
+          status: record.status === '1' ? '2' : '1'
+        }
+        putAction(this.url.edit, params).then((res) => {
+          if (res.success) {
+            this.$message.success(res.message)
+            this.loadData()
+          } else {
+            this.$message.warning(res.message)
+          }
+        })
+      },
+      handleDelete(id) {
+        getAction(this.url.list, { parentId: id }).then((res) => {
+          if (res.success) {
+            if (res.result.total > 0) {
+              this.$message.warning('璇峰厛鍒犻櫎瀛愯妭鐐�');
+            } else {
+              deleteAction(this.url.delete, {id: id}).then((res) => {
+                if (res.success) {
+                  //閲嶆柊璁$畻鍒嗛〉闂
+                  this.loadData()
+                  this.$message.success(res.message);
+                  this.$bus.$emit('queryTreeData')
+                } else {
+                  this.$message.warning(res.message);
+                }
+              });
+            }
+          } else {
+            this.$message.warning(res.message);
+          }
+        })
+      },
+      // onBeginTimeChange(date, dateString) {
+      //   this.queryParam.begin_time = dateString[0]
+      // },
+      // onEndTimeChange(date, dateString) {
+      //   this.queryParam.end_time = dateString[0]
+      // },
+      searchReset() {
+        const now = moment()
+        const lastWeek = now.clone().subtract(7,'days')
+        this.queryParam = {
+          beginTime: lastWeek.format('YYYY-MM-DD HH:mm'),
+          endTime: now.format('YYYY-MM-DD HH:mm'),
+          warehouseName: '',
+          parentId: ''
+        }
+        this.treeSelected = {}
+        this.loadData(1)
+        this.$bus.$emit('clearTreeSelection')
+      },
+      modalFormOk() {
+        this.loadData()
+        this.$bus.$emit('queryTreeData')
+      },
       initDictConfig(){
       },
       getSuperFieldList(){
@@ -235,8 +335,8 @@
         fieldList.push({type:'string',value:'leafFlag',text:'鏄惁鍙跺瓙鑺傜偣(1鏄�;2鍚�)',dictCode:''})
         fieldList.push({type:'string',value:'status',text:'鐘舵�侊紙1鍚敤;2鍋滅敤锛�',dictCode:''})
         fieldList.push({type:'string',value:'remark',text:'澶囨敞',dictCode:''})
-        fieldList.push({type:'string',value:'createdBy',text:'鍒涘缓浜�',dictCode:''})
-        fieldList.push({type:'date',value:'createdTime',text:'鍒涘缓鏃堕棿'})
+        fieldList.push({type:'string',value:'createBy',text:'鍒涘缓浜�',dictCode:''})
+        fieldList.push({type:'date',value:'createTime',text:'鍒涘缓鏃堕棿'})
         this.superFieldList = fieldList
       }
     }
@@ -244,4 +344,10 @@
 </script>
 <style scoped>
   @import '~@assets/less/common.less';
+  .enable {
+    color: green;
+  }
+  .disable {
+    color: red;
+  }
 </style>
\ No newline at end of file

--
Gitblit v1.9.3