快乐的昕的电脑
2025-10-09 c714ebbefe251a3b2ca8d11352ba6e646e040db5
components/mold.vue
@@ -42,8 +42,15 @@
               </button>
            </view>
            <view class="dialog-actions">
               <button class="btn-blue" @click="confirmTool">确定</button>
               <button class="btn-disabled" @click="showToolDialog = false">取消</button>
               <div style="display: flex; align-items: center;">
                  <button class="btn-blue" @click="prevPage" :disabled="pageIndex === 1">上一页</button>
                  <span style="margin: 0 12px;">第{{ pageIndex }}页 / 共{{ totalPages }}页</span>
                  <button class="btn-blue" @click="nextPage" :disabled="pageIndex === totalPages">下一页</button>
               </div>
               <div>
                  <button class="btn-blue" @click="confirmTool">确定</button>
                  <button class="btn-disabled" @click="showToolDialog = false">取消</button>
               </div>
            </view>
         </view>
      </view>
@@ -97,11 +104,10 @@
   export default {
      data() {
         return {
            toolList: [
               // 示例数据,实际应从后端接口获取
               { no: 'T22050338', name: 'm1.5合金长刀', model: 'xxx' },
               { no: 'T22050337', name: 'm0.546合金长刀', model: 'yyy' }
            ],
                pageIndex: 1,
                pageSize: 20,
                total: 0,
            toolList: [],
            selectedToolNo: '',
            toolName: '',
            toolModel: '',
@@ -115,11 +121,20 @@
            ]
         };
      },
        computed: {
            totalPages() {
                return Math.ceil(this.total / this.pageSize) || 1;
            }
        },
      methods: {
            async fetchTools(searchKey) {
                const res = await this.$post({
                    url: '/MesCutterLedger/QueryTools',
                    data: JSON.stringify({ searchKey }), // 关键点
                    data: JSON.stringify({
                        searchKey,
                        pageIndex: this.pageIndex,
                        pageSize: this.pageSize
                    }),
                    headers: { 'Content-Type': 'application/json' }
                });
                if (res.status === 0) {
@@ -128,13 +143,28 @@
                        name: t.cutterName || t.name,
                        model: t.cutterModel || t.model
                    }));
                    this.total = res.data.total || 0; // 假设后端返回总数
                } else {
                    this.$showMessage(res.message || '查询失败');
                }
            },
         async searchTool() {
            await this.fetchTools(this.searchKey);
         },
         //翻页
            async prevPage() {
                if (this.pageIndex > 1) {
                    this.pageIndex--;
                    await this.fetchTools(this.searchKey);
                }
            },
            async nextPage() {
                if (this.pageIndex < this.totalPages) {
                    this.pageIndex++;
                    await this.fetchTools(this.searchKey);
                }
            },
            async searchTool() {
                this.pageIndex = 1; // 搜索时重置到第一页
                await this.fetchTools(this.searchKey);
            },
         selectTool(tool) {
            this.selectedToolNo = tool.no;
            this.toolName = tool.name;