| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <template>
- <div>
- <el-dropdown @command="addBtn">
- <el-button type="primary" size="mini">
- {{$t(`打印资料`)}}<i class="el-icon-arrow-down el-icon--right"></i>
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="质保书">{{$t(`质保书`)}}</el-dropdown-item>
- <el-dropdown-item command="合格证">{{$t(`合格证`)}}</el-dropdown-item>
- <el-dropdown-item command="检验报告">{{$t(`检验报告`)}}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <el-drawer
- :visible.sync="drawer"
- :with-header="false"
- direction="rtl"
- size="50%"
- append-to-body>
- <div class="detail__panel container">
- <p class="normal-title" style="margin-bottom:16px">{{$t(drawerTitle)}}</p>
- <el-table
- v-loading="loading"
- :data="list"
- :height="heightTable"
- border
- style="width: 100%">
- <el-table-column
- prop="name"
- :label="$t(`报表名称`)">
- </el-table-column>
- <el-table-column
- prop="operation"
- :label="$t(`操作`)"
- width="150px">
- <template slot-scope="scope">
- <el-button @click="printBtn(scope.row)" type="text" size="mini">{{$t('打 印')}}</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="margin-top:10px;text-align:right" v-if="nowSelect == '检验报告'">
- <el-pagination
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="param.content.pageNumber"
- :page-sizes="[20, 50, 100, 200]"
- :page-size="20"
- layout="total,sizes, prev, pager, next, jumper"
- :total="total">
- </el-pagination>
- </div>
- </div>
- </el-drawer>
- </div>
- </template>
- <script>
- export default {
- name: "printMaterials",
- data(){
- return {
- drawer:false,
- list:[],
- nowSelect:"",
- sys_reportid:'',
- idName:'',
- drawerTitle:'',
- param:{
- "id": 20221115104703,
- "content": {
- "sa_orderid": 0,
- "pageNumber": 1,
- "pageSize": 20,
- "where": {
- "condition": ""
- }
- },
- },
- total:0,
- currentPage:0,
- heightTable:260 + 'px',
- loading:false
- }
- },
- methods:{
- addBtn(type){
- if (type == '质保书'){
- this.list = [
- {
- name:'质保书'
- }
- ]
- this.nowSelect = type
- this.idName = 'sa_dispatchid'
- this.dataid = this.$route.query.id
- this.drawerTitle = '打印质保书'
- this.drawer = true
- }else if (type == '检验报告'){
- this.nowSelect = type
- this.idName = 'sa_dispatch_itemsid'
- this.drawerTitle = '打印检验报告'
- this.param.content.pageNUmber = 1
- this.drawer = true
- this.loading = true
- this.heightTable = 'calc(100vh - 160px)'
- this.listData()
- }else if (type == '合格证'){
- this.nowSelect = type
- this.idName = 'sa_dispatchid'
- this.drawerTitle = '打印合格证'
- this.dataid = this.$route.query.id
- }
- this.queryReportId(type)
- },
- async queryReportId(type){
- const res = await this.$api.requested({
- "id": "2025101715070202",
- "content": {
- },
- })
- if (res.code == 0){
- this.tool.showMessage(res,()=>{})
- }else {
- res.data.forEach(item=>{
- if (item.name == type){
- this.sys_reportid = item.sys_reportid
- }
- })
- if (this.nowSelect == '合格证'){
- this.isPrint()
- }
- }
- },
- async listData(){
- this.param.content.sa_dispatchid = this.$route.query.id
- const res = await this.$api.requested(this.param)
- let tableData = res.data.map(item=>{
- return {
- name:item.itemno + ' ' + item.itemname + '_检验报告',
- sa_dispatch_itemsid:item.sa_dispatch_itemsid
- }
- })
- this.list = tableData
- this.total = res.total
- this.currentPage = res.pageNumber
- this.loading = false
- },
- handleSizeChange(val) {
- // console.log(`每页 ${val} 条`);
- this.param.content.pageSize = val
- this.listData()
- },
- handleCurrentChange(val) {
- // console.log(`当前页: ${val}`);
- this.param.content.pageNumber = val
- this.listData()
- },
- /*判断是否可以打印合格证*/
- async isPrint(){
- const res = await this.$api.requested({
- "id": "2025101713160202",
- "content": {
- "sa_dispatchid":this.$route.query.id
- },
- })
- if (res.code == 0){
- this.tool.showMessage(res,()=>{
- })
- }else {
- this.printBtn()
- }
- },
- async printBtn (data) {
- if (this.nowSelect == '检验报告'){
- this.dataid = data.sa_dispatch_itemsid
- }
- let res = await this.$api.requested({
- "id":20221213094501,
- "content": {
- sys_reportid:this.sys_reportid,
- dataid:this.dataid
- }
- })
- this.tool.showMessage(res,() => {
- window.open(this.tool.getBaseUrl() + res.data + `&${this.idName}=${this.dataid}`)
- // window.open('http://61.164.207.46:8000' + res.data + `&${this.idName}=${this.dataid}`)
- })
- },
- }
- }
- </script>
- <style scoped>
- .box p {
- line-height: 40px;
- text-align: center;
- }
- .box p:hover {
- background: #EBF1FE;
- color: #6191F8;
- cursor: pointer;
- }
- </style>
|