CommunicationLogsAdd.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="detail-view">
  3. <u-form label-width="140" ref="uForm">
  4. <view class="form-model-view">
  5. <u-form-item required label="拜访对象">
  6. <u-input class="dis-input" disabled placeholder="请选择" v-model="keyword" @click="goPage('/pagesT/customer/selCustomer')" />
  7. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  8. </u-form-item>
  9. <u-form-item label=" " label-position="top">
  10. <view style="width: 100%;">
  11. <u-input height="150" maxlength="1000" v-model="content" type="textarea" />
  12. <upload :sourceType="['camera']" :images="extend.license ? [extend.license] : []" @handleRemove="imgRemove" @uploadSuccess="uploadSuccess" />
  13. </view>
  14. </u-form-item>
  15. </view>
  16. <view class="address-view">
  17. <u-icon name="map-fill" color="#6c6c6c" size="26"></u-icon>
  18. <text class="text">{{ location || '获取位置' }}</text>
  19. <u-icon @click="locationRegion" name="reload" color="#2979ff" size="28"></u-icon>
  20. </view>
  21. <view class="submit-btn"><button :loading="sub_loading" class="add-btn" @click="addCustomerCommunication">保存提交</button></view>
  22. </u-form>
  23. </view>
  24. </template>
  25. <script>
  26. import upload from '@/components/qiniu/QiniuUpload.vue';
  27. import amap from '@/common/amap-wx.js';
  28. import config from '@/common/config.js';
  29. export default {
  30. components: {
  31. upload
  32. },
  33. data() {
  34. return {
  35. content: '',
  36. id: '',
  37. customerId: '',
  38. time: '',
  39. customerData: '',
  40. keyword: '',
  41. location: '',
  42. picture: '',
  43. staff_id: '',
  44. extend: {
  45. license: ''
  46. },
  47. amapPlugin: null,
  48. sub_loading: false
  49. };
  50. },
  51. onLoad(options) {
  52. this.amapPlugin = new amap.AMapWX({
  53. key: config.gdKey
  54. });
  55. if (options.id) {
  56. (this.id = options.id),
  57. uni.setNavigationBarTitle({
  58. title: '编辑客户拜访'
  59. });
  60. this.getCustomerCommunication(this.id);
  61. } else {
  62. this.locationRegion();
  63. }
  64. console.log(this.$store.state.userInfo,'this.$store.state.userInfo')
  65. },
  66. watch: {
  67. customerData(val) {
  68. if (val) {
  69. this.keyword = val.name;
  70. this.customerId = val.id;
  71. }
  72. }
  73. },
  74. computed: {
  75. staffId() {
  76. return this.$store.state.userInfo.staffId;
  77. }
  78. },
  79. methods: {
  80. // 获取详情
  81. getCustomerCommunication(id) {
  82. this.$u.api.getCustomerCommunication(id).then(res => {
  83. this.content = res.data.content;
  84. this.customerId = res.data.customerId;
  85. this.staff_id = res.data.staffId;
  86. this.time = res.data.createTime;
  87. this.extend.license = res.data.picture;
  88. this.location = res.data.location;
  89. this.keyword = res.data.customerName;
  90. });
  91. },
  92. // 新增
  93. addCustomerCommunication() {
  94. if (!this.keyword) {
  95. this.$u.toast('请选择客户');
  96. return;
  97. }
  98. if (!this.content) {
  99. this.$u.toast('请输入内容');
  100. return;
  101. }
  102. // if (!this.extend.license) {
  103. // this.$u.toast('请上传拜访凭证');
  104. // return;
  105. // }
  106. console.log(this.id,'this.id')
  107. this.sub_loading = true;
  108. if (this.id) {
  109. this.$u.api
  110. .updateCustomerCommunication(this.id, {
  111. customerId: this.customerId,
  112. staffId: this.staff_id,
  113. content: this.content,
  114. time: this.time,
  115. location: this.location,
  116. picture: this.extend.license
  117. })
  118. .then(res => {
  119. this.sub_loading = false;
  120. this.$u.toast('编辑成功');
  121. setTimeout(() => {
  122. uni.navigateBack();
  123. }, 500);
  124. })
  125. .catch(res => {
  126. this.sub_loading = false;
  127. });
  128. } else {
  129. console.log({
  130. customerId: this.customerId,
  131. staffId: this.staffId,
  132. content: this.content,
  133. time: this.time,
  134. location: this.location,
  135. picture: this.extend.license
  136. },'相应数据')
  137. this.$u.api
  138. .addCustomerCommunication({
  139. customerId: this.customerId,
  140. staffId: this.staffId,
  141. content: this.content,
  142. time: this.time,
  143. location: this.location,
  144. picture: this.extend.license
  145. })
  146. .then(res => {
  147. this.sub_loading = false;
  148. this.$u.toast('提交成功');
  149. setTimeout(() => {
  150. uni.navigateBack();
  151. }, 500);
  152. })
  153. .catch(res => {
  154. console.log(res,'shibai+++')
  155. this.sub_loading = false;
  156. });
  157. }
  158. },
  159. locationRegion() {
  160. uni.showLoading({
  161. title: '获取信息中'
  162. });
  163. this.amapPlugin.getRegeo({
  164. success: data => {
  165. console.log(data);
  166. this.location = data[0].name;
  167. uni.hideLoading();
  168. },
  169. fail: err => {
  170. console.log('获取位置失败::', err);
  171. }
  172. });
  173. },
  174. // 图片上传成功
  175. uploadSuccess(imgUrl) {
  176. this.extend.license = imgUrl;
  177. },
  178. //移除图片
  179. imgRemove(arr) {
  180. this.extend.license = '';
  181. }
  182. }
  183. };
  184. </script>
  185. <style scoped lang="scss">
  186. .need-submit {
  187. padding: 30rpx;
  188. padding-top: 50rpx;
  189. }
  190. .add-btn {
  191. width: 690upx;
  192. height: 80upx;
  193. font-size: 32upx;
  194. color: #fff;
  195. border-radius: 10upx;
  196. margin: 0 auto;
  197. background-color: $uni-color-primary;
  198. }
  199. .add-btn:after {
  200. border: 0 none;
  201. }
  202. .address-view {
  203. font-size: 24rpx;
  204. background-color: #ffffff;
  205. line-height: 50rpx;
  206. height: 50rpx;
  207. border-radius: 40rpx;
  208. display: inline-block;
  209. margin: 0 20rpx;
  210. padding: 0 20rpx;
  211. .text {
  212. margin: 0 16rpx 0 8rpx;
  213. }
  214. }
  215. </style>