cancelDrugStockOrder.vue 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <el-button
  6. size="small"
  7. @click="AddNewOrder"
  8. class="filter-item"
  9. style="float:right;"
  10. type="primary"
  11. icon="el-icon-circle-plus-outline"
  12. >新增
  13. </el-button>
  14. </div>
  15. <div class="app-container">
  16. <div class="cell clearfix">
  17. <el-input
  18. size="small"
  19. style="width: 400px;"
  20. class="filter-item"
  21. v-model.trim="searchKey"
  22. placeholder="单据编码/制单人/厂商"
  23. />
  24. <el-button
  25. size="small"
  26. class="filter-item"
  27. type="primary"
  28. icon="el-icon-search"
  29. @click="search"
  30. >搜索</el-button
  31. >
  32. <div style="margin-left:10px;">
  33. <label class="title"><span class="name">退库时间</span> : </label>
  34. <el-date-picker
  35. size="small"
  36. v-model="start_time"
  37. prefix-icon="el-icon-date"
  38. :editable="false"
  39. style="width: 196px;"
  40. type="date"
  41. placeholder="选择日期时间"
  42. align="right"
  43. format="yyyy-MM-dd"
  44. value-format="yyyy-MM-dd"
  45. @change="startTimeChange"
  46. ></el-date-picker>
  47. <span class="cellLine"> - </span>
  48. <el-date-picker
  49. size="small"
  50. v-model="end_time"
  51. prefix-icon="el-icon-date"
  52. :editable="false"
  53. style="width: 196px;"
  54. type="date"
  55. placeholder="选择日期时间"
  56. align="right"
  57. format="yyyy-MM-dd"
  58. value-format="yyyy-MM-dd"
  59. @change="endTimeChange"
  60. ></el-date-picker>
  61. </div>
  62. </div>
  63. <div class="filter-container" style="margin-top: 10px">
  64. <el-checkbox
  65. style="width: 70px"
  66. v-model="checked"
  67. @change="changeAllSelected"
  68. >全选</el-checkbox
  69. >
  70. <el-button size="small" icon="el-icon-delete" @click="batchDelete">删除</el-button>
  71. <el-button size="small" type="primary" @click="toPrint">打印</el-button>
  72. <el-button size="small" type="primary" @click="toExport">导出</el-button>
  73. </div>
  74. <el-table
  75. :data="cancelStockDate"
  76. :class="signAndWeighBoxPatients"
  77. border
  78. highlight-current-row
  79. ref="multipleTable"
  80. @current-change="handleCurrentChangeOne"
  81. @selection-change="select"
  82. :row-style="{ color: '#303133' }"
  83. :header-cell-style="{
  84. backgroundColor: 'rgb(245, 247, 250)',
  85. color: '#606266'
  86. }"
  87. >
  88. <el-table-column type="selection" width="55"> </el-table-column>
  89. <el-table-column label="单据日期" align="center">
  90. <template slot-scope="scope">
  91. {{ scope.row.return_time | parseTime("{y}-{m}-{d}") }}
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="单据编号" align="center">
  95. <template slot-scope="scope">
  96. {{ scope.row.order_number }}
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="制单人" align="center">
  100. <template slot-scope="scope">
  101. {{ getXuserName(scope.row.creater) }}
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="操作" align="center">
  105. <template slot-scope="scope">
  106. <el-tooltip
  107. class="item"
  108. effect="dark"
  109. content="编辑"
  110. placement="top"
  111. >
  112. <el-button
  113. size="mini"
  114. type="primary"
  115. icon="el-icon-edit-outline"
  116. @click="handleEdit(scope.$index, scope.row)"
  117. >
  118. </el-button>
  119. </el-tooltip>
  120. <el-tooltip
  121. class="item"
  122. effect="dark"
  123. content="删除"
  124. placement="top"
  125. >
  126. <el-button
  127. size="mini"
  128. type="danger"
  129. icon="el-icon-delete"
  130. @click="handleDelete(scope.$index, scope.row)"
  131. >
  132. </el-button>
  133. </el-tooltip>
  134. </template>
  135. </el-table-column>
  136. </el-table>
  137. <el-pagination
  138. @size-change="handleSizeChange"
  139. @current-change="handleCurrentChange"
  140. :page-sizes="[5,10, 15, 100]"
  141. :page-size="5"
  142. background
  143. style="margin-top:20px;float: right;margin-bottom:10px;"
  144. layout="total, sizes, prev, pager, next, jumper"
  145. :total="total"
  146. >
  147. </el-pagination>
  148. <div v-show ="showTable">
  149. <el-table
  150. :data="tableList"
  151. :class="signAndWeighBoxPatients"
  152. border
  153. highlight-current-row
  154. ref="multipleTableOne"
  155. @selection-change="select"
  156. :row-style="{ color: '#303133' }"
  157. :header-cell-style="{
  158. backgroundColor: 'rgb(245, 247, 250)',
  159. color: '#606266'
  160. }"
  161. >
  162. <el-table-column label="药品名称" align="center">
  163. <template slot-scope="scope">
  164. {{ scope.row.BaseDrugLib.drug_name}}
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="规格&单位" align="center">
  168. <template slot-scope="scope">
  169. {{ scope.row.BaseDrugLib.dose}}{{scope.row.BaseDrugLib.dose_unit}} * {{scope.row.BaseDrugLib.min_number}}{{scope.row.BaseDrugLib.min_unit}} /{{scope.row.BaseDrugLib.max_unit}}
  170. </template>
  171. </el-table-column>
  172. <el-table-column label="退库数量" align="center">
  173. <template slot-scope="scope">
  174. {{ scope.row.count}}
  175. </template>
  176. </el-table-column>
  177. <el-table-column label="退库单位" align="center">
  178. <template slot-scope="scope">
  179. {{ scope.row.max_unit}}
  180. </template>
  181. </el-table-column>
  182. <el-table-column label="退库单价" align="center">
  183. <template slot-scope="scope">
  184. {{ scope.row.price}}
  185. </template>
  186. </el-table-column>
  187. <!-- <el-table-column label="批次" align="center">
  188. <template slot-scope="scope">
  189. {{ scope.row.batch_number}}
  190. </template>
  191. </el-table-column> -->
  192. <el-table-column label="品名/注册证号(备案凭证号)" align="center">
  193. <template slot-scope="scope">
  194. {{ scope.row.register_account}}
  195. </template>
  196. </el-table-column>
  197. <el-table-column label="生产厂家" align="center">
  198. <template slot-scope="scope">
  199. {{scope.row.manufacturer}}
  200. </template>
  201. </el-table-column>
  202. <el-table-column label="生产日期" align="center">
  203. <template slot-scope="scope">
  204. {{scope.row.product_date}}
  205. </template>
  206. </el-table-column>
  207. <el-table-column label="有效日期" align="center">
  208. <template slot-scope="scope">
  209. {{scope.row.expiry_date}}
  210. </template>
  211. </el-table-column>
  212. <el-table-column label="经销商" align="center">
  213. <template slot-scope="scope">
  214. {{scope.row.dealer}}
  215. </template>
  216. </el-table-column>
  217. <el-table-column label="退库原因" align="center">
  218. <template slot-scope="scope">
  219. {{scope.row.remark}}
  220. </template>
  221. </el-table-column>
  222. </el-table>
  223. </div>
  224. </div>
  225. </div>
  226. </template>
  227. <script>
  228. import { uParseTime } from "@/utils/tools";
  229. import { fetchAllAdminUsers, fetchAllDoctorAndNurse } from "@/api/doctor";
  230. import {
  231. deleteDrugCancelStock,
  232. GetAllConfig,
  233. getDrugCancelStockList,
  234. getCancelStockDetail,
  235. getDrugCancelExportList
  236. } from "@/api/drug/drug_stock";
  237. import BreadCrumb from '../../components/bread-crumb'
  238. // import BreadCrumb from "../components/bread-crumb";
  239. export default {
  240. name: "salesReturnOrder",
  241. components: { BreadCrumb },
  242. created() {
  243. var nowDate = new Date();
  244. var nowYear = nowDate.getFullYear();
  245. var nowMonth = nowDate.getMonth() + 1;
  246. var nowDay = nowDate.getDate();
  247. this.end_time =
  248. nowYear +
  249. "-" +
  250. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  251. "-" +
  252. (nowDay < 10 ? "0" + nowDay : nowDay);
  253. nowDate.setMonth(nowDate.getMonth() - 1);
  254. nowYear = nowDate.getFullYear();
  255. nowMonth = nowDate.getMonth() + 1;
  256. nowDay = nowDate.getDate();
  257. this.start_time =
  258. nowYear +
  259. "-" +
  260. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  261. "-" +
  262. (nowDay < 10 ? "0" + nowDay : nowDay);
  263. this.GetCancelStock();
  264. this.GetConfigInfo();
  265. this.fetchAllAdminUsers();
  266. },
  267. data() {
  268. return {
  269. crumbs: [
  270. { path: false, name: "库存管理" },
  271. { path: false, name: "出库退库单" }
  272. ],
  273. searchKey: "",
  274. type: 1,
  275. page: 1,
  276. limit: 5,
  277. checked: false,
  278. total: 0,
  279. pageTotal: 0,
  280. pageSelect: 0,
  281. adminUserOptions: [],
  282. multipleSelection: [],
  283. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  284. start_time: "",
  285. cancelStockDate: [],
  286. end_time: "",
  287. goodType: [],
  288. goodInfo: [],
  289. manufacturer: [],
  290. selectedTableData: [],
  291. dealer: [],
  292. tableList:[],
  293. showTable:false,
  294. order_id:"",
  295. exportList:[]
  296. };
  297. },
  298. methods: {
  299. search: function() {
  300. const Params = {
  301. page: this.page,
  302. limit: this.limit,
  303. start_time: this.start_time,
  304. end_time: this.end_time,
  305. type: this.type,
  306. keywords: this.searchKey
  307. };
  308. this.cancelStockDate = [];
  309. getDrugCancelStockList(Params).then(response => {
  310. if (response.data.state == 0) {
  311. this.$message.error(response.data.msg);
  312. return false;
  313. } else {
  314. this.total = response.data.data.total;
  315. for (let i = 0; i < response.data.data.list.length; i++) {
  316. this.cancelStockDate.push(response.data.data.list[i]);
  317. }
  318. }
  319. });
  320. },
  321. AddNewOrder: function() {
  322. this.$router.push({
  323. name: "cancelDrugStockOrderAdd",
  324. query: { type: this.type }
  325. });
  326. },
  327. GetCancelStock: function() {
  328. const Params = {
  329. page: this.page,
  330. limit: this.limit,
  331. start_time: this.start_time,
  332. end_time: this.end_time,
  333. type: this.type
  334. };
  335. this.cancelStockDate = [];
  336. getDrugCancelStockList(Params).then(response => {
  337. if (response.data.state == 0) {
  338. this.$message.error(response.data.msg);
  339. return false;
  340. } else {
  341. console.log("列表23232323232323",response.data.data.list)
  342. this.total = response.data.data.total;
  343. for (let i = 0; i < response.data.data.list.length; i++) {
  344. this.cancelStockDate.push(response.data.data.list[i]);
  345. }
  346. }
  347. });
  348. },
  349. getXuserName(id) {
  350. if (id <= 0) {
  351. return "";
  352. }
  353. var name = "";
  354. if (
  355. this.adminUserOptions == null ||
  356. typeof this.adminUserOptions.length === "undefined"
  357. ) {
  358. return name;
  359. }
  360. var leng = this.adminUserOptions.length;
  361. if (leng == 0) {
  362. return name;
  363. }
  364. for (let index = 0; index < leng; index++) {
  365. if (this.adminUserOptions[index].id == id) {
  366. name = this.adminUserOptions[index].name;
  367. break;
  368. }
  369. }
  370. return name;
  371. },
  372. fetchAllAdminUsers() {
  373. fetchAllAdminUsers().then(response => {
  374. if (response.data.state == 1) {
  375. this.adminUserOptions = response.data.data.users;
  376. var alen = this.adminUserOptions.length;
  377. for (let index = 0; index < alen; index++) {
  378. if (this.adminUserOptions[index].user_type == 2) {
  379. // this.doctorOptions.push(this.adminUserOptions[index]);
  380. }
  381. }
  382. }
  383. });
  384. },
  385. handleSelectionChange: function(val) {
  386. this.multipleSelection = val;
  387. },
  388. handleSizeChange(val) {
  389. this.limit = val;
  390. this.GetCancelStock();
  391. },
  392. handleCurrentChange(val) {
  393. this.page = val;
  394. this.GetCancelStock();
  395. },
  396. startTimeChange(val) {
  397. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  398. if (time > 0) {
  399. this.$message.error("结束时间不能小于开始时间");
  400. this.start_time = "";
  401. } else {
  402. this.GetCancelStock();
  403. }
  404. this.GetCancelStock();
  405. },
  406. endTimeChange(val) {
  407. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  408. if (time < 0) {
  409. this.$message.error("结束时间不能小于开始时间");
  410. this.end_time = "";
  411. } else {
  412. this.GetCancelStock();
  413. }
  414. },
  415. getTimestamp(time) {
  416. // 把时间日期转成时间戳
  417. return new Date(time).getTime() / 1000;
  418. },
  419. calculate: function(val) {
  420. return Math.round(parseFloat(val) * 100) / 100;
  421. },
  422. GetConfigInfo: function() {
  423. GetAllConfig().then(response => {
  424. if (response.data.state == 0) {
  425. this.$message.error(response.data.msg);
  426. return false;
  427. } else {
  428. this.manufacturer = response.data.data.manufacturer;
  429. this.dealer = response.data.data.dealer;
  430. }
  431. });
  432. },
  433. getManufactuerName: function(manufacturer_id) {
  434. for (let i = 0; i < this.manufacturer.length; i++) {
  435. if (this.manufacturer[i].id == manufacturer_id) {
  436. return this.manufacturer[i].manufacturer_name;
  437. }
  438. }
  439. },
  440. getDealerName: function(dealer_id) {
  441. for (let i = 0; i < this.dealer.length; i++) {
  442. if (this.dealer[i].id == dealer_id) {
  443. return this.dealer[i].dealer_name;
  444. }
  445. }
  446. },
  447. handleEdit: function(index, row) {
  448. this.$router.push({path:"/drugstock/cancel/edit?id="+row.id+"&type="+this.type})
  449. },
  450. handleDelete: function(index, row) {
  451. const ids = [];
  452. ids.push(row.id);
  453. const idStr = ids.join(",");
  454. const params = {
  455. ids: idStr
  456. };
  457. this.$confirm("确认删除退库单记录?", "删除退库单记录", {
  458. confirmButtonText: "确定",
  459. cancelButtonText: "取消",
  460. type: "warning"
  461. })
  462. .then(() => {
  463. deleteDrugCancelStock(params).then(response => {
  464. if (response.data.state == 0) {
  465. this.$message.error(response.data.msg);
  466. return false;
  467. } else {
  468. this.$notify({
  469. title: "成功",
  470. message: "删除成功",
  471. type: "success",
  472. duration: 2000
  473. });
  474. for (let i = 0; i < ids.length; i++) {
  475. for (let y = 0; y < this.cancelStockDate.length; y++) {
  476. if (ids[i] == this.cancelStockDate[y].id) {
  477. this.cancelStockDate.splice(y, 1);
  478. }
  479. }
  480. }
  481. }
  482. });
  483. })
  484. .catch(() => {});
  485. },
  486. changeAllSelected: function(val) {
  487. if (val) {
  488. this.$refs.multipleTable.toggleAllSelection();
  489. } else {
  490. this.$refs.multipleTable.clearSelection();
  491. }
  492. },
  493. select(selection) {
  494. var ids= []
  495. for(let i=0;i<selection.length;i++){
  496. ids.push(selection[i].id)
  497. }
  498. this.order_id = ids.join(",")
  499. this.selectedTableData = selection;
  500. this.getDrugCancelExportList()
  501. },
  502. batchDelete() {
  503. if (this.selectedTableData.length <= 0) {
  504. this.$message.error("请选择要删除的记录");
  505. return;
  506. }
  507. const ids = [];
  508. for (let i = 0; i < this.selectedTableData.length; i++) {
  509. ids.push(this.selectedTableData[i].id);
  510. }
  511. const idStr = ids.join(",");
  512. const params = {
  513. ids: idStr
  514. };
  515. this.$confirm("确认删除退库单记录?", "删除退库单记录", {
  516. confirmButtonText: "确定",
  517. cancelButtonText: "取消",
  518. type: "warning"
  519. })
  520. .then(() => {
  521. deleteDrugCancelStock(params).then(response => {
  522. if (response.data.state == 0) {
  523. this.$message.error(response.data.msg);
  524. return false;
  525. } else {
  526. this.$notify({
  527. title: "成功",
  528. message: "删除成功",
  529. type: "success",
  530. duration: 2000
  531. });
  532. for (let i = 0; i < ids.length; i++) {
  533. for (let y = 0; y < this.cancelStockDate.length; y++) {
  534. if (ids[i] == this.cancelStockDate[y].id) {
  535. this.cancelStockDate.splice(y, 1);
  536. }
  537. }
  538. }
  539. }
  540. });
  541. })
  542. .catch(() => {});
  543. },
  544. handleCurrentChangeOne(val) {
  545. this.getCancelStockDetail(val.id)
  546. },
  547. getCancelStockDetail(id){
  548. console.log("id232233223",id)
  549. var params = {
  550. id:id
  551. }
  552. getCancelStockDetail(params).then(response=>{
  553. if(response.data.state == 1){
  554. var list = response.data.data.list
  555. console.log("hhhh23233323223",list)
  556. for(let i=0;i<list.length;i++){
  557. list[i].product_date = this.getTime(list[i].product_date,"{y}-{h}-{d}")
  558. list[i].expiry_date = this.getTime(list[i].expiry_date,"{y}-{h}-{d}")
  559. }
  560. this.tableList = list
  561. // console.log("list23232",list)
  562. this.showTable = true
  563. }
  564. })
  565. },
  566. getTime(val) {
  567. if(val < 0){
  568. return ""
  569. }
  570. if(val == ""){
  571. return ""
  572. }else {
  573. return uParseTime(val, '{y}-{m}-{d}')
  574. }
  575. },
  576. toPrint(){
  577. if(this.order_id == ""){
  578. this.$message.error("请勾选退库单")
  579. return
  580. }
  581. this.$router.push({path:"/drug/cancel/print?order_id="+this.order_id+"&start_time="+this.start_time+"&end_time="+this.end_time})
  582. },
  583. getDrugCancelExportList(){
  584. const params = {
  585. order_id:this.order_id
  586. }
  587. getDrugCancelExportList(params).then(response=>{
  588. if(response.data.state == 1){
  589. var list = response.data.data.list
  590. // console.log("导出数据222",list)
  591. this.exportList = list
  592. }
  593. })
  594. },
  595. toExport(){
  596. if(this.order_id == ""){
  597. this.$message.error("请勾选退库单")
  598. return
  599. }
  600. import('@/vendor/Export2Excel').then(excel => {
  601. for(let i=0;i<this.exportList.length;i++){
  602. this.exportList[i].total_price = this.exportList[i].count * this.exportList[i].price
  603. this.exportList[i].drug_name = this.exportList[i].BaseDrugLib.drug_name
  604. this.exportList[i].unit = this.exportList[i].BaseDrugLib.dose + this.exportList[i].BaseDrugLib.dose_unit + "*" + this.exportList[i].BaseDrugLib.min_number +this.exportList[i].BaseDrugLib.min_unit + "/" +this.exportList[i].BaseDrugLib.max_unit
  605. if(this.exportList[i].dealer == 0){
  606. this.exportList[i].dealer = ""
  607. }
  608. if(this.exportList[i].manufacturer == 0){
  609. this.exportList[i].manufacturer = ""
  610. }
  611. this.exportList[i].product_date = this.getTime(this.exportList[i].product_date,"{y}-{h}-{d}")
  612. this.exportList[i].expiry_date = this.getTime(this.exportList[i].expiry_date,"{y}-{h}-{d}")
  613. }
  614. const tHeader = ['药品名称', '规格&单位','退库数量','退库单价','批次','品名/注册证号(备案凭证号)','生产厂家','生产日期','有效期','退库原因']
  615. const filterVal = ['drug_name', 'unit','count','price','batch_number','register_account','manufacturer','product_date','expiry_date','remark']
  616. // console.log("table",this.exportList)
  617. const data = this.formatJson(filterVal, this.exportList)
  618. excel.export_json_to_excel({
  619. header: tHeader,
  620. data,
  621. filename: '药品退库单详情'
  622. })
  623. this.downloadLoading = false
  624. })
  625. },
  626. formatJson(filterVal, jsonData) {
  627. return jsonData.map(v => filterVal.map(j => v[j]));
  628. },
  629. }
  630. };
  631. </script>
  632. <style rel="stylesheet/css" lang="scss" scoped>
  633. .information {
  634. border: 1px #dcdfe6 solid;
  635. padding: 30px 20px 30px 20px;
  636. .border {
  637. border-bottom: 1px #dcdfe6 solid;
  638. margin: 0px 0 20px 0;
  639. }
  640. }
  641. .edit_separater {
  642. border-top: 1px solid rgb(233, 233, 233);
  643. margin-top: 15px;
  644. margin-bottom: 15px;
  645. }
  646. </style>
  647. <style>
  648. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  649. font-size: 12px;
  650. }
  651. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  652. background: #6fb5fa;
  653. }
  654. .count {
  655. color: #bd2c00;
  656. }
  657. .el-table td,
  658. .el-table th.is-leaf,
  659. .el-table--border,
  660. .el-table--group {
  661. border-color: #d0d3da;
  662. }
  663. .el-table--border::after,
  664. .el-table--group::after,
  665. .el-table::before {
  666. background-color: #d0d3da;
  667. }
  668. </style>