AddSupplier.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="detail-view">
  3. <u-form label-width="150" :model="add_form" ref="uForm">
  4. <view class="form-model-view">
  5. <u-form-item required label="供应商名称">
  6. <u-input v-model="add_form.title" placeholder="请输入供应商名称" />
  7. </u-form-item>
  8. <u-form-item required label="联系人">
  9. <u-input v-model="add_form.realName" placeholder="请输入联系人" />
  10. </u-form-item>
  11. <u-form-item required label="联系电话">
  12. <u-input v-model="add_form.mobile" placeholder="请输入手机号码" />
  13. </u-form-item>
  14. <u-form-item label="联系人职务">
  15. <u-input v-model="add_form.position" placeholder="请输入职务" />
  16. </u-form-item>
  17. <u-form-item label="状态" v-if='$accessCheck($Access.SupplierUpdateEnableStatus)'>
  18. <view class="form-value">
  19. <u-switch style="transform: translateY(14rpx);" v-model="switchStatus"
  20. :active-value="5" :inactive-value="4" size="40" @change='change'></u-switch>
  21. </view>
  22. </u-form-item>
  23. </view>
  24. <view class="form-model-view">
  25. <u-form-item required label="所属区域">
  26. <u-input v-model='area' class="dis-input" @click="region_show = true" disabled placeholder="请选择" />
  27. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  28. </u-form-item>
  29. <u-form-item label-position="top" label="详细地址">
  30. <u-input v-model="add_form.address" type="textarea" placeholder="请输入" />
  31. </u-form-item>
  32. </view>
  33. <view class="form-model-view">
  34. <u-form-item label="开户人">
  35. <u-input v-model="add_form.accountName" placeholder="请输入真实姓名" />
  36. </u-form-item>
  37. <u-form-item label="开户银行">
  38. <u-input v-model="add_form.bankName" placeholder="请输入开户银行" />
  39. </u-form-item>
  40. <u-form-item label="银行账号">
  41. <u-input v-model="add_form.bankCard" placeholder="请输入银行账号" />
  42. </u-form-item>
  43. </view>
  44. <view class="form-model-view">
  45. <u-form-item label="备注" label-position="top">
  46. <u-input v-model="add_form.remark" type="textarea" placeholder="请输入备注" />
  47. </u-form-item>
  48. </view>
  49. </u-form>
  50. <view class="detail-bottom">
  51. <view class="handel-btn" @click="addSupplier">提交</view>
  52. </view>
  53. <RegionSel v-model="region_show" @confirm="confirm" @cancel="region_show = false" />
  54. </view>
  55. </template>
  56. <script>
  57. import RegionSel from '@/components/region/RegionSel.vue';
  58. export default {
  59. components: {
  60. RegionSel
  61. },
  62. data() {
  63. return {
  64. region_show: false,
  65. add_form: {
  66. title: '',
  67. provinceCode: '',
  68. cityCode: '',
  69. districtCode: '',
  70. address: '',
  71. realName: '',
  72. mobile: '',
  73. enableStatus: 5,
  74. sex: 0,
  75. phone: '',
  76. position: '',
  77. email: '',
  78. remark: '',
  79. accountName: '',
  80. bankName: '',
  81. bankCard: '',
  82. },
  83. area: '',
  84. customer_id: '',
  85. switchStatus:true
  86. };
  87. },
  88. onLoad(options) {
  89. if (options.id) {
  90. this.customer_id = options.id
  91. uni.setNavigationBarTitle({
  92. title: '编辑供应商'
  93. });
  94. this.getSupplierInfoById();
  95. }
  96. },
  97. methods: {
  98. addSupplier() {
  99. if (!this.add_form.title.trim() || !this.add_form.realName.trim() || !this.add_form.mobile.trim() || !this
  100. .area.trim()) {
  101. this.$u.toast('必填项不能为空')
  102. return
  103. }
  104. if (this.customer_id) {
  105. this.$u.api.editSupplier(this.customer_id, this.add_form).then(res => {
  106. this.$u.toast('编辑成功')
  107. setTimeout(() => {
  108. uni.navigateBack()
  109. }, 500)
  110. })
  111. } else {
  112. this.$u.api.addSupplier(this.add_form).then(res => {
  113. this.$u.toast('提交成功')
  114. setTimeout(() => {
  115. uni.navigateBack()
  116. }, 500)
  117. })
  118. }
  119. },
  120. confirm(val) {
  121. this.add_form.provinceCode = val[0].value;
  122. this.add_form.cityCode = val[1].value;
  123. this.add_form.districtCode = val[2].value;
  124. let name = '';
  125. val.forEach(item => {
  126. name += item.label;
  127. });
  128. this.area = name;
  129. },
  130. getSupplierInfoById() {
  131. this.$u.api.getSupplierInfoById(this.customer_id).then(res => {
  132. this.add_form = res.data
  133. this.switchStatus=res.data.enableStatus===5
  134. this.area = res.data.area.provinceName + "-" + res.data.area.cityName + "-" + res.data.area
  135. .districtName
  136. })
  137. },
  138. change(val) {
  139. this.add_form.enableStatus = val
  140. }
  141. }
  142. };
  143. </script>
  144. <style></style>