index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div class="check-task">
  3. <MenuPage only-key="/personal_workbench/check_task" />
  4. <div class="check-main">
  5. <div class="textbook-container">
  6. <div class="title">待审校的教材</div>
  7. <div class="list-header">
  8. <span class="cell">编号</span>
  9. <span class="cell">名称</span>
  10. </div>
  11. <ul class="textbook-list">
  12. <li
  13. v-for="{ id, sn, name } in project_list"
  14. :key="id"
  15. class="textbook-item"
  16. :class="{ active: cur_project_id === id }"
  17. @click="selectProject(id)"
  18. >
  19. <span class="cell">{{ sn }}</span>
  20. <span class="cell">{{ name }}</span>
  21. </li>
  22. </ul>
  23. </div>
  24. <div class="textbook-chapter">
  25. <div ref="chapterHeader" class="chapter-header">
  26. <span class="cell">教材内容</span>
  27. <span class="cell">最后编辑人</span>
  28. <span class="cell">最后编辑时间</span>
  29. <span class="cell">制作人</span>
  30. <span class="cell">我的审校节点</span>
  31. <span class="cell">状态</span>
  32. </div>
  33. <div ref="chapterList" class="chapter-list">
  34. <div
  35. v-for="{
  36. id,
  37. name,
  38. producer_list,
  39. status_name,
  40. deep,
  41. is_my_audit_task,
  42. last_editor_name,
  43. last_edit_time,
  44. is_leaf_chapter,
  45. my_audit_node_desc,
  46. } in node_list"
  47. :key="id"
  48. :style="computedNameStyle(deep, isTrue(is_my_audit_task))"
  49. class="chapter-item"
  50. >
  51. <span
  52. class="path"
  53. :style="computedPathStyle(isTrue(is_my_audit_task))"
  54. @click="navigateToChapter(id, isTrue(is_my_audit_task))"
  55. >
  56. {{ name }}
  57. </span>
  58. <span>{{ isTrue(is_leaf_chapter) ? last_editor_name : '' }}</span>
  59. <span>{{ isTrue(is_leaf_chapter) ? last_edit_time : '' }}</span>
  60. <span :title="producer_list.map((producer) => producer.name).join(';')">
  61. {{ producer_list.map((producer) => producer.name).join(';') }}
  62. </span>
  63. <span class="audit-node-desc nowrap-ellipsis" :title="my_audit_node_desc">
  64. {{ my_audit_node_desc }}
  65. </span>
  66. <span class="status">{{ status_name }}</span>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import MenuPage from '../common/menu.vue';
  75. import { ChapterGetBookChapterStructExpandList } from '@/api/book';
  76. import { PageQueryMyProjectList_Auditor } from '@/api/list';
  77. import { isTrue } from '@/utils/validate';
  78. export default {
  79. name: 'CheckTaskPage',
  80. components: {
  81. MenuPage,
  82. },
  83. data() {
  84. return {
  85. project_list: [],
  86. cur_project_id: '',
  87. node_list: [],
  88. isTrue,
  89. };
  90. },
  91. created() {
  92. this.queryMyProjectList_Auditor();
  93. },
  94. methods: {
  95. /**
  96. * 查询我的审校项目列表
  97. */
  98. queryMyProjectList_Auditor() {
  99. PageQueryMyProjectList_Auditor({ page_capacity: 50, cur_page: 1 }).then(({ project_list }) => {
  100. this.project_list = project_list;
  101. if (this.project_list.length > 0) {
  102. this.cur_project_id = this.project_list[0].id;
  103. this.getBookChapterStructExpandList();
  104. }
  105. });
  106. },
  107. /**
  108. * 得到教材章节结构展开列表
  109. */
  110. getBookChapterStructExpandList() {
  111. ChapterGetBookChapterStructExpandList({
  112. book_id: this.cur_project_id,
  113. node_deep_mode: 0,
  114. is_contain_producer: 'true',
  115. is_contain_auditor: 'true',
  116. }).then(({ node_list }) => {
  117. this.node_list = node_list;
  118. this.$nextTick(() => {
  119. const chapterList = this.$refs.chapterList;
  120. if (chapterList.scrollHeight > chapterList.clientHeight) {
  121. this.$refs.chapterHeader.classList.add('has-scrollbar');
  122. } else {
  123. this.$refs.chapterHeader.classList.remove('has-scrollbar');
  124. }
  125. });
  126. });
  127. },
  128. /**
  129. * 选择项目
  130. * @param {string} id - 项目ID
  131. */
  132. selectProject(id) {
  133. this.cur_project_id = id;
  134. this.getBookChapterStructExpandList();
  135. },
  136. /**
  137. * 计算章节名称样式
  138. * @param {number} deep - 节点深度
  139. * @param {boolean} isMyAuditTask - 是否是我的审校任务
  140. * @returns {Object} - 样式对象
  141. */
  142. computedNameStyle(deep, isMyAuditTask) {
  143. return {
  144. 'padding-left': `${(deep - 1) * 16}px`,
  145. fontWeight: deep === 1 ? 'bold' : 'normal',
  146. cursor: isMyAuditTask ? 'pointer' : 'auto',
  147. };
  148. },
  149. /**
  150. * 计算章节路径样式
  151. * @param {boolean} isMyAuditTask - 是否是我的审校任务
  152. * @returns {Object} - 样式对象
  153. */
  154. computedPathStyle(isMyAuditTask) {
  155. console.log(isMyAuditTask);
  156. return {
  157. color: isMyAuditTask ? '#165dff' : 'default',
  158. };
  159. },
  160. /**
  161. * 导航到章节
  162. * @param {string} id - 章节ID
  163. * @param {boolean} isMyAuditTask - 是否是我的审校任务
  164. */
  165. navigateToChapter(id, isMyAuditTask) {
  166. if (!isMyAuditTask) return;
  167. if (!id) return;
  168. this.$router.push({
  169. path: `/personal_workbench/check_task/audit/${id}`,
  170. query: { project_id: this.cur_project_id },
  171. });
  172. },
  173. },
  174. };
  175. </script>
  176. <style lang="scss" scoped>
  177. @use '@/styles/mixin.scss' as *;
  178. .check-task {
  179. @include page-base;
  180. height: 100%;
  181. .check-main {
  182. display: flex;
  183. flex: 1;
  184. width: 100%;
  185. height: 100%;
  186. border-top: $border;
  187. .textbook-container {
  188. display: flex;
  189. flex-direction: column;
  190. width: 450px;
  191. border-right: $border;
  192. .title {
  193. padding-left: 12px;
  194. font-size: 14px;
  195. font-weight: bold;
  196. color: $font-light-color;
  197. }
  198. .list-header {
  199. display: flex;
  200. align-items: center;
  201. justify-content: space-between;
  202. height: 40px;
  203. padding: 0 12px;
  204. font-size: 14px;
  205. color: $font-light-color;
  206. background-color: #eee;
  207. border-radius: 4px;
  208. .cell {
  209. font-size: 14px;
  210. font-weight: bold;
  211. text-align: center;
  212. &:first-child {
  213. width: 120px;
  214. }
  215. &:last-child {
  216. flex: 1;
  217. }
  218. }
  219. }
  220. .textbook-list {
  221. display: flex;
  222. flex-direction: column;
  223. height: calc(100vh - 184px);
  224. overflow: auto;
  225. .textbook-item {
  226. display: flex;
  227. align-items: center;
  228. height: 40px;
  229. min-height: 40px;
  230. padding: 0 12px;
  231. font-size: 14px;
  232. color: $font-light-color;
  233. cursor: pointer;
  234. background-color: #fff;
  235. border-radius: 4px;
  236. &:hover {
  237. background-color: #f5f5f5;
  238. }
  239. &.active {
  240. background-color: $main-active-color;
  241. }
  242. .cell {
  243. text-align: center;
  244. &:first-child {
  245. width: 120px;
  246. }
  247. &:last-child {
  248. flex: 1;
  249. }
  250. }
  251. }
  252. }
  253. }
  254. .textbook-chapter {
  255. display: flex;
  256. flex: 1;
  257. flex-direction: column;
  258. @mixin cell {
  259. > span {
  260. min-height: 37px;
  261. padding: 8px 12px;
  262. border-right: $border;
  263. }
  264. :first-child {
  265. flex: 1;
  266. border-right: $border;
  267. }
  268. :nth-child(2) {
  269. width: 120px;
  270. max-width: 120px;
  271. }
  272. :nth-child(3) {
  273. width: 170px;
  274. max-width: 170px;
  275. font-weight: normal;
  276. }
  277. :nth-child(4) {
  278. width: 140px;
  279. max-width: 140px;
  280. }
  281. :nth-child(5) {
  282. width: 320px;
  283. text-align: center;
  284. }
  285. :last-child {
  286. width: 140px;
  287. text-align: center;
  288. }
  289. }
  290. .chapter-header {
  291. display: flex;
  292. height: 40px;
  293. font-size: 14px;
  294. background-color: $main-background-color;
  295. border-bottom: $border;
  296. @include cell;
  297. .cell {
  298. font-weight: bold;
  299. text-align: center;
  300. }
  301. &.has-scrollbar {
  302. padding-right: 15px;
  303. }
  304. }
  305. .chapter-list {
  306. height: calc(100vh - 165px);
  307. overflow: auto;
  308. .chapter-item {
  309. display: flex;
  310. align-items: center;
  311. font-size: 14px;
  312. border-bottom: $border;
  313. @include cell;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. </style>