index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <script lang="ts">
  2. // 声明额外的选项
  3. export default {
  4. name: "Edit"
  5. };
  6. </script>
  7. <script setup lang="ts">
  8. import { inject, onMounted, reactive, ref, Uploadfile, UploadImg, Editor, useRenderIcon, ElMessage, ElMessageBox, Upload, Close, http, getGroupUrl, RegularVerification, verification } from "@/utils/importUsed"
  9. // 接口列表实例
  10. let UrlList = reactive(null)
  11. // 获取当前板块接口列表
  12. onMounted(async () => {
  13. UrlList = await getGroupUrl(["kxsConfigServer"]);
  14. })
  15. const props = defineProps<{
  16. editVisible: {
  17. type: Boolean;
  18. default: false;
  19. };
  20. width: {
  21. type: Number;
  22. default: 50;
  23. };
  24. formData: {
  25. id: any;
  26. type: any;
  27. default: {};
  28. };
  29. }>();
  30. // 表单数据
  31. const UpdateForm: any = ref({
  32. terminalKind: "", //终端类型
  33. versionNum: "", //版本号
  34. title: "", //标题
  35. info: "", //更新信息
  36. confirmText: "", //确定按钮文字
  37. cancelText: "", //取消按钮文字
  38. downloadUrl: "", //更新地址
  39. });
  40. // 终端类型选项数据
  41. const terminalKindOptionList = [
  42. ]
  43. // 表单实例
  44. const ruleFormRef = ref()
  45. // 选项卡参数(默认值为列表某项的id)
  46. const activeId = ref('1')
  47. // 提交函数
  48. const submit = async (formEl) => {
  49. // 表单校验拦截
  50. if (!formEl) return
  51. await formEl.validate(async (valid, fields) => {
  52. if (valid) {
  53. //表单校验成功回调
  54. console.log('submit!')
  55. // 需动态生成接口
  56. const { status, msg }: any = await http.Request({
  57. method: UrlList.kxsConfigServer.appupdate.method,
  58. url: UrlList.kxsConfigServer.appupdate.url,
  59. params: UpdateForm.value
  60. });
  61. if (status === 1) {
  62. //业务成功回调
  63. ElMessage({
  64. message: "修改成功",
  65. type: "success"
  66. });
  67. UpdateForm.value = {
  68. terminalKind: "", //终端类型
  69. versionNum: "", //版本号
  70. title: "", //标题
  71. info: "", //更新信息
  72. confirmText: "", //确定按钮文字
  73. cancelText: "", //取消按钮文字
  74. downloadUrl: "", //更新地址
  75. };
  76. // 关闭修改弹窗;
  77. closeUpdateVisible();
  78. } else {
  79. //业务失败回调
  80. ElMessageBox.alert(msg, "提示", {
  81. confirmButtonText: "关闭",
  82. type: "warning"
  83. });
  84. }
  85. } else {
  86. //表单校验失败回调
  87. ElMessage({
  88. message: "请输入完整信息",
  89. type: "error"
  90. });
  91. }
  92. })
  93. };
  94. // 表单校验规则
  95. const rules = reactive({
  96. })
  97. // 关闭弹窗回调函数
  98. const closeFn: any = inject('closeEditUpdateVisible');
  99. const openVisible = async () => {
  100. //通过ID获取表格数据
  101. const { status, data }: any = await http.Request({ method: UrlList.kxsConfigServer.appquery.method, url: UrlList.kxsConfigServer.appquery.url, params: { id: props.formData.id }});
  102. if (status === 1) {
  103. UpdateForm.value = data;
  104. }
  105. };
  106. // 关闭弹窗回调函数
  107. const closeUpdateVisible = () => {
  108. UpdateForm.value = {
  109. terminalKind: "", //终端类型
  110. versionNum: "", //版本号
  111. title: "", //标题
  112. info: "", //更新信息
  113. confirmText: "", //确定按钮文字
  114. cancelText: "", //取消按钮文字
  115. downloadUrl: "", //更新地址
  116. };
  117. closeFn();
  118. };
  119. // 弹窗是否全屏
  120. const isFullscreen = ref(false)
  121. </script>
  122. <template lang="pug">
  123. .main
  124. el-dialog(v-model='props.editVisible' draggable width="50%" :fullscreen="isFullscreen" title="修改" @close="closeUpdateVisible" @open="openVisible")
  125. el-tabs(v-model="activeId" class="demo-tabs" @tab-click="handleClick")
  126. el-tab-pane(label="基本资料" name="1")
  127. el-form(:model='UpdateForm' label-position="right" ref="ruleFormRef" :rules="rules" label-width="100px")
  128. el-form-item(label="终端类型", prop="terminalKind")
  129. el-select(
  130. v-model="UpdateForm.terminalKind",
  131. placeholder="请选择终端类型",
  132. clearable,
  133. )
  134. el-option(:label="item.label", :value="item.id" v-for="(item,index) in terminalKindOptionList")
  135. el-form-item(label='版本号' prop="versionNum")
  136. el-input(v-model='UpdateForm.versionNum' autocomplete='off'
  137. placeholder="请输入版本号")
  138. el-form-item(label='标题' prop="title")
  139. el-input(v-model='UpdateForm.title' autocomplete='off'
  140. placeholder="请输入标题")
  141. el-form-item(label='确定按钮文字' prop="confirmText")
  142. el-input(v-model='UpdateForm.confirmText' autocomplete='off'
  143. placeholder="请输入确定按钮文字")
  144. el-form-item(label='取消按钮文字' prop="cancelText")
  145. el-input(v-model='UpdateForm.cancelText' autocomplete='off'
  146. placeholder="请输入取消按钮文字")
  147. el-form-item(label='更新地址' prop="downloadUrl")
  148. el-input(v-model='UpdateForm.downloadUrl' autocomplete='off'
  149. placeholder="请输入更新地址")
  150. el-tab-pane(label="基本信息" name="2")
  151. el-form(:model='UpdateForm' label-position="right" ref="ruleFormRef" :rules="rules" label-width="100px")
  152. .flex.justify-end
  153. el-button(
  154. :icon="useRenderIcon(Close)",
  155. :loading="loading",
  156. @click="closeUpdateVisible()"
  157. ) 关闭
  158. el-button(
  159. type="primary",
  160. :icon="useRenderIcon(Upload)",
  161. @click="submit(ruleFormRef)"
  162. ) 确认提交
  163. </template>
  164. <style scoped lang="scss">
  165. :deep(.el-dropdown-menu__item i) {
  166. margin: 0;
  167. }
  168. :deep(.el-form-item__label) {
  169. font-weight: 700;
  170. }
  171. :deep(.el-pagination) {
  172. flex-flow: wrap;
  173. }
  174. :deep(.is-draggable) {
  175. max-height: 80vh;
  176. overflow: auto;
  177. }
  178. :deep(.el-dialog__header) {
  179. position: sticky;
  180. top: 0;
  181. z-index: 2;
  182. background: #fff;
  183. }
  184. .collapsedom {
  185. padding: 0 20px;
  186. background-color: #fff;
  187. }
  188. .ovh-x {
  189. height: 40vh;
  190. overflow-y: auto;
  191. }
  192. :deep(.el-descriptions__header) {
  193. margin: 16px 0 !important;
  194. }
  195. .el-select {
  196. width: 100%;
  197. }
  198. </style>