index.vue 6.6 KB

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