index.vue 7.2 KB

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