index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="rl_pre">
  3. <div class="rp_top adfacjb">
  4. <div class="rlp_l adfac">
  5. <div class="rlpl_l">
  6. <img src="@/assets/images/agent/report.png">
  7. </div>
  8. <div class="rlpl_r adfac">
  9. <div class="rr_pre rp1">
  10. <p class="text"><span v-if="item.programName">{{ item.programName}} - </span>{{ item.enterpriseName||'' }}</p>
  11. <p class="tip">{{ item.title||'' }}</p>
  12. </div>
  13. <div class="rr_pre rp2">
  14. <p class="text">{{ item.teamName||'' }}</p>
  15. <p class="tip">团队类型</p>
  16. </div>
  17. <div class="rr_pre rp3">
  18. <p class="text">{{ item.endTime||'' }}</p>
  19. <p class="tip">截止日期</p>
  20. </div>
  21. <div class="rr_pre rp4">
  22. <p class="text">{{ item.finishNum||0 }}</p>
  23. <p class="tip">作答人数</p>
  24. </div>
  25. <div class="rr_pre rp5">
  26. <p class="text">{{ item.userNum||0 }}</p>
  27. <p class="tip">团队人数</p>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="rlp_r">
  32. <el-button type="primary" @click.stop="toggleReport(item)">查看报告</el-button>
  33. </div>
  34. </div>
  35. <div class="rp_bottom" v-if="showMore">
  36. <el-table :data="reportList" border cell-class-name="vertical-top-cell" empty-text="暂无报告" max-height="578px">
  37. <el-table-column label="报告名称" prop="reportName" min-width="200"></el-table-column>
  38. <el-table-column label="创建时间" prop="createDate"></el-table-column>
  39. <el-table-column label="生成时间" prop="updateDate"></el-table-column>
  40. <el-table-column label="状态" prop="state" width="150">
  41. <template #default="{ row }">
  42. <div class="rp_status adfac">
  43. <div class="rps_l" :style="{'background':sColorCfg[row.state]||'#1D2129'}"></div>
  44. <div class="rps_r" :style="{'color':sColorCfg[row.state]||'#1D2129'}">{{ sTextCfg[row.state]||'未知' }}</div>
  45. </div>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="操作" width="300">
  49. <template #default="scope">
  50. <el-button link type="text" size="mini" @click="handleReive(scope.row)" v-if="[1,2].includes(scope.row.state)">预览</el-button>
  51. <el-button link type="text" size="mini" @click="handledDelete(scope.row)" v-hasPermi="['core:report:delete']">删除</el-button>
  52. <el-button link type="text" size="mini" @click="handleSend(scope.row)" v-if="scope.row.state>0">发送报告</el-button>
  53. <el-button link type="text" size="mini" @click="handleCreate(scope.row)" v-if="scope.row.state=='-1'&&isTeam">重新生成</el-button>
  54. <el-button link type="text" size="mini" @click="handleExport(scope.row)" v-if="scope.row.state>0">导出报告</el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. </div>
  59. <template v-if="pdfShow">
  60. <report-pdf :reportId="reportId" :reportName="reportName" :reportData="reportData" :isTeam="isTeam" @cancel="pdfCancel" @refreshReportList="refreshReportList"></report-pdf>
  61. </template>
  62. </div>
  63. </template>
  64. <script setup name="ReportList">
  65. import reportPdf from '@/components/reportPdf/index.vue'
  66. const props = defineProps({
  67. item: {
  68. type: Object,
  69. default: () => {}
  70. },
  71. reportList: {
  72. type: Array,
  73. default: () => []
  74. },
  75. isTeam: {
  76. type: Boolean,
  77. default: true
  78. },
  79. showMore: {
  80. type: Boolean,
  81. default: false
  82. }
  83. })
  84. import { ref, getCurrentInstance, nextTick } from 'vue'
  85. const { proxy } = getCurrentInstance();
  86. import useCommonStore from "@/store_v3/modules/common";
  87. import {
  88. getReportPdfData
  89. } from '@/api/agent/index.js'
  90. const sTextCfg = {
  91. 1: '未发送',
  92. 0: '生成中',
  93. 2: '已发送',
  94. '-1': '生成失败'
  95. }
  96. const sColorCfg = {
  97. 1: '#22C55D',
  98. 0: '#FEA400',
  99. 2: '#2E69EB',
  100. '-1': '#F31616'
  101. }
  102. const pdfShow = ref(false)
  103. const reportData = ref({})
  104. const reportParentId = ref('')
  105. const reportId = ref('')
  106. const item = ref(props.item)
  107. const isTeam = ref(props.isTeam)
  108. const reportName = ref('')
  109. const emit = defineEmits(['toggleReport','deleteReport','sendReport','reCreateReport','refreshReportList'])
  110. const toggleReport = (item) => {
  111. if(isTeam.value){
  112. useCommonStore().$state.relationId = item?.id;
  113. }else{
  114. useCommonStore().$state.userRealName = item?.realName;
  115. useCommonStore().$state.teamQuestionnaireId = item?.teamQuestionnaireId;
  116. useCommonStore().$state.reportUserId = item?.userId;
  117. }
  118. useCommonStore().$state.reportUsers = item?.memberInfos;
  119. reportParentId.value = item?.id;
  120. emit('toggleReport', item)
  121. }
  122. const pdfCancel = () => {
  123. pdfShow.value = false;
  124. reportData.value = {};
  125. reportParentId.value = '';
  126. reportId.value = '';
  127. reportName.value = '';
  128. }
  129. const refreshReportList = (relationId) => {
  130. emit('refreshReportList', relationId)
  131. }
  132. const handleReive = (row) => {
  133. reportId.value = row.id;
  134. reportName.value = row.reportName;
  135. getReportPdfData(row.id).then(res => {
  136. if(res.code!==0) proxy.$message.error(res.msg);
  137. reportData.value = {...res.data,id:row.id,relationId:row.relationId};
  138. nextTick(() => {
  139. pdfShow.value = true;
  140. })
  141. })
  142. }
  143. const handledDelete = (row) => {
  144. emit('deleteReport', row.id)
  145. }
  146. const handleSend = async (row) => {
  147. if(!row.fileUrl) return proxy.$message.error('请先在预览页面生成PDF报告!');
  148. if(row.state==2){
  149. await proxy.$modal.confirm('当前报告已发送,若继续发送会覆盖当前报告,是否继续发送?');
  150. emit('sendReport', row.id)
  151. }else emit('sendReport', row.id)
  152. }
  153. const handleCreate = (row) => {
  154. emit('reCreateReport', row?.id)
  155. }
  156. const handleExport = (row) => {
  157. if(!row.fileUrl) return proxy.$message.error('请先在预览页面生成PDF报告!');
  158. window.open(row.fileUrl)
  159. }
  160. </script>
  161. <style scoped lang="scss">
  162. .rl_pre{
  163. padding: 24px;
  164. background: #FFFFFF;
  165. border-radius: 6px;
  166. margin-top: 12px;
  167. cursor: pointer;
  168. .rp_top{
  169. .rlp_l{
  170. width: calc(100% - 112px);
  171. .rlpl_l{
  172. img{
  173. width: 23px;
  174. height: 22px;
  175. }
  176. }
  177. .rlpl_r{
  178. width: calc(100% - 23px);
  179. padding-left: 24px;
  180. box-sizing: border-box;
  181. .rr_pre{
  182. padding-right: 20px;
  183. box-sizing: border-box;
  184. .text{
  185. font-family: PingFang-SC, PingFang-SC;
  186. font-weight: bold;
  187. font-size: 14px;
  188. color: #252525;
  189. line-height: 16px;
  190. overflow: hidden;
  191. text-overflow: ellipsis;
  192. white-space: nowrap;
  193. }
  194. .tip{
  195. font-family: PingFangSC, PingFang SC;
  196. font-weight: 400;
  197. font-size: 14px;
  198. color: #86909C;
  199. line-height: 16px;
  200. margin-top: 10px;
  201. }
  202. &.rp1{
  203. flex: 1;
  204. }
  205. &.rp2{
  206. width: 140px;
  207. }
  208. &.rp3,&.rp4, &.rp5{
  209. width: 260px;
  210. }
  211. &.rp6{
  212. width: 540px;
  213. }
  214. }
  215. }
  216. }
  217. }
  218. .rp_bottom{
  219. border-top: 1px solid #E5E7EB;
  220. margin-top: 24px;
  221. padding-top: 19px;
  222. }
  223. .rp_status{
  224. .rps_l{
  225. width: 10px;
  226. height: 10px;
  227. border-radius: 50%;
  228. }
  229. .rps_r{
  230. font-family: PingFangSC, PingFang SC;
  231. font-weight: 400;
  232. font-size: 14px;
  233. line-height: 20px;
  234. margin-left: 10px;
  235. }
  236. }
  237. }
  238. </style>