index.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <div id="app" v-cloak>
  2. <el-card
  3. v-loading="loading"
  4. style="border:0; min-width: 800px;"
  5. shadow="never"
  6. body-style="background-color: #f3f3f3;padding: 10px 0 0;"
  7. >
  8. <div slot="header">
  9. <span>配置</span>
  10. </div>
  11. <el-form
  12. :model="formData"
  13. ref="elForm"
  14. label-width="200px"
  15. style="position: relative"
  16. size="small"
  17. :rules="rules"
  18. >
  19. <el-row>
  20. <el-col :span="24">
  21. <div class="form-body">
  22. <el-col :span="24">
  23. <el-form-item label="自提码自定义名称" prop="pickup_code_name">
  24. <el-input v-model="formData.pickup_code_name"></el-input>
  25. </el-form-item>
  26. </el-col>
  27. <div></div>
  28. <el-col :span="24">
  29. <el-form-item size="large">
  30. <el-button type="primary" size="small" @click="submitForm">提交</el-button>
  31. </el-form-item>
  32. </el-col>
  33. </div>
  34. </el-col>
  35. </el-row>
  36. </el-form>
  37. </el-card>
  38. </div>
  39. <script>
  40. const app = new Vue({
  41. el: '#app',
  42. data() {
  43. return {
  44. loading: false,
  45. submitLoading: false,
  46. formData: {
  47. pickup_code_name: '',
  48. },
  49. rules: {
  50. pickup_code_name: [{
  51. required: true,
  52. message: '自提码自定义名称不能为空',
  53. }],
  54. },
  55. }
  56. },
  57. computed: {},
  58. watch: {},
  59. created() {
  60. this.readConfig()
  61. },
  62. mounted() {},
  63. methods: {
  64. submitForm() {
  65. this.$refs['elForm'].validate(valid => {
  66. if (valid) {
  67. this.submitLoading = true;
  68. request({
  69. params: {
  70. r: 'printer/setting/save',
  71. },
  72. method: 'post',
  73. data: this.formData,
  74. }).then(e => {
  75. this.submitLoading = false
  76. if (e.data.code === 0) {
  77. this.$message.success(e.data.msg)
  78. } else {
  79. this.$message.error(e.data.msg)
  80. }
  81. })
  82. } else {
  83. this.$message.error('部分参数验证不通过')
  84. }
  85. })
  86. },
  87. resetForm() {
  88. this.$refs['elForm'].resetFields()
  89. },
  90. readConfig(){
  91. request({
  92. params: {
  93. r: 'printer/setting/index',
  94. },
  95. method: 'get',
  96. }).then(e => {
  97. this.submitLoading = false
  98. if (e.data.code === 0) {
  99. this.formData = {...this.formData, ...e.data.data}
  100. }
  101. })
  102. },
  103. }
  104. })
  105. </script>
  106. <style>
  107. .form-body {
  108. padding-bottom: 5px;
  109. display: flex;
  110. flex-direction: column;
  111. }
  112. .title {
  113. display: flex;
  114. align-items: center;
  115. padding: 18px 20px;
  116. border-bottom: 1px solid #F3F3F3;
  117. background-color: #fff;
  118. }
  119. .title-line {
  120. width: 4px;
  121. height: 20px;
  122. background-color: #1479F0;
  123. margin-right: 10px;
  124. }
  125. .padding-top {
  126. margin-bottom: 10px;
  127. }
  128. </style>