visit.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view style="padding-top: 1rpx;">
  3. <!-- :style="{marginTop:revenueTop+120+'rpx'}" -->
  4. <view style="width: 96%;margin: 20rpx auto;background-color: #fff;border-radius: 20rpx;">
  5. <u-cell-group :border="false">
  6. <u-cell icon="account" title="客户" :value="form.corpName" :isLink="true" @click="selectCustomer">
  7. </u-cell>
  8. <u-cell icon="calendar" title="日期" :value="form.bizDate?form.bizDate.slice(0,10):''" :isLink="true"
  9. @click="show = true"></u-cell>
  10. <u-cell icon="man-add" title="联系人" :isLink="false">
  11. <view slot="right-icon" style="width:400rpx;">
  12. <u--input placeholder="请输入联系人" border="none" inputAlign="right" v-model="form.contacts">
  13. </u--input>
  14. </view>
  15. </u-cell>
  16. <u-cell icon="phone" title="联系电话" :isLink="false">
  17. <view slot="right-icon" style="width:400rpx;">
  18. <u--input placeholder="请输入联系电话" border="none" inputAlign="right" v-model="form.tel"></u--input>
  19. </view>
  20. </u-cell>
  21. <u-cell icon="edit-pen" title="备注" :isLink="false">
  22. <view slot="right-icon" style="width:400rpx;">
  23. <u--textarea :showConfirmBar="false" height="40" v-model="form.remarks" confirmType="return"
  24. placeholder="请输入内容" maxlength="-1" autoHeight border="none"></u--textarea>
  25. </view>
  26. </u-cell>
  27. </u-cell-group>
  28. </view>
  29. <view style="width: 96%;;margin: 0 auto;">
  30. <u-button type="primary" class="custom-style" color="linear-gradient(0deg, #FD5003 0%, #FBA680 100%)" shape="circle" @click="saveOrder" text="确认保存">
  31. </u-button>
  32. </view>
  33. <u-datetime-picker :show="show" v-model="timeValue" mode="date" @confirm="confirm" @cancel="show = false">
  34. </u-datetime-picker>
  35. <u-picker :show="showWarehouse" :columns="columns" keyName="cname" @confirm="confirmWarehouse"
  36. @cancel="showWarehouse = false"></u-picker>
  37. <u-notify ref="uNotify"></u-notify>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. customerList
  43. } from '@/api/views/sale/index.js'
  44. import {
  45. typeSave,
  46. getUserInfo
  47. } from '@/api/views/visit/index.js'
  48. import {
  49. dateFormat
  50. } from '@/common/dateFormat.js'
  51. export default {
  52. data() {
  53. return {
  54. show: false,
  55. showWarehouse: false,
  56. timeValue: Number(new Date()),
  57. columns: [],
  58. dataList: [],
  59. amount: 0.00,
  60. form: {
  61. corpId: '',
  62. corpName: '',
  63. customer: '',
  64. bizDate: '',
  65. storageName: '',
  66. remarks: '',
  67. total: 0
  68. },
  69. revenueTop: 0
  70. }
  71. },
  72. onLoad() {
  73. this.form.bizDate = new Date((new Date()).getTime() + 8 * 60 * 60 * 1000).toJSON().split('T').join(' ').substr(
  74. 0, 19)
  75. uni.getSystemInfo({
  76. success: (e) => {
  77. this.revenueTop = e.statusBarHeight
  78. }
  79. })
  80. },
  81. created() {
  82. let this_ = this
  83. uni.getLocation({
  84. type: 'gcj02',
  85. geocode: true,
  86. success: function(res) {
  87. console.log(res)
  88. let positionName= {
  89. country: res.address.country||'',
  90. province: res.address.province||'',
  91. city: res.address.city||'',
  92. district: res.address.district||'',
  93. street: res.address.street||'',
  94. streetNum: res.address.streetNum||'',
  95. poiName: res.address.poiName||'',
  96. }
  97. this_.form.position = [res.latitude, res.longitude]
  98. this_.form.positionName = positionName.country + positionName.province + positionName.city + positionName.district + positionName.street + positionName.streetNum + positionName.poiName
  99. },
  100. fail: function(err) {
  101. console.log('获取定位失败', err);
  102. uni.showToast({
  103. title: '获取地址失败,将导致部分功能不可用',
  104. icon: 'none'
  105. });
  106. }
  107. });
  108. getUserInfo().then(res => {
  109. this.$set(this.form, 'fromUser', res.data.id);
  110. this.$set(this.form, 'toUser', res.data.id);
  111. })
  112. customerList({
  113. size: 1,
  114. current: 1
  115. }).then(request => {
  116. customerList({
  117. size: request.data.total,
  118. current: 1
  119. }).then(res => {
  120. this.columns = [res.data.records]
  121. })
  122. })
  123. },
  124. onNavigationBarButtonTap(e) {
  125. uni.$u.route('/pages/views/visit/historical0rders');
  126. },
  127. methods: {
  128. deleteProduct(index) {
  129. this.amount = Number(this.amount) - Number(this.dataList[index].amount)
  130. this.amount.toFixed(2)
  131. this.dataList.splice(index, 1)
  132. },
  133. //客户选择返回触发
  134. otherFun(customer) {
  135. this.form.contacts = customer.attn
  136. this.form.tel = customer.tel
  137. this.form.corpName = customer.cname
  138. this.form.corpId = customer.id
  139. this.form.belongToCorpId = customer.belongtocompany
  140. },
  141. selectCustomer() {
  142. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  143. corpType: 'KH'
  144. });
  145. },
  146. confirm(e) {
  147. this.show = false
  148. this.form.bizDate = new Date((new Date(e.value)).getTime() + 8 * 60 * 60 * 1000).toJSON().split('T')
  149. .join(' ').substr(0, 19)
  150. },
  151. confirmWarehouse(e) {
  152. this.form.storageName = e.value[0].cname
  153. this.form.storageId = e.value[0].id
  154. this.showWarehouse = false
  155. },
  156. //保存订单
  157. saveOrder() {
  158. let this_ = this
  159. uni.showModal({
  160. content: '是否确认保存',
  161. success: function(res) {
  162. if (res.confirm) {
  163. if (!this_.form.corpId) return this_.$refs.uNotify.show({
  164. top: this_.revenueTop,
  165. type: 'warning',
  166. message: '请选择客户!'
  167. })
  168. if (!this_.form.bizDate) return this_.$refs.uNotify.show({
  169. top: this_.revenueTop,
  170. type: 'warning',
  171. message: '请选择日期!'
  172. })
  173. uni.showLoading({
  174. title: '操作中',
  175. mask: true
  176. });
  177. let form = {
  178. ...this_.form,
  179. itemList: []
  180. }
  181. typeSave(form).then(res => {
  182. uni.hideLoading();
  183. this_.$refs.uNotify.success('操作成功')
  184. uni.navigateBack()
  185. })
  186. }
  187. }
  188. });
  189. }
  190. }
  191. }
  192. </script>
  193. <style scoped>
  194. .submitBar {
  195. width: 100%;
  196. position: fixed;
  197. bottom: 20rpx;
  198. font-size: 32rpx;
  199. color: #000;
  200. text-align: center;
  201. border-top: 2rpx solid #f2f2f6;
  202. }
  203. .custom-style {
  204. color: #3ab2f7;
  205. margin-top: 40rpx;
  206. box-shadow: 2px 5px 10px 1px rgba(43, 117, 250, 0.3);
  207. }
  208. </style>