4d7e9fedb72d923eb2669a7a79ab0d1c7ef4d8f8.svn-base 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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="layername">
  8. <j-search-select-tag v-model="model.layername" dict="rescatalog,alias,name,has_child='0'" />
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="字段名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
  13. <a-input v-model="model.name" 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="alias">
  18. <a-input v-model="model.alias" placeholder="请输入字段展示名" ></a-input>
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :span="24">
  22. <a-form-model-item label="展示顺序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xh">
  23. <a-input-number v-model="model.xh" placeholder="请输入展示顺序" style="width: 100%" />
  24. </a-form-model-item>
  25. </a-col>
  26. </a-row>
  27. </a-form-model>
  28. </j-form-container>
  29. </a-spin>
  30. </template>
  31. <script>
  32. import { httpAction, getAction } from '@/api/manage'
  33. import { validateDuplicateValue } from '@/utils/util'
  34. export default {
  35. name: 'LayerfieldsForm',
  36. components: {
  37. },
  38. props: {
  39. //表单禁用
  40. disabled: {
  41. type: Boolean,
  42. default: false,
  43. required: false
  44. }
  45. },
  46. data () {
  47. return {
  48. model:{
  49. },
  50. labelCol: {
  51. xs: { span: 24 },
  52. sm: { span: 5 },
  53. },
  54. wrapperCol: {
  55. xs: { span: 24 },
  56. sm: { span: 16 },
  57. },
  58. confirmLoading: false,
  59. validatorRules: {
  60. },
  61. url: {
  62. add: "/resManager.fields/layerfields/add",
  63. edit: "/resManager.fields/layerfields/edit",
  64. queryById: "/resManager.fields/layerfields/queryById"
  65. }
  66. }
  67. },
  68. computed: {
  69. formDisabled(){
  70. return this.disabled
  71. },
  72. },
  73. created () {
  74. //备份model原始值
  75. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  76. },
  77. methods: {
  78. add () {
  79. this.edit(this.modelDefault);
  80. },
  81. edit (record) {
  82. this.model = Object.assign({}, record);
  83. this.visible = true;
  84. },
  85. submitForm () {
  86. const that = this;
  87. // 触发表单验证
  88. this.$refs.form.validate(valid => {
  89. if (valid) {
  90. that.confirmLoading = true;
  91. let httpurl = '';
  92. let method = '';
  93. if(!this.model.id){
  94. httpurl+=this.url.add;
  95. method = 'post';
  96. }else{
  97. httpurl+=this.url.edit;
  98. method = 'post';
  99. }
  100. httpAction(httpurl,this.model,method).then((res)=>{
  101. if(res.success){
  102. that.$message.success(res.message);
  103. that.$emit('ok');
  104. }else{
  105. that.$message.warning(res.message);
  106. }
  107. }).finally(() => {
  108. that.confirmLoading = false;
  109. })
  110. }
  111. })
  112. },
  113. }
  114. }
  115. </script>