fadb7916ab4f6a7b92c2b1843e98a3bf9352dd10.svn-base 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <a-row>
  6. <a-col :span="24">
  7. <a-form-model-item label="查询名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="queryName">
  8. <a-input v-model="model.queryName" placeholder="请输入查询名称" ></a-input>
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="查询接口地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="queryPort">
  13. <a-input v-model="model.queryPort" placeholder="请输入查询接口地址" ></a-input>
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="24">
  17. <a-form-model-item label="显示顺序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="displayorder">
  18. <a-input-number v-model="model.displayorder" placeholder="请输入显示顺序" style="width: 100%" />
  19. </a-form-model-item>
  20. </a-col>
  21. </a-row>
  22. </a-form-model>
  23. </j-form-container>
  24. </a-spin>
  25. </template>
  26. <script>
  27. import { httpAction, getAction } from '@/api/manage'
  28. import { validateDuplicateValue } from '@/utils/util'
  29. export default {
  30. name: 'QuerymanageForm',
  31. components: {
  32. },
  33. props: {
  34. //表单禁用
  35. disabled: {
  36. type: Boolean,
  37. default: false,
  38. required: false
  39. }
  40. },
  41. data () {
  42. return {
  43. model:{
  44. },
  45. labelCol: {
  46. xs: { span: 24 },
  47. sm: { span: 5 },
  48. },
  49. wrapperCol: {
  50. xs: { span: 24 },
  51. sm: { span: 16 },
  52. },
  53. confirmLoading: false,
  54. validatorRules: {
  55. queryName: [
  56. { required: true, message: '请输入查询名称!'},
  57. ],
  58. queryPort: [
  59. { required: true, message: '请输入查询接口地址!'},
  60. ],
  61. displayorder: [
  62. { required: true, message: '请输入显示顺序!'},
  63. { pattern: /^-?\d+$/, message: '请输入整数!'},
  64. ],
  65. },
  66. url: {
  67. add: "/querymanage/querymanage/add",
  68. edit: "/querymanage/querymanage/edit",
  69. queryById: "/querymanage/querymanage/queryById"
  70. }
  71. }
  72. },
  73. computed: {
  74. formDisabled(){
  75. return this.disabled
  76. },
  77. },
  78. created () {
  79. //备份model原始值
  80. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  81. },
  82. methods: {
  83. add () {
  84. this.edit(this.modelDefault);
  85. },
  86. edit (record) {
  87. this.model = Object.assign({}, record);
  88. this.visible = true;
  89. },
  90. submitForm () {
  91. const that = this;
  92. // 触发表单验证
  93. this.$refs.form.validate(valid => {
  94. if (valid) {
  95. that.confirmLoading = true;
  96. let httpurl = '';
  97. let method = '';
  98. if(!this.model.id){
  99. httpurl+=this.url.add;
  100. method = 'post';
  101. }else{
  102. httpurl+=this.url.edit;
  103. method = 'post';
  104. }
  105. httpAction(httpurl,this.model,method).then((res)=>{
  106. if(res.success){
  107. that.$message.success(res.message);
  108. that.$emit('ok');
  109. }else{
  110. that.$message.warning(res.message);
  111. }
  112. }).finally(() => {
  113. that.confirmLoading = false;
  114. })
  115. }
  116. })
  117. },
  118. }
  119. }
  120. </script>