DialogForm.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <el-dialog
  3. v-if="visible"
  4. :title="form.id?'编辑文旅岗位目录':'新建文旅岗位目录'"
  5. :visible.sync="visible"
  6. width="600px"
  7. >
  8. <el-form v-loading="isLoading" :model="form" label-width="100px" label-position="top">
  9. <el-row :gutter="16">
  10. <el-col :span="12">
  11. <el-form-item label="职业名称">
  12. <el-input v-model="form.name" />
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="12">
  16. <el-form-item label="排序">
  17. <el-input-number v-model="form.sortNumber" :min="0" />
  18. </el-form-item>
  19. </el-col>
  20. </el-row>
  21. <el-form-item label="备注说明">
  22. <el-input v-model="form.remark" type="textarea" rows="5" />
  23. </el-form-item>
  24. </el-form>
  25. <div slot="footer" class="dialog-footer">
  26. <el-button @click="visible = false">取 消</el-button>
  27. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  28. </div>
  29. </el-dialog>
  30. </template>
  31. <style type="text/css">
  32. .image {
  33. width: 100%;
  34. height: 100%;
  35. border-radius: 6px;
  36. }
  37. </style>
  38. <script>
  39. import { save, updateById } from '@/api/category/occupation'
  40. export default {
  41. data() {
  42. return {
  43. visible: false,
  44. isLoading: false,
  45. form: {},
  46. businessLicense: null,
  47. legalPersonIdCardA: null,
  48. legalPersonIdCardB: null,
  49. lng: null,
  50. lat: null
  51. }
  52. },
  53. mounted() {
  54. },
  55. methods: {
  56. open(data) {
  57. this.visible = true
  58. this.isLoading = false
  59. this.form = {}
  60. console.log(data)
  61. if (data && data.id) {
  62. this.lat = data.lat
  63. this.lng = data.lng
  64. this.businessLicense = data.businessLicense
  65. this.legalPersonIdCardB = data.legalPersonIdCardB
  66. this.legalPersonIdCardA = data.legalPersonIdCardA
  67. }
  68. this.form = Object.assign({}, data)
  69. },
  70. mapClick(e) {
  71. console.log(e)
  72. this.lng = e.latLng.lng
  73. this.lat = e.latLng.lat
  74. },
  75. handleSubmit() {
  76. this.isLoading = true
  77. const param = {
  78. ...this.form,
  79. 'lng': this.lng,
  80. 'lat': this.lat,
  81. 'businessLicense': this.businessLicense,
  82. 'legalPersonIdCardB': this.legalPersonIdCardB,
  83. 'legalPersonIdCardA': this.legalPersonIdCardA
  84. }
  85. console.log(param)
  86. if (this.form.id) {
  87. updateById(this.form.id, param).then(() => {
  88. this.visible = false
  89. this.$emit('ok')
  90. }).finally(() => {
  91. this.isLoading = false
  92. })
  93. } else {
  94. save(param).then(res => {
  95. this.visible = false
  96. this.$emit('ok')
  97. }).finally(() => {
  98. this.isLoading = false
  99. })
  100. }
  101. }
  102. }
  103. }
  104. </script>