concatCreate.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-03-22 10:41:11
  6. * @Description: file content
  7. * @FilePath: \oms\pages\publicPages\concatCreate.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="addForm" :rules="rules" ref="addForm" label-width="0">
  23. <u-form-item prop="cuctName" customStyle="padding:40rpx 0 34rpx" borderBottom>
  24. <view class="form-label flex_l">
  25. <view class="label-tag"></view>
  26. 姓名
  27. </view>
  28. <u-input border="none" v-model="addForm.cuctName" placeholder="请输入姓名"></u-input>
  29. </u-form-item>
  30. <u-form-item prop="custName" customStyle="padding:40rpx 0 34rpx" borderBottom>
  31. <view class="form-label flex_l">
  32. <view class="label-tag"></view>
  33. 客户名称
  34. </view>
  35. <u-input disabled border="none" v-model="addForm.custName" placeholder="请输入客户名称"></u-input>
  36. </u-form-item>
  37. <u-form-item prop="telephone" customStyle="padding:40rpx 0 34rpx" borderBottom>
  38. <view class="form-label flex_l">手机号码</view>
  39. <u-input border="none" maxlength="11" v-model="addForm.telephone" placeholder="请输入手机号码"></u-input>
  40. </u-form-item>
  41. <u-form-item prop="wechat" customStyle="padding:40rpx 0 34rpx" borderBottom>
  42. <view class="form-label flex_l">微信</view>
  43. <u-input border="none" v-model="addForm.wechat" placeholder="请输入微信"></u-input>
  44. </u-form-item>
  45. <u-form-item prop="email" customStyle="padding:40rpx 0 34rpx" borderBottom>
  46. <view class="form-label flex_l">邮箱</view>
  47. <u-input border="none" v-model="addForm.email" placeholder="请输入邮箱"></u-input>
  48. </u-form-item>
  49. <u-form-item prop="dept" customStyle="padding:40rpx 0 34rpx" borderBottom>
  50. <view class="form-label flex_l">部门</view>
  51. <u-input border="none" v-model="addForm.dept" placeholder="请输入部门"></u-input>
  52. </u-form-item>
  53. <u-form-item prop="postion" customStyle="padding:40rpx 0 34rpx" borderBottom>
  54. <view class="form-label flex_l">
  55. <view class="label-tag"></view>
  56. 职务
  57. </view>
  58. <u-input border="none" v-model="addForm.postion" placeholder="请输入职务"></u-input>
  59. </u-form-item>
  60. <u-form-item prop="officeLocation" customStyle="padding:40rpx 0 34rpx" borderBottom>
  61. <view class="form-label flex_l">办公地点</view>
  62. <u-input border="none" v-model="addForm.officeLocation" placeholder="请输入办公地点"></u-input>
  63. </u-form-item>
  64. <u-form-item prop="isDecision" customStyle="padding:40rpx 0 34rpx" borderBottom>
  65. <view class="form-label flex_l">
  66. <view class="label-tag"></view>
  67. 是否关键决策人
  68. </view>
  69. <u-radio-group v-model="addForm.isDecision" placement="row">
  70. <u-radio name="10" label="是" customStyle="margin-right:14rpx"></u-radio>
  71. <u-radio name="20" label="否"></u-radio>
  72. </u-radio-group>
  73. </u-form-item>
  74. <u-form-item prop="isDecision" customStyle="padding:40rpx 0 34rpx" borderBottom>
  75. <view class="form-label flex_l">
  76. <view class="label-tag"></view>
  77. 性别
  78. </view>
  79. <u-radio-group v-model="addForm.cuctGender" placement="row">
  80. <u-radio name="10" label="男" customStyle="margin-right:14rpx"></u-radio>
  81. <u-radio name="20" label="女"></u-radio>
  82. </u-radio-group>
  83. </u-form-item>
  84. </u-form>
  85. <view class="center">
  86. <view class="handle-btn" @click="handleAdd">保存</view>
  87. </view>
  88. </view>
  89. <u-notify ref="uNotify"></u-notify>
  90. <u-toast ref="uToast"></u-toast>
  91. </view>
  92. </template>
  93. <script>
  94. import to from 'await-to-js'
  95. import customerApi from '../../api/customer'
  96. export default {
  97. name: 'omsIndex',
  98. data() {
  99. return {
  100. height: '',
  101. paddingTop: '',
  102. addForm: {
  103. cuctName: '',
  104. telephone: '',
  105. wechat: '',
  106. email: '',
  107. dept: '',
  108. postion: '',
  109. officeLocation: '',
  110. custId: 0,
  111. custName: '',
  112. isDecision: '20', //是否决策人 (10是20否)
  113. cuctGender: '10', //性别(10男20女)
  114. },
  115. rules: {
  116. cuctName: { required: true, trigger: ['blur'], message: '请输入联系人姓名' },
  117. custName: { required: true, trigger: ['blur'], message: '请输入客户名称' },
  118. cuctGender: { required: true, trigger: ['blur'], message: '请输入性别' },
  119. postion: { required: true, trigger: ['blur'], message: '请输入岗位名称' },
  120. telephone: [
  121. {
  122. validator: (rule, value, callback) => {
  123. if (value !== '') {
  124. const reg = /^1[3456789]\d{9}$/
  125. if (!reg.test(value)) {
  126. callback(new Error('手机号格式不正确'))
  127. } else {
  128. callback()
  129. }
  130. } else {
  131. callback()
  132. }
  133. },
  134. },
  135. ],
  136. },
  137. }
  138. },
  139. onLoad(option) {
  140. console.log(option)
  141. this.addForm.custId = Number(option.id)
  142. this.addForm.custName = option.name
  143. },
  144. created() {
  145. const navData = uni.getMenuButtonBoundingClientRect()
  146. this.height = navData.height + 'px'
  147. this.paddingTop = navData.top + 'px'
  148. },
  149. mounted() {},
  150. methods: {
  151. handleAdd() {
  152. this.$refs.addForm
  153. .validate()
  154. .then(async () => {
  155. let params = this.addForm
  156. console.log(params)
  157. const [err, res] = await to(customerApi.createContact(params))
  158. if (err) return
  159. if (res && res.code == 200) {
  160. this.$refs.uToast.show({
  161. type: 'success',
  162. message: '创建成功',
  163. complete: () => {
  164. uni.navigateBack({
  165. //关闭当前页面,返回上一页面或多级页面。
  166. delta: 1,
  167. })
  168. },
  169. })
  170. }
  171. })
  172. .catch((err) => {
  173. console.log(err)
  174. this.$refs.uNotify.show({
  175. top: this.height + this.paddingTop + 10,
  176. type: 'warning',
  177. message: err[0].message,
  178. duration: 1000 * 3,
  179. })
  180. })
  181. },
  182. goBack() {
  183. uni.navigateBack({
  184. //关闭当前页面,返回上一页面或多级页面。
  185. delta: 1,
  186. })
  187. },
  188. },
  189. }
  190. </script>
  191. <style>
  192. page {
  193. background: #f2f3f5;
  194. }
  195. </style>
  196. <style lang="scss" scoped>
  197. .home {
  198. padding-top: 188rpx;
  199. .nav {
  200. position: absolute;
  201. left: 0;
  202. top: 0;
  203. width: 100%;
  204. height: 284rpx;
  205. background: #3e7ef8;
  206. .title {
  207. position: relative;
  208. text-align: center;
  209. font-size: 32rpx;
  210. font-weight: bold;
  211. color: #ffffff;
  212. .back {
  213. position: absolute;
  214. top: 0;
  215. bottom: 0;
  216. margin: auto;
  217. left: 70rpx;
  218. display: flex;
  219. }
  220. }
  221. }
  222. .main {
  223. position: absolute;
  224. width: 100%;
  225. height: calc(100vh - 188rpx);
  226. background: #ffffff;
  227. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  228. border-radius: 31rpx 31rpx 0 0;
  229. padding: 0 32rpx;
  230. overflow: auto;
  231. padding-bottom: 64rpx;
  232. .form-label {
  233. font-size: 32rpx;
  234. font-weight: bold;
  235. color: #323232;
  236. padding-bottom: 18rpx;
  237. .label-tag {
  238. width: 15rpx;
  239. height: 15rpx;
  240. background: #ff4d4f;
  241. border-radius: 50%;
  242. margin-right: 10rpx;
  243. }
  244. }
  245. .upload-file-box {
  246. padding: 20rpx 0;
  247. position: relative;
  248. .upload-btn {
  249. position: absolute;
  250. right: 0;
  251. top: 26rpx;
  252. }
  253. }
  254. }
  255. .handle-btn {
  256. width: 569rpx;
  257. height: 92rpx;
  258. background: #3e7ef8;
  259. border-radius: 31rpx;
  260. margin: 116rpx auto 0;
  261. font-size: 32rpx;
  262. color: #ffffff;
  263. text-align: center;
  264. line-height: 92rpx;
  265. }
  266. }
  267. </style>