index copy.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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" 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">发送报告</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">导出报告</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. useCommonStore().$state.reportUserId = item?.userId;
  125. }
  126. reportParentId.value = item?.id;
  127. emit('toggleReport', item)
  128. }
  129. const pdfCancel = () => {
  130. pdfShow.value = false;
  131. reportData.value = {};
  132. reportParentId.value = '';
  133. reportId.value = '';
  134. reportName.value = '';
  135. }
  136. const refreshReportList = (relationId) => {
  137. emit('refreshReportList', relationId)
  138. }
  139. const handleReive = (row) => {
  140. reportId.value = row.id;
  141. reportName.value = row.reportName;
  142. getReportPdfData(row.id).then(res => {
  143. if(res.code!==0) proxy.$message.error(res.msg);
  144. reportData.value = {...res.data,id:row.id,relationId:row.relationId};
  145. nextTick(() => {
  146. pdfShow.value = true;
  147. })
  148. })
  149. }
  150. const handledDelete = (row) => {
  151. emit('deleteReport', row.id)
  152. }
  153. const handleSend = (row) => {
  154. if(!row.fileUrl) return proxy.$message.error('请先在预览页面生成PDF报告!');
  155. if(row.state==2){
  156. proxy.$modal.confirm('当前报告已发送,若继续发送会覆盖当前报告,是否继续发送?').then((res) => {
  157. if(res == 'confirm'){
  158. emit('sendReport', row.id)
  159. }
  160. })
  161. }else emit('sendReport', row.id)
  162. }
  163. const handleCreate = (row) => {
  164. emit('reCreateReport', row?.id)
  165. }
  166. const handleExport = (row) => {
  167. if(!row.fileUrl) return proxy.$message.error('请先在预览页面生成PDF报告!');
  168. window.open(row.fileUrl)
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. .rl_pre{
  173. padding: 24px;
  174. background: #FFFFFF;
  175. border-radius: 6px;
  176. margin-top: 12px;
  177. cursor: pointer;
  178. .rp_top{
  179. .rlp_l{
  180. width: calc(100% - 112px);
  181. .rlpl_l{
  182. img{
  183. width: 23px;
  184. height: 22px;
  185. }
  186. }
  187. .rlpl_r{
  188. width: calc(100% - 23px);
  189. padding-left: 24px;
  190. box-sizing: border-box;
  191. .rr_pre{
  192. padding-right: 20px;
  193. box-sizing: border-box;
  194. .text{
  195. font-family: PingFang-SC, PingFang-SC;
  196. font-weight: bold;
  197. font-size: 14px;
  198. color: #252525;
  199. line-height: 16px;
  200. overflow: hidden;
  201. text-overflow: ellipsis;
  202. white-space: nowrap;
  203. }
  204. .tip{
  205. font-family: PingFangSC, PingFang SC;
  206. font-weight: 400;
  207. font-size: 14px;
  208. color: #86909C;
  209. line-height: 16px;
  210. margin-top: 10px;
  211. }
  212. &.rp1{
  213. flex: 1;
  214. }
  215. &.rp2{
  216. width: 140px;
  217. }
  218. &.rp3,&.rp4, &.rp5{
  219. width: 260px;
  220. }
  221. &.rp6{
  222. width: 540px;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. .rp_bottom{
  229. border-top: 1px solid #E5E7EB;
  230. margin-top: 24px;
  231. padding-top: 19px;
  232. }
  233. .rp_status{
  234. .rps_l{
  235. width: 10px;
  236. height: 10px;
  237. border-radius: 50%;
  238. }
  239. .rps_r{
  240. font-family: PingFangSC, PingFang SC;
  241. font-weight: 400;
  242. font-size: 14px;
  243. line-height: 20px;
  244. margin-left: 10px;
  245. }
  246. }
  247. }
  248. </style>