cancelDrugStockOrder.vue 21KB

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