index.vue 7.5 KB

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