addDisinfect.vue 12 KB

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