addDisinfect.vue 12 KB

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