YpMzCodgMatch.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <div class="layout_container">
  3. <header>
  4. <el-input v-model="codgTotal" class="w-50 m-2" style="width: 200px" disabled>
  5. <template #prepend><span style="color: #d71345;font-weight: bolder">处方发药总数量</span></template>
  6. </el-input>
  7. <el-input v-model="quantityJc" class="w-50 m-2" style="width: 200px" disabled>
  8. <template #prepend><span style="color: #d71345;font-weight: bolder">追溯码检查数量</span></template>
  9. </el-input>
  10. <el-divider direction="vertical" />
  11. <el-button type="primary" icon="Search" @click="checkBarList" style="margin-left: 5px">检查</el-button>
  12. <el-button type="danger" icon="Remove" @click="drugBarRepeat" style="margin-left: 5px">去重</el-button>
  13. <el-button type="warning" icon="Filter" @click="matchCodgData" style="margin-left: 5px">匹配</el-button>
  14. <el-button type="success" icon="Select" @click="saveMatchCodgData" style="margin-left: 5px" v-if="confirmFlag !== 1">保存</el-button>
  15. <el-button type="success" icon="Select" @click="saveMatchCodgData" style="margin-left: 5px" v-if="chargeFlag === 1">变更</el-button>
  16. <el-button type="danger" v-show="setlText" disabled :icon="Star"><span style="font-size: 14px">医保病人</span></el-button>
  17. </header>
  18. <div class="layout_display_flex_y">
  19. <div class="layout_flex_1-y">
  20. <el-table :data="mzCfDetail" border stripe highlight-current-row height="100%">
  21. <el-table-column type="index" label="序号" width="50" />
  22. <el-table-column prop="location" label="货柜号" width="80" />
  23. <el-table-column prop="patientId" label="门诊号" width="90" />
  24. <el-table-column prop="times" label="就诊次数" width="70" />
  25. <el-table-column prop="chargeCode" label="药品编码" width="80" />
  26. <el-table-column prop="chargeName" label="品名" width="240" />
  27. <el-table-column prop="specification" label="规格" width="200" />
  28. <el-table-column prop="retprice" label="价格" width="80"/>
  29. <el-table-column prop="quantity" label="数量" width="80">
  30. <template #default="scope">
  31. <el-button type="primary" size="small">{{ scope.row.quantity }}</el-button>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="factory" label="生产厂家" width="240"/>
  35. <el-table-column prop="chargeDate" label="收费时间" width="140" />
  36. <el-table-column prop="deptName" label="科室" width="120" />
  37. </el-table>
  38. </div>
  39. <div style="margin-top: 4px">
  40. <el-row :gutter="5">
  41. <el-col :span="3">
  42. <el-divider content-position="left">追溯码采集信息</el-divider>
  43. <el-input v-model="codgLine" type="textarea" :rows="36"/>
  44. </el-col>
  45. <el-col :span="3">
  46. <el-divider content-position="left">追溯码检查信息</el-divider>
  47. <el-input v-model="drugTracCodgAt" type="textarea" :rows="36"/>
  48. </el-col>
  49. <el-col :span="18">
  50. <el-divider content-position="left">追溯码匹配信息</el-divider>
  51. <div class="layout_display_flex_y">
  52. <div class="layout_flex_1-y">
  53. <el-table :data="codgInfo" border stripe highlight-current-row>
  54. <el-table-column type="index" label="序号" width="40" fixed/>
  55. <el-table-column prop="matchFlag" label="匹配结果" width="105" fixed>
  56. <template #default="scope">
  57. <el-button v-if="scope.row.matchFlag === '0' " type="success" size="small">下载匹配成功</el-button>
  58. <el-button v-else-if="scope.row.matchFlag === '1' " type="success" size="small">平台匹配成功</el-button>
  59. <el-button v-else-if="scope.row.matchFlag === '-1' " type="danger" size="small">匹配失败</el-button>
  60. <el-button v-else type="primary" size="small">其他</el-button>
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="matchMessage" label="匹配信息" width="180" fixed show-overflow-tooltip/>
  64. <el-table-column prop="drugTracCodg" label="追溯码" width="150" fixed />
  65. <el-table-column prop="drugName" label="品名" width="240" fixed/>
  66. <el-table-column prop="specification" label="规格" width="160" />
  67. <el-table-column prop="manuNo" label="生产批号" width="140"/>
  68. <el-table-column prop="manuDate" label="生产日期" width="140"/>
  69. <el-table-column prop="expyEnd" label="有效期止" width="140"/>
  70. <el-table-column prop="abbrName" label="生产厂家" width="240"/>
  71. </el-table>
  72. </div>
  73. </div>
  74. </el-col>
  75. </el-row>
  76. </div>
  77. </div>
  78. </div>
  79. </template>
  80. <script setup name="YpMzCodgMatch">
  81. import {nextTick, onMounted, ref, watch} from "vue";
  82. import {
  83. selectMatchCodgInfo,
  84. selectMzCfDetail,
  85. selectMzDrugTracCodgData,
  86. updateMzDrugCodgData,
  87. updateMzDrugCodgDataNew
  88. } from "@/api/yp-codg/yp-codg-match.js";
  89. import {isEmpty} from "xe-utils";
  90. import {ElMessage, ElMessageBox} from "element-plus";
  91. import {Star} from "@element-plus/icons-vue";
  92. const mzCfData = ref([])
  93. const mzCfDetail = ref([])
  94. const setlText = ref(false)
  95. const codgLine = ref('')
  96. const codgTotal = ref(0)
  97. // 处方匹配的追溯码信息
  98. const codgInfo = ref([])
  99. const confirmFlag = ref(0)
  100. // 已经发药了,变更追溯码信息
  101. const chargeFlag = ref(0)
  102. const emit = defineEmits(['close', 'closeYpMzCodgMatch'])
  103. const props = defineProps({
  104. ypMzCfData: {
  105. type: Object,
  106. default: {}
  107. }
  108. })
  109. onMounted( () => {
  110. nextTick(() => {
  111. mzCfData.value = props.ypMzCfData
  112. confirmFlag.value = props.ypMzCfData.confirmFlag
  113. chargeFlag.value = props.ypMzCfData.flag
  114. setlText.value = props.ypMzCfData.setlId
  115. queryMzCfDetail()
  116. queryMzDrugCodgMatch()
  117. })
  118. })
  119. watch(() => props.ypMzCfData, () => {
  120. mzCfData.value = props.ypMzCfData
  121. confirmFlag.value = props.ypMzCfData.confirmFlag
  122. chargeFlag.value = props.ypMzCfData.flag
  123. setlText.value = props.ypMzCfData.setlId
  124. })
  125. const queryMzCfDetail = () => {
  126. selectMzCfDetail(mzCfData.value).then(res => {
  127. let u = 0
  128. res.forEach((item) => {
  129. u = u + item.quantity
  130. });
  131. codgTotal.value = u
  132. mzCfDetail.value = res
  133. })
  134. }
  135. const queryMzDrugCodgMatch = () => {
  136. selectMzDrugTracCodgData(mzCfData.value).then(res => {
  137. if(res.data){
  138. codgInfo.value = res.data
  139. }
  140. })
  141. }
  142. // 去重
  143. const drugBarRepeat = () => {
  144. let barStr = codgLine.value
  145. if(!isEmpty(barStr)) {
  146. let barInfo = barStr.replaceAll('\n', ',').split(',')
  147. if (barInfo.length > 0) {
  148. let barData = new Set(barInfo)
  149. let barList = [...barData]
  150. let data = ''
  151. for(let i in barList){
  152. if(!isEmpty(barList[i])) {
  153. data += (barList[i] + '\n')
  154. }
  155. }
  156. codgLine.value = data
  157. }
  158. }
  159. // 去重后在进行一起检查
  160. checkBarList()
  161. }
  162. // 追溯码扫码计数统计
  163. let barFor = false
  164. let barC = 0
  165. // 检查后数量
  166. const quantityJc = ref(0)
  167. // 检验信息
  168. const drugTracCodgAt = ref('')
  169. // 追溯码检查
  170. const checkBarList = () => {
  171. barFor = false
  172. barC = 0
  173. quantityJc.value = 0
  174. drugTracCodgAt.value = ''
  175. let sum = 0;
  176. let str = codgLine.value;
  177. let infoErr = '错误:\n';
  178. let infoRep = '重复:\n';
  179. if(!isEmpty(str)){
  180. let barInfo = str.replaceAll('\n', ',').split(',')
  181. if(barInfo.length > 0) {
  182. for(let i in barInfo){
  183. if(barInfo[i].length === 20 || barInfo[i].length === 55){
  184. sum++;
  185. } else {
  186. if(barInfo[i] > 0 && barInfo[i].length !== 20 && barInfo[i].length !== 55){
  187. sum++;
  188. barFor = true
  189. infoErr += barInfo[i] + '\n';
  190. }
  191. }
  192. }
  193. let barInfoCp = [...barInfo]
  194. let repStr = ''
  195. for(let i in barInfo){
  196. let rep = 1;
  197. // 不能用index的序号去比,因为它已经比过了
  198. let index = 0;
  199. if(!(isEmpty(repStr) || repStr.indexOf(barInfo[i]) === -1)){
  200. continue
  201. }
  202. for(let j in barInfoCp){
  203. if(j > i && barInfo[i] === barInfoCp[j]){
  204. rep++;
  205. barFor = true
  206. if(isEmpty(repStr)){
  207. repStr = barInfo[i]
  208. } else if(repStr.indexOf(barInfo[i]) === -1){
  209. repStr += ',' + barInfo[i]
  210. }
  211. index = j
  212. }
  213. }
  214. if(rep > 1){
  215. infoRep = infoRep + barInfo[i] + '重复出现:' + rep + '次。 \n'
  216. rep = 1
  217. }
  218. }
  219. }
  220. }
  221. let info = infoErr + '\n' + infoRep
  222. quantityJc.value = sum
  223. drugTracCodgAt.value = info
  224. }
  225. // 追溯码匹配
  226. const matchCodgData = () => {
  227. if(barFor){
  228. ElMessage({
  229. type: "warning",
  230. message: "当前扫码有重复或者错误追溯码信息,请检查!",
  231. duration: 2500,
  232. showClose: true,
  233. });
  234. return false
  235. }
  236. // 匹配追溯码并返回结果
  237. mzCfData.value.codeLine = codgLine.value
  238. selectMatchCodgInfo(mzCfData.value).then(res => {
  239. if(res.data){
  240. codgInfo.value = res.data
  241. }
  242. })
  243. }
  244. // 保存匹配结果
  245. const saveMatchCodgData = () => {
  246. if(!codgInfo.value){
  247. ElMessage({
  248. type: "warning",
  249. message: '没有匹配信息,请检查!',
  250. duration: 2500,
  251. showClose: true,
  252. });
  253. return false
  254. }
  255. let unMatchCodgInfo = codgInfo.value.filter(codg => {
  256. return codg.flag === '-1'
  257. })
  258. if(unMatchCodgInfo.length > 0){
  259. ElMessage({
  260. type: "warning",
  261. message: '追溯码匹配信息中存在匹配失败数据,请检查!',
  262. duration: 2500,
  263. showClose: true,
  264. });
  265. return false
  266. }
  267. if(codgInfo.value.length > codgTotal.value){
  268. ElMessage({
  269. type: "warning",
  270. message: '追溯码匹配数量不允许超过处方发药总数量,请检查!',
  271. duration: 2500,
  272. showClose: true,
  273. });
  274. return false
  275. }
  276. let tips = "确定保存药品匹配信息?"
  277. if(chargeFlag.value === 1){
  278. tips = "确定变更药品匹配信息?【友情提示:已经上传医保的追溯码,请取消上传再变更追溯码信息!】"
  279. }
  280. ElMessageBox.confirm(tips, {
  281. cancelButtonText: '取消',
  282. confirmButtonText: '确定',
  283. type: 'warning',
  284. distinguishCancelAndClose: true,
  285. dangerouslyUseHTMLString: true
  286. }).then(() => {
  287. if(chargeFlag.value === 1){
  288. updateMzDrugCodgDataNew(codgInfo.value).then((res) => {
  289. if(res.code === 0){
  290. ElMessage({
  291. type: "success",
  292. message: res.message,
  293. duration: 2500,
  294. showClose: true,
  295. });
  296. emit('closeYpMzCodgMatch', true)
  297. }
  298. })
  299. } else {
  300. updateMzDrugCodgData(codgInfo.value).then((res) => {
  301. if(res.code === 0){
  302. ElMessage({
  303. type: "success",
  304. message: res.message,
  305. duration: 2500,
  306. showClose: true,
  307. });
  308. emit('closeYpMzCodgMatch', true)
  309. }
  310. })
  311. }
  312. }).catch((action) => {
  313. if (action === 'cancel') {
  314. console.log("已取消。。。")
  315. }
  316. })
  317. }
  318. </script>