setting.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div class="app-container">
  3. <base-header title="外勤签到设置" />
  4. <div class="container">
  5. <mt-cell title="是否启用照片上传功能">
  6. <mt-switch v-model="usePhoto" @change="setConfig" />
  7. </mt-cell>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import {LegworkGetConfig, LegworkSetConfig} from 'API/oa/legwork'
  13. export default {
  14. name: 'LegworkSetting',
  15. beforeRouteEnter(to, from, next) {
  16. next(vm => {
  17. vm.getConfig()
  18. })
  19. },
  20. data() {
  21. return {
  22. usePhoto: false
  23. }
  24. },
  25. methods: {
  26. getConfig() {
  27. LegworkGetConfig().then(res => {
  28. this.usePhoto = res === 1
  29. }).catch()
  30. },
  31. setConfig() {
  32. LegworkSetConfig({
  33. status: this.usePhoto ? 1 : 0
  34. }).then(() => {
  35. this.$toast('修改成功')
  36. }).catch()
  37. }
  38. }
  39. }
  40. </script>
  41. <style scoped lang="scss">
  42. .app-container {
  43. .container {
  44. .mint-cell {
  45. margin-top: 20px;
  46. padding: 0 32px;
  47. }
  48. ::v-deep .mint-switch-core {
  49. width: 80px;
  50. height: 40px;
  51. border-radius: 40px;
  52. &:before, &:after {
  53. top: 1px;
  54. width: 36px;
  55. height: 36px;
  56. border-radius: 36px;
  57. }
  58. }
  59. ::v-deep .mint-switch-core {
  60. background-color: #E6E6E6;
  61. border-color: #E6E6E6;
  62. }
  63. ::v-deep .mint-switch-input:checked + .mint-switch-core::after {
  64. transform: translateX(44px);
  65. }
  66. ::v-deep .mint-switch-input:checked + .mint-switch-core {
  67. border-color: $theme-color;
  68. background-color: $theme-color;
  69. }
  70. ::v-deep .mint-cell-value {
  71. margin-right: 0;
  72. }
  73. }
  74. }
  75. </style>