edit.vue 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div class="subPage">
  3. <form class="mainForm">
  4. <ul>
  5. <li class="flex-h">
  6. <span>选择案场:</span>
  7. <div class="flex-item">
  8. <div style="width:50%">
  9. <el-select v-model="CaseId" placeholder="请选择">
  10. <el-option
  11. v-for="item in cases"
  12. :key="item.CaseId"
  13. :label="item.CaseName"
  14. :value="item.CaseId">
  15. </el-option>
  16. </el-select>
  17. </div>
  18. </div>
  19. </li>
  20. <li class="flex-h">
  21. <span>渠道名:</span>
  22. <div class="flex-item">
  23. <div style="width:50%">
  24. <el-input
  25. placeholder="请输入渠道名"
  26. v-model="postData.ChannelName"
  27. clearable>
  28. </el-input>
  29. </div>
  30. </div>
  31. </li>
  32. <li style="text-align:center">
  33. <el-button type="primary" size="mini" @click="submit">保存</el-button>
  34. <el-button type="danger" size="mini" @click="cancel">取消</el-button>
  35. </li>
  36. </ul>
  37. </form>
  38. </div>
  39. </template>
  40. <script>
  41. import { mapState } from 'vuex'
  42. export default {
  43. name: '',
  44. data () {
  45. return {
  46. postData: {
  47. ChannelId: '', // 渠道id
  48. ChannelName: '', // 渠道名称
  49. CaseId: '', // 案场id
  50. OrgId: '', // 机构id
  51. }
  52. }
  53. },
  54. computed: {
  55. ...mapState({
  56. cases: x => x.app.cases.list,
  57. defaultCaseId: x => x.app.cases.default,
  58. OrgId: x => x.app.user.OrgId,
  59. }),
  60. CaseId: {
  61. get () {
  62. return this.postData.CaseId === '' ? this.defaultCaseId || '' : this.postData.CaseId
  63. },
  64. set (val) {
  65. this.postData.CaseId = val
  66. }
  67. }
  68. },
  69. created () {
  70. this.getChannelInfo()
  71. },
  72. components: {},
  73. methods: {
  74. getChannelInfo () {
  75. this.$ajax(this.$api.channelManager.getChannelInfo.url, {
  76. method: this.$api.channelManager.getChannelInfo.method,
  77. urlData: { channelId: this.$route.query.id }
  78. }).then(res => {
  79. this.postData = res
  80. })
  81. },
  82. submit () { // 提交数据
  83. if (this.postData.ChannelName === '') {
  84. this.$message({
  85. type: 'error',
  86. message: '渠道名称不能为空'
  87. })
  88. return false
  89. }
  90. this.postData.OrgId = this.OrgId
  91. if (this.postData.CaseId === '') this.postData.CaseId = this.CaseId
  92. this.$ajax(this.$api.channelManager.editChannel.url, {
  93. method: this.$api.channelManager.editChannel.method,
  94. data: this.postData
  95. }).then(res => {
  96. this.$message({
  97. type: 'success',
  98. message: '操作成功'
  99. })
  100. this.$router.push({ name: 'channelList' })
  101. })
  102. },
  103. cancel () {
  104. this.$router.push({ name: 'channelList' })
  105. }
  106. },
  107. mounted () { }
  108. }
  109. </script>
  110. <!-- Add "scoped" attribute to limit CSS to this component only -->
  111. <style lang="scss" scoped>
  112. </style>