drugCancelDetail.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <div>
  3. <el-button
  4. style="float: right"
  5. size="small"
  6. icon="el-icon-printer"
  7. @click="PrintAction"
  8. type="primary"
  9. >打印
  10. </el-button>
  11. <!-- <el-button
  12. style="float: right;margin-right:10px"
  13. size="small"
  14. @click="exportListOne"
  15. type="primary"
  16. >明细导出
  17. </el-button> -->
  18. <el-button
  19. style="float: right;margin-right:10px"
  20. size="small"
  21. @click="exportList"
  22. type="primary"
  23. >汇总导出
  24. </el-button>
  25. <div class="cell clearfix">
  26. <el-input
  27. size="small"
  28. style="width: 400px;"
  29. class="filter-item"
  30. v-model.trim="searchKey"
  31. placeholder="单据编码/制单人/规格名称"
  32. />
  33. <el-button
  34. size="small"
  35. class="filter-item"
  36. type="primary"
  37. icon="el-icon-search"
  38. @click="search"
  39. >搜索</el-button
  40. >
  41. <div style="margin-left:10px;">
  42. <label class="title"><span class="name">日期查询</span> : </label>
  43. <el-date-picker
  44. size="small"
  45. v-model="start_time"
  46. prefix-icon="el-icon-date"
  47. :editable="false"
  48. style="width: 150px;"
  49. type="date"
  50. placeholder="选择日期时间"
  51. align="right"
  52. format="yyyy-MM-dd"
  53. value-format="yyyy-MM-dd"
  54. @change="startTimeChange"
  55. ></el-date-picker>
  56. <span class="cellLine"> - </span>
  57. <el-date-picker
  58. size="small"
  59. v-model="end_time"
  60. prefix-icon="el-icon-date"
  61. :editable="false"
  62. style="width: 150px;"
  63. type="date"
  64. placeholder="选择日期时间"
  65. align="right"
  66. format="yyyy-MM-dd"
  67. value-format="yyyy-MM-dd"
  68. @change="endTimeChange"
  69. ></el-date-picker>
  70. </div>
  71. </div>
  72. <!-- <div class="cell clearfix">
  73. <label class="title"><span class="name">单据类型</span> : </label>
  74. <el-select
  75. size="small"
  76. v-model="order_type"
  77. clearable
  78. placeholder="单据类型"
  79. @change="changeType"
  80. >
  81. <el-option
  82. v-for="item in orderTypeArr"
  83. :key="item.value"
  84. :label="item.label"
  85. :value="item.value"
  86. >
  87. </el-option>
  88. </el-select>
  89. </div> -->
  90. <!--
  91. <div class="cell clearfix">
  92. <label class="title"><span class="name">其它</span> : </label>
  93. <el-select
  94. size="small"
  95. v-model="manufacturer_id"
  96. clearable
  97. placeholder="厂商"
  98. @change="changeManufacturer"
  99. >
  100. <el-option
  101. v-for="item in manufacturer"
  102. :key="item.id"
  103. :label="item.manufacturer_name"
  104. :value="item.id"
  105. >
  106. </el-option>
  107. </el-select>
  108. </div> -->
  109. <el-row :gutter="12" style="margin-top: 10px">
  110. <el-table
  111. :data="tableData"
  112. :class="signAndWeighBoxPatients"
  113. border
  114. highlight-current-row
  115. ref="multipleTable"
  116. @selection-change="select"
  117. :row-style="{ color: '#303133' }"
  118. :header-cell-style="{
  119. backgroundColor: 'rgb(245, 247, 250)',
  120. color: '#606266'
  121. }"
  122. >
  123. <el-table-column label="单据编号" align="center" width="200">
  124. <template slot-scope="scope">
  125. {{scope.row.order_number}}
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="药品类型" align="center">
  129. <template slot-scope="scope">
  130. <span v-if="scope.row.drug_type == 1">西药</span>
  131. <span v-if="scope.row.drug_type == 2">草药</span>
  132. <span v-if="scope.row.drug_type == 3">成药</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="药品名称" align="center">
  136. <template slot-scope="scope">
  137. <span>{{scope.row.drug_name}}</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="规格型号" align="center">
  141. <template slot-scope="scope">
  142. <span>{{scope.row.dose}}{{scope.row.dose_unit}}*{{scope.row.min_number}}{{scope.row.min_unit}}/{{scope.row.max_unit}}</span>
  143. </template>
  144. </el-table-column>
  145. <!-- <el-table-column label="单据类型" align="center">
  146. <template slot-scope="scope">
  147. <span v-if="scope.row.type == 1">药品退库单</span>
  148. <span v-if="scope.row.type == 2">其他</span>
  149. </template>
  150. </el-table-column> -->
  151. <el-table-column label="操作时间" align="center">
  152. <template slot-scope="scope">
  153. <span>{{getTime(scope.row.ctime)}}</span>
  154. </template>
  155. </el-table-column>
  156. <el-table-column label="制单人" align="center">
  157. <template slot-scope="scope">
  158. {{getAdminUser(scope.row.creater)}}
  159. </template>
  160. </el-table-column>
  161. <el-table-column label="退货价" align="center">
  162. <template slot-scope="scope">
  163. {{scope.row.price}}
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="数量" align="center">
  167. <template slot-scope="scope">
  168. {{scope.row.count}}
  169. </template>
  170. </el-table-column>
  171. <el-table-column label="总价" align="center">
  172. <template slot-scope="scope">
  173. {{scope.row.count * scope.row.price}}
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <el-pagination
  178. @size-change="handleSizeChange"
  179. @current-change="handleCurrentChange"
  180. :page-sizes="[10, 50, 100]"
  181. :page-size="10"
  182. background
  183. style="margin-top:20px;float: right"
  184. layout="total, sizes, prev, pager, next, jumper"
  185. :total="total"
  186. >
  187. </el-pagination>
  188. </el-row>
  189. </div>
  190. </template>
  191. <script>
  192. import { uParseTime } from "@/utils/tools";
  193. import { fetchAllAdminUsers} from "@/api/doctor";
  194. import { GetAllConfig} from "@/api/stock";
  195. import { getDrugCancelDetail } from "@/api/drug/drug_stock";
  196. export default {
  197. name: "cancelStockDetail",
  198. created() {
  199. var nowDate = new Date();
  200. var nowYear = nowDate.getFullYear();
  201. var nowMonth = nowDate.getMonth() + 1;
  202. var nowDay = nowDate.getDate();
  203. this.end_time =
  204. nowYear +
  205. "-" +
  206. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  207. "-" +
  208. (nowDay < 10 ? "0" + nowDay : nowDay);
  209. nowDate.setMonth(nowDate.getMonth() - 1);
  210. nowYear = nowDate.getFullYear();
  211. nowMonth = nowDate.getMonth() + 1;
  212. nowDay = nowDate.getDate();
  213. this.start_time =
  214. nowYear +
  215. "-" +
  216. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  217. "-" +
  218. (nowDay < 10 ? "0" + nowDay : nowDay);
  219. this.GetConfigInfo();
  220. this.fetchAllAdminUsers();
  221. this.getlist()
  222. },
  223. data() {
  224. return {
  225. orderTypeArr: [
  226. { value: 1, label: "药品退库单" },
  227. { value: 2, label: "其他入库单" }
  228. ],
  229. manufacturer_id: "",
  230. dealer_id: "",
  231. order_type: "",
  232. searchKey: "",
  233. type: 4,
  234. page: 1,
  235. limit: 10,
  236. checked: false,
  237. total: 0,
  238. pageTotal: 0,
  239. pageSelect: 0,
  240. adminUserOptions: [],
  241. multipleSelection: [],
  242. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  243. start_time: "",
  244. cancelStockDate: [],
  245. end_time: "",
  246. goodType: [],
  247. goodInfo: [],
  248. manufacturer: [],
  249. selectedTableData: [],
  250. dealer: [],
  251. tableData:[],
  252. tableList:[]
  253. };
  254. },
  255. methods: {
  256. PrintAction() {
  257. this.$router.push("/stock/drugcanceldetaiprint?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)
  258. },
  259. changeType: function(val) {
  260. this.order_type = val;
  261. this.getlist()
  262. },
  263. changeManufacturer: function(val) {
  264. this.manufacturer_id = val;
  265. this.getlist()
  266. },
  267. getTypeName: function(row) {
  268. let name = "";
  269. const name2 = "";
  270. if (row.type == 1) {
  271. name = "药品退库单";
  272. } else if (row.type == 2) {
  273. name = "其他退库单";
  274. }
  275. return name;
  276. },
  277. search() {
  278. this.getlist()
  279. },
  280. fetchAllAdminUsers() {
  281. fetchAllAdminUsers().then(response => {
  282. console.log(response);
  283. if (response.data.state == 1) {
  284. this.adminUserOptions = response.data.data.users;
  285. }
  286. });
  287. },
  288. handleSelectionChange: function(val) {
  289. this.multipleSelection = val;
  290. this.getlist()
  291. },
  292. handleSizeChange(val) {
  293. this.limit = val;
  294. this.getlist()
  295. },
  296. handleCurrentChange(val) {
  297. this.page = val;
  298. this.getlist()
  299. },
  300. startTimeChange(val) {
  301. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  302. if (time > 0) {
  303. this.$message.error("结束时间不能小于开始时间");
  304. this.start_time = "";
  305. } else {
  306. this.getlist()
  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. }
  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: function() {
  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. select(selection) {
  339. },
  340. getlist(){
  341. var params = {
  342. start_time:this.start_time,
  343. end_time:this.end_time,
  344. order_type:this.order_type,
  345. manufacturer_id:this.manufacturer_id,
  346. keyword:this.searchKey,
  347. limit:this.limit,
  348. page:this.page,
  349. }
  350. getDrugCancelDetail(params).then(response=>{
  351. if(response.data.state == 1){
  352. var order = response.data.data.order
  353. // console.log("退库详细222222222222222222",order)
  354. this.tableData = order
  355. this.tableList = order
  356. var total = response.data.data.total
  357. this.total = total
  358. }
  359. })
  360. },
  361. getAdminUser(id){
  362. var name = ""
  363. for(let i=0;i<this.adminUserOptions.length;i++){
  364. if(id == this.adminUserOptions[i].id){
  365. name = this.adminUserOptions[i].name
  366. }
  367. }
  368. return name
  369. },
  370. getTime: function(val) {
  371. if (val == 0) {
  372. return "";
  373. } else {
  374. return uParseTime(val, "{y}-{m}-{d}");
  375. }
  376. },
  377. exportList(){
  378. for(let i=0;i<this.tableList.length;i++){
  379. this.tableList[i].index = i+1
  380. this.tableList[i].unit = this.tableList[i].dose + this.tableList[i].dose_unit + "*"+this.tableList[i].min_number + this.tableList[i].min_unit+"/"+this.tableList[i].max_unit
  381. }
  382. import('@/vendor/Export2Excel').then(excel => {
  383. const tHeader = ['序号','单据编号', '药品名称', '规格型号','单据类型','操作时间','制单人','数量']
  384. const filterVal = ['index','drug_name', 'unit', 'min_unit','count','price','remark']
  385. const data = this.formatJson(filterVal, this.tableList)
  386. console.log("data",data)
  387. excel.export_json_to_excel({
  388. header: tHeader,
  389. data,
  390. filename: '药品退库明细'
  391. })
  392. this.downloadLoading = false
  393. })
  394. },
  395. formatJson(filterVal, jsonData) {
  396. return jsonData.map(v => filterVal.map(j => v[j]));
  397. },
  398. exportListOne(){
  399. let obj = {'index':'合计','total_price':0}
  400. for(let i=0;i<this.tableList.length;i++){
  401. this.tableList[i].index = i+1
  402. this.tableList[i].unit = this.tableList[i].dose + this.tableList[i].dose_unit + "*"+this.tableList[i].min_number + this.tableList[i].min_unit+"/"+this.tableList[i].max_unit
  403. if(this.tableData[i].drug_type == 1){
  404. this.tableData[i].drugtype = "西药"
  405. }
  406. if(this.tableData[i].drug_type == 2){
  407. this.tableData[i].drugtype = "草药"
  408. }
  409. if(this.tableData[i].drug_type == 3){
  410. this.tableData[i].drugtype = "成药"
  411. }
  412. this.tableData[i].time = this.getTime(this.tableData[i].ctime)
  413. this.tableData[i].user_name = this.getAdminUser(this.tableData[i].creater)
  414. this.tableData[i].total_price = this.tableData[i].count * this.tableData[i].price
  415. obj.total_price += this.tabelePrintList[i].count * this.tabelePrintList[i].price
  416. }
  417. obj.total_price = obj.total_price.toFixed(2)
  418. this.tableData.push(obj)
  419. for(let i=0;i<this.tableData.length;i++){
  420. this.tableData[i].total_price = this.tableData[i].total_price.toFixed(2)
  421. }
  422. import('@/vendor/Export2Excel').then(excel => {
  423. const tHeader = ['序号','单据编号', '药品类型','药品名称', '规格型号','操作时间','制单人','退货价','数量','总价']
  424. const filterVal = ['index','order_number','drugtype','drug_name', 'unit', 'time','user_name','price','count','total_price']
  425. const data = this.formatJson(filterVal, this.tableList)
  426. console.log("data",data)
  427. excel.export_json_to_excel({
  428. header: tHeader,
  429. data,
  430. filename: '药品退库明细'
  431. })
  432. this.downloadLoading = false
  433. })
  434. },
  435. }
  436. };
  437. </script>
  438. <style rel="stylesheet/css" lang="scss" scoped>
  439. .information {
  440. border: 1px #dcdfe6 solid;
  441. padding: 30px 20px 30px 20px;
  442. .border {
  443. border-bottom: 1px #dcdfe6 solid;
  444. margin: 0px 0 20px 0;
  445. }
  446. }
  447. .edit_separater {
  448. border-top: 1px solid rgb(233, 233, 233);
  449. margin-top: 15px;
  450. margin-bottom: 15px;
  451. }
  452. </style>
  453. <style>
  454. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  455. font-size: 12px;
  456. }
  457. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  458. background: #6fb5fa;
  459. }
  460. .count {
  461. color: #bd2c00;
  462. }
  463. .el-table td,
  464. .el-table th.is-leaf,
  465. .el-table--border,
  466. .el-table--group {
  467. border-color: #d0d3da;
  468. }
  469. .el-table--border::after,
  470. .el-table--group::after,
  471. .el-table::before {
  472. background-color: #d0d3da;
  473. }
  474. </style>