index.vue 7.9 KB

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