index.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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="settingForm" size="small" ref="settingForm" label-width="150px">
  11. <el-card shadow="never">
  12. <el-form-item label="应用是否开启" style="margin-bottom: 10px">
  13. <el-radio-group v-model="settingForm.is_enable">
  14. <el-radio :label="0">关闭
  15. </el-radio>
  16. <el-radio :label="1">开启
  17. </el-radio>
  18. </el-radio-group>
  19. </el-form-item>
  20. <block v-if="settingForm.is_enable == 1">
  21. <el-form-item label="Host:" style="margin-bottom: 10px;width:1000px;">
  22. <el-input v-model="settingForm.suona_host" >
  23. </el-input>
  24. </el-form-item>
  25. <el-form-item label="appId:" style="margin-bottom: 10px;width:1000px;">
  26. <el-input v-model="settingForm.suona_appId" >
  27. </el-input>
  28. </el-form-item>
  29. <el-form-item label="appSecret:" style="margin-bottom: 10px;width:1000px;">
  30. <el-input v-model="settingForm.suona_appSecret" >
  31. </el-input>
  32. </el-form-item>
  33. <el-form-item label="设备ID(IMEI码)" style="margin-bottom: 10px;width:1000px;">
  34. <el-form-item v-for="(item,index) in settingForm.device_id_arr" :key='index' style="display: flex;align-items: center;">
  35. <div class="flex">
  36. <el-input v-model="item.device_id" placeholder="">
  37. </el-input>
  38. <div class="minibtn flexcenter">
  39. <el-button v-if="settingForm.device_id_arr.length>1" size="mini" type="danger"
  40. icon="el-icon-close" circle
  41. @click="delItem(index)"></el-button>
  42. </div>
  43. </div>
  44. </el-form-item>
  45. <el-form-item>
  46. <el-button v-if="settingForm.device_id_arr && settingForm.device_id_arr.length<10" style="margin-bottom: 10px;" type="primary" size="small" @click="addCouponItem">添加IM
  47. </el-button>
  48. </el-form-item>
  49. </el-form-item>
  50. </block>
  51. </el-card>
  52. </el-form>
  53. </div>
  54. <div class="form_box">
  55. </div>
  56. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;"
  57. @click="store('settingForm')" size="small">保存
  58. </el-button>
  59. </el-card>
  60. </div>
  61. <script>
  62. const app = new Vue({
  63. el: '#app',
  64. data() {
  65. return {
  66. loading: false,
  67. btnLoading: false,
  68. settingForm: {
  69. is_enable: 0,
  70. suona_host:'',
  71. suona_appId:'',
  72. suona_appSecret:'',
  73. device_id:'',
  74. device_id_arr : [
  75. {
  76. device_id : '',
  77. },
  78. ],
  79. },
  80. }
  81. },
  82. mounted: function () {
  83. this.loadData();
  84. },
  85. methods: {
  86. loadData() {
  87. this.loading = true;
  88. request({
  89. params: {
  90. r: 'suona/setting/index',
  91. },
  92. method: 'get'
  93. }).then(e => {
  94. this.loading = false;
  95. if (e.data.code == 0 && !isEmpty(e.data.data)) {
  96. this.settingForm = e.data.data.basic;
  97. }
  98. }).catch(e => {
  99. this.loading = false;
  100. })
  101. },
  102. store(formName) {
  103. this.$refs[formName].validate((valid) => {
  104. if (valid) {
  105. this.btnLoading = true;
  106. request({
  107. params: {
  108. r: 'suona/setting/index',
  109. },
  110. method: 'post',
  111. data: this.settingForm
  112. }).then(e => {
  113. this.btnLoading = false;
  114. if (e.data.code == 0) {
  115. this.$message.success(e.data.msg);
  116. } else {
  117. this.$message.error(e.data.msg);
  118. }
  119. }).catch(e => {
  120. this.$message.error(e);
  121. this.btnLoading = false;
  122. })
  123. } else {
  124. this.btnLoading = false;
  125. console.log('error submit!!');
  126. return false;
  127. }
  128. });
  129. },
  130. // 点击删除某一item
  131. delItem(index){
  132. let temp = JSON.parse(JSON.stringify(this.settingForm.device_id_arr));
  133. temp.splice(index, 1);
  134. this.settingForm.device_id_arr = temp;
  135. },
  136. addCouponItem(){
  137. let deviceIdArr = JSON.parse(JSON.stringify(this.settingForm.device_id_arr));
  138. let item = {device_id : ''};
  139. deviceIdArr.push(item);
  140. this.settingForm.device_id_arr = deviceIdArr;
  141. },
  142. }
  143. });
  144. </script>
  145. <style >
  146. .flex{
  147. display:flex;
  148. }
  149. .minibtn{
  150. width:28px;
  151. height:28px;
  152. margin-left:10px;
  153. }
  154. .flexcenter{
  155. display:flex;
  156. justify-content: center;
  157. align-items: center;
  158. }
  159. .form_box {
  160. background-color: #f3f3f3;
  161. padding: 0 0 20px;
  162. }
  163. .button-item {
  164. margin-top: 12px;
  165. padding: 9px 25px;
  166. }
  167. .el-input-group__append {
  168. background-color: #fff;
  169. color: #353535;
  170. }
  171. .flex{
  172. display:flex;
  173. }
  174. >>> .el-input{
  175. width:30%;
  176. }
  177. </style>