licp
2024-04-25 f6811caf6c66d4e2a55393f3b6dc169efd28d863
src/views/technology/document/teststandard.vue
@@ -6,6 +6,7 @@
          :table="table"
          @handleSelectionChange="handleSelectionChange"
          @currentChange="handleCurrentChange"
          @shoudonggouxuan="handleCurrentChange"
          :uploadInfo="uploadInfo"
          :prelang="prelang"
          :options="options"
@@ -18,14 +19,30 @@
        </ttable>
      </el-col>
      <el-col :span="12" style="padding-left: 10px">
        <div style="float: right;margin-bottom: 8px;" v-if="editable && currentRow&&currentRow.id">
        <el-button
            style="padding: 3px 0"
            type="text"
            size="medium"
            @click="saveAllParamChange"
            >保存
        </el-button>
        <!-- <el-button
            style="padding: 3px 0"
            type="text"
            size="medium"
            @click="openTempalteParamDialog"
            >添加
        </el-button> -->
        </div>
        <el-table
          :data="testStandardParams"
          id="testStandardParamTable"
          ref="testStandardParam"
          :default-sort="{ prop: 'index' }"
          highlight-current-row
          height="500"
          style="width: 100%"
          max-height="500"
          style="width: 100%;overflow-x: auto;"
        >
          <el-table-column
            prop="index"
@@ -39,10 +56,54 @@
            label="要求值"
            prop="referenceValue"
            align="center"
          />
          <el-table-column label="单位" prop="unit" align="center" />
          <el-table-column label="测试方法" prop="method" align="center" />
          <el-table-column label="测试目的" prop="purpose" align="center" />
            width="120px"
          >
          <template slot-scope="scope">
                <el-input
                v-model="scope.row.referenceValue"
                placeholder="值"
                :disabled="!editable"
                ></el-input>
            </template>
            </el-table-column>
          <el-table-column label="单位" prop="unit" align="center" width="120px">
            <template slot-scope="scope">
                <el-input
                v-model="scope.row.unit"
                placeholder="单位"
                :disabled="!editable"
                ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="测试方法" prop="method" align="center">
            <template slot-scope="scope">
                <el-input
                v-model="scope.row.method"
                placeholder=""
                :disabled="!editable"
                ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="测试目的" prop="purpose" align="center">
            <template slot-scope="scope">
                <el-input
                v-model="scope.row.purpose"
                placeholder=""
                :disabled="!editable"
                ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" fixed="right">
        <template slot-scope="scope">
            <el-button
            type="text"
            size="mini"
            v-if="editable && currentRow&&currentRow.id"
            @click.stop="handleParamDelete(scope.row, scope.$index)"
            >删除
            </el-button>
        </template>
        </el-table-column>
        </el-table>
      </el-col>
    </el-row>
@@ -60,7 +121,9 @@
  deleteTestStandard,
  getTestStand,
  saveTestStandard,
  getTestStandardParams
  getTestStandardParams,
  deleteTestStandardParam,
  saveTestStandardParam,
} from '@/api/technology/document'
import qualityStandardDialog from '@/views/common/teststandardradio.vue'
@@ -289,6 +352,46 @@
    handleSelectionChange(val) {
      // 多行选中
      this.multipleSelection = val
    },
    saveAllParamChange(){
        this.testStandardParams.forEach(e=>{
        if(e.referenceValue!=null){
        e.referenceValue=e.referenceValue.replace(',',',').replace('(','(').replace(')',')')
          if (!isNaN(e.referenceValue)) {
            e.referenceValue='='+e.referenceValue
          }
        }
      })
      saveTestStandardParam(this.testStandardParams).then((response) => {
        const data = response.data
        if (data.code == 0) {
          this.$message.success('保存成功')
          this.getTestStandardParamData(this.currentRow.id)
        } else {
          this.$message.error('保存失败')
        }
      })
    },
    openTempalteParamDialog(){},
    handleParamDelete(row, index){
        this.$confirm('是否确认删除参数项为' + row.parameterItem, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(function() {
          return deleteTestStandardParam(row.id)
        })
        .then((response) => {
          const data = response.data
          if (data.code == 0) {
            // 删除当前行
            this.testStandardParams.splice(index, 1)
            this.$message.success('删除成功')
          } else {
            this.$message.error('删除失败')
          }
        })
    }
  }
}