create.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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="provinceDesc" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showProvince = true">
  31. <view class="form-label flex_l">
  32. <view class="label-tag"></view>
  33. 选择省份
  34. </view>
  35. <u-input
  36. :readonly="true"
  37. placeholder="请选择省份"
  38. v-model="addForm.provinceDesc"
  39. border="none"
  40. suffixIcon="arrow-down"
  41. suffixIconStyle="color:#CDCDCD"
  42. clearable
  43. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  44. </u-form-item>
  45. <u-form-item prop="registerDistrict" 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 border="none" v-model="addForm.registerDistrict" placeholder="请输入备注"></u-input>
  51. </u-form-item>
  52. </u-form>
  53. <view class="center">
  54. <view class="handle-btn" @click="handleAdd">保存</view>
  55. </view>
  56. </view>
  57. <!-- 选择省 -->
  58. <u-picker
  59. :show="showProvince"
  60. :columns="provinceColumns"
  61. keyName="distName"
  62. @cancel="showProvince = false"
  63. @confirm="pickProvince"></u-picker>
  64. <!-- 选择销售 -->
  65. <u-notify ref="uNotify"></u-notify>
  66. <u-toast ref="uToast"></u-toast>
  67. </view>
  68. </template>
  69. <script>
  70. import to from 'await-to-js'
  71. import distrApi from '../../api/base/distr'
  72. import SelectUser from 'components/SelectUser'
  73. export default {
  74. name: 'omsIndex',
  75. components: { SelectUser },
  76. data() {
  77. return {
  78. height: '',
  79. paddingTop: '',
  80. showProvince: false,
  81. provinceColumns: [],
  82. addForm: {
  83. distName: '',
  84. provinceId: null,
  85. provinceDesc: '',
  86. registerDistrict: '',
  87. distType: '10',
  88. },
  89. rules: {
  90. distName: [{ required: true, trigger: 'blur', message: '请输入名称' }],
  91. registerDistrict: [{ required: true, trigger: 'blur', message: '请输入注册地' }],
  92. provinceDesc: [{ required: true, trigger: 'blur', message: '请选择省份' }],
  93. },
  94. }
  95. },
  96. created() {
  97. const navData = uni.getMenuButtonBoundingClientRect()
  98. this.height = navData.height + 'px'
  99. this.paddingTop = navData.top + 'px'
  100. },
  101. mounted() {
  102. this.getOptions()
  103. },
  104. methods: {
  105. getOptions() {
  106. Promise.all([distrApi.getProvinceList()])
  107. .then(([province]) => {
  108. this.provinceColumns = [province.data.list]
  109. })
  110. .catch((err) => console.log(err))
  111. },
  112. // 省份选择
  113. pickProvince(e) {
  114. this.addForm.provinceId = e.value[0].id
  115. this.addForm.provinceDesc = e.value[0].distName
  116. this.showProvince = false
  117. },
  118. handleAdd() {
  119. this.$refs.addForm
  120. .validate()
  121. .then(async () => {
  122. let params = this.addForm
  123. const [err, res] = await to(distrApi.doAdd(params))
  124. if (err) return
  125. if (res && res.code == 200) {
  126. this.$refs.uToast.show({
  127. type: 'success',
  128. message: '创建成功',
  129. complete: () => {
  130. uni.navigateBack({
  131. //关闭当前页面,返回上一页面或多级页面。
  132. delta: 1,
  133. })
  134. },
  135. })
  136. }
  137. })
  138. .catch((err) => {
  139. this.$refs.uNotify.show({
  140. top: this.height + this.paddingTop + 10,
  141. type: 'warning',
  142. message: err[0].message,
  143. duration: 1000 * 3,
  144. })
  145. })
  146. },
  147. goBack() {
  148. uni.navigateBack({
  149. //关闭当前页面,返回上一页面或多级页面。
  150. delta: 1,
  151. })
  152. },
  153. },
  154. }
  155. </script>
  156. <style>
  157. page {
  158. background: #f2f3f5;
  159. }
  160. </style>
  161. <style lang="scss" scoped>
  162. .home {
  163. padding-top: 188rpx;
  164. .nav {
  165. position: absolute;
  166. left: 0;
  167. top: 0;
  168. width: 100%;
  169. height: 284rpx;
  170. background: #3e7ef8;
  171. .title {
  172. position: relative;
  173. text-align: center;
  174. font-size: 32rpx;
  175. font-weight: bold;
  176. color: #ffffff;
  177. .back {
  178. position: absolute;
  179. top: 0;
  180. bottom: 0;
  181. margin: auto;
  182. left: 70rpx;
  183. display: flex;
  184. }
  185. }
  186. }
  187. .main {
  188. position: absolute;
  189. width: 100%;
  190. height: calc(100vh - 188rpx);
  191. background: #ffffff;
  192. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  193. border-radius: 31rpx 31rpx 0 0;
  194. padding: 0 32rpx;
  195. overflow: auto;
  196. padding-bottom: 64rpx;
  197. .form-label {
  198. font-size: 32rpx;
  199. font-weight: bold;
  200. color: #323232;
  201. padding-bottom: 18rpx;
  202. .label-tag {
  203. width: 15rpx;
  204. height: 15rpx;
  205. background: #ff4d4f;
  206. border-radius: 50%;
  207. margin-right: 10rpx;
  208. }
  209. }
  210. .upload-file-box {
  211. padding: 20rpx 0;
  212. position: relative;
  213. .upload-btn {
  214. position: absolute;
  215. right: 0;
  216. top: 26rpx;
  217. }
  218. }
  219. }
  220. .handle-btn {
  221. width: 569rpx;
  222. height: 92rpx;
  223. background: #3e7ef8;
  224. border-radius: 31rpx;
  225. margin: 116rpx auto 0;
  226. font-size: 32rpx;
  227. color: #ffffff;
  228. text-align: center;
  229. line-height: 92rpx;
  230. }
  231. }
  232. </style>