index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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(["prizeSet"]);
  14. databaseIdQuery();
  15. })
  16. const props = defineProps<{
  17. editVisible: {
  18. type: Boolean;
  19. default: false;
  20. };
  21. width: {
  22. type: Number;
  23. default: 50;
  24. };
  25. formData: {
  26. id: any;
  27. type: any;
  28. default: {};
  29. };
  30. }>();
  31. // 表单数据
  32. const UpdateForm: any = ref({
  33. id: null, //ID
  34. databaseId: null, //查询数据库
  35. tableEnName: "", //查询表
  36. summary: "", //说明
  37. });
  38. // 表单实例
  39. const ruleFormRef = ref()
  40. // 选项卡参数(默认值为列表某项的id)
  41. const activeId = ref('1')
  42. // 提交函数
  43. const submit = async (formEl) => {
  44. // 表单校验拦截
  45. if (!formEl) return
  46. await formEl.validate(async (valid, fields) => {
  47. if (valid) {
  48. //表单校验成功回调
  49. console.log('submit!')
  50. // 需动态生成接口
  51. const { status, msg }: any = await http.Request({
  52. method: UrlList.prizeSet.priupdatePriQueryTable.method,
  53. url: UrlList.prizeSet.priupdatePriQueryTable.url,
  54. params: UpdateForm.value
  55. });
  56. if (status === 1) {
  57. //业务成功回调
  58. ElMessage({
  59. message: "修改成功",
  60. type: "success"
  61. });
  62. UpdateForm.value = {
  63. id: null, //ID
  64. databaseId: null, //查询数据库
  65. tableEnName: "", //查询表
  66. summary: "", //说明
  67. };
  68. // 关闭修改弹窗;
  69. closeUpdatePriQueryTableVisible();
  70. } else {
  71. //业务失败回调
  72. ElMessageBox.alert(msg, "提示", {
  73. confirmButtonText: "关闭",
  74. type: "warning"
  75. });
  76. }
  77. } else {
  78. //表单校验失败回调
  79. ElMessage({
  80. message: "请输入完整信息",
  81. type: "error"
  82. });
  83. }
  84. })
  85. };
  86. //获取查询库数据
  87. const databaseIdOptionList = ref([]);
  88. const databaseIdQuery = async () => {
  89. const { status, data }: any = await http.Request({ method: UrlList.prizeSet.prigetPriDatabaseSetDic.method, url: UrlList.prizeSet.prigetPriDatabaseSetDic.url, params: {} });
  90. if (status === 1) {
  91. databaseIdOptionList.value = data.records;
  92. }
  93. };
  94. // 表单校验规则
  95. const rules = reactive({
  96. tableEnName: [
  97. { required: true, message: '请输入查询表', trigger: 'blur' },
  98. ],
  99. })
  100. // 关闭弹窗回调函数
  101. const closeFn: any = inject('closeEditUpdatePriQueryTableVisible');
  102. const openVisible = async () => {
  103. //通过ID获取表格数据
  104. const { status, data }: any = await http.Request({ method: UrlList.prizeSet.prigetPriQueryTableQuery.method, url: UrlList.prizeSet.prigetPriQueryTableQuery.url, params: { id: props.formData.id } });
  105. if (status === 1) {
  106. UpdateForm.value = data;
  107. }
  108. };
  109. // 关闭弹窗回调函数
  110. const closeUpdatePriQueryTableVisible = () => {
  111. UpdateForm.value = {
  112. id: null, //ID
  113. databaseId: null, //查询数据库
  114. tableEnName: "", //查询表
  115. summary: "", //说明
  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="closeUpdatePriQueryTableVisible" @open="openVisible")
  125. el-form(:model='UpdateForm' label-position="right" ref="ruleFormRef" :rules="rules" label-width="100px")
  126. el-form-item(label='ID' prop="id")
  127. el-input-number(v-model='UpdateForm.id' :min="1" :max="1000"
  128. placeholder="请输入ID")
  129. el-form-item(label="数据库", prop="databaseId")
  130. el-select(
  131. v-model="UpdateForm.databaseId",
  132. placeholder="请选择数据库",
  133. clearable,
  134. )
  135. el-option(:label="item.title", :value="item.id" v-for="(item,index) in databaseIdOptionList")
  136. el-form-item(label='查询表' prop="tableEnName")
  137. el-input(v-model='UpdateForm.tableEnName' autocomplete='off'
  138. placeholder="请输入查询表")
  139. el-form-item(label='说明' prop="summary")
  140. el-input(v-model='UpdateForm.summary' autocomplete='off'
  141. placeholder="请输入说明")
  142. .flex.justify-end
  143. el-button(
  144. :icon="useRenderIcon(Close)",
  145. :loading="loading",
  146. @click="closeUpdatePriQueryTableVisible()"
  147. ) 关闭
  148. el-button(
  149. type="primary",
  150. :icon="useRenderIcon(Upload)",
  151. @click="submit(ruleFormRef)"
  152. ) 确认提交
  153. </template>
  154. <style scoped lang="scss">
  155. :deep(.el-dropdown-menu__item i) {
  156. margin: 0;
  157. }
  158. :deep(.el-form-item__label) {
  159. font-weight: 700;
  160. }
  161. :deep(.el-pagination) {
  162. flex-flow: wrap;
  163. }
  164. :deep(.is-draggable) {
  165. max-height: 80vh;
  166. overflow: auto;
  167. }
  168. :deep(.el-dialog__header) {
  169. position: sticky;
  170. top: 0;
  171. z-index: 2;
  172. background: #fff;
  173. }
  174. .collapsedom {
  175. padding: 0 20px;
  176. background-color: #fff;
  177. }
  178. .ovh-x {
  179. height: 40vh;
  180. overflow-y: auto;
  181. }
  182. :deep(.el-descriptions__header) {
  183. margin: 16px 0 !important;
  184. }
  185. .el-select {
  186. width: 100%;
  187. }
  188. </style>