setting.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <drawer-tabs-container>
  3. <div class="book-setting">
  4. <Form ref="formSystem" :model="formSystem" :label-width="80">
  5. <FormItem :label="$L('修改权限')">
  6. <div>
  7. <RadioGroup v-model="formSystem.role_edit">
  8. <Radio label="private">{{$L('私有文库')}}</Radio>
  9. <Radio label="member">{{$L('成员开放')}}</Radio>
  10. <Radio label="reg">{{$L('注册会员')}}</Radio>
  11. </RadioGroup>
  12. </div>
  13. <div class="form-placeholder">{{$L('管理文库的会员。')}}</div>
  14. </FormItem>
  15. <FormItem :label="$L('阅读权限')">
  16. <div>
  17. <RadioGroup v-model="formSystem.role_view">
  18. <Radio label="private">{{$L('私有文库')}}</Radio>
  19. <Radio label="member">{{$L('成员开放')}}</Radio>
  20. <Radio label="reg">{{$L('注册会员')}}</Radio>
  21. <Radio label="all">{{$L('完全开放')}}</Radio>
  22. </RadioGroup>
  23. </div>
  24. <div class="form-placeholder">{{$L('可以打开阅读分享地址的会员。')}}</div>
  25. </FormItem>
  26. <FormItem>
  27. <Button :loading="loadIng > 0" type="primary" @click="handleSubmit('formSystem')">{{$L('提交')}}</Button>
  28. <Button :loading="loadIng > 0" @click="handleReset('formSystem')" style="margin-left: 8px">{{$L('重置')}}</Button>
  29. </FormItem>
  30. </Form>
  31. </div>
  32. </drawer-tabs-container>
  33. </template>
  34. <style lang="scss" scoped>
  35. .book-setting {
  36. padding: 0 12px;
  37. .form-placeholder {
  38. color: #999;
  39. }
  40. }
  41. </style>
  42. <script>
  43. import DrawerTabsContainer from "../DrawerTabsContainer";
  44. export default {
  45. name: 'BookSetting',
  46. components: {DrawerTabsContainer},
  47. props: {
  48. id: {
  49. default: 0
  50. },
  51. canload: {
  52. type: Boolean,
  53. default: true
  54. },
  55. },
  56. data () {
  57. return {
  58. loadYet: false,
  59. loadIng: 0,
  60. formSystem: {},
  61. }
  62. },
  63. mounted() {
  64. if (this.canload) {
  65. this.loadYet = true;
  66. this.getSetting();
  67. }
  68. },
  69. watch: {
  70. id() {
  71. if (this.loadYet) {
  72. this.getSetting();
  73. }
  74. },
  75. canload(val) {
  76. if (val && !this.loadYet) {
  77. this.loadYet = true;
  78. this.getSetting();
  79. }
  80. }
  81. },
  82. methods: {
  83. getSetting(save) {
  84. this.loadIng++;
  85. $A.aAjax({
  86. url: 'docs/book/setting?type=' + (save ? 'save' : 'get'),
  87. data: Object.assign(this.formSystem, {
  88. id: this.id
  89. }),
  90. complete: () => {
  91. this.loadIng--;
  92. },
  93. success: (res) => {
  94. if (res.ret === 1) {
  95. this.formSystem = res.data;
  96. this.formSystem.role_edit = this.formSystem.role_edit || 'reg';
  97. this.formSystem.role_view = this.formSystem.role_view || 'all';
  98. if (save) {
  99. this.$Message.success(this.$L('修改成功'));
  100. }
  101. } else {
  102. if (save) {
  103. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg });
  104. }
  105. }
  106. }
  107. });
  108. },
  109. handleSubmit(name) {
  110. this.$refs[name].validate((valid) => {
  111. if (valid) {
  112. switch (name) {
  113. case "formSystem": {
  114. this.getSetting(true);
  115. break;
  116. }
  117. }
  118. }
  119. })
  120. },
  121. handleReset(name) {
  122. this.$refs[name].resetFields();
  123. },
  124. }
  125. }
  126. </script>