drugStockInOrderAdd.vue 40KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb v-if="type == 1" :crumbs="crumbs"></bread-crumb>
  5. <bread-crumb v-if="type == 2" :crumbs="crumbs2"></bread-crumb>
  6. <div style="float: right">
  7. <el-button size="small" @click="back()" class="filter-item"
  8. >取 消</el-button
  9. >
  10. <el-button
  11. size="small"
  12. type="primary"
  13. @click="submit()"
  14. class="filter-item"
  15. >保 存</el-button
  16. >
  17. <el-button
  18. size="small"
  19. type="primary"
  20. @click="toCheck()"
  21. v-show ="showCheck"
  22. class="filter-item"
  23. >审核</el-button
  24. >
  25. <!-- <el-button
  26. size="small"
  27. type="primary"
  28. @click="toReturnCheck()"
  29. v-show ="showReturnCheck"
  30. class="filter-item"
  31. >反审核</el-button
  32. > -->
  33. </div>
  34. </div>
  35. <div class="app-container" v-loading="loading">
  36. <drugs-stock-dialog
  37. ref="dialog"
  38. :propForm="propForm"
  39. :visibility="isVisibility"
  40. v-on:dialog-comfirm="comfirm"
  41. v-on:dialog-cancle="cancle"
  42. ></drugs-stock-dialog>
  43. <div class="cell clearfix">
  44. <label class="title"
  45. ><span class="name"><span style="color: red">*</span>仓库</span>
  46. :</label
  47. >
  48. <el-select
  49. size="small"
  50. v-model="storehouse_id"
  51. filterable
  52. placeholder="请选择仓库"
  53. style="width: 200px"
  54. >
  55. <el-option
  56. v-for="(option, index) in list"
  57. :key="index"
  58. :label="option.storehouse_name"
  59. :value="option.id"
  60. >
  61. </el-option>
  62. </el-select>
  63. <label class="title"><span class="name">入库时间</span> : </label>
  64. <el-date-picker
  65. size="small"
  66. v-model="warehousing_time"
  67. prefix-icon="el-icon-date"
  68. :editable="false"
  69. style="width: 196px"
  70. type="date"
  71. placeholder="选择日期时间"
  72. align="right"
  73. format="yyyy-MM-dd"
  74. value-format="yyyy-MM-dd"
  75. ></el-date-picker>
  76. <div class="titleOne">
  77. 制单人:{{ this.$store.getters.xt_user.user.user_name }}
  78. </div>
  79. </div>
  80. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  81. <el-table
  82. id="oictable"
  83. :data="recordInfo.recordData"
  84. :class="signAndWeighBoxPatients"
  85. style="width: 100%"
  86. border
  87. max-height="450"
  88. v-loading="listLoading"
  89. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  90. >
  91. <el-table-column align="center" width="200" fixed="left">
  92. <template slot="header" slot-scope="scope">
  93. <span>药品名称<span style="color: red">*</span></span>
  94. </template>
  95. <template slot-scope="scope">
  96. <el-form-item style="padding-top: 20px">
  97. <el-autocomplete
  98. class="checkSearch"
  99. popper-class="my-autocomplete"
  100. v-model="scope.row.drug_name"
  101. :fetch-suggestions="querySearchAsync"
  102. :trigger-on-focus="true"
  103. placeholder="请输入药品名称"
  104. @select="handleSelect"
  105. @input="changeDrugName(scope.$index)"
  106. style="width: 160px"
  107. >
  108. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  109. <template slot-scope="{ item }">
  110. <div class="name">
  111. {{
  112. item.drug_name +
  113. item.dose +
  114. item.dose_unit +
  115. "*" +
  116. item.min_number +
  117. item.min_unit +
  118. "/" +
  119. item.max_unit +
  120. " " +
  121. item.manufacturer
  122. }}
  123. </div>
  124. </template>
  125. </el-autocomplete>
  126. </el-form-item>
  127. </template>
  128. </el-table-column>
  129. <el-table-column align="center" width="140">
  130. <template slot="header" slot-scope="scope">
  131. <span>药品类型</span>
  132. </template>
  133. <template slot-scope="scope">
  134. <el-select
  135. v-model="scope.row.drug_type"
  136. filterable
  137. placeholder="请选择药品类型"
  138. >
  139. <el-option
  140. v-for="(option, index) in drugTypeList"
  141. :key="index"
  142. :label="option.name"
  143. :value="option.id"
  144. >
  145. </el-option>
  146. </el-select>
  147. </template>
  148. </el-table-column>
  149. <el-table-column align="center" width="140">
  150. <template slot="header" slot-scope="scope">
  151. <span>规格&单位</span>
  152. </template>
  153. <template slot-scope="scope">
  154. <el-form-item style="padding-top: 20px">
  155. <el-input
  156. :disabled="true"
  157. placeholder="请输入规格&单位"
  158. v-model="scope.row.name"
  159. ></el-input>
  160. </el-form-item>
  161. </template>
  162. </el-table-column>
  163. <el-table-column align="center" width="150">
  164. <template slot="header" slot-scope="scope">
  165. <span>批号<span style="color: red">*</span></span>
  166. </template>
  167. <template slot-scope="scope">
  168. <el-form-item
  169. style="padding-top: 20px"
  170. :rules="tableRules.batch_number"
  171. :prop="'recordData.' + scope.$index + '.batch_number'"
  172. >
  173. <el-input
  174. placeholder="请输入批号"
  175. v-model="scope.row.batch_number"
  176. ></el-input>
  177. </el-form-item>
  178. </template>
  179. </el-table-column>
  180. <el-table-column align="center" width="200">
  181. <template slot="header" slot-scope="scope">
  182. <span>入库数量<span style="color: red">*</span></span>
  183. </template>
  184. <template slot-scope="scope">
  185. <el-form-item
  186. :prop="'recordData.' + scope.$index + '.warehousing_count'"
  187. :rules="tableRules.warehousing_count"
  188. style="padding-top: 10px"
  189. >
  190. <div style="display: flex">
  191. <!-- <el-input
  192. oninput="value=value.replace(/\D|^0/g,'')"
  193. placeholder="请输入入库数量"
  194. type="number"
  195. v-model="scope.row.warehousing_count"
  196. style="width:120px"
  197. ></el-input> -->
  198. <el-input
  199. placeholder="请输入入库数量"
  200. v-model="scope.row.warehousing_count"
  201. style="width: 120px"
  202. ></el-input>
  203. <!-- {{scope.row.max_unit}} -->
  204. <el-select
  205. v-model="scope.row.max_unit"
  206. filterable
  207. placeholder="请选择单位"
  208. style="width: 80px"
  209. @change="changeUnit(scope.row,scope.$index)"
  210. >
  211. <el-option
  212. v-for="(option, index) in scope.row.unitList"
  213. :key="index"
  214. :label="option.name"
  215. :value="option.name"
  216. >
  217. </el-option>
  218. </el-select>
  219. </div>
  220. </el-form-item>
  221. </template>
  222. </el-table-column>
  223. <el-table-column align="center" width="140">
  224. <template slot="header" slot-scope="scope">
  225. <span>拆零零售价(元)<span style="color: red">*</span></span>
  226. </template>
  227. <template slot-scope="scope">
  228. <el-form-item
  229. :prop="'recordData.' + scope.$index + '.retail_price'"
  230. :rules="tableRules.retail_price"
  231. style="padding-top: 20px"
  232. >
  233. <el-input
  234. style="width: 100px"
  235. placeholder="请输入拆零零售价"
  236. type="number"
  237. v-model="scope.row.retail_price"
  238. ></el-input>
  239. </el-form-item>
  240. </template>
  241. </el-table-column>
  242. <el-table-column align="center" width="120">
  243. <template slot="header" slot-scope="scope">
  244. <span>进货单价(元)<span style="color: red">*</span></span>
  245. </template>
  246. <template slot-scope="scope">
  247. <el-form-item
  248. :prop="'recordData.' + scope.$index + '.price'"
  249. :rules="tableRules.last_price"
  250. style="padding-top: 20px"
  251. >
  252. <el-input
  253. style="width: 100px"
  254. placeholder="请输入单价"
  255. type="number"
  256. v-model="scope.row.last_price"
  257. ></el-input>
  258. </el-form-item>
  259. </template>
  260. </el-table-column>
  261. <el-table-column label="总价(元)" align="center" width="80">
  262. <template slot-scope="scope">
  263. {{ calculate(scope.row.last_price * scope.row.warehousing_count) }}
  264. </template>
  265. </el-table-column>
  266. <el-table-column width="180" align="center">
  267. <template slot="header" slot-scope="scope">
  268. <span>有效日期<span style="color: red">*</span></span>
  269. </template>
  270. <template slot-scope="scope">
  271. <el-form-item
  272. :prop="'recordData.' + scope.$index + '.expiry_date'"
  273. :rules="tableRules.expiry_date"
  274. style="padding-top: 20px"
  275. >
  276. <el-date-picker
  277. prefix-icon="el-icon-date"
  278. style="width: 145px"
  279. v-model="scope.row.expiry_date"
  280. type="date"
  281. placeholder="选择日期时间"
  282. format="yyyy-MM-dd"
  283. value-format="yyyy-MM-dd"
  284. ></el-date-picker>
  285. </el-form-item>
  286. </template>
  287. </el-table-column>
  288. <el-table-column label="生产日期" width="180" align="center">
  289. <template slot-scope="scope">
  290. <el-date-picker
  291. prefix-icon="el-icon-date"
  292. style="width: 145px"
  293. v-model="scope.row.product_date"
  294. type="date"
  295. placeholder="选择日期时间"
  296. format="yyyy-MM-dd"
  297. value-format="yyyy-MM-dd"
  298. ></el-date-picker>
  299. </template>
  300. </el-table-column>
  301. <el-table-column label="生产厂家" width="140" align="center">
  302. <template slot-scope="scope">
  303. <el-select
  304. v-model="scope.row.manufacturer"
  305. filterable
  306. placeholder="请选择厂商"
  307. >
  308. <el-option
  309. v-for="(option, index) in manufacturerList"
  310. :key="index"
  311. :label="option.manufacturer_name"
  312. :value="option.id"
  313. >
  314. </el-option>
  315. </el-select>
  316. </template>
  317. </el-table-column>
  318. <el-table-column label="经销商" width="140" align="center">
  319. <template slot-scope="scope">
  320. <el-select
  321. v-model="scope.row.dealer"
  322. filterable
  323. placeholder="请选择厂商"
  324. >
  325. <el-option
  326. v-for="(option, index) in dealerList"
  327. :key="index"
  328. :label="option.dealer_name"
  329. :value="option.id"
  330. >
  331. </el-option>
  332. </el-select>
  333. </template>
  334. </el-table-column>
  335. <el-table-column align="center" width="150" label="批准文号">
  336. <template slot-scope="scope">
  337. <el-form-item style="padding-top: 20px">
  338. <el-input
  339. placeholder="请输入批准文号"
  340. v-model="scope.row.number"
  341. ></el-input>
  342. </el-form-item>
  343. </template>
  344. </el-table-column>
  345. <el-table-column label="药品追溯码" width="150" align="center">
  346. <template slot-scope="scope">
  347. <el-input v-model="scope.row.drug_code" placeholder="请输入药品追溯码"></el-input>
  348. </template>
  349. </el-table-column>
  350. <el-table-column label="备注" width="150" align="center">
  351. <template slot-scope="scope">
  352. <el-input v-model="scope.row.remark" placeholder="请输入备注"></el-input>
  353. </template>
  354. </el-table-column>
  355. <el-table-column
  356. label="操作"
  357. fixed="right"
  358. align="center"
  359. width="150"
  360. >
  361. <template slot-scope="scope">
  362. <el-tooltip
  363. class="item"
  364. effect="dark"
  365. content="新增"
  366. placement="top"
  367. >
  368. <el-button
  369. size="mini"
  370. type="primary"
  371. icon="el-icon-circle-plus-outline"
  372. @click="handleEdit(scope.$index, scope.row)"
  373. >
  374. </el-button>
  375. </el-tooltip>
  376. <el-tooltip
  377. class="item"
  378. effect="dark"
  379. content="删除"
  380. placement="top"
  381. >
  382. <el-button
  383. size="mini"
  384. type="danger"
  385. icon="el-icon-delete"
  386. @click="handleDelete(scope.$index, scope.row)"
  387. >
  388. </el-button>
  389. </el-tooltip>
  390. </template>
  391. </el-table-column>
  392. </el-table>
  393. <div style="margin-top: 20px;">合计金额: {{getTotalPirce() }} </div>
  394. </el-form>
  395. </div>
  396. </div>
  397. </template>
  398. <script>
  399. import { uParseTime } from "@/utils/tools";
  400. import {
  401. GetAllConfig,
  402. GetAllDrugInfoByID,
  403. postDrugWarehouse,
  404. toCheckWarehousingInfo,
  405. toReturnCheckWarehousing
  406. } from "@/api/drug/drug_stock";
  407. import BreadCrumb from "../../components/bread-crumb";
  408. import DrugsStockDialog from "./drugsStockDialog/index";
  409. import { getDataConfig, getDictionaryDataConfig } from "@/utils/data";
  410. import { getAllDrugList, postSearchDrugList } from "@/api/data";
  411. export default {
  412. components: { DrugsStockDialog, BreadCrumb },
  413. name: "stockIn",
  414. data() {
  415. var checkGoodId = (rule, value, callback) => {
  416. setTimeout(() => {
  417. if (value == "" || value == 0) {
  418. return callback(new Error("规格名称不能为空"));
  419. }
  420. }, 2000);
  421. };
  422. return {
  423. crumbs: [
  424. { path: false, name: "库存管理" },
  425. { path: false, name: "药品入库单" },
  426. { path: false, name: "新增入库单" },
  427. ],
  428. crumbs2: [
  429. { path: false, name: "库存管理" },
  430. { path: false, name: "其他入库单" },
  431. { path: false, name: "新增入库单" },
  432. ],
  433. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  434. warehousing_time: "",
  435. adminUserOptions: null,
  436. currentIndex: 0,
  437. listLoading: false,
  438. recordInfo: {
  439. recordData: [],
  440. stock_in_code: "",
  441. current_index: "",
  442. },
  443. tableRules: {
  444. price: [{ required: true, message: "单价不能为空", trigger: "blur" }],
  445. warehousing_count: [
  446. { required: true, message: "数量不能为空", trigger: "blur" },
  447. ],
  448. good_id: [{ validator: checkGoodId, trigger: "blur" }],
  449. min_unit: [
  450. { required: true, message: "单位不能为空", trigger: "blur" },
  451. ],
  452. batch_number: [
  453. { required: true, message: "批号不能为空", trigger: "blur" },
  454. ],
  455. expiry_date: [
  456. { required: true, message: "有效日期不能为空", trigger: "blur" },
  457. ],
  458. retail_price: [
  459. { required: true, message: "请输入包装零售价", trigger: "blur" },
  460. ],
  461. },
  462. type: this.$route.query.type,
  463. total: "",
  464. product_date: "",
  465. expiry_date: "",
  466. numbers: "",
  467. // prop
  468. isVisibility: false,
  469. propForm: {
  470. goods: [],
  471. goodType: [],
  472. goodInfo: [],
  473. goodUnit: [],
  474. title: "入库",
  475. formValue: {
  476. good_type_id: "",
  477. good_id: "",
  478. number: "",
  479. product_date: "",
  480. expiry_date: "",
  481. warehousing_count: "",
  482. price: "",
  483. remark: "",
  484. dealer: "",
  485. manufacturer: "",
  486. },
  487. isCreated: 1,
  488. },
  489. form: {
  490. manufacturer: "",
  491. dealer: "",
  492. },
  493. formValue: {
  494. good_type_id: "",
  495. good_id: "",
  496. number: "",
  497. product_date: "",
  498. expiry_date: "",
  499. warehousing_count: "",
  500. price: "",
  501. remark: "",
  502. dealer: "",
  503. manufacturer: "",
  504. },
  505. manufacturer: [],
  506. dealer: [],
  507. goodType: [],
  508. goodInfo: [],
  509. drugList: [],
  510. manufacturerList: [],
  511. dealerList: [],
  512. showOne: true,
  513. showTwo: false,
  514. drugTypeList: [],
  515. totalPrice: 0,
  516. unitList: [],
  517. loading: false,
  518. list: [],
  519. storehouse_id: "",
  520. warehousing_id:0,
  521. showCheck:false,
  522. showReturnCheck:false,
  523. };
  524. },
  525. methods: {
  526. handleSave: function () {
  527. if (this.recordInfo.recordData.length <= 0) {
  528. this.$message.error("请添加入库信息");
  529. return;
  530. }
  531. sessionStorage.removeItem("warehousing_orders");
  532. this.$router.back(-1);
  533. },
  534. handleCancle: function () {
  535. this.$confirm("是否放弃编辑返回上一页?", "放弃编辑", {
  536. confirmButtonText: "确定",
  537. cancelButtonText: "取消",
  538. type: "warning",
  539. })
  540. .then(() => {
  541. sessionStorage.removeItem("warehousing_orders");
  542. this.$router.back(-1);
  543. })
  544. .catch(() => {});
  545. },
  546. handleCreate: function () {
  547. this.propForm.formValue = {};
  548. this.propForm.isCreated = 1;
  549. this.isVisibility = true;
  550. },
  551. comfirm: function (val) {
  552. this.$refs.dialog.hide();
  553. if (val.selectedGoodInfo.length > 0) {
  554. for (let i = val.selectedGoodInfo.length - 1; i >= 0; i--) {
  555. if (i == 0) {
  556. this.recordInfo.recordData[this.currentIndex].drug_id =
  557. val.selectedGoodInfo[i].id;
  558. this.recordInfo.recordData[this.currentIndex].price =
  559. val.selectedGoodInfo[i].last_price.toString();
  560. this.recordInfo.recordData[this.currentIndex].retail_price =
  561. val.selectedGoodInfo[i].retail_price.toString();
  562. this.recordInfo.recordData[this.currentIndex].min_unit =
  563. val.selectedGoodInfo[i].min_unit;
  564. } else {
  565. const tempForm = {};
  566. tempForm["id"] = 0;
  567. tempForm["drug_id"] = val.selectedGoodInfo[i].id;
  568. tempForm["number"] = "";
  569. tempForm["product_date"] = "";
  570. tempForm["expiry_date"] = "";
  571. tempForm["warehousing_count"] = "";
  572. tempForm["retail_price"] =
  573. val.selectedGoodInfo[i].retail_price.toString();
  574. tempForm["price"] = val.selectedGoodInfo[i].last_price.toString();
  575. tempForm["remark"] = "";
  576. tempForm["dealer"] = "";
  577. tempForm["manufacturer"] = "";
  578. tempForm["min_unit"] = val.selectedGoodInfo[i].min_unit;
  579. this.recordInfo.recordData.splice(
  580. this.currentIndex + 1,
  581. 0,
  582. tempForm
  583. );
  584. }
  585. }
  586. }
  587. this.currentIndex = -1;
  588. },
  589. cancle: function () {
  590. this.$refs.dialog.hide();
  591. },
  592. GetConfigInfo: function () {
  593. const loading = this.$loading({
  594. lock: true,
  595. text: "Loading",
  596. spinner: "el-icon-loading",
  597. background: "rgba(0, 0, 0, 0.7)",
  598. });
  599. GetAllConfig().then((response) => {
  600. if (response.data.state == 0) {
  601. this.$message.error(response.data.msg);
  602. return false;
  603. } else {
  604. this.manufacturer = response.data.data.manufacturer;
  605. this.dealer = response.data.data.dealer;
  606. for (let i = 0; i < response.data.data.drugs.length; i++) {
  607. this.goodType.push(response.data.data.drugs[i]);
  608. if (response.data.data.drugs[i].drug_specs != null) {
  609. for (
  610. let b = 0;
  611. b < response.data.data.drugs[i].drug_specs.length;
  612. b++
  613. ) {
  614. this.goodInfo.push(response.data.data.drugs[i].drug_specs[b]);
  615. }
  616. }
  617. }
  618. this.manufacturer.splice(0, 0, { id: 0, manufacturer_name: "全部" });
  619. this.dealer.splice(0, 0, { id: 0, dealer_name: "全部" });
  620. this.form.manufacturer = 0;
  621. this.form.dealer = 0;
  622. this.list = response.data.data.list;
  623. this.storehouse_id =response.data.data.configlist.drug_storehouse_info;
  624. }
  625. loading.close();
  626. });
  627. },
  628. typeName: function (drug_id) {
  629. let name = "";
  630. for (let i = 0; i < this.goodInfo.length; i++) {
  631. if (this.goodInfo[i].id == drug_id) {
  632. name = this.goodInfo[i].drug_name;
  633. }
  634. }
  635. return name;
  636. },
  637. specificationName: function (drug_id) {
  638. let name = "";
  639. for (let i = 0; i < this.goodInfo.length; i++) {
  640. if (this.goodInfo[i].id == drug_id) {
  641. name = this.goodInfo[i].drug_spec;
  642. }
  643. }
  644. return name;
  645. },
  646. getDrugName: function (drug_id) {
  647. let name = "";
  648. for (let i = 0; i < this.recordInfo.recordData.length; i++) {
  649. if (drug_id == this.recordInfo.recordData[i].id) {
  650. name =
  651. this.recordInfo.recordData[i].dose +
  652. this.recordInfo.recordData[i].dose_unit +
  653. "*" +
  654. this.recordInfo.recordData[i].min_number +
  655. this.recordInfo.recordData[i].min_unit +
  656. "/" +
  657. this.recordInfo.recordData[i].max_unit;
  658. }
  659. }
  660. return name;
  661. },
  662. handleEdit: function (index, row) {
  663. const tempObj = {};
  664. tempObj["id"] = 0;
  665. tempObj["drug_name"] = "";
  666. tempObj["drug_id"] = 0;
  667. tempObj["number"] = "";
  668. tempObj["product_date"] = "";
  669. tempObj["expiry_date"] = "";
  670. tempObj["warehousing_count"] = "";
  671. tempObj["retail_price"] = "";
  672. tempObj["price"] = "";
  673. tempObj["remark"] = "";
  674. tempObj["dealer"] = "";
  675. tempObj["manufacturer"] = "";
  676. tempObj["min_unit"] = "";
  677. tempObj["max_unit"] = "";
  678. tempObj["drug_type"] = "";
  679. tempObj["batch_number"] = "";
  680. tempObj["dose"] = "";
  681. tempObj["dose_unit"] = "";
  682. tempObj["dealer"] = "";
  683. tempObj["last_price"] = "";
  684. tempObj["count_unit"] = "";
  685. tempObj["min_number"] = "";
  686. tempObj["drug_code"] = ""
  687. this.recordInfo.recordData.push(tempObj);
  688. },
  689. handleDelete: function (index, row) {
  690. if (this.recordInfo.recordData.length <= 1) {
  691. this.$message.error("只有一条记录的时候无法删除");
  692. return;
  693. } else {
  694. this.recordInfo.recordData.splice(index, 1);
  695. }
  696. },
  697. calculate: function (val) {
  698. if (val == 0) {
  699. return "";
  700. }
  701. return Math.round(parseFloat(val) * 100) / 100;
  702. },
  703. getTime(val, temp) {
  704. if (val != 0) {
  705. return uParseTime(val, temp);
  706. } else {
  707. return "";
  708. }
  709. },
  710. getTimeOne(val) {
  711. if(val < 0){
  712. return ""
  713. }
  714. if(val == ""){
  715. return ""
  716. }else {
  717. return uParseTime(val, '{y}-{m}-{d}')
  718. }
  719. },
  720. showDialog(index, row) {
  721. const loading = this.$loading({
  722. lock: true,
  723. text: "Loading",
  724. spinner: "el-icon-loading",
  725. background: "rgba(0, 0, 0, 0.7)",
  726. });
  727. this.currentIndex = index;
  728. this.isVisibility = true;
  729. const params = {
  730. manufacturer_id: this.form.manufacturer,
  731. dealer_id: this.form.dealer,
  732. };
  733. GetAllDrugInfoByID(params).then((response) => {
  734. if (response.data.state == 0) {
  735. this.$message.error(response.data.msg);
  736. return false;
  737. loading.close();
  738. } else {
  739. loading.close();
  740. if (response.data.data.drugs.length <= 0) {
  741. this.$message.error("该厂商或经销商没有药品信息");
  742. return;
  743. }
  744. for (let i = 0; i < response.data.data.drugs.length; i++) {
  745. this.propForm.goods.push(response.data.data.drugs[i]);
  746. }
  747. this.$refs.dialog.show();
  748. const obj = {};
  749. this.propForm.goods = this.propForm.goods.reduce((cur, next) => {
  750. obj[next.id] ? "" : (obj[next.id] = true && cur.push(next));
  751. return cur;
  752. }, []); // 设置cur默认类型为数组,并且初始值为空的数组
  753. }
  754. for (let i = 0; i < this.propForm.goods.length; i++) {
  755. for (let a = 0; a < this.propForm.goods[i].drug_specs.length; a++) {
  756. var respObj = this.propForm.goods[i].drug_specs[a];
  757. respObj["isSelected"] = false;
  758. }
  759. }
  760. });
  761. },
  762. getSummaries(param) {
  763. const { columns, data } = param;
  764. const sums = [];
  765. columns.forEach((column, index) => {
  766. if (index === 0) {
  767. sums[index] = "总价";
  768. return;
  769. }
  770. const values = data.map((item) => Number(item[column.property]));
  771. if (!values.every((value) => isNaN(value))) {
  772. sums[index] = values.reduce((prev, curr) => {
  773. const value = Number(curr);
  774. if (!isNaN(value)) {
  775. return prev + curr;
  776. } else {
  777. return prev;
  778. }
  779. }, 0);
  780. sums[index] += " 元";
  781. } else {
  782. sums[index] = "N/A";
  783. }
  784. });
  785. return sums;
  786. },
  787. back() {
  788. this.$router.go(-1);
  789. },
  790. submit() {
  791. this.$refs["tableForm"].validate((valid) => {
  792. if (valid) {
  793. this.loading = true;
  794. const array = this.recordInfo.recordData;
  795. if (this.storehouse_id == 0) {
  796. this.$message.error("仓库不能为空!");
  797. this.loading = false;
  798. return false;
  799. }
  800. for (let i = 0; i < array.length; i++) {
  801. if (array[i].drug_id == 0) {
  802. this.$message.error("药品名称或者药品规格名称不能为空");
  803. this.loading = false;
  804. return;
  805. }
  806. }
  807. if (this.recordInfo.recordData.length <= 0) {
  808. this.$message.success("请添加入库商品");
  809. this.loading = false;
  810. return;
  811. }
  812. for (let i = 0; i < this.recordInfo.recordData.length; i++) {
  813. if (this.recordInfo.recordData[i].dealer == "") {
  814. this.recordInfo.recordData[i].dealer = 0;
  815. }
  816. this.recordInfo.recordData[i].last_price =
  817. this.recordInfo.recordData[i].last_price.toString();
  818. this.recordInfo.recordData[i].retail_price =
  819. this.recordInfo.recordData[i].retail_price.toString();
  820. if (this.recordInfo.recordData[i].dealer == "") {
  821. this.recordInfo.recordData[i].dealer = 0;
  822. }
  823. for (let j = 0; j < this.manufacturerList.length; j++) {
  824. if (
  825. this.recordInfo.recordData[i].manufacturer ==
  826. this.manufacturerList[j].manufacturer_name
  827. ) {
  828. this.recordInfo.recordData[i].manufacturer =
  829. this.manufacturerList[j].id;
  830. }
  831. }
  832. for (let z = 0; z < this.dealerList.length; z++) {
  833. if (
  834. this.recordInfo.recordData[i].dealer ==
  835. this.dealerList[z].dealer_name
  836. ) {
  837. this.recordInfo.recordData[i].dealer = this.dealerList[z].id;
  838. }
  839. }
  840. }
  841. const params = {
  842. stockIn: this.recordInfo.recordData,
  843. };
  844. postDrugWarehouse(
  845. params,
  846. this.warehousing_time,
  847. this.form.manufacturer,
  848. this.form.dealer,
  849. this.type,
  850. this.storehouse_id,
  851. this.warehousing_id,
  852. ).then((response) => {
  853. if (response.data.state == 0) {
  854. this.loading = false;
  855. this.$message.error(response.data.msg);
  856. return false;
  857. } else {
  858. this.loading = false;
  859. this.$message.success("保存成功");
  860. this.listLoading = false;
  861. var info = response.data.data.info
  862. this.warehousing_id = info.id
  863. var list = response.data.data.list
  864. var manufacturerList = response.data.data.manufacturerList
  865. var dealerList = response.data.data.dealerList
  866. var drugTypeList = response.data.data.drugTypeList
  867. for(let i=0;i<list.length;i++){
  868. for(let j=0;j<manufacturerList.length;j++){
  869. if(list[i].manufacturer_id == manufacturerList[j].id){
  870. list[i].manufacturer_id = manufacturerList[j].manufacturer_name
  871. }
  872. }
  873. for(let s=0;s<dealerList.length;s++){
  874. if(list[i].dealer_id == dealerList[s].id){
  875. list[i].dealer_id = dealerList[s].manufacturer_name
  876. }
  877. }
  878. list[i].expiry_date = this.getTimeOne(list[i].expiry_date)
  879. list[i].product_date = this.getTimeOne(list[i].product_date)
  880. list[i].drug_name = list[i].drug.drug_name
  881. list[i].name = list[i].drug.dose + list[i].drug.dose_unit +"*"+list[i].drug.min_number +list[i].drug.min_unit+"/"+list[i].drug.max_unit
  882. for(let z=0;z<drugTypeList.length;z++){
  883. if(list[i].drug.drug_type == drugTypeList[z].value){
  884. list[i].drug_type = drugTypeList[z].name
  885. }
  886. }
  887. list[i].last_price = list[i].price
  888. list[i].warehousing_count = list[i].warehousing_count.toString()
  889. list[i].unitList = []
  890. list[i].drug_code = list[i].drug_code
  891. var obj = {id:1,name:""}
  892. obj.name = list[i].drug.max_unit
  893. var objOne = {id:2,name:""}
  894. objOne.name = list[i].drug.min_unit
  895. list[i].unitList.push(obj)
  896. list[i].unitList.push(objOne)
  897. }
  898. this.recordInfo.recordData = []
  899. this.recordInfo.recordData = list
  900. this.showCheck = true
  901. this.showReturnCheck = false
  902. // this.$router.back(-1);
  903. }
  904. });
  905. } else {
  906. return false;
  907. }
  908. });
  909. },
  910. changeManufacturer(val) {},
  911. changeDealer(val) {
  912. this.form.dealer = val;
  913. this.propForm.goods = [];
  914. },
  915. getDataConfig(module, filed_name) {
  916. return getDataConfig(module, filed_name);
  917. },
  918. getDictionaryDataConfig(module, filed_name) {
  919. return getDictionaryDataConfig(module, filed_name);
  920. },
  921. // 改版后的JS
  922. getlist() {
  923. getAllDrugList().then((response) => {
  924. if (response.data.state == 1) {
  925. var list = response.data.data.list;
  926. this.drugList = list;
  927. var manufacturerList = response.data.data.manufacturerList;
  928. this.manufacturerList = manufacturerList;
  929. for (let i = 0; i < this.drugList.length; i++) {
  930. for (let j = 0; j < this.manufacturerList.length; j++) {
  931. if (
  932. this.drugList[i].manufacturer == this.manufacturerList[j].id
  933. ) {
  934. this.drugList[i].manufacturer =
  935. this.manufacturerList[j].manufacturer_name;
  936. }
  937. }
  938. }
  939. }
  940. });
  941. },
  942. changeDrugName(val) {
  943. this.showOne = false;
  944. this.showTwo = true;
  945. },
  946. querySearchAsync(keyword, cb) {
  947. let key = "";
  948. if (keyword != undefined) {
  949. key = keyword;
  950. }
  951. let searchArray = [];
  952. postSearchDrugList(key, this.storehouse_id).then((response) => {
  953. if (response.data.state == 1) {
  954. searchArray = response.data.data.list;
  955. var list = response.data.data.list;
  956. this.drugList = list;
  957. var manufacturerList = response.data.data.manufacturerList;
  958. this.manufacturerList = manufacturerList;
  959. var dealerList = response.data.data.dealerList;
  960. this.dealerList = dealerList;
  961. for (let i = 0; i < this.drugList.length; i++) {
  962. for (let j = 0; j < this.manufacturerList.length; j++) {
  963. if (
  964. this.drugList[i].manufacturer == this.manufacturerList[j].id
  965. ) {
  966. this.drugList[i].manufacturer =
  967. this.manufacturerList[j].manufacturer_name;
  968. }
  969. }
  970. for (let z = 0; z < dealerList.length; z++) {
  971. if (this.drugList[i].dealer == this.dealerList[z].id) {
  972. this.drugList[i].dealer = this.dealerList[z].dealer_name;
  973. }
  974. }
  975. }
  976. cb(this.drugList);
  977. } else {
  978. cb([]);
  979. }
  980. });
  981. },
  982. changeDrugName(val) {
  983. this.currentIndex = val;
  984. },
  985. handleSelect(val) {
  986. for (let i = 0; i < this.recordInfo.recordData.length; i++) {
  987. if (i == this.currentIndex) {
  988. this.recordInfo.recordData[i].drug_id = val.id;
  989. this.recordInfo.recordData[i].drug_name = val.drug_name;
  990. this.recordInfo.recordData[i].drug_type = val.drug_type;
  991. this.recordInfo.recordData[i].name =
  992. val.dose +
  993. val.dose_unit +
  994. "*" +
  995. val.min_number +
  996. val.min_unit +
  997. "/" +
  998. val.max_unit;
  999. this.recordInfo.recordData[i].last_price = val.last_price;
  1000. this.recordInfo.recordData[i].retail_price = val.min_price;
  1001. this.recordInfo.recordData[i].manufacturer = val.manufacturer;
  1002. this.recordInfo.recordData[i].number = val.number;
  1003. this.recordInfo.recordData[i].max_unit = val.max_unit;
  1004. this.recordInfo.recordData[i].min_unit = val.min_unit;
  1005. this.recordInfo.recordData[i].count_unit = val.max_unit;
  1006. this.recordInfo.recordData[i].min_number = val.min_number
  1007. if (val.dealer == 0) {
  1008. this.recordInfo.recordData[i].dealer = "";
  1009. } else {
  1010. this.recordInfo.recordData[i].dealer = val.dealer;
  1011. }
  1012. this.recordInfo.recordData[i].unitList = []
  1013. var obj = {id:1,name:""}
  1014. var objOne= {id:2,name:""}
  1015. obj.name = val.max_unit
  1016. objOne.name = val.min_unit
  1017. this.recordInfo.recordData[i].unitList.push(obj)
  1018. this.recordInfo.recordData[i].unitList.push(objOne)
  1019. }
  1020. }
  1021. },
  1022. toCheck(){
  1023. const loading = this.$loading({
  1024. lock: true,
  1025. text: "Loading",
  1026. spinner: "el-icon-loading",
  1027. background: "rgba(0, 0, 0, 0.7)",
  1028. });
  1029. var params = {
  1030. warehousing_id:this.warehousing_id,
  1031. }
  1032. toCheckWarehousingInfo(params).then(response=>{
  1033. if(response.data.state == 1){
  1034. var list = response.data.data.list
  1035. this.$message.success("审核成功!")
  1036. this.$router.back(-1);
  1037. this.showCheck = false
  1038. this.showReturnCheck = true
  1039. loading.close()
  1040. }else{
  1041. this.$message.error("审核失败!")
  1042. loading.close()
  1043. }
  1044. })
  1045. },
  1046. toReturnCheck(){
  1047. const loading = this.$loading({
  1048. lock: true,
  1049. text: "Loading",
  1050. spinner: "el-icon-loading",
  1051. background: "rgba(0, 0, 0, 0.7)",
  1052. });
  1053. var params = {
  1054. warehousing_id:this.warehousing_id,
  1055. }
  1056. toReturnCheckWarehousing(params).then(response=>{
  1057. if(response.data.state == 1){
  1058. var list = response.data.data.list
  1059. this.$message.success("反审核成功!")
  1060. this.showCheck = true
  1061. this.showReturnCheck = false
  1062. loading.close()
  1063. }else{
  1064. this.$message.error("反审核失败!")
  1065. loading.close()
  1066. }
  1067. })
  1068. },
  1069. changeUnit(val,index){
  1070. // console.log("val3232323232",val)
  1071. // for(let i=0;i<this.recordInfo.recordData.length;i++){
  1072. // if(i == index){
  1073. // if(this.recordInfo.recordData[i].max_unit == this.recordInfo.recordData[i].count_unit){
  1074. // }
  1075. // if(this.recordInfo.recordData[i].min_unit == this.recordInfo.recordData[i].count_unit){
  1076. // }
  1077. // }
  1078. // }
  1079. },
  1080. getTotalPirce(){
  1081. var total_price = 0
  1082. if(this.recordInfo.recordData!=null && this.recordInfo.recordData.length>0){
  1083. for(let i=0;i<this.recordInfo.recordData.length;i++){
  1084. total_price += this.recordInfo.recordData[i].last_price * parseInt(this.recordInfo.recordData[i].warehousing_count)
  1085. }
  1086. if(total_price>0){
  1087. return total_price.toFixed(4)
  1088. }else{
  1089. return ""
  1090. }
  1091. }
  1092. }
  1093. },
  1094. created() {
  1095. if (this.$route.path == "/Pharmacy/in/add") {
  1096. this.crumbs = [
  1097. { path: false, name: "药品管理" },
  1098. { path: false, name: "药品入库单" },
  1099. { path: false, name: "新增入库单" },
  1100. ];
  1101. }
  1102. this.drugTypeList = getDictionaryDataConfig("system", "drug_type");
  1103. var nowDate = new Date();
  1104. var nowYear = nowDate.getFullYear();
  1105. var nowMonth = nowDate.getMonth() + 1;
  1106. var nowDay = nowDate.getDate();
  1107. this.warehousing_time =
  1108. nowYear +
  1109. "-" +
  1110. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  1111. "-" +
  1112. (nowDay < 10 ? "0" + nowDay : nowDay);
  1113. const tempObj = {};
  1114. tempObj["id"] = 0;
  1115. tempObj["drug_id"] = 0;
  1116. tempObj["drug_name"] = "";
  1117. tempObj["dosage"] = "";
  1118. tempObj["max_unit"] = "";
  1119. tempObj["min_unit"] = "",
  1120. tempObj["lot_number"] = "";
  1121. tempObj["product_date"] = "";
  1122. tempObj["expiry_date"] = "";
  1123. tempObj["warehousing_count"] = "";
  1124. tempObj["retail_price"] = "";
  1125. tempObj["last_price"] = "";
  1126. tempObj["remark"] = "";
  1127. tempObj["dealer"] = "";
  1128. tempObj["manufacturer"] = "";
  1129. tempObj["batch_number"] = "";
  1130. tempObj["drug_type"] = "";
  1131. tempObj["dealer"] = "";
  1132. tempObj["number"] = "";
  1133. tempObj["count_unit"] = "";
  1134. tempObj["min_number"] = "";
  1135. tempObj["drug_code"] = ""
  1136. this.recordInfo.recordData.push(tempObj);
  1137. this.GetConfigInfo();
  1138. this.propForm.goodUnit = this.$store.getters.good_unit;
  1139. // this.unitList = getDataConfig("hemodialysis", "units");
  1140. // console.log("hhahdhhafd",this.unitList)
  1141. },
  1142. };
  1143. </script>
  1144. <style>
  1145. #oictable ::-webkit-scrollbar {
  1146. height: 15px;
  1147. }
  1148. </style>
  1149. <style rel="stylesheet/css" lang="scss" scoped>
  1150. .information {
  1151. border: 1px #dcdfe6 solid;
  1152. padding: 30px 20px 30px 20px;
  1153. .border {
  1154. border-bottom: 1px #dcdfe6 solid;
  1155. margin: 0px 0 20px 0;
  1156. }
  1157. }
  1158. .edit_separater {
  1159. border-top: 1px solid rgb(233, 233, 233);
  1160. margin-top: 15px;
  1161. margin-bottom: 15px;
  1162. }
  1163. .titleOne {
  1164. width: 120px;
  1165. display: inline-block;
  1166. font-weight: normal;
  1167. color: #909399;
  1168. padding: 6px 0;
  1169. margin-left: 20px;
  1170. }
  1171. </style>
  1172. <style>
  1173. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  1174. font-size: 12px;
  1175. }
  1176. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  1177. background: #6fb5fa;
  1178. }
  1179. .el-autocomplete-suggestion {
  1180. width: 400px !important;
  1181. }
  1182. </style>