add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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="请选择" :end="startDate" @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.chinaCarSuff" 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. startDate:new Date().getTime()-24*60*60*1000,
  183. form: {
  184. declarePeople: '',
  185. declarePhone: '',
  186. goodsName: '',
  187. grossWeight: '',
  188. num: '',
  189. productionDate: '',
  190. expirationDate: '',
  191. productionMode: '',
  192. origin: '',
  193. sendUnit: '',
  194. producerCode: '',
  195. receiveUnit: '',
  196. route: '',
  197. storageMode: '',
  198. driverName: '',
  199. driverPhone: '',
  200. agent: '',
  201. chinaCarNo: '',
  202. chinaCarSuff: '',
  203. carNo: '',
  204. customProof: '',
  205. quarantineProof: '',
  206. shop: '',
  207. productionCode: '',
  208. containerCode: '',
  209. },
  210. perList:[]
  211. }
  212. },
  213. onShow() {
  214. this.perList=uni.getStorageSync('perList');
  215. },
  216. mounted() {
  217. this.checkStore();
  218. },
  219. onBackPress() {
  220. this.$common.to('/pages/index/index');
  221. return true;
  222. },
  223. methods: {
  224. createModal() {
  225. return {
  226. declarePeople: '',
  227. declarePhone: '',
  228. goodsName: '',
  229. grossWeight: '',
  230. num: '',
  231. productionDate: this.$common.forDate(new Date().getTime()-24*60*60*1000,1),
  232. expirationDate: '',
  233. productionMode: '',
  234. origin: '',
  235. sendUnit: '',
  236. producerCode: '',
  237. receiveUnit: '',
  238. route: '',
  239. storageMode: '',
  240. driverName: '',
  241. driverPhone: '',
  242. agent: '',
  243. chinaCarNo: '',
  244. chinaCarSuff: '',
  245. carNo: '',
  246. customProof: '',
  247. quarantineProof: '',
  248. shop: '',
  249. productionCode: '',
  250. containerCode: ''
  251. }
  252. },
  253. cleanFn() {
  254. this.form = this.createModal();
  255. this.cleanStore();
  256. this.setInfo();
  257. },
  258. cleanStore() {
  259. uni.removeStorageSync('declare')
  260. uni.removeStorageSync('disinfect')
  261. },
  262. handler() {
  263. let cacheObj = {
  264. count: 0,
  265. cache: this.form
  266. }
  267. uni.setStorageSync('info',{declarePeople:this.form.declarePeople,declarePhone:this.form.declarePhone})
  268. uni.setStorageSync('declare', cacheObj);
  269. },
  270. addStoreCount() {
  271. let cacheObj = {
  272. count: 1,
  273. cache: this.form
  274. }
  275. uni.setStorageSync('declare', cacheObj);
  276. },
  277. setInfo(){
  278. let info=uni.getStorageSync('info');
  279. if(info){
  280. this.form.declarePeople=info.declarePeople;
  281. this.form.declarePhone=info.declarePhone
  282. }
  283. },
  284. checkStore() {
  285. let store = uni.getStorageSync('declare');
  286. this.setInfo();
  287. if (store && store.count == 0) {
  288. let that = this;
  289. let cache = store.cache;
  290. uni.showModal({
  291. title: '提示',
  292. content: '检测到您有未完成表单,是否继续?',
  293. success(resp) {
  294. if (resp.confirm) {
  295. that.form = cache
  296. if(!that.form.productionDate){
  297. that.form.productionDate=that.$common.forDate(new Date().getTime()-24*60*60*1000,1)
  298. }
  299. } else {
  300. that.cleanFn();
  301. }
  302. }
  303. })
  304. }
  305. let disinfectStore = uni.getStorageSync('disinfect');
  306. if (disinfectStore) {
  307. let that = this;
  308. let cache = disinfectStore.cache;
  309. that.form.declarePeople = cache.declarePeople
  310. that.form.declarePhone = cache.declarePhone
  311. uni.showModal({
  312. title: '提示',
  313. content: '检测到最近有相似消杀申报信息,是否导入?',
  314. success(resp) {
  315. if (resp.confirm) {
  316. that.form = cache
  317. } else {
  318. that.cleanFn();
  319. }
  320. }
  321. })
  322. }
  323. },
  324. saveFn() {
  325. if (!this.form.declarePeople) {
  326. this.$common.toast('请填写申报人');
  327. return;
  328. }
  329. if (!this.$common.isPhone(this.form.declarePhone)) {
  330. this.$common.toast('请填写正确的申报电话');
  331. return;
  332. }
  333. if (!this.form.goodsName) {
  334. this.$common.toast('请填写产品');
  335. return;
  336. }
  337. if (!this.form.grossWeight || !this.$common.isNum(this.form.grossWeight)) {
  338. this.$common.toast('毛重只能填写数字');
  339. return;
  340. }
  341. if (!this.form.num || !this.$common.isNum(this.form.num)) {
  342. this.$common.toast('件数只能填整数');
  343. return;
  344. }
  345. if (!this.form.productionDate) {
  346. this.$common.toast('请选择生产日期');
  347. return;
  348. }
  349. if (!this.form.expirationDate || !this.$common.isNum(this.form.expirationDate)) {
  350. this.$common.toast('保质期为正数');
  351. return;
  352. }
  353. if (!this.form.storageMode) {
  354. this.$common.toast('请填写储藏条件');
  355. return;
  356. }
  357. if (!this.form.productionMode) {
  358. this.$common.toast('请填写生产方式');
  359. return;
  360. }
  361. if (!this.form.origin) {
  362. this.$common.toast('请输入原产国');
  363. return;
  364. }
  365. if (!this.form.sendUnit) {
  366. this.$common.toast('请填写货主单位');
  367. return;
  368. }
  369. if (!this.form.producerCode) {
  370. this.$common.toast('请填写生产商注册号');
  371. return;
  372. }
  373. if (!this.form.receiveUnit) {
  374. this.$common.toast('请填写收货单位');
  375. return;
  376. }
  377. if (!this.form.route) {
  378. this.$common.toast('请填写货物流向');
  379. return;
  380. }
  381. let chinaCarNo = this.form.chinaCarNo;
  382. if (!chinaCarNo) {
  383. this.$common.toast('请填写运输车辆车头牌');
  384. return;
  385. }
  386. let noArray = chinaCarNo.replace(",", ",").split(",");
  387. for (let i in noArray) {
  388. noArray[i]=noArray[i].toUpperCase();
  389. if (!this.$common.isCarNo(noArray[i])) {
  390. this.$common.toast('运输车头牌不正确');
  391. return;
  392. }
  393. }
  394. let chinaCarSuff = this.form.chinaCarSuff;
  395. if (!chinaCarSuff) {
  396. this.$common.toast('请填写运输车辆车尾牌');
  397. return;
  398. }
  399. let suffArray = chinaCarSuff.replace(",", ",").split(",");
  400. for (let i in suffArray) {
  401. suffArray[i]=suffArray[i].toUpperCase();
  402. if (!this.$common.isCarNo(suffArray[i])) {
  403. this.$common.toast('运输车尾牌不正确');
  404. return;
  405. }
  406. }
  407. if (!this.form.driverName) {
  408. this.$common.toast('请填写司机姓名');
  409. return;
  410. }
  411. let driverPhone = this.form.driverPhone;
  412. if (!driverPhone) {
  413. this.$common.toast('请填写司机号码');
  414. return;
  415. }
  416. let phoneArray = driverPhone.replace(",", ",").split(",");
  417. for (let i in phoneArray) {
  418. let phone = phoneArray[i];
  419. if (!this.$common.isPhone(phone)) {
  420. this.$common.toast('司机联系号码不正确');
  421. return;
  422. }
  423. }
  424. if (!this.$common.isPhone(this.form.agentPhone)) {
  425. this.$common.toast('代理商联系号码不正确');
  426. return;
  427. }
  428. if (!this.form.customProof) {
  429. this.$common.toast('海关报关单据');
  430. return;
  431. }
  432. if (!this.form.quarantineProof) {
  433. this.$common.toast('请填写检验检疫证');
  434. return;
  435. }
  436. if (!this.form.shop) {
  437. this.$common.toast('请填写商铺');
  438. return;
  439. }
  440. if (!this.form.productionCode) {
  441. this.$common.toast('请填写生产批号');
  442. return;
  443. }
  444. if (!this.form.containerCode) {
  445. this.$common.toast('请填写柜号');
  446. return;
  447. }
  448. if (!this.form.carNo) {
  449. this.$common.toast('请填写越南车牌号');
  450. return;
  451. }
  452. this.$api.addDeclare(this.$common.removeNull(this.form)).then(resp => {
  453. if (resp.code == 200) {
  454. this.addStoreCount();
  455. this.$common.to('/pages/declare/addDeclareSuccess')
  456. }
  457. })
  458. },
  459. },
  460. }
  461. </script>
  462. <style lang="scss">
  463. page {
  464. background-color: #fff;
  465. }
  466. .hs-item {
  467. text-align: center;
  468. }
  469. .item-line {
  470. color: #a2a2a2;
  471. padding: 5px 0 10px 29px;
  472. border-bottom: 1px solid #E5E5E5;
  473. }
  474. .hj {
  475. padding: 50rpx;
  476. font-size: 40rpx;
  477. color: red;
  478. font-weight: bold;
  479. }
  480. .save-btn {
  481. background-color: #ff4200;
  482. height: 88rpx;
  483. display: flex;
  484. justify-content: center;
  485. align-items: center;
  486. margin: 60rpx;
  487. color: #fff;
  488. font-size: 30rpx;
  489. font-weight: bold;
  490. border-radius: 10rpx;
  491. }
  492. @import '@/common/common.scss'
  493. </style>