drugInOrder.vue 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. <template>
  2. <div>
  3. <el-button
  4. style="float: right"
  5. size="small"
  6. @click="PrintAction"
  7. type="primary"
  8. >打印
  9. </el-button>
  10. <el-button
  11. style="float: right;margin-right:10px"
  12. size="small"
  13. @click="exportListDetail"
  14. type="primary"
  15. >明细导出
  16. </el-button>
  17. <el-button
  18. style="float: right;margin-right:10px"
  19. size="small"
  20. @click="exportList"
  21. type="primary"
  22. >汇总导出
  23. </el-button>
  24. <div class="cell clearfix">
  25. <label class="title"><span class="name">仓库</span> :</label>
  26. <el-select size="small" v-model="storehouse_id" filterable placeholder="请选择仓库" style="width:200px" @change="changeHouseList">
  27. <el-option
  28. v-for="(option, index) in houseList"
  29. :key="index"
  30. :label="option.storehouse_name"
  31. :value="option.id">
  32. </el-option>
  33. </el-select>
  34. <el-input
  35. size="small"
  36. style="width: 200px;"
  37. class="filter-item"
  38. v-model.trim="searchKey"
  39. placeholder="单据编码/制单人/药品名称"
  40. />
  41. <el-button
  42. size="small"
  43. class="filter-item"
  44. type="primary"
  45. icon="el-icon-search"
  46. @click="search"
  47. >搜索</el-button
  48. >
  49. <label class="title"><span class="name">日期查询</span> : </label>
  50. <el-date-picker
  51. size="small"
  52. v-model="start_time"
  53. prefix-icon="el-icon-date"
  54. :editable="false"
  55. style="width: 150px;"
  56. type="date"
  57. placeholder="选择日期时间"
  58. align="right"
  59. format="yyyy-MM-dd"
  60. value-format="yyyy-MM-dd"
  61. @change="startTimeChange"
  62. ></el-date-picker>
  63. <span class="cellLine"> - </span>
  64. <el-date-picker
  65. size="small"
  66. v-model="end_time"
  67. prefix-icon="el-icon-date"
  68. :editable="false"
  69. style="width: 150px;"
  70. type="date"
  71. placeholder="选择日期时间"
  72. align="right"
  73. format="yyyy-MM-dd"
  74. value-format="yyyy-MM-dd"
  75. @change="endTimeChange"
  76. ></el-date-picker>
  77. </div>
  78. <!-- <el-row :gutter="12" style="margin-top: 10px"> -->
  79. <el-table class="eltable"
  80. :data="cancelStockDate"
  81. :class="signAndWeighBoxPatients"
  82. border
  83. highlight-current-row
  84. ref="multipleTable"
  85. @selection-change="select"
  86. :row-style="{ color: '#303133' }"
  87. :header-cell-style="{
  88. backgroundColor: 'rgb(245, 247, 250)',
  89. color: '#606266'
  90. }"
  91. max-height="calc(100vh - 300px)"
  92. >
  93. <el-table-column label="单据编号" align="center" width="200">
  94. <template slot-scope="scope">
  95. {{scope.row.warehousing_order}}
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="药品类型" align="center">
  99. <template slot-scope="scope">
  100. <span v-if="scope.row.drug_type == 1">西药</span>
  101. <span v-if="scope.row.drug_type == 2">草药</span>
  102. <span v-if="scope.row.drug_type == 3">成药</span>
  103. <!-- {{getTypeList(scope.row.drug_type)}} -->
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="药品名称" align="center">
  107. <template slot-scope="scope">
  108. {{scope.row.drug_name}}
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="规格型号" align="center">
  112. <template slot-scope="scope">
  113. {{scope.row.specification_name}}
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="操作时间" align="center">
  117. <template slot-scope="scope">
  118. <span>{{getTime(scope.row.ctime)}}</span>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="制单人" align="center">
  122. <template slot-scope="scope">
  123. {{getAdminUser(scope.row.creater)}}
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="仓库名称" align="center">
  127. <template slot-scope="scope">
  128. {{getStorehouseName(scope.row.storehouse_id)}}
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="进货价" align="center">
  132. <template slot-scope="scope">
  133. {{scope.row.price}}
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="数量" align="center">
  137. <template slot-scope="scope">
  138. {{scope.row.warehousing_count}}
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="单位" align="center">
  142. <template slot-scope="scope">
  143. {{scope.row.count_unit}}
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="总价" align="center">
  147. <template slot-scope="scope">
  148. {{scope.row.total_price}}
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <el-pagination
  153. @size-change="handleSizeChange"
  154. @current-change="handleCurrentChange"
  155. :page-sizes="[10, 50, 100]"
  156. :page-size="10"
  157. background
  158. style="margin-top:20px;float: right"
  159. layout="total, sizes, prev, pager, next, jumper"
  160. :total="total"
  161. >
  162. </el-pagination>
  163. <!-- </el-row> -->
  164. </div>
  165. </template>
  166. <script>
  167. import { uParseTime } from "@/utils/tools";
  168. import { fetchAllAdminUsers } from "@/api/doctor";
  169. import { GetAllConfig } from "@/api/stock";
  170. import { getDrugIndetail,getDrugWarehouseInfoPrint} from "@/api/drug/drug_stock"
  171. export default {
  172. name: "stockInDetail",
  173. created() {
  174. var nowDate = new Date();
  175. var nowYear = nowDate.getFullYear();
  176. var nowMonth = nowDate.getMonth() + 1;
  177. var nowDay = nowDate.getDate();
  178. this.end_time =
  179. nowYear +
  180. "-" +
  181. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  182. "-" +
  183. (nowDay < 10 ? "0" + nowDay : nowDay);
  184. nowDate.setMonth(nowDate.getMonth() - 1);
  185. nowYear = nowDate.getFullYear();
  186. nowMonth = nowDate.getMonth() + 1;
  187. nowDay = nowDate.getDate();
  188. this.start_time =
  189. nowYear +
  190. "-" +
  191. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  192. "-" +
  193. (nowDay < 10 ? "0" + nowDay : nowDay);
  194. var start_time = window.sessionStorage.getItem('drug_start_in_time')
  195. var end_time = window.sessionStorage.getItem('drug_end_in_time')
  196. if(start_time !=null){
  197. this.start_time = start_time
  198. }
  199. if(end_time!=null){
  200. this.end_time = end_time
  201. }
  202. window.sessionStorage.removeItem('drug_start_in_time')
  203. window.sessionStorage.removeItem('drug_end_in_time')
  204. this.GetConfigInfo()
  205. this.fetchAllAdminUsers()
  206. //获取入库单数据
  207. this.getlist()
  208. this.getDrugWarehouseInfoPrint()
  209. },
  210. data() {
  211. return {
  212. orderTypeArr: [
  213. { value: 1, label: "药品入库单" },
  214. { value: 2, label: "其他入库单" }
  215. ],
  216. newDate: [{ name: "合计", num: "111111" }],
  217. searchKey: "",
  218. type: 1,
  219. page: 1,
  220. limit: 10,
  221. manufacturer_id: "",
  222. dealer_id: "",
  223. order_type: 1,
  224. checked: false,
  225. total: 0,
  226. pageTotal: 0,
  227. pageSelect: 0,
  228. adminUserOptions: [],
  229. multipleSelection: [],
  230. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  231. start_time: "",
  232. cancelStockDate: [],
  233. end_time: "",
  234. goodType: [],
  235. goodInfo: [],
  236. manufacturer: [],
  237. selectedTableData: [],
  238. dealer: [],
  239. tableList:[],
  240. tabelePrintList:[],
  241. drugTypeList:[],
  242. storehouse_id:0,
  243. houseList:[],
  244. };
  245. },
  246. methods: {
  247. changeType: function(val) {
  248. this.order_type = val;
  249. },
  250. changeManufacturer: function(val) {
  251. this.manufacturer_id = val;
  252. },
  253. changeDealer: function(val) {
  254. this.dealer_id = val;
  255. },
  256. search: function() {
  257. this.getlist()
  258. },
  259. getTime: function(val) {
  260. if (val == 0) {
  261. return "";
  262. } else {
  263. return uParseTime(val, "{y}-{m}-{d}");
  264. }
  265. },
  266. AddNewOrder: function() {
  267. },
  268. fetchAllAdminUsers() {
  269. fetchAllAdminUsers().then(response => {
  270. if (response.data.state == 1) {
  271. this.adminUserOptions = response.data.data.users;
  272. }
  273. });
  274. },
  275. handleSelectionChange: function(val) {
  276. this.multipleSelection = val;
  277. },
  278. handleSizeChange(val) {
  279. this.limit = val;
  280. this.getlist()
  281. },
  282. handleCurrentChange(val) {
  283. this.page = val;
  284. this.getlist()
  285. },
  286. startTimeChange(val) {
  287. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  288. if (time > 0) {
  289. this.$message.error("结束时间不能小于开始时间");
  290. this.start_time = "";
  291. } else {
  292. window.sessionStorage.setItem('drug_start_in_time',this.start_time)
  293. this.getlist()
  294. this.getDrugWarehouseInfoPrint()
  295. }
  296. },
  297. endTimeChange(val) {
  298. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  299. if (time < 0) {
  300. this.$message.error("结束时间不能小于开始时间");
  301. this.end_time = "";
  302. } else {
  303. window.sessionStorage.setItem('drug_end_in_time',this.end_time)
  304. this.getlist()
  305. this.getDrugWarehouseInfoPrint()
  306. }
  307. },
  308. getTimestamp(time) {
  309. // 把时间日期转成时间戳
  310. return new Date(time).getTime() / 1000;
  311. },
  312. calculate: function(val) {
  313. return Math.round(parseFloat(val) * 100) / 100;
  314. },
  315. GetConfigInfo(){
  316. GetAllConfig().then(response => {
  317. if (response.data.state == 0) {
  318. this.$message.error(response.data.msg);
  319. return false;
  320. } else {
  321. this.manufacturer = response.data.data.manufacturer;
  322. this.dealer = response.data.data.dealer;
  323. this.goodInfo = response.data.data.goodInfo;
  324. this.goodType = response.data.data.goodType;
  325. }
  326. });
  327. },
  328. getlist(){
  329. var params = {
  330. start_time:this.start_time,
  331. end_time:this.end_time,
  332. order_type:this.order_type,
  333. manufacturer_id:this.manufacturer_id,
  334. keyword:this.searchKey,
  335. limit:this.limit,
  336. page:this.page,
  337. storehouse_id:this.storehouse_id,
  338. }
  339. getDrugIndetail(params).then(response=>{
  340. if(response.data.state == 1){
  341. var drugInOrder = response.data.data.detail
  342. var drugTypeParent = response.data.data.drugTypeParent
  343. var obj = {id:0,storehouse_name:"全部"}
  344. this.houseList = []
  345. this.houseList.push(obj)
  346. for(let i=0;i<response.data.data.houseList.length;i++){
  347. this.houseList.push(response.data.data.houseList[i])
  348. }
  349. var total_price = 0
  350. for(let i=0;i<drugInOrder.length;i++){
  351. drugInOrder[i].specification_name = drugInOrder[i].dose + drugInOrder[i].dose_unit + "*" + drugInOrder[i].min_number + drugInOrder[i].min_unit + "/" + drugInOrder[i].max_unit
  352. if(drugInOrder[i].storehouse_id > 0){
  353. drugInOrder[i].total_price = (drugInOrder[i].warehousing_count * drugInOrder[i].price).toFixed(2)
  354. }
  355. drugInOrder[i].is_total = 0
  356. total_price += drugInOrder[i].warehousing_count * drugInOrder[i].price
  357. }
  358. drugInOrder.push({
  359. warehousing_order: "合计",
  360. is_total: 1,
  361. specification_name:"",
  362. ctime:"",
  363. total_price:total_price.toFixed(2),
  364. });
  365. console.log("drugInOrder232332322323233232322332322332",drugInOrder)
  366. this.cancelStockDate = drugInOrder
  367. let objInfo = {}
  368. drugInOrder.forEach((item,index)=>{
  369. let { drug_id } = item
  370. if(!objInfo[drug_id]){
  371. objInfo[drug_id] = {
  372. drug_id,
  373. child:[],
  374. drug_name:item.drug_name,
  375. drug_spec:item.drug_spec,
  376. min_unit:item.min_unit,
  377. warehousing_count:0,
  378. price:item.price,
  379. remark:item.remark,
  380. total_price:0,
  381. dose:item.dose,
  382. dose_unit:item.dose_unit,
  383. min_number:item.min_number,
  384. max_unit:item.max_unit
  385. }
  386. }
  387. })
  388. let list = Object.values(objInfo);
  389. for(let i=0;i<drugInOrder.length;i++){
  390. list.map(item=>{
  391. if(drugInOrder[i].drug_id == item.drug_id){
  392. item.child.push(drugInOrder[i])
  393. }
  394. })
  395. }
  396. for(let i=0;i<list.length;i++){
  397. for(let j=0;j<list[i].child.length;j++){
  398. if(list[i].child[j].warehousing_count!=null || list[i].child[j].warehousing_count != "" || list[i].child[j].warehousing_count!=0){
  399. list[i].warehousing_count += list[i].child[j].warehousing_count
  400. }
  401. }
  402. }
  403. for(let i=0;i<list.length;i++){
  404. list[i].total_price = list[i].warehousing_count * list[i].price
  405. }
  406. this.tableList = list
  407. var total = response.data.data.total
  408. this.total = total
  409. }
  410. })
  411. },
  412. getDrugWarehouseInfoPrint(){
  413. var params = {
  414. start_time:this.start_time,
  415. end_time:this.end_time,
  416. order_type:this.order_type,
  417. }
  418. getDrugWarehouseInfoPrint(params).then(response=>{
  419. if(response.data.state == 1){
  420. var list = response.data.data.list
  421. this.tabelePrintList = list
  422. this.manufacturerList = response.data.data.manufacturerList
  423. this.dealerList = response.data.data.dealerList
  424. }
  425. })
  426. },
  427. PrintAction(){
  428. window.sessionStorage.setItem('drug_start_in_time',this.start_time)
  429. window.sessionStorage.setItem('drug_end_in_time',this.end_time)
  430. this.$router.push("/stock/drugprint?start_time="+this.start_time+"&end_time="+this.end_time+"&order_type="+this.order_type+"&manufacturer_id="+this.manufacturer_id+"&keyword="+this.keyword+"&limit="+this.limit+"&page="+this.page)
  431. },
  432. select(){
  433. },
  434. getAdminUser(id){
  435. var name = ""
  436. for(let i=0;i<this.adminUserOptions.length;i++){
  437. if(id == this.adminUserOptions[i].id){
  438. name = this.adminUserOptions[i].name
  439. }
  440. }
  441. return name
  442. },
  443. exportList(){
  444. console.log("tablePrintlist",this.tabelePrintList)
  445. for(let i=0;i<this.tabelePrintList.length;i++){
  446. this.tabelePrintList[i].index = i+1
  447. this.tabelePrintList[i].drug_name = this.tabelePrintList[i].XtBaseDrug.drug_name
  448. this.tabelePrintList[i].manufacturer_name = this.getManufacturerName(this.tabelePrintList[i].manufacturer)
  449. this.tabelePrintList[i].dealer_name = this.getDealerName(this.tabelePrintList[i].dealer)
  450. this.tabelePrintList[i].unit = this.tabelePrintList[i].XtBaseDrug.dose + this.tabelePrintList[i].XtBaseDrug.dose_unit + "*" + this.tabelePrintList[i].XtBaseDrug.min_number +this.tabelePrintList[i].XtBaseDrug.min_unit +"/"+this.tabelePrintList[i].XtBaseDrug.max_unit
  451. }
  452. import('@/vendor/Export2Excel').then(excel => {
  453. const tHeader = ['序号','药品名称', '规格型号','生产厂商','经销商', '单位','数量','单价','总价','备注']
  454. const filterVal = ['index','drug_name', 'unit','manufacturer_name','dealer_name', 'max_unit','warehousing_count','price','total_price','remark']
  455. let obj = {'index':'合计','total_price':0}
  456. for(let i=0;i<this.tabelePrintList.length;i++){
  457. obj.total_price += this.tabelePrintList[i].price * this.tabelePrintList[i].warehousing_count
  458. }
  459. for(let j=0;j<this.tabelePrintList.length;j++){
  460. this.tabelePrintList[j].total_price = this.tabelePrintList[j].total_price.toFixed(2)
  461. }
  462. obj.total_price = obj.total_price.toFixed(2)
  463. this.tabelePrintList.push(obj)
  464. const data = this.formatJson(filterVal, this.tabelePrintList)
  465. excel.export_json_to_excel({
  466. header: tHeader,
  467. data,
  468. filename: '药品入库明细'
  469. })
  470. this.downloadLoading = false
  471. })
  472. },
  473. formatJson(filterVal, jsonData) {
  474. return jsonData.map(v => filterVal.map(j => v[j]));
  475. },
  476. getManufacturerName(id){
  477. var manufacturer_name = ""
  478. for(let i=0;i<this.manufacturerList.length;i++){
  479. if(id == this.manufacturerList[i].id){
  480. manufacturer_name = this.manufacturerList[i].manufacturer_name
  481. }
  482. }
  483. return manufacturer_name
  484. },
  485. getDealerName(id){
  486. var dealer_name = ""
  487. for(let i=0;i<this.dealerList.length;i++){
  488. if(id == this.dealerList[i].id){
  489. dealer_name = this.dealerList[i].dealer_name
  490. }
  491. }
  492. return dealer_name
  493. },
  494. exportListDetail(){
  495. import('@/vendor/Export2Excel').then(excel => {
  496. const tHeader = ['序号','单据编号', '药品类型', '药品名称','规格型号','生产厂商','进销商','操作时间','制单人','进货价','数量','总价']
  497. const filterVal = ['index','warehousing_order','drugtype','drug_name', 'specification_name','manufacturer_name','dealer_name','time','user_name','price','warehousing_count','total']
  498. var newArr = []
  499. newArr = this.cancelStockDate
  500. console.log("newArrwowowowoow",newArr)
  501. let obj = {'index':'合计','total':0}
  502. for(let i=0;i<newArr.length;i++){
  503. newArr.specification_name = ""
  504. newArr.index = i+1
  505. newArr[i].drugtype = this.getTypeList(newArr[i].drug_type)
  506. newArr[i].specification_name = newArr[i].dose + newArr[i].dose_unit +"*" + newArr[i].min_number + newArr[i].min_unit + "/" + newArr[i].max_unit
  507. newArr[i].manufacturer_name = this.getManufacturerName(newArr[i].manufacturer)
  508. newArr[i].dealer_name = this.getDealerName(newArr[i].dealer)
  509. newArr[i].time = this.getTime(newArr[i].ctime)
  510. newArr[i].user_name = this.getAdminUser(newArr[i].creater)
  511. newArr[i].total = (newArr[i].price * newArr[i].warehousing_count).toFixed(2)
  512. obj.total += (newArr[i].price * newArr[i].warehousing_count)
  513. }
  514. obj.total = obj.total.toFixed(2)
  515. newArr.push(obj)
  516. const data = this.formatJson(filterVal, newArr)
  517. excel.export_json_to_excel({
  518. header: tHeader,
  519. data,
  520. filename: '药品入库明细'
  521. })
  522. this.downloadLoading = false
  523. })
  524. },
  525. getTypeList(id){
  526. var name = ""
  527. for(let i=0;i<this.drugTypeList.length;i++){
  528. if(id == this.drugTypeList[i].value){
  529. name = this.drugTypeList[i].name
  530. }
  531. }
  532. return name
  533. },
  534. getStorehouseName(id){
  535. var storehouse_name = ""
  536. for(let i=0;i<this.houseList.length;i++){
  537. if(id == this.houseList[i].id){
  538. storehouse_name = this.houseList[i].storehouse_name
  539. }
  540. }
  541. if(storehouse_name == "全部"){
  542. return ""
  543. }else{
  544. return storehouse_name
  545. }
  546. },
  547. changeHouseList(){
  548. this.houseList = []
  549. this.getlist()
  550. }
  551. }
  552. };
  553. </script>
  554. <style rel="stylesheet/css" lang="scss" scoped>
  555. .information {
  556. border: 1px #dcdfe6 solid;
  557. padding: 30px 20px 30px 20px;
  558. .border {
  559. border-bottom: 1px #dcdfe6 solid;
  560. margin: 0px 0 20px 0;
  561. }
  562. }
  563. .edit_separater {
  564. border-top: 1px solid rgb(233, 233, 233);
  565. margin-top: 15px;
  566. margin-bottom: 15px;
  567. }
  568. .eltable{
  569. display: flex;
  570. flex-direction: column;
  571. .el-table__header-wrapper {
  572. height: 70px !important;
  573. }
  574. }
  575. </style>
  576. <style>
  577. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  578. font-size: 12px;
  579. }
  580. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  581. background: #6fb5fa;
  582. }
  583. .count {
  584. color: #bd2c00;
  585. }
  586. .el-table td,
  587. .el-table th.is-leaf,
  588. .el-table--border,
  589. .el-table--group {
  590. border-color: #d0d3da;
  591. }
  592. .el-table--border::after,
  593. .el-table--group::after,
  594. .el-table::before {
  595. background-color: #d0d3da;
  596. }
  597. </style>