setting.vue 4.1 KB

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