upload.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view>
  3. <my_form ref="form" :form="form" @isUncomplete="isUncomplete" @onUploading="onUploading" />
  4. <view class="footer">
  5. <view class="but" :class="(uncomplete || onUpload) ? 'forbidden' : ''" hover-class="navigator-hover"
  6. @click="(uncomplete || onUpload) ? '' : submit()">
  7. 立即提交
  8. </view>
  9. </view>
  10. <view style="height: 75px;" />
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. form: [],
  18. uncomplete: true,
  19. pageType: 4,
  20. onUpload: false,
  21. isSubmit: false,
  22. }
  23. },
  24. onUnload() {
  25. if (!this.isSubmit) this.$refs.form.deleteFiles()
  26. },
  27. onLoad(options) {
  28. this.pageType = options.pageType == '设计' ? 4 : 5
  29. uni.setNavigationBarTitle({
  30. title: '上传'
  31. });
  32. this.initForm()
  33. },
  34. methods: {
  35. async initForm() {
  36. this.form = [{
  37. key: "title_c",
  38. type: "text",
  39. label: "标题",
  40. isMust: true,//是否必填
  41. value: "",
  42. marginTop: 10
  43. }, {
  44. key: "panoramaurl",
  45. type: "text",
  46. label: "全景地址",
  47. placeholder: "请填写酷乐家/三维家720°全景地址",
  48. value: ""
  49. }, {
  50. key: "space",
  51. type: "customClass",
  52. label: "空间",
  53. isMultipleChoice: true,//是否多选
  54. value: [],
  55. list: await this.getCustomClass('picturespace'),
  56. marginTop: 10
  57. }, {
  58. key: "style",
  59. type: "customClass",
  60. label: "风格",
  61. isMultipleChoice: true,//是否多选
  62. value: [],
  63. list: await this.getCustomClass('picturestyle'),
  64. marginTop: 10
  65. }, {
  66. key: "spec",
  67. type: "customClass",
  68. label: "尺寸",
  69. isMultipleChoice: true,//是否多选
  70. value: [],
  71. list: await this.getCustomClass('picturespec'),
  72. marginTop: 10
  73. }, {
  74. key: "attachmentids",
  75. type: "upload",
  76. label: "图片/视频",
  77. placeholder: "可上传多个视频或图片",
  78. accept: "media",
  79. ownertable: "temporary",
  80. ownerid: 999,
  81. usetype: 'default',
  82. allowUpload: true,
  83. allowDelete: true,
  84. value: [],
  85. marginTop: 10
  86. }]
  87. },
  88. isUncomplete(uncomplete) {
  89. this.uncomplete = uncomplete;
  90. },
  91. submit() {
  92. this.$refs.form.submit().then(data => {
  93. this.onUpload = true;
  94. this.$Http.basic({
  95. "id": 20240417104602,
  96. "content": {
  97. "sat_sharematerialid": 0,
  98. "title": "",
  99. "title_c": data.title_c,
  100. "type": this.pageType, //4:设计,5:实景
  101. "panoramaurl": data.panoramaurl,
  102. "renderingsclass": {
  103. "style": data.style,
  104. "space": data.space,
  105. "spec": data.spec
  106. },
  107. "isnationwide": 0, //是否全国精选
  108. "sequence": 0,
  109. "ispublish": 1//是否发布
  110. },
  111. }).then(async res => {
  112. this.onUpload = false;
  113. console.log("新建", res)
  114. if (this.cutoff(res.msg)) return;
  115. if (data.files.temporarys.length) {
  116. this.onUpload = true;
  117. await this.$Http.basic({
  118. "classname": "system.attachment.Attachment",
  119. "method": "createFileLink",
  120. "content": {
  121. ownertable: 'sat_sharematerial',
  122. ownerid: res.data.sat_sharematerialid,
  123. usetype: 'default',
  124. attachmentids: data.files.temporarys
  125. }
  126. }).then(async s => {
  127. this.isSubmit = true;
  128. this.onUpload = false;
  129. console.log("绑定附加", s)
  130. if (this.cutoff(s.msg)) return;
  131. await this.$Http.basic({
  132. "id": "20240425102102",
  133. "content": {
  134. "ownertable": 'sat_sharematerial',
  135. "ownerid": res.data.sat_sharematerialid,
  136. "items": data.files.temporarys.map(v => {
  137. return {
  138. "attachmentid": v,
  139. "jumpurl": "",
  140. "sequence": 0
  141. }
  142. })
  143. }
  144. }).then(e => {
  145. console.log("plc", e)
  146. if (this.cutoff(e.msg)) return;
  147. })
  148. })
  149. };
  150. console.log("updateList", this.$Http.updateList)
  151. if (this.$Http.updateList) return this.$Http.updateList(res.data);
  152. uni.showModal({
  153. title: '提示',
  154. content: '新建成功,是否立即查看',
  155. cancelText: '返回列表',
  156. confirmText: '查看详情',
  157. success: ({ confirm }) => {
  158. if (confirm) {
  159. uni.redirectTo({
  160. url: `/packageA/fullView/detail?id=${res.data.sat_sharematerialid}`
  161. });
  162. this.$Http.setCount = null;
  163. } else {
  164. uni.navigateBack()
  165. }
  166. },
  167. })
  168. })
  169. console.log("页面", data)
  170. })
  171. },
  172. onUploading(ing) {
  173. this.onUpload = ing;
  174. },
  175. },
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. .footer {
  180. position: fixed;
  181. bottom: 0;
  182. width: 375px;
  183. height: 65px;
  184. background: #FFFFFF;
  185. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  186. border-radius: 0px 0px 0px 0px;
  187. .but {
  188. width: 355px;
  189. height: 45px;
  190. background: #C30D23;
  191. border-radius: 5px;
  192. margin: 5px auto;
  193. text-align: center;
  194. line-height: 45px;
  195. font-size: 14px;
  196. color: #FFFFFF;
  197. }
  198. .forbidden {
  199. opacity: .6;
  200. }
  201. }
  202. </style>