batch.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <view class="query-wrap">
  3. <view class="inner-item">
  4. <view class="item-stats" @click.stop="addBatch()">
  5. 添加批次
  6. </view>
  7. <view class="inventory-item">
  8. <view class="shuo-item-name">
  9. <view class="shuo-label-podnme">
  10. 耗材编码
  11. </view>
  12. <view class="shuo-unit">
  13. {{formData.prodCode}}
  14. </view>
  15. </view>
  16. </view>
  17. <view class="inventory-item">
  18. <view class="shuo-item-name">
  19. <view class="shuo-label-podnme">
  20. 医保编码
  21. </view>
  22. <view class="shuo-unit">
  23. {{formData.hiCode}}
  24. </view>
  25. </view>
  26. </view>
  27. <view class="inventory-item">
  28. <view class="shuo-item-name">
  29. <view class="shuo-label-podnme">
  30. {{formData.prodName}}
  31. </view>
  32. <view class="shuo-unit">
  33. <span>{{ formData.purcUnt }} ({{ formData.convrat }}{{ formData.prcUnt }}/{{
  34. formData.purcUnt
  35. }})</span>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="inventory-item">
  40. <view class="shuo-item">
  41. <view class="shuo-label">
  42. 已出库数量:
  43. </view>
  44. <view class="shuo-cont">
  45. {{formData.delvCntYck}}
  46. </view>
  47. </view>
  48. <view class="shuo-item">
  49. <view class="shuo-label">
  50. 剩余出库量:
  51. </view>
  52. <view class="shuo-cont">
  53. {{formData.toDelvCnt}}
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="inner-item" v-for="(item,idex) in batchData[formData.id]" :key="idex">
  59. <view class="text-title">
  60. {{idex+1}}
  61. </view>
  62. <liu-swipe-action :index="idex" @clickItem="clickItem(idex)">
  63. <view class="inventory-item">
  64. <view class="shuo-item">
  65. <view class="shuo-label">
  66. 批号:
  67. </view>
  68. <view class="shuo-cont">
  69. {{item.lotNum}}
  70. </view>
  71. </view>
  72. <view class="shuo-item">
  73. <view class="shuo-label">
  74. 本次出库数:
  75. </view>
  76. <view class="shuo-cont">
  77. {{item.delvCnt}}
  78. </view>
  79. </view>
  80. </view>
  81. <view class="inventory-item">
  82. <view class="shuo-item-name">
  83. <view class="shuo-label">
  84. 生产日期:
  85. </view>
  86. <view class="shuo-cont">
  87. {{forMatTime(item.manuDate)}}
  88. </view>
  89. </view>
  90. </view>
  91. <view class="inventory-item">
  92. <view class="shuo-item-name">
  93. <view class="shuo-label">
  94. 有效期至:
  95. </view>
  96. <view class="shuo-cont">
  97. {{forMatTime(item.prodExpy)}}
  98. </view>
  99. </view>
  100. </view>
  101. </liu-swipe-action>
  102. </view>
  103. <view class="empty-cont" v-if="listData.length==0">
  104. 暂无明细
  105. </view>
  106. <uni-popup ref="popup">
  107. <uni-popup-dialog type="warn" :before-close="true" cancelText="取消" confirmText="确定" @confirm="dialogConfirm"
  108. @close="dialogClose">
  109. <UniForm ref="valiForm" :rules="rules" :modelValue="valiFormData">
  110. <UniFormItem label="批号" required name="lotNum" label-width=100>
  111. <uni-easyinput v-model="valiFormData.lotNum" placeholder="请输入批号" />
  112. </UniFormItem>
  113. <UniFormItem label="生产日期" required label-width=100>
  114. <UnidatetimePicker type="datetime" return-type="date" v-model="valiFormData.manuDate" />
  115. </UniFormItem>
  116. <UniFormItem label="有效期至" required label-width=100>
  117. <UnidatetimePicker type="datetime" return-type="date" v-model="valiFormData.prodExpy" />
  118. </UniFormItem>
  119. <UniFormItem label="出库数量" required label-width=100>
  120. <uni-number-box v-model="valiFormData.delvCnt" min="1" />
  121. </UniFormItem>
  122. </UniForm>
  123. </uni-popup-dialog>
  124. </uni-popup>
  125. <view class="botm-btn">
  126. <button type="default" plain="true" style="width:240rpx;line-height: 70rpx;background: #01A992;color:#fff"
  127. @click.stop="subMitData()">确定</button>
  128. </view>
  129. </view>
  130. </template>
  131. <script>
  132. import {
  133. mapState,
  134. mapMutations,
  135. mapActions
  136. } from 'vuex';
  137. import moment from "moment";
  138. import UnidatetimePicker from '@/subpkg/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue';
  139. import UniForm from '@/subpkg/uni_modules/uni-forms/components/uni-forms/uni-forms.vue';
  140. import UniFormItem from '@/subpkg/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item';
  141. const paging = {
  142. current: 1,
  143. size: 10000
  144. };
  145. export default {
  146. components: {
  147. UnidatetimePicker,
  148. UniForm,
  149. UniFormItem
  150. },
  151. data() {
  152. return {
  153. value: "",
  154. listData: [],
  155. formData: {},
  156. type: "",
  157. stas: "",
  158. delIndex: 0,
  159. icontext: "",
  160. valiFormData: {
  161. lotNum: "",
  162. manuDate: "",
  163. prodExpy: "",
  164. delvCnt: "1"
  165. },
  166. rules: {
  167. lotNum: {
  168. rules: [{
  169. required: true,
  170. errorMessage: '批号不能为空'
  171. }]
  172. },
  173. },
  174. }
  175. },
  176. computed: {
  177. ...mapState(['batchData'])
  178. },
  179. onShow() {
  180. let that = this;
  181. this.$forceUpdate();
  182. uni.getStorage({
  183. key: 'batchDelsData',
  184. success: function(res) {
  185. let lnumData = that.batchData[res.data.id] || [];
  186. if (lnumData.length > 0) {
  187. let count = 0;
  188. lnumData.forEach((item) => {
  189. count += Number(item.delvCnt)
  190. })
  191. let newDevCnt = Number(res.data.toDelvCnt) - count;
  192. that.formData = {
  193. ...res.data,
  194. toDelvCnt: newDevCnt
  195. };
  196. } else {
  197. that.formData = res.data;
  198. }
  199. }
  200. });
  201. },
  202. mounted() {
  203. },
  204. methods: {
  205. ...mapMutations(['setBatchData']),
  206. //添加批次
  207. addBatch() {
  208. let {
  209. toDelvCnt
  210. } = this.formData;
  211. if (toDelvCnt <= 0) {
  212. uni.showToast({
  213. title: '剩余出库量不足,不可添加批次',
  214. icon: 'none',
  215. duration: 1000,
  216. });
  217. return;
  218. }
  219. this.valiFormData = {
  220. lotNum: "",
  221. manuDate: "",
  222. prodExpy: "",
  223. delvCnt: "1"
  224. };
  225. this.$refs.popup.open();
  226. },
  227. forMatTime(row) {
  228. return moment(row).format("YYYY-MM-DD");
  229. },
  230. //确定删除
  231. clickItem(idx) {
  232. let {
  233. toDelvCnt
  234. } = this.formData;
  235. this.delIndex = idx;
  236. let stoBat = {
  237. ...this.batchData
  238. };
  239. let deleData = stoBat[this.formData.id];
  240. let newDcnt = Number(toDelvCnt) + Number(this.valiFormData.delvCnt);
  241. this.formData.toDelvCnt = newDcnt;
  242. deleData.splice(idx, 1);
  243. this.setBatchData({
  244. ...this.batchData,
  245. [this.formData.id]: deleData
  246. })
  247. },
  248. dialogClose() {
  249. this.$refs.popup.close();
  250. },
  251. //弹窗确定
  252. dialogConfirm() {
  253. this.$refs['valiForm'].validate().then(res => {
  254. if (this.valiFormData.manuDate == "") {
  255. uni.showToast({
  256. title: '生产日期不能为空',
  257. icon: 'none',
  258. duration: 1000,
  259. });
  260. return;
  261. }
  262. let batData = this.batchData[this.formData.id] || [];
  263. let filtNum = batData.filter((item) => {
  264. return item.lotNum === this.valiFormData.lotNum;
  265. })
  266. if (filtNum.length > 0) {
  267. uni.showToast({
  268. title: '批次号不可重复',
  269. icon: 'none',
  270. duration: 1000,
  271. });
  272. return;
  273. }
  274. if (this.valiFormData.prodExpy == "") {
  275. uni.showToast({
  276. title: '有效日期不能为空',
  277. icon: 'none',
  278. duration: 1000,
  279. });
  280. return;
  281. }
  282. if (this.valiFormData.prodExpy <= this.valiFormData.manuDate) {
  283. uni.showToast({
  284. title: '有效日期不能小于等于生产日期',
  285. icon: 'none',
  286. duration: 1000,
  287. });
  288. return;
  289. }
  290. this.editData(this.valiFormData);
  291. this.$refs.popup.close();
  292. }).catch(err => {
  293. })
  294. },
  295. editData(formData) {
  296. let {
  297. toDelvCnt
  298. } = this.formData;
  299. let filtBatch = this.batchData[this.formData.id] ? this.batchData[this.formData.id] : [];
  300. let newBatch = [...filtBatch, {
  301. ...this.formData,
  302. ...formData,
  303. manuDate: this.forMatTime(formData.manuDate),
  304. prodExpy: this.forMatTime(formData.prodExpy),
  305. materialId: this.formData.prodCode
  306. }];
  307. let remainData = Number(toDelvCnt) - Number(formData.delvCnt);
  308. if (remainData < 0) {
  309. uni.showToast({
  310. title: '出库数量大于了剩余出库数量',
  311. icon: 'none',
  312. duration: 1000,
  313. });
  314. return;
  315. }
  316. this.formData.toDelvCnt = remainData;
  317. this.setBatchData({
  318. ...this.batchData,
  319. [this.formData.id]: newBatch
  320. })
  321. },
  322. //批次提交
  323. subMitData() {
  324. uni.navigateBack({
  325. delta: 1
  326. })
  327. },
  328. },
  329. watch: {
  330. }
  331. }
  332. </script>
  333. <style lang="scss" scoped>
  334. .query-wrap {
  335. width: 100%;
  336. height: 100%;
  337. padding: 20rpx;
  338. box-sizing: border-box;
  339. background-color: #F1F1F1;
  340. overflow-y: scroll;
  341. overflow-x: hidden;
  342. position: relative;
  343. padding-bottom: 200rpx;
  344. .botm-btn {
  345. width: 100%;
  346. height: 120rpx;
  347. background-color: #fff;
  348. position: fixed;
  349. left: 0;
  350. bottom: 0;
  351. padding-top: 40rpx;
  352. }
  353. .empty-cont {
  354. width: 100%;
  355. height: 500rpx;
  356. display: flex;
  357. align-items: center;
  358. justify-content: center;
  359. }
  360. }
  361. uni-page-body {
  362. width: 100%;
  363. height: 100%;
  364. background-color: #F1F1F1;
  365. ;
  366. }
  367. </style>