addDisinfect.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. }
  173. },
  174. onShow() {},
  175. mounted() {
  176. this.checkStore();
  177. },
  178. onBackPress() {
  179. this.$common.to('/pages/index/index');
  180. return true;
  181. },
  182. methods: {
  183. createModal() {
  184. return {
  185. sendPeople:'',
  186. receivePeople:'',
  187. declarePeople: '',
  188. declarePhone: '',
  189. goodsName: '',
  190. grossWeight: '',
  191. num: '',
  192. origin: '',
  193. unit: '',
  194. pack: '',
  195. flag: '',
  196. phone: '',
  197. sourceAddress: '',
  198. arrivePart: '',
  199. carName: '',
  200. carNo: '',
  201. chinaCarName: '',
  202. chinaCarNo: '',
  203. remark: ''
  204. }
  205. },
  206. cleanFn() {
  207. this.form = this.createModal();
  208. this.cleanStore();
  209. this.setInfo();
  210. },
  211. cleanStore() {
  212. uni.removeStorageSync('disinfect')
  213. uni.removeStorageSync('declare')
  214. },
  215. handler() {
  216. let cacheObj = {
  217. count: 0,
  218. cache: this.form
  219. }
  220. uni.setStorageSync('info',{declarePeople:this.form.declarePeople,declarePhone:this.form.declarePhone})
  221. uni.setStorageSync('disinfect', cacheObj);
  222. },
  223. addStoreCount() {
  224. let cacheObj = {
  225. count: 1,
  226. cache: this.form
  227. }
  228. uni.setStorageSync('disinfect', cacheObj);
  229. },
  230. setInfo(){
  231. let info=uni.getStorageSync('info');
  232. if(info){
  233. this.form.declarePeople=info.declarePeople;
  234. this.form.declarePhone=info.declarePhone
  235. }
  236. },
  237. checkStore() {
  238. this.setInfo();
  239. let disinfectStore = uni.getStorageSync('disinfect');
  240. if (disinfectStore && disinfectStore.count == 0) {
  241. let that = this;
  242. let cache=disinfectStore.cache;
  243. uni.showModal({
  244. title: '提示',
  245. content: '检测到您有未完成表单,是否继续?',
  246. success(resp) {
  247. if (resp.confirm) {
  248. that.form =cache
  249. } else {
  250. that.cleanFn();
  251. }
  252. }
  253. })
  254. }
  255. let declareStore = uni.getStorageSync('declare');
  256. if(declareStore){
  257. let that = this;
  258. let cache=declareStore.cache;
  259. that.form.declarePeople=cache.declarePeople
  260. that.form.declarePhone=cache.declarePhone
  261. uni.showModal({
  262. title: '提示',
  263. content: '检测到最近有相似申报信息,是否导入?',
  264. success(resp) {
  265. if (resp.confirm) {
  266. that.form=cache;
  267. } else {
  268. that.cleanFn();
  269. }
  270. }
  271. })
  272. }
  273. },
  274. saveFn() {
  275. if(!this.check()){
  276. return;
  277. }
  278. this.$api.addDisinfect(this.$common.removeNull(this.form)).then(resp => {
  279. this.addStoreCount();
  280. this.$common.to('/pages/disinfect/addDisinfectSuccess')
  281. })
  282. },
  283. check(){
  284. if (!this.form.sendPeople) {
  285. this.$common.toast('请填写发货人信息');
  286. return false;
  287. }
  288. if (!this.form.receivePeople) {
  289. this.$common.toast('请填写接货人信息');
  290. return false;
  291. }
  292. if (!this.form.goodsName) {
  293. this.$common.toast('请填写品名');
  294. return false;
  295. }
  296. if (!this.$common.isNum(this.form.num)) {
  297. this.$common.toast('数量请填写数字');
  298. return false;
  299. }
  300. if (!this.$common.isNum(this.form.grossWeight)) {
  301. this.$common.toast('请填写重量');
  302. return false;
  303. }
  304. if (!this.form.origin) {
  305. this.$common.toast('请填写原产地');
  306. return false;
  307. }
  308. if (!this.$common.isNum(this.form.unit)) {
  309. this.$common.toast('规格只能填写数字');
  310. return false;
  311. }
  312. if (!this.form.pack) {
  313. this.$common.toast('请填写包装');
  314. return false;
  315. }
  316. if (!this.form.flag) {
  317. this.$common.toast('请填写标记');
  318. return false;
  319. }
  320. if (!this.$common.isPhone(this.form.phone)) {
  321. this.$common.toast('请填写正确号码');
  322. return false;
  323. }
  324. if (!this.form.sourceAddress) {
  325. this.$common.toast('请填写启运地');
  326. return false;
  327. }
  328. if (!this.form.arrivePart) {
  329. this.$common.toast('请填写到货口岸');
  330. return false;
  331. }
  332. if (!this.form.carName) {
  333. this.$common.toast('请填写运输工具');
  334. return false;
  335. }
  336. if (!this.form.carNo) {
  337. this.$common.toast('请填写工具号码');
  338. return false;
  339. }
  340. if (!this.form.chinaCarName) {
  341. this.$common.toast('请填写国内运输工具');
  342. return false;
  343. }
  344. if (!this.form.chinaCarNo) {
  345. this.$common.toast('请填写国内运输工具号码');
  346. return false;
  347. }
  348. if (!this.form.declarePeople) {
  349. this.$common.toast('请填写申请人');
  350. return false;
  351. }
  352. if (!this.$common.isPhone(this.form.declarePhone)) {
  353. this.$common.toast('请填写正确申请电话');
  354. return false;
  355. }
  356. if (!this.form.applyUnit) {
  357. this.$common.toast('请填写申请单位');
  358. return false;
  359. }
  360. return true;
  361. }
  362. },
  363. }
  364. </script>
  365. <style lang="scss">
  366. page {
  367. background-color: #fff;
  368. }
  369. .hs-item {
  370. text-align: center;
  371. }
  372. .item-line {
  373. color: #a2a2a2;
  374. padding: 5px 0 10px 29px;
  375. border-bottom: 1px solid #E5E5E5;
  376. }
  377. .hj {
  378. padding: 50rpx;
  379. font-size: 40rpx;
  380. color: red;
  381. font-weight: bold;
  382. }
  383. .save-btn {
  384. background-color: #ff4200;
  385. height: 88rpx;
  386. display: flex;
  387. justify-content: center;
  388. align-items: center;
  389. margin: 60rpx;
  390. color: #fff;
  391. font-size: 30rpx;
  392. font-weight: bold;
  393. border-radius: 10rpx;
  394. }
  395. @import '@/common/common.scss'
  396. </style>