index.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <div id="app" v-cloak>
  2. <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1500px;"
  3. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  4. <div slot="header">
  5. <div>
  6. <span>基础设置</span>
  7. </div>
  8. </div>
  9. <div class="form_box">
  10. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="150px">
  11. <el-card shadow="never">
  12. <div>
  13. <el-row>
  14. <el-col :span="16">
  15. <el-form-item label="启用" style="margin-bottom: 0">
  16. <div>
  17. <el-switch v-model="ruleForm.is_enable" :active-value="1" :inactive-value="0"></el-switch>
  18. </div>
  19. </el-form-item>
  20. </el-col>
  21. </el-row>
  22. </div>
  23. </el-card>
  24. </el-form>
  25. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;"
  26. @click="store('ruleForm')" size="small">保存
  27. </el-button>
  28. </div>
  29. </el-card>
  30. </div>
  31. <script>
  32. const app = new Vue({
  33. el: '#app',
  34. data() {
  35. return {
  36. loading: false,
  37. btnLoading: false,
  38. ruleForm: {
  39. is_enable: 0,
  40. },
  41. }
  42. },
  43. mounted: function () {
  44. this.loadData();
  45. },
  46. methods: {
  47. loadData() {
  48. this.loading = true;
  49. request({
  50. params: {
  51. r: 'clerk/setting/index',
  52. },
  53. method: 'get'
  54. }).then(e => {
  55. this.loading = false;
  56. if (e.data.code == 0 && !isEmpty(e.data.data)) {
  57. this.ruleForm = e.data.data;
  58. }
  59. }).catch(e => {
  60. this.loading = false;
  61. })
  62. },
  63. store(formName) {
  64. this.$refs[formName].validate((valid) => {
  65. if (valid) {
  66. this.btnLoading = true;
  67. request({
  68. params: {
  69. r: 'clerk/setting/index',
  70. },
  71. method: 'post',
  72. data: this.ruleForm
  73. }).then(e => {
  74. this.btnLoading = false;
  75. if (e.data.code == 0) {
  76. this.$message.success(e.data.msg);
  77. } else {
  78. this.$message.error(e.data.msg);
  79. }
  80. }).catch(e => {
  81. this.$message.error(e);
  82. this.btnLoading = false;
  83. })
  84. } else {
  85. this.btnLoading = false;
  86. console.log('error submit!!');
  87. return false;
  88. }
  89. });
  90. },
  91. }
  92. });
  93. </script>
  94. <style>
  95. .form_box {
  96. background-color: #f3f3f3;
  97. padding: 0 0 20px;
  98. }
  99. .button-item {
  100. margin-top: 12px;
  101. padding: 9px 25px;
  102. }
  103. .el-input-group__append {
  104. background-color: #fff;
  105. color: #353535;
  106. }
  107. </style>