printMaterials.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <div>
  3. <el-dropdown @command="addBtn">
  4. <el-button type="primary" size="mini">
  5. {{$t(`打印资料`)}}<i class="el-icon-arrow-down el-icon--right"></i>
  6. </el-button>
  7. <el-dropdown-menu slot="dropdown">
  8. <el-dropdown-item command="质保书">{{$t(`质保书`)}}</el-dropdown-item>
  9. <el-dropdown-item command="合格证">{{$t(`合格证`)}}</el-dropdown-item>
  10. <el-dropdown-item command="检验报告">{{$t(`检验报告`)}}</el-dropdown-item>
  11. </el-dropdown-menu>
  12. </el-dropdown>
  13. <el-drawer
  14. :visible.sync="drawer"
  15. :with-header="false"
  16. direction="rtl"
  17. size="50%"
  18. append-to-body>
  19. <div class="detail__panel container">
  20. <p class="normal-title" style="margin-bottom:16px">{{$t(drawerTitle)}}</p>
  21. <el-table
  22. v-loading="loading"
  23. :data="list"
  24. :height="heightTable"
  25. border
  26. style="width: 100%">
  27. <el-table-column
  28. prop="name"
  29. :label="$t(`报表名称`)">
  30. </el-table-column>
  31. <el-table-column
  32. prop="operation"
  33. :label="$t(`操作`)"
  34. width="150px">
  35. <template slot-scope="scope">
  36. <el-button @click="printBtn(scope.row)" type="text" size="mini">{{$t('打 印')}}</el-button>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <div style="margin-top:10px;text-align:right" v-if="nowSelect == '检验报告'">
  41. <el-pagination
  42. background
  43. @size-change="handleSizeChange"
  44. @current-change="handleCurrentChange"
  45. :current-page="param.content.pageNumber"
  46. :page-sizes="[20, 50, 100, 200]"
  47. :page-size="20"
  48. layout="total,sizes, prev, pager, next, jumper"
  49. :total="total">
  50. </el-pagination>
  51. </div>
  52. </div>
  53. </el-drawer>
  54. </div>
  55. </template>
  56. <script>
  57. export default {
  58. name: "printMaterials",
  59. data(){
  60. return {
  61. drawer:false,
  62. list:[],
  63. nowSelect:"",
  64. sys_reportid:'',
  65. idName:'',
  66. drawerTitle:'',
  67. param:{
  68. "id": 20221115104703,
  69. "content": {
  70. "sa_orderid": 0,
  71. "pageNumber": 1,
  72. "pageSize": 20,
  73. "where": {
  74. "condition": ""
  75. }
  76. },
  77. },
  78. total:0,
  79. currentPage:0,
  80. heightTable:260 + 'px',
  81. loading:false
  82. }
  83. },
  84. methods:{
  85. addBtn(type){
  86. if (type == '质保书'){
  87. this.list = [
  88. {
  89. name:'质保书'
  90. }
  91. ]
  92. this.nowSelect = type
  93. this.idName = 'sa_dispatchid'
  94. this.dataid = this.$route.query.id
  95. this.drawerTitle = '打印质保书'
  96. this.drawer = true
  97. }else if (type == '检验报告'){
  98. this.nowSelect = type
  99. this.idName = 'sa_dispatch_itemsid'
  100. this.drawerTitle = '打印检验报告'
  101. this.param.content.pageNUmber = 1
  102. this.drawer = true
  103. this.loading = true
  104. this.heightTable = 'calc(100vh - 160px)'
  105. this.listData()
  106. }else if (type == '合格证'){
  107. this.nowSelect = type
  108. this.idName = 'sa_dispatchid'
  109. this.drawerTitle = '打印合格证'
  110. this.dataid = this.$route.query.id
  111. }
  112. this.queryReportId(type)
  113. },
  114. async queryReportId(type){
  115. const res = await this.$api.requested({
  116. "id": "2025101715070202",
  117. "content": {
  118. },
  119. })
  120. if (res.code == 0){
  121. this.tool.showMessage(res,()=>{})
  122. }else {
  123. res.data.forEach(item=>{
  124. if (item.name == type){
  125. this.sys_reportid = item.sys_reportid
  126. }
  127. })
  128. if (this.nowSelect == '合格证'){
  129. this.isPrint()
  130. }
  131. }
  132. },
  133. async listData(){
  134. this.param.content.sa_dispatchid = this.$route.query.id
  135. const res = await this.$api.requested(this.param)
  136. let tableData = res.data.map(item=>{
  137. return {
  138. name:item.itemno + ' ' + item.itemname + '_检验报告',
  139. sa_dispatch_itemsid:item.sa_dispatch_itemsid
  140. }
  141. })
  142. this.list = tableData
  143. this.total = res.total
  144. this.currentPage = res.pageNumber
  145. this.loading = false
  146. },
  147. handleSizeChange(val) {
  148. // console.log(`每页 ${val} 条`);
  149. this.param.content.pageSize = val
  150. this.listData()
  151. },
  152. handleCurrentChange(val) {
  153. // console.log(`当前页: ${val}`);
  154. this.param.content.pageNumber = val
  155. this.listData()
  156. },
  157. /*判断是否可以打印合格证*/
  158. async isPrint(){
  159. const res = await this.$api.requested({
  160. "id": "2025101713160202",
  161. "content": {
  162. "sa_dispatchid":this.$route.query.id
  163. },
  164. })
  165. if (res.code == 0){
  166. this.tool.showMessage(res,()=>{
  167. })
  168. }else {
  169. this.printBtn()
  170. }
  171. },
  172. async printBtn (data) {
  173. if (this.nowSelect == '检验报告'){
  174. this.dataid = data.sa_dispatch_itemsid
  175. }
  176. let res = await this.$api.requested({
  177. "id":20221213094501,
  178. "content": {
  179. sys_reportid:this.sys_reportid,
  180. dataid:this.dataid
  181. }
  182. })
  183. this.tool.showMessage(res,() => {
  184. window.open(this.tool.getBaseUrl() + res.data + `&${this.idName}=${this.dataid}`)
  185. // window.open('http://61.164.207.46:8000' + res.data + `&${this.idName}=${this.dataid}`)
  186. })
  187. },
  188. }
  189. }
  190. </script>
  191. <style scoped>
  192. .box p {
  193. line-height: 40px;
  194. text-align: center;
  195. }
  196. .box p:hover {
  197. background: #EBF1FE;
  198. color: #6191F8;
  199. cursor: pointer;
  200. }
  201. </style>