index.vue 7.7 KB

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