newRelease.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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, propertyNoticeAdd,propertyNoticeEdit,getPropertyNoticeById} 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. if (type.noticeType === '1'){
  77. noticeParkGetById({id:type.id}).then(res=>{
  78. console.log(res)
  79. this.postData = res.data
  80. this.postData = res.data
  81. const picArr = res.data.picture.split(',')
  82. picArr.forEach(id=>{
  83. this.fileList.push({
  84. imgUrl: "/FileController/download/" + id,
  85. id: id,
  86. url:
  87. this.$constant.BASE_URI +
  88. "/FileController/download/" +
  89. id,
  90. isImage: true,
  91. });
  92. })
  93. })
  94. }else{
  95. getPropertyNoticeById({id:type.id}).then(res=>{
  96. console.log(res)
  97. this.postData = res.data
  98. const picArr = res.data.picture.split(',')
  99. picArr.forEach(id=>{
  100. this.fileList.push({
  101. imgUrl: "/FileController/download/" + id,
  102. id: id,
  103. url:
  104. this.$constant.BASE_URI +
  105. "/FileController/download/" +
  106. id,
  107. isImage: true,
  108. });
  109. })
  110. })
  111. }
  112. }
  113. },
  114. methods:{
  115. onInput(event){
  116. console.log(event)
  117. this.postData.title = event.detail;
  118. },
  119. onInput2(event){
  120. this.postData.content = event.detail;
  121. },
  122. addClick() {
  123. const dayjs = require('dayjs')
  124. this.postData.releaseTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  125. this.postData.status = 'published'
  126. const picArr = []
  127. this.fileList.forEach(e=>{
  128. picArr.push(e.id)
  129. })
  130. this.postData.picture = picArr.toString()
  131. if (this.addType === '发布'){
  132. if (this.type === '1'){
  133. //新增园区通知
  134. // console.log(this.postData)
  135. noticeParkAdd(this.postData).then(res=>{
  136. if (res.code == '200'){
  137. uni.reLaunch({
  138. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  139. })
  140. uni.showToast({
  141. title: '操作成功',
  142. duration: 500
  143. });
  144. }
  145. })
  146. }else{
  147. //新增物业通知
  148. propertyNoticeAdd(this.postData).then(res=>{
  149. if (res.code == '200'){
  150. uni.reLaunch({
  151. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  152. })
  153. uni.showToast({
  154. title: '操作成功',
  155. duration: 500
  156. });
  157. }
  158. })
  159. }
  160. }else if(this.addType === '编辑'){
  161. if (this.type === '1'){
  162. noticeParkEdit(this.postData).then(res=>{
  163. if (res.code == '200'){
  164. uni.reLaunch({
  165. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  166. })
  167. uni.showToast({
  168. title: '操作成功',
  169. duration: 500
  170. });
  171. }
  172. })
  173. }else{
  174. propertyNoticeEdit(this.postData).then(res=>{
  175. if (res.code == '200'){
  176. uni.reLaunch({
  177. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  178. })
  179. uni.showToast({
  180. title: '操作成功',
  181. duration: 500
  182. });
  183. }
  184. })
  185. }
  186. }
  187. },
  188. commitCliack() {
  189. const dayjs = require('dayjs')
  190. this.postData.releaseTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  191. this.postData.status = 'unpublished'
  192. const picArr = []
  193. this.fileList.forEach(e=>{
  194. picArr.push(e.id)
  195. })
  196. this.postData.picture = picArr.toString()
  197. if (this.addType === '发布'){
  198. if (this.type === '1'){
  199. //新增园区通知
  200. // console.log(this.postData)
  201. noticeParkAdd(this.postData).then(res=>{
  202. if (res.code == '200'){
  203. uni.reLaunch({
  204. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  205. })
  206. uni.showToast({
  207. title: '操作成功',
  208. duration: 500
  209. });
  210. }
  211. })
  212. }else{
  213. // 新增物业通知
  214. propertyNoticeAdd(this.postData).then(res=>{
  215. if (res.code == '200'){
  216. uni.reLaunch({
  217. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  218. })
  219. uni.showToast({
  220. title: '操作成功',
  221. duration: 500
  222. });
  223. }
  224. })
  225. }
  226. }else if(this.addType === '编辑'){
  227. if (this.type === '1'){
  228. noticeParkEdit(this.postData).then(res=>{
  229. if (res.code == '200'){
  230. uni.reLaunch({
  231. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  232. })
  233. uni.showToast({
  234. title: '操作成功',
  235. duration: 500
  236. });
  237. }
  238. })
  239. }else{
  240. propertyNoticeEdit(this.postData).then(res=>{
  241. if (res.code == '200'){
  242. uni.reLaunch({
  243. url:'/pages/subPackages/propertyNotice_manage/index?type=' + this.type
  244. })
  245. uni.showToast({
  246. title: '操作成功',
  247. duration: 500
  248. });
  249. }
  250. })
  251. }
  252. }
  253. },
  254. deleteRYXXZP(event) {
  255. this.fileList.splice(event.detail.index, 1);
  256. this.$forceUpdate();
  257. },
  258. uploadRYXXZP(event) {
  259. console.log(event)
  260. let that = this;
  261. const { file } = event.detail;
  262. uni.uploadFile({
  263. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  264. filePath: file.url,
  265. name: "file",
  266. formData: { user: "test" },
  267. success(res) {
  268. // 上传完成需要更新 fileList
  269. let data = JSON.parse(res.data);
  270. console.log('data',data)
  271. that.fileList.push({
  272. imgUrl: "/FileController/download/" + data.data[0],
  273. id: data.data[0],
  274. url:
  275. that.$constant.BASE_URI +
  276. "/FileController/download/" +
  277. data.data[0],
  278. isImage: true,
  279. });
  280. },
  281. fail(res) {},
  282. });
  283. },
  284. }
  285. }
  286. </script>
  287. <style lang="scss">
  288. .newRelease{
  289. .predetermineUl{
  290. margin: 24rpx 0;
  291. background: white;
  292. box-sizing: border-box;
  293. padding: 0 32rpx;
  294. .predetermineLi{
  295. padding: 32rpx 0;
  296. border-bottom: 1px solid rgba(230, 230, 230, 1);
  297. display: flex;
  298. justify-content: space-between;
  299. }
  300. .predetermineLi2{
  301. padding: 32rpx 0;
  302. border-bottom: 1px solid rgba(230, 230, 230, 1);
  303. display: flex;
  304. flex-direction: column;
  305. }
  306. .van-cell {
  307. background: #F5F7FA !important;
  308. border-radius: 8rpx;
  309. font-size: 28rpx;
  310. margin-top: 16rpx;
  311. }
  312. .liName{
  313. color: rgba(51, 51, 51, 1);
  314. font-size: 32rpx;
  315. }
  316. .liIpt{
  317. color: rgba(102, 102, 102, 1);
  318. font-size: 32rpx;
  319. text-align: right;
  320. }
  321. }
  322. .titleBox{
  323. display: flex;
  324. align-items: center;
  325. .titleName{
  326. color: rgba(24, 23, 42, 1);
  327. font-size: 32rpx;
  328. font-weight: 600;
  329. margin-right: 16rpx;
  330. }
  331. .tips{
  332. font-size: 28rpx;
  333. color: rgba(179, 179, 179, 1);
  334. }
  335. }
  336. .buttonBox{
  337. display: flex;
  338. justify-content: center;
  339. .btn{
  340. width: 240rpx;
  341. height: 80rpx;
  342. display: flex;
  343. border-radius: 8rpx;
  344. align-items: center;
  345. justify-content: center;
  346. margin: 48rpx 16rpx 150rpx 16rpx;
  347. color: white;
  348. letter-spacing: 2rpx;
  349. text-indent: 2rpx;
  350. }
  351. .zcBtn{
  352. background: #FE8643;
  353. }
  354. .tjBtn{
  355. background: #0365F9;
  356. }
  357. }
  358. }
  359. </style>