ArticleDetail.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="createPost-container">
  3. <el-form ref="postForm" :label-position="labelPosition" :model="postForm" :rules="rules" class="form-container" label-width="200px">
  4. <div class="createPost-main-container">
  5. <el-form-item prop="old_partner" label="老店合同人姓名">
  6. <el-input v-model="postForm.old_partner" placeholder="" style="width: 300px;" />
  7. </el-form-item>
  8. <el-form-item prop="mobile" label="手机号">
  9. <el-input v-model="postForm.mobile" placeholder="" style="width: 300px;" />
  10. </el-form-item>
  11. <el-form-item prop="old_store_name" label="老店店名">
  12. <el-input v-model="postForm.old_store_name" placeholder="" style="width: 300px;" />
  13. </el-form-item>
  14. <el-form-item prop="store_name" label="店号">
  15. <el-input v-model="postForm.store_name" placeholder="" style="width: 300px;" />
  16. </el-form-item>
  17. <el-form-item prop="store_num" label="申请第几家店">
  18. <el-input v-model="postForm.store_num" placeholder="" style="width: 600px;" />
  19. </el-form-item>
  20. <el-form-item prop="address" label="意向开店位置">
  21. <el-input v-model="postForm.address" placeholder="" style="width: 300px;" />
  22. </el-form-item>
  23. <el-form-item prop="staff_num" label="分店有几位员工">
  24. <el-input v-model="postForm.staff_num" placeholder="" style="width: 300px;" />
  25. </el-form-item>
  26. <el-form-item prop="manager" label="分店管理者">
  27. <el-input v-model="postForm.manager" placeholder="" style="width: 300px;" />
  28. </el-form-item>
  29. <el-form-item prop="old_order_rate" label="老店小程序点单占比">
  30. <el-input v-model="postForm.old_order_rate" placeholder="" style="width: 300px;" />
  31. </el-form-item>
  32. <el-form-item prop="old_profit" label="老店月净利润">
  33. <el-input v-model="postForm.old_profit" placeholder="" style="width: 300px;" />
  34. </el-form-item>
  35. <el-form-item prop="old_take_out" label="老店外卖评分">
  36. <el-input v-model="postForm.old_take_out" placeholder="" style="width: 300px;" />
  37. </el-form-item>
  38. <el-row>
  39. <el-button v-if="!isEdit" v-loading="loading" type="success" @click="submitForm">
  40. 查看
  41. </el-button>
  42. <el-button v-if="isEdit" v-loading="loading" type="success" @click="updateArticle">
  43. 返回
  44. </el-button>
  45. </el-row>
  46. </div>
  47. </el-form>
  48. </div>
  49. </template>
  50. <script>
  51. // import Upload from '@/components/Upload/SingleImage3'
  52. // import Sticky from '@/components/Sticky' // 粘性header组件
  53. // import { validURL } from '@/utils/validate'
  54. import { fetchBranchJoin } from '@/api/branchJoin'
  55. // import Warning from './Warning'
  56. // import { CommentDropdown, PlatformDropdown, SourceUrlDropdown } from './Dropdown'
  57. const defaultForm = {
  58. // status: 'draft',
  59. redirect: '', // 文章题目
  60. status: true, // 文章内容
  61. position: 1, // 文章摘要
  62. url: '', // 文章外链
  63. cover_img: '', // 文章图片
  64. display_time: undefined, // 前台展示时间
  65. id: undefined,
  66. platforms: ['a-platform'],
  67. comment_disabled: false,
  68. importance: 0
  69. }
  70. export default {
  71. name: 'ArticleDetail',
  72. components: { },
  73. props: {
  74. isEdit: {
  75. type: Boolean,
  76. default: false
  77. }
  78. },
  79. data() {
  80. return {
  81. postForm: Object.assign({}, defaultForm),
  82. loading: false,
  83. userListOptions: [],
  84. rules: {
  85. },
  86. tempRoute: {},
  87. labelPosition: 'left'
  88. }
  89. },
  90. computed: {
  91. },
  92. created() {
  93. if (this.isEdit) {
  94. const id = this.$route.params && this.$route.params.id
  95. this.fetchData(id)
  96. }
  97. // Why need to make a copy of this.$route here?
  98. // Because if you enter this page and quickly switch tag, may be in the execution of the setTagsViewTitle function, this.$route is no longer pointing to the current page
  99. // https://github.com/PanJiaChen/vue-element-admin/issues/1221
  100. this.tempRoute = Object.assign({}, this.$route)
  101. },
  102. methods: {
  103. fetchData(id) {
  104. fetchBranchJoin(id).then(response => {
  105. this.postForm = response.data.info
  106. // set tags view title
  107. // this.setTagsViewTitle()
  108. // set page title
  109. // this.setPageTitle()
  110. }).catch(err => {
  111. console.log(err)
  112. })
  113. },
  114. setPageTitle() {
  115. const title = 'Edit Article'
  116. document.title = `${title} - ${this.postForm.id}`
  117. },
  118. submitForm() {
  119. this.$refs.postForm.validate(valid => {
  120. if (valid) {
  121. this.loading = true
  122. } else {
  123. console.log('error submit!!')
  124. return false
  125. }
  126. })
  127. },
  128. updateArticle() {
  129. console.log(this.postForm)
  130. this.$router.push(`/branchJoin/list`)
  131. },
  132. draftForm() {
  133. if (this.postForm.content.length === 0 || this.postForm.title.length === 0) {
  134. this.$message({
  135. message: '请填写必要的标题和内容',
  136. type: 'warning'
  137. })
  138. return
  139. }
  140. this.$message({
  141. message: '保存成功',
  142. type: 'success',
  143. showClose: true,
  144. duration: 1000
  145. })
  146. this.postForm.status = 'draft'
  147. },
  148. formatCreatePosition(position) {
  149. switch (position) {
  150. case 1:
  151. return 'HOME'
  152. case 2:
  153. return 'ACTIVITY'
  154. }
  155. },
  156. editPosition(position) {
  157. switch (position) {
  158. case 'HOME':
  159. return 1
  160. case 'ACTIVITY':
  161. return 2
  162. }
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. @import "~@/styles/mixin.scss";
  169. .createPost-container {
  170. position: relative;
  171. .createPost-main-container {
  172. padding: 40px 45px 20px 50px;
  173. .postInfo-container {
  174. position: relative;
  175. @include clearfix;
  176. margin-bottom: 10px;
  177. .postInfo-container-item {
  178. float: left;
  179. }
  180. }
  181. }
  182. .word-counter {
  183. width: 40px;
  184. position: absolute;
  185. right: 10px;
  186. top: 0px;
  187. }
  188. }
  189. .article-textarea ::v-deep {
  190. textarea {
  191. padding-right: 40px;
  192. resize: none;
  193. border: none;
  194. border-radius: 0px;
  195. border-bottom: 1px solid #bfcbd9;
  196. }
  197. }
  198. </style>