index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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(["kxsSys"]);
  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. status: "", //状态 0未开始 1进行中 2已结束
  33. });
  34. // 状态 0未开始 1进行中 2已结束选项数据
  35. const statusOptionList = [
  36. ]
  37. // 表单实例
  38. const ruleFormRef = ref()
  39. // 选项卡参数(默认值为列表某项的id)
  40. const activeId = ref('1')
  41. // 提交函数
  42. const submit = async (formEl) => {
  43. // 表单校验拦截
  44. if (!formEl) return
  45. await formEl.validate(async (valid, fields) => {
  46. if (valid) {
  47. //表单校验成功回调
  48. console.log('submit!')
  49. // 需动态生成接口
  50. const { status, msg }: any = await http.Request({
  51. method: UrlList.kxsSys.sysCampchangeStatus.method,
  52. url: UrlList.kxsSys.sysCampchangeStatus.url,
  53. params: UpdateForm.value
  54. });
  55. if (status === 1) {
  56. //业务成功回调
  57. ElMessage({
  58. message: "修改成功",
  59. type: "success"
  60. });
  61. UpdateForm.value = {
  62. status: "", //状态 0未开始 1进行中 2已结束
  63. };
  64. // 关闭修改弹窗;
  65. closeChangeStatusVisible();
  66. } else {
  67. //业务失败回调
  68. ElMessageBox.alert(msg, "提示", {
  69. confirmButtonText: "关闭",
  70. type: "warning"
  71. });
  72. }
  73. } else {
  74. //表单校验失败回调
  75. ElMessage({
  76. message: "请输入完整信息",
  77. type: "error"
  78. });
  79. }
  80. })
  81. };
  82. // 表单校验规则
  83. const rules = reactive({
  84. })
  85. // 关闭弹窗回调函数
  86. const closeFn: any = inject('closeEditChangeStatusVisible');
  87. const openVisible = async () => {
  88. //通过ID获取表格数据
  89. const { status, data }: any = await http.Request({ method: UrlList.kxsSys.sysCamp.method, url: UrlList.kxsSys.sysCamp.url, params: { id: props.formData.id } });
  90. if (status === 1) {
  91. UpdateForm.value = data;
  92. }
  93. };
  94. // 关闭弹窗回调函数
  95. const closeChangeStatusVisible = () => {
  96. UpdateForm.value = {
  97. status: "", //状态 0未开始 1进行中 2已结束
  98. };
  99. closeFn();
  100. };
  101. </script>
  102. <template lang="pug">
  103. .main
  104. el-dialog(v-model='props.editVisible' width="50%" title="修改" @close="closeChangeStatusVisible()" @open="openVisible")
  105. el-form(:model='UpdateForm' label-position="right" ref="ruleFormRef" :rules="rules" label-width="100px")
  106. el-form-item(label="状态 0未开始 1进行中 2已结束", prop="status")
  107. el-select(
  108. v-model="UpdateForm.status",
  109. placeholder="请选择状态 0未开始 1进行中 2已结束",
  110. clearable,
  111. class="!w-[230px]"
  112. )
  113. el-option(:label="item.label", :value="item.id" v-for="(item,index) in statusOptionList")
  114. el-button(
  115. :icon="useRenderIcon(Close)",
  116. :loading="loading",
  117. @click="closeChangeStatusVisible()"
  118. ) 关闭
  119. el-button(
  120. type="primary",
  121. :icon="useRenderIcon(Upload)",
  122. @click="submit(ruleFormRef)"
  123. ) 确认提交
  124. </template>
  125. <style scoped lang="scss">
  126. :deep(.el-dropdown-menu__item i) {
  127. margin: 0;
  128. }
  129. :deep(.el-form-item__label) {
  130. font-weight: 700;
  131. }
  132. :deep(.el-pagination) {
  133. flex-flow: wrap;
  134. }
  135. :deep(.is-draggable) {
  136. max-height: 80vh;
  137. overflow: auto;
  138. }
  139. :deep(.el-dialog__header) {
  140. position: sticky;
  141. top: 0;
  142. z-index: 2;
  143. background: #fff;
  144. }
  145. .collapsedom {
  146. padding: 0 20px;
  147. background-color: #fff;
  148. }
  149. .ovh-x {
  150. height: 40vh;
  151. overflow-y: auto;
  152. }
  153. :deep(.el-descriptions__header) {
  154. margin: 16px 0 !important;
  155. }
  156. </style>