SetUser.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible="visible"
  5. width="320px"
  6. :append-to-body="true"
  7. :close-on-click-modal="false"
  8. @close="dialogClose"
  9. >
  10. <el-select v-model="user[bindKey]" :placeholder="placeholder" :multiple="isMultiple">
  11. <el-option v-for="item in memberList" :key="item.id" :label="item.name" :value="item.id" />
  12. </el-select>
  13. <div v-if="type === typeList[0].type" class="end-date">
  14. <span>交稿日期:</span>
  15. <el-date-picker v-model="editEndDate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" />
  16. </div>
  17. <div slot="footer">
  18. <el-button @click="dialogClose">取消</el-button>
  19. <el-button type="primary" @click="addChapterNode">确定</el-button>
  20. </div>
  21. </el-dialog>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'SetUser',
  26. props: {
  27. visible: {
  28. type: Boolean,
  29. required: true,
  30. },
  31. id: {
  32. type: String,
  33. default: '',
  34. },
  35. memberList: {
  36. type: Array,
  37. required: true,
  38. },
  39. type: {
  40. type: String,
  41. default: 'producer',
  42. },
  43. list: {
  44. type: Array,
  45. default: () => [],
  46. },
  47. },
  48. data() {
  49. return {
  50. user: {
  51. id_list: [],
  52. id: '',
  53. },
  54. typeList: [
  55. { type: 'producer', label: '设置制作人', placeholder: '请选择制作人', bindKey: 'id_list', isMultiple: true },
  56. { type: 'auditor', label: '设置审校人', placeholder: '请选择审校人', bindKey: 'id_list', isMultiple: true },
  57. { type: 'mainAuditor', label: '设置主审校人', placeholder: '请选择主审校人', bindKey: 'id', isMultiple: false },
  58. ],
  59. editEndDate: '',
  60. };
  61. },
  62. computed: {
  63. title() {
  64. return this.typeList.find((item) => item.type === this.type).label;
  65. },
  66. placeholder() {
  67. return this.typeList.find((item) => item.type === this.type).placeholder;
  68. },
  69. isMultiple() {
  70. return this.typeList.find((item) => item.type === this.type).isMultiple;
  71. },
  72. bindKey() {
  73. return this.typeList.find((item) => item.type === this.type).bindKey;
  74. },
  75. },
  76. watch: {
  77. list: {
  78. handler(val) {
  79. if (this.type !== 'producer') return;
  80. if (val.length === 0) {
  81. this.user = {
  82. id_list: [],
  83. id: '',
  84. };
  85. return;
  86. }
  87. if (this.isMultiple) {
  88. this.user.id_list = val.map(({ id }) => id);
  89. } else {
  90. this.user.id = val[0]?.id || '';
  91. }
  92. },
  93. deep: true,
  94. },
  95. },
  96. methods: {
  97. dialogClose() {
  98. this.$emit('update:visible', false);
  99. this.user = {
  100. id_list: [],
  101. id: '',
  102. };
  103. },
  104. addChapterNode() {
  105. if (this.type === this.typeList[0].type) {
  106. if (this.editEndDate.length === 0) {
  107. this.$message.error('请选择交稿日期');
  108. return;
  109. }
  110. this.$emit('chapterSetProducer', {
  111. node_id: this.id,
  112. producer_id_list: this.user.id_list,
  113. edit_end_date: this.editEndDate,
  114. });
  115. }
  116. if (this.type === this.typeList[1].type) {
  117. this.$emit('SetAuditor', { flow_node_id: this.id, user_id_list: this.user.id_list });
  118. }
  119. if (this.type === this.typeList[2].type) {
  120. this.$emit('SetMainAuditor', { flow_node_id: this.id, user_id: this.user.id });
  121. }
  122. this.dialogClose();
  123. },
  124. },
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. .el-select {
  129. width: 100%;
  130. }
  131. .el-dialog {
  132. .end-date {
  133. display: flex;
  134. align-items: center;
  135. margin-top: 16px;
  136. span {
  137. width: 80px;
  138. }
  139. .el-date-picker {
  140. flex: 1;
  141. }
  142. }
  143. }
  144. </style>