| | |
| | | <view class="action-buttons"> |
| | | <button v-if="isUpdate && !isShowTable && current" class="primary-btn" @click="getItem">生成检验单</button> |
| | | <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="toImage">图片管理</button> |
| | | <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="fetchItems">获取检验项目</button> |
| | | <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="saveRemarks">添加描述</button> |
| | | <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="showTablePopup = true">查看数据</button> |
| | | <button v-if="!isUpdate && !isShowTable && current" class="primary-btn" @click="submitInspection">检验提交</button> |
| | |
| | | this.initPopupTableData(); |
| | | }, |
| | | methods: { |
| | | // 手动获取现有检验项目(调用 /RKJ/getItems) |
| | | fetchItems() { |
| | | if (!this.formData.id) { |
| | | this.$showMessage("请先生成或打开检验单"); |
| | | return; |
| | | } |
| | | this.$post({ |
| | | url: "/RKJ/getItems", |
| | | data: { pid: this.formData.id } |
| | | }).then(res1 => { |
| | | let tableData = res1.data.tbBillList; |
| | | // 排序与 init 保持一致 |
| | | tableData.sort((a, b) => { |
| | | if (a.result === '未完成' && b.result === '合格') { |
| | | return -1; |
| | | } else if (a.result === '合格' && b.result === '未完成') { |
| | | return 1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | }); |
| | | this.tableData = tableData; |
| | | this.isShowTable = this.tableData.length === 0; |
| | | // 为每一项添加 current 属性 |
| | | this.tableData.forEach((item) => { |
| | | this.$set(item, 'current', this.current); |
| | | }); |
| | | }); |
| | | }, |
| | | // 获取合格项目数量 |
| | | getPassedCount() { |
| | | return this.tableData.filter(item => item.result === '合格').length; |