add-record.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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">咨询人:</view>
  6. </view>
  7. <view class="remarks-input">{{ questionMan }}</view>
  8. <view class="list-view-title">
  9. <view class="list-view-h1"><text>*</text>咨询类别:</view>
  10. </view>
  11. <view class="remarks-category">
  12. <view
  13. class="checkbox-list"
  14. :class="category.isChecked ? 'checked' : ''"
  15. v-for="(category, index) in categorys"
  16. :key="index"
  17. @click="choiceCategorys(category, index)"
  18. >
  19. <text class="iconfont" :class="category.isChecked ? 'icon-yixuanze' : 'icon-weixuanze'"></text>
  20. {{ category.className }}
  21. </view>
  22. </view>
  23. <view class="list-view-title">
  24. <view class="list-view-h1"><text>*</text>关键词记录:</view>
  25. </view>
  26. <view class="remarks-textarea">
  27. <textarea
  28. class="textarea"
  29. v-model="remarksParams.remarks"
  30. value=""
  31. placeholder="请总结你和客户的聊天内容,以关键词形式填入框内,关键词之间用中文逗号隔开"
  32. maxlength="500"
  33. @input="conInput"
  34. />
  35. <text class="limit-text">{{ min }}/{{ max }}</text>
  36. </view>
  37. <view class="list-view-title">
  38. <view class="list-view-h1">上传图片</view>
  39. <view class="list-view-p">(可上传与客户的聊天截图或其他重要图片资料,最多10张)</view>
  40. </view>
  41. <view class="list-view-upload clearfix">
  42. <view class="photo-item" v-for="(image, imageIndex) in remarksParams.imageList" :key="imageIndex">
  43. <image
  44. :src="image"
  45. mode="aspectFill"
  46. @click.stop="previewImg(remarksParams.imageList, imageIndex)"
  47. ></image>
  48. <text
  49. class="iconfont icon-iconfontguanbi"
  50. @click.stop="deletePhotoFn(remarksParams.imageList, imageIndex)"
  51. ></text>
  52. </view>
  53. <view
  54. class="photo-item add"
  55. @click.stop="uploadPhotoFn(remarksParams.imageList)"
  56. v-if="remarksParams.imageList.length < 10 || remarksParams.imageList.length == 0"
  57. >
  58. <text class="iconfont icon-jiahao"></text>
  59. </view>
  60. </view>
  61. <view class="list-view-title">
  62. <view class="list-view-h1">上传文件</view>
  63. <view class="list-view-p">(可上传与客户相关的文件资料,最多10份,支持word,excel,ppt和pdf格式文件)</view>
  64. </view>
  65. <view class="list-view" v-for="(file, fileIndex) in remarksParams.fileList" :key="fileIndex">
  66. <view class="list-view-text">
  67. <view class="input">{{ file.fileName }}</view>
  68. <view class="delbtn" @click.stop="deleteFileFn(remarksParams.fileList, fileIndex)">删除</view>
  69. </view>
  70. </view>
  71. <view class="list-view">
  72. <view class="list-view-file" @click="uploadFile(remarksParams.fileList)">选择文件</view>
  73. </view>
  74. </view>
  75. <view class="remarks-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  76. <view class="edit-button" @click="editButtonConfim">确定</view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import { mapState, mapMutations } from 'vuex'
  82. import authorize from '@/common/config/authorize.js'
  83. import { uploadFileImage, uploadFilePdfDocDocxXlsx } from '@/services/public.js'
  84. var isPreviewImg
  85. export default {
  86. data() {
  87. return {
  88. isIphoneX: this.$store.state.isIphoneX,
  89. shopOrderId: 0,
  90. logisticsBatchId: 0,
  91. productActions: [],
  92. remarksParams: {
  93. remarks: '',
  94. fileList: [],
  95. imageList: [],
  96. questionManId: 0,
  97. serviceProviderId: 0
  98. },
  99. min: 0,
  100. max: 500,
  101. handleType:'',
  102. questionMan:'',
  103. clubUserId:0,
  104. clubInfo:{},
  105. userInfo:{},
  106. checkedCategorysList:[],
  107. categorys:[]
  108. }
  109. },
  110. onLoad(option) {
  111. console.log(option)
  112. if (option.type == 'edit') {
  113. this.handleType = option.type
  114. this.getUserClubConsults()
  115. this.getUserRemarksVisitDetail(option.remarksId)
  116. uni.setNavigationBarTitle({title:'修改记录'})
  117. } else {
  118. this.questionMan = option.questionMan
  119. this.remarksParams.questionManId = option.questionManId
  120. this.initGetStotage(option)
  121. this.getUserClubConsults()
  122. }
  123. },
  124. methods: {
  125. ...mapMutations(['login']),
  126. async initGetStotage(option) {
  127. const userInfo = await this.$api.getStorage()
  128. this.remarksParams.serviceProviderId = userInfo.serviceProviderId ? userInfo.serviceProviderId : 0
  129. },
  130. getUserRemarksVisitDetail(remarksId) {
  131. //修改回显资料备注信息
  132. this.UserService.getUserRemarksVisitDetail({
  133. remarksId : remarksId
  134. })
  135. .then(response => {
  136. let data = response.data
  137. this.questionMan = data.questionMan
  138. this.remarksParams.questionManId = data.questionManId
  139. this.remarksParams.remarks = data.remarks.join(',')
  140. this.remarksParams.remarksId = data.remarksId
  141. this.remarksParams.fileList = data.fileList
  142. this.remarksParams.imageList = data.imageList
  143. this.remarksParams.consult = data.consult
  144. this.checkedCategorysList = data.consult.split(',').map(i => parseInt(i, 0))
  145. this.categorys = this.categorys.map((el, index) => {
  146. if(data.consult.includes(el.id)){
  147. el.isChecked = true
  148. }else{
  149. el.isChecked = false
  150. }
  151. return el
  152. })
  153. this.initGetStotage()
  154. })
  155. .catch(error => {
  156. this.$util.msg(error.msg, 2000)
  157. })
  158. },
  159. getUserClubConsults() {
  160. //查询咨询类别
  161. this.UserService.getUserClubConsults()
  162. .then(response => {
  163. this.categorys = response.data.map((el, index) => {
  164. el.isChecked = false
  165. return el
  166. })
  167. })
  168. .catch(error => {
  169. console.log('=========>获取咨询类别列表失败')
  170. })
  171. },
  172. editButtonConfim() {
  173. //保存资料备注
  174. if (this.remarksParams.remarks == '') {
  175. this.$util.msg('请输入关键词记录', 2000)
  176. return
  177. }
  178. if (this.remarksParams.consult == '') {
  179. this.$util.msg('请选择咨询类别', 2000)
  180. return
  181. }
  182. if (this.remarksParams.remarks == '') {
  183. this.$util.msg('请输入关键词记录', 2000)
  184. return
  185. }
  186. this.UserService.getUserClubVisitorSaveAdd({
  187. params: JSON.stringify(this.remarksParams)
  188. })
  189. .then(response => {
  190. this.$util.msg('保存成功', 2000, true, 'success')
  191. let VisitorInfo = {
  192. questionManId: this.remarksParams.questionManId,
  193. questionMan: this.questionMan
  194. }
  195. this.$api.setStorage('VisitorInfo', VisitorInfo)
  196. setTimeout(() => {
  197. uni.navigateBack({
  198. delta: 1
  199. })
  200. }, 2000)
  201. })
  202. .catch(error => {
  203. this.$util.msg(error.msg, 2000)
  204. })
  205. },
  206. choiceCategorys(category,index){
  207. // 选择类别
  208. category.isChecked = !category.isChecked
  209. if (category.isChecked) {
  210. if(!this.contains(this.checkedCategorysList,category.id)){
  211. this.checkedCategorysList.push(category.id)
  212. }
  213. } else {
  214. this.checkedCategorysList.splice(this.checkedCategorysList.indexOf(category.id),1)
  215. }
  216. this.remarksParams.consult = this.checkedCategorysList.join(',')
  217. },
  218. contains(arr, val) {// 校验
  219. return arr.some(item => item === val)
  220. },
  221. uploadFile(array) {
  222. //上传资质文件
  223. console.log(array)
  224. uploadFilePdfDocDocxXlsx().then(res => {
  225. let data = JSON.parse(res.data).data
  226. let obj = {
  227. fileName: uni.getStorageSync('fileName'),
  228. ossName: data.ossName
  229. }
  230. array.push(obj)
  231. }).catch(err=>{
  232. console.log(err)
  233. })
  234. },
  235. uploadPhotoFn(array) {
  236. //添加图片
  237. uploadFileImage().then(res => {
  238. array.push(JSON.parse(res.data).data)
  239. })
  240. },
  241. deleteFileFn(array, index) {
  242. console.log(array)
  243. //删除文件
  244. this.UploadService.PostFileDelete({
  245. ossName: array[index].ossName
  246. })
  247. .then(res => {
  248. array.splice(index, 1)
  249. })
  250. .catch(error => {
  251. console.log('删除文件异常提示===>', error.msg)
  252. })
  253. },
  254. deletePhotoFn(array, index) {
  255. //删除图片
  256. array.splice(index, 1)
  257. },
  258. previewImg(image, index) {
  259. //顶部商品图片预览
  260. isPreviewImg = true
  261. let previewUrls = image
  262. uni.previewImage({
  263. current: index, //图片索引
  264. urls: previewUrls, //必须是http图片,本地图片无效
  265. longPressActions: ''
  266. })
  267. },
  268. conInput(e) {
  269. //备注文字字数限制
  270. let value = e.detail.value
  271. let len = parseInt(value.length)
  272. if (len > this.max) return
  273. this.min = len
  274. if (this.min == 200) {
  275. this.$util.msg('您输入的字数已达上限', 2000)
  276. }
  277. },
  278. },
  279. onShow() {}
  280. }
  281. </script>
  282. <style lang="scss">
  283. page {
  284. height: auto;
  285. background: #ffffff;
  286. }
  287. .remarks-content {
  288. width: 100%;
  289. height: auto;
  290. box-sizing: border-box;
  291. padding: 0 24rpx;
  292. padding-bottom: 160rpx;
  293. .list-view-title {
  294. width: 100%;
  295. height: auto;
  296. margin-bottom: 16rpx;
  297. margin-top: 20rpx;
  298. .list-view-h1 {
  299. line-height: 40rpx;
  300. font-size: $font-size-28;
  301. color: #333333;
  302. text-align: left;
  303. text {
  304. color: #ff2a2a;
  305. }
  306. }
  307. .list-view-p {
  308. line-height: 30rpx;
  309. color: #fea785;
  310. font-size: $font-size-20;
  311. }
  312. }
  313. .remarks-category{
  314. width: 100%;
  315. float: left;
  316. .checkbox-list {
  317. height: 60rpx;
  318. font-size: $font-size-28;
  319. line-height: 60rpx;
  320. border-radius: 10rpx;
  321. margin-right: 20rpx;
  322. margin-bottom: 10rpx;
  323. box-sizing: border-box;
  324. float: left;
  325. .icon-yixuanze{
  326. margin-right: 10rpx;
  327. color: #E15616;
  328. }
  329. .icon-weixuanze{
  330. margin-right: 10rpx;
  331. color: #B2B2B2;
  332. }
  333. }
  334. .item-text {
  335. display: inline-block;
  336. font-size: 26rpx;
  337. color: #333333;
  338. border-radius: 28rpx;
  339. line-height: 50rpx;
  340. }
  341. }
  342. .remarks-input{
  343. width: 100%;
  344. height: 48rpx;
  345. padding:0 16rpx;
  346. margin: 20rpx 0 0 0;
  347. position: relative;
  348. box-sizing: border-box;
  349. line-height: 48rpx;
  350. font-size: $font-size-26;
  351. color: $text-color;
  352. }
  353. .remarks-textarea {
  354. width: 100%;
  355. height: 340rpx;
  356. padding: 16rpx;
  357. margin: 20rpx 0 0 0;
  358. border-radius: 6rpx;
  359. position: relative;
  360. border: 1px solid #b2b2b2;
  361. box-sizing: border-box;
  362. .textarea {
  363. width: 100%;
  364. height: 100%;
  365. line-height: 36rpx;
  366. font-size: $font-size-26;
  367. color: $text-color;
  368. z-index: 1;
  369. }
  370. .limit-text {
  371. position: absolute;
  372. right: 20rpx;
  373. bottom: 16rpx;
  374. line-height: 44rpx;
  375. font-size: $font-size-24;
  376. color: #b2b2b2;
  377. }
  378. }
  379. .list-view {
  380. width: 100%;
  381. height: 40rpx;
  382. margin-top: 20rpx;
  383. .list-view-file {
  384. width: 132rpx;
  385. height: 44rpx;
  386. line-height: 44rpx;
  387. font-size: $font-size-20;
  388. text-align: center;
  389. color: #ffffff;
  390. background-color: $color-system;
  391. border-radius: 8rpx;
  392. float: left;
  393. margin-top: 10rpx;
  394. }
  395. .list-view-text {
  396. width: 100%;
  397. float: left;
  398. .input {
  399. width: 560rpx;
  400. height: 44rpx;
  401. box-sizing: border-box;
  402. line-height: 44rpx;
  403. color: #333333;
  404. text-overflow: ellipsis;
  405. overflow: hidden;
  406. display: -webkit-box;
  407. -webkit-line-clamp: 1;
  408. line-clamp: 1;
  409. -webkit-box-orient: vertical;
  410. float: left;
  411. }
  412. .delbtn {
  413. width: 96rpx;
  414. height: 44rpx;
  415. border-radius: 8rpx;
  416. background-color: #fff2ec;
  417. font-size: $font-size-24;
  418. color: #e15616;
  419. line-height: 44rpx;
  420. text-align: center;
  421. float: left;
  422. }
  423. }
  424. }
  425. .list-view-upload {
  426. width: 100%;
  427. height: auto;
  428. .photo-item {
  429. display: inline-block;
  430. width: 112rpx;
  431. height: 112rpx;
  432. margin: 10rpx 0;
  433. margin-right: 25rpx;
  434. border-radius: 10rpx;
  435. border: 1px solid #f5f5f5;
  436. position: relative;
  437. float: left;
  438. &.add {
  439. width: 112rpx;
  440. height: 112rpx;
  441. border-color: #b2b2b2;
  442. text-align: center;
  443. line-height: 112rpx;
  444. margin-right: 0rpx;
  445. .icon-jiahao {
  446. font-size: $font-size-44;
  447. color: #b2b2b2;
  448. font-weight: bold;
  449. }
  450. }
  451. .icon-iconfontguanbi {
  452. width: 30rpx;
  453. height: 30rpx;
  454. border-radius: 50%;
  455. display: block;
  456. position: absolute;
  457. right: -10rpx;
  458. top: -10rpx;
  459. background: #f94b4b;
  460. text-align: center;
  461. line-height: 30rpx;
  462. color: #ffffff;
  463. font-size: $font-size-22;
  464. }
  465. image {
  466. width: 112rpx;
  467. height: 112rpx;
  468. border-radius: 10rpx;
  469. }
  470. }
  471. .photo-list {
  472. width: 100%;
  473. height: 116rpx;
  474. overflow: hidden;
  475. white-space: nowrap;
  476. display: flex;
  477. align-items: flex-start;
  478. }
  479. }
  480. }
  481. .remarks-btn {
  482. width: 100%;
  483. padding-top: 20rpx;
  484. position: fixed;
  485. bottom: 0;
  486. left: 0;
  487. background-color: #ffffff;
  488. .edit-button-canel {
  489. width: 100%;
  490. height: 88rpx;
  491. line-height: 88rpx;
  492. text-align: center;
  493. color: #e15616;
  494. font-size: $font-size-24;
  495. }
  496. .edit-button {
  497. width: 600rpx;
  498. height: 90rpx;
  499. background: $btn-confirm;
  500. line-height: 90rpx;
  501. text-align: center;
  502. color: #ffffff;
  503. font-size: $font-size-30;
  504. margin: 0 auto;
  505. border-radius: 45rpx;
  506. }
  507. }
  508. </style>