collection.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <!-- 新建回款 -->
  3. <view class="home">
  4. <view class="nav">
  5. <view :style="{ paddingTop }">
  6. <view class="title" :style="[{ height }, { lineHeight: height }]">
  7. <view class="back" @click="goBack()">
  8. <u-icon name="arrow-left" color="#ffffff" size="22"></u-icon>
  9. </view>
  10. <text>新建回款</text>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="main">
  15. <u-form :model="form" :rules="rules" ref="form" label-width="0">
  16. <u-form-item prop="contractCode">
  17. <view class="form-label flex_l">
  18. <view class="label-tag"></view>
  19. 合同编号
  20. </view>
  21. <u-input v-model="form.contractCode" disabled />
  22. </u-form-item>
  23. <u-form-item prop="collectionAmount">
  24. <view class="form-label flex_l">
  25. <view class="label-tag"></view>
  26. 回款金额
  27. </view>
  28. <u-input v-model.number="form.collectionAmount" placeholder="请输入回款金额" />
  29. </u-form-item>
  30. <u-form-item prop="collectionDatetime" @click="show = true">
  31. <view class="form-label flex_l">
  32. <view class="label-tag"></view>
  33. 回款日期
  34. </view>
  35. <u-input v-model="form.collectionDatetime" disabled disabledColor="#ffffff" placeholder="请选择回款日期"></u-input>
  36. </u-form-item>
  37. <u-form-item prop="collectionType" @click="showPicker = true">
  38. <view class="form-label flex_l">
  39. <view class="label-tag"></view>
  40. 回款方式
  41. </view>
  42. <u-input v-model="form.collectionName" disabled disabledColor="#ffffff" placeholder="请选择回款方式" />
  43. </u-form-item>
  44. <u-form-item prop="remark">
  45. <view class="form-label flex_l">
  46. <view class="label-tag"></view>
  47. 备注
  48. </view>
  49. <u-textarea fontSize="26rpx" v-model="form.remark" placeholder="输入备注" height="180" :count="true"
  50. maxlength="300"></u-textarea>
  51. </u-form-item>
  52. </u-form>
  53. <view class="save" @click="save">保存</view>
  54. </view>
  55. <u-calendar :show="show" @confirm="confirmCalendar" @close="show = false"></u-calendar>
  56. <u-action-sheet :actions="collectionTypeOption" @select="selectClick" :show="showPicker"></u-action-sheet>
  57. <u-toast ref="uToast"></u-toast>
  58. </view>
  59. </template>
  60. <script>
  61. import api from '@/api/contract'
  62. import to from 'await-to-js'
  63. export default {
  64. data() {
  65. return {
  66. height: '',
  67. paddingTop: '',
  68. form: {
  69. planId: null, //计划回款id
  70. collectionDatetime: '', //回款日期
  71. contractCode: '', //合同编号
  72. contractId: null, //合同id
  73. collectionAmount: '', //回款金额
  74. collectionType: '', //回款方式
  75. collectionName:'',
  76. remark: '', //备注
  77. },
  78. rules: {
  79. contractCode: [{
  80. required: true,
  81. trigger: 'blur',
  82. message: '请选择合同'
  83. }],
  84. collectionAmount: [{
  85. required: true,
  86. trigger: 'blur',
  87. message: '请输入回款金额'
  88. }],
  89. collectionDatetime: [{
  90. required: true,
  91. trigger: 'change',
  92. message: '请选择回款日期'
  93. }, ],
  94. },
  95. show: false,
  96. showPicker: false,
  97. collectionTypeOption: []
  98. }
  99. },
  100. created() {
  101. const navData = uni.getMenuButtonBoundingClientRect()
  102. this.height = navData.height + 'px'
  103. this.paddingTop = navData.top + 'px'
  104. this.getOptions()
  105. },
  106. onLoad(option) {
  107. console.log(option.id) //打印出上个页面传递的参数。
  108. this.form.contractId = parseInt(option.id)
  109. this.form.contractCode = option.code
  110. },
  111. methods: {
  112. getOptions() {
  113. Promise.all([this.getDicts('collection_type')])
  114. .then(([collectionType]) => {
  115. this.collectionTypeOption = collectionType.data.values || []
  116. this.collectionTypeOption.forEach(item => item.name = item.value)
  117. })
  118. .catch((err) => console.log(err))
  119. },
  120. closeMoveInModel() {
  121. },
  122. confirmCalendar(val) {
  123. this.form.collectionDatetime = val[0]
  124. this.show = false
  125. },
  126. selectClick(val) {
  127. this.form.collectionType = val.key
  128. this.form.collectionName = val.value
  129. this.showPicker = false
  130. },
  131. async save() {
  132. let params = {
  133. ...this.form
  134. }
  135. delete params.collectionName
  136. params.collectionAmount = parseInt(params.collectionAmount)
  137. this.$refs.form.validate().then(async valid => {
  138. if (valid) {
  139. console.log(valid);
  140. const [err, res] = await to(api.addCollection(params))
  141. if (err) return
  142. this.$refs.uToast.show({
  143. type: 'success',
  144. message: '创建成功',
  145. complete: () => {
  146. this.goBack()
  147. },
  148. })
  149. }
  150. }).catch(errors => {})
  151. },
  152. goBack() {
  153. uni.navigateBack({
  154. //关闭当前页面,返回上一页面或多级页面。
  155. delta: 1,
  156. })
  157. },
  158. },
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. .home {
  163. padding-top: 188rpx;
  164. .nav {
  165. position: absolute;
  166. left: 0;
  167. top: 0;
  168. width: 100%;
  169. height: 284rpx;
  170. background: #3e7ef8;
  171. .title {
  172. position: relative;
  173. text-align: center;
  174. font-size: 32rpx;
  175. font-weight: bold;
  176. color: #ffffff;
  177. .back {
  178. position: absolute;
  179. top: 0;
  180. bottom: 0;
  181. margin: auto;
  182. left: 70rpx;
  183. display: flex;
  184. }
  185. }
  186. }
  187. .main {
  188. position: absolute;
  189. width: 100%;
  190. height: calc(100vh - 280rpx);
  191. background: #ffffff;
  192. border-radius: 31rpx 31rpx 0 0;
  193. padding: 0 32rpx;
  194. overflow: auto;
  195. padding-bottom: 64rpx;
  196. .form-label {
  197. font-size: 32rpx;
  198. font-weight: bold;
  199. color: #323232;
  200. padding-bottom: 18rpx;
  201. .label-tag {
  202. width: 15rpx;
  203. height: 15rpx;
  204. background: rgba(62, 126, 248, 0.6);
  205. border-radius: 50%;
  206. margin-right: -4rpx;
  207. }
  208. }
  209. .save {
  210. position: fixed;
  211. bottom: 0;
  212. left: 0;
  213. width: 100%;
  214. height: 92rpx;
  215. background: #3e7ef8;
  216. border-radius: 31rpx 31rpx 0 0;
  217. margin: 116rpx auto 0;
  218. font-size: 32rpx;
  219. color: #ffffff;
  220. text-align: center;
  221. line-height: 92rpx;
  222. }
  223. }
  224. }
  225. </style>