collection.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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" :class="!flag ? 'disabledBtn' : ''">保存</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. flag: true,
  76. height: '',
  77. paddingTop: '',
  78. form: {
  79. planId: null, //计划回款id
  80. collectionDatetime: '', //回款日期
  81. contractCode: '', //合同编号
  82. contractId: null, //合同id
  83. collectionAmount: '', //回款金额
  84. collectionType: '', //回款方式
  85. collectionName: '',
  86. remark: '', //备注
  87. },
  88. rules: {
  89. contractCode: [
  90. {
  91. required: true,
  92. trigger: 'blur',
  93. message: '请选择合同',
  94. },
  95. ],
  96. collectionAmount: [
  97. {
  98. required: true,
  99. trigger: 'blur',
  100. message: '请输入回款金额',
  101. },
  102. ],
  103. collectionDatetime: [
  104. {
  105. required: true,
  106. trigger: 'change',
  107. message: '请选择回款日期',
  108. },
  109. ],
  110. },
  111. show: false,
  112. showPicker: false,
  113. collectionTypeOption: [],
  114. }
  115. },
  116. created() {
  117. const navData = uni.getMenuButtonBoundingClientRect()
  118. this.height = navData.height + 'px'
  119. this.paddingTop = navData.top + 'px'
  120. this.getOptions()
  121. },
  122. onLoad(option) {
  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. if (!this.flag) return
  147. let params = {
  148. ...this.form,
  149. }
  150. delete params.collectionName
  151. params.collectionAmount = parseInt(params.collectionAmount)
  152. this.$refs.form
  153. .validate()
  154. .then(async (valid) => {
  155. if (valid) {
  156. this.flag = false
  157. const [err, res] = await to(api.addCollection(params))
  158. this.flag = true
  159. if (err) return
  160. this.$refs.uToast.show({
  161. type: 'success',
  162. message: '创建成功',
  163. complete: () => {
  164. this.goBack()
  165. },
  166. })
  167. }
  168. })
  169. .catch((errors) => {})
  170. },
  171. goBack() {
  172. uni.navigateBack({
  173. //关闭当前页面,返回上一页面或多级页面。
  174. delta: 1,
  175. })
  176. },
  177. },
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .home {
  182. padding-top: 188rpx;
  183. .nav {
  184. position: absolute;
  185. left: 0;
  186. top: 0;
  187. width: 100%;
  188. height: 284rpx;
  189. background: #3e7ef8;
  190. .title {
  191. position: relative;
  192. text-align: center;
  193. font-size: 32rpx;
  194. font-weight: bold;
  195. color: #ffffff;
  196. .back {
  197. position: absolute;
  198. top: 0;
  199. bottom: 0;
  200. margin: auto;
  201. left: 70rpx;
  202. display: flex;
  203. }
  204. }
  205. }
  206. .main {
  207. position: absolute;
  208. width: 100%;
  209. height: calc(100vh - 190rpx);
  210. background: #ffffff;
  211. border-radius: 31rpx 31rpx 0 0;
  212. padding: 0 32rpx;
  213. overflow: auto;
  214. padding-bottom: 64rpx;
  215. .form-label {
  216. font-size: 32rpx;
  217. font-weight: bold;
  218. color: #323232;
  219. padding-bottom: 18rpx;
  220. .label-tag {
  221. width: 15rpx;
  222. height: 15rpx;
  223. background: #ff4d4f;
  224. border-radius: 50%;
  225. margin-right: 10rpx;
  226. }
  227. }
  228. .save {
  229. width: 100%;
  230. height: 92rpx;
  231. background: #3e7ef8;
  232. border-radius: 31rpx;
  233. margin: 60rpx auto 0;
  234. font-size: 32rpx;
  235. color: #ffffff;
  236. text-align: center;
  237. line-height: 92rpx;
  238. }
  239. }
  240. }
  241. </style>