printMaterials.vue 5.6 KB

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