reportTemplateDialog.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="报告模板"
  5. :visible.sync="visible"
  6. width="600px"
  7. append-to-body
  8. :close-on-click-modal="false"
  9. :modal="false"
  10. v-loading="loading"
  11. :before-close="close">
  12. <div style="height: calc(100vh - 300px)">
  13. <el-container>
  14. <el-main class="height_100" :loading="loading">
  15. <el-table
  16. class="copyTable"
  17. :data="tableData"
  18. style="width: 100%"
  19. row-key="id"
  20. >
  21. <el-table-column prop="index" label="序号" width="100px">
  22. <template slot-scope="scope">
  23. <div>
  24. {{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}
  25. </div>
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="name" label="名称">
  29. <template slot-scope="scope">
  30. <div>
  31. <el-link type="primary" @click="chooseReportTemplate(scope.row)">{{ scope.row.templateName }}</el-link>
  32. </div>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </el-main>
  37. <el-footer class="pagination">
  38. <el-pagination
  39. background
  40. layout="total, sizes, prev, pager, next, jumper"
  41. :current-page.sync="queryParams.current"
  42. :page-size.sync="queryParams.size"
  43. @current-change="handleCurrentChange"
  44. @size-change="changeSize"
  45. :total="total"
  46. >
  47. </el-pagination>
  48. </el-footer>
  49. </el-container>
  50. </div>
  51. </el-dialog>
  52. </div>
  53. </template>
  54. <script>
  55. export default {
  56. components: {},
  57. props: {
  58. },
  59. data() {
  60. return {
  61. visible:false,
  62. tableData:[],
  63. loading:false,
  64. queryParams:{
  65. current:1,
  66. size:10
  67. },
  68. total:0,
  69. projectId:null,
  70. };
  71. },
  72. watch: {},
  73. computed: {},
  74. created() {},
  75. mounted() {},
  76. methods: {
  77. otherTemplate(){
  78. let router = this.$router.resolve({
  79. path: '/exportReportByFile',
  80. query: {
  81. }
  82. })
  83. window.open(router.href, '_blank')
  84. },
  85. open(projectId){
  86. this.projectId = projectId
  87. this.queryParams.current = 1
  88. this.getReportTemplate()
  89. this.visible = true
  90. },
  91. //获取模板
  92. getReportTemplate(){
  93. this.loading = true
  94. this.$api.queryNoveltyTemplate({}).then(response=>{
  95. if(response.code = 200){
  96. this.tableData = response.data.data
  97. this.total = response.data.total
  98. this.loading = false
  99. }
  100. }).catch(error=>{
  101. this.tableData = []
  102. this.total = 0
  103. this.loading = false
  104. })
  105. },
  106. close(){
  107. this.visible = false
  108. },
  109. handleCurrentChange(val){
  110. this.queryParams.current = val
  111. this.getReportTemplate()
  112. },
  113. changeSize(val){
  114. this.queryParams.current = 1
  115. this.queryParams.size = val
  116. this.getReportTemplate()
  117. },
  118. chooseReportTemplate(row){
  119. var params = {
  120. projectId:this.projectId,
  121. templateId:row.id,
  122. }
  123. var message = this.$message({
  124. message: '报告生成中...',
  125. type: 'warning',
  126. duration:0
  127. });
  128. this.loading = true
  129. this.$api.editNoveltyReport(params).then(response=>{
  130. if(response.code == 200){
  131. message.close()
  132. this.$message.success('报告生成成功')
  133. this.loading = false
  134. this.toEdit(response.data)
  135. }
  136. }).catch(error=>{
  137. message.close()
  138. this.$message.error('报告生成失败')
  139. })
  140. // let router = this.$router.resolve({
  141. // path: '/exportReport',
  142. // query: {
  143. // reportTemplateId: row.id,
  144. // // path:row.configMessage,
  145. // projectId: this.projectId,
  146. // }
  147. // })
  148. // window.open(router.href, '_blank')
  149. },
  150. toEdit(id){
  151. let params = {
  152. projectId: this.projectId,
  153. current:1,
  154. size:1,
  155. id:id
  156. }
  157. var api = 'queryNoveltyReport'
  158. this.$api[api](params).then(res => {
  159. if (res.code == 200) {
  160. var data = res.data.data
  161. if(data && data.length){
  162. let router = this.$router.resolve({
  163. path: '/onlyOffice',
  164. query: {
  165. projectId:this.projectId,
  166. guid:data[0].fileGuid,
  167. title:data[0].referencesName
  168. }
  169. })
  170. window.open(router.href, '_blank')
  171. }
  172. this.loading = false
  173. }
  174. }).catch(error => {
  175. this.loading = false
  176. })
  177. },
  178. },
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. .head{
  183. display: flex;
  184. justify-content: flex-end;
  185. }
  186. </style>