llj
2025-12-15 a0010bcabbfbc3771aa05d54094f5d02bcdd5609
src/views/gyMaterial/GyMaterialCorrection.vue
@@ -15,15 +15,15 @@
        <el-card class="search-card">
          <div slot="header" class="clearfix">
            <span>查询条件</span>
            <el-button
              style="float: right; padding: 3px 0"
            <el-button
              style="float: right; padding: 3px 0"
              type="text"
              @click="toggleSearchMore"
            >
              {{ searchMore ? '收起' : '更多' }}
            </el-button>
          </div>
          <el-form :model="queryParams" ref="queryForm" label-width="80px">
            <el-row :gutter="20">
              <el-col :span="6">
@@ -126,7 +126,7 @@
                    </el-col>
                  </el-row>
                </div>
                <el-button
                  type="primary"
                  icon="el-icon-plus"
@@ -175,7 +175,7 @@
                </el-button>
              </div>
            </div>
            <div class="table-container">
              <el-table
                ref="mainTable"
@@ -204,7 +204,7 @@
                  </template>
                </el-table-column>
              </el-table>
              <!-- 分页 -->
              <div class="pagination-container">
                <el-pagination
@@ -245,7 +245,7 @@
                </el-button>
              </div>
            </div>
            <div class="table-container">
              <el-table
                ref="tempTable"
@@ -270,7 +270,7 @@
                      size="mini"
                      @change="handleCellEdit(row, column.field, $index)"
                    />
                    <!-- 下拉选择框 - 物料属性 -->
                    <el-select
                      v-else-if="column.field === '物料属性'"
@@ -283,7 +283,7 @@
                      <el-option value="自制" label="自制"></el-option>
                      <el-option value="委外" label="委外"></el-option>
                    </el-select>
                    <!-- 下拉选择框 - 事业部 -->
                    <el-select
                      v-else-if="column.field === '事业部'"
@@ -296,7 +296,7 @@
                      <el-option value="软磁事业部" label="软磁事业部"></el-option>
                      <el-option value="其他事业部" label="其他事业部"></el-option>
                    </el-select>
                    <!-- 不可编辑字段 -->
                    <span v-else>{{ row[column.field] }}</span>
                  </template>
@@ -347,34 +347,34 @@
      loading: false,
      tempLoading: false,
      columnSettingVisible: false,
      // 查询参数
      queryParams: {
        HNumber: '',
        HName: '',
        HOrgID: ''
      },
      // 过滤条件
      filterConditions: [
        { colName: '0', comparator: '0', colContent: '' }
      ],
      // 组织选项
      organizationOptions: [],
      // 表格数据
      tableData: [],
      tempTableData: [],
      selectedRows: [],
      // 分页
      pagination: {
        page: 1,
        size: 50,
        total: 0
      },
      // 列配置
      allColumns: [],
      mainTableColumns: [],
@@ -384,8 +384,8 @@
      openColumnSetting: false,
      // 模块名称
      HModName: 'Gy_Material_Correction',
      baseURL: process.env.VUE_APP_BASE_URL || 'http://47.96.97.237/API/',
      baseURL: process.env.VUE_APP_BASE_API || 'http://47.96.97.237/API/',
      user: 'admin'
    }
  },
@@ -414,7 +414,7 @@
      await this.getOrganizations()
      await this.getTableData()
    },
    // 获取组织列表
    async getOrganizations() {
      try {
@@ -429,9 +429,9 @@
        this.$modal.msgError('获取组织列表失败!')
      }
    },
    // 设置默认列
    setDefaultColumns() {
      this.allColumns = [
@@ -459,20 +459,20 @@
        { field: '创建人', title: '创建人', width: 100 },
        { field: '创建时间', title: '创建时间', width: 150 }
      ]
      this.mainTableColumns = this.allColumns.filter(col => !col.hide)
      this.tempTableColumns = this.mainTableColumns.map(col => ({
        ...col,
        editable: this.isEditableColumn(col.field)
      }))
    },
    // 获取表格数据
    async getTableData() {
      this.loading = true
      try {
        const sWhere = this.buildWhereCondition()
        const response = await axios.get(`${this.baseURL}/Gy_Material/page`, {
          params: {
            sWhere: sWhere,
@@ -482,7 +482,7 @@
            Organization: ''
          }
        })
        if (response.data.code === 1) {
          this.tableData = response.data.data
          this.pagination.total = response.data.count
@@ -495,11 +495,11 @@
        this.loading = false
      }
    },
    // 构建查询条件
    buildWhereCondition() {
      let sWhere = ''
      // 基本查询条件
      if (this.queryParams.HNumber) {
        sWhere += ` and 物料代码 like '%${this.queryParams.HNumber}%'`
@@ -510,7 +510,7 @@
      if (this.queryParams.HOrgID) {
        sWhere += ` and HUSEORGID = '${this.queryParams.HOrgID}'`
      }
      // 过滤条件
      this.filterConditions.forEach(filter => {
        if (filter.colName && filter.colName !== '0' && filter.comparator && filter.comparator !== '0') {
@@ -534,16 +534,16 @@
          sWhere += ` and ${filter.colName} ${condition}`
        }
      })
      return sWhere
    },
    // 查询
    handleSearch() {
      this.pagination.page = 1
      this.getTableData()
    },
    handleColumnSetting() {
      this.columnSettingShow = true;
      this.openColumnSetting = true;
@@ -568,7 +568,7 @@
      this.pagination.page = 1
      this.getTableData()
    },
    // 添加过滤条件
    addFilter() {
      this.filterConditions.push({
@@ -577,50 +577,50 @@
        colContent: ''
      })
    },
    // 删除过滤条件
    removeFilter(index) {
      this.filterConditions.splice(index, 1)
    },
    // 切换更多搜索条件
    toggleSearchMore() {
      this.searchMore = !this.searchMore
    },
    // 选择行变化
    handleSelectionChange(selection) {
      this.selectedRows = selection
    },
    // 数据确认 - 将选中的数据复制到临时表格
    handleDataConfirm() {
      if (this.selectedRows.length === 0) {
        this.$modal.msgWarning('请先选择要批改的数据!')
        return
      }
      // 深拷贝选中的数据到临时表格
      this.tempTableData = JSON.parse(JSON.stringify(this.selectedRows))
      // 锁定主表格中已选中的行(通过CSS类名)
      this.$nextTick(() => {
        this.$refs.mainTable.clearSelection()
      })
      this.$modal.msgSuccess(`已确认 ${this.selectedRows.length} 条数据,请在右侧表格中进行批改`)
    },
    // 保存批改数据
    async handleSave() {
      if (this.tempTableData.length === 0) {
        this.$modal.msgWarning('没有需要保存的数据!')
        return
      }
      try {
        this.tempLoading = true
        // 转换数据格式
        const saveData = this.tempTableData.map(item => ({
          HOnceRightRate: item['一次合格率标准值'],
@@ -643,7 +643,7 @@
          // 其他需要保存的字段...
          HItemID: item.HItemID
        }))
        // 数据验证
        for (const item of saveData) {
          if (!item.HNumber) {
@@ -654,12 +654,12 @@
          }
          // 其他验证规则...
        }
        const dataStr = JSON.stringify(saveData)
        const response = await axios.post(`${this.baseURL}/Gy_Material/SaveGy_MaterialList_Batch`, {
          msg: dataStr + ';' + this.user + ';' + this.queryParams.HOrgID
        })
        if (response.data.count === 1) {
          this.$modal.msgSuccess('保存成功!')
          this.tempTableData = []
@@ -673,14 +673,14 @@
        this.tempLoading = false
      }
    },
    // 删除数据
    async handleDelete() {
      if (this.selectedRows.length === 0) {
        this.$modal.msgWarning('请选择要删除的数据!')
        return
      }
      try {
        await this.$confirm('确认要删除选中的数据吗?', '提示', {
          type: 'warning'
@@ -693,7 +693,7 @@
            }
          })
        }
        this.$modal.msgSuccess('删除成功!')
        this.getTableData()
        this.selectedRows = []
@@ -703,13 +703,13 @@
        }
      }
    },
    // 单元格编辑
    handleCellEdit(row, field, index) {
      // 可以在这里添加编辑验证逻辑
      console.log(`编辑第${index + 1}行,字段: ${field}, 值: ${row[field]}`)
    },
    // 下拉选择变化
    handleSelectChange(field) {
      // 批量更新相同字段的值
@@ -717,12 +717,12 @@
        // 这里可以根据业务需求决定是否同步更新所有行的相同字段
      })
    },
    // 列设置
    handleColumnSetting() {
      this.columnSettingVisible = true
    },
    // 保存列设置
    handleColumnSave(columns) {
      this.allColumns = columns
@@ -735,7 +735,7 @@
    },
    // 退出
    handleExit() {
      if (this.tempTableData.length > 0) {
@@ -748,26 +748,26 @@
        this.handleClose()
      }
    },
    // 关闭对话框
    handleClose() {
      this.openCorrect = false
      this.$emit('close')
    },
    // 分页大小变化
    handleSizeChange(size) {
      this.pagination.size = size
      this.pagination.page = 1
      this.getTableData()
    },
    // 当前页变化
    handleCurrentChange(page) {
      this.pagination.page = page
      this.getTableData()
    },
    // 工具方法
    isEditableColumn(field) {
      const nonEditableFields = [
@@ -775,25 +775,25 @@
      ]
      return !nonEditableFields.includes(field)
    },
    isSelectColumn(field) {
      return ['物料属性', '事业部'].includes(field)
    },
    isDateColumn(field) {
      return field.includes('时间') || field.includes('日期')
    },
    formatDate(dateString) {
      if (!dateString) return ''
      const date = new Date(dateString)
      return date.toLocaleString('zh-CN')
    },
    getRowClassName({ row }) {
      return this.selectedRows.some(selected => selected.HItemID === row.HItemID) ? 'locked-row' : ''
    },
    divisionJudgment(divisionStr) {
      switch (divisionStr) {
        case '注塑事业部': return 3
@@ -801,7 +801,7 @@
        default: return 0
      }
    },
    materClsJudgment(materClsStr) {
      switch (materClsStr) {
        case '外购': return '1'
@@ -910,4 +910,4 @@
::v-deep .temp-table .el-select {
  width: 100%;
}
</style>
</style>