memory.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-image');
  4. ComponentHelper::loadComponentView('com-attachment');
  5. ComponentHelper::loadComponentView('com-rich-text');
  6. ?>
  7. <div id="app" v-cloak>
  8. <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  9. <div class="form_box">
  10. <template>
  11. <el-card>
  12. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="150px">
  13. <el-tabs v-model="activeName" type="card">
  14. <el-tab-pane label="存储设置" name="storage">
  15. <?=ComponentHelper::loadComponentView('storage', __DIR__ . '/storage/'); ?>
  16. </el-tab-pane>
  17. <el-tab-pane label="超限设置" name="limit">
  18. <?=ComponentHelper::loadComponentView('limit', __DIR__ . '/storage/'); ?>
  19. </el-tab-pane>
  20. </el-tabs>
  21. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;" @click="submit" size="small">保存
  22. </el-button>
  23. </el-form>
  24. </el-card>
  25. </template>
  26. </div>
  27. </el-card>
  28. </div>
  29. <script>
  30. const app = new Vue({
  31. el: '#app',
  32. data() {
  33. return {
  34. loading: false,
  35. btnLoading: false,
  36. params: {},
  37. activeName: 'storage',
  38. setting_group_name:{
  39. storage:'存储设置',
  40. limit:'超限设置'
  41. },
  42. ruleForm: {
  43. storage:{
  44. driver:{
  45. title:'存储方式',
  46. value:'oss',
  47. extra:{
  48. local:'本地存储',
  49. cos:'腾讯云存储',
  50. oss:'阿里云存储',
  51. qiniu:'七牛云存储'
  52. }
  53. }
  54. },
  55. storage_driver:{
  56. local:{title:'本地存储',value:'',remark:'本地服务器存储无需额外配置'},
  57. cos:{
  58. title:'腾讯云存储',
  59. value:{
  60. bucket: '',
  61. area:'',
  62. domain:'',
  63. secret_id:'',
  64. secret_key:'',
  65. }
  66. },
  67. oss:{
  68. title:'阿里云存储',
  69. value:{
  70. storage_aliyun_bucket: '',
  71. storage_aliyun_endpoint:'',
  72. storage_aliyun_accesskeyid:'',
  73. storage_aliyun_accesskeysecret:'',
  74. storage_aliyun_user_url:'',
  75. storage_aliyun_transport_protocols:'',
  76. img_style_interface:'',
  77. arn: '',
  78. }
  79. },
  80. qiniu:{
  81. title:'七牛云存储',
  82. value:{
  83. bucket: '',
  84. domain:'',
  85. access_key_id:'',
  86. access_key_secret:'',
  87. img_style_interface:'',
  88. }
  89. }
  90. },
  91. limit:{
  92. img:{title:'上传图片限制',value:'',remark: '-1:表示无限制,单位:MB'},
  93. upload_images_compress:{title:'上传图片是否压缩',value:0,remark: '开启上传图片会按比例进行压缩'},
  94. video:{title:'上传视频限制',value:'',remark: '-1:表示无限制,单位:MB'},
  95. diy:{title:'diy组件限制',value:'',remark: '-1:表示无限制,单位:个'}
  96. }
  97. }
  98. }
  99. },
  100. mounted: function() {
  101. this.loadData();
  102. },
  103. methods: {
  104. loadData() {
  105. if(this.loading === true) return;
  106. this.loading = true;
  107. request({
  108. params: {
  109. r: 'mall/setting/get-memory',
  110. type: 'mall_storage'
  111. },
  112. method: 'get'
  113. }).then(e => {
  114. this.loading = false;
  115. if (e.data.code == 0) {
  116. if(e.data.data){//有选中的
  117. var data = e.data.data;
  118. Object.keys(this.ruleForm).forEach((key) => {
  119. Object.keys(this.ruleForm[key]).forEach((k) => {
  120. if (data[key][k]) {
  121. if (typeof data[key][k].value == 'string' && data[key][k].value.indexOf("{") !== -1) {
  122. // 将json字符串转为对象
  123. this.ruleForm[key][k].value = JSON.parse(data[key][k].value);
  124. }else{
  125. this.ruleForm[key][k].value = data[key][k].value;
  126. }
  127. }
  128. });
  129. });
  130. }
  131. }
  132. }).catch(e => {
  133. this.loading = false;
  134. })
  135. },
  136. submit() {
  137. this.btnLoading = true;
  138. this.$request({
  139. params: {
  140. r: 'mall/setting/get-memory',
  141. },
  142. method: 'post',
  143. data: {
  144. setting: this.ruleForm,
  145. },
  146. }).then(e => {
  147. this.btnLoading = false;
  148. if (e.data.code === 0) {
  149. this.$message.success(e.data.msg);
  150. } else {
  151. this.$message.error(e.data.msg);
  152. }
  153. }).catch(e => {
  154. this.btnLoading = false;
  155. });
  156. },
  157. updateSuccess(e) {
  158. this.$message.success('上传成功')
  159. }
  160. }
  161. });
  162. </script>