concatCreate.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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" :class="!flag ? 'disabledBtn' : ''">保存</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. flag:true,
  101. height: '',
  102. paddingTop: '',
  103. addForm: {
  104. cuctName: '',
  105. telephone: '',
  106. wechat: '',
  107. email: '',
  108. dept: '',
  109. postion: '',
  110. officeLocation: '',
  111. custId: 0,
  112. custName: '',
  113. isDecision: '20', //是否决策人 (10是20否)
  114. cuctGender: '10', //性别(10男20女)
  115. },
  116. rules: {
  117. cuctName: { required: true, trigger: ['blur'], message: '请输入联系人姓名' },
  118. custName: { required: true, trigger: ['blur'], message: '请输入客户名称' },
  119. cuctGender: { required: true, trigger: ['blur'], message: '请输入性别' },
  120. postion: { required: true, trigger: ['blur'], message: '请输入岗位名称' },
  121. telephone: [
  122. {
  123. validator: (rule, value, callback) => {
  124. if (value !== '') {
  125. const reg = /^1[3456789]\d{9}$/
  126. if (!reg.test(value)) {
  127. callback(new Error('手机号格式不正确'))
  128. } else {
  129. callback()
  130. }
  131. } else {
  132. callback()
  133. }
  134. },
  135. },
  136. ],
  137. },
  138. }
  139. },
  140. onLoad(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. if(!this.flag) return
  153. this.$refs.addForm
  154. .validate()
  155. .then(async () => {
  156. let params = this.addForm
  157. this.flag = false
  158. const [err, res] = await to(customerApi.createContact(params))
  159. this.flag = true
  160. if (err) return
  161. if (res && res.code == 200) {
  162. this.$refs.uToast.show({
  163. type: 'success',
  164. message: '创建成功',
  165. complete: () => {
  166. uni.navigateBack({
  167. //关闭当前页面,返回上一页面或多级页面。
  168. delta: 1,
  169. })
  170. },
  171. })
  172. }
  173. })
  174. .catch((err) => {
  175. this.$refs.uNotify.show({
  176. top: this.height + this.paddingTop + 10,
  177. type: 'warning',
  178. message: err[0].message,
  179. duration: 1000 * 3,
  180. })
  181. })
  182. },
  183. goBack() {
  184. uni.navigateBack({
  185. //关闭当前页面,返回上一页面或多级页面。
  186. delta: 1,
  187. })
  188. },
  189. },
  190. }
  191. </script>
  192. <style>
  193. page {
  194. background: #f2f3f5;
  195. }
  196. </style>
  197. <style lang="scss" scoped>
  198. .home {
  199. padding-top: 188rpx;
  200. .nav {
  201. position: absolute;
  202. left: 0;
  203. top: 0;
  204. width: 100%;
  205. height: 284rpx;
  206. background: #3e7ef8;
  207. .title {
  208. position: relative;
  209. text-align: center;
  210. font-size: 32rpx;
  211. font-weight: bold;
  212. color: #ffffff;
  213. .back {
  214. position: absolute;
  215. top: 0;
  216. bottom: 0;
  217. margin: auto;
  218. left: 70rpx;
  219. display: flex;
  220. }
  221. }
  222. }
  223. .main {
  224. position: absolute;
  225. width: 100%;
  226. height: calc(100vh - 188rpx);
  227. background: #ffffff;
  228. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  229. border-radius: 31rpx 31rpx 0 0;
  230. padding: 0 32rpx;
  231. overflow: auto;
  232. padding-bottom: 64rpx;
  233. .form-label {
  234. font-size: 32rpx;
  235. font-weight: bold;
  236. color: #323232;
  237. padding-bottom: 18rpx;
  238. .label-tag {
  239. width: 15rpx;
  240. height: 15rpx;
  241. background: #ff4d4f;
  242. border-radius: 50%;
  243. margin-right: 10rpx;
  244. }
  245. }
  246. .upload-file-box {
  247. padding: 20rpx 0;
  248. position: relative;
  249. .upload-btn {
  250. position: absolute;
  251. right: 0;
  252. top: 26rpx;
  253. }
  254. }
  255. }
  256. .handle-btn {
  257. width: 569rpx;
  258. height: 92rpx;
  259. background: #3e7ef8;
  260. border-radius: 31rpx;
  261. margin: 116rpx auto 0;
  262. font-size: 32rpx;
  263. color: #ffffff;
  264. text-align: center;
  265. line-height: 92rpx;
  266. }
  267. }
  268. </style>