add.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. padding-bottom: 160rpx;
  209. .list-view-title {
  210. width: 100%;
  211. height: auto;
  212. margin-bottom: 16rpx;
  213. margin-top: 40rpx;
  214. .list-view-h1 {
  215. line-height: 40rpx;
  216. font-size: $font-size-28;
  217. color: #333333;
  218. text-align: left;
  219. text {
  220. color: #ff2a2a;
  221. }
  222. }
  223. .list-view-p {
  224. line-height: 30rpx;
  225. color: #fea785;
  226. font-size: $font-size-20;
  227. }
  228. }
  229. .remarks-textarea {
  230. width: 100%;
  231. height: 340rpx;
  232. padding: 16rpx;
  233. margin: 20rpx 0 0 0;
  234. border-radius: 6rpx;
  235. position: relative;
  236. border: 1px solid #b2b2b2;
  237. box-sizing: border-box;
  238. .textarea {
  239. width: 100%;
  240. height: 100%;
  241. line-height: 36rpx;
  242. font-size: $font-size-26;
  243. color: $text-color;
  244. z-index: 1;
  245. }
  246. .limit-text {
  247. position: absolute;
  248. right: 20rpx;
  249. bottom: 16rpx;
  250. line-height: 44rpx;
  251. font-size: $font-size-24;
  252. color: #b2b2b2;
  253. }
  254. }
  255. .list-view {
  256. width: 100%;
  257. height: 40rpx;
  258. margin-top: 20rpx;
  259. .list-view-file {
  260. width: 132rpx;
  261. height: 44rpx;
  262. line-height: 44rpx;
  263. font-size: $font-size-20;
  264. text-align: center;
  265. color: #ffffff;
  266. background-color: $color-system;
  267. border-radius: 8rpx;
  268. float: left;
  269. margin-top: 10rpx;
  270. }
  271. .list-view-text {
  272. width: 100%;
  273. float: left;
  274. .input {
  275. width: 560rpx;
  276. height: 44rpx;
  277. box-sizing: border-box;
  278. line-height: 44rpx;
  279. color: #333333;
  280. text-overflow: ellipsis;
  281. overflow: hidden;
  282. display: -webkit-box;
  283. -webkit-line-clamp: 1;
  284. line-clamp: 1;
  285. -webkit-box-orient: vertical;
  286. float: left;
  287. }
  288. .delbtn {
  289. width: 96rpx;
  290. height: 44rpx;
  291. border-radius: 8rpx;
  292. background-color: #fff2ec;
  293. font-size: $font-size-24;
  294. color: #e15616;
  295. line-height: 44rpx;
  296. text-align: center;
  297. float: left;
  298. }
  299. }
  300. }
  301. .list-view-upload {
  302. width: 100%;
  303. height: auto;
  304. .photo-item {
  305. display: inline-block;
  306. width: 112rpx;
  307. height: 112rpx;
  308. margin: 10rpx 0;
  309. margin-right: 25rpx;
  310. border-radius: 10rpx;
  311. border: 1px solid #f5f5f5;
  312. position: relative;
  313. float: left;
  314. &.add {
  315. width: 112rpx;
  316. height: 112rpx;
  317. border-color: #b2b2b2;
  318. text-align: center;
  319. line-height: 112rpx;
  320. margin-right: 0rpx;
  321. .icon-jiahao {
  322. font-size: $font-size-44;
  323. color: #b2b2b2;
  324. font-weight: bold;
  325. }
  326. }
  327. .icon-iconfontguanbi {
  328. width: 30rpx;
  329. height: 30rpx;
  330. border-radius: 50%;
  331. display: block;
  332. position: absolute;
  333. right: -10rpx;
  334. top: -10rpx;
  335. background: #f94b4b;
  336. text-align: center;
  337. line-height: 30rpx;
  338. color: #ffffff;
  339. font-size: $font-size-22;
  340. }
  341. image {
  342. width: 112rpx;
  343. height: 112rpx;
  344. border-radius: 10rpx;
  345. }
  346. }
  347. .photo-list {
  348. width: 100%;
  349. height: 116rpx;
  350. overflow: hidden;
  351. white-space: nowrap;
  352. display: flex;
  353. align-items: flex-start;
  354. }
  355. }
  356. }
  357. .remarks-btn {
  358. width: 100%;
  359. padding-top: 20rpx;
  360. position: fixed;
  361. bottom: 0;
  362. left: 0;
  363. background-color: #ffffff;
  364. .edit-button-canel {
  365. width: 100%;
  366. height: 88rpx;
  367. line-height: 88rpx;
  368. text-align: center;
  369. color: #e15616;
  370. font-size: $font-size-24;
  371. }
  372. .edit-button {
  373. width: 600rpx;
  374. height: 90rpx;
  375. background: $btn-confirm;
  376. line-height: 90rpx;
  377. text-align: center;
  378. color: #ffffff;
  379. font-size: $font-size-30;
  380. margin: 0 auto;
  381. border-radius: 45rpx;
  382. }
  383. }
  384. </style>