collection.vue 6.9 KB

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