快乐的昕的电脑
2025-10-09 cb0f0660986138df8cd2b268124edfe9c06b39e3
components/mold.vue
@@ -116,10 +116,26 @@
         };
      },
      methods: {
         searchTool() {
            this.filteredTools = this.toolList.filter(t =>
               t.no.includes(this.searchKey) || t.name.includes(this.searchKey)
            );
         async fetchTools(searchKey) {
            // 实际项目中请替换为你的后端接口地址
            const res = await fetch('/api/QueryTools', {
               method: 'POST',
               headers: { 'Content-Type': 'application/json' },
               body: JSON.stringify(searchKey)
            });
            const data = await res.json();
            if (data.status === 0) {
               this.filteredTools = data.data.tbBillList.map(t => ({
                  no: t.cutterId || t.no,
                  name: t.cutterName || t.name,
                  model: t.cutterModel || t.model
               }));
            } else {
               this.$showMessage(data.message || '查询失败');
            }
         },
         async searchTool() {
            await this.fetchTools(this.searchKey);
         },
         selectTool(tool) {
            this.selectedToolNo = tool.no;
@@ -141,11 +157,15 @@
            this.selectedToolNo = '';
            this.toolName = '';
            this.toolModel = '';
         },
         setUseLimit() {
            // 保存使用上限逻辑,实际应调用后端接口
            this.$showMessage('使用上限已保存(示例)');
         }
      },
      mounted() {
         // 实际应从后端加载刀具目录和使用记录
         this.filteredTools = this.toolList;
         // 页面加载时拉取全部刀具
         this.fetchTools('');
      }
   };
</script>