CommunicationLogsAdd.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. },
  65. watch: {
  66. customerData(val) {
  67. if (val) {
  68. this.keyword = val.name;
  69. this.customerId = val.id;
  70. }
  71. }
  72. },
  73. computed: {
  74. staffId() {
  75. return this.$store.state.userInfo.staffId;
  76. }
  77. },
  78. methods: {
  79. // 获取详情
  80. getCustomerCommunication(id) {
  81. this.$u.api.getCustomerCommunication(id).then(res => {
  82. this.content = res.data.content;
  83. this.customerId = res.data.customerId;
  84. this.staff_id = res.data.staffId;
  85. this.time = res.data.createTime;
  86. this.extend.license = res.data.picture;
  87. this.location = res.data.location;
  88. this.keyword = res.data.customerName;
  89. });
  90. },
  91. // 新增
  92. addCustomerCommunication() {
  93. if (!this.keyword) {
  94. this.$u.toast('请选择客户');
  95. return;
  96. }
  97. if (!this.content) {
  98. this.$u.toast('请输入内容');
  99. return;
  100. }
  101. // if (!this.extend.license) {
  102. // this.$u.toast('请上传拜访凭证');
  103. // return;
  104. // }
  105. this.sub_loading = true;
  106. if (this.id) {
  107. this.$u.api
  108. .updateCustomerCommunication(this.id, {
  109. customerId: this.customerId,
  110. staffId: this.staff_id,
  111. content: this.content,
  112. time: this.time,
  113. location: this.location,
  114. picture: this.extend.license
  115. })
  116. .then(res => {
  117. this.sub_loading = false;
  118. this.$u.toast('编辑成功');
  119. setTimeout(() => {
  120. uni.navigateBack();
  121. }, 500);
  122. })
  123. .catch(res => {
  124. this.sub_loading = false;
  125. });
  126. } else {
  127. this.$u.api
  128. .addCustomerCommunication({
  129. customerId: this.customerId,
  130. staffId: this.staffId,
  131. content: this.content,
  132. time: this.time,
  133. location: this.location,
  134. picture: this.extend.license
  135. })
  136. .then(res => {
  137. this.sub_loading = false;
  138. this.$u.toast('提交成功');
  139. setTimeout(() => {
  140. uni.navigateBack();
  141. }, 500);
  142. })
  143. .catch(res => {
  144. this.sub_loading = false;
  145. });
  146. }
  147. },
  148. locationRegion() {
  149. uni.showLoading({
  150. title: '获取信息中'
  151. });
  152. this.amapPlugin.getRegeo({
  153. success: data => {
  154. console.log(data);
  155. this.location = data[0].name;
  156. uni.hideLoading();
  157. },
  158. fail: err => {
  159. console.log('获取位置失败::', err);
  160. }
  161. });
  162. },
  163. // 图片上传成功
  164. uploadSuccess(imgUrl) {
  165. this.extend.license = imgUrl;
  166. },
  167. //移除图片
  168. imgRemove(arr) {
  169. this.extend.license = '';
  170. }
  171. }
  172. };
  173. </script>
  174. <style scoped lang="scss">
  175. .need-submit {
  176. padding: 30rpx;
  177. padding-top: 50rpx;
  178. }
  179. .add-btn {
  180. width: 690upx;
  181. height: 80upx;
  182. font-size: 32upx;
  183. color: #fff;
  184. border-radius: 10upx;
  185. margin: 0 auto;
  186. background-color: $uni-color-primary;
  187. }
  188. .add-btn:after {
  189. border: 0 none;
  190. }
  191. .address-view {
  192. font-size: 24rpx;
  193. background-color: #ffffff;
  194. line-height: 50rpx;
  195. height: 50rpx;
  196. border-radius: 40rpx;
  197. display: inline-block;
  198. margin: 0 20rpx;
  199. padding: 0 20rpx;
  200. .text {
  201. margin: 0 16rpx 0 8rpx;
  202. }
  203. }
  204. </style>