drugChange.vue 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <template>
  2. <div>
  3. <div class="position">
  4. <BreadCrumb :crumbs="crumbs"></BreadCrumb>
  5. </div>
  6. <div class="app-container">
  7. <div style="display: flex;justify-content: space-between;margin-bottom:10px;">
  8. <div class="cell clearfix">
  9. <span>入库时间:</span>
  10. <el-date-picker
  11. size="small"
  12. v-model="start_time"
  13. prefix-icon="el-icon-date"
  14. :editable="false"
  15. style="width: 196px;"
  16. type="date"
  17. placeholder="选择日期时间"
  18. align="right"
  19. format="yyyy-MM-dd"
  20. value-format="yyyy-MM-dd"
  21. ></el-date-picker>-
  22. <el-date-picker
  23. size="small"
  24. v-model="end_time"
  25. prefix-icon="el-icon-date"
  26. :editable="false"
  27. style="width: 196px;margin-right:10px;"
  28. type="date"
  29. placeholder="选择日期时间"
  30. align="right"
  31. format="yyyy-MM-dd"
  32. value-format="yyyy-MM-dd"
  33. ></el-date-picker>
  34. </div>
  35. <div>
  36. <span>销售状态:</span>
  37. <el-select size="small" v-model="is_sale" placeholder="请选择"
  38. style="width:100px;" @change="changeStock">
  39. <el-option
  40. label="不限"
  41. value="3">
  42. </el-option>
  43. <el-option
  44. v-for="item,index in items"
  45. :key="index"
  46. :label="item.name"
  47. :value="item.id">
  48. </el-option>
  49. </el-select>
  50. </div>
  51. <div>
  52. <el-button type="primary" @click="query()">查询</el-button>
  53. <el-button type="primary" @click="change_stock()">批量销售上传</el-button>
  54. <el-button type="primary" @click="exportdata()">导出</el-button>
  55. <!-- <el-button type="primary" @click="change()">变更</el-button>-->
  56. </div>
  57. </div>
  58. <el-table :data="tableData" border :row-style="{ color: '#303133' }" ref="table2"
  59. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
  60. max-height="600"
  61. @select="selectCostInfo"
  62. @selection-change="changeCostInfoTableData"
  63. @select-all="changeAllCostInfoTableData"
  64. highlight-current-row>
  65. <el-table-column
  66. align="center"
  67. type="selection"
  68. width="55"
  69. ></el-table-column>
  70. <el-table-column align="center" prop="name" label="药品名称">
  71. <template slot-scope="scope">{{scope.row.drug_name}}</template>
  72. </el-table-column>
  73. <el-table-column align="center" prop="name" label="规格单位">
  74. <template slot-scope="scope">{{scope.row.spec}}</template>
  75. </el-table-column>
  76. <el-table-column align="center" prop="name" label="追溯码">
  77. <template slot-scope="scope">
  78. <div @click="getDrugCode(scope.row.advice_id,scope.row.drug_code,scope.$index)"><el-input style="width: 100;" v-model="scope.row.drug_code"></el-input></div>
  79. </template>
  80. <!-- <template slot-scope="scope">{{scope.row.drug_code}}</template> -->
  81. </el-table-column>
  82. <el-table-column align="center" prop="name" label="患者姓名">
  83. <template slot-scope="scope">
  84. <!-- {{scope.row.p.name}} -->
  85. {{ getPatientName(scope.row.patient_id) }}
  86. </template>
  87. </el-table-column>
  88. <el-table-column align="center" prop="name" label="批号">
  89. <template slot-scope="scope">{{scope.row.batch_number}}</template>
  90. </el-table-column>
  91. <el-table-column align="center" prop="name" label="数量">
  92. <template slot-scope="scope">
  93. <div>{{scope.row.count}}{{scope.row.unit}}</div>
  94. </template>
  95. </el-table-column>
  96. <el-table-column align="center" prop="total" label="开方日期">
  97. <template slot-scope="scope">
  98. <div>{{scope.row.p_date}}</div>
  99. </template>
  100. </el-table-column>
  101. <el-table-column align="center" prop="total" label="销售状态">
  102. <template slot-scope="scope">
  103. <div>{{scope.row.is_sale?'已销售':'未销售'}}</div>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="操作" width="200">
  107. <template slot-scope="scope">
  108. <el-button v-if="!scope.row.is_sale || scope.row.is_sale == 0" type="primary" @click="sigle_stock(scope.row)">销售上传</el-button>
  109. <el-button v-if="scope.row.is_sale == 1" type="warning" @click="deleteStock(scope.row)">撤销</el-button>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <el-pagination
  114. @size-change="handleSizeChange"
  115. @current-change="handleCurrentChange"
  116. :page-size="5"
  117. :page-sizes="[10, 20, 50, 100,500,1000,2000]"
  118. background
  119. style="margin-top:20px;float: right"
  120. :total="value"
  121. ></el-pagination>
  122. <el-table v-show="false" :data="tableData" border :row-style="{ color: '#303133' }" ref="table"
  123. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
  124. max-height="600"
  125. @select="selectCostInfo"
  126. @selection-change="changeCostInfoTableData"
  127. @select-all="changeAllCostInfoTableData"
  128. highlight-current-row>
  129. <el-table-column
  130. align="center"
  131. type="selection"
  132. width="55"
  133. ></el-table-column>
  134. <el-table-column align="center" prop="name" label="药品名称">
  135. <template slot-scope="scope">{{scope.row.drug_name}}</template>
  136. </el-table-column>
  137. <el-table-column align="center" prop="name" label="药品类型">
  138. <template slot-scope="scope">{{scope.row.drug_type}}</template>
  139. </el-table-column>
  140. <el-table-column align="center" prop="name" label="规格单位">
  141. <template slot-scope="scope">{{scope.row.spec}}</template>
  142. </el-table-column>
  143. <el-table-column align="center" prop="name" label="国家编码">
  144. <template slot-scope="scope">{{scope.row.code}}</template>
  145. </el-table-column>
  146. <el-table-column align="center" prop="name" label="批号">
  147. <template slot-scope="scope">{{scope.row.batch_number}}</template>
  148. </el-table-column>
  149. <el-table-column align="center" prop="name" label="数量">
  150. <template slot-scope="scope">
  151. <div>{{scope.row.count}}{{scope.row.unit}}</div>
  152. </template>
  153. </el-table-column>
  154. <el-table-column align="center" prop="total" label="开方日期">
  155. <template slot-scope="scope">
  156. <div>{{scope.row.p_date}}</div>
  157. </template>
  158. </el-table-column>
  159. <el-table-column align="center" prop="total" label="结算日期">
  160. <template slot-scope="scope">
  161. <div>{{scope.row.e_date}}</div>
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. </div>
  166. <el-dialog
  167. title="药品追溯码"
  168. :visible.sync="dialogVisibleOne"
  169. width="40%">
  170. <span>
  171. <el-input
  172. @keyup.native="changeText"
  173. type="textarea"
  174. placeholder="请输入内容"
  175. v-model="textarea"
  176. :rows="10"
  177. >
  178. </el-input>
  179. </span>
  180. <span slot="footer" class="dialog-footer">
  181. <el-button @click="dialogVisibleOne = false">取 消</el-button>
  182. <el-button type="primary" @click="saveTextArea()">确 定</el-button>
  183. </span>
  184. </el-dialog>
  185. </div>
  186. <!-- </div> -->
  187. </template>
  188. <script>
  189. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  190. import { GetDrugChangeStock } from '../../api/new_stock/stock'
  191. import { getDictionaryDataConfig } from "@/utils/data";
  192. import { uParseTime } from '@/utils/tools'
  193. import { changeDrugCode } from "@/api/pharmacy";
  194. import axios from 'axios'
  195. const moment = require('moment')
  196. export default {
  197. components: {
  198. BreadCrumb
  199. },
  200. data() {
  201. return {
  202. drugTypeList: [{ id: 0, name: "全部" }],
  203. start_time: new Date(new Date().getFullYear(), new Date().getMonth(), 1).toLocaleDateString('en-CA'),
  204. end_time: new Date(new Date().getFullYear(), new Date().getMonth() + 3, 0).toLocaleDateString('en-CA'),
  205. tableData: [],
  206. change_type:"3",
  207. selection:[],
  208. page:1,
  209. limit:10,
  210. value:0,
  211. is_sale:"3",
  212. items: [
  213. { id: 1, name: '已销售' },
  214. { id: 2, name: '已销售退货' },
  215. ],
  216. changes: [
  217. { id: 1, name: '已变更' },
  218. { id: 2, name: '未变更' },
  219. ],
  220. textarea:'',
  221. dialogVisibleOne:false,
  222. currentRow:{},
  223. currentIndex:0,
  224. patientList:[],
  225. crumbs: [
  226. { path: false, name: '药品追溯' },
  227. { path: false, name: '药品销售' }
  228. ],
  229. }
  230. },
  231. methods: {
  232. changeText(event){
  233. // 检查是否为特定的按键,例如回车键,来确认扫码枪输入完成
  234. if (event.key === 'Enter') {
  235. var textarea = ""
  236. textarea += this.textarea + ","
  237. this.textarea = textarea
  238. }
  239. },
  240. getDrugCode(id,DrugCode,index){
  241. this.id = id
  242. this.textarea = DrugCode
  243. this.currentIndex = index
  244. this.dialogVisibleOne = true
  245. },
  246. saveTextArea(){
  247. var str = this.textarea.replace(/\s+/g, '')
  248. console.log("str000000000000000",str)
  249. // 1. 分割字符串并过滤空值
  250. const numbers = str.split(',').filter(item => item.trim() !== '');
  251. // 2. 统计每个数字出现的次数
  252. const countMap = numbers.reduce((acc, num) => {
  253. // 由于数字很大,用字符串作为键
  254. const key = num.trim();
  255. acc[key] = (acc[key] || 0) + 1;
  256. return acc;
  257. }, {});
  258. // 3. 转换为要求的格式数组
  259. const result = Object.entries(countMap).map(([name, count]) => ({
  260. name, // 保持字符串形式,因为数字太大可能丢失精度
  261. count
  262. }));
  263. console.log("result-----",result);
  264. var params = {
  265. id:this.id,
  266. data_source:1,
  267. drug_code:this.textarea,
  268. codeinfo:result
  269. }
  270. console.log("paramss",params)
  271. changeDrugCode(params).then(response=>{
  272. if(response.data.state == 1){
  273. this.$message.success("保存成功!")
  274. for(let i=0;i<this.tableData.length;i++){
  275. if(this.currentIndex == i){
  276. this.tableData[i].drug_code = this.textarea
  277. }
  278. }
  279. this.dialogVisibleOne = false
  280. }
  281. })
  282. },
  283. deleteStock(row){
  284. let ids = row.id
  285. var that = this;
  286. let params = {
  287. ids:ids,
  288. admin_user_id:this.$store.getters.xt_user.user.id
  289. };
  290. axios.get('http://127.0.0.1:9532/test/net',{}).then(function(response) {
  291. if (response.data.state == 0) {
  292. // that.$message.error(response.data.data.msg);
  293. that.$confirm("请检查医保程序是否有打开", "提示", {
  294. confirmButtonText: "确 定",
  295. cancelButtonText: "取 消",
  296. type: "warning",
  297. }).then(() => {
  298. axios.get('http://127.0.0.1:9532/api/delete_xs_bg',{params:params}).then(function(response) {
  299. if (response.data.state == 0) {
  300. that.$message.error(response.data.data.msg);
  301. return false
  302. } else {
  303. if(response.data.data.failed_code == -10){
  304. that.$confirm(response.data.data.msg, '医保错误信息', {
  305. confirmButtonText: '确 定',
  306. type: 'warning'
  307. }).then(() => {
  308. }).catch(() => {
  309. })
  310. }else{
  311. that.GetDrugStock()
  312. }
  313. }
  314. }).catch(function(error) {
  315. })
  316. })
  317. .catch(() => {});
  318. return false
  319. } else {
  320. }
  321. }).catch(function(error) {
  322. that.$confirm("请检查医保程序是否有打开", "提示", {
  323. confirmButtonText: "确 定",
  324. cancelButtonText: "取 消",
  325. type: "warning",
  326. }).then(() => {
  327. })
  328. .catch(() => {});
  329. })
  330. },
  331. sigle_stock(row){
  332. if(row.drug_code.length == 0){
  333. this.$message.error("追溯码不能为空");
  334. return
  335. }
  336. var that = this;
  337. let params = {
  338. ids:row.id,
  339. admin_user_id:this.$store.getters.xt_user.user.id
  340. };
  341. axios.get('http://127.0.0.1:9532/test/net',{}).then(function(response) {
  342. if (response.data.state == 0) {
  343. // that.$message.error(response.data.data.msg);
  344. that.$confirm("请检查医保程序是否有打开", "提示", {
  345. confirmButtonText: "确 定",
  346. cancelButtonText: "取 消",
  347. type: "warning",
  348. }).then(() => {
  349. })
  350. .catch(() => {});
  351. return false
  352. } else {
  353. axios.get('http://127.0.0.1:9532/api/changedrug',{params:params}).then(function(response) {
  354. if (response.data.state == 0) {
  355. that.$message.error(response.data.data.msg);
  356. return false
  357. } else {
  358. if(response.data.data.failed_code == -10){
  359. that.$confirm(response.data.data.msg, '医保错误信息', {
  360. confirmButtonText: '确 定',
  361. type: 'warning'
  362. }).then(() => {
  363. }).catch(() => {
  364. })
  365. }else{
  366. }
  367. }
  368. }).catch(function(error) {
  369. })
  370. }
  371. }).catch(function(error) {
  372. that.$confirm("请检查医保程序是否有打开", "提示", {
  373. confirmButtonText: "确 定",
  374. cancelButtonText: "取 消",
  375. type: "warning",
  376. }).then(() => {
  377. })
  378. .catch(() => {});
  379. })
  380. },
  381. handleSizeChange(val) {
  382. this.limit = val
  383. this.GetDrugStock()
  384. },
  385. handleCurrentChange(val) {
  386. this.page = val
  387. this.GetDrugStock()
  388. },
  389. selectCostInfo(selection, row) {
  390. this.selection = selection
  391. }, changeCostInfoTableData(val) {
  392. this.selection = val
  393. }, changeAllCostInfoTableData(selection) {
  394. this.selection = selection
  395. },
  396. delete(){
  397. },
  398. exportdata(){
  399. let list = []
  400. // for (let i = 0; i < this.tableData.length; i++) {
  401. // let order = this.tableData[i]
  402. // let name = order.name
  403. // let item_name = order.item_name
  404. // let count = order.count
  405. // let price = order.price.toFixed(2)
  406. // let pay_sumamt = (order.price.toFixed(2) * order.count).toFixed(2)
  407. // let total = order.total.toFixed(2)
  408. //
  409. // let obj = {
  410. // '患者姓名': name,
  411. // '项目名称': item_name,
  412. // '数量': count,
  413. // '单价': price,
  414. // '费用': pay_sumamt,
  415. // '费用总额': total
  416. // }
  417. // list.push(obj)
  418. // }
  419. import('@/vendor/Export2Excel').then(excel => {
  420. const tHeader = ['患者姓名', '项目名称', '数量', '单价', '费用', '费用总额']
  421. const filterVal = ['患者姓名', '项目名称', '数量', '单价', '费用', '费用总额']
  422. const data = this.formatJson(filterVal, list)
  423. excel.export_json_to_excel1({
  424. header: tHeader,
  425. data,
  426. filename: '明细',
  427. ref: this.$refs['table'].$el
  428. })
  429. })
  430. },formatJson(filterVal, jsonData) {
  431. return jsonData.map(v => filterVal.map(j => v[j]))
  432. },
  433. change_stock(){
  434. let ids = ""
  435. for (var i = 0; i < this.selection.length; i++){
  436. if (ids.length == 0){
  437. ids = this.selection[i].id
  438. }else{
  439. ids = ids + "," + this.selection[i].id
  440. }
  441. }
  442. if(ids.length == 0 ){
  443. this.$message.error("请勾选需要上传的数据");
  444. return
  445. }
  446. var that = this;
  447. let params = {
  448. ids:ids,
  449. admin_user_id:this.$store.getters.xt_user.user.id
  450. };
  451. axios.get('http://127.0.0.1:9532/test/net',{}).then(function(response) {
  452. if (response.data.state == 0) {
  453. // that.$message.error(response.data.data.msg);
  454. that.$confirm("请检查医保程序是否有打开", "提示", {
  455. confirmButtonText: "确 定",
  456. cancelButtonText: "取 消",
  457. type: "warning",
  458. }).then(() => {
  459. })
  460. .catch(() => {});
  461. return false
  462. } else {
  463. axios.get('http://127.0.0.1:9532/api/changedrug',{params:params}).then(function(response) {
  464. if (response.data.state == 0) {
  465. that.$message.error(response.data.data.msg);
  466. return false
  467. } else {
  468. if(response.data.data.failed_code == -10){
  469. that.$confirm(response.data.data.msg, '医保错误信息', {
  470. confirmButtonText: '确 定',
  471. type: 'warning'
  472. }).then(() => {
  473. }).catch(() => {
  474. })
  475. }else{
  476. }
  477. }
  478. }).catch(function(error) {
  479. })
  480. }
  481. }).catch(function(error) {
  482. that.$confirm("请检查医保程序是否有打开", "提示", {
  483. confirmButtonText: "确 定",
  484. cancelButtonText: "取 消",
  485. type: "warning",
  486. }).then(() => {
  487. })
  488. .catch(() => {});
  489. })
  490. },
  491. query(){
  492. this.GetDrugStock()
  493. },
  494. change(){
  495. },getDrugType(id) {
  496. var name = "";
  497. for (let i = 0; i < this.drugTypeList.length; i++) {
  498. if (this.drugTypeList[i].id == id) {
  499. name = this.drugTypeList[i].name;
  500. }
  501. }
  502. return name;
  503. }, getTime(val) {
  504. if(val == "" || val == undefined){
  505. return ""
  506. }else {
  507. return uParseTime(val, '{y}-{m}-{d}')
  508. }
  509. },GetDrugStock(){
  510. this.tableData = []
  511. let params = {
  512. start_time: this.start_time,
  513. end_time: this.end_time,
  514. page:this.page,
  515. limit:this.limit,
  516. is_sale:this.is_sale,
  517. is_bg:this.change_type
  518. }
  519. GetDrugChangeStock(params).then(response => {
  520. if (response.data.state == 0) {
  521. this.$message.error(response.data.msg)
  522. return false
  523. } else {
  524. this.value = response.data.data.total
  525. this.patientList = response.data.data.patientList
  526. for(let i =0; i < response.data.data.info.length; i++){
  527. let obj = {
  528. id:response.data.data.info[i].id,
  529. drug_name:response.data.data.info[i].BaseDrugLib.drug_name,
  530. drug_type:this.getDrugType(response.data.data.info[i].BaseDrugLib.drug_type),
  531. spec: response.data.data.info[i].BaseDrugLib.dose + response.data.data.info[i].BaseDrugLib.dose_unit + "*" + response.data.data.info[i].BaseDrugLib.min_number + response.data.data.info[i].BaseDrugLib.min_unit+"/" +response.data.data.info[i].BaseDrugLib.max_unit,
  532. code:response.data.data.info[i].BaseDrugLib.medical_insurance_number,
  533. batch_number:response.data.data.info[i].batch_number,
  534. count: response.data.data.info[i].PCount,
  535. p_date:this.getTime(response.data.data.info[i].PDate),
  536. e_date:(response.data.data.info[i].SDate),
  537. is_sale:response.data.data.info[i].is_sale,
  538. pc_date:response.data.data.info[i].pc_date,
  539. is_bg:response.data.data.info[i].is_change,
  540. unit:response.data.data.info[i].Unit,
  541. patient_id:response.data.data.info[i].patient_id,
  542. drug_code:response.data.data.info[i].his_advice_info.drug_code,
  543. advice_id:response.data.data.info[i].his_advice_info.id
  544. }
  545. this.tableData.push(obj)
  546. }
  547. }
  548. })
  549. },
  550. changeStock(){
  551. },
  552. getPatientName(id){
  553. console.log("id=-=--------------",id)
  554. console.log("patinetlist===========",this.patientList)
  555. var name = ""
  556. for(let i=0;i<this.patientList.length;i++){
  557. if(id == this.patientList[i].id){
  558. name = this.patientList[i].name
  559. }
  560. }
  561. return name
  562. }
  563. },
  564. created() {
  565. var drugTypeList = getDictionaryDataConfig("system", "drug_type");
  566. this.drugTypeList.push(...drugTypeList);
  567. this.GetDrugStock()
  568. }
  569. }
  570. </script>