add-record.vue 12 KB

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