Commit 17e848af by lichengming

修改了数据录入生成试验项目报告

parent 5eb23d7b
<template>
<div>
<Modal v-model="showBatchModal" v-drag width="900">
<p slot="header">
生成项目报告
</p>
<div>
<!--内容-->
<div class="layout-content-padding">
<div class="layout-content-main">
<Row>
<!--样品信息-->
<!--报告模板-->
<Col span="24">
<ItemReportTemplate ref="reportTemplate" @on-result-change="_templateResultChange"></ItemReportTemplate>
</Col>
</Row>
</div>
</div>
</div>
<div slot="footer">
<modal-footer ref="footerModal" :footer="footerBtn" @on-result-change="_footerResult"></modal-footer>
</div>
</Modal>
<!--生成报告的进度条-->
</div>
</template>
<script>
import ItemReportTemplate from './ItemReportTemplate'
/**
* 样品列表--生成报告或者选择模板生成报告
*/
export default {
components: {
ItemReportTemplate
},
data() {
return {
selectIds: [],
getPage: {
records: []
},
showBatchModal: false,
isLoading: false,
footerBtn: [
{ type: '', id: '', name: '取消' },
{ type: 'primary', id: '', name: '确定' }
],
pageColumns: [
{ title: '样品名称', key: 'name', width: 160 },
{ title: '样品编号', key: 'code', width: 150 },
{ title: '证书编号', key: 'certificate', width: 150 }
],
reportModelId: '',
backData: {},
// 样品数据
tableData: [],
// 签发日期
issueDateTemp: '',
issueDate: '',
showIssueModal: false
}
},
methods: {
_open() {
this.getPage.records = []
this.backData = {}
this.showBatchModal = true
this._reportTemplate()
this.reportModelId = ''
this.isLoading = false
},
// 报告模板
_reportTemplate() {
this.$refs.reportTemplate._open()
},
_footerResult(name) {
switch (name) {
case '确定':
this._ok()
break
case '取消':
this.showBatchModal = false
break
}
},
_templateResultChange(selectData) {
this.backData = selectData[0]
},
_issueChange(data) {
if (data) {
this.issueDate = data
}
},
_hideLoading() {
this.$refs.footerModal._hideLoading()
},
_ok() {
this.$refs.footerModal._hideLoading()
if (!this.backData.name) {
this.$Message.warning('请选择一个原始记录模板!')
// this._hideLoading()
} else {
this.$emit('on-result-change', this.backData)
this.showBatchModal = false
}
},
_issueCancel() {
this.showIssueModal = false
},
// 选择时间ok
_issueOk() {
this.isLoading = true
this.showIssueModal = false
this._createOk()
},
// 生成报告
_createOk() {
const obj = []
for (let i = 0; i < this.tableData.length; i++) {
obj.push({
sampleId: this.tableData[i].id,
reportSn: this.tableData[i].reportSn,
issueDate: this.issueDate
})
}
this.$layxLoading(true, '数据验证中')
const validateObj = {
sampleReports: obj,
reportModelId: this.reportModelId
}
// 先进行验证
this.$store
.dispatch('FoodSampleReport/createReportValidate', validateObj)
.then(() => {
if (this.$store.state.FoodSampleReport.success) {
// 验证成功之后再建立连接,然后进行生成报告操作
// 建立websocket连接
const currentTime = new Date().getTime()
this.$refs.progressModal._open(this.tableData.length, currentTime)
validateObj.seriesNo = currentTime
console.log('生成报告的当前序列号,', validateObj.seriesNo)
this.$store
.dispatch('FoodSampleReport/createReport', validateObj)
.then(() => {})
}
this._hideLoading()
this.isLoading = false
this.$layxLoading(false)
})
},
_closeResult() {
this.showBatchModal = false
this.$emit('on-result-change')
}
}
}
</script>
......@@ -14,7 +14,7 @@
</Form>
</Col>
<Col span="24">
<btn-list @on-result-change="_btnClick" class="contHide" style="margin-bottom: 6px;"></btn-list>
<btn-list @on-result-change="_btnClick" :msg="btn" class="contHide" style="margin-bottom: 6px;"></btn-list>
</Col>
<!-- 表格 -->
<Col span="24">
......@@ -41,13 +41,15 @@
</Col>
</Row>
<CreateItemReport ref="createModal" @on-result-change="_certificateSelectExcelBack"></CreateItemReport>
<CreateBatchItemReport ref="createBatchModal" @on-result-change="_templateBack"></CreateBatchItemReport>
</div>
</template>
<script>
import { soilSample, soilTest } from '../../../../api'
import CreateItemReport from './CreateItemReport'
import CreateBatchItemReport from './CreateBatchItemReport'
export default {
components: { CreateItemReport },
components: { CreateItemReport, CreateBatchItemReport },
data() {
return {
currentComponent: '',
......@@ -58,7 +60,14 @@ export default {
name: undefined,
entrustId: undefined
},
formObjBatchSample: {
obj: {
entrustId: '',
nameList: []
}
},
sampleIds: [],
batchSampleIds: [],
itemName: '',
tableName: 'food-task-assign-item-left',
// 用户自己选中的列
......@@ -70,6 +79,13 @@ export default {
],
getPage: {},
iconMsg: [{ type: 'ios-book', id: '', name: '生成项目报告' }],
btn: [
{
type: 'success',
id: '',
name: '生成项目报告'
}
],
id: '',
selectId: '',
pageColumns: [{ title: '检测项目', key: 'name', width: 120 }]
......@@ -150,6 +166,10 @@ export default {
},
_btnClick(msg) {
switch (msg) {
case '生成项目报告':
// this.$emit('on-result-change', data)
this._itemReportMakeBatch()
break
case '自动分配':
this._autoAssign()
break
......@@ -165,12 +185,43 @@ export default {
}
})
},
_itemReportMakeBatch() {
if (this.selectDataName.length > 0) {
// this.itemName = data.name
this._searchBatchSampleId(this.id, this.selectDataName)
// this.selectId = data.id
this.$refs.createBatchModal._open()
} else {
this.$Message.warning('请至少选择一条数据')
}
},
_itemReportMake(data) {
this.itemName = data.name
this._searchSampleId(this.id, data.name)
// this.selectId = data.id
this.$refs.createModal._open()
},
_searchBatchSampleId: async function(id, name) {
Object.assign(
this.formObjBatchSample,
this.$refs.pageTable._searchParams()
)
this.formObjBatchSample.obj.entrustId = id
this.formObjBatchSample.obj.nameList = name
const result = await soilTest.pageExperimentTestBath(
this.$serializeForm(this.formObjBatchSample)
)
if (result) {
this.batchSampleIds = []
for (let i = 0; i < result.records.length; i++) {
this.batchSampleIds.push(result.records[i].id)
}
console.log('右侧样品id', this.batchSampleIds)
this.$refs.pageTable._hideLoading()
} else {
this.$refs.pageTable._hideLoading()
}
},
_searchSampleId: async function(id, name) {
Object.assign(this.formObjSample, this.$refs.pageTable._searchParams())
this.formObjSample.entrustId = id
......@@ -188,6 +239,14 @@ export default {
console.log('右侧样品id', this.sampleIds)
}
},
_templateBack(data) {
if (data) {
this.$refs.pageTable._showLoading()
this._makeBatchCodeExcel(data)
} else {
this.$refs.pageTable._hideLoading()
}
},
_certificateSelectExcelBack(data) {
if (data) {
this.$refs.pageTable._showLoading()
......@@ -196,6 +255,27 @@ export default {
this.$refs.pageTable._hideLoading()
}
},
_makeBatchCodeExcel: async function(data) {
const result = await soilSample.saveExcelExpReport({
entrustId: this.id,
expName: this.selectDataName.join(','),
ids: this.batchSampleIds.join(','),
templateId: data.id
})
if (result) {
// await this._page()
if (result === null || result === undefined) {
this.$Message.warning('证书编制失败,请联系管理员!')
this.$refs.pageTable._hideLoading()
return false
} else {
this.$refs.pageTable._hideLoading()
this._viewReport(result)
}
} else {
this.$refs.pageTable._hideLoading()
}
},
_makeCodeExcel: async function(data) {
const result = await soilSample.saveExcelExpReport({
entrustId: this.id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment