addDisinfect.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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" style="flex: 7;">
  23. <text style="color: red;">*</text>
  24. 发货人名称:
  25. </view>
  26. <view class="r">
  27. <u-input placeholder="发货人名称" @input="handler()" v-model="form.sendPeople">
  28. </u-input>
  29. </view>
  30. </view>
  31. <view class="item">
  32. <view class="l" style="flex: 7;">
  33. <text style="color: red;">*</text>
  34. 收货人名称:
  35. </view>
  36. <view class="r">
  37. <u-input placeholder="收货人名称" @input="handler()" v-model="form.receivePeople">
  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.num">
  58. </u-input>
  59. </view>
  60. </view>
  61. <view class="item">
  62. <view class="l">
  63. <text style="color: red;">*</text>
  64. 重量:
  65. </view>
  66. <view class="r">
  67. <u-input type="number" placeholder="输入毛重" @input="handler()" v-model="form.grossWeight">
  68. <text slot="suffix">kg</text>
  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. <u-input placeholder="输入产地" @input="handler()" v-model="form.origin">
  79. </u-input>
  80. </view>
  81. </view>
  82. <view class="item">
  83. <view class="l">
  84. <text style="color: red;">*</text>
  85. 规格:
  86. </view>
  87. <view class="r">
  88. <u-input placeholder="输入规格" @input="handler()" v-model="form.unit">
  89. </u-input>
  90. </view>
  91. </view>
  92. <view class="item">
  93. <view class="l">
  94. <text style="color: red;">*</text>
  95. 包装:
  96. </view>
  97. <view class="r">
  98. <view class="r">
  99. <u-input placeholder="输入包装" @input="handler()" v-model="form.pack"/>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="item">
  104. <view class="l">
  105. <text style="color: red;">*</text>
  106. 标记:
  107. </view>
  108. <view class="r">
  109. <u-input placeholder="标记" @input="handler()" v-model="form.flag"/>
  110. </view>
  111. </view>
  112. <view class="item">
  113. <view class="l">
  114. <text style="color: red;">*</text>
  115. 号码:
  116. </view>
  117. <view class="r">
  118. <u-input type="number" placeholder="号码" @input="handler()" v-model="form.phone"/>
  119. </view>
  120. </view>
  121. <view class="item">
  122. <view class="l">
  123. <text style="color: red;">*</text>
  124. 启运地:
  125. </view>
  126. <view class="r">
  127. <u-input placeholder="启运地" @input="handler()" v-model="form.sourceAddress"/>
  128. </view>
  129. </view>
  130. <view class="item">
  131. <view class="l">
  132. <text style="color: red;">*</text>
  133. 到货口岸:
  134. </view>
  135. <view class="r">
  136. <u-input placeholder="到货口岸" @input="handler()" v-model="form.arrivePart"/>
  137. </view>
  138. </view>
  139. <view class="item">
  140. <view class="l">
  141. <text style="color: red;">*</text>
  142. 运输工具:
  143. </view>
  144. <view class="r">
  145. <u-input placeholder="运输工具" @input="handler()" v-model="form.carName"/>
  146. </view>
  147. </view>
  148. <view class="item">
  149. <view class="l">
  150. <text style="color: red;">*</text>
  151. 工具号码:
  152. </view>
  153. <view class="r">
  154. <u-input placeholder="运输工具号码" @input="handler()" v-model="form.carNo"/>
  155. </view>
  156. </view>
  157. <view class="item">
  158. <view class="l" style="flex: 7;">
  159. <text style="color: red;">*</text>
  160. 国内运输工具:
  161. </view>
  162. <view class="r">
  163. <u-input placeholder="国内运输工具" @input="handler()" v-model="form.chinaCarName"/>
  164. </view>
  165. </view>
  166. <view class="item">
  167. <view class="l">
  168. <text style="color: red;">*</text>
  169. 工具号码:
  170. </view>
  171. <view class="r">
  172. <u-input placeholder="工具号码" @input="handler()" v-model="form.chinaCarNo"/>
  173. </view>
  174. </view>
  175. <view class="item">
  176. <view class="l">
  177. <text style="color: red;">*</text>
  178. 申报人:
  179. </view>
  180. <view class="r">
  181. <u-input placeholder="申报人" @input="handler()" v-model="form.declarePeople">
  182. </u-input>
  183. </view>
  184. </view>
  185. <view class="item">
  186. <view class="l">
  187. <text style="color: red;">*</text>
  188. 申报电话:
  189. </view>
  190. <view class="r">
  191. <u-input type="number" placeholder="申报电话" @input="handler()" v-model="form.declarePhone">
  192. </u-input>
  193. </view>
  194. </view>
  195. <!-- <view class="item">
  196. <view class="l"><text style="color: red;">*</text>申报单位:</view>
  197. <view class="r">
  198. <u-input placeholder="申报单位" @input="handler()" v-model="form.applyUnit">
  199. </u-input>
  200. </view>
  201. </view> -->
  202. <view class="item">
  203. <view class="l" style="flex: 7;">其他要求:</view>
  204. <view class="r">
  205. <u--textarea @input="handler()" v-model="form.remark" placeholder="其他要求及备注">
  206. </u--textarea>
  207. </view>
  208. </view>
  209. </view>
  210. <u-button type="primary" text="确定" @click="saveFn"></u-button>
  211. <u-button type="info" text="重置" @click="cleanFn" style="margin-top: 20rpx;"></u-button>
  212. <!-- ---------------------------------------------------------- -->
  213. <view class="bottom-safety"></view>
  214. </view>
  215. </template>
  216. <script>
  217. export default {
  218. data() {
  219. return {
  220. customerId: '1',
  221. customer: {
  222. index: 0,
  223. customerList: [],
  224. },
  225. form: {
  226. declarePeople: '',
  227. declarePhone: '',
  228. goodsName: '',
  229. grossWeight: '',
  230. num: '',
  231. origin: '',
  232. unit: '',
  233. pack: '',
  234. flag: '',
  235. phone: '',
  236. sourceAddress: '',
  237. arrivePart: '',
  238. carName: '',
  239. carNo: '',
  240. chinaCarName: '',
  241. chinaCarNo: '',
  242. remark: ''
  243. },
  244. perList: []
  245. }
  246. },
  247. onShow() {
  248. this.customerId = uni.getStorageSync('customerId');
  249. this.perList = uni.getStorageSync('perList');
  250. },
  251. mounted() {
  252. this.checkStore();
  253. this.getCustomerList();
  254. },
  255. onBackPress() {
  256. this.$common.to('/pages/index/index');
  257. return true;
  258. },
  259. methods: {
  260. createModal() {
  261. return {
  262. sendPeople: '',
  263. receivePeople: '',
  264. declarePeople: '',
  265. declarePhone: '',
  266. goodsName: '',
  267. grossWeight: '',
  268. num: '',
  269. origin: '',
  270. unit: '',
  271. pack: '',
  272. flag: '',
  273. phone: '',
  274. sourceAddress: '',
  275. arrivePart: '',
  276. carName: '',
  277. carNo: '',
  278. chinaCarName: '',
  279. chinaCarNo: '',
  280. remark: ''
  281. }
  282. },
  283. getCustomerList() {
  284. this.$api.getCustomerList({type: 0}).then(resp => {
  285. this.customer.customerList = resp.data;
  286. })
  287. },
  288. bindPickerChange(e) {
  289. var value = e.detail.value; //当前picker选中的值
  290. this.customer.index = value;
  291. this.handler();
  292. },
  293. cleanFn() {
  294. this.form = this.createModal();
  295. this.cleanStore();
  296. this.setInfo();
  297. },
  298. cleanStore() {
  299. uni.removeStorageSync('disinfect')
  300. uni.removeStorageSync('declare')
  301. },
  302. handler() {
  303. let cacheObj = {
  304. count: 0,
  305. cache: this.form
  306. }
  307. uni.setStorageSync('info', {
  308. declarePeople: this.form.declarePeople,
  309. declarePhone: this.form.declarePhone
  310. })
  311. uni.setStorageSync('disinfect', cacheObj);
  312. },
  313. addStoreCount() {
  314. let cacheObj = {
  315. count: 1,
  316. cache: this.form
  317. }
  318. uni.setStorageSync('disinfect', cacheObj);
  319. },
  320. setInfo() {
  321. let info = uni.getStorageSync('info');
  322. if (info) {
  323. this.form.declarePeople = info.declarePeople;
  324. this.form.declarePhone = info.declarePhone
  325. }
  326. },
  327. checkStore() {
  328. this.setInfo();
  329. let disinfectStore = uni.getStorageSync('disinfect');
  330. if (disinfectStore && disinfectStore.count == 0) {
  331. let that = this;
  332. let cache = disinfectStore.cache;
  333. uni.showModal({
  334. title: '提示',
  335. content: '检测到您有未完成表单,是否继续?',
  336. success(resp) {
  337. if (resp.confirm) {
  338. that.form = cache
  339. } else {
  340. that.cleanFn();
  341. }
  342. }
  343. })
  344. }
  345. let declareStore = uni.getStorageSync('declare');
  346. if (declareStore) {
  347. let that = this;
  348. let cache = declareStore.cache;
  349. that.form.declarePeople = cache.declarePeople
  350. that.form.declarePhone = cache.declarePhone
  351. uni.showModal({
  352. title: '提示',
  353. content: '检测到最近有相似申报信息,是否导入?',
  354. success(resp) {
  355. if (resp.confirm) {
  356. that.form = cache;
  357. } else {
  358. that.cleanFn();
  359. }
  360. }
  361. })
  362. }
  363. },
  364. saveFn() {
  365. if (!this.check()) {
  366. return;
  367. }
  368. if (this.customerId == '1') {
  369. this.form.customerId = this.customer.customerList[this.customer.index].id;
  370. } else {
  371. this.form.customerId = this.customerId;
  372. }
  373. this.$api.addDisinfect(this.$common.removeNull(this.form)).then(resp => {
  374. if (resp.code == 200) {
  375. this.addStoreCount();
  376. this.$common.to('/pages/disinfect/addDisinfectSuccess')
  377. }
  378. })
  379. },
  380. check() {
  381. if (!this.form.sendPeople) {
  382. this.$common.toast('请填写发货人信息');
  383. return false;
  384. }
  385. if (!this.form.receivePeople) {
  386. this.$common.toast('请填写接货人信息');
  387. return false;
  388. }
  389. if (!this.form.goodsName) {
  390. this.$common.toast('请填写品名');
  391. return false;
  392. }
  393. if (!this.$common.isNum(this.form.num)) {
  394. this.$common.toast('数量请填写数字');
  395. return false;
  396. }
  397. if (!this.$common.isNum(this.form.grossWeight)) {
  398. this.$common.toast('请填写重量');
  399. return false;
  400. }
  401. if (!this.form.origin) {
  402. this.$common.toast('请填写原产地');
  403. return false;
  404. }
  405. if (!this.form.pack) {
  406. this.$common.toast('请填写包装');
  407. return false;
  408. }
  409. if (!this.form.flag) {
  410. this.$common.toast('请填写标记');
  411. return false;
  412. }
  413. if (!this.form.phone) {
  414. this.$common.toast('请填写号码');
  415. return false;
  416. }
  417. if (!this.form.sourceAddress) {
  418. this.$common.toast('请填写启运地');
  419. return false;
  420. }
  421. if (!this.form.arrivePart) {
  422. this.$common.toast('请填写到货口岸');
  423. return false;
  424. }
  425. if (!this.form.carName) {
  426. this.$common.toast('请填写运输工具');
  427. return false;
  428. }
  429. if (!this.form.carNo) {
  430. this.$common.toast('请填写工具号码');
  431. return false;
  432. }
  433. if (!this.form.chinaCarName) {
  434. this.$common.toast('请填写国内运输工具');
  435. return false;
  436. }
  437. if (!this.form.chinaCarNo) {
  438. this.$common.toast('请填写国内运输工具号码');
  439. return false;
  440. }
  441. if (!this.form.declarePeople) {
  442. this.$common.toast('请填写申请人');
  443. return false;
  444. }
  445. if (!this.$common.isPhone(this.form.declarePhone)) {
  446. this.$common.toast('请填写正确申请电话');
  447. return false;
  448. }
  449. return true;
  450. }
  451. },
  452. }
  453. </script>
  454. <style lang="scss">
  455. page {
  456. background-color: #fff;
  457. }
  458. .hs-item {
  459. text-align: center;
  460. }
  461. .item-line {
  462. color: #a2a2a2;
  463. padding: 5px 0 10px 29px;
  464. border-bottom: 1px solid #E5E5E5;
  465. }
  466. .hj {
  467. padding: 50rpx;
  468. font-size: 40rpx;
  469. color: red;
  470. font-weight: bold;
  471. }
  472. .save-btn {
  473. background-color: #ff4200;
  474. height: 88rpx;
  475. display: flex;
  476. justify-content: center;
  477. align-items: center;
  478. margin: 60rpx;
  479. color: #fff;
  480. font-size: 30rpx;
  481. font-weight: bold;
  482. border-radius: 10rpx;
  483. }
  484. @import '@/common/common.scss'
  485. </style>