|
@@ -296,7 +296,8 @@ import {
|
|
|
getassayConfigPage,
|
|
|
getCollectRecordPage,
|
|
|
getSampleplacedPage,
|
|
|
- addCollectRecord
|
|
|
+ addCollectRecord,
|
|
|
+ assayresultwSaveBatch
|
|
|
} from '@/api/dcApi/assayMngApi'
|
|
|
|
|
|
import ReturnPdf from '../../../common/ReturnPdf'
|
|
@@ -359,7 +360,8 @@ export default {
|
|
|
pdfData: [],
|
|
|
column: [],
|
|
|
samplingLocationData: [],
|
|
|
- excelFileName: ''
|
|
|
+ excelFileName: '',
|
|
|
+ commitType: 'JSON' // JSON OR FORMDATA
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -484,12 +486,13 @@ export default {
|
|
|
/**
|
|
|
* 验证数据
|
|
|
*/
|
|
|
- validationData() {
|
|
|
+ validationData(type) {
|
|
|
if (this.tableData.length == 0) {
|
|
|
this.$message.warning('请选择化验项配置!')
|
|
|
return false
|
|
|
}
|
|
|
const formData = new FormData()
|
|
|
+ const result = []
|
|
|
let currentDay = moment().format('YYYY-MM-DD')
|
|
|
const find = this.tableData.find(item => item.assayTime === currentDay)
|
|
|
if (find) {
|
|
@@ -527,22 +530,32 @@ export default {
|
|
|
currentDay = row[key]
|
|
|
continue
|
|
|
}
|
|
|
- formData.append(`assayResultDetails[${indexNum}].assayDicId`, key.replace('value', '')) // 化验项id
|
|
|
- formData.append(`assayResultDetails[${indexNum}].assayCheckValue`, row[key]) // 化验值
|
|
|
- formData.append(`assayResultDetails[${indexNum}].assayUser`, this.$store.state.user.realName) // 化验人员
|
|
|
- formData.append(`assayResultDetails[${indexNum}].assayTime`, currentDay) // 化验时间
|
|
|
- formData.append(`assayResultDetails[${indexNum}].assayResult`, '合格') // 化验结果
|
|
|
+ if (type === 'JSON') {
|
|
|
+ result.push({
|
|
|
+ assayDicId: key.replace('value', ''),
|
|
|
+ assayCheckValue: row[key],
|
|
|
+ assayUser: this.$store.state.user.realName,
|
|
|
+ assayTime: currentDay,
|
|
|
+ assayResult: '合格'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ formData.append(`assayResultDetails[${indexNum}].assayDicId`, key.replace('value', '')) // 化验项id
|
|
|
+ formData.append(`assayResultDetails[${indexNum}].assayCheckValue`, row[key]) // 化验值
|
|
|
+ formData.append(`assayResultDetails[${indexNum}].assayUser`, this.$store.state.user.realName) // 化验人员
|
|
|
+ formData.append(`assayResultDetails[${indexNum}].assayTime`, currentDay) // 化验时间
|
|
|
+ formData.append(`assayResultDetails[${indexNum}].assayResult`, '合格') // 化验结果
|
|
|
+ }
|
|
|
indexNum++
|
|
|
}
|
|
|
}
|
|
|
- return formData
|
|
|
+ return type === 'JSON' ? result : formData
|
|
|
},
|
|
|
|
|
|
commit() {
|
|
|
this.$refs['ruleForm'].validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
this.dialogLoading = true
|
|
|
- const formData = this.validationData()
|
|
|
+ let formData = this.validationData(this.commitType)
|
|
|
if (!formData) return
|
|
|
if (!this.ruleForm.collectNo) {
|
|
|
this.ruleForm.collectNo = await this.getItemList()
|
|
@@ -551,11 +564,25 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- formData.append('assayResultName', this.ruleForm.assayResultName)
|
|
|
- formData.append('assayConfigId', this.ruleForm.assayConfigId)
|
|
|
- formData.append('collectNo', this.ruleForm.collectNo)
|
|
|
- formData.append('remark', this.ruleForm.remark)
|
|
|
- addAssayResult(formData).then((res) => {
|
|
|
+ let _run = addAssayResult
|
|
|
+ if (this.commitType === 'JSON') {
|
|
|
+ formData = {
|
|
|
+ assayResultDetails: formData,
|
|
|
+ id: this.ruleForm.id,
|
|
|
+ assayResultName: this.ruleForm.assayResultName,
|
|
|
+ assayConfigId: this.ruleForm.assayConfigId,
|
|
|
+ collectNo: this.ruleForm.collectNo,
|
|
|
+ remark: this.ruleForm.remark
|
|
|
+ }
|
|
|
+ _run = assayresultwSaveBatch
|
|
|
+ } else {
|
|
|
+ formData.append('assayResultName', this.ruleForm.assayResultName)
|
|
|
+ formData.append('assayConfigId', this.ruleForm.assayConfigId)
|
|
|
+ formData.append('collectNo', this.ruleForm.collectNo)
|
|
|
+ formData.append('remark', this.ruleForm.remark)
|
|
|
+ }
|
|
|
+
|
|
|
+ _run(formData).then((res) => {
|
|
|
if (res.code == 1) {
|
|
|
this.$message.success('新增成功')
|
|
|
this.dialogVisible = false
|
|
@@ -630,15 +657,29 @@ export default {
|
|
|
upData() {
|
|
|
this.$refs['ruleForm'].validate(async(valid) => {
|
|
|
if (valid) {
|
|
|
- const formData = this.validationData()
|
|
|
+ let formData = this.validationData(this.commitType)
|
|
|
if (!formData) return
|
|
|
- formData.append('id', this.ruleForm.id)
|
|
|
- formData.append('assayResultName', this.ruleForm.assayResultName)
|
|
|
- formData.append('assayConfigId', this.ruleForm.assayConfigId)
|
|
|
- formData.append('collectNo', this.ruleForm.collectNo)
|
|
|
- formData.append('remark', this.ruleForm.remark)
|
|
|
+ let _run = editAssayResult
|
|
|
+ debugger
|
|
|
+ if (this.commitType === 'JSON') {
|
|
|
+ formData = {
|
|
|
+ assayResultDetails: formData,
|
|
|
+ id: this.ruleForm.id,
|
|
|
+ assayResultName: this.ruleForm.assayResultName,
|
|
|
+ assayConfigId: this.ruleForm.assayConfigId,
|
|
|
+ collectNo: this.ruleForm.collectNo,
|
|
|
+ remark: this.ruleForm.remark
|
|
|
+ }
|
|
|
+ _run = assayresultwSaveBatch
|
|
|
+ } else {
|
|
|
+ formData.append('id', this.ruleForm.id)
|
|
|
+ formData.append('assayResultName', this.ruleForm.assayResultName)
|
|
|
+ formData.append('assayConfigId', this.ruleForm.assayConfigId)
|
|
|
+ formData.append('collectNo', this.ruleForm.collectNo)
|
|
|
+ formData.append('remark', this.ruleForm.remark)
|
|
|
+ }
|
|
|
|
|
|
- editAssayResult(formData).then((res) => {
|
|
|
+ _run(formData).then((res) => {
|
|
|
if (res.code == 1) {
|
|
|
this.$message.success('修改成功')
|
|
|
this.dialogVisible = false
|