SetAuditor.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <el-dialog :title="title" :visible="visible" width="750px" :close-on-click-modal="false" @close="dialogClose">
  3. <el-table :data="flow_node_list" border>
  4. <el-table-column label="序号" width="60" align="center" header-align="center">
  5. <template slot-scope="scope">
  6. {{ scope.$index + 1 }}
  7. </template>
  8. </el-table-column>
  9. <el-table-column label="审校步骤" prop="name" width="120" header-align="center" align="center" />
  10. <el-table-column label="审校人" width="180" header-align="center" align="center">
  11. <template slot-scope="{ row }">
  12. <span>{{ row.auditor_list.map((auditor) => auditor.name).join(', ') }}</span>
  13. </template>
  14. </el-table-column>
  15. <el-table-column label="主审校人" width="120" header-align="center" align="center">
  16. <template slot-scope="{ row }">
  17. <span>{{ row?.main_auditor?.name }}</span>
  18. </template>
  19. </el-table-column>
  20. <el-table-column label="操作" fixed="right" header-align="center" align="center">
  21. <template slot-scope="{ row }">
  22. <span class="link" @click="openSetUserDialog(row.id, 'auditor')">设置审校人</span>
  23. <span class="link" @click="openSetUserDialog(row.id, 'mainAuditor')">设置主审校人</span>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. <div slot="footer">
  28. <el-button @click="dialogClose">关闭</el-button>
  29. </div>
  30. <SetUser
  31. :id="user.flow_node_id"
  32. :member-list="userList"
  33. :type="user.type"
  34. :visible.sync="user.visible"
  35. @SetAuditor="setAuditor"
  36. @SetMainAuditor="setMainAuditor"
  37. />
  38. </el-dialog>
  39. </template>
  40. <script>
  41. import SetUser from './SetUser.vue';
  42. import { SetAuditor, SetMainAuditor, GetChapterNodeAuditorList } from '@/api/project';
  43. export default {
  44. name: 'SetAuditor',
  45. components: {
  46. SetUser,
  47. },
  48. props: {
  49. visible: {
  50. type: Boolean,
  51. default: false,
  52. },
  53. id: {
  54. type: String,
  55. default: '',
  56. },
  57. memberList: {
  58. type: Array,
  59. default: () => [],
  60. },
  61. bookId: {
  62. type: String,
  63. default: '',
  64. },
  65. },
  66. data() {
  67. return {
  68. flow_node_list: [],
  69. chapter_node_name_path: '',
  70. auditor_desc: '',
  71. user: {
  72. type: 'auditor',
  73. visible: false,
  74. flow_node_id: '',
  75. },
  76. };
  77. },
  78. computed: {
  79. title() {
  80. return `设置审校人(${this.chapter_node_name_path})`;
  81. },
  82. userList() {
  83. if (this.user.type === 'auditor') {
  84. return this.memberList;
  85. } else if (this.user.type === 'mainAuditor') {
  86. return this.flow_node_list.find((item) => item.id === this.user.flow_node_id).auditor_list;
  87. }
  88. return [];
  89. },
  90. },
  91. watch: {
  92. visible(newVal) {
  93. if (newVal) {
  94. this.getChapterNodeAuditorList();
  95. }
  96. },
  97. },
  98. methods: {
  99. dialogClose() {
  100. this.$emit('update:visible', false);
  101. this.$emit('close');
  102. this.flow_node_list = [];
  103. this.chapter_node_name_path = '';
  104. this.auditor_desc = '';
  105. this.user = {
  106. type: 'auditor',
  107. visible: false,
  108. flow_node_id: '',
  109. };
  110. },
  111. openSetUserDialog(flow_node_id, type) {
  112. this.user.flow_node_id = flow_node_id;
  113. this.user.type = type;
  114. this.user.visible = true;
  115. },
  116. /**
  117. * @description 设置审校人
  118. * @param {object} param0 - 参数对象
  119. * @param {string} param0.flow_node_id - 审校节点ID
  120. * @param {Array<string>} param0.user_id_list - 用户ID列表
  121. */
  122. setAuditor({ flow_node_id, user_id_list }) {
  123. SetAuditor({ book_id: this.bookId, book_chapter_node_id: this.id, flow_node_id, user_id_list }).then(() => {
  124. this.$message.success('设置审校人成功');
  125. this.getChapterNodeAuditorList();
  126. });
  127. },
  128. /**
  129. * @description 设置主审校人
  130. * @param {object} param0 - 参数对象
  131. * @param {string} param0.flow_node_id - 审校节点ID
  132. * @param {string} param0.user_id - 用户ID
  133. */
  134. setMainAuditor({ flow_node_id, user_id }) {
  135. SetMainAuditor({ book_id: this.bookId, book_chapter_node_id: this.id, flow_node_id, user_id }).then(() => {
  136. this.$message.success('设置主审校人成功');
  137. this.getChapterNodeAuditorList();
  138. });
  139. },
  140. getChapterNodeAuditorList() {
  141. GetChapterNodeAuditorList({ book_id: this.bookId, book_chapter_node_id: this.id }).then(
  142. ({ flow_node_list, chapter_node_name_path, auditor_desc }) => {
  143. this.flow_node_list = flow_node_list;
  144. this.chapter_node_name_path = chapter_node_name_path;
  145. this.auditor_desc = auditor_desc;
  146. },
  147. );
  148. },
  149. },
  150. };
  151. </script>
  152. <style lang="scss" scoped></style>