add.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <view class="container qualifications" :style="{ paddingBottom: isIphoneX ? '68rpx' : '0' }">
  3. <view class="remarks-content">
  4. <view class="list-view-title">
  5. <view class="list-view-h1"><text>*</text>文字备注</view>
  6. </view>
  7. <view class="remarks-textarea">
  8. <textarea
  9. class="textarea"
  10. v-model="remarksParams.remarks"
  11. value=""
  12. placeholder="文字备注,500字以内"
  13. maxlength="500"
  14. @input="conInput"
  15. />
  16. <text class="limit-text">{{ min }}/{{ max }}</text>
  17. </view>
  18. <view class="list-view-title">
  19. <view class="list-view-h1">上传图片</view>
  20. <view class="list-view-p">(可上传与客户的聊天截图或其他重要图片资料,最多10张)</view>
  21. </view>
  22. <view class="list-view-upload clearfix">
  23. <view class="photo-item" v-for="(image, imageIndex) in remarksParams.imageList" :key="imageIndex">
  24. <image
  25. :src="image"
  26. mode="aspectFill"
  27. @click.stop="previewImg(remarksParams.imageList, imageIndex)"
  28. ></image>
  29. <text
  30. class="iconfont icon-iconfontguanbi"
  31. @click.stop="deletePhotoFn(remarksParams.imageList, imageIndex)"
  32. ></text>
  33. </view>
  34. <view
  35. class="photo-item add"
  36. @click.stop="uploadPhotoFn(remarksParams.imageList)"
  37. v-if="remarksParams.imageList.length < 10 || remarksParams.imageList.length == 0"
  38. >
  39. <text class="iconfont icon-jiahao"></text>
  40. </view>
  41. </view>
  42. <view class="list-view-title">
  43. <view class="list-view-h1">上传文件</view>
  44. <view class="list-view-p">(可上传与客户相关的文件资料,最多10份,支持word,excel,ppt和pdf格式文件)</view>
  45. </view>
  46. <view class="list-view" v-for="(file, fileIndex) in remarksParams.fileList" :key="fileIndex">
  47. <view class="list-view-text">
  48. <view class="input">{{ file.fileName }}</view>
  49. <view class="delbtn" @click.stop="deleteFileFn(remarksParams.fileList, fileIndex)">删除</view>
  50. </view>
  51. </view>
  52. <view class="list-view">
  53. <view class="list-view-file" @click="uploadFile(remarksParams.fileList)">选择文件</view>
  54. </view>
  55. </view>
  56. <view class="remarks-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  57. <view class="edit-button" @click="editButtonConfim">确定</view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import { mapState, mapMutations } from 'vuex'
  63. import authorize from '@/common/config/authorize.js'
  64. import { uploadFileImage, uploadFilePdfDocDocxXlsx } from '@/services/public.js'
  65. var isPreviewImg
  66. export default {
  67. data() {
  68. return {
  69. isIphoneX: this.$store.state.isIphoneX,
  70. shopOrderId: 0,
  71. logisticsBatchId: 0,
  72. productActions: [],
  73. remarksParams: {
  74. clubId: 0,
  75. remarks: '',
  76. fileList: [],
  77. imageList: [],
  78. serviceProviderId: 0
  79. },
  80. min: 0,
  81. max: 500,
  82. handleType:''
  83. }
  84. },
  85. onLoad(option) {
  86. console.log(option)
  87. if (option.type == 'edit') {
  88. this.getUserClubRemarksDetail(option.remarksId)
  89. this.handleType = option.type
  90. } else {
  91. this.initGetStotage()
  92. }
  93. },
  94. methods: {
  95. ...mapMutations(['login']),
  96. async initGetStotage() {
  97. const clubInfo = await this.$api.getComStorage('orderUserInfo')
  98. const userInfo = await this.$api.getStorage()
  99. this.remarksParams.clubId = clubInfo.clubId ? clubInfo.clubId : 0
  100. this.remarksParams.serviceProviderId = userInfo.serviceProviderId ? userInfo.serviceProviderId : 0
  101. },
  102. getUserClubRemarksDetail(remarksId) {
  103. //修改回显资料备注信息
  104. this.UserService.getUserClubRemarksDetail({
  105. remarksId : remarksId
  106. })
  107. .then(response => {
  108. let data = response.data
  109. this.remarksParams.remarks = data.remarks
  110. this.remarksParams.remarksId = data.remarksId
  111. this.remarksParams.fileList = data.fileList
  112. this.remarksParams.imageList = data.imageList
  113. this.initGetStotage()
  114. })
  115. .catch(error => {
  116. this.$util.msg(error.msg, 2000)
  117. })
  118. },
  119. editButtonConfim() {
  120. //保存资料备注
  121. if (this.remarksParams.remarks == '') {
  122. this.$util.msg('请输入文字备注', 2000)
  123. return
  124. }
  125. this.UserService.getUserClubRemarksSave({
  126. params: JSON.stringify(this.remarksParams)
  127. })
  128. .then(response => {
  129. this.$util.msg('添加成功', 3000, true, 'success')
  130. setTimeout(() => {
  131. uni.navigateBack({delta: 1})
  132. }, 1000)
  133. })
  134. .catch(error => {
  135. this.$util.msg(error.msg, 2000)
  136. })
  137. },
  138. uploadFile(array) {
  139. //上传资质文件
  140. console.log(array)
  141. uploadFilePdfDocDocxXlsx().then(res => {
  142. let data = JSON.parse(res.data).data
  143. let obj = {
  144. fileName: uni.getStorageSync('fileName'),
  145. ossName: data.ossName
  146. }
  147. array.push(obj)
  148. console.log('array', array)
  149. })
  150. },
  151. uploadPhotoFn(array) {
  152. //添加图片
  153. uploadFileImage().then(res => {
  154. array.push(JSON.parse(res.data).data)
  155. })
  156. },
  157. deleteFileFn(array, index) {
  158. console.log(array)
  159. //删除文件
  160. this.UploadService.PostFileDelete({
  161. ossName: array[index].ossName
  162. })
  163. .then(res => {
  164. array.splice(index, 1)
  165. })
  166. .catch(error => {
  167. console.log('删除文件异常提示===>', error.msg)
  168. })
  169. },
  170. deletePhotoFn(array, index) {
  171. //删除图片
  172. array.splice(index, 1)
  173. },
  174. previewImg(image, index) {
  175. //顶部商品图片预览
  176. isPreviewImg = true
  177. let previewUrls = image
  178. uni.previewImage({
  179. current: index, //图片索引
  180. urls: previewUrls, //必须是http图片,本地图片无效
  181. longPressActions: ''
  182. })
  183. },
  184. conInput(e) {
  185. //备注文字字数限制
  186. let value = e.detail.value
  187. let len = parseInt(value.length)
  188. if (len > this.max) return
  189. this.min = len
  190. if (this.min == 200) {
  191. this.$util.msg('您输入的字数已达上限', 2000)
  192. }
  193. }
  194. },
  195. onShow() {}
  196. }
  197. </script>
  198. <style lang="scss">
  199. page {
  200. height: auto;
  201. background: #ffffff;
  202. }
  203. .remarks-content {
  204. width: 100%;
  205. height: auto;
  206. box-sizing: border-box;
  207. padding: 0 24rpx;
  208. .list-view-title {
  209. width: 100%;
  210. height: auto;
  211. margin-bottom: 16rpx;
  212. margin-top: 40rpx;
  213. .list-view-h1 {
  214. line-height: 40rpx;
  215. font-size: $font-size-28;
  216. color: #333333;
  217. text-align: left;
  218. text {
  219. color: #ff2a2a;
  220. }
  221. }
  222. .list-view-p {
  223. line-height: 30rpx;
  224. color: #fea785;
  225. font-size: $font-size-20;
  226. }
  227. }
  228. .remarks-textarea {
  229. width: 100%;
  230. height: 340rpx;
  231. padding: 16rpx;
  232. margin: 20rpx 0 0 0;
  233. border-radius: 6rpx;
  234. position: relative;
  235. border: 1px solid #b2b2b2;
  236. box-sizing: border-box;
  237. .textarea {
  238. width: 100%;
  239. height: 100%;
  240. line-height: 36rpx;
  241. font-size: $font-size-26;
  242. color: $text-color;
  243. z-index: 1;
  244. }
  245. .limit-text {
  246. position: absolute;
  247. right: 20rpx;
  248. bottom: 16rpx;
  249. line-height: 44rpx;
  250. font-size: $font-size-24;
  251. color: #b2b2b2;
  252. }
  253. }
  254. .list-view {
  255. width: 100%;
  256. height: 40rpx;
  257. margin-top: 20rpx;
  258. .list-view-file {
  259. width: 132rpx;
  260. height: 44rpx;
  261. line-height: 44rpx;
  262. font-size: $font-size-20;
  263. text-align: center;
  264. color: #ffffff;
  265. background-color: $color-system;
  266. border-radius: 8rpx;
  267. float: left;
  268. margin-top: 10rpx;
  269. }
  270. .list-view-text {
  271. width: 100%;
  272. float: left;
  273. .input {
  274. width: 560rpx;
  275. height: 44rpx;
  276. box-sizing: border-box;
  277. line-height: 44rpx;
  278. color: #333333;
  279. text-overflow: ellipsis;
  280. overflow: hidden;
  281. display: -webkit-box;
  282. -webkit-line-clamp: 1;
  283. line-clamp: 1;
  284. -webkit-box-orient: vertical;
  285. float: left;
  286. }
  287. .delbtn {
  288. width: 96rpx;
  289. height: 44rpx;
  290. border-radius: 8rpx;
  291. background-color: #fff2ec;
  292. font-size: $font-size-24;
  293. color: #e15616;
  294. line-height: 44rpx;
  295. text-align: center;
  296. float: left;
  297. }
  298. }
  299. }
  300. .list-view-upload {
  301. width: 100%;
  302. height: auto;
  303. .photo-item {
  304. display: inline-block;
  305. width: 112rpx;
  306. height: 112rpx;
  307. margin: 10rpx 0;
  308. margin-right: 25rpx;
  309. border-radius: 10rpx;
  310. border: 1px solid #f5f5f5;
  311. position: relative;
  312. float: left;
  313. &.add {
  314. width: 112rpx;
  315. height: 112rpx;
  316. border-color: #b2b2b2;
  317. text-align: center;
  318. line-height: 112rpx;
  319. margin-right: 0rpx;
  320. .icon-jiahao {
  321. font-size: $font-size-44;
  322. color: #b2b2b2;
  323. font-weight: bold;
  324. }
  325. }
  326. .icon-iconfontguanbi {
  327. width: 30rpx;
  328. height: 30rpx;
  329. border-radius: 50%;
  330. display: block;
  331. position: absolute;
  332. right: -10rpx;
  333. top: -10rpx;
  334. background: #f94b4b;
  335. text-align: center;
  336. line-height: 30rpx;
  337. color: #ffffff;
  338. font-size: $font-size-22;
  339. }
  340. image {
  341. width: 112rpx;
  342. height: 112rpx;
  343. border-radius: 10rpx;
  344. }
  345. }
  346. .photo-list {
  347. width: 100%;
  348. height: 116rpx;
  349. overflow: hidden;
  350. white-space: nowrap;
  351. display: flex;
  352. align-items: flex-start;
  353. }
  354. }
  355. }
  356. .remarks-btn {
  357. width: 100%;
  358. padding-top: 20rpx;
  359. position: fixed;
  360. bottom: 0;
  361. left: 0;
  362. background-color: #ffffff;
  363. .edit-button-canel {
  364. width: 100%;
  365. height: 88rpx;
  366. line-height: 88rpx;
  367. text-align: center;
  368. color: #e15616;
  369. font-size: $font-size-24;
  370. }
  371. .edit-button {
  372. width: 600rpx;
  373. height: 90rpx;
  374. background: $btn-confirm;
  375. line-height: 90rpx;
  376. text-align: center;
  377. color: #ffffff;
  378. font-size: $font-size-30;
  379. margin: 0 auto;
  380. border-radius: 45rpx;
  381. }
  382. }
  383. </style>