newRelease.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="newRelease">
  3. <ul class="predetermineUl">
  4. <li class="predetermineLi2">
  5. <div class="liName">标题</div>
  6. <van-field
  7. :value="postData.title"
  8. autosize
  9. type="textarea"
  10. placeholder="请输入"
  11. class="myField"
  12. maxlength="50"
  13. show-word-limit
  14. @input="onInput"
  15. />
  16. </li>
  17. <li class="predetermineLi2" style="border-bottom: none">
  18. <div class="titleBox" style="margin-bottom: 24rpx">
  19. <span class="liName">上传图片</span>
  20. <span class="tips">(支持图片上传限20M内,最多6张)</span>
  21. </div>
  22. <van-uploader
  23. :max-count="12"
  24. @delete="deleteRYXXZP"
  25. :file-list="fileList"
  26. @after-read="uploadRYXXZP"
  27. :show-upload="true"
  28. />
  29. </li>
  30. <li class="predetermineLi2" style="border-bottom: none">
  31. <div class="titleBox" style="margin-bottom: 24rpx">
  32. <span class="liName">内容</span>
  33. </div>
  34. <van-field
  35. :value="postData.content"
  36. autosize
  37. type="textarea"
  38. placeholder="请输入"
  39. class="myField"
  40. maxlength="1000"
  41. show-word-limit
  42. @input="onInput2"
  43. />
  44. </li>
  45. </ul>
  46. <div class="buttonBox" >
  47. <button class="btn zcBtn" @tap="commitCliack">暂存</button>
  48. <button class="btn tjBtn" @tap="addClick">发布</button>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. import { noticeParkAdd,getUserLocalStorageInfo,noticeParkGetById,noticeParkEdit } from "@/js_sdk/http";
  54. import dayjs from "dayjs";
  55. export default {
  56. name: "newRelease",
  57. data(){
  58. return{
  59. postData:{
  60. content:'',
  61. title:'',
  62. createdBy: getUserLocalStorageInfo().userId,
  63. source:'2',
  64. status:''
  65. },
  66. fileList:[],
  67. addType: '',
  68. type:''
  69. }
  70. },
  71. onLoad(type){
  72. console.log(type)
  73. this.type = type.noticeType
  74. this.addType = type.addType
  75. if (type.id){
  76. noticeParkGetById({id:type.id}).then(res=>{
  77. console.log(res)
  78. this.postData = res.data
  79. })
  80. }
  81. },
  82. methods:{
  83. onInput(event){
  84. console.log(event)
  85. this.postData.title = event.detail;
  86. },
  87. onInput2(event){
  88. this.postData.content = event.detail;
  89. },
  90. addClick() {
  91. const dayjs = require('dayjs')
  92. this.postData.releaseTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  93. this.postData.status = 'published'
  94. if (this.addType === '发布'){
  95. // console.log(this.postData)
  96. noticeParkAdd(this.postData).then(res=>{
  97. if (res.code == '200'){
  98. uni.reLaunch({
  99. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  100. })
  101. uni.showToast({
  102. title: '操作成功',
  103. duration: 500
  104. });
  105. }
  106. })
  107. }else if(this.addType === '编辑'){
  108. noticeParkEdit(this.postData).then(res=>{
  109. if (res.code == '200'){
  110. uni.reLaunch({
  111. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  112. })
  113. uni.showToast({
  114. title: '操作成功',
  115. duration: 500
  116. });
  117. }
  118. })
  119. }
  120. },
  121. commitCliack() {
  122. const dayjs = require('dayjs')
  123. if (this.addType === '发布'){
  124. this.postData.releaseTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  125. this.postData.status = 'unpublished'
  126. noticeParkAdd(this.postData).then(res=>{
  127. if (res.code == '200'){
  128. uni.reLaunch({
  129. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  130. })
  131. uni.showToast({
  132. title: '操作成功',
  133. duration: 500
  134. });
  135. }
  136. })
  137. }else if(this.addType === '编辑'){
  138. noticeParkEdit(this.postData).then(res=>{
  139. if (res.code == '200'){
  140. uni.reLaunch({
  141. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  142. })
  143. uni.showToast({
  144. title: '操作成功',
  145. duration: 500
  146. });
  147. }
  148. })
  149. }
  150. },
  151. deleteRYXXZP(event) {
  152. this.fileList.splice(event.detail.index, 1);
  153. this.$forceUpdate();
  154. },
  155. uploadRYXXZP(event) {
  156. console.log(event)
  157. let that = this;
  158. const { file } = event.detail;
  159. uni.uploadFile({
  160. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  161. filePath: file.url,
  162. name: "file",
  163. formData: { user: "test" },
  164. success(res) {
  165. // 上传完成需要更新 fileList
  166. let data = JSON.parse(res.data);
  167. that.fileList.push({
  168. imgUrl: "/FileController/download/" + data.data[0],
  169. id: data.data[0],
  170. url:
  171. that.$constant.BASE_URI +
  172. "/FileController/download/" +
  173. data.data[0],
  174. isImage: true,
  175. });
  176. },
  177. fail(res) {},
  178. });
  179. },
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. .newRelease{
  185. .predetermineUl{
  186. margin: 24rpx 0;
  187. background: white;
  188. box-sizing: border-box;
  189. padding: 0 32rpx;
  190. .predetermineLi{
  191. padding: 32rpx 0;
  192. border-bottom: 1px solid rgba(230, 230, 230, 1);
  193. display: flex;
  194. justify-content: space-between;
  195. }
  196. .predetermineLi2{
  197. padding: 32rpx 0;
  198. border-bottom: 1px solid rgba(230, 230, 230, 1);
  199. display: flex;
  200. flex-direction: column;
  201. }
  202. .van-cell {
  203. background: #F5F7FA !important;
  204. border-radius: 8rpx;
  205. font-size: 28rpx;
  206. margin-top: 16rpx;
  207. }
  208. .liName{
  209. color: rgba(51, 51, 51, 1);
  210. font-size: 32rpx;
  211. }
  212. .liIpt{
  213. color: rgba(102, 102, 102, 1);
  214. font-size: 32rpx;
  215. text-align: right;
  216. }
  217. }
  218. .titleBox{
  219. display: flex;
  220. align-items: center;
  221. .titleName{
  222. color: rgba(24, 23, 42, 1);
  223. font-size: 32rpx;
  224. font-weight: 600;
  225. margin-right: 16rpx;
  226. }
  227. .tips{
  228. font-size: 28rpx;
  229. color: rgba(179, 179, 179, 1);
  230. }
  231. }
  232. .buttonBox{
  233. display: flex;
  234. justify-content: center;
  235. .btn{
  236. width: 240rpx;
  237. height: 80rpx;
  238. display: flex;
  239. border-radius: 8rpx;
  240. align-items: center;
  241. justify-content: center;
  242. margin: 48rpx 16rpx 150rpx 16rpx;
  243. color: white;
  244. letter-spacing: 2rpx;
  245. text-indent: 2rpx;
  246. }
  247. .zcBtn{
  248. background: #FE8643;
  249. }
  250. .tjBtn{
  251. background: #0365F9;
  252. }
  253. }
  254. }
  255. </style>