ListingDialog.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <el-dialog :visible="visible" title="上架" width="450px" @close="dialogClose">
  3. <div class="listing">
  4. <div class="authorized-agency">
  5. <div class="authorized-agency-title">选择授权机构(可多选)</div>
  6. <el-select
  7. v-model="org_id_list"
  8. multiple
  9. placeholder="选择机构"
  10. :disabled="publish_scope === publishList[0].value"
  11. >
  12. <el-option
  13. v-for="{ id: org_id, name: org_name } in org_list"
  14. :key="org_id"
  15. :label="org_name"
  16. :value="org_id"
  17. />
  18. </el-select>
  19. </div>
  20. </div>
  21. <div slot="footer" class="footer">
  22. <el-button round @click="dialogClose">取消</el-button>
  23. <el-button type="primary" round @click="listing">上架</el-button>
  24. </div>
  25. </el-dialog>
  26. </template>
  27. <script>
  28. import { SetPublishStatusForBook, PageQueryOrgIndexList_OpenQuery } from '@/api/book';
  29. export default {
  30. name: 'ListingDialog',
  31. props: {
  32. id: {
  33. type: String,
  34. required: true,
  35. },
  36. visible: {
  37. type: Boolean,
  38. default: false,
  39. },
  40. },
  41. data() {
  42. return {
  43. publish_scope: 0, // 可见范围
  44. publishList: [
  45. { label: '全部机构可见', value: 1 },
  46. { label: '仅授权机构可见', value: 0 },
  47. ],
  48. cur_page: 1,
  49. org_list: [], // 机构列表
  50. org_id_list: [], // 授权机构
  51. };
  52. },
  53. created() {
  54. this.pageQueryOrgIndexList_OpenQuery();
  55. },
  56. methods: {
  57. dialogClose() {
  58. this.$emit('update:visible', false);
  59. },
  60. // 上架
  61. listing() {
  62. SetPublishStatusForBook({
  63. book_id: this.id,
  64. publish_status: 1,
  65. publish_scope: this.publish_scope,
  66. org_id_list: this.org_id_list,
  67. }).then(() => {
  68. this.dialogClose();
  69. this.$emit('PublishSuccess');
  70. });
  71. },
  72. pageQueryOrgIndexList_OpenQuery() {
  73. PageQueryOrgIndexList_OpenQuery({ name: '', page_capacity: 50, cur_page: this.cur_page }).then(
  74. ({ org_list, total_count, cur_page_end_index }) => {
  75. this.org_list.push(...org_list);
  76. if (cur_page_end_index < total_count) {
  77. this.cur_page += 1;
  78. this.pageQueryOrgIndexList_OpenQuery();
  79. }
  80. },
  81. );
  82. },
  83. },
  84. };
  85. </script>
  86. <style lang="scss" scoped>
  87. .el-dialog__wrapper {
  88. :deep .el-dialog {
  89. .listing {
  90. padding: 0 16px;
  91. .authorized-agency {
  92. display: flex;
  93. flex-direction: column;
  94. row-gap: 8px;
  95. margin-top: 20px;
  96. }
  97. }
  98. &__body {
  99. padding: 0 20px 16px;
  100. }
  101. &__header {
  102. display: flex;
  103. align-items: center;
  104. padding: 16px 20px;
  105. border-bottom: 1px solid #ebebeb;
  106. }
  107. &__title {
  108. font-size: 14px;
  109. font-weight: bold;
  110. color: $font-color;
  111. }
  112. &__headerbtn .el-dialog__close {
  113. color: $font-color;
  114. }
  115. .footer {
  116. display: flex;
  117. padding: 0 16px;
  118. .el-button {
  119. flex: 1;
  120. }
  121. }
  122. }
  123. }
  124. </style>