index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="app-container">
  3. <div
  4. class="config-card"
  5. v-loading="cardLoading"
  6. :element-loading-text="loadingText"
  7. >
  8. <div class="config-header">
  9. <p>配置小程序/飞书补发策略及可用状态</p>
  10. </div>
  11. <el-form
  12. ref="form"
  13. :model="form"
  14. label-width="80px"
  15. v-loading="loading"
  16. class="config-form"
  17. >
  18. <el-form-item label="类型" prop="type">
  19. <el-select
  20. v-model="form.type"
  21. placeholder="请选择类型"
  22. class="form-select"
  23. >
  24. <el-option label="小程序" :value="1" />
  25. <el-option label="飞书" :value="2" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="小程序" prop="appId">
  29. <el-select
  30. v-model="form.appId"
  31. placeholder="请选择小程序"
  32. class="form-select"
  33. >
  34. <el-option
  35. v-for="item in appList"
  36. :key="item.appid"
  37. :label="item.name"
  38. :value="item.appid"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="答题短链" prop="shortLink">
  43. <el-input v-model="form.shortLink" :disabled="true" />
  44. </el-form-item>
  45. <el-form-item label="答题进度" prop="rate">
  46. <el-input-number
  47. v-model="form.rate"
  48. :min="1"
  49. :max="100"
  50. class="form-select"
  51. />
  52. </el-form-item>
  53. <el-form-item label="可用状态">
  54. <el-radio-group v-model="form.status">
  55. <el-radio :label="1">正常</el-radio>
  56. <el-radio :label="2">禁用</el-radio>
  57. </el-radio-group>
  58. </el-form-item>
  59. </el-form>
  60. <div class="config-footer">
  61. <el-button type="primary" @click="submitForm">提 交</el-button>
  62. <el-button
  63. v-if="form.id"
  64. type="success"
  65. :loading="shortLinkLoading"
  66. @click="shortLinkHandle"
  67. >生成短链</el-button
  68. >
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import {
  75. getConfigInfo,
  76. getAppIdList,
  77. addReissueConfig,
  78. updateReissueConfig,
  79. generateAnswerShortLink,
  80. } from "@/api/his/reissueConfig";
  81. export default {
  82. name: "ReissueConfig",
  83. data() {
  84. return {
  85. appList: [],
  86. loading: false,
  87. reissueLoading: false,
  88. shortLinkLoading: false,
  89. form: {
  90. type: null,
  91. appId: null,
  92. status: 1,
  93. },
  94. };
  95. },
  96. computed: {
  97. cardLoading() {
  98. return this.reissueLoading || this.shortLinkLoading;
  99. },
  100. loadingText() {
  101. if (this.shortLinkLoading) return "短链生成中,请稍候...";
  102. if (this.reissueLoading) return "补发中,请稍候...";
  103. return "";
  104. },
  105. },
  106. created() {
  107. this.getInfo();
  108. getAppIdList().then((response) => {
  109. this.appList = response.data;
  110. });
  111. },
  112. methods: {
  113. getInfo() {
  114. this.loading = true;
  115. getConfigInfo()
  116. .then((response) => {
  117. this.form = response.data;
  118. })
  119. .finally(() => {
  120. this.loading = false;
  121. });
  122. },
  123. shortLinkHandle(){
  124. this.shortLinkLoading = true;
  125. generateAnswerShortLink(this.form)
  126. .then(() => {
  127. this.msgSuccess("生成短链成功");
  128. this.getInfo();
  129. })
  130. .finally(() => {
  131. this.shortLinkLoading = false;
  132. });
  133. },
  134. submitForm() {
  135. this.$refs["form"].validate((valid) => {
  136. if (!valid) return;
  137. const api =
  138. this.form.id != null ? updateReissueConfig : addReissueConfig;
  139. const successMsg = this.form.id != null ? "修改成功" : "新增成功";
  140. api(this.form).then(() => {
  141. this.msgSuccess(successMsg);
  142. this.getInfo();
  143. });
  144. });
  145. },
  146. },
  147. };
  148. </script>
  149. <style scoped>
  150. .config-card {
  151. max-width: 600px;
  152. margin: 0 auto;
  153. background: #fff;
  154. border-radius: 8px;
  155. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  156. overflow: hidden;
  157. }
  158. .config-header {
  159. padding: 20px 24px 16px;
  160. border-bottom: 1px solid #ebeef5;
  161. }
  162. .config-header h2 {
  163. margin: 0;
  164. font-size: 18px;
  165. color: #303133;
  166. font-weight: 600;
  167. }
  168. .config-header p {
  169. margin: 6px 0 0;
  170. font-size: 13px;
  171. color: #909399;
  172. }
  173. .config-form {
  174. padding: 24px 24px 0;
  175. }
  176. .config-form .el-form-item {
  177. margin-bottom: 20px;
  178. }
  179. .form-select {
  180. width: 240px;
  181. }
  182. .config-footer {
  183. padding: 16px 24px;
  184. border-top: 1px solid #ebeef5;
  185. text-align: right;
  186. }
  187. /* ========== 手机端适配 ========== */
  188. @media (max-width: 768px) {
  189. .app-container {
  190. margin: 0 !important;
  191. padding: 10px !important;
  192. }
  193. .config-card {
  194. max-width: 100%;
  195. border-radius: 4px;
  196. box-shadow: none;
  197. }
  198. .config-header {
  199. padding: 16px 16px 12px;
  200. }
  201. .config-header h2 {
  202. font-size: 16px;
  203. }
  204. .config-header p {
  205. font-size: 12px;
  206. }
  207. .config-form {
  208. padding: 16px 16px 0;
  209. }
  210. .config-form .el-form-item {
  211. margin-bottom: 16px;
  212. }
  213. /* 标签置顶,内容撑满 */
  214. .config-form ::v-deep .el-form-item__label {
  215. float: none;
  216. display: block;
  217. text-align: left;
  218. line-height: 1.5;
  219. padding-bottom: 6px;
  220. }
  221. .config-form ::v-deep .el-form-item__content {
  222. margin-left: 0 !important;
  223. }
  224. .form-select {
  225. width: 100%;
  226. }
  227. .config-footer {
  228. padding: 12px 16px;
  229. text-align: center;
  230. }
  231. .config-footer .el-button {
  232. display: block;
  233. width: 100%;
  234. margin: 0 0 10px;
  235. }
  236. .config-footer .el-button:last-child {
  237. margin-bottom: 0;
  238. }
  239. }
  240. </style>