collection.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. this.form.contractId = parseInt(option.id)
  123. this.form.contractCode = option.code
  124. },
  125. methods: {
  126. getOptions() {
  127. Promise.all([this.getDicts('collection_type')])
  128. .then(([collectionType]) => {
  129. this.collectionTypeOption = collectionType.data.values || []
  130. this.collectionTypeOption.forEach((item) => (item.name = item.value))
  131. })
  132. .catch((err) => console.log(err))
  133. },
  134. closeMoveInModel() {},
  135. confirmCalendar(val) {
  136. this.form.collectionDatetime = val[0]
  137. this.show = false
  138. },
  139. selectClick(val) {
  140. this.form.collectionType = val.key
  141. this.form.collectionName = val.value
  142. this.showPicker = false
  143. },
  144. async save() {
  145. let params = {
  146. ...this.form,
  147. }
  148. delete params.collectionName
  149. params.collectionAmount = parseInt(params.collectionAmount)
  150. this.$refs.form
  151. .validate()
  152. .then(async (valid) => {
  153. if (valid) {
  154. const [err, res] = await to(api.addCollection(params))
  155. if (err) return
  156. this.$refs.uToast.show({
  157. type: 'success',
  158. message: '创建成功',
  159. complete: () => {
  160. this.goBack()
  161. },
  162. })
  163. }
  164. })
  165. .catch((errors) => {})
  166. },
  167. goBack() {
  168. uni.navigateBack({
  169. //关闭当前页面,返回上一页面或多级页面。
  170. delta: 1,
  171. })
  172. },
  173. },
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .home {
  178. padding-top: 188rpx;
  179. .nav {
  180. position: absolute;
  181. left: 0;
  182. top: 0;
  183. width: 100%;
  184. height: 284rpx;
  185. background: #3e7ef8;
  186. .title {
  187. position: relative;
  188. text-align: center;
  189. font-size: 32rpx;
  190. font-weight: bold;
  191. color: #ffffff;
  192. .back {
  193. position: absolute;
  194. top: 0;
  195. bottom: 0;
  196. margin: auto;
  197. left: 70rpx;
  198. display: flex;
  199. }
  200. }
  201. }
  202. .main {
  203. position: absolute;
  204. width: 100%;
  205. height: calc(100vh - 280rpx);
  206. background: #ffffff;
  207. border-radius: 31rpx 31rpx 0 0;
  208. padding: 0 32rpx;
  209. overflow: auto;
  210. padding-bottom: 64rpx;
  211. .form-label {
  212. font-size: 32rpx;
  213. font-weight: bold;
  214. color: #323232;
  215. padding-bottom: 18rpx;
  216. .label-tag {
  217. width: 15rpx;
  218. height: 15rpx;
  219. background: #ff4d4f;
  220. border-radius: 50%;
  221. margin-right: 10rpx;
  222. }
  223. }
  224. .save {
  225. position: fixed;
  226. bottom: 0;
  227. left: 0;
  228. width: 100%;
  229. height: 92rpx;
  230. background: #3e7ef8;
  231. border-radius: 31rpx 31rpx 0 0;
  232. margin: 116rpx auto 0;
  233. font-size: 32rpx;
  234. color: #ffffff;
  235. text-align: center;
  236. line-height: 92rpx;
  237. }
  238. }
  239. }
  240. </style>