CrowdTaskView.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="crowd-task-view">
  3. <el-card v-if="current">
  4. <template #header>
  5. <div class="header">
  6. <span class="title">客群任务详情</span>
  7. </div>
  8. </template>
  9. <!-- 基本信息 -->
  10. <div class="section-title">基本信息</div>
  11. <el-descriptions :column="2" border>
  12. <el-descriptions-item label="客群名称">{{ current.name }}</el-descriptions-item>
  13. <el-descriptions-item label="客群编号">{{ current.id }}</el-descriptions-item>
  14. <el-descriptions-item label="状态">
  15. <el-tag :type="statusTagType(current.status)" size="small">{{ statusLabel(current.status) }}</el-tag>
  16. </el-descriptions-item>
  17. <el-descriptions-item label="客群描述" :span="2">{{ current.description || '-' }}</el-descriptions-item>
  18. <el-descriptions-item label="任务开始/结束日期" :span="2">
  19. {{ current.startDate }} ~ {{ current.endDate }}
  20. </el-descriptions-item>
  21. <el-descriptions-item label="任务创建时间">{{ current.createdAt }}</el-descriptions-item>
  22. <el-descriptions-item label="任务创建用户">{{ current.creator }}</el-descriptions-item>
  23. <el-descriptions-item label="审核人">{{ current.reviewer || '-' }}</el-descriptions-item>
  24. <el-descriptions-item label="最近更新时间">{{ current.updatedAt }}</el-descriptions-item>
  25. </el-descriptions>
  26. <!-- 规则组信息 -->
  27. <div class="section-title" style="margin-top: 24px">规则组信息</div>
  28. <div class="rule-group-meta">
  29. <span class="meta-label">规则组间逻辑:</span>
  30. <span>{{ current.ruleGroupLogic === 'AND' ? 'and/且' : 'or/或' }}</span>
  31. </div>
  32. <div class="rule-group-meta">
  33. <span class="meta-label">规则组详情:</span>
  34. </div>
  35. <el-table :data="current.ruleGroups || []" border style="width: 100%" empty-text="无规则组">
  36. <el-table-column prop="id" label="规则组编号" width="170" align="center" />
  37. <el-table-column prop="name" label="规则组名称" min-width="160" show-overflow-tooltip />
  38. <el-table-column prop="description" label="规则组描述" min-width="200" show-overflow-tooltip />
  39. <el-table-column label="规则组内逻辑" width="120" align="center">
  40. <template #default="scope">{{ scope.row.logic === 'AND' ? 'and/且' : 'or/或' }}</template>
  41. </el-table-column>
  42. <el-table-column prop="ruleCount" label="规则个数" width="90" align="center" />
  43. </el-table>
  44. <!-- 运行信息 -->
  45. <div class="section-title" style="margin-top: 24px">运行信息</div>
  46. <div class="run-info">
  47. <div class="run-row">
  48. <span class="run-label">总数(count):</span>
  49. <span class="run-value">{{ countDisplay }}</span>
  50. </div>
  51. <div class="run-row">
  52. <span class="run-label">校验(sample):</span>
  53. <span class="run-value">
  54. <el-link
  55. v-if="sampleAvailable"
  56. type="primary"
  57. :underline="false"
  58. @click="showSample = true"
  59. >详情</el-link>
  60. <span v-else-if="current.run.sample === 'running'" class="muted">详情</span>
  61. <span v-else class="muted">未运行</span>
  62. </span>
  63. <el-button
  64. size="small"
  65. type="primary"
  66. :disabled="!canRerun"
  67. style="margin-left: 16px"
  68. @click="handleRerun"
  69. >重新校验</el-button>
  70. </div>
  71. <div class="run-row">
  72. <span class="run-label">全量圈客(fulllist):</span>
  73. <span :class="['run-value', fulllistClass]">{{ fulllistDisplay }}</span>
  74. </div>
  75. </div>
  76. <div class="footer">
  77. <el-button type="primary" @click="$router.push('/customization/hsbc/crowd-tasks')">返回</el-button>
  78. </div>
  79. </el-card>
  80. <sample-detail-dialog
  81. v-model:visible="showSample"
  82. :rows="sampleRows"
  83. />
  84. </div>
  85. </template>
  86. <script>
  87. import { ElMessage, ElMessageBox } from 'element-plus'
  88. import crowdTaskStore from '@/store/crowdTaskStore'
  89. import SampleDetailDialog from '@/components/crowdTask/SampleDetailDialog.vue'
  90. export default {
  91. name: 'CrowdTaskView',
  92. components: { SampleDetailDialog },
  93. data() {
  94. return { current: null, showSample: false }
  95. },
  96. computed: {
  97. sampleAvailable() {
  98. return this.current && Array.isArray(this.current.run.sample) && this.current.run.sample.length > 0
  99. },
  100. sampleRows() {
  101. return this.sampleAvailable ? this.current.run.sample : []
  102. },
  103. countDisplay() {
  104. const c = this.current && this.current.run.count
  105. if (c === null || c === undefined) return '未运行'
  106. if (c === 'running') return '正在运行'
  107. return c
  108. },
  109. fulllistDisplay() {
  110. const f = this.current && this.current.run.fulllist
  111. if (f === null || f === undefined) return '未运行'
  112. if (f === 'running') return '正在运行'
  113. if (f === 'completed') return '已完成'
  114. return f
  115. },
  116. fulllistClass() {
  117. const f = this.current && this.current.run.fulllist
  118. if (!f) return 'red'
  119. if (f === 'running') return 'muted'
  120. return 'green'
  121. },
  122. canRerun() {
  123. if (!this.current) return false
  124. if (this.current.run.count === 'running' || this.current.run.sample === 'running') return false
  125. if (this.current.status === 'stopped') return false
  126. // 任意非"正在运行"且非"已停止"状态都支持运维人员重跑
  127. return this.current.run.count !== null
  128. }
  129. },
  130. created() {
  131. const target = crowdTaskStore.getById(this.$route.params.id)
  132. if (!target) {
  133. ElMessage.error('任务不存在')
  134. this.$router.replace('/customization/hsbc/crowd-tasks')
  135. return
  136. }
  137. this.current = target
  138. },
  139. methods: {
  140. statusLabel(s) {
  141. return { draft: '新建', verifying: '校验', online: '上线', stopped: '已停止' }[s] || s
  142. },
  143. statusTagType(s) {
  144. return { draft: 'info', verifying: 'warning', online: 'success', stopped: 'danger' }[s] || ''
  145. },
  146. handleRerun() {
  147. ElMessageBox.confirm('重新校验将重新运行 count 和 sample,不影响 fullist。', '重新校验', {
  148. confirmButtonText: '运行', cancelButtonText: '取消', type: 'info'
  149. }).then(() => {
  150. crowdTaskStore.rerunCountSample(this.current.id)
  151. ElMessage.success('已触发重新校验,请稍候查看结果')
  152. }).catch(() => {})
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped>
  158. .crowd-task-view { padding: 0; }
  159. .header { display: flex; align-items: center; justify-content: center; }
  160. .title { font-size: 16px; font-weight: 600; color: #409EFF; }
  161. .section-title {
  162. font-size: 14px; font-weight: 600; color: #303133;
  163. background: #f5f7fa; padding: 10px 14px; border-radius: 4px;
  164. margin-bottom: 16px;
  165. }
  166. .rule-group-meta { margin: 8px 0; font-size: 13px; color: #606266; }
  167. .rule-group-meta .meta-label { font-weight: 600; color: #303133; }
  168. .run-info {
  169. border: 1px solid #fbbfbf; border-radius: 4px;
  170. background: #fffaf0; padding: 16px 24px;
  171. }
  172. .run-row { display: flex; align-items: center; padding: 6px 0; font-size: 14px; }
  173. .run-label { width: 160px; color: #303133; font-weight: 600; }
  174. .run-value { color: #606266; }
  175. .run-value.red { color: #F56C6C; }
  176. .run-value.green { color: #67C23A; }
  177. .muted { color: #c0c4cc; }
  178. .footer { text-align: center; margin-top: 24px; padding-top: 16px; border-top: 1px solid #ebeef5; }
  179. </style>