recordedit.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="page">
  3. <view class="form">
  4. <u-form :model="form" ref="uForm">
  5. <u-form-item label-width="150" label="佣金到款" prop="info1" @click.native="openinfo1Popoup">
  6. <view class="scoped-input-floor" @click.native="openinfo1Popoup"></view>
  7. <u-input placeholder="请选择佣金到款日期" v-model="form.info1" disabled type="text"></u-input>
  8. </u-form-item>
  9. <u-form-item label-width="150" label="回款比例" prop="info2">
  10. <u-input placeholder="请输入回款比例" v-model="form.info2" type="text"></u-input>
  11. <template v-slot:right>
  12. %
  13. </template>
  14. </u-form-item>
  15. <u-form-item label-width="150" label="开票情况" prop="info3">
  16. <u-radio-group v-model="form.info3" active-color="#2979ff">
  17. <u-radio name="1">有开</u-radio>
  18. <u-radio name="2">没有</u-radio>
  19. </u-radio-group>
  20. </u-form-item>
  21. <u-form-item label-position="top" label-width="150" label="开票或返佣凭证" prop="info4">
  22. <view class="id_card" @click="uploadInfo4Image">
  23. <u-icon v-if="form.info4 == null" name="plus" size="32" color="#606266"></u-icon>
  24. <text v-if="form.info4 == null">请先上传开票或返佣凭证照片</text>
  25. <image v-if="form.info4 != null" :src="form.info4" mode="aspectFill"></image>
  26. </view>
  27. </u-form-item>
  28. <u-form-item label-width="150" label="备注信息" prop="remark" required label-position="top">
  29. <u-input :placeholder="remarkTips" v-model="form.remark" type="textarea"></u-input>
  30. </u-form-item>
  31. </u-form>
  32. <u-gap height="60"></u-gap>
  33. <u-button type="primary" @click="submitHandle">提交</u-button>
  34. </view>
  35. <!-- utoast -->
  36. <u-toast ref="uToast" />
  37. <u-calendar v-model="info1Show" mode="date" @change="info1Change"></u-calendar>
  38. </view>
  39. </template>
  40. <script>
  41. import { arrToObj } from '@/utils'
  42. export default {
  43. data() {
  44. return {
  45. info1Show: false,
  46. form: {
  47. info1: '',
  48. info2: '',
  49. info3: '1',
  50. info4: null,
  51. remark: null,
  52. },
  53. trade_id: null,
  54. rules: {
  55. remark: [
  56. {
  57. required: true,
  58. message: '备注不能为空',
  59. trigger: ['change']
  60. },
  61. ],
  62. },
  63. remarkTips: '请输入',
  64. };
  65. },
  66. onLoad(data) {
  67. this.trade_id = data.id
  68. },
  69. created() {
  70. },
  71. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  72. onReady() {
  73. this.$refs.uForm.setRules(this.rules);
  74. },
  75. methods: {
  76. uploadImgHandle (bc) {
  77. uni.chooseImage({
  78. count: 1,
  79. sizeType: ['compressed'],
  80. success: function(res) {
  81. const filePath = res.tempFilePaths[0];
  82. let token = uni.getStorageSync('MD_token') || ''
  83. uni.uploadFile({
  84. url: uni.baseUrl + 'api/upload/cloud',
  85. filePath,
  86. name: 'upload',
  87. formData: {
  88. 'token': token
  89. },
  90. success: (f) => {
  91. const cData = JSON.parse(f.data)
  92. if (cData.errno === 0) {
  93. if (bc && typeof(bc) === 'function') bc(cData.data)
  94. } else {
  95. uni.$msg(cData.errmsg || `未知错误-${cData.errno}`)
  96. }
  97. }
  98. })
  99. }
  100. })
  101. },
  102. // 选择上传照片
  103. uploadInfo4Image() {
  104. this.uploadImgHandle((d) => {
  105. this.form.info4 = d.url
  106. // this.info4 = d.pub_url
  107. this.info4 = d.url
  108. })
  109. },
  110. openinfo1Popoup () {
  111. this.info1Show = true
  112. },
  113. info1Change (e) {
  114. this.form.info1 = e.result || ''
  115. },
  116. submitHandle() {
  117. const that = this
  118. this.$refs.uForm.validate(valid => {
  119. if (valid) {
  120. // 验证成功
  121. let apiStr = 'apitraderecordadd'
  122. let params = {
  123. remark: that.form.remark,
  124. info1: that.form.info1 || '',
  125. info2: that.form.info2 || '',
  126. info3: that.form.info3 || '1',
  127. info4: that.form.info4 || '',
  128. trade_id: that.trade_id
  129. }
  130. if (that.isEdit) {
  131. apiStr = 'apitraderecordedit'
  132. params.id = that.form.id
  133. }
  134. uni.api.cust[apiStr](params).then(res => {
  135. if (that.isEdit) {
  136. uni.$msgConfirm('编辑成功', () => {
  137. uni.navigateBack()
  138. }, () => {
  139. uni.navigateBack()
  140. })
  141. } else {
  142. uni.$msgConfirm('添加跟进记录成功,是否前往列表?', () => {
  143. uni.navigateBack()
  144. }, () => {
  145. that.imgArr = []
  146. that.form = {
  147. remark: null,
  148. }
  149. })
  150. }
  151. })
  152. } else {
  153. console.log('验证失败');
  154. }
  155. });
  156. },
  157. }
  158. };
  159. </script>
  160. <style lang="scss">
  161. .page {
  162. padding: 20rpx;
  163. background-color: #ffffff;
  164. }
  165. .form {
  166. border-radius: 10rpx;
  167. padding: 0 40rpx;
  168. }
  169. .popup-body {
  170. .tips-title {
  171. font-size: $u-p;
  172. margin-bottom: 20rpx;
  173. }
  174. .tips-content {
  175. font-size: $u-p2;
  176. color: $u-tips-color;
  177. margin-bottom: 60rpx;
  178. }
  179. }
  180. .id_card {
  181. color: #606266;
  182. width: 100%;
  183. height: 350rpx;
  184. display: flex;
  185. flex-direction: column;
  186. align-items: center;
  187. justify-content: center;
  188. background-color: #f4f5f6;
  189. font-size: $u-p2;
  190. }
  191. .footer {
  192. position: absolute;
  193. text-align: center;
  194. bottom: 40rpx;
  195. font-size: $u-p2;
  196. .agreement {
  197. color: $u-type-error;
  198. }
  199. }
  200. .slot-content {
  201. font-size: 28rpx;
  202. color: $u-content-color;
  203. padding: 20rpx;
  204. }
  205. .scoped-input-floor {
  206. position: absolute;
  207. left: 0;
  208. top: 0;
  209. width: 100%;
  210. height: 100%;
  211. background: transparent;
  212. z-index: 9;
  213. }
  214. </style>