addIceRaft.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <!-- 添加运单 -->
  3. <view>
  4. <u-navbar :title="headline" autoBack placeholder></u-navbar>
  5. <x-form ref="recipients" :list="list" :model="recipientsModel" :rules="rules"></x-form>
  6. <view style="width: 100%;height: 150rpx;"></view>
  7. <view class="btn_print" @click="printWaybill">
  8. <u-button type="primary" :loading="printLoading" :text="headline"></u-button>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import {
  14. iceRaftRulesil
  15. } from "./waybill.js";
  16. export default {
  17. name: 'addIceRaft',
  18. data() {
  19. return {
  20. recipientsModel: {
  21. id: null,
  22. code: '',
  23. label: '',
  24. status: '正常',
  25. freezeClaim: [],
  26. suitableForCold: null,
  27. forColdTime: null,
  28. iceColdAddress: '',
  29. sort: null,
  30. },
  31. rules: {
  32. code: [{
  33. required: true,
  34. message: '请输入编号',
  35. trigger: ['blur', 'change'],
  36. },
  37. // {
  38. // required: true,
  39. // validator: (rule, value, callback) => {
  40. // if (!value) {
  41. // return callback(new Error('请输入数值'));
  42. // }
  43. // if (!/^(\d+)?(\.\d+)?$/.test(value)) {
  44. // return callback(new Error('请输入有效的数值'));
  45. // }
  46. // // 如果需要校验整数,可以使用下面的正则表达式
  47. // // if (!/^\d+$/.test(value)) {
  48. // // return callback(new Error('请输入整数'));
  49. // // }
  50. // return callback();
  51. // },
  52. // trigger: 'blur'
  53. // },
  54. ],
  55. label: {
  56. required: false,
  57. message: '请输入冰排备注',
  58. trigger: ['blur', 'change']
  59. },
  60. status: {
  61. required: true,
  62. message: '请选择状态',
  63. trigger: ['blur', 'change']
  64. },
  65. freezeClaim: {
  66. type: 'array',
  67. required: true,
  68. message: '请输入冷冻要求',
  69. trigger: ['blur', 'change']
  70. },
  71. suitableForCold: [{
  72. required: false,
  73. message: '请输入释冷温度',
  74. trigger: ['blur', 'change']
  75. }],
  76. forColdTime: [{
  77. required: false,
  78. message: '请输入释冷要求',
  79. trigger: ['blur', 'change']
  80. }, {
  81. required: false,
  82. validator: (rule, value, callback) => {
  83. if (!value && rule.required) {
  84. return callback(new Error('请输入释冷要求'));
  85. }
  86. if (value) {
  87. if (!/^(\d+)?(\.\d+)?$/.test(value)) {
  88. return callback(new Error('请输入有效的数值'));
  89. }
  90. }
  91. return callback();
  92. },
  93. trigger: ['blur', 'change']
  94. }],
  95. iceColdAddress: {
  96. required: false,
  97. message: '请输入释冷地点',
  98. trigger: ['blur', 'change']
  99. },
  100. sort: {
  101. required: false,
  102. validator: (rule, value, callback) => {
  103. if (!value && rule.required) {
  104. return callback(new Error('请输入排序编号'));
  105. }
  106. if (value) {
  107. if (!/^(\d+)?(\.\d+)?$/.test(value)) {
  108. return callback(new Error('请输入有效的数值'));
  109. }
  110. }
  111. return callback();
  112. },
  113. trigger: ['blur', 'change']
  114. }
  115. },
  116. list: [],
  117. isIceInfo: {},
  118. headline: '添加冰排',
  119. type: 1,
  120. printLoading: false,
  121. }
  122. },
  123. onShow() {
  124. var userInfo = this.$cache.getCache('userInfo')
  125. this.isIceInfo = userInfo.dept
  126. if (this.isIceInfo.isIceReleaseCold) {
  127. this.list = iceRaftRulesil()
  128. } else {
  129. var arrIce = iceRaftRulesil()
  130. this.list = removePointById(arrIce, ['suitableForCold', 'forColdTime', 'iceColdAddress'])
  131. }
  132. function removePointById(arr1, arr2) {
  133. for (let i = 0; i < arr2.length; i++) {
  134. for (let j = 0; j < arr1.length; j++) {
  135. if (arr2[i] == arr1[j].field) {
  136. let indexs = arr1.indexOf(arr1[j]);
  137. arr1.splice(indexs, 1);
  138. }
  139. }
  140. }
  141. return arr1
  142. }
  143. },
  144. onLoad(option) {
  145. if (option.list) {
  146. let arrValue = JSON.parse(option.list)
  147. if (arrValue.id) {
  148. this.$nextTick(() => {
  149. this.headline = '编辑冰排'
  150. this.recipientsModel = arrValue
  151. if (arrValue.freezeClaim) {
  152. this.recipientsModel.freezeClaim = arrValue.freezeClaim
  153. }
  154. this.recipientsModel.suitableForCold = String(arrValue.suitableForCold)
  155. if (arrValue.status == '2') {
  156. this.recipientsModel.status = '正常'
  157. } else {
  158. this.recipientsModel.status = '停用'
  159. }
  160. })
  161. } else {
  162. this.headline = '添加冰排'
  163. }
  164. }
  165. },
  166. mounted() {},
  167. methods: {
  168. // tianjia运单
  169. async printWaybill() {
  170. let flag1 = await this.$refs['recipients'].validateForm();
  171. if (flag1) {
  172. let params = {
  173. codeList: [],
  174. label: this.recipientsModel.label,
  175. freezeClaim: this.recipientsModel.freezeClaim,
  176. iceColdAddress: this.recipientsModel.iceColdAddress,
  177. forColdTime: Number(this.recipientsModel.forColdTime),
  178. suitableForCold: this.recipientsModel.suitableForCold,
  179. status: null,
  180. sort: Number(this.recipientsModel.sort),
  181. }
  182. if (this.recipientsModel.status == '正常') {
  183. params.status = '2'
  184. } else {
  185. params.status = '1'
  186. }
  187. params.codeList.push(this.recipientsModel.code)
  188. this.printLoading = true
  189. uni.showLoading({
  190. mask: true
  191. });
  192. if (this.recipientsModel.id) {
  193. params.id = this.recipientsModel.id
  194. params.code = this.recipientsModel.code
  195. delete params.codeList
  196. this.$api.put('/api/ice-raft', params).then(res => {
  197. if (res.code == 200) {
  198. uni.navigateBack({
  199. delta: 1
  200. });
  201. } else {
  202. uni.$u.toast(res.msg)
  203. }
  204. this.printLoading = false
  205. uni.hideLoading();
  206. }).catch(() => {
  207. this.printLoading = false
  208. uni.hideLoading();
  209. })
  210. } else {
  211. this.$api.post('/api/ice-raft', params).then(res => {
  212. if (res.code == 200) {
  213. uni.navigateBack({
  214. delta: 1
  215. });
  216. } else {
  217. uni.$u.toast(res.msg)
  218. }
  219. this.printLoading = false
  220. uni.hideLoading();
  221. }).catch(() => {
  222. this.printLoading = false
  223. uni.hideLoading();
  224. })
  225. }
  226. } else {
  227. uni.$u.toast('请先完善表单')
  228. }
  229. },
  230. }
  231. }
  232. </script>
  233. <style lang="scss">
  234. page {
  235. background-color: #fff !important;
  236. }
  237. .title_waybill {
  238. font-size: 32rpx;
  239. padding: 20rpx;
  240. }
  241. .title_waybill1 {
  242. position: relative;
  243. margin: 20rpx;
  244. border-bottom: 1rpx;
  245. padding-bottom: 20rpx;
  246. }
  247. .card_Address {
  248. position: relative;
  249. }
  250. .card_flex_il {
  251. display: flex;
  252. align-items: center;
  253. padding: 20rpx;
  254. }
  255. .title_sou {
  256. font-size: 32rpx;
  257. }
  258. .card_Address:before {
  259. content: " ";
  260. position: absolute;
  261. left: 0;
  262. bottom: 0;
  263. width: 100%;
  264. height: 1px;
  265. border-top: 1px solid #e7e6e4;
  266. -webkit-transform-origin: 0 0;
  267. transform-origin: 0 0;
  268. -webkit-transform: scaleY(0.5);
  269. transform: scaleY(0.5);
  270. }
  271. .card_courier {
  272. min-height: 600rpx;
  273. padding-bottom: 20rpx;
  274. }
  275. .scroll-view {
  276. max-height: 60vh;
  277. overflow: hidden;
  278. }
  279. .headline {
  280. padding: 30rpx 30rpx 0rpx 30rpx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. padding-bottom: 30rpx;
  285. font-size: 32rpx;
  286. font-weight: 600;
  287. }
  288. .search_card {
  289. padding: 0rpx 30rpx 10rpx 30rpx;
  290. }
  291. .courier_item {
  292. margin: 20rpx 20rpx;
  293. width: calc(100% - 80rpx);
  294. padding: 20rpx;
  295. border-radius: 20rpx;
  296. // box-shadow: 0 2rpx 10rpx 0 rgba(0, 0, 0, .1);
  297. border: 1rpx solid #e7e6e4;
  298. }
  299. .courier_name {
  300. display: flex;
  301. flex-direction: column;
  302. }
  303. .title_name {
  304. font-weight: 600;
  305. font-size: 32rpx;
  306. margin-bottom: 10rpx;
  307. }
  308. .title_phone {
  309. font-size: 28rpx;
  310. }
  311. .xd_title {
  312. width: auto;
  313. font-size: 28rpx;
  314. font-weight: 500;
  315. padding: 15rpx 30rpx;
  316. border-radius: 35rpx;
  317. // border: 3rpx solid #82848a;
  318. background-color: #E4E7ED;
  319. }
  320. </style>