123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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-input
  10. placeholder="请输入标题"
  11. v-model="postData.InfoName"
  12. clearable>
  13. </el-input>
  14. </div>
  15. </div>
  16. </li>
  17. <li class="flex-h">
  18. <span>跳转链接:</span>
  19. <div class="flex-item">
  20. <div style="width:50%">
  21. <el-input
  22. placeholder="请输入链接"
  23. v-model="postData.InfoUrl"
  24. clearable>
  25. </el-input>
  26. </div>
  27. </div>
  28. </li>
  29. <li class="flex-h">
  30. <span>对应案场:</span>
  31. <div class="flex-item">
  32. <div style="width:50%">
  33. <el-select v-model="postData.CaseId" placeholder="请选择">
  34. <el-option
  35. v-for="item in caseList"
  36. :key="item.CaseId"
  37. :label="item.CaseName"
  38. :value="item.CaseId">
  39. </el-option>
  40. </el-select>
  41. </div>
  42. </div>
  43. </li>
  44. <!-- <li class="flex-h">
  45. <span>位置:</span>
  46. <div class="flex-item">
  47. <div style="width:50%">
  48. <el-select v-model="postData.LocationId" placeholder="请选择">
  49. <el-option
  50. v-for="item in positionList"
  51. :key="item.LocationId"
  52. :label="item.LocationName"
  53. :value="item.LocationId">
  54. </el-option>
  55. </el-select>
  56. </div>
  57. </div>
  58. </li> -->
  59. <li style="text-align:center">
  60. <el-button type="primary" size="mini" @click="submit">保存</el-button>
  61. <el-button type="danger" size="mini" @click="cancel">取消</el-button>
  62. </li>
  63. </ul>
  64. </form>
  65. </div>
  66. </template>
  67. <script>
  68. import { mapState, createNamespacedHelpers, mapActions } from 'vuex'
  69. const { mapActions: mapCmsActions } = createNamespacedHelpers('cms')
  70. export default {
  71. name: '',
  72. data () {
  73. return {
  74. postData: {
  75. InfoName: '',
  76. InfoUrl: '',
  77. OrgId: '',
  78. CaseId: '',
  79. LocationId: 'index'
  80. }
  81. }
  82. },
  83. components: {},
  84. created () {
  85. this.updateLocationInfo()
  86. this.updateSystemInfo().then(() => {
  87. this.postData.CaseId = this.defaultCaseId
  88. })
  89. },
  90. computed: {
  91. ...mapState({
  92. // positionList: x => x.cms.location,
  93. OrgId: x => x.app.user.OrgId,
  94. defaultCaseId: x => x.app.cases.default,
  95. caseList: x => x.app.cases.list
  96. })
  97. },
  98. methods: {
  99. ...mapCmsActions(['updateLocationInfo']),
  100. ...mapActions(['updateSystemInfo']),
  101. submit () {
  102. var reg = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/ // eslint-disable-line
  103. if (!reg.test(this.postData.InfoUrl)) {
  104. this.$message({
  105. message: '链接地址格式不正确',
  106. type: 'error',
  107. })
  108. return false
  109. }
  110. this.postData.OrgId = this.OrgId
  111. this.$ajax(this.$api.cms.addInfo.url, {
  112. method: this.$api.cms.addInfo.method,
  113. data: this.postData
  114. }).then(res => {
  115. this.$message({
  116. message: '添加成功',
  117. type: 'success',
  118. duration: 1000
  119. })
  120. setTimeout(() => {
  121. this.$router.push({ name: 'indexMsg' })
  122. }, 1000)
  123. }).catch(msg => {
  124. })
  125. },
  126. cancel () {
  127. this.$router.go(-1)
  128. }
  129. }
  130. }
  131. </script>
  132. <!-- Add "scoped" attribute to limit CSS to this component only -->
  133. <style lang="scss" scoped>
  134. </style>