index.vue 6.6 KB

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