upload.vue 7.3 KB

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