5b71fffbc6382733f8a156d2c103d94da3d76a4c.svn-base 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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" />
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="图例展示名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="legendname">
  13. <a-input v-model="model.legendname" 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="legendimg">
  18. <j-image-upload isMultiple v-model="model.legendimg" ></j-image-upload>
  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: 'LayercategoriesForm',
  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. },
  56. url: {
  57. add: "/resManager.categories/layercategories/add",
  58. edit: "/resManager.categories/layercategories/edit",
  59. queryById: "/resManager.categories/layercategories/queryById"
  60. }
  61. }
  62. },
  63. computed: {
  64. formDisabled(){
  65. return this.disabled
  66. },
  67. },
  68. created () {
  69. //备份model原始值
  70. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  71. },
  72. methods: {
  73. add () {
  74. this.edit(this.modelDefault);
  75. },
  76. edit (record) {
  77. this.model = Object.assign({}, record);
  78. this.visible = true;
  79. },
  80. submitForm () {
  81. const that = this;
  82. // 触发表单验证
  83. this.$refs.form.validate(valid => {
  84. if (valid) {
  85. that.confirmLoading = true;
  86. let httpurl = '';
  87. let method = '';
  88. if(!this.model.id){
  89. httpurl+=this.url.add;
  90. method = 'post';
  91. }else{
  92. httpurl+=this.url.edit;
  93. method = 'post';
  94. }
  95. httpAction(httpurl,this.model,method).then((res)=>{
  96. if(res.success){
  97. that.$message.success(res.message);
  98. that.$emit('ok');
  99. }else{
  100. that.$message.warning(res.message);
  101. }
  102. }).finally(() => {
  103. that.confirmLoading = false;
  104. })
  105. }
  106. })
  107. },
  108. }
  109. }
  110. </script>