add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="top">
  5. <text class="title">申报单录入</text>
  6. </view>
  7. <view class="item">
  8. <view class="l"><text style="color: red;">*</text>申报人:</view>
  9. <view class="r">
  10. <u-input placeholder="申报人" @input="handler()" v-model="form.declarePeople">
  11. </u-input>
  12. </view>
  13. </view>
  14. <view class="item">
  15. <view class="l"><text style="color: red;">*</text>申报电话:</view>
  16. <view class="r">
  17. <u-input placeholder="申报电话" type="number" @input="handler()" v-model="form.declarePhone">
  18. </u-input>
  19. </view>
  20. </view>
  21. <view class="item">
  22. <view class="l"><text style="color: red;">*</text>产品学名:</view>
  23. <view class="r">
  24. <u-input placeholder="输入产品学名" @input="handler()" v-model="form.goodsName">
  25. </u-input>
  26. </view>
  27. </view>
  28. <view class="item">
  29. <view class="l"><text style="color: red;">*</text>毛重:</view>
  30. <view class="r">
  31. <u-input type="number" placeholder="输入毛重" @input="handler()" v-model="form.grossWeight">
  32. <text slot="suffix">吨</text>
  33. </u-input>
  34. </view>
  35. </view>
  36. <view class="item">
  37. <view class="l"><text style="color: red;">*</text>件数:</view>
  38. <view class="r">
  39. <u-input type="number" placeholder="输入件数" @input="handler()" v-model="form.num">
  40. </u-input>
  41. </view>
  42. </view>
  43. <view class="item">
  44. <view class="l"><text style="color: red;">*</text>生产日期:</view>
  45. <view class="r">
  46. <view class="r">
  47. <uni-datetime-picker placeholder="请选择" @input="handler()" :clear-icon="false" type="date"
  48. v-model="form.productionDate" />
  49. </view>
  50. </view>
  51. </view>
  52. <view class="item">
  53. <view class="l" style="flex: 7;"><text style="color: red;">*</text>保质期(天):</view>
  54. <view class="r">
  55. <view class="r">
  56. <u-input placeholder="输入保质期" type="number" @input="handler()" v-model="form.expirationDate" />
  57. </view>
  58. </view>
  59. </view>
  60. <view class="item">
  61. <view class="l"><text style="color: red;">*</text>储藏条件:</view>
  62. <view class="r">
  63. <u-input placeholder="储存条件" @input="handler()" v-model="form.storageMode" />
  64. </view>
  65. </view>
  66. <view class="item">
  67. <view class="l"><text style="color: red;">*</text>生产方式:</view>
  68. <view class="r">
  69. <u-input placeholder="生产方式" @input="handler()" v-model="form.productionMode" />
  70. </view>
  71. </view>
  72. <view class="item">
  73. <view class="l"><text style="color: red;">*</text>原产国:</view>
  74. <view class="r">
  75. <u-input placeholder="原产国" @input="handler()" v-model="form.origin" />
  76. </view>
  77. </view>
  78. <view class="item">
  79. <view class="l"><text style="color: red;">*</text>货主单位:</view>
  80. <view class="r">
  81. <u-input placeholder="货主单位" @input="handler()" v-model="form.sendUnit" />
  82. </view>
  83. </view>
  84. <view class="item">
  85. <view class="l" style="flex: 7;"><text style="color: red;">*</text>生产商注册号:</view>
  86. <view class="r">
  87. <u-input placeholder="生产商注册号" @input="handler()" v-model="form.producerCode" />
  88. </view>
  89. </view>
  90. <view class="item">
  91. <view class="l"><text style="color: red;">*</text>收货单位:</view>
  92. <view class="r">
  93. <u-input placeholder="收货单位" @input="handler()" v-model="form.receiveUnit" />
  94. </view>
  95. </view>
  96. <view class="item">
  97. <view class="l"><text style="color: red;">*</text>货物流向:</view>
  98. <view class="r">
  99. <u-input placeholder="货物流向" @input="handler()" v-model="form.route" />
  100. </view>
  101. </view>
  102. <view class="item">
  103. <view class="l"><text style="color: red;">*</text>运输车辆(车头牌):</view>
  104. <view class="r">
  105. <u--textarea @input="handler()" v-model="form.chinaCarNo" placeholder="运输车车头牌,多个请用逗号隔开">
  106. </u--textarea>
  107. </view>
  108. </view>
  109. <view class="item">
  110. <view class="l"><text style="color: red;">*</text>运输车辆(车尾牌):</view>
  111. <view class="r">
  112. <u--textarea @input="handler()" v-model="form.chinaCarNoSuff" placeholder="运输车车尾牌,多个请用逗号隔开">
  113. </u--textarea>
  114. </view>
  115. </view>
  116. <view class="item">
  117. <view class="l"><text style="color: red;">*</text>司机姓名:</view>
  118. <view class="r">
  119. <u--textarea @input="handler()" v-model="form.driverName" placeholder="司机姓名,多个请用逗号隔开"></u--textarea>
  120. </view>
  121. </view>
  122. <view class="item">
  123. <view class="l"><text style="color: red;">*</text>司机电话:</view>
  124. <view class="r">
  125. <u--textarea @input="handler()" v-model="form.driverPhone" placeholder="司机电话,多个请用逗号隔开">
  126. </u--textarea>
  127. </view>
  128. </view>
  129. <view class="item">
  130. <view class="l" style="flex: 7;"><text style="color: red;">*</text>代理商电话:</view>
  131. <view class="r">
  132. <u-input type="number" placeholder="代理商电话" @input="handler()" v-model="form.agentPhone" />
  133. </view>
  134. </view>
  135. <view class="item">
  136. <view class="l" style="flex: 7;"><text style="color: red;">*</text>海关报关单据:</view>
  137. <view class="r">
  138. <u-input placeholder="海关报关单据" @input="handler()" v-model="form.customProof" />
  139. </view>
  140. </view>
  141. <view class="item">
  142. <view class="l" style="flex: 7;"><text style="color: red;">*</text>检验检疫证:</view>
  143. <view class="r">
  144. <u-input placeholder="检验检疫证" @input="handler()" v-model="form.quarantineProof" />
  145. </view>
  146. </view>
  147. <view class="item">
  148. <view class="l"><text style="color: red;">*</text>商铺:</view>
  149. <view class="r">
  150. <u-input placeholder="商铺" @input="handler()" v-model="form.shop" />
  151. </view>
  152. </view>
  153. <view class="item">
  154. <view class="l"><text style="color: red;">*</text>生产批号:</view>
  155. <view class="r">
  156. <u-input placeholder="生产批号" @input="handler()" v-model="form.productionCode" />
  157. </view>
  158. </view>
  159. <view class="item">
  160. <view class="l"><text style="color: red;">*</text>柜号:</view>
  161. <view class="r">
  162. <u-input placeholder="柜号" @input="handler()" v-model="form.containerCode" />
  163. </view>
  164. </view>
  165. <view class="item">
  166. <view class="l"><text style="color: red;">*</text>越南车牌:</view>
  167. <view class="r">
  168. <u-input placeholder="越南车牌" @input="handler()" v-model="form.carNo" />
  169. </view>
  170. </view>
  171. </view>
  172. <u-button type="primary" text="确定" @click="saveFn"></u-button>
  173. <u-button type="info" text="重置" @click="cleanFn" style="margin-top: 20rpx;"></u-button>
  174. <!-- ---------------------------------------------------------- -->
  175. <view class="bottom-safety"></view>
  176. </view>
  177. </template>
  178. <script>
  179. export default {
  180. data() {
  181. return {
  182. form: {
  183. declarePeople: '',
  184. declarePhone: '',
  185. goodsName: '',
  186. grossWeight: '',
  187. num: '',
  188. productionDate: '',
  189. expirationDate: '',
  190. productionMode: '',
  191. origin: '',
  192. sendUnit: '',
  193. producerCode: '',
  194. receiveUnit: '',
  195. route: '',
  196. storageMode: '',
  197. driverName: '',
  198. driverPhone: '',
  199. agent: '',
  200. chinaCarNo: '',
  201. chinaCarNoSuff: '',
  202. carNo: '',
  203. customProof: '',
  204. quarantineProof: '',
  205. shop: '',
  206. productionCode: '',
  207. containerCode: ''
  208. },
  209. }
  210. },
  211. onShow() {},
  212. mounted() {
  213. this.checkStore();
  214. },
  215. onBackPress() {
  216. this.$common.to('/pages/index/index');
  217. return true;
  218. },
  219. methods: {
  220. createModal() {
  221. return {
  222. declarePeople: '',
  223. declarePhone: '',
  224. goodsName: '',
  225. grossWeight: '',
  226. num: '',
  227. productionDate: '',
  228. expirationDate: '',
  229. productionMode: '',
  230. origin: '',
  231. sendUnit: '',
  232. producerCode: '',
  233. receiveUnit: '',
  234. route: '',
  235. storageMode: '',
  236. driverName: '',
  237. driverPhone: '',
  238. agent: '',
  239. chinaCarNo: '',
  240. chinaCarNoSuff: '',
  241. carNo: '',
  242. customProof: '',
  243. quarantineProof: '',
  244. shop: '',
  245. productionCode: '',
  246. containerCode: ''
  247. }
  248. },
  249. cleanFn() {
  250. this.form = this.createModal();
  251. this.cleanStore();
  252. this.setInfo();
  253. },
  254. cleanStore() {
  255. uni.removeStorageSync('declare')
  256. uni.removeStorageSync('disinfect')
  257. },
  258. handler() {
  259. let cacheObj = {
  260. count: 0,
  261. cache: this.form
  262. }
  263. uni.setStorageSync('info',{declarePeople:this.form.declarePeople,declarePhone:this.form.declarePhone})
  264. uni.setStorageSync('declare', cacheObj);
  265. },
  266. addStoreCount() {
  267. let cacheObj = {
  268. count: 1,
  269. cache: this.form
  270. }
  271. uni.setStorageSync('declare', cacheObj);
  272. },
  273. setInfo(){
  274. let info=uni.getStorageSync('info');
  275. if(info){
  276. this.form.declarePeople=info.declarePeople;
  277. this.form.declarePhone=info.declarePhone
  278. }
  279. },
  280. checkStore() {
  281. let store = uni.getStorageSync('declare');
  282. this.setInfo();
  283. if (store && store.count == 0) {
  284. let that = this;
  285. let cache = store.cache;
  286. uni.showModal({
  287. title: '提示',
  288. content: '检测到您有未完成表单,是否继续?',
  289. success(resp) {
  290. if (resp.confirm) {
  291. that.form = cache
  292. } else {
  293. that.cleanFn();
  294. }
  295. }
  296. })
  297. }
  298. let disinfectStore = uni.getStorageSync('disinfect');
  299. if (disinfectStore) {
  300. let that = this;
  301. let cache = disinfectStore.cache;
  302. that.form.declarePeople = cache.declarePeople
  303. that.form.declarePhone = cache.declarePhone
  304. uni.showModal({
  305. title: '提示',
  306. content: '检测到最近有相似消杀申报信息,是否导入?',
  307. success(resp) {
  308. if (resp.confirm) {
  309. that.form = cache
  310. } else {
  311. that.cleanFn();
  312. }
  313. }
  314. })
  315. }
  316. },
  317. saveFn() {
  318. if (!this.form.declarePeople) {
  319. this.$common.toast('请填写申报人');
  320. return;
  321. }
  322. if (!this.$common.isPhone(this.form.declarePhone)) {
  323. this.$common.toast('请填写正确的申报电话');
  324. return;
  325. }
  326. if (!this.form.goodsName) {
  327. this.$common.toast('请填写产品');
  328. return;
  329. }
  330. if (!this.form.grossWeight || !this.$common.isNum(this.form.grossWeight)) {
  331. this.$common.toast('毛重只能填写数字');
  332. return;
  333. }
  334. if (!this.form.num || !this.$common.isNum(this.form.num)) {
  335. this.$common.toast('件数只能填整数');
  336. return;
  337. }
  338. if (!this.form.productionDate) {
  339. this.$common.toast('请选择生产日期');
  340. return;
  341. }
  342. if (!this.form.expirationDate || !this.$common.isNum(this.form.expirationDate)) {
  343. this.$common.toast('保质期为正数');
  344. return;
  345. }
  346. if (!this.form.storageMode) {
  347. this.$common.toast('请填写储藏条件');
  348. return;
  349. }
  350. if (!this.form.productionMode) {
  351. this.$common.toast('请填写生产方式');
  352. return;
  353. }
  354. if (!this.form.origin) {
  355. this.$common.toast('请输入原产国');
  356. return;
  357. }
  358. if (!this.form.sendUnit) {
  359. this.$common.toast('请填写货主单位');
  360. return;
  361. }
  362. if (!this.form.producerCode) {
  363. this.$common.toast('请填写生产商注册号');
  364. return;
  365. }
  366. if (!this.form.receiveUnit) {
  367. this.$common.toast('请填写收货单位');
  368. return;
  369. }
  370. if (!this.form.route) {
  371. this.$common.toast('请填写货物流向');
  372. return;
  373. }
  374. let chinaCarNo = this.form.chinaCarNo;
  375. if (!chinaCarNo) {
  376. this.$common.toast('请填写运输车辆车头牌');
  377. return;
  378. }
  379. let noArray = chinaCarNo.replace(",", ",").split(",");
  380. for (let i in noArray) {
  381. if (!this.$common.isCarNo(noArray[i])) {
  382. this.$common.toast('运输车头牌不正确');
  383. return;
  384. }
  385. }
  386. let chinaCarNoSuff = this.form.chinaCarNoSuff;
  387. if (!chinaCarNoSuff) {
  388. this.$common.toast('请填写运输车辆车尾牌');
  389. return;
  390. }
  391. let suffArray = chinaCarNoSuff.replace(",", ",").split(",");
  392. for (let i in suffArray) {
  393. if (!this.$common.isCarNo(suffArray[i])) {
  394. this.$common.toast('运输车尾牌不正确');
  395. return;
  396. }
  397. }
  398. if (!this.form.driverName) {
  399. this.$common.toast('请填写司机姓名');
  400. return;
  401. }
  402. let driverPhone = this.form.driverPhone;
  403. if (!driverPhone) {
  404. this.$common.toast('请填写司机号码');
  405. return;
  406. }
  407. let phoneArray = driverPhone.replace(",", ",").split(",");
  408. for (let i in phoneArray) {
  409. let phone = phoneArray[i];
  410. if (!this.$common.isPhone(phone)) {
  411. this.$common.toast('司机联系号码不正确');
  412. return;
  413. }
  414. }
  415. if (!this.$common.isPhone(this.form.agentPhone)) {
  416. this.$common.toast('代理商联系号码不正确');
  417. return;
  418. }
  419. if (!this.form.customProof) {
  420. this.$common.toast('海关报关单据');
  421. return;
  422. }
  423. if (!this.form.quarantineProof) {
  424. this.$common.toast('请填写检验检疫证');
  425. return;
  426. }
  427. if (!this.form.shop) {
  428. this.$common.toast('请填写商铺');
  429. return;
  430. }
  431. if (!this.form.productionCode) {
  432. this.$common.toast('请填写生产批号');
  433. return;
  434. }
  435. if (!this.form.containerCode) {
  436. this.$common.toast('请填写柜号');
  437. return;
  438. }
  439. if (!this.form.carNo) {
  440. this.$common.toast('请填写越南车牌号');
  441. return;
  442. }
  443. this.$api.addDeclare(this.$common.removeNull(this.form)).then(resp => {
  444. this.addStoreCount();
  445. if (resp.code == 200) {
  446. this.$common.to('/pages/declare/addDeclareSuccess')
  447. }
  448. })
  449. },
  450. },
  451. }
  452. </script>
  453. <style lang="scss">
  454. page {
  455. background-color: #fff;
  456. }
  457. .hs-item {
  458. text-align: center;
  459. }
  460. .item-line {
  461. color: #a2a2a2;
  462. padding: 5px 0 10px 29px;
  463. border-bottom: 1px solid #E5E5E5;
  464. }
  465. .hj {
  466. padding: 50rpx;
  467. font-size: 40rpx;
  468. color: red;
  469. font-weight: bold;
  470. }
  471. .save-btn {
  472. background-color: #ff4200;
  473. height: 88rpx;
  474. display: flex;
  475. justify-content: center;
  476. align-items: center;
  477. margin: 60rpx;
  478. color: #fff;
  479. font-size: 30rpx;
  480. font-weight: bold;
  481. border-radius: 10rpx;
  482. }
  483. @import '@/common/common.scss'
  484. </style>