create.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. this.addForm.custId = Number(option.id)
  162. this.addForm.custName = option.name
  163. },
  164. created() {
  165. const navData = uni.getMenuButtonBoundingClientRect()
  166. this.height = navData.height + 'px'
  167. this.paddingTop = navData.top + 'px'
  168. },
  169. mounted() {
  170. this.getOptions()
  171. },
  172. methods: {
  173. getOptions() {
  174. Promise.all([distrApi.getProvinceList()])
  175. .then(([province]) => {
  176. this.provinceColumns = [province.data.list]
  177. })
  178. .catch((err) => console.log(err))
  179. },
  180. openUser() {
  181. this.$refs.user.open()
  182. },
  183. // 关闭选择销售
  184. closeUser(user) {
  185. if (user) {
  186. this.addForm.belongSaleId = user.id
  187. this.addForm.belongSale = user.label
  188. }
  189. },
  190. // 省份选择
  191. pickProvince(e) {
  192. this.addForm.provinceId = e.value[0].id
  193. this.addForm.provinceDesc = e.value[0].distName
  194. this.showProvince = false
  195. },
  196. handleAdd() {
  197. this.$refs.addForm
  198. .validate()
  199. .then(async () => {
  200. let params = this.addForm
  201. const [err, res] = await to(distrApi.doAdd(params))
  202. if (err) return
  203. if (res && res.code == 200) {
  204. this.$refs.uToast.show({
  205. type: 'success',
  206. message: '创建成功',
  207. complete: () => {
  208. uni.navigateBack({
  209. //关闭当前页面,返回上一页面或多级页面。
  210. delta: 1,
  211. })
  212. },
  213. })
  214. }
  215. })
  216. .catch((err) => {
  217. this.$refs.uNotify.show({
  218. top: this.height + this.paddingTop + 10,
  219. type: 'warning',
  220. message: err[0].message,
  221. duration: 1000 * 3,
  222. })
  223. })
  224. },
  225. goBack() {
  226. uni.navigateBack({
  227. //关闭当前页面,返回上一页面或多级页面。
  228. delta: 1,
  229. })
  230. },
  231. },
  232. }
  233. </script>
  234. <style>
  235. page {
  236. background: #f2f3f5;
  237. }
  238. </style>
  239. <style lang="scss" scoped>
  240. .home {
  241. padding-top: 188rpx;
  242. .nav {
  243. position: absolute;
  244. left: 0;
  245. top: 0;
  246. width: 100%;
  247. height: 284rpx;
  248. background: #3e7ef8;
  249. .title {
  250. position: relative;
  251. text-align: center;
  252. font-size: 32rpx;
  253. font-weight: bold;
  254. color: #ffffff;
  255. .back {
  256. position: absolute;
  257. top: 0;
  258. bottom: 0;
  259. margin: auto;
  260. left: 70rpx;
  261. display: flex;
  262. }
  263. }
  264. }
  265. .main {
  266. position: absolute;
  267. width: 100%;
  268. height: calc(100vh - 188rpx);
  269. background: #ffffff;
  270. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  271. border-radius: 31rpx 31rpx 0 0;
  272. padding: 0 32rpx;
  273. overflow: auto;
  274. padding-bottom: 64rpx;
  275. .form-label {
  276. font-size: 32rpx;
  277. font-weight: bold;
  278. color: #323232;
  279. padding-bottom: 18rpx;
  280. .label-tag {
  281. width: 15rpx;
  282. height: 15rpx;
  283. background: #ff4d4f;
  284. border-radius: 50%;
  285. margin-right: 10rpx;
  286. }
  287. }
  288. .upload-file-box {
  289. padding: 20rpx 0;
  290. position: relative;
  291. .upload-btn {
  292. position: absolute;
  293. right: 0;
  294. top: 26rpx;
  295. }
  296. }
  297. }
  298. .handle-btn {
  299. width: 569rpx;
  300. height: 92rpx;
  301. background: #3e7ef8;
  302. border-radius: 31rpx;
  303. margin: 116rpx auto 0;
  304. font-size: 32rpx;
  305. color: #ffffff;
  306. text-align: center;
  307. line-height: 92rpx;
  308. }
  309. }
  310. </style>