add.vue 18 KB

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