CheckAndEditModel.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <j-modal
  3. :title="title"
  4. :width="700"
  5. :visible="visible"
  6. :mask-closable="false"
  7. cancel-text="关闭"
  8. @close="close"
  9. >
  10. <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :rules="validatorRules" :model="model">
  11. <a-form-model-item label="支柱号" prop="zzh">
  12. <a-input v-model="model.zzh" />
  13. </a-form-model-item>
  14. <a-form-model-item label="所属部门" prop="bm">
  15. </a-form-model-item>
  16. <a-form-model-item label="线别" prop="xb">
  17. <j-dict-select-tag
  18. v-model="model.xb"
  19. dict-code="word_type"
  20. />
  21. </a-form-model-item>
  22. <a-form-model-item label="站场区间" prop="qj">
  23. <j-dict-select-tag
  24. v-model="model.qj"
  25. dict-code="word_type"
  26. />
  27. </a-form-model-item>
  28. <a-form-model-item label="行别" prop="hb">
  29. <j-dict-select-tag
  30. type="radioButton"
  31. v-model="model.hb"
  32. dict-code="word_type"
  33. />
  34. </a-form-model-item>
  35. <a-form-model-item label="公里标" prop="glb">
  36. <a-input v-model="model.glb" />
  37. </a-form-model-item>
  38. <a-form-model-item label="支柱类型" prop="zzlx">
  39. <j-dict-select-tag
  40. v-model="model.zzlx"
  41. dict-code="word_type"
  42. />
  43. </a-form-model-item>
  44. <a-form-model-item label="支柱型号" prop="zzxh">
  45. <j-dict-select-tag
  46. v-model="model.zzxh"
  47. dict-code="word_type"
  48. />
  49. </a-form-model-item>
  50. <a-form-model-item label="支柱用途" prop="zzyt">
  51. <j-dict-select-tag
  52. v-model="model.zzyt"
  53. dict-code="word_type"
  54. />
  55. </a-form-model-item>
  56. <a-form-model-item label="材质" prop="cz">
  57. <j-dict-select-tag
  58. v-model="model.cz"
  59. dict-code="word_type"
  60. />
  61. </a-form-model-item>
  62. <a-form-model-item label="直线/曲外/曲内" prop="zxqwqn">
  63. <j-dict-select-tag
  64. type="radioButton"
  65. v-model="model.zxqwqn"
  66. dict-code="word_type"
  67. />
  68. </a-form-model-item>
  69. </a-form-model>
  70. </j-modal>
  71. </template>
  72. <script>
  73. import { httpAction } from '@/api/request'
  74. import JModal from '@/components/JModal'
  75. export default {
  76. name: 'CheckAndEditModel',
  77. components: {
  78. JModal
  79. },
  80. data() {
  81. return {
  82. labelCol: { span: 4 },
  83. wrapperCol: { span: 19 },
  84. dataSource: [],
  85. title: '',
  86. visible: false,
  87. isCheck: false,
  88. model: {},
  89. validatorRules: {
  90. name: [{ required: true, message: '请输入' }],
  91. type: [{ required: true, message: '请选择' }]
  92. },
  93. url: {
  94. add: '/business/catenary/bus/zzdzxx/add',
  95. edit: '/business/catenary/bus/zzdzxx/update'
  96. }
  97. }
  98. },
  99. created() {
  100. },
  101. methods: {
  102. add() {
  103. this.model = {}
  104. this.visible = true
  105. },
  106. edit(record) {
  107. debugger
  108. this.model = Object.assign({}, record)
  109. this.visible = true
  110. },
  111. close(isSubmit) {
  112. if (isSubmit) {
  113. this.checkData()
  114. } else {
  115. this.visible = false
  116. }
  117. },
  118. checkData() {
  119. this.$refs.form.validate(valid => {
  120. if (valid) {
  121. this.saveData()
  122. } else {
  123. return false
  124. }
  125. })
  126. },
  127. saveData() {
  128. let url, type
  129. if (!this.model.id) {
  130. url = this.url.add
  131. type = 'post'
  132. } else {
  133. debugger
  134. url = this.url.edit
  135. type = 'put'
  136. }
  137. httpAction(url, this.model, type).then((res) => {
  138. if (res.code === 200) {
  139. this.$message.success(res.msg)
  140. this.$emit('ok')
  141. this.visible = false
  142. } else {
  143. console.log(res)
  144. }
  145. })
  146. }
  147. }
  148. }
  149. </script>