index.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <div id="app" v-cloak>
  2. <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;">
  3. <div class="form_box">
  4. <el-form :model="ruleForm" :rules="rules" size="small" ref="ruleForm" label-width="150px">
  5. <el-card shadow="never">
  6. <div slot="header">
  7. <div>
  8. <span>基础配置</span>
  9. </div>
  10. </div>
  11. <div>
  12. <el-row>
  13. <el-col :span="16">
  14. <el-form-item label="是否开启" >
  15. <el-switch v-model="ruleForm.is_enable" :active-value="1" :inactive-value="0"></el-switch>
  16. </el-form-item>
  17. </el-col>
  18. </el-row>
  19. <el-form-item label="弹窗图片" prop="cover">
  20. <el-col :span="12">
  21. <com-attachment v-model="ruleForm.picture" :multiple="false" :max="1">
  22. <el-tooltip class="item" effect="dark" content="建议尺寸:900 * 600" placement="top">
  23. <el-button size="mini">选择图片</el-button>
  24. </el-tooltip>
  25. </com-attachment>
  26. <div class="customize-share-title" v-if="ruleForm.picture" >
  27. <image mode="aspectFill" width='120px' :src="ruleForm.picture ? ruleForm.picture : ''"></image>
  28. <el-button v-if="ruleForm.picture" class="del-btn" size="mini" type="danger" icon="el-icon-close" circle @click="ruleForm.picture = ''"></el-button>
  29. </div>
  30. </el-col>
  31. </el-form-item>
  32. </div>
  33. </el-card>
  34. </el-form>
  35. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;" @click="store('ruleForm')" size="small">保存</el-button>
  36. </div>
  37. </el-card>
  38. </div>
  39. <script>
  40. const app = new Vue({
  41. el: '#app',
  42. data() {
  43. return {
  44. loading: false,
  45. btnLoading: false,
  46. ruleForm: {
  47. is_enable: 0,
  48. picture: '',
  49. },
  50. rules: {
  51. }
  52. }
  53. },
  54. mounted: function() {
  55. this.loadData();
  56. },
  57. methods: {
  58. loadData() {
  59. this.loading = true;
  60. request({
  61. params: {
  62. r: 'purchase/setting/index',
  63. },
  64. method: 'get'
  65. }).then(e => {
  66. this.loading = false;
  67. if (e.data.code == 0) {
  68. Object.assign(this.ruleForm, e.data.data);
  69. }
  70. }).catch(e => {
  71. this.loading = false;
  72. this.$message.error(e);
  73. })
  74. },
  75. store(formName) {
  76. this.$refs[formName].validate((valid) => {
  77. if (valid) {
  78. this.btnLoading = true;
  79. request({
  80. params: {
  81. r: 'purchase/setting/index',
  82. },
  83. method: 'post',
  84. data: {
  85. basic: this.ruleForm,
  86. }
  87. }).then(e => {
  88. this.btnLoading = false;
  89. if (e.data.code == 0) {
  90. this.$message.success(e.data.msg);
  91. } else {
  92. this.$message.error(e.data.msg);
  93. }
  94. }).catch(e => {
  95. this.$message.error(e);
  96. this.btnLoading = false;
  97. })
  98. } else {
  99. this.btnLoading = false;
  100. console.log('error submit!!');
  101. return false;
  102. }
  103. });
  104. },
  105. }
  106. });
  107. </script>