Commit 29e06c88 by lichengming

修改了生成项目报告

parent 32015bb9
<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>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<Col span="24"> <Col span="24">
<PTVXETable ref="pageTable" :isRadio="true" :pageColumns="pageColumns" :table-name="tableName" <PTVXETable ref="pageTable" :isRadio="true" :pageColumns="pageColumns" :table-name="tableName"
:tableHeight="tableHeight" :tableHeight="tableHeight"
@on-result-change="_tableResultChange" :getPage="getPage" :hide-checkbox="true" select-data> @on-result-change="_tableResultChange" :getPage="getPage" :icon-msg="iconMsg" :hide-checkbox="true" select-data>
<vxe-table-column <vxe-table-column
v-for="item in userColumns.length > 0 ?userColumns:pageColumns" v-for="item in userColumns.length > 0 ?userColumns:pageColumns"
:key="item.key" :key="item.key"
...@@ -40,18 +40,26 @@ ...@@ -40,18 +40,26 @@
</PTVXETable> </PTVXETable>
</Col> </Col>
</Row> </Row>
<CreateItemReport ref="createModal" @on-result-change="_certificateSelectExcelBack"></CreateItemReport>
</div> </div>
</template> </template>
<script> <script>
import { soilTest } from '../../../../api' import { soilSample, soilTest } from '../../../../api'
import CreateItemReport from './CreateItemReport'
export default { export default {
components: {}, components: { CreateItemReport },
data() { data() {
return { return {
currentComponent: '', currentComponent: '',
formObj: { formObj: {
name: undefined name: undefined
}, },
formObjSample: {
name: undefined,
entrustId: undefined
},
sampleIds: [],
itemName: '',
tableName: 'food-task-assign-item-left', tableName: 'food-task-assign-item-left',
// 用户自己选中的列 // 用户自己选中的列
userColumns: [], userColumns: [],
...@@ -60,7 +68,9 @@ export default { ...@@ -60,7 +68,9 @@ export default {
{ key: 'testBasis', name: '检测依据', placeholder: '请输入检测依据' } { key: 'testBasis', name: '检测依据', placeholder: '请输入检测依据' }
], ],
getPage: {}, getPage: {},
iconMsg: [{ type: 'ios-book', id: '', name: '生成项目报告' }],
id: '', id: '',
selectId: '',
pageColumns: [ pageColumns: [
{ title: '检测项目', key: 'name', width: 120 }, { title: '检测项目', key: 'name', width: 120 },
{ title: '检测方法', key: 'testMethod', width: 140 }, { title: '检测方法', key: 'testMethod', width: 140 },
...@@ -93,6 +103,7 @@ export default { ...@@ -93,6 +103,7 @@ export default {
}, },
_open(id) { _open(id) {
this.id = id this.id = id
this.selectId = ''
this._page() this._page()
}, },
_searchParams() { _searchParams() {
...@@ -116,7 +127,7 @@ export default { ...@@ -116,7 +127,7 @@ export default {
console.log(msg, data) console.log(msg, data)
switch (msg) { switch (msg) {
case 'page': case 'page':
this.getPage = this.$store.state.FoodItem.page this._page()
break break
case 'selectData': case 'selectData':
this.$emit('on-result-change', data) this.$emit('on-result-change', data)
...@@ -124,13 +135,12 @@ export default { ...@@ -124,13 +135,12 @@ export default {
case 'singleSelect': case 'singleSelect':
this.$emit('on-result-change', data) this.$emit('on-result-change', data)
break break
case 'iconClick':
this._iconClick(data.name, data.rowData, data.componentName)
break
case 'changeSize': case 'changeSize':
this._page() this._page()
break break
case 'table-col':
// 用户选中的表格列
this.userColumns = data
break
} }
}, },
_formSearch() { _formSearch() {
...@@ -143,15 +153,77 @@ export default { ...@@ -143,15 +153,77 @@ export default {
break break
} }
}, },
_iconClick(res, data, currentComponent) {
this.$nextTick(() => {
switch (res) {
case '生成项目报告':
// this.$emit('on-result-change', data)
this._itemReportMake(data)
break
}
})
},
_itemReportMake(data) {
this.itemName = data.name
this._searchSampleId(this.id, data.name)
// this.selectId = data.id
this.$refs.createModal._open()
},
_searchSampleId: async function(id, name) {
Object.assign(this.formObjSample, this.$refs.pageTable._searchParams())
this.formObjSample.entrustId = id
this.formObjSample.name = name
this.$refs.pageTable._hideLoading()
const result = await soilTest.pageExperimentTest(
this.$serializeForm(this.formObjSample)
)
if (result) {
console.log(result)
this.sampleIds = []
for (let i = 0; i < result.records.length; i++) {
this.sampleIds.push(result.records[i].id)
}
console.log('右侧样品id', this.sampleIds)
}
},
_certificateSelectExcelBack(data) {
if (data) {
this.$refs.pageTable._showLoading()
this._makeCodeExcel(data)
} else {
this.$refs.pageTable._hideLoading()
}
},
_makeCodeExcel: async function(data) {
console.log('左侧项目名称', this.itemName)
console.log('右侧样品Id', this.sampleIds)
console.log('报告信息', data)
this.$refs.pageTable._hideLoading()
const result = await soilSample.generateExcelReport(data)
if (result) {
await this._page()
if (result === null || result === undefined) {
this.$Message.warning('证书编制失败,请联系管理员!')
this.$refs.pageTable._hideLoading()
return false
} else {
this.$emit('on-result-change')
this._viewReport(result)
}
}
},
_viewReport(data) {
if (data) {
this.$openWindowModeless({
objectKey: data.objectKey,
idType: 10,
id: data.id,
isReport: 4
})
}
},
_autoAssign() { _autoAssign() {
console.log('自动分配') console.log('自动分配')
// this.$refs.autoAssignModal._open()
// this.$store.dispatch('FoodItem/autoAllotNum').then(() => {
// const num = this.$store.state.FoodItem.count
// if (num !== undefined) {
// this.$refs.refModal._open(num)
// }
// })
} }
} }
} }
......
<template>
<div>
<Row>
<Col span="24">
<Form id="formId" :label-width="80" inline onsubmit="return false">
<label class="label-sign"></label>
<Form-item label="模板名称:" class="search-item">
<Input v-model="formObj.alias" @on-enter="_formSearch" placeholder="请输入模板名称" clearable/>
</Form-item>
<Form-item class="search-btn" style="margin-left: -10px">
<Button @click="_formSearch" type="primary">搜索</Button>
</Form-item>
</Form>
</Col>
<Col span="24">
<PTVXETableHeight
ref="pageTable"
:table-height="300"
:get-page="getPage"
:is-radio="true"
@on-result-change="_tableResultChange"
select-data="true"
hide-checkbox>
<vxe-table-column
v-for="item in pageColumns"
:key="item.key"
:field="item.key"
:title="item.title"
:width="item.width"
:min-width="200"
:fixed="item.fixed?item.fixed:undefined"
sortable
>
<template slot-scope="scope">
<span v-if="item.dateTime">{{scope.row[item.key]?$dateformat(scope.row[item.key],'yyyy-mm-dd HH:MM:ss'):''}}</span>
<span v-else-if="item.judged">{{scope.row[item.key]===1?'是':'否'}}</span>
<span v-else>{{scope.row[item.key]}}</span>
</template>
</vxe-table-column>
</PTVXETableHeight>
</Col>
</Row>
</div>
</template>
<script>
import { soilAptitude } from '../../../../api'
export default {
components: {},
data() {
return {
tableHeight: '400',
pageColumns: [
{ title: '模板名称', key: 'alias', width: 220 },
{ title: '类别', key: 'classType', width: 140 },
{ title: '备注', key: 'remark' }
],
getPage: {},
modalTitle: '报告模板',
sampleId: '',
formObj: {
name: undefined
},
selectData: []
}
},
methods: {
_tableResultChange(msg, data) {
console.log(msg)
switch (msg) {
case 'page':
this._page()
break
case 'changeSize':
this._page()
break
case 'selectData':
this.selectData = data
break
case 'singleSelect':
this.selectData = [data]
this.$emit('on-result-change', this.selectData)
break
case 'iconClick':
this._iconClick(data.name, data.rowData)
break
}
},
_open(sampleId) {
this.sampleId = sampleId || ''
this._page()
},
_formSearch() {
this.$refs.pageTable._pageChange(1)
},
_page: async function() {
Object.assign(this.formObj, this.$refs.pageTable._searchParams())
const result = await soilAptitude.expReportTemplatePage(
this.$serializeForm(this.formObj)
)
if (result) {
this.getPage = result
this.$refs.pageTable._hideLoading()
}
}
}
}
</script>
...@@ -37,7 +37,6 @@ export default { ...@@ -37,7 +37,6 @@ export default {
}, },
_open(id) { _open(id) {
this.id = id this.id = id
console.log(id)
this.$refs.leftModal._open(this.id) this.$refs.leftModal._open(this.id)
// this.$refs.rightModal._getColumn() // this.$refs.rightModal._getColumn()
}, },
......
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