addIceRaft.vue 7.8 KB

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