addDisinfect.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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" style="flex: 7;"><text style="color: red;">*</text>发货人名称:</view>
  9. <view class="r">
  10. <u-input placeholder="发货人名称" @input="handler()" v-model="form.sendPeople">
  11. </u-input>
  12. </view>
  13. </view>
  14. <view class="item">
  15. <view class="l" style="flex: 7;"><text style="color: red;">*</text>收货人名称:</view>
  16. <view class="r">
  17. <u-input placeholder="收货人名称" @input="handler()" v-model="form.receivePeople">
  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.num">
  32. </u-input>
  33. </view>
  34. </view>
  35. <view class="item">
  36. <view class="l"><text style="color: red;">*</text>重量:</view>
  37. <view class="r">
  38. <u-input type="number" placeholder="输入毛重" @input="handler()" v-model="form.grossWeight">
  39. <text slot="suffix">吨</text>
  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. <u-input placeholder="输入产地" @input="handler()" v-model="form.origin">
  47. </u-input>
  48. </view>
  49. </view>
  50. <view class="item">
  51. <view class="l"><text style="color: red;">*</text>规格:</view>
  52. <view class="r">
  53. <u-input type="number" placeholder="输入规格" @input="handler()" v-model="form.unit">
  54. <text slot="suffix">米</text>
  55. </u-input>
  56. </view>
  57. </view>
  58. <view class="item">
  59. <view class="l"><text style="color: red;">*</text>包装:</view>
  60. <view class="r">
  61. <view class="r">
  62. <u-input placeholder="输入包装" @input="handler()" v-model="form.pack" />
  63. </view>
  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.flag" />
  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 type="number" placeholder="号码" @input="handler()" v-model="form.phone" />
  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.sourceAddress" />
  82. </view>
  83. </view>
  84. <view class="item">
  85. <view class="l"><text style="color: red;">*</text>到货口岸:</view>
  86. <view class="r">
  87. <u-input placeholder="到货口岸" @input="handler()" v-model="form.arrivePart" />
  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.carName" />
  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.carNo" />
  100. </view>
  101. </view>
  102. <view class="item">
  103. <view class="l" style="flex: 7;"><text style="color: red;">*</text>国内运输工具:</view>
  104. <view class="r">
  105. <u-input placeholder="国内运输工具" @input="handler()" v-model="form.chinaCarName" />
  106. </view>
  107. </view>
  108. <view class="item">
  109. <view class="l"><text style="color: red;">*</text>工具号码:</view>
  110. <view class="r">
  111. <u-input placeholder="工具号码" @input="handler()" v-model="form.chinaCarNo" />
  112. </view>
  113. </view>
  114. <view class="item">
  115. <view class="l"><text style="color: red;">*</text>申报人:</view>
  116. <view class="r">
  117. <u-input placeholder="申报人" @input="handler()" v-model="form.declarePeople">
  118. </u-input>
  119. </view>
  120. </view>
  121. <view class="item">
  122. <view class="l"><text style="color: red;">*</text>申报电话:</view>
  123. <view class="r">
  124. <u-input type="number" placeholder="申报电话" @input="handler()" v-model="form.declarePhone">
  125. </u-input>
  126. </view>
  127. </view>
  128. <view class="item">
  129. <view class="l"><text style="color: red;">*</text>申报单位:</view>
  130. <view class="r">
  131. <u-input placeholder="申报单位" @input="handler()" v-model="form.applyUnit">
  132. </u-input>
  133. </view>
  134. </view>
  135. <view class="item">
  136. <view class="l" style="flex: 7;">其他要求:</view>
  137. <view class="r">
  138. <u--textarea @input="handler()" v-model="form.remark" placeholder="其他要求及备注">
  139. </u--textarea>
  140. </view>
  141. </view>
  142. </view>
  143. <u-button type="primary" text="确定" @click="saveFn"></u-button>
  144. <u-button type="info" text="重置" @click="cleanFn" style="margin-top: 20rpx;"></u-button>
  145. <!-- ---------------------------------------------------------- -->
  146. <view class="bottom-safety"></view>
  147. </view>
  148. </template>
  149. <script>
  150. export default {
  151. data() {
  152. return {
  153. form: {
  154. declarePeople: '',
  155. declarePhone: '',
  156. goodsName: '',
  157. grossWeight: '',
  158. num: '',
  159. origin: '',
  160. unit: '',
  161. pack: '',
  162. flag: '',
  163. phone: '',
  164. sourceAddress: '',
  165. arrivePart: '',
  166. carName: '',
  167. carNo: '',
  168. chinaCarName: '',
  169. chinaCarNo: '',
  170. remark: ''
  171. },
  172. perList:[]
  173. }
  174. },
  175. onShow() {
  176. this.perList=uni.getStorageSync('perList');
  177. },
  178. mounted() {
  179. this.checkStore();
  180. },
  181. onBackPress() {
  182. this.$common.to('/pages/index/index');
  183. return true;
  184. },
  185. methods: {
  186. createModal() {
  187. return {
  188. sendPeople:'',
  189. receivePeople:'',
  190. declarePeople: '',
  191. declarePhone: '',
  192. goodsName: '',
  193. grossWeight: '',
  194. num: '',
  195. origin: '',
  196. unit: '',
  197. pack: '',
  198. flag: '',
  199. phone: '',
  200. sourceAddress: '',
  201. arrivePart: '',
  202. carName: '',
  203. carNo: '',
  204. chinaCarName: '',
  205. chinaCarNo: '',
  206. remark: ''
  207. }
  208. },
  209. cleanFn() {
  210. this.form = this.createModal();
  211. this.cleanStore();
  212. this.setInfo();
  213. },
  214. cleanStore() {
  215. uni.removeStorageSync('disinfect')
  216. uni.removeStorageSync('declare')
  217. },
  218. handler() {
  219. let cacheObj = {
  220. count: 0,
  221. cache: this.form
  222. }
  223. uni.setStorageSync('info',{declarePeople:this.form.declarePeople,declarePhone:this.form.declarePhone})
  224. uni.setStorageSync('disinfect', cacheObj);
  225. },
  226. addStoreCount() {
  227. let cacheObj = {
  228. count: 1,
  229. cache: this.form
  230. }
  231. uni.setStorageSync('disinfect', cacheObj);
  232. },
  233. setInfo(){
  234. let info=uni.getStorageSync('info');
  235. if(info){
  236. this.form.declarePeople=info.declarePeople;
  237. this.form.declarePhone=info.declarePhone
  238. }
  239. },
  240. checkStore() {
  241. this.setInfo();
  242. let disinfectStore = uni.getStorageSync('disinfect');
  243. if (disinfectStore && disinfectStore.count == 0) {
  244. let that = this;
  245. let cache=disinfectStore.cache;
  246. uni.showModal({
  247. title: '提示',
  248. content: '检测到您有未完成表单,是否继续?',
  249. success(resp) {
  250. if (resp.confirm) {
  251. that.form =cache
  252. } else {
  253. that.cleanFn();
  254. }
  255. }
  256. })
  257. }
  258. let declareStore = uni.getStorageSync('declare');
  259. if(declareStore){
  260. let that = this;
  261. let cache=declareStore.cache;
  262. that.form.declarePeople=cache.declarePeople
  263. that.form.declarePhone=cache.declarePhone
  264. uni.showModal({
  265. title: '提示',
  266. content: '检测到最近有相似申报信息,是否导入?',
  267. success(resp) {
  268. if (resp.confirm) {
  269. that.form=cache;
  270. } else {
  271. that.cleanFn();
  272. }
  273. }
  274. })
  275. }
  276. },
  277. saveFn() {
  278. if(!this.check()){
  279. return;
  280. }
  281. this.$api.addDisinfect(this.$common.removeNull(this.form)).then(resp => {
  282. if(resp.code==200){
  283. this.addStoreCount();
  284. this.$common.to('/pages/disinfect/addDisinfectSuccess')
  285. }
  286. })
  287. },
  288. check(){
  289. if (!this.form.sendPeople) {
  290. this.$common.toast('请填写发货人信息');
  291. return false;
  292. }
  293. if (!this.form.receivePeople) {
  294. this.$common.toast('请填写接货人信息');
  295. return false;
  296. }
  297. if (!this.form.goodsName) {
  298. this.$common.toast('请填写品名');
  299. return false;
  300. }
  301. if (!this.$common.isNum(this.form.num)) {
  302. this.$common.toast('数量请填写数字');
  303. return false;
  304. }
  305. if (!this.$common.isNum(this.form.grossWeight)) {
  306. this.$common.toast('请填写重量');
  307. return false;
  308. }
  309. if (!this.form.origin) {
  310. this.$common.toast('请填写原产地');
  311. return false;
  312. }
  313. if (!this.$common.isNum(this.form.unit)) {
  314. this.$common.toast('规格只能填写数字');
  315. return false;
  316. }
  317. if (!this.form.pack) {
  318. this.$common.toast('请填写包装');
  319. return false;
  320. }
  321. if (!this.form.flag) {
  322. this.$common.toast('请填写标记');
  323. return false;
  324. }
  325. if (!this.$common.isPhone(this.form.phone)) {
  326. this.$common.toast('请填写正确号码');
  327. return false;
  328. }
  329. if (!this.form.sourceAddress) {
  330. this.$common.toast('请填写启运地');
  331. return false;
  332. }
  333. if (!this.form.arrivePart) {
  334. this.$common.toast('请填写到货口岸');
  335. return false;
  336. }
  337. if (!this.form.carName) {
  338. this.$common.toast('请填写运输工具');
  339. return false;
  340. }
  341. if (!this.form.carNo) {
  342. this.$common.toast('请填写工具号码');
  343. return false;
  344. }
  345. if (!this.form.chinaCarName) {
  346. this.$common.toast('请填写国内运输工具');
  347. return false;
  348. }
  349. if (!this.form.chinaCarNo) {
  350. this.$common.toast('请填写国内运输工具号码');
  351. return false;
  352. }
  353. if (!this.form.declarePeople) {
  354. this.$common.toast('请填写申请人');
  355. return false;
  356. }
  357. if (!this.$common.isPhone(this.form.declarePhone)) {
  358. this.$common.toast('请填写正确申请电话');
  359. return false;
  360. }
  361. if (!this.form.applyUnit) {
  362. this.$common.toast('请填写申请单位');
  363. return false;
  364. }
  365. return true;
  366. }
  367. },
  368. }
  369. </script>
  370. <style lang="scss">
  371. page {
  372. background-color: #fff;
  373. }
  374. .hs-item {
  375. text-align: center;
  376. }
  377. .item-line {
  378. color: #a2a2a2;
  379. padding: 5px 0 10px 29px;
  380. border-bottom: 1px solid #E5E5E5;
  381. }
  382. .hj {
  383. padding: 50rpx;
  384. font-size: 40rpx;
  385. color: red;
  386. font-weight: bold;
  387. }
  388. .save-btn {
  389. background-color: #ff4200;
  390. height: 88rpx;
  391. display: flex;
  392. justify-content: center;
  393. align-items: center;
  394. margin: 60rpx;
  395. color: #fff;
  396. font-size: 30rpx;
  397. font-weight: bold;
  398. border-radius: 10rpx;
  399. }
  400. @import '@/common/common.scss'
  401. </style>