SetUser.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <el-dialog :title="title" :visible="visible" width="320px" :append-to-body="true" @close="dialogClose">
  3. <el-select v-model="user[bindKey]" :placeholder="placeholder" :multiple="isMultiple">
  4. <el-option v-for="item in memberList" :key="item.id" :label="item.name" :value="item.id" />
  5. </el-select>
  6. <div slot="footer">
  7. <el-button @click="dialogClose">取消</el-button>
  8. <el-button type="primary" @click="addChapterNode">确定</el-button>
  9. </div>
  10. </el-dialog>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'SetUser',
  15. props: {
  16. visible: {
  17. type: Boolean,
  18. required: true,
  19. },
  20. id: {
  21. type: String,
  22. default: '',
  23. },
  24. memberList: {
  25. type: Array,
  26. required: true,
  27. },
  28. type: {
  29. type: String,
  30. default: 'producer',
  31. },
  32. },
  33. data() {
  34. return {
  35. user: {
  36. id_list: [],
  37. id: '',
  38. },
  39. typeList: [
  40. { type: 'producer', label: '设置制作人', placeholder: '请选择制作人', bindKey: 'id_list', isMultiple: true },
  41. { type: 'auditor', label: '设置审校人', placeholder: '请选择审校人', bindKey: 'id_list', isMultiple: true },
  42. { type: 'mainAuditor', label: '设置主审校人', placeholder: '请选择主审校人', bindKey: 'id', isMultiple: false },
  43. ],
  44. };
  45. },
  46. computed: {
  47. title() {
  48. return this.typeList.find((item) => item.type === this.type).label;
  49. },
  50. placeholder() {
  51. return this.typeList.find((item) => item.type === this.type).placeholder;
  52. },
  53. isMultiple() {
  54. return this.typeList.find((item) => item.type === this.type).isMultiple;
  55. },
  56. bindKey() {
  57. return this.typeList.find((item) => item.type === this.type).bindKey;
  58. },
  59. },
  60. methods: {
  61. dialogClose() {
  62. this.$emit('update:visible', false);
  63. this.user = {
  64. id_list: [],
  65. id: '',
  66. };
  67. },
  68. addChapterNode() {
  69. if (this.type === this.typeList[0].type) {
  70. this.$emit('chapterSetProducer', { node_id: this.id, producer_id_list: this.user.id_list });
  71. }
  72. if (this.type === this.typeList[1].type) {
  73. this.$emit('SetAuditor', { flow_node_id: this.id, user_id_list: this.user.id_list });
  74. }
  75. if (this.type === this.typeList[2].type) {
  76. this.$emit('SetMainAuditor', { flow_node_id: this.id, user_id: this.user.id });
  77. }
  78. this.dialogClose();
  79. },
  80. },
  81. };
  82. </script>
  83. <style lang="scss" scoped>
  84. .el-select {
  85. width: 100%;
  86. }
  87. </style>