add.vue 14 KB

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