durg-batch.vue 9.9 KB

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