drugInOrder.vue 20KB

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