drugCode.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <div>
  3. <div style="display: flex;justify-content: space-between;margin-bottom:10px;">
  4. <div class="cell clearfix">
  5. <span>发药时间:</span>
  6. <el-date-picker
  7. size="small"
  8. v-model="start_time"
  9. prefix-icon="el-icon-date"
  10. :editable="false"
  11. style="width: 196px;"
  12. type="date"
  13. placeholder="选择日期时间"
  14. align="right"
  15. format="yyyy-MM-dd"
  16. value-format="yyyy-MM-dd"
  17. @change="changeStartTime"
  18. ></el-date-picker>-
  19. <el-date-picker
  20. @change="changeEndTime"
  21. size="small"
  22. v-model="end_time"
  23. prefix-icon="el-icon-date"
  24. :editable="false"
  25. style="width: 196px;margin-right:10px;"
  26. type="date"
  27. placeholder="选择日期时间"
  28. align="right"
  29. format="yyyy-MM-dd"
  30. value-format="yyyy-MM-dd"
  31. ></el-date-picker>
  32. </div>
  33. <div>
  34. <div>上传状态:
  35. <el-select size="small" v-model="is_sale" placeholder="请选择" style="width:100px;" @change="changeStock">
  36. <el-option
  37. v-for="item,index in items"
  38. :key="index"
  39. :label="item.name"
  40. :value="item.id">
  41. </el-option>
  42. </el-select>
  43. </div>
  44. </div>
  45. <div>
  46. <el-button type="primary" @click="query()">查询</el-button>
  47. <el-button type="primary" @click="exportdata()">导出</el-button>
  48. </div>
  49. </div>
  50. <el-table :data="tableData" border :row-style="{ color: '#303133' }" ref="table2"
  51. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
  52. max-height="800"
  53. @select="selectCostInfo"
  54. @selection-change="changeCostInfoTableData"
  55. @select-all="changeAllCostInfoTableData"
  56. highlight-current-row>
  57. <el-table-column align="center" prop="name" label="患者姓名">
  58. <template slot-scope="scope">{{getPatientName(scope.row.patient_id) }}</template>
  59. </el-table-column>
  60. <el-table-column align="center" prop="name" label="处方日期">
  61. <template slot-scope="scope">{{getTime(scope.row.advice_date)}}</template>
  62. </el-table-column>
  63. <el-table-column align="center" prop="name" label="药品名称">
  64. <template slot-scope="scope">{{ scope.row.advice_name }}</template>
  65. </el-table-column>
  66. <el-table-column align="center" prop="name" label="规格">
  67. <template slot-scope="scope">{{getDrugSpec(scope.row.drug_id)}}</template>
  68. </el-table-column>
  69. <el-table-column align="center" prop="name" label="开药总量">
  70. <template slot-scope="scope">{{scope.row.prescribing_number}}{{ scope.row.prescribing_number_unit }}</template>
  71. </el-table-column>
  72. <el-table-column align="center" prop="name" label="药品追溯码">
  73. <template slot-scope="scope">
  74. <div @click="getDrugCode(scope.row.id,scope.row.DataSources,scope.row.drug_code,scope.$index)"><el-input style="width: 100;" v-model="scope.row.drug_code"></el-input></div>
  75. </template>
  76. </el-table-column>
  77. <el-table-column align="center" prop="name" label="上传状态">
  78. <template slot-scope="scope">
  79. <div v-if="scope.row.is_upload == 1">已上传</div>
  80. <div v-if="scope.row.is_upload == 2 || scope.row.is_upload == 0">未上传</div>
  81. </template>
  82. </el-table-column>
  83. <el-table-column align="center" prop="name" label="发药状态">
  84. <template slot-scope="scope">
  85. <div v-if="scope.row.is_medicine == 1">已发药</div>
  86. <div v-if="scope.row.is_medicine == 2 || scope.row.is_medicine == 0">未发药</div>
  87. </template>
  88. </el-table-column>
  89. <el-table-column align="center" prop="name" label="操作" width="200">
  90. <template slot-scope="scope">
  91. <div>
  92. <el-button v-if="scope.row.is_upload == 1" type="primary" @click="sigle_stock(scope.row)">未上传</el-button>
  93. <el-button type="primary" v-if="scope.row.is_upload == 0 || scope.row.is_upload == 2" @click="toUpload(scope.row)">上传</el-button>
  94. <el-button v-if="faShow == true" type="primary" @click="toFaYao(scope.row)">发药</el-button>
  95. </div>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <el-pagination
  100. @size-change="handleSizeChange"
  101. @current-change="handleCurrentChange"
  102. :page-size="10"
  103. :page-sizes="[10, 20, 50, 100,500,1000,2000]"
  104. background
  105. style="margin-top:20px;float: right"
  106. :total="total"
  107. ></el-pagination>
  108. <el-dialog
  109. title="药品追溯码"
  110. :visible.sync="dialogVisibleOne"
  111. width="40%">
  112. <span>
  113. <el-input
  114. @keyup.native="changeText"
  115. type="textarea"
  116. placeholder="请输入内容"
  117. v-model="textarea"
  118. :rows="10"
  119. >
  120. </el-input>
  121. </span>
  122. <span slot="footer" class="dialog-footer">
  123. <el-button @click="dialogVisibleOne = false">取 消</el-button>
  124. <el-button type="primary" @click="saveTextArea()">确 定</el-button>
  125. </span>
  126. </el-dialog>
  127. </div>
  128. </template>
  129. <script>
  130. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  131. import { getHisDrugCodeQueryList,createUploadDrugCode,getPatientDrugCode } from '../../api/new_stock/stock'
  132. import { getDictionaryDataConfig } from "@/utils/data";
  133. import { uParseTime } from '@/utils/tools'
  134. import { changeDrugCode } from "@/api/pharmacy";
  135. import axios from 'axios'
  136. const moment = require('moment')
  137. export default {
  138. components: {
  139. BreadCrumb
  140. },
  141. data() {
  142. return {
  143. drugTypeList: [{ id: 0, name: "全部" }],
  144. start_time: new Date(new Date().getFullYear(), new Date().getMonth(), 1).toLocaleDateString('en-CA'),
  145. end_time: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0).toLocaleDateString('en-CA'),
  146. tableData: [],
  147. change_type:"3",
  148. selection:[],
  149. page:1,
  150. limit:10,
  151. value:0,
  152. is_sale:"0",
  153. items: [
  154. { id: "0", name: '全部' },
  155. { id: "1", name: '已上传' },
  156. { id: "2", name: '未上传' },
  157. ],
  158. patientList:[],
  159. drugList:[],
  160. dialogVisibleOne:false,
  161. id:0,
  162. is_source:0,
  163. drug_code:0,
  164. currentRow:{},
  165. currentIndex:0,
  166. is_drug_open:"2",
  167. textarea:'',
  168. total:0,
  169. faShow:false,
  170. is_open:false,
  171. }
  172. },
  173. methods: {
  174. changeText(event){
  175. // 检查是否为特定的按键,例如回车键,来确认扫码枪输入完成
  176. if (event.key === 'Enter') {
  177. var textarea = ""
  178. textarea += this.textarea + ","
  179. this.textarea = textarea
  180. }
  181. },
  182. getDrugCode(id,DataSources,DrugCode,index){
  183. this.id = id
  184. this.textarea = DrugCode
  185. this.currentIndex = index
  186. this.dialogVisibleOne = true
  187. },
  188. saveTextArea(){
  189. var params = {
  190. id:this.id,
  191. data_source:1,
  192. drug_code:this.textarea,
  193. }
  194. console.log("paramss",params)
  195. changeDrugCode(params).then(response=>{
  196. if(response.data.state == 1){
  197. this.$message.success("保存成功!")
  198. for(let i=0;i<this.tableData.length;i++){
  199. if(this.currentIndex == i){
  200. this.tableData[i].drug_code = this.textarea
  201. }
  202. }
  203. this.dialogVisibleOne = false
  204. }
  205. })
  206. },
  207. getPatientName(id){
  208. var name = ""
  209. for(let i=0;i<this.patientList.length;i++){
  210. if(id == this.patientList[i].id){
  211. name = this.patientList[i].name
  212. }
  213. }
  214. return name
  215. },
  216. getTime(val) {
  217. if(val < 0){
  218. return ""
  219. }
  220. if(val == ""){
  221. return ""
  222. }else {
  223. return uParseTime(val, '{y}-{m}-{d}')
  224. }
  225. },
  226. getDrugName(drug_id){
  227. var drug_name = ""
  228. for(let i=0;i<this.drugList.length;i++){
  229. if(drug_id == this.drugList[i].id){
  230. drug_name = this.drugList[i].drug_name
  231. }
  232. }
  233. return drug_name
  234. },
  235. getDrugSpec(drug_id){
  236. var specification_name = ""
  237. for(let i=0;i<this.drugList.length;i++){
  238. if(drug_id == this.drugList[i].id){
  239. specification_name = this.drugList[i].specification_name
  240. }
  241. }
  242. return specification_name
  243. },
  244. handleSizeChange(val) {
  245. this.limit = val
  246. this.getlist()
  247. },
  248. handleCurrentChange(val) {
  249. this.page = val
  250. this.getlist()
  251. },
  252. selectCostInfo(selection, row) {
  253. this.selection = selection
  254. },
  255. changeCostInfoTableData(val) {
  256. this.selection = val
  257. }, changeAllCostInfoTableData(selection) {
  258. this.selection = selection
  259. },
  260. delete(){
  261. },
  262. exportdata(){
  263. console.log("hahahahh",this.tableData)
  264. if(this.tableData!=null && this.tableData.length>0){
  265. for(let i=0;i<this.tableData.length;i++){
  266. this.tableData[i].patient_name = this.getPatientName(this.tableData[i].patient_id)
  267. this.tableData[i].advice_date_str = this.getTime(this.tableData[i].advice_date)
  268. if(this.tableData[i].is_upload == 1){
  269. this.tableData[i].is_upload_name = "已上传"
  270. }
  271. if(this.tableData[i].is_upload == 2 || this.tableData[i].is_upload == 0){
  272. this.tableData[i].is_upload_name = "未上传"
  273. }
  274. if(this.tableData[i].is_medicine == 1){
  275. this.tableData[i].is_medicine_name = "已发药"
  276. }
  277. if(this.tableData[i].is_medicine == 2 || this.tableData[i].is_medicine == 0){
  278. this.tableData[i].is_medicine_name = "未发药"
  279. }
  280. this.tableData[i].specification_name = this.getDrugSpec(this.tableData[i].drug_id)
  281. }
  282. }
  283. import('@/vendor/Export2Excel').then(excel => {
  284. const tHeader = ['患者姓名', '处方日期', '药品名称', '规格', '开药总量', '药品追溯码','上传状态','发药状态']
  285. const filterVal = ['patient_name', 'advice_date_str', 'advice_name', 'specification_name', 'prescribing_numbers', 'drug_code','is_upload_name','is_medicine_name']
  286. const data = this.formatJson(filterVal, this.tableData)
  287. excel.export_json_to_excel({
  288. header: tHeader,
  289. data,
  290. filename: '药品追溯'
  291. })
  292. })
  293. },formatJson(filterVal, jsonData) {
  294. return jsonData.map(v => filterVal.map(j => v[j]))
  295. },
  296. query(){
  297. this.getlist()
  298. },
  299. getDrugType(id) {
  300. var name = "";
  301. for (let i = 0; i < this.drugTypeList.length; i++) {
  302. if (this.drugTypeList[i].id == id) {
  303. name = this.drugTypeList[i].name;
  304. }
  305. }
  306. return name;
  307. },
  308. getTime(val) {
  309. if(val == "" || val == undefined){
  310. return ""
  311. }else {
  312. return uParseTime(val, '{y}-{m}-{d}')
  313. }
  314. },
  315. getlist(){
  316. this.tableData = []
  317. let params = {
  318. start_time: this.start_time,
  319. end_time: this.end_time,
  320. page:this.page,
  321. limit:this.limit,
  322. is_sale:this.is_sale,
  323. }
  324. getHisDrugCodeQueryList(params).then(response => {
  325. if (response.data.state == 0) {
  326. this.$message.error(response.data.msg)
  327. return false
  328. } else {
  329. this.tableData = response.data.data.list
  330. this.total = response.data.data.total
  331. this.drugList = response.data.data.drug
  332. this.patientList = response.data.data.patients
  333. this.is_open = response.data.data.codeConfig.is_open
  334. }
  335. })
  336. },
  337. changeStock(val){
  338. this.is_sale = val
  339. this.getlist()
  340. },
  341. changeStartTime(val){
  342. this.start_time = val
  343. },
  344. changeEndTime(val){
  345. this.end_time = val
  346. },
  347. toUpload(row){
  348. if(row.is_medicine == 0 || row.is_is_medicine == 2){
  349. this.$message.error("该药品未发药,请先发药")
  350. this.faShow = true
  351. return
  352. }
  353. var params = {
  354. drug_id:row.drug_id,
  355. patient_id:row.patient_id,
  356. advice_date:row.advice_date,
  357. }
  358. createUploadDrugCode(params).then(response=>{
  359. if(response.data.state == 1){
  360. this.$message.success("上传成功!")
  361. }
  362. })
  363. },
  364. toFaYao(row){
  365. if(this.is_open == 1){
  366. if(row.drug_code==''){
  367. this.$message.error("药品追溯码不能为空!")
  368. return
  369. }
  370. }
  371. var params= {
  372. drug_id:row.drug_id,
  373. patient_id:row.patient_id,
  374. advice_date:row.advice_date,
  375. }
  376. getPatientDrugCode(params).then(response=>{
  377. if(response.data.state == 1){
  378. this.$message.success("发药成功!")
  379. this.getlist()
  380. }
  381. })
  382. }
  383. },
  384. created() {
  385. var drugTypeList = getDictionaryDataConfig("system", "drug_type");
  386. this.drugTypeList.push(...drugTypeList);
  387. this.getlist()
  388. }
  389. }
  390. </script>