transfer.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-02-17 14:33:19
  6. * @Description: file content
  7. * @FilePath: \oms\pages\project\transfer.vue
  8. -->
  9. <template>
  10. <view class="home">
  11. <view class="nav">
  12. <view :style="{ paddingTop }">
  13. <view class="title" :style="[{ height }, { lineHeight: height }]">
  14. <view class="back" @click="goBack()">
  15. <u-icon name="arrow-left" color="#ffffff" size="22"></u-icon>
  16. </view>
  17. <text>项目转移</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="main">
  22. <u-form :model="transferObj" :rules="rules" ref="addForm" label-width="0">
  23. <u-form-item prop="userName" borderBottom customStyle="padding:40rpx 0 30rpx" @click="$refs.user.open()">
  24. <view class="form-label flex_l">
  25. <view class="label-tag"></view>
  26. 接收对象
  27. </view>
  28. <u-input
  29. v-model="transferObj.userName"
  30. disabled
  31. disabledColor="#ffffff"
  32. placeholder="请选择接收对象"
  33. border="none"></u-input>
  34. <u-icon slot="right" name="arrow-right"></u-icon>
  35. </u-form-item>
  36. <u-form-item prop="remark" customStyle="padding:40rpx 0 30rpx">
  37. <view class="form-label flex_l">
  38. <view class="label-tag"></view>
  39. 转移原因
  40. </view>
  41. <u-textarea
  42. fontSize="26rpx"
  43. v-model="transferObj.remark"
  44. placeholder="请输入转移原因"
  45. height="180"
  46. :count="true"
  47. maxlength="300"></u-textarea>
  48. </u-form-item>
  49. </u-form>
  50. <view class="save" @click="handleAdd" :class="!flag ? 'disabledBtn' : ''">保存</view>
  51. </view>
  52. <u-notify ref="uNotify"></u-notify>
  53. <u-toast ref="uToast"></u-toast>
  54. <select-user ref="user" @close="closeUser($event)"></select-user>
  55. </view>
  56. </template>
  57. <script>
  58. import projectApi from '../../api/project'
  59. import SelectUser from '../../components/SelectUser'
  60. import to from 'await-to-js'
  61. export default {
  62. name: 'omsIndex',
  63. components: { SelectUser },
  64. data() {
  65. return {
  66. flag: true,
  67. height: '',
  68. paddingTop: '',
  69. transferObj: {
  70. remark: '',
  71. userId: null, //接收对象id
  72. userName: '', //接收对象name
  73. id: 0, //客户id
  74. },
  75. rules: {
  76. userName: {
  77. type: 'string',
  78. required: true,
  79. message: '请选择转移对象',
  80. trigger: ['blur'],
  81. },
  82. remark: {
  83. type: 'string',
  84. required: true,
  85. message: '请输入转移原因',
  86. trigger: ['blur', 'change'],
  87. },
  88. },
  89. }
  90. },
  91. created() {
  92. const navData = uni.getMenuButtonBoundingClientRect()
  93. this.height = navData.height + 'px'
  94. this.paddingTop = navData.top + 'px'
  95. },
  96. onLoad(option) {
  97. this.transferObj.id = parseInt(option.id)
  98. },
  99. onShow() {},
  100. methods: {
  101. handleAdd() {
  102. if (!this.flag) return
  103. this.$refs.addForm
  104. .validate()
  105. .then(async () => {
  106. let params = this.transferObj
  107. this.flag = false
  108. const [err, res] = await to(projectApi.transfer(params))
  109. this.flag = true
  110. if (err) return
  111. if (res && res.code == 200) {
  112. this.$refs.uToast.show({
  113. type: 'success',
  114. message: '转移成功',
  115. complete: () => {
  116. this.goBack()
  117. },
  118. })
  119. }
  120. })
  121. .catch((err) => {
  122. this.$refs.uNotify.show({
  123. top: this.height + this.paddingTop + 10,
  124. type: 'warning',
  125. message: err[0].message,
  126. duration: 1000 * 3,
  127. })
  128. })
  129. },
  130. closeUser(user) {
  131. if (user) {
  132. this.transferObj.userId = user.id
  133. this.transferObj.userName = user.label
  134. }
  135. },
  136. goBack() {
  137. uni.navigateBack({
  138. //关闭当前页面,返回上一页面或多级页面。
  139. delta: 1,
  140. })
  141. },
  142. },
  143. }
  144. </script>
  145. <style>
  146. page {
  147. background: #f2f3f5;
  148. }
  149. </style>
  150. <style lang="scss" scoped>
  151. .home {
  152. padding-top: 188rpx;
  153. .nav {
  154. position: absolute;
  155. left: 0;
  156. top: 0;
  157. width: 100%;
  158. height: 284rpx;
  159. background: #3e7ef8;
  160. .title {
  161. position: relative;
  162. text-align: center;
  163. font-size: 32rpx;
  164. font-weight: bold;
  165. color: #ffffff;
  166. .back {
  167. position: absolute;
  168. top: 0;
  169. bottom: 0;
  170. margin: auto;
  171. left: 70rpx;
  172. display: flex;
  173. }
  174. }
  175. }
  176. .main {
  177. position: absolute;
  178. width: 100%;
  179. height: calc(100vh - 188rpx);
  180. background: #ffffff;
  181. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  182. border-radius: 31rpx 31rpx 0 0;
  183. padding: 0 32rpx;
  184. overflow: auto;
  185. padding-bottom: 64rpx;
  186. .form-label {
  187. font-size: 32rpx;
  188. font-weight: bold;
  189. color: #323232;
  190. padding-bottom: 18rpx;
  191. .label-tag {
  192. width: 15rpx;
  193. height: 15rpx;
  194. background: #ff4d4f;
  195. border-radius: 50%;
  196. margin-right: 10rpx;
  197. }
  198. }
  199. .save {
  200. width: 569rpx;
  201. height: 92rpx;
  202. background: #3e7ef8;
  203. border-radius: 31rpx;
  204. margin: 116rpx auto 0;
  205. font-size: 32rpx;
  206. color: #ffffff;
  207. text-align: center;
  208. line-height: 92rpx;
  209. }
  210. }
  211. }
  212. </style>