index.vue 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <div class="query-box">
  5. <div class="query-box__left">
  6. <el-form-item label="" prop="code">
  7. <el-input v-model="queryParams.code" placeholder="请输入单据号" clearable size="small" style="width:160px" @keyup.enter.native="handleQuery"></el-input>
  8. </el-form-item>
  9. <el-form-item label="" prop="keepingTime">
  10. <el-date-picker clearable size="small" style="width:260px" v-model="queryParams.keepingTime" type="daterange" value-format="yyyy-MM-dd" start-placeholder="入库开始时间" end-placeholder="入库结束时间"></el-date-picker>
  11. </el-form-item>
  12. <el-form-item label="" prop="warehousingType">
  13. <el-select style="width:160px" v-model="queryParams.warehousingType" placeholder="请选择入库方式" clearable size="small">
  14. <el-option v-for="item in storageArr" :key="item.id" :value="item.id" :label="item.name"></el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="" prop="state">
  18. <el-select style="width:160px" v-model="queryParams.state" placeholder="请选择单据状态" clearable size="small">
  19. <el-option v-for="item in billOptions" :key="item.dictValue" :value="item.dictValue" :label="item.dictLabel"></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" >搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. <el-button
  26. type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['inventory:warehouse:add']" >新增</el-button>
  27. </el-form-item>
  28. </div>
  29. </div>
  30. </el-form>
  31. <el-table v-loading="loading" :data="warehouseList" size="mini" border>
  32. <el-table-column type="index" width="55" align="center" label="序号" />
  33. <el-table-column label="入库单号" align="center" prop="code" />
  34. <el-table-column label="入库方式" align="center" prop="typeName">
  35. <!-- <template slot-scope="scope">
  36. <dict-tag :options="storageArr" :value="scope.row.warehousingType" />
  37. </template> -->
  38. </el-table-column>
  39. <el-table-column label="单位部门" align="center" prop="supplierName"/>
  40. <el-table-column label="制单人" align="center" prop="createBy" />
  41. <el-table-column label="制单时间" align="center" prop="createTime" />
  42. <el-table-column label="记账人" align="center" prop="keepingBy" />
  43. <el-table-column label="记账时间" align="center" prop="keepingTime"/>
  44. <el-table-column label="单据状态" align="center" prop="state">
  45. <template slot-scope="scope">
  46. <dict-tag :options="billOptions" :value="scope.row.state" />
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="备注" align="center" prop="remarks" />
  50. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220" fixed="right">
  51. <template slot-scope="scope">
  52. <el-button
  53. size="mini"
  54. type="primary"
  55. style="width: 40px"
  56. @click="handleUpdate(1, scope.row)"
  57. v-hasPermi="['inventory:warehouse:edit']"
  58. v-if="scope.row.state === '1'"
  59. >修改</el-button
  60. >
  61. <el-button
  62. size="mini"
  63. type="primary"
  64. style="width: 40px"
  65. v-hasPermi="['inventory:warehouse:remove']"
  66. @click="handleUpdate(2, scope.row)"
  67. v-if="scope.row.state === '1'"
  68. >记账</el-button
  69. >
  70. <el-button
  71. size="mini"
  72. type="primary"
  73. style="width: 40px"
  74. @click="handleDelete(scope.row)"
  75. v-hasPermi="['inventory:warehouse:remove']"
  76. v-if="scope.row.state !== '2'"
  77. >删除</el-button
  78. >
  79. <el-button
  80. size="mini"
  81. type="primary"
  82. style="width: 40px"
  83. v-hasPermi="['inventory:warehouse:remove']"
  84. @click="handleUpdate(3, scope.row)"
  85. >详情</el-button
  86. >
  87. <el-button
  88. size="mini"
  89. type="primary"
  90. style="width: 40px"
  91. v-hasPermi="['inventory:warehouse:remove']"
  92. @click="handleUpdate(4, scope.row)"
  93. v-if="scope.row.state === '2'"
  94. >冲销</el-button
  95. >
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <pagination
  100. v-show="total > 0"
  101. :total="total"
  102. :page.sync="queryParams.pageNum"
  103. :limit.sync="queryParams.pageSize"
  104. @pagination="getList"
  105. />
  106. <!-- 添加或修改入库单对话框 -->
  107. <el-dialog
  108. :fullscreen="true"
  109. :title="title"
  110. :visible.sync="open"
  111. width="1180px"
  112. append-to-body
  113. size="mini"
  114. >
  115. <el-form
  116. ref="form"
  117. :model="form"
  118. :rules="rules"
  119. label-width="80px"
  120. label-position="top"
  121. >
  122. <el-row :gutter="20">
  123. <el-col :span="6">
  124. <el-form-item label="入库单号" prop="code">
  125. <el-input
  126. v-model="form.code"
  127. placeholder="请输入单号"
  128. disabled
  129. style="width: 100%"
  130. />
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="6">
  134. <el-form-item
  135. label="入库方式"
  136. prop="warehousingType"
  137. :rules="[{ required: true, message: '请选择入库方式' }]"
  138. >
  139. <el-select
  140. v-model="form.warehousingType"
  141. placeholder="请选择入库方式"
  142. :disabled="disableDetails"
  143. style="width: 100%"
  144. >
  145. <el-option
  146. v-for="item in storageArr"
  147. :key="item.id"
  148. :value="item.id"
  149. :label="item.name"
  150. ></el-option>
  151. </el-select>
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="6">
  155. <el-form-item
  156. label="单位部门"
  157. prop="supplierId"
  158. :rules="[{ required: true, message: '请选择单位部门' }]"
  159. >
  160. <el-select
  161. v-if="editable||disableDetails"
  162. v-model="form.supplierName"
  163. placeholder="请选择单位部门"
  164. :disabled="!editable||disableDetails"
  165. style="width: 100%"
  166. >
  167. <el-option
  168. v-for="item in supplierArr"
  169. :key="item.id"
  170. :value="item.id+''"
  171. :label="item.name"
  172. />
  173. </el-select>
  174. <el-select
  175. v-else
  176. v-model="form.supplierId"
  177. placeholder="请选择单位部门"
  178. style="width: 100%"
  179. value-key="id"
  180. >
  181. <el-option
  182. v-for="item in supplierArr"
  183. :key="item.id"
  184. :value="item"
  185. :label="item.name"
  186. />
  187. </el-select>
  188. </el-form-item>
  189. </el-col>
  190. <el-col :span="6">
  191. <el-form-item label="备注" prop="remarks">
  192. <el-input
  193. v-model="form.remarks"
  194. placeholder="请输入备注"
  195. :disabled="disableDetails"
  196. style="width: 100%"
  197. />
  198. </el-form-item>
  199. </el-col>
  200. </el-row>
  201. <el-row :gutter="20">
  202. <el-col :span="6">
  203. <el-form-item label="制单人" prop="createBy">
  204. <el-input v-if="form.createBy" v-model="form.createBy" disabled style="width: 100%"></el-input>
  205. <el-input v-else :value="createBy" disabled style="width: 100%"></el-input>
  206. </el-form-item>
  207. </el-col>
  208. <el-col :span="6">
  209. <el-form-item label="制单时间" prop="createTime">
  210. <el-input v-if="form.createTime" v-model="form.createTime" disabled style="width: 100%"></el-input>
  211. <el-input v-else v-model="createTime" disabled style="width: 100%"></el-input>
  212. </el-form-item>
  213. </el-col>
  214. <el-col :span="6">
  215. <el-form-item label="记账人" prop="keepingBy">
  216. <el-input v-if="form.keepingBy" v-model="form.keepingBy" disabled style="width: 100%"></el-input>
  217. <template v-else>
  218. <el-input v-if="BtnState==2" :value="createBy" disabled style="width: 100%"></el-input>
  219. <el-input v-else value="" disabled style="width: 100%"></el-input>
  220. </template>
  221. </el-form-item>
  222. </el-col>
  223. <el-col :span="6">
  224. <el-form-item label="记账时间" prop="keepingTime">
  225. <el-input v-if="form.keepingTime" v-model="form.keepingTime" disabled style="width: 100%"></el-input>
  226. <template v-else>
  227. <el-input v-if="BtnState==2" :value="createTime" disabled style="width: 100%"></el-input>
  228. <el-input v-else value="" disabled style="width: 100%"></el-input>
  229. </template>
  230. </el-form-item>
  231. </el-col>
  232. </el-row>
  233. <el-divider content-position="center">入库单详情信息</el-divider>
  234. <el-row :gutter="10" class="mb8">
  235. <el-col :span="1.5">
  236. <el-button
  237. type="primary"
  238. icon="el-icon-plus"
  239. size="mini"
  240. @click="handleAddWarehouseDetail"
  241. v-if="!disableDetails"
  242. >添加</el-button
  243. >
  244. </el-col>
  245. <el-col :span="1.5">
  246. <el-button
  247. type="danger"
  248. icon="el-icon-delete"
  249. size="mini"
  250. @click="handleDeleteWarehouseDetail"
  251. v-if="!disableDetails"
  252. >删除</el-button
  253. >
  254. </el-col>
  255. </el-row>
  256. <el-table
  257. :data="warehousingDetails"
  258. :row-class-name="rowWarehouseDetailIndex"
  259. @selection-change="handleWarehouseDetailSelectionChange"
  260. ref="warehouseDetail"
  261. border
  262. :summary-method="getSummaries"
  263. show-summary
  264. >
  265. <el-table-column type="selection" width="80" align="center" />
  266. <el-table-column
  267. label="序号"
  268. align="center"
  269. prop="index"
  270. width="65"
  271. />
  272. <el-table-column
  273. label="药品名称"
  274. prop="drugsName"
  275. width="110"
  276. align="center"
  277. >
  278. <template slot-scope="scope">
  279. <!-- <el-input
  280. v-model="scope.row.drugsId"
  281. placeholder="请输入药品名称"
  282. /> -->
  283. <selectTable v-if="open" :info="scope.row" :index="scope.$index" :disableDetails="disableDetails" @selectChange="selectChange" :disabled="num==4||num==2"></selectTable>
  284. </template>
  285. </el-table-column>
  286. <el-table-column
  287. label="药品类型"
  288. prop="drugsType"
  289. width="110"
  290. align="center"
  291. >
  292. <template slot-scope="scope">
  293. <span v-if="scope.row.drugsType">{{drugsTypeOptions.find(v=>v.dictValue==scope.row.drugsType).dictLabel}}</span>
  294. <!-- <el-input
  295. disabled
  296. v-model="scope.row.drugsType"
  297. placeholder="药品类型"
  298. /> -->
  299. <!-- <el-select
  300. v-model="scope.row.drugsType"
  301. placeholder="药品类型"
  302. disabled
  303. >
  304. <el-option
  305. v-for="item in drugsTypeOptions"
  306. :key="item.dictValue"
  307. :value="item.dictValue"
  308. :label="item.dictLabel"
  309. ></el-option>
  310. </el-select> -->
  311. </template>
  312. </el-table-column>
  313. <el-table-column
  314. label="药品规格"
  315. prop="specsName"
  316. width="110"
  317. align="center"
  318. ></el-table-column>
  319. <el-table-column
  320. label="药品产地"
  321. prop="priceName"
  322. width="110"
  323. align="center"
  324. >
  325. <template slot-scope="scope">
  326. <span>{{scope.row.placeName}}</span>
  327. <!-- <el-input
  328. v-model="scope.row.priceId"
  329. placeholder="请输入药品产地"
  330. /> -->
  331. <!-- <el-select
  332. v-model="scope.row.priceId"
  333. placeholder="药品产地"
  334. @change="handlePriceId($event, scope)"
  335. :disabled="disableDetails"
  336. >
  337. <el-option
  338. v-for="item in scope.row.priceArr"
  339. :key="item.id"
  340. :value="item.id"
  341. :label="item.placeName"
  342. :disabled="item.state == 1 || item.del == 0 ? false : true"
  343. />
  344. </el-select> -->
  345. </template>
  346. </el-table-column>
  347. <el-table-column
  348. label="药品单位"
  349. prop="dosageSizeUnit"
  350. width="110"
  351. align="center"
  352. >
  353. <template slot-scope="scope">
  354. <dict-tag v-if="scope.row.dosageSizeUnit" :options="unitArr" :value="scope.row.dosageSizeUnit" />
  355. </template>
  356. </el-table-column>
  357. <el-table-column
  358. label="库存数量"
  359. prop="inventory"
  360. align="center"
  361. width="110"
  362. >
  363. <!-- <template slot-scope="scope">
  364. <el-input
  365. v-model="scope.row.inventory"
  366. placeholder="库存"
  367. disabled
  368. />
  369. </template> -->
  370. </el-table-column>
  371. <el-table-column
  372. label="入库数量"
  373. prop="stock"
  374. align="cneter"
  375. width="110"
  376. >
  377. <template slot-scope="scope">
  378. <el-input
  379. v-model="scope.row.stock"
  380. placeholder="入库数量"
  381. :disabled="disableDetails"
  382. type="number"
  383. :min="1"
  384. onkeypress="return (/^[-]?[0-9]*\.?[0-9]+(eE?[0-9]+)?$/.test(String.fromCharCode(event.keyCode)))"
  385. />
  386. </template>
  387. </el-table-column>
  388. <el-table-column
  389. label="进货单价"
  390. prop="purchasePrice"
  391. align="center"
  392. width="110"
  393. >
  394. <template slot-scope="scope">
  395. <el-input
  396. v-model="scope.row.purchasePrice"
  397. placeholder="进货单价"
  398. :disabled="num==4||num==2"
  399. />
  400. </template>
  401. </el-table-column>
  402. <el-table-column
  403. label="进货总价"
  404. prop="purchasePriceAll"
  405. align="center"
  406. width="110"
  407. >
  408. <template slot-scope="scope">
  409. <!-- <el-input
  410. :v-model="scope.row.purchasePrice*scope.row.inventory"
  411. placeholder="请输入进货总价"
  412. /> -->
  413. <div>{{ (scope.row.purchasePrice * scope.row.stock).toFixed(4) }}</div>
  414. </template>
  415. </el-table-column>
  416. <el-table-column
  417. label="零售单价"
  418. prop="retailPrice"
  419. width="110"
  420. align="center"
  421. >
  422. <template slot-scope="scope">
  423. <el-input
  424. v-model="scope.row.retailPrice"
  425. placeholder="零售单价"
  426. disabled
  427. />
  428. </template>
  429. </el-table-column>
  430. <el-table-column
  431. label="零售总价"
  432. prop="retailPrice"
  433. width="110"
  434. align="center"
  435. >
  436. <template slot-scope="scope">
  437. <!-- <el-input
  438. v-model="scope.row.retailPrice"
  439. placeholder="请输入零售总价"
  440. /> -->
  441. <div disabled>
  442. {{ (scope.row.retailPrice * scope.row.stock).toFixed(4) }}
  443. </div>
  444. </template>
  445. </el-table-column>
  446. <el-table-column
  447. label="生产批号"
  448. prop="productionCode"
  449. align="center"
  450. width="110"
  451. >
  452. <template slot-scope="scope">
  453. <span v-if="disableDetails">{{scope.row.productionCode}}</span>
  454. <el-input
  455. v-model="scope.row.productionCode"
  456. placeholder="生产批号"
  457. v-else
  458. />
  459. </template>
  460. </el-table-column>
  461. <el-table-column label="药品效期" prop="validTime" width="155" align="center">
  462. <template slot-scope="scope">
  463. <el-date-picker
  464. :disabled="disableDetails"
  465. clearable
  466. size="small"
  467. v-model="scope.row.validTime"
  468. type="date"
  469. value-format="yyyy-MM-dd"
  470. placeholder="有效时间"
  471. style="width: 130px">
  472. </el-date-picker>
  473. </template>
  474. </el-table-column>
  475. <el-table-column label="批准文号" prop="approvalCode" align="center" width="110">
  476. </el-table-column>
  477. <el-table-column label="摆放位置" prop="site" width="110" align="center"></el-table-column>
  478. </el-table>
  479. </el-form>
  480. <div slot="footer" class="dialog-footer">
  481. <el-button type="primary" @click="submitForm" v-if="BtnState === 1">确 定</el-button>
  482. <el-button @click="cancel" v-if="BtnState === 1">取 消</el-button>
  483. <el-button type="primary" @click="handleUpdataKeeping" v-if="BtnState === 2">记 账</el-button>
  484. <el-button @click="handleOff" v-if="BtnState === 4">冲销</el-button>
  485. </div>
  486. </el-dialog>
  487. </div>
  488. </template>
  489. <script>
  490. import {
  491. listWarehousing,
  492. getWarehousing,
  493. delWarehousing,
  494. addWarehousing,
  495. updateWarehousing,
  496. exportWarehousing,
  497. updataKeeping,
  498. undataWriteOff,
  499. listRk,
  500. getProductionCode
  501. } from "@/api/inventory/warehousing";
  502. import { listSupplier } from "@/api/pharmacy/supplier";
  503. import { listSpecs } from "@/api/drugs/specs";
  504. import { listDrugs } from "@/api/drugs/drugs";
  505. import { listPrice } from "@/api/drugs/price";
  506. import { getSumStock } from "@/api/inventory/inventory";
  507. import { listMedicalPharmacy } from "@/api/pharmacy/MedicalPharmacy";
  508. import selectTable from '@/components/selectTable/selectTable.vue'
  509. export default {
  510. name: "Warehouse",
  511. components: {
  512. selectTable
  513. },
  514. data() {
  515. return {
  516. num: '',
  517. createBy: '',
  518. createTime: '',
  519. storageArr: [],
  520. billOptions: [],
  521. supplierArr: [],
  522. drugsArr: [],
  523. specsArr: [],
  524. priceArr: [],
  525. drugsId: "",
  526. specsId: "",
  527. priceId: "",
  528. productionCode: "",
  529. drugsTypeOptions: [],
  530. unitOptions: [],
  531. disableDetails: false,
  532. tableId: "",
  533. BtnState: "",
  534. // 遮罩层
  535. loading: true,
  536. // 导出遮罩层
  537. exportLoading: false,
  538. editable: false,
  539. // 选中数组
  540. ids: [],
  541. // 子表选中数据
  542. checkedWarehouseDetail: [],
  543. // 非单个禁用
  544. single: true,
  545. // 非多个禁用
  546. multiple: true,
  547. // 显示搜索条件
  548. showSearch: true,
  549. // 总条数
  550. total: 0,
  551. // 入库单表格数据
  552. warehouseList: [],
  553. // 入库单详情表格数据
  554. warehousingDetails: [
  555. {
  556. drugsId: "",
  557. specsId: "",
  558. riceId: "",
  559. stock: "",
  560. inventory: "",
  561. purchasePrice: "",
  562. purchasePriceAll: "",
  563. retailPrice: "",
  564. approvalCode: "",
  565. site: "",
  566. productionCode: "",
  567. validTime: "",
  568. specsArr: [],
  569. priceArr: [],
  570. },
  571. ],
  572. // 弹出层标题
  573. title: "",
  574. // 是否显示弹出层
  575. open: false,
  576. // 查询参数
  577. queryParams: {
  578. pageNum: 1,
  579. pageSize: 10,
  580. code: null,
  581. keepingTime: [],
  582. pharmacyId: window.localStorage.getItem("pharmacyId"),
  583. },
  584. // 表单参数
  585. form: {
  586. keepingBy: null,
  587. createBy: null,
  588. supplierId: '',
  589. pharmacyId: window.localStorage.getItem("pharmacyId"),
  590. },
  591. // 表单校验
  592. rules: {
  593. pharmacyId: [
  594. { required: true, message: "药房id不能为空", trigger: "blur" },
  595. ],
  596. },
  597. supplierArrTab: [],
  598. unitArr: []
  599. };
  600. },
  601. watch: {
  602. 'form.warehousingType' (val) {
  603. if (val != null) {
  604. this.handleRk()
  605. }
  606. }
  607. },
  608. created() {
  609. this.getDicts("unit").then((response) => {
  610. this.unitArr = response.data;
  611. });
  612. this.createBy = localStorage.getItem('userName')
  613. this.createTime = this.dayjs().format("YYYY-MM-DD HH:mm:ss")
  614. this.getDicts("bill_state").then((response) => {
  615. this.billOptions = response.data;
  616. });
  617. this.getDicts("drugs_type").then((response) => {
  618. // response.data.map((item) => {
  619. // this.drugsTypeOptions[item.dictValue] = item.dictLabel;
  620. // });
  621. this.drugsTypeOptions = response.data;
  622. });
  623. this.getDicts("unit").then((response) => {
  624. this.unitOptions = response.data;
  625. });
  626. this.getListSupplierArr();
  627. this.getList();
  628. this.getListStorage();
  629. // this.getListDrugs();
  630. },
  631. methods: {
  632. selectChange (data) {
  633. var index = data.index
  634. var r = data.data
  635. this.warehousingDetails[index].drugsType = String(r.drugsType);
  636. this.warehousingDetails[index].drugsId = r.drugsId;
  637. this.warehousingDetails[index].specsId = r.specsId;
  638. this.warehousingDetails[index].priceId = r.priceId;
  639. this.warehousingDetails[index].placeName = r.placeName;
  640. this.warehousingDetails[index].dosageSizeUnit = r.dosageSizeUnit;
  641. this.warehousingDetails[index].specsName = r.drugsSpecsName;
  642. this.warehousingDetails[index].drugsName = r.drugsName;
  643. this.warehousingDetails[index].priceName = r.placeName;
  644. //this.warehousingDetails[index].purchasePrice = r.purchasePrice||'';
  645. this.warehousingDetails[index].retailPrice = r.retail;
  646. this.warehousingDetails[index].approvalCode = r.approvalCode;
  647. this.warehousingDetails[index].site = r.site;
  648. this.warehousingDetails[index].packingUnit = r.packingUnit;
  649. //this.warehousingDetails[index].drugsType = r.drugsType;
  650. this.warehousingDetails[index].inventory = r.inventory;
  651. this.$set(this.warehousingDetails[index], "specsArr", data.result);
  652. if (this.title == "添加入库单") {
  653. getProductionCode({
  654. drugsId: r.drugsId,
  655. specsId: r.specsId,
  656. priceId: r.priceId,
  657. pharmacyId: localStorage.getItem('pharmacyId')
  658. }).then(res => {
  659. if (res.code == 200) {
  660. this.$set(this.warehousingDetails[index], 'productionCode', res.data || '')
  661. }
  662. })
  663. }
  664. },
  665. /** 表单合计 **/
  666. getSummaries(param) {
  667. const { columns, data } = param;
  668. const sums = [];
  669. columns.forEach((column, index) => {
  670. if (index === 0) {
  671. sums[index] = "总价";
  672. return;
  673. }
  674. const values = data.map((item) => Number(item[column.property]));
  675. if (index === 7 || index === 8 || index === 9 || index === 11) {
  676. sums[index] = values.reduce((prev, curr) => {
  677. const value = Number(curr);
  678. if (!isNaN(value)) {
  679. return prev + curr;
  680. } else {
  681. return prev;
  682. }
  683. }, 0);
  684. sums[index] = sums[index].toFixed(4)
  685. } else {
  686. sums[index] = "/";
  687. }
  688. if (index === 10) {
  689. let num = [];
  690. data.map((item) => {
  691. num.push(item.stock * item.purchasePrice);
  692. });
  693. let sum = num.reduce(function (prev, cur, index, array) {
  694. return prev + cur;
  695. });
  696. sums[10] = (sum-0).toFixed(4);
  697. }
  698. if (index === 12) {
  699. let num = [];
  700. data.map((item) => {
  701. num.push(item.stock * item.retailPrice);
  702. });
  703. let sum = num.reduce(function (prev, cur, index, array) {
  704. return prev + cur;
  705. });
  706. sums[12] = (sum-0).toFixed(4);
  707. }
  708. });
  709. return sums;
  710. },
  711. /** 查询出库单列表 */
  712. getList() {
  713. this.loading = true;
  714. var form = Object.assign({}, this.queryParams)
  715. if (form.keepingTime && form.keepingTime.length) {
  716. form.startTime = form.keepingTime[0]
  717. form.endTime = form.keepingTime[1]
  718. } else {
  719. form.startTime = form.endTime = ''
  720. }
  721. delete form.keepingTime
  722. listWarehousing(form).then((response) => {
  723. this.warehouseList = response.rows;
  724. this.total = response.total;
  725. this.loading = false;
  726. });
  727. },
  728. //获取入库方式
  729. getListStorage() {
  730. listRk({
  731. display: 'Y'
  732. }).then((res) => {
  733. this.storageArr = res.rows;
  734. });
  735. },
  736. //选择入库单位
  737. handleRk(e) {
  738. //console.log(e, "87");
  739. let newArr = this.storageArr.filter((item) => {
  740. return item.id == this.form.warehousingType;
  741. });
  742. if (newArr[0].deptType == "1") {
  743. this.getListMedicalPharmacy();
  744. } else {
  745. this.getListSupplier();
  746. }
  747. },
  748. //供货单位
  749. getListSupplier() {
  750. listSupplier().then((res) => {
  751. //console.log(res, "res1212");
  752. this.supplierArr = res.rows;
  753. });
  754. },
  755. getListSupplierArr() {
  756. listSupplier().then((res) => {
  757. //console.log(res, "res3434");
  758. this.supplierArrTab = res.rows;
  759. });
  760. },
  761. //药房
  762. getListMedicalPharmacy() {
  763. listMedicalPharmacy({
  764. state: 1
  765. }).then((res) => {
  766. this.supplierArr = res.data;
  767. });
  768. },
  769. //获取药品名称
  770. /*getListDrugs() {
  771. listAll().then((res) => {
  772. this.drugsArr = res.data;
  773. });
  774. },*/
  775. //通过药品名称获取药品类型
  776. /*handleDrugsId(e, row) {
  777. //console.log(e);
  778. //console.log(this.drugsArr);
  779. let newArr = this.drugsArr.filter((item) => {
  780. return item.id === e;
  781. });
  782. this.drugsId = e;
  783. this.warehousingDetails[row.$index].drugsType = String(
  784. newArr[0].drugsType
  785. );
  786. this.getListSpecs(e, row.$index);
  787. this.warehousingDetails[row.$index].specsId = "";
  788. this.warehousingDetails[row.$index].priceId = "";
  789. this.warehousingDetails[row.$index].purchasePrice = "";
  790. this.warehousingDetails[row.$index].retailPrice = "";
  791. this.warehousingDetails[row.$index].approvalCode = "";
  792. this.warehousingDetails[row.$index].packingUnit = "";
  793. },*/
  794. //获取药品规格
  795. getListSpecs(drugsId, index) {
  796. listSpecs({ drugsId }).then((res) => {
  797. // this.specsArr = res.rows;
  798. // this.warehousingDetails[row.$index].specsArr = res.rows
  799. this.$set(this.warehousingDetails[index], "specsArr", res.rows);
  800. });
  801. },
  802. //通过药品规格获取
  803. handleSpecsId(e, row) {
  804. let newArr = this.warehousingDetails[row.$index].specsArr.filter(
  805. (item) => {
  806. return item.id === e;
  807. }
  808. );
  809. this.specsId = e;
  810. this.warehousingDetails[row.$index].packingUnit = String(
  811. newArr[0].packingUnit
  812. );
  813. this.getListPrice(e, row.$index);
  814. this.warehousingDetails[row.$index].priceId = "";
  815. this.warehousingDetails[row.$index].purchasePrice = "";
  816. this.warehousingDetails[row.$index].retailPrice = "";
  817. this.warehousingDetails[row.$index].approvalCode = "";
  818. },
  819. //获取产地
  820. getListPrice(specsId, index) {
  821. listPrice({ specsId }).then((res) => {
  822. this.$set(this.warehousingDetails[index], "priceArr", res.rows);
  823. });
  824. },
  825. //通过药品产地获取
  826. handlePriceId(e, row) {
  827. let newArr = this.warehousingDetails[row.$index].priceArr.filter(
  828. (item) => {
  829. return item.id === e;
  830. }
  831. );
  832. this.priceId = e;
  833. this.productionCode = newArr[0].approvalCode;
  834. this.warehousingDetails[row.$index].purchasePrice = newArr[0].wholesale;
  835. this.warehousingDetails[row.$index].retailPrice = newArr[0].retail;
  836. // this.warehousingDetails[row.$index].productionCode =
  837. // newArr[0].approvalCode;
  838. this.warehousingDetails[row.$index].approvalCode = newArr[0].approvalCode;
  839. this.warehousingDetails[row.$index].site = newArr[0].site;
  840. if (
  841. window.localStorage.getItem("pharmacyId") &&
  842. this.drugsId &&
  843. this.specsId &&
  844. this.priceId
  845. ) {
  846. this.getOneList(row.$index);
  847. }
  848. },
  849. //获取库存数量
  850. getOneList(index) {
  851. let params = {
  852. pharmacyId: window.localStorage.getItem("pharmacyId"),
  853. drugsId: this.drugsId,
  854. specsId: this.specsId,
  855. priceId: this.priceId,
  856. };
  857. getSumStock(params).then((res) => {
  858. //console.log(res, 99999999);
  859. !res.data
  860. ? this.$set(this.warehousingDetails[index], "inventory", "0")
  861. : this.$set(
  862. this.warehousingDetails[index],
  863. "inventory",
  864. res.data.stock
  865. );
  866. });
  867. },
  868. // 取消按钮
  869. cancel() {
  870. this.open = false;
  871. this.reset();
  872. },
  873. // 表单重置
  874. reset() {
  875. this.form = {
  876. id: null,
  877. code: null,
  878. pharmacyId: window.localStorage.getItem("pharmacyId"),
  879. warehousingType: null,
  880. remarks: null,
  881. createTime: null,
  882. keepingBy: null,
  883. createBy: null,
  884. keepingTime: null,
  885. state: null,
  886. del: null,
  887. };
  888. this.warehousingDetails = [
  889. {
  890. drugsId: "",
  891. specsId: "",
  892. riceId: "",
  893. stock: "",
  894. inventory: "",
  895. purchasePrice: "",
  896. purchasePriceAll: "",
  897. retailPrice: "",
  898. approvalCode: "",
  899. site: "",
  900. productionCode: "",
  901. validTime: "",
  902. specsArr: [],
  903. priceArr: [],
  904. },
  905. ];
  906. this.resetForm("form");
  907. },
  908. /** 记账 **/
  909. handleUpdataKeeping() {
  910. updataKeeping(this.tableId).then((res) => {
  911. this.msgSuccess("记账成功");
  912. this.open = false;
  913. this.getList();
  914. });
  915. },
  916. /**冲销**/
  917. handleOff() {
  918. undataWriteOff(this.tableId).then((res) => {
  919. this.msgSuccess("冲销成功");
  920. this.open = false;
  921. this.getList();
  922. });
  923. },
  924. /** 搜索按钮操作 */
  925. handleQuery() {
  926. this.queryParams.pageNum = 1;
  927. this.getList();
  928. },
  929. /** 重置按钮操作 */
  930. resetQuery() {
  931. this.resetForm("queryForm");
  932. this.handleQuery();
  933. },
  934. // 多选框选中数据
  935. /*handleSelectionChange(selection) {
  936. this.ids = selection.map((item) => item.id);
  937. this.single = selection.length !== 1;
  938. this.multiple = !selection.length;
  939. },*/
  940. /** 新增按钮操作 */
  941. handleAdd() {
  942. this.reset();
  943. this.form.code = this.dayjs().format("YYYYMMDDHHmmssSSS");
  944. // this.form.createTime = new Date();
  945. this.open = true;
  946. this.title = "添加入库单";
  947. this.BtnState = 1;
  948. this.disableDetails = false;
  949. },
  950. /** 修改按钮操作 */
  951. handleUpdate(num, row) {
  952. this.BtnState = num;
  953. this.reset();
  954. const id = row.id || this.ids;
  955. this.tableId = id;
  956. getWarehousing(id).then((response) => {
  957. response.data.warehousingDetails.map((item) => {
  958. item.drugsType = String(item.drugsType);
  959. item.packingUnit = String(item.packingUnit);
  960. });
  961. this.form = response.data;
  962. this.form.supplierId += ''
  963. this.warehousingDetails = response.data.warehousingDetails;
  964. //this.warehousingDetails.forEach((item, index) => {
  965. //this.getListSpecs(item.drugsId, index);
  966. //this.getListPrice(item.specsId, index);
  967. // this.warehousingDetails[index].packingUnit = String(item.packingUnit)
  968. //});
  969. //this.handleRk(response.data.warehousingType);
  970. this.open = true;
  971. num == 3
  972. ? (this.title = "详情入库单")
  973. : num == 1
  974. ? (this.title = "修改入库单")
  975. : num == 4
  976. ? (this.title = "冲销入库单")
  977. : num == 2
  978. ? (this.title = "记账入库单")
  979. : "";
  980. });
  981. this.num = num
  982. if (num === 1) {
  983. this.disableDetails = false;
  984. this.editable = true
  985. } else if (num === 2 || num === 3 || num === 4) {
  986. this.disableDetails = true;
  987. this.editable = false
  988. }
  989. //console.log('num', this.num)
  990. },
  991. formatTime(date, fmt) {
  992. var date = new Date(date);
  993. if (/(y+)/.test(fmt)) {
  994. fmt = fmt.replace(
  995. RegExp.$1,
  996. (date.getFullYear() + "").substr(4 - RegExp.$1.length)
  997. );
  998. }
  999. var o = {
  1000. "M+": date.getMonth() + 1,
  1001. "d+": date.getDate(),
  1002. "h+": date.getHours(),
  1003. "m+": date.getMinutes(),
  1004. "s+": date.getSeconds(),
  1005. };
  1006. for (var k in o) {
  1007. if (new RegExp("(" + k + ")").test(fmt)) {
  1008. var str = o[k] + "";
  1009. fmt = fmt.replace(
  1010. RegExp.$1,
  1011. RegExp.$1.length === 1 ? str : ("00" + str).substr(str.length)
  1012. );
  1013. }
  1014. }
  1015. return fmt;
  1016. },
  1017. /** 提交按钮 */
  1018. submitForm() {
  1019. this.$refs["form"].validate((valid) => {
  1020. if (valid) {
  1021. if (this.warehousingDetails.find(v => v.purchasePrice == '')) {
  1022. return this.msgError('请完善进货单价信息')
  1023. }
  1024. this.form.warehousingDetails = this.warehousingDetails;
  1025. // this.form.createTime = this.form.createTime
  1026. // ? this.formatTime(this.form.createTime, "yyyy-MM-dd hh:mm:ss")
  1027. // : null;
  1028. // this.form.keepingTime = this.form.keepingTime
  1029. // ? this.formatTime(this.form.keepingTime, "yyyy-MM-dd hh:mm:ss")
  1030. // : null;
  1031. var result = this.form.warehousingDetails.every(
  1032. (v, i) => v.productionCode
  1033. );
  1034. var form = Object.assign({}, this.form)
  1035. if (!this.editable) {
  1036. form.supplierId = this.form.supplierId.id
  1037. form.supplierName = this.form.supplierId.name
  1038. } else {
  1039. if (this.supplierArr.find(v => v.id == form.supplierId)) {
  1040. form.supplierId = this.supplierArr.find(v => v.name == form.supplierName).id
  1041. }
  1042. }
  1043. if (result) {
  1044. if (form.id != null) {
  1045. updateWarehousing(form).then((response) => {
  1046. this.msgSuccess("修改成功");
  1047. this.open = false;
  1048. this.getList();
  1049. });
  1050. } else {
  1051. addWarehousing(form).then((response) => {
  1052. this.msgSuccess("新增成功");
  1053. this.open = false;
  1054. this.getList();
  1055. });
  1056. }
  1057. } else {
  1058. this.msgError("生产批号不能为空");
  1059. }
  1060. }
  1061. });
  1062. },
  1063. /** 删除按钮操作 */
  1064. handleDelete(row) {
  1065. const ids = row.id || this.ids;
  1066. this.$confirm("确定需要删除选中数据吗?", "警告", {
  1067. confirmButtonText: "确定",
  1068. cancelButtonText: "取消",
  1069. type: "warning",
  1070. })
  1071. .then(function () {
  1072. return delWarehousing(ids);
  1073. })
  1074. .then(() => {
  1075. this.getList();
  1076. this.msgSuccess("删除成功");
  1077. })
  1078. .catch(() => {});
  1079. },
  1080. /** 入库单详情序号 */
  1081. rowWarehouseDetailIndex({ row, rowIndex }) {
  1082. row.index = rowIndex + 1;
  1083. },
  1084. /** 入库单详情添加按钮操作 */
  1085. handleAddWarehouseDetail() {
  1086. let obj = {};
  1087. obj.drugsId = "";
  1088. obj.specsId = "";
  1089. obj.priceId = "";
  1090. obj.stock = "";
  1091. obj.inventory = "";
  1092. obj.purchasePrice = "";
  1093. obj.purchasePriceAll = "";
  1094. obj.retailPrice = "";
  1095. obj.approvalCode = "";
  1096. obj.site = "";
  1097. obj.productionCode = "";
  1098. obj.validTime = "";
  1099. this.warehousingDetails.push(obj);
  1100. },
  1101. /** 入库单详情删除按钮操作 */
  1102. handleDeleteWarehouseDetail() {
  1103. if (this.checkedWarehouseDetail.length == 0) {
  1104. this.msgError("请先选择要删除的入库单详情数据");
  1105. } else {
  1106. const warehousingDetails = this.warehousingDetails;
  1107. const checkedWarehouseDetail = this.checkedWarehouseDetail;
  1108. this.warehousingDetails = warehousingDetails.filter(function (item) {
  1109. return checkedWarehouseDetail.indexOf(item.index) == -1;
  1110. });
  1111. }
  1112. },
  1113. /** 复选框选中数据 */
  1114. handleWarehouseDetailSelectionChange(selection) {
  1115. this.checkedWarehouseDetail = selection.map((item) => item.index);
  1116. },
  1117. /** 导出按钮操作 */
  1118. async handleExport() {
  1119. this.exportLoading = true;
  1120. try {
  1121. await this.$confirm("是否确认导出所有入库单数据项?", "警告", {
  1122. confirmButtonText: "确定",
  1123. cancelButtonText: "取消",
  1124. type: "warning",
  1125. });
  1126. const data = await exportWarehousing(this.queryParams)
  1127. this.$message.success(`导出 ${data.name} 成功`);
  1128. } catch (e) {}
  1129. this.exportLoading = false;
  1130. },
  1131. },
  1132. };
  1133. </script>
  1134. <style scoped>
  1135. /* .el-date-editor.el-input,
  1136. .el-date-editor.el-input__inner {
  1137. width: 190px;
  1138. } */
  1139. .el-input--small .el-input__inner {
  1140. height: 36px;
  1141. line-height: 36px;
  1142. }
  1143. </style>