addIceRaft.vue 7.5 KB

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