index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. })
  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. id: null, //ID
  33. fieldName: "", //字段名称
  34. fieldEnName: "", //字段名
  35. fieldQueryKind: "", //匹配条件
  36. fieldQueryModel: "", //匹配方式
  37. fieldQueryValue: "", //匹配值
  38. fieldQueryValueType: "", //匹配值类型
  39. objectTableId: null, //对象表
  40. });
  41. // 匹配条件选项数据
  42. const fieldQueryKindOptionList = [
  43. { id: 1, label: '模糊匹配' },
  44. { id: 2, label: '精确匹配' },
  45. { id: 3, label: '范围匹配' },
  46. ]
  47. // 匹配方式选项数据
  48. const fieldQueryModelOptionList = [
  49. { id: 'request_param', label: '入参' },
  50. { id: 'loop_field', label: '循环递归字段' },
  51. { id: 'fixed_value', label: '固定值' },
  52. ]
  53. // 匹配值类型选项数据
  54. const fieldQueryValueTypeOptionList = [
  55. { id: 'text', label: '文本' },
  56. { id: 'number', label: '数字' },
  57. { id: 'range', label: '范围' },
  58. ]
  59. // 表单实例
  60. const ruleFormRef = ref()
  61. // 选项卡参数(默认值为列表某项的id)
  62. const activeId = ref('1')
  63. // 提交函数
  64. const submit = async (formEl) => {
  65. // 表单校验拦截
  66. if (!formEl) return
  67. await formEl.validate(async (valid, fields) => {
  68. if (valid) {
  69. //表单校验成功回调
  70. console.log('submit!')
  71. // 需动态生成接口
  72. const { status, msg }: any = await http.Request({
  73. method: UrlList.prizeSet.priupdatePriRecursionStartField.method,
  74. url: UrlList.prizeSet.priupdatePriRecursionStartField.url,
  75. params: UpdateForm.value
  76. });
  77. if (status === 1) {
  78. //业务成功回调
  79. ElMessage({
  80. message: "修改成功",
  81. type: "success"
  82. });
  83. UpdateForm.value = {
  84. id: null, //ID
  85. fieldName: "", //字段名称
  86. fieldEnName: "", //字段名
  87. fieldQueryKind: "", //匹配条件
  88. fieldQueryModel: "", //匹配方式
  89. fieldQueryValue: "", //匹配值
  90. fieldQueryValueType: "", //匹配值类型
  91. objectTableId: null, //对象表
  92. };
  93. // 关闭修改弹窗;
  94. closeUpdatePriRecursionStartFieldVisible();
  95. } else {
  96. //业务失败回调
  97. ElMessageBox.alert(msg, "提示", {
  98. confirmButtonText: "关闭",
  99. type: "warning"
  100. });
  101. }
  102. } else {
  103. //表单校验失败回调
  104. ElMessage({
  105. message: "请输入完整信息",
  106. type: "error"
  107. });
  108. }
  109. })
  110. };
  111. // 表单校验规则
  112. const rules = reactive({
  113. })
  114. // 关闭弹窗回调函数
  115. const closeFn: any = inject('closeEditUpdatePriRecursionStartFieldVisible');
  116. const openVisible = async () => {
  117. //通过ID获取表格数据
  118. const { status, data }: any = await http.Request({ method: UrlList.prizeSet.prigetPriRecursionStartFieldQuery.method, url: UrlList.prizeSet.prigetPriRecursionStartFieldQuery.url, params: { id: props.formData.id }});
  119. if (status === 1) {
  120. UpdateForm.value = data;
  121. }
  122. };
  123. // 关闭弹窗回调函数
  124. const closeUpdatePriRecursionStartFieldVisible = () => {
  125. UpdateForm.value = {
  126. id: null, //ID
  127. fieldName: "", //字段名称
  128. fieldEnName: "", //字段名
  129. fieldQueryKind: "", //匹配条件
  130. fieldQueryModel: "", //匹配方式
  131. fieldQueryValue: "", //匹配值
  132. fieldQueryValueType: "", //匹配值类型
  133. objectTableId: null, //对象表
  134. };
  135. closeFn();
  136. };
  137. // 弹窗是否全屏
  138. const isFullscreen = ref(false)
  139. </script>
  140. <template lang="pug">
  141. .main
  142. el-dialog(v-model='props.editVisible' draggable width="50%" :fullscreen="isFullscreen" title="修改" @close="closeUpdatePriRecursionStartFieldVisible" @open="openVisible")
  143. el-form(:model='UpdateForm' label-position="right" ref="ruleFormRef" :rules="rules" label-width="100px")
  144. el-form-item(label='ID' prop="id")
  145. el-input-number(v-model='UpdateForm.id' :min="1" :max="1000"
  146. placeholder="请输入ID")
  147. el-form-item(label='字段名称' prop="fieldName")
  148. el-input(v-model='UpdateForm.fieldName' autocomplete='off'
  149. placeholder="请输入字段名称")
  150. el-form-item(label='字段名' prop="fieldEnName")
  151. el-input(v-model='UpdateForm.fieldEnName' autocomplete='off'
  152. placeholder="请输入字段名")
  153. el-form-item(label="匹配条件", prop="fieldQueryKind")
  154. el-select(
  155. v-model="UpdateForm.fieldQueryKind",
  156. placeholder="请选择匹配条件",
  157. clearable,
  158. )
  159. el-option(:label="item.label", :value="item.id" v-for="(item,index) in fieldQueryKindOptionList")
  160. el-form-item(label="匹配方式", prop="fieldQueryModel")
  161. el-select(
  162. v-model="UpdateForm.fieldQueryModel",
  163. placeholder="请选择匹配方式",
  164. clearable,
  165. )
  166. el-option(:label="item.label", :value="item.id" v-for="(item,index) in fieldQueryModelOptionList")
  167. el-form-item(label='匹配值' prop="fieldQueryValue")
  168. el-input(v-model='UpdateForm.fieldQueryValue' autocomplete='off'
  169. placeholder="请输入匹配值")
  170. el-form-item(label="匹配值类型", prop="fieldQueryValueType")
  171. el-select(
  172. v-model="UpdateForm.fieldQueryValueType",
  173. placeholder="请选择匹配值类型",
  174. clearable,
  175. )
  176. el-option(:label="item.label", :value="item.id" v-for="(item,index) in fieldQueryValueTypeOptionList")
  177. el-form-item(label='对象表' prop="objectTableId")
  178. el-input-number(v-model='UpdateForm.objectTableId' :min="1" :max="1000"
  179. placeholder="请输入对象表")
  180. .flex.justify-end
  181. el-button(
  182. :icon="useRenderIcon(Close)",
  183. :loading="loading",
  184. @click="closeUpdatePriRecursionStartFieldVisible()"
  185. ) 关闭
  186. el-button(
  187. type="primary",
  188. :icon="useRenderIcon(Upload)",
  189. @click="submit(ruleFormRef)"
  190. ) 确认提交
  191. </template>
  192. <style scoped lang="scss">
  193. :deep(.el-dropdown-menu__item i) {
  194. margin: 0;
  195. }
  196. :deep(.el-form-item__label) {
  197. font-weight: 700;
  198. }
  199. :deep(.el-pagination) {
  200. flex-flow: wrap;
  201. }
  202. :deep(.is-draggable) {
  203. max-height: 80vh;
  204. overflow: auto;
  205. }
  206. :deep(.el-dialog__header) {
  207. position: sticky;
  208. top: 0;
  209. z-index: 2;
  210. background: #fff;
  211. }
  212. .collapsedom {
  213. padding: 0 20px;
  214. background-color: #fff;
  215. }
  216. .ovh-x {
  217. height: 40vh;
  218. overflow-y: auto;
  219. }
  220. :deep(.el-descriptions__header) {
  221. margin: 16px 0 !important;
  222. }
  223. .el-select {
  224. width: 100%;
  225. }
  226. </style>