add.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. }).catch(err=>{
  150. console.log(err)
  151. })
  152. },
  153. uploadPhotoFn(array) {
  154. //添加图片
  155. uploadFileImage().then(res => {
  156. array.push(JSON.parse(res.data).data)
  157. })
  158. },
  159. deleteFileFn(array, index) {
  160. console.log(array)
  161. //删除文件
  162. this.UploadService.PostFileDelete({
  163. ossName: array[index].ossName
  164. })
  165. .then(res => {
  166. array.splice(index, 1)
  167. })
  168. .catch(error => {
  169. console.log('删除文件异常提示===>', error.msg)
  170. })
  171. },
  172. deletePhotoFn(array, index) {
  173. //删除图片
  174. array.splice(index, 1)
  175. },
  176. previewImg(image, index) {
  177. //顶部商品图片预览
  178. isPreviewImg = true
  179. let previewUrls = image
  180. uni.previewImage({
  181. current: index, //图片索引
  182. urls: previewUrls, //必须是http图片,本地图片无效
  183. longPressActions: ''
  184. })
  185. },
  186. conInput(e) {
  187. //备注文字字数限制
  188. let value = e.detail.value
  189. let len = parseInt(value.length)
  190. if (len > this.max) return
  191. this.min = len
  192. if (this.min == 200) {
  193. this.$util.msg('您输入的字数已达上限', 2000)
  194. }
  195. }
  196. },
  197. onShow() {}
  198. }
  199. </script>
  200. <style lang="scss">
  201. page {
  202. height: auto;
  203. background: #ffffff;
  204. }
  205. .remarks-content {
  206. width: 100%;
  207. height: auto;
  208. box-sizing: border-box;
  209. padding: 0 24rpx;
  210. padding-bottom: 160rpx;
  211. .list-view-title {
  212. width: 100%;
  213. height: auto;
  214. margin-bottom: 16rpx;
  215. margin-top: 40rpx;
  216. .list-view-h1 {
  217. line-height: 40rpx;
  218. font-size: $font-size-28;
  219. color: #333333;
  220. text-align: left;
  221. text {
  222. color: #ff2a2a;
  223. }
  224. }
  225. .list-view-p {
  226. line-height: 30rpx;
  227. color: #fea785;
  228. font-size: $font-size-20;
  229. }
  230. }
  231. .remarks-textarea {
  232. width: 100%;
  233. height: 340rpx;
  234. padding: 16rpx;
  235. margin: 20rpx 0 0 0;
  236. border-radius: 6rpx;
  237. position: relative;
  238. border: 1px solid #b2b2b2;
  239. box-sizing: border-box;
  240. .textarea {
  241. width: 100%;
  242. height: 100%;
  243. line-height: 36rpx;
  244. font-size: $font-size-26;
  245. color: $text-color;
  246. z-index: 1;
  247. }
  248. .limit-text {
  249. position: absolute;
  250. right: 20rpx;
  251. bottom: 16rpx;
  252. line-height: 44rpx;
  253. font-size: $font-size-24;
  254. color: #b2b2b2;
  255. }
  256. }
  257. .list-view {
  258. width: 100%;
  259. height: 40rpx;
  260. margin-top: 20rpx;
  261. .list-view-file {
  262. width: 132rpx;
  263. height: 44rpx;
  264. line-height: 44rpx;
  265. font-size: $font-size-20;
  266. text-align: center;
  267. color: #ffffff;
  268. background-color: $color-system;
  269. border-radius: 8rpx;
  270. float: left;
  271. margin-top: 10rpx;
  272. }
  273. .list-view-text {
  274. width: 100%;
  275. float: left;
  276. .input {
  277. width: 560rpx;
  278. height: 44rpx;
  279. box-sizing: border-box;
  280. line-height: 44rpx;
  281. color: #333333;
  282. text-overflow: ellipsis;
  283. overflow: hidden;
  284. display: -webkit-box;
  285. -webkit-line-clamp: 1;
  286. line-clamp: 1;
  287. -webkit-box-orient: vertical;
  288. float: left;
  289. }
  290. .delbtn {
  291. width: 96rpx;
  292. height: 44rpx;
  293. border-radius: 8rpx;
  294. background-color: #fff2ec;
  295. font-size: $font-size-24;
  296. color: #e15616;
  297. line-height: 44rpx;
  298. text-align: center;
  299. float: left;
  300. }
  301. }
  302. }
  303. .list-view-upload {
  304. width: 100%;
  305. height: auto;
  306. .photo-item {
  307. display: inline-block;
  308. width: 112rpx;
  309. height: 112rpx;
  310. margin: 10rpx 0;
  311. margin-right: 25rpx;
  312. border-radius: 10rpx;
  313. border: 1px solid #f5f5f5;
  314. position: relative;
  315. float: left;
  316. &.add {
  317. width: 112rpx;
  318. height: 112rpx;
  319. border-color: #b2b2b2;
  320. text-align: center;
  321. line-height: 112rpx;
  322. margin-right: 0rpx;
  323. .icon-jiahao {
  324. font-size: $font-size-44;
  325. color: #b2b2b2;
  326. font-weight: bold;
  327. }
  328. }
  329. .icon-iconfontguanbi {
  330. width: 30rpx;
  331. height: 30rpx;
  332. border-radius: 50%;
  333. display: block;
  334. position: absolute;
  335. right: -10rpx;
  336. top: -10rpx;
  337. background: #f94b4b;
  338. text-align: center;
  339. line-height: 30rpx;
  340. color: #ffffff;
  341. font-size: $font-size-22;
  342. }
  343. image {
  344. width: 112rpx;
  345. height: 112rpx;
  346. border-radius: 10rpx;
  347. }
  348. }
  349. .photo-list {
  350. width: 100%;
  351. height: 116rpx;
  352. overflow: hidden;
  353. white-space: nowrap;
  354. display: flex;
  355. align-items: flex-start;
  356. }
  357. }
  358. }
  359. .remarks-btn {
  360. width: 100%;
  361. padding-top: 20rpx;
  362. position: fixed;
  363. bottom: 0;
  364. left: 0;
  365. background-color: #ffffff;
  366. .edit-button-canel {
  367. width: 100%;
  368. height: 88rpx;
  369. line-height: 88rpx;
  370. text-align: center;
  371. color: #e15616;
  372. font-size: $font-size-24;
  373. }
  374. .edit-button {
  375. width: 600rpx;
  376. height: 90rpx;
  377. background: $btn-confirm;
  378. line-height: 90rpx;
  379. text-align: center;
  380. color: #ffffff;
  381. font-size: $font-size-30;
  382. margin: 0 auto;
  383. border-radius: 45rpx;
  384. }
  385. }
  386. </style>