addpaygoods.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="container">
  3. <view class="information">
  4. <u-form :model="user" ref="uForm" class="uForm">
  5. <u-form-item label="收货人姓名" prop="receiveName" label-width="160" required>
  6. <u-input v-model="user.receiveName" :disabled="recipientsNumber?true:false" input-align="right"
  7. placeholder="请输入收货人姓名" />
  8. </u-form-item>
  9. <u-form-item label="收货人手机号" prop="receivePhone" label-width="180" required>
  10. <u-input v-model="user.receivePhone" :disabled="recipientsNumber?true:false" input-align="right"
  11. placeholder="请输入收货人注册易粮易运的手机号" />
  12. </u-form-item>
  13. </u-form>
  14. </view>
  15. <button class="submit-btn" @click="submit" v-if="!recipientsNumber">提交</button>
  16. <button class="submit-btn btn-bgccolor" v-if="recipientsNumber">人数已达上限</button>
  17. <view class="c-row">
  18. <view class="">全部收货人({{dataList.receivingUsers.length+1}})</view>
  19. </view>
  20. <view class="c-row">
  21. <view class="title">{{dataList.consignee}}</view>
  22. <view class="phone">
  23. {{dataList.accountNumber}}
  24. </view>
  25. </view>
  26. <view class="information" v-for="(item,index) in dataList.receivingUsers">
  27. <view class="c-row">
  28. <view class="title">{{item.receiveName}}</view>
  29. <view class="con-list">
  30. <view class="phone">
  31. {{item.receivePhone}}
  32. </view>
  33. <image src="../../static/img/jiaoyi/shanchu.png" class="del" @click="del(item)"></image>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import uploadImage from '@/components/ossutil/uploadFile.js';
  41. import {
  42. mapState
  43. } from 'vuex';
  44. export default {
  45. name: "trust",
  46. data() {
  47. return {
  48. id:"",
  49. user: {
  50. compId: "",
  51. infoId: "",
  52. receiveName: "",
  53. receivePhone: "",
  54. },
  55. dataList: {
  56. receivingUsers: []
  57. },
  58. rules: {
  59. receiveName: [{
  60. validator: (rule, value, callback) => {
  61. return this.$u.test.chinese(value)
  62. },
  63. message: '收货人姓名为汉字',
  64. trigger: ['change', 'blur']
  65. },
  66. {
  67. validator: (rule, value, callback) => {
  68. if (value.length > 10 || value.length < 2) return false
  69. return true
  70. },
  71. message: '请输入2-10个汉字',
  72. trigger: ['change', 'blur'],
  73. },
  74. ],
  75. receivePhone: [{
  76. validator: (rule, value, callback) => {
  77. return this.$u.test.mobile(value)
  78. },
  79. message: '手机号格式不正确',
  80. trigger: ['change', 'blur']
  81. },
  82. {
  83. validator: (rule, value, callback) => {
  84. return !this.checkMobile(value)
  85. },
  86. message: '手机号不能与其他收货人重复',
  87. trigger: ['blur']
  88. }
  89. ]
  90. },
  91. recipientsNumber: false
  92. }
  93. },
  94. computed: {
  95. },
  96. onShow() {},
  97. onReady() {
  98. this.$refs.uForm.setRules(this.rules);
  99. },
  100. onLoad(option) {
  101. this.user.infoId = option.id;
  102. this.getDetail(option.id);
  103. this.id = option.id
  104. },
  105. methods: {
  106. // 手机号重复校验
  107. checkMobile(val) {
  108. let _data = this.dataList.receivingUsers;
  109. if (_data == null || _data.length == 0) return false
  110. for (let i = 0; i < _data.length; i++) {
  111. if (val == _data[i].receivePhone) return true
  112. }
  113. return false
  114. },
  115. getDetail(id) {
  116. this.$api.doRequest('get', 'freightReceivingDispatching/getFreightReceivingDispatching', {
  117. "id": id
  118. }).then(res => {
  119. if (res.data.code == 200) {
  120. this.dataList = res.data.data
  121. this.dataList.receivingUsers = this.dataList.receivingUsers ? this.dataList
  122. .receivingUsers : []
  123. if (this.dataList.receivingUsers.length > 20) this.recipientsNumber = true
  124. console.log("this.dataList----------------------")
  125. console.log(this.dataList)
  126. } else {
  127. }
  128. }).catch(res => {
  129. // uni.showToast({
  130. // title: res.data.message,
  131. // icon: 'none',
  132. // duration: 2000
  133. // })
  134. })
  135. },
  136. submit() {
  137. let that = this
  138. this.$refs.uForm.validate(valid => {
  139. if (valid) {
  140. that.$api.doRequest('post', '/freightReceivingDispatching/api/insertReceivingUser', this
  141. .user).then(res => {
  142. if (res.data.code == 200) {
  143. uni.showToast({
  144. title: '提交成功',
  145. icon: 'none',
  146. duration: 2000,
  147. success: function() {
  148. this.getDetail(that.id);
  149. }
  150. })
  151. } else {
  152. uni.showToast({
  153. title: '提交失败',
  154. icon: 'none',
  155. duration: 2000,
  156. success: function() {}
  157. })
  158. }
  159. }).catch(res => {
  160. // uni.showToast({
  161. // title: res.data.message,
  162. // icon: 'none',
  163. // duration: 2000
  164. // })
  165. })
  166. console.log('验证通过');
  167. } else {
  168. console.log('验证失败');
  169. return
  170. }
  171. });
  172. },
  173. del(val) {
  174. let that = this
  175. uni.showModal({
  176. content: '确定删除该收货人?',
  177. cancelText: "取消",
  178. confirmText: "删除",
  179. success: function(res) {
  180. if (res.confirm) {
  181. that.$api.doRequest('post', '/receivingUser/deleteInfo', {
  182. "id": val.id
  183. }).then(res => {
  184. if (res.data.code == 200) {
  185. uni.showToast({
  186. title: '删除成功',
  187. icon: 'none',
  188. duration: 2000,
  189. success: function() {
  190. that.getDetail(that.user.infoId)
  191. }
  192. })
  193. } else {
  194. uni.showToast({
  195. title: '删除失败',
  196. icon: 'none',
  197. duration: 2000,
  198. success: function() {}
  199. })
  200. }
  201. }).catch(res => {
  202. // uni.showToast({
  203. // title: res.data.message,
  204. // icon: 'none',
  205. // duration: 2000
  206. // })
  207. })
  208. } else if (res.cancel) {}
  209. }
  210. });
  211. }
  212. },
  213. }
  214. </script>
  215. <style scoped lang="scss">
  216. .container {
  217. padding: 10px 10px;
  218. background-color: #F5F6FA;
  219. }
  220. .cu-form-group textarea {
  221. text-align: right;
  222. }
  223. .commit {
  224. background: linear-gradient(45deg, #DF331C, #DA611A);
  225. color: #fff;
  226. }
  227. .c-row {
  228. display: -webkit-box;
  229. display: -webkit-flex;
  230. display: flex;
  231. -webkit-box-align: center;
  232. -webkit-align-items: center;
  233. align-items: center;
  234. padding: 20rpx 30rpx;
  235. position: relative;
  236. .title {
  237. width: 30%;
  238. // background: green;
  239. }
  240. }
  241. .con-list {
  242. display: flex;
  243. // background: red;
  244. width: 100%;
  245. justify-content: space-between;
  246. align-items: center;
  247. .del {
  248. display: block;
  249. width: 29rpx;
  250. height: 31rpx;
  251. }
  252. }
  253. .information {
  254. background-color: #FFFFFF;
  255. border-radius: 20px;
  256. margin-top: 10px;
  257. }
  258. .btn {
  259. margin-top: 10px;
  260. border-radius: 25px;
  261. background-color: #22C572;
  262. border: none;
  263. color: #FFFFFF;
  264. }
  265. .uForm {
  266. padding: 0 40rpx;
  267. }
  268. .custom-style {
  269. color: #606266;
  270. width: 400rpx;
  271. }
  272. .submit-btn {
  273. margin-top: 20rpx;
  274. width: 100%;
  275. background: #22C572;
  276. border-radius: 92rpx;
  277. font-size: 34rpx;
  278. font-weight: 500;
  279. color: #FFFFFF;
  280. }
  281. .btn-bgccolor {
  282. background: #D8DAE0;
  283. }
  284. </style>