cda1262b76a1c5ce2fc5c61dffc88bd422a7fe48.svn-base 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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="name">
  8. <a-input v-model="model.name" placeholder="请输入名称"></a-input>
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="IP地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ip">
  13. <a-input v-model="model.ip" placeholder="请输入IP地址"></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="port">
  18. <a-input v-model="model.port" 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="username">
  23. <a-input v-model="model.username" placeholder="请输入用户名"></a-input>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :span="24">
  27. <a-form-model-item label="密码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="password">
  28. <a-input v-model="model.password" placeholder="请输入密码"></a-input>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :span="24">
  32. <a-form-model-item label="经度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lng">
  33. <a-input-number v-model="model.lng" placeholder="请输入经度" style="width: 100%" @blur="coordsChange"/>
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :span="24">
  37. <a-form-model-item label="纬度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lat">
  38. <a-input-number v-model="model.lat" placeholder="请输入纬度" style="width: 100%" @blur="coordsChange"/>
  39. </a-form-model-item>
  40. </a-col>
  41. </a-row>
  42. </a-form-model>
  43. </j-form-container>
  44. </a-spin>
  45. </template>
  46. <script>
  47. import {httpAction, getAction} from '@/api/manage'
  48. import {validateDuplicateValue} from '@/utils/util'
  49. export default {
  50. name: 'RmVideogeoForm',
  51. components: {},
  52. props: {
  53. //表单禁用
  54. disabled: {
  55. type: Boolean,
  56. default: false,
  57. required: false
  58. }
  59. },
  60. data() {
  61. return {
  62. model: {},
  63. labelCol: {
  64. xs: {span: 24},
  65. sm: {span: 5},
  66. },
  67. wrapperCol: {
  68. xs: {span: 24},
  69. sm: {span: 16},
  70. },
  71. confirmLoading: false,
  72. validatorRules: {},
  73. url: {
  74. add: "/hzz.video/rmVideogeo/add",
  75. edit: "/hzz.video/rmVideogeo/edit",
  76. queryById: "/hzz.video/rmVideogeo/queryById"
  77. }
  78. }
  79. },
  80. computed: {
  81. formDisabled() {
  82. return this.disabled
  83. },
  84. },
  85. created() {
  86. //备份model原始值
  87. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  88. },
  89. methods: {
  90. add() {
  91. this.edit(this.modelDefault);
  92. },
  93. edit(record) {
  94. this.model = Object.assign({}, record);
  95. this.visible = true;
  96. },
  97. submitForm() {
  98. const that = this;
  99. // 触发表单验证
  100. this.$refs.form.validate(valid => {
  101. if (valid) {
  102. that.confirmLoading = true;
  103. let httpurl = '';
  104. let method = '';
  105. if (!this.model.id) {
  106. httpurl += this.url.add;
  107. method = 'post';
  108. } else {
  109. httpurl += this.url.edit;
  110. //method = 'put';
  111. method = 'post';
  112. }
  113. httpAction(httpurl, this.model, method).then((res) => {
  114. if (res.success) {
  115. that.$message.success(res.message);
  116. that.$emit('ok');
  117. } else {
  118. that.$message.warning(res.message);
  119. }
  120. }).finally(() => {
  121. that.confirmLoading = false;
  122. })
  123. }
  124. })
  125. },
  126. coordsChange() {
  127. this.$emit("coordsChange", this.model.lng, this.model.lat);
  128. }
  129. }
  130. }
  131. </script>