userBehavior.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <template>
  2. <div class="behavior-track-container">
  3. <!-- 筛选区域 -->
  4. <div class="filter-section">
  5. <div class="filter-item">
  6. <label>操作类型:</label>
  7. <el-select
  8. v-model="queryParams.operationType"
  9. class="type-select"
  10. @change="handleTypeChange"
  11. placeholder="请选择行为类型"
  12. clearable
  13. >
  14. <el-option
  15. v-for="item in typeList"
  16. :key="item"
  17. :label="item"
  18. :value="item"
  19. ></el-option>
  20. </el-select>
  21. </div>
  22. </div>
  23. <div v-if="steps.length === 0" class="no-data">
  24. <p>暂无数据</p>
  25. </div>
  26. <!-- 按日期分组展示(分页后的数据) -->
  27. <div v-if="steps.length != 0" v-for="(records, date) in groupedPaginatedSteps" :key="date" class="date-group">
  28. <!-- 日期标题(如果是今天,显示“今天”,否则显示具体日期) -->
  29. <div class="date-title">
  30. {{ isToday(date) ? '今天' : date }}
  31. </div>
  32. <div class="date-divider"></div>
  33. <!-- 当前日期下的记录 -->
  34. <el-steps
  35. direction="vertical"
  36. :space="120"
  37. process-status="process"
  38. finish-status="success"
  39. class="custom-steps"
  40. >
  41. <el-step
  42. v-for="(step, index) in records"
  43. :key="index"
  44. :icon="index === 0 ? 'el-icon-s-help' : 'el-icon-bangzhu'"
  45. >
  46. <template #title>
  47. <div class="step-title">
  48. {{ step.operationType }}
  49. <span class="step-time">{{ step.createTime }}</span> <!-- 每个步骤的时间 -->
  50. </div>
  51. </template>
  52. <template #description>
  53. <!-- 答题 -->
  54. <div v-if="step.operationType == '答题'" class="step-content">
  55. <!-- 第一行 -->
  56. <div class="step-row first-row">
  57. <div v-if="step.paramVo" class="detail-item">
  58. <span class="detail-label"><i class="el-icon-notebook-2"></i> 课节名称:</span>
  59. <span class="detail-value">{{ step.paramVo.courseName }}</span>
  60. </div>
  61. </div>
  62. <!-- 第二行 -->
  63. <div v-if="step.details" class="step-row second-row">
  64. <div class="detail-item">
  65. <span class="detail-label"><i class="el-icon-chat-dot-round"></i> 备注:</span>
  66. <span class="detail-value">{{ step.details }}</span>
  67. </div>
  68. </div>
  69. </div>
  70. <!-- 发放奖励 -->
  71. <div v-else-if="step.operationType == '发送奖励'" class="step-content">
  72. <!-- 第一行 -->
  73. <div class="step-row first-row">
  74. <div v-if="step.paramVo" class="detail-item">
  75. <span class="detail-label"><i class="el-icon-gift"></i> 课程名称:</span>
  76. <span class="detail-value">{{ step.paramVo.courseName }}</span>
  77. </div>
  78. <div v-if="step.paramVo" class="detail-item">
  79. <span class="detail-label"><i class="el-icon-coin"></i> 小节名称:</span>
  80. <span class="detail-value">{{ step.paramVo.title }}</span>
  81. </div>
  82. <div v-if="step.fsCourseRedPacketLog" class="detail-item">
  83. <span class="detail-label"><i class="el-icon-coin"></i> 发放金额:</span>
  84. <span class="detail-value">{{ step.fsCourseRedPacketLog.amount }} 元</span>
  85. </div>
  86. </div>
  87. <!-- 第二行 -->
  88. <div v-if="step.details" class="step-row second-row">
  89. <div class="detail-item">
  90. <span class="detail-label"><i class="el-icon-chat-dot-round"></i> 备注:</span>
  91. <span class="detail-value">{{ step.details }}</span>
  92. </div>
  93. </div>
  94. </div>
  95. <!-- 其他类型 -->
  96. <div v-else class="step-content">
  97. <!-- 第一行 -->
  98. <div class="step-row first-row">
  99. <div v-if="step.paramVo" class="detail-item">
  100. <span class="detail-label"><i class="el-icon-office-building"></i> 训练营:</span>
  101. <span class="detail-value">{{ step.paramVo.trainingCampName }}</span>
  102. </div>
  103. <div v-if="step.paramVo" class="detail-item">
  104. <span class="detail-label"><i class="el-icon-collection-tag"></i> 营期名称:</span>
  105. <span class="detail-value">{{ step.paramVo.periodName }}</span>
  106. </div>
  107. <div v-if="step.paramVo" class="detail-item">
  108. <span class="detail-label"><i class="el-icon-notebook-2"></i> 课节名称:</span>
  109. <span class="detail-value">{{ step.paramVo.courseName }}</span>
  110. </div>
  111. </div>
  112. <!-- 第二行 -->
  113. <div v-if="step.details" class="step-row second-row">
  114. <div class="detail-item">
  115. <span class="detail-label"><i class="el-icon-chat-dot-round"></i> 备注:</span>
  116. <span class="detail-value">{{ step.details }}</span>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. </el-step>
  122. </el-steps>
  123. </div>
  124. <!-- 分页 -->
  125. <pagination
  126. v-show="total>0"
  127. :total="total"
  128. :page.sync="queryParams.pageNum"
  129. :limit.sync="queryParams.pageSize"
  130. @pagination="getList"
  131. />
  132. </div>
  133. </template>
  134. <script>
  135. import { listUserOperationLog,getOperationType} from "@/api/his/userOperationLog";
  136. export default {
  137. data() {
  138. return {
  139. // 遮罩层
  140. loading: true,
  141. typeList: [],
  142. queryParams: {
  143. pageNum: 1,
  144. pageSize: 10,
  145. operationType:null,
  146. userId:null,
  147. },
  148. total: 0,
  149. steps: [
  150. ]
  151. };
  152. },
  153. created() {
  154. getOperationType().then(response => {
  155. this.typeList = response.data;
  156. });
  157. },
  158. computed: {
  159. // 删除这个属性,直接在 getList 中使用后端的操作类型
  160. groupedPaginatedSteps() {
  161. const groups = {};
  162. this.steps.forEach((step) => {
  163. const date = step.createTime ?
  164. (step.createTime instanceof Date ? step.createTime.toISOString().substr(0, 10) : new Date(step.createTime).toISOString().substr(0, 10))
  165. : null;
  166. if (!groups[date]) {
  167. groups[date] = [];
  168. }
  169. groups[date].push(step);
  170. });
  171. return groups;
  172. },
  173. },
  174. methods: {
  175. getList() {
  176. this.loading = true;
  177. listUserOperationLog(this.queryParams).then(response => {
  178. this.steps = response.rows;
  179. this.total = response.total;
  180. this.loading = false;
  181. });
  182. },
  183. // 判断是否为今天
  184. isToday(date) {
  185. const today = new Date();
  186. const formattedDate = `${today.getFullYear()}-${(today.getMonth() + 1).toString().padStart(2, '0')}-${today.getDate().toString().padStart(2, '0')}`;
  187. return date === formattedDate;
  188. },
  189. getDetails(orderId) {
  190. this.queryParams.userId=orderId;
  191. this.getList();
  192. },
  193. handleTypeChange() {
  194. this.queryParams.pageNum = 1; // 重置分页为第一页
  195. this.getList(); // 重新获取数据
  196. }
  197. },
  198. };
  199. </script>
  200. <style scoped>
  201. .behavior-track-container {
  202. width: 100%;
  203. padding: 24px;
  204. font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
  205. background-color: #f9fbfd;
  206. border-radius: 12px;
  207. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  208. }
  209. .filter-section {
  210. margin-bottom: 24px;
  211. background: #ffffff;
  212. border-radius: 8px;
  213. padding: 16px 20px;
  214. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  215. display: flex;
  216. align-items: center;
  217. }
  218. .filter-item {
  219. display: flex;
  220. align-items: center;
  221. }
  222. .filter-item label {
  223. font-weight: 600;
  224. color: #333;
  225. margin-right: 12px;
  226. font-size: 14px;
  227. }
  228. .type-select {
  229. width: 240px;
  230. }
  231. .custom-steps {
  232. padding: 0 16px;
  233. }
  234. .step-title {
  235. font-size: 16px;
  236. font-weight: 600;
  237. color: #333;
  238. }
  239. .step-detail p {
  240. margin: 8px 0;
  241. line-height: 1.6;
  242. font-size: 14px;
  243. color: #555;
  244. }
  245. /* 步骤条样式优化 - 移除图标边框 */
  246. .custom-steps >>> .el-step__head {
  247. padding-right: 16px;
  248. }
  249. .custom-steps >>> .el-step__icon {
  250. width: 24px;
  251. height: 24px;
  252. font-size: 18px;
  253. }
  254. .custom-steps >>> .el-step__icon.is-icon {
  255. color: #52c41a;
  256. }
  257. .custom-steps >>> .el-step__line {
  258. top: 36px;
  259. left: 11px;
  260. background-color: #e8e8e8;
  261. }
  262. /* 分页样式优化 */
  263. .pagination-wrapper {
  264. margin-top: 32px;
  265. text-align: center;
  266. padding: 16px 0;
  267. }
  268. .custom-pagination >>> .el-pager li {
  269. border-radius: 4px;
  270. margin: 0 4px;
  271. }
  272. .custom-pagination >>> .el-pager li.active {
  273. background-color: #52c41a;
  274. color: #fff;
  275. }
  276. .custom-pagination >>> .el-pagination__jump {
  277. margin-left: 12px;
  278. }
  279. .custom-pagination >>> .el-input__inner {
  280. border-radius: 4px;
  281. }
  282. /* 新增和修改的样式 */
  283. .step-content {
  284. margin-top: 8px;
  285. padding: 16px;
  286. background: #ffffff;
  287. border-radius: 8px;
  288. border: 1px solid #ebeef5;
  289. box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  290. transition: all 0.3s ease;
  291. }
  292. .step-content:hover {
  293. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  294. transform: translateY(-1px);
  295. }
  296. .detail-label {
  297. display: inline-flex;
  298. align-items: center;
  299. width: 100px;
  300. color: #606266;
  301. font-weight: 500;
  302. flex-shrink: 0;
  303. }
  304. .detail-label i {
  305. margin-right: 6px;
  306. font-size: 14px;
  307. color: #909399;
  308. }
  309. .detail-value {
  310. flex: 1;
  311. color: #303133;
  312. word-break: break-word;
  313. padding-left: 4px;
  314. }
  315. .step-row {
  316. display: flex;
  317. flex-wrap: wrap;
  318. justify-content: space-between;
  319. margin-bottom: 8px;
  320. }
  321. .first-row .detail-item {
  322. flex: 1 1 30%; /* 平均分布 */
  323. display: flex;
  324. align-items: center;
  325. margin-right: 16px;
  326. }
  327. .second-row .detail-item {
  328. display: flex;
  329. align-items: center;
  330. }
  331. .time-item {
  332. margin-left: auto; /* 时间靠右 */
  333. }
  334. .detail-label {
  335. font-weight: 500;
  336. color: #606266;
  337. margin-right: 6px;
  338. }
  339. .detail-value {
  340. color: #303133;
  341. word-break: break-word;
  342. }
  343. @media (max-width: 768px) {
  344. .first-row,
  345. .second-row {
  346. flex-direction: column;
  347. }
  348. .time-item {
  349. margin-left: 0;
  350. }
  351. }
  352. /* 完全重置步骤描述区域的样式 */
  353. .custom-steps >>> .el-step__description {
  354. width: 100% !important;
  355. max-width: 100% !important;
  356. padding: 0 !important;
  357. margin: 0 !important;
  358. }
  359. /* 确保步骤内容使用弹性布局 */
  360. .step-content {
  361. display: flex;
  362. flex-direction: column;
  363. width: 100%;
  364. }
  365. /* 调整时间项 */
  366. .time-item {
  367. align-self: flex-end; /* 替代 margin-left: auto */
  368. margin-top: 8px; /* 如果需要与上方的间距 */
  369. }
  370. /* 日期标题样式 */
  371. .date-title {
  372. font-size: 16px;
  373. font-weight: bold;
  374. color: #333;
  375. margin-top: 16px;
  376. }
  377. .date-divider {
  378. height: 1px;
  379. background: #e8e8e8;
  380. margin: 4px 0 12px;
  381. }
  382. /* 在步骤条标题旁边显示时间 */
  383. .step-title {
  384. display: flex;
  385. justify-content: space-between;
  386. align-items: center;
  387. }
  388. .step-time {
  389. font-size: 12px;
  390. color: #999;
  391. margin-left: 10px;
  392. }
  393. /* 第二行的备注 */
  394. .second-row {
  395. display: flex;
  396. justify-content: space-between;
  397. align-items: center;
  398. }
  399. .second-row .detail-item {
  400. display: flex;
  401. align-items: center;
  402. }
  403. .no-data {
  404. text-align: center;
  405. color: #999;
  406. font-size: 18px;
  407. padding: 20px;
  408. }
  409. </style>