create.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-03-22 11:26:04
  6. * @Description: file content
  7. * @FilePath: \oms\pages\distributor\create.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="distName" 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.distName" placeholder="请输入名称"></u-input>
  29. </u-form-item>
  30. <u-form-item prop="abbrName" customStyle="padding:40rpx 0 34rpx" borderBottom>
  31. <view class="form-label flex_l">助记名</view>
  32. <u-input border="none" v-model="addForm.abbrName" placeholder="请输入助记名"></u-input>
  33. </u-form-item>
  34. <u-form-item prop="distDesc" customStyle="padding:40rpx 0 34rpx" borderBottom>
  35. <view class="form-label flex_l">说明</view>
  36. <u-input border="none" maxlength="11" v-model="addForm.distDesc" placeholder="请输入说明"></u-input>
  37. </u-form-item>
  38. <u-form-item prop="distBoss" customStyle="padding:40rpx 0 34rpx" borderBottom>
  39. <view class="form-label flex_l">
  40. <view class="label-tag"></view>
  41. 负责人
  42. </view>
  43. <u-input border="none" v-model="addForm.distBoss" placeholder="请输入负责人"></u-input>
  44. </u-form-item>
  45. <u-form-item prop="distBossPhone" customStyle="padding:40rpx 0 34rpx" borderBottom>
  46. <view class="form-label flex_l">
  47. <view class="label-tag"></view>
  48. 电话
  49. </view>
  50. <u-input maxlength="11" border="none" v-model="addForm.distBossPhone" placeholder="请输入电话"></u-input>
  51. </u-form-item>
  52. <u-form-item prop="businessScope" customStyle="padding:40rpx 0 34rpx" borderBottom>
  53. <view class="form-label flex_l">
  54. <view class="label-tag"></view>
  55. 业务范围
  56. </view>
  57. <u-input border="none" v-model="addForm.businessScope" placeholder="请输入业务范围"></u-input>
  58. </u-form-item>
  59. <u-form-item prop="provinceDesc" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showProvince = true">
  60. <view class="form-label flex_l">
  61. <view class="label-tag"></view>
  62. 选择省份
  63. </view>
  64. <u-input
  65. :readonly="true"
  66. placeholder="请选择省份"
  67. v-model="addForm.provinceDesc"
  68. border="none"
  69. suffixIcon="arrow-down"
  70. suffixIconStyle="color:#CDCDCD"
  71. clearable
  72. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  73. </u-form-item>
  74. <u-form-item prop="belongSale" borderBottom customStyle="padding:40rpx 0 30rpx" @click="openUser()">
  75. <view class="form-label flex_l">
  76. <view class="label-tag"></view>
  77. 销售工程师
  78. </view>
  79. <u-input
  80. :readonly="true"
  81. placeholder="请选择销售工程师"
  82. v-model="addForm.belongSale"
  83. border="none"
  84. suffixIcon="arrow-down"
  85. suffixIconStyle="color:#CDCDCD"
  86. clearable
  87. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  88. </u-form-item>
  89. <u-form-item prop="remark" customStyle="padding:40rpx 0 34rpx" borderBottom>
  90. <view class="form-label flex_l">备注</view>
  91. <u-textarea
  92. v-model="addForm.remark"
  93. placeholder="请输入备注"
  94. maxlength="800"
  95. height="190rpx"
  96. count
  97. customStyle="border-radius:16rpx"></u-textarea>
  98. </u-form-item>
  99. </u-form>
  100. <view class="center">
  101. <view class="handle-btn" @click="handleAdd">保存</view>
  102. </view>
  103. </view>
  104. <!-- 选择省 -->
  105. <u-picker
  106. :show="showProvince"
  107. :columns="provinceColumns"
  108. keyName="distName"
  109. @cancel="showProvince = false"
  110. @confirm="pickProvince"></u-picker>
  111. <!-- 选择销售 -->
  112. <select-user ref="user" :query-params="{ roles: ['SalesEngineer','ProductLineManager'] }" @close="closeUser($event)"></select-user>
  113. <u-notify ref="uNotify"></u-notify>
  114. <u-toast ref="uToast"></u-toast>
  115. </view>
  116. </template>
  117. <script>
  118. import to from 'await-to-js'
  119. import distrApi from '../../api/base/distr'
  120. import SelectUser from 'components/SelectUser'
  121. export default {
  122. name: 'omsIndex',
  123. components: { SelectUser },
  124. data() {
  125. return {
  126. height: '',
  127. paddingTop: '',
  128. showProvince: false,
  129. provinceColumns: [],
  130. addForm: {
  131. distName: '',
  132. abbrName: '',
  133. distDesc: '',
  134. distBoss: '',
  135. distBossPhone: '',
  136. businessScope: '',
  137. provinceId: null,
  138. provinceDesc: '',
  139. belongSale: '',
  140. belongSaleId: 0,
  141. remark: '',
  142. },
  143. rules: {
  144. distName: [{ required: true, trigger: 'blur', message: '请输入名称' }],
  145. distBoss: [{ required: true, trigger: 'blur', message: '请输入负责人' }],
  146. distBossPhone: [
  147. {
  148. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  149. message: '请输入正确的手机号码',
  150. trigger: 'blur',
  151. required: true,
  152. },
  153. ],
  154. businessScope: [{ required: true, trigger: 'blur', message: '请填写业务范围' }],
  155. provinceDesc: [{ required: true, trigger: 'blur', message: '请选择省份' }],
  156. belongSale: [{ required: true, trigger: 'blur', message: '请填写归属销售' }],
  157. },
  158. }
  159. },
  160. onLoad(option) {
  161. console.log(option)
  162. this.addForm.custId = Number(option.id)
  163. this.addForm.custName = option.name
  164. },
  165. created() {
  166. const navData = uni.getMenuButtonBoundingClientRect()
  167. this.height = navData.height + 'px'
  168. this.paddingTop = navData.top + 'px'
  169. },
  170. mounted() {
  171. this.getOptions()
  172. },
  173. methods: {
  174. getOptions() {
  175. Promise.all([distrApi.getProvinceList()])
  176. .then(([province]) => {
  177. this.provinceColumns = [province.data.list]
  178. })
  179. .catch((err) => console.log(err))
  180. },
  181. openUser() {
  182. this.$refs.user.open()
  183. },
  184. // 关闭选择销售
  185. closeUser(user) {
  186. console.log(user)
  187. if (user) {
  188. this.addForm.belongSaleId = user.id
  189. this.addForm.belongSale = user.label
  190. }
  191. },
  192. // 省份选择
  193. pickProvince(e) {
  194. console.log(e)
  195. this.addForm.provinceId = e.value[0].id
  196. this.addForm.provinceDesc = e.value[0].distName
  197. this.showProvince = false
  198. },
  199. handleAdd() {
  200. this.$refs.addForm
  201. .validate()
  202. .then(async () => {
  203. let params = this.addForm
  204. console.log(params)
  205. const [err, res] = await to(distrApi.doAdd(params))
  206. if (err) return
  207. if (res && res.code == 200) {
  208. this.$refs.uToast.show({
  209. type: 'success',
  210. message: '创建成功',
  211. complete: () => {
  212. uni.navigateBack({
  213. //关闭当前页面,返回上一页面或多级页面。
  214. delta: 1,
  215. })
  216. },
  217. })
  218. }
  219. })
  220. .catch((err) => {
  221. console.log(err)
  222. this.$refs.uNotify.show({
  223. top: this.height + this.paddingTop + 10,
  224. type: 'warning',
  225. message: err[0].message,
  226. duration: 1000 * 3,
  227. })
  228. })
  229. },
  230. goBack() {
  231. uni.navigateBack({
  232. //关闭当前页面,返回上一页面或多级页面。
  233. delta: 1,
  234. })
  235. },
  236. },
  237. }
  238. </script>
  239. <style>
  240. page {
  241. background: #f2f3f5;
  242. }
  243. </style>
  244. <style lang="scss" scoped>
  245. .home {
  246. padding-top: 188rpx;
  247. .nav {
  248. position: absolute;
  249. left: 0;
  250. top: 0;
  251. width: 100%;
  252. height: 284rpx;
  253. background: #3e7ef8;
  254. .title {
  255. position: relative;
  256. text-align: center;
  257. font-size: 32rpx;
  258. font-weight: bold;
  259. color: #ffffff;
  260. .back {
  261. position: absolute;
  262. top: 0;
  263. bottom: 0;
  264. margin: auto;
  265. left: 70rpx;
  266. display: flex;
  267. }
  268. }
  269. }
  270. .main {
  271. position: absolute;
  272. width: 100%;
  273. height: calc(100vh - 188rpx);
  274. background: #ffffff;
  275. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  276. border-radius: 31rpx 31rpx 0 0;
  277. padding: 0 32rpx;
  278. overflow: auto;
  279. padding-bottom: 64rpx;
  280. .form-label {
  281. font-size: 32rpx;
  282. font-weight: bold;
  283. color: #323232;
  284. padding-bottom: 18rpx;
  285. .label-tag {
  286. width: 15rpx;
  287. height: 15rpx;
  288. background: #ff4d4f;
  289. border-radius: 50%;
  290. margin-right: 10rpx;
  291. }
  292. }
  293. .upload-file-box {
  294. padding: 20rpx 0;
  295. position: relative;
  296. .upload-btn {
  297. position: absolute;
  298. right: 0;
  299. top: 26rpx;
  300. }
  301. }
  302. }
  303. .handle-btn {
  304. width: 569rpx;
  305. height: 92rpx;
  306. background: #3e7ef8;
  307. border-radius: 31rpx;
  308. margin: 116rpx auto 0;
  309. font-size: 32rpx;
  310. color: #ffffff;
  311. text-align: center;
  312. line-height: 92rpx;
  313. }
  314. }
  315. </style>