drugInOrder.vue 17KB

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