lixiangyu
昨天 8b5bfdeb201b2653fb648f742b6d4ff5ff05ff6c
src/views/cms/CuttingToolList.vue
@@ -1,5 +1,5 @@
<template>
  <a-card :bordered="false">
  <a-card :bordered="false" >
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
@@ -121,9 +121,18 @@
      </a-table>
    </div>
    <a-tabs defaultActiveKey="1">
    <a-tabs defaultActiveKey="1" @change="onTabChange">
      <a-tab-pane tab="扩展属性" key="1">
        <cutting-properties-list ref="cuttingPropertiesList"></cutting-properties-list>
      </a-tab-pane>
      <a-tab-pane key="2" tab="刀具库存">
        <cutting-inventory-list ref="cuttingInventoryList"></cutting-inventory-list>
      </a-tab-pane>
      <a-tab-pane key="3" tab="刀具额定寿命">
        <rated-life-list
          ref="RatedLifeList"
          :selected-cutting-id="selectedRowKeys.length > 0 ? selectedRowKeys[0] : ''">
        </rated-life-list>
      </a-tab-pane>
    </a-tabs>
    <!-- table区域-end -->
@@ -140,15 +149,20 @@
import CuttingPropertiesList from './CuttingPropertiesList'
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
import CuttingInventoryList from '@views/cms/CuttingInventoryList.vue'
import RatedLifeList from '@views/cms/RatedLifeList.vue'
import { getAction } from '@api/manage'
export default {
  name: 'CuttingToolList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    RatedLifeList,
    CuttingInventoryList,
    CuttingToolModal,
    CuttingPropertiesList,
    JDictSelectTag,
    JSearchSelectTag
    JSearchSelectTag,
  },
  data() {
    return {
@@ -255,12 +269,32 @@
        }
      };
    },
    onSelectChange(selectedRowKeys) {
      console.log('Selected row keys:', selectedRowKeys);
      this.selectedRowKeys = selectedRowKeys;
      if (selectedRowKeys.length > 0) {
        this.$refs.cuttingPropertiesList.getCuttingProperties(selectedRowKeys[0]);
        console.log('Loading details for:', selectedRowKeys[0]);
        const selectedId = selectedRowKeys[0];
        // 使用 $nextTick 确保 DOM 更新完成
        this.$nextTick(() => {
          // 检查并调用各个子组件的方法,无论当前在哪个页签
          if (this.$refs.cuttingPropertiesList) {
            this.$refs.cuttingPropertiesList.getCuttingProperties(selectedId);
          }
          if (this.$refs.RatedLifeList) {
            this.$refs.RatedLifeList.getRatedLife(selectedId);
          }
          if (this.$refs.cuttingInventoryList) {
            this.$refs.cuttingInventoryList.getCuttingInventory(selectedId);
          }
        });
      }
    },
    handleEdit(record) {
      this.$refs.modalForm.edit(record);
      this.$refs.modalForm.title = '编辑';
@@ -278,20 +312,127 @@
    },
    searchQuery() {
      this.selectedRowKeys = [];
      this.$refs.cuttingPropertiesList.getCuttingProperties("-1");
      this.$refs.cuttingPropertiesList.loadData();
      this.$refs.cuttingPropertiesList.selectedRowKeys = [];
      this.loadData();
      // 清理所有子组件的数据
      this.$nextTick(() => {
        if (this.$refs.cuttingPropertiesList) {
          this.$refs.cuttingPropertiesList.getCuttingProperties("-1");
          this.$refs.cuttingPropertiesList.loadData();
          this.$refs.cuttingPropertiesList.selectedRowKeys = [];
        }
        if (this.$refs.cuttingInventoryList) {
          this.$refs.cuttingInventoryList.getCuttingInventory("-1");
          this.$refs.cuttingInventoryList.selectedRowKeys = [];
        }
        if (this.$refs.RatedLifeList) {
          this.$refs.RatedLifeList.getRatedLife("-1");
          this.$refs.RatedLifeList.selectedRowKeys = [];
        }
      });
    },
    searchReset() {
      this.queryParam = {
        cuttingCode: '',
        cuttingName: '',
        cuttingCategory: ''
      };
      this.$refs.cuttingPropertiesList.getCuttingProperties("-1");
      this.selectedRowKeys = [];
      this.loadData();
      // 清理所有子组件的数据
      this.$nextTick(() => {
        if (this.$refs.cuttingPropertiesList) {
          this.$refs.cuttingPropertiesList.getCuttingProperties("-1");
          this.$refs.cuttingPropertiesList.selectedRowKeys = [];
        }
        if (this.$refs.cuttingInventoryList) {
          this.$refs.cuttingInventoryList.getCuttingInventory("-1");
          this.$refs.cuttingInventoryList.selectedRowKeys = [];
        }
        if (this.$refs.RatedLifeList) {
          this.$refs.RatedLifeList.getRatedLife("-1");
          this.$refs.RatedLifeList.selectedRowKeys = [];
        }
      });
    },
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
      // 清空 CuttingPropertiesList 列表数据
      this.$refs.cuttingPropertiesList.dataSource = [];
      this.$refs.cuttingPropertiesList.selectedRowKeys = [];
      this.$refs.cuttingPropertiesList.selectionRows = [];
      this.$refs.cuttingPropertiesList.queryParam.cuttingId = "-1";
    },
    loadData(arg) {
      if(!this.url.list){
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();//查询条件
      console.log('params',params)
      if(!params){
        return false;
      }
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          // console.log(res)
          //update-begin---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
          this.dataSource = res.result.records||res.result;
          if(res.result.total)
          {
            this.ipagination.total = res.result.total;
          }else{
            this.ipagination.total = 0;
          }
          //update-end---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
        }else{
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    onTabChange(activeKey) {
      // 当页签切换时,如果已有选中的刀具,立即加载对应的数据
      if (this.selectedRowKeys.length > 0) {
        const selectedId = this.selectedRowKeys[0];
        this.$nextTick(() => {
          switch(activeKey) {
            case '1':
              if (this.$refs.cuttingPropertiesList) {
                this.$refs.cuttingPropertiesList.getCuttingProperties(selectedId);
              }
              break;
            case '2':
              if (this.$refs.cuttingInventoryList) {
                this.$refs.cuttingInventoryList.getCuttingInventory(selectedId);
              }
              break;
            case '3':
              if (this.$refs.RatedLifeList) {
                this.$refs.RatedLifeList.getRatedLife(selectedId);
              }
              break;
          }
        });
      }
    },
    handleOk() {
      // 新增/修改 成功时,重载列表
      this.loadData();