add.vue 15 KB

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