YpTempPurchase.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <div class="layout_container">
  3. <header>
  4. <el-input v-model="inpatientNo" class="w-50 m-2" style="width: 220px" placeholder="请输入姓名/住院号" clearable>
  5. </el-input>
  6. <el-select v-model="chargeCode" placeholder="请选择临购药品" filterable clearable
  7. style="width: 320px;margin-left: 3px">
  8. <el-option v-for="item in tempPurchaseData" :key="item.chargeCode" :label="item.chargeName"
  9. :value="item.chargeCode">
  10. <span style="float: left">{{ item.chargeName }}</span>
  11. <span style="float: right; color: var(--el-text-color-secondary); font-size: 13px; ">
  12. {{ item.chargeCode }}
  13. </span>
  14. </el-option>
  15. </el-select>
  16. <el-select v-model="ztFlag" placeholder="请选择申请进度" clearable style="width: 140px;margin-left: 3px">
  17. <el-option v-for="item in ztOptions" :key="item.value" :label="item.label" :value="item.value">
  18. </el-option>
  19. </el-select>
  20. <el-date-picker v-model="dateRange" type="daterange" :shortcuts="maxHalfYear" range-separator="至"
  21. start-placeholder="开始时间" end-placeholder="结束时间" style="width: 260px;margin-left: 3px">
  22. </el-date-picker>
  23. <el-button type="primary" icon="Search" @click="queryYpTempPurchaseData"
  24. style="margin-left: 5px">查询
  25. </el-button>
  26. <el-button type="primary" icon="Download" @click="exportData" style="margin-left: 5px">导出</el-button>
  27. </header>
  28. <div class="layout_main">
  29. <el-tabs class="el-tabs__fill" v-model="editableTabsValue" type="border-card" @tab-click="handleClick">
  30. <el-tab-pane key="ypPurchase" label="明细" name="ypPurchaseInfo">
  31. <div class="layout_container">
  32. <div class="layout_main layout_el-table">
  33. <el-table :data="ypPurchaseData.slice(pageSize * (currentPage - 1), pageSize * currentPage)" border
  34. stripe highlight-current-row>
  35. <el-table-column type="index" label="序号" width="60"/>
  36. <el-table-column prop="chargeCode" label="药品编码" width="90"/>
  37. <el-table-column prop="serial" label="药品包装" width="70">
  38. <template #default="scope">
  39. <span v-if="scope.row.serial === '99'">大包装</span>
  40. <span v-else>小包装</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="chargeName" label="药品名称" width="220" show-overflow-tooltip/>
  44. <el-table-column prop="specification" label="药品规格" width="140" show-overflow-tooltip/>
  45. <el-table-column prop="name" label="患者姓名" width="100"/>
  46. <el-table-column prop="inpatientNo" label="住院号" width="100"/>
  47. <el-table-column prop="amount" label="数量" width="70"/>
  48. <el-table-column prop="useResult" label="使用理由" width="200" show-overflow-tooltip/>
  49. <el-table-column prop="op" label="申请人" width="100"/>
  50. <el-table-column prop="applyDate" label="申请时间" width="140"/>
  51. <el-table-column prop="receptFlag" label="是否接收" width="80">
  52. <template #default="scope">
  53. <span v-if="scope.row.receptFlag === '1'" style="color:#106898;">已接收</span>
  54. <span v-else-if="scope.row.receptFlag === '0'" style="color:#d12020;">拒接收</span>
  55. <span v-else></span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column prop="purchaseFlag" label="是否采购" width="80">
  59. <template #default="scope">
  60. <span v-if="scope.row.purchaseFlag === '1'" style="color:#106898;">已采购</span>
  61. <span v-else-if="scope.row.purchaseFlag === '0'" style="color:#d12020;">拒采购</span>
  62. <span v-else></span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="storageFlag" label="是否入库" width="80">
  66. <template #default="scope">
  67. <span v-if="scope.row.storageFlag === '1'" style="color:#106898;">已入库</span>
  68. <span v-else-if="scope.row.storageFlag === '0'" style="color:#d12020;">拒入库</span>
  69. <span v-else></span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="result" label="采购情况" width="200" show-overflow-tooltip/>
  73. <el-table-column fixed="right" label="操作" min-width="80" width="80" header-align="center"
  74. align="center">
  75. <template #default="scope">
  76. <el-button type="primary" size="small" v-if="scope.row.permissions === '1'"
  77. @click="auditTempPurchase(scope.row)">审核
  78. </el-button>
  79. <el-button type="primary" size="small" v-if="scope.row.permissions === '0'"
  80. @click="editTempPurchase(scope.row)">修改
  81. </el-button>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </div>
  86. <div>
  87. <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="[15, 30, 45, 60]"
  88. :total="ypPurchaseData.length" layout="total, sizes, prev, pager, next, jumper"
  89. style="margin-top: 5px" @size-change="handleSizeChange"
  90. @current-change="handleCurrentChange">
  91. </el-pagination>
  92. </div>
  93. </div>
  94. <el-dialog v-model="showAuditTempPurchase" :close-on-click-modal="false" :before-close="handleClose"
  95. :close-on-press-escape="false" :title="auditTempPurchaseName" width="80%" destroy-on-close>
  96. <TempPurchaseAudit :ypTempPurchaseDetail="ypTempPurchaseDetail"
  97. @closeTempPurchaseAudit="closeTempPurchaseAudit"/>
  98. </el-dialog>
  99. <el-dialog v-model="showEditTempPurchase" :close-on-click-modal="false" :before-close="handleClose"
  100. :close-on-press-escape="false" :title="editTempPurchaseName" width="80%" destroy-on-close>
  101. <TempPurchaseEdit :ypTempPurchaseEditData="ypTempPurchaseEditData"
  102. @closeTempPurchaseEdit="closeTempPurchaseEdit"/>
  103. </el-dialog>
  104. </el-tab-pane>
  105. <el-tab-pane key="ypPurchase" label="申请" name="ypPurchase">
  106. <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="120px"
  107. class="demo-ruleForm" :size="formSize" status-icon>
  108. <el-row>
  109. <el-col :span="6">
  110. <el-form-item label="药品" prop="chargeCode">
  111. <el-select v-model="ruleForm.chargeCode" placeholder="请选择药品" filterable clearable
  112. style="width: 100%" @change="ypChange">
  113. <el-option v-for="item in tempPurchaseData" :key="item.chargeCode"
  114. :label="item.chargeName" :value="item.chargeCode">
  115. <span style="float: left">{{ item.chargeName }}</span>
  116. <span
  117. style="float: right; color: var(--el-text-color-secondary); font-size: 13px;">
  118. {{ item.chargeCode }}
  119. </span>
  120. </el-option>
  121. </el-select>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="6">
  125. <el-form-item label="序号" prop="serial">
  126. <el-input v-model="ruleForm.serial" maxlength="2" show-word-limit placeholder="序号"
  127. disabled/>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="6">
  131. <el-form-item label="规格" prop="specification">
  132. <el-input v-model="ruleForm.specification" maxlength="40" show-word-limit
  133. placeholder="规格" disabled/>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="6">
  137. <el-form-item label="数量" prop="amount">
  138. <el-input v-model="ruleForm.amount" maxlength="10" show-word-limit
  139. placeholder="请填写数量" autocomplete="off"/>
  140. </el-form-item>
  141. </el-col>
  142. </el-row>
  143. <el-row>
  144. <el-col :span="6">
  145. <el-form-item label="申请人" prop="op">
  146. <el-input v-model="ruleForm.op" maxlength="40" show-word-limit
  147. placeholder="请填写申请人" disabled/>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="6">
  151. <el-form-item label="患者姓名" prop="name">
  152. <el-input v-model="ruleForm.name" maxlength="40" show-word-limit
  153. placeholder="请填写患者姓名"/>
  154. </el-form-item>
  155. </el-col>
  156. <el-col :span="6">
  157. <el-form-item label="住院号" prop="inpatientNo">
  158. <el-input v-model="ruleForm.inpatientNo" maxlength="6" show-word-limit
  159. placeholder="请填写住院号"/>
  160. </el-form-item>
  161. </el-col>
  162. <el-col :span="6">
  163. <el-form-item label="申请日期" prop="applyDate">
  164. <el-input v-model="ruleForm.applyDate" show-word-limit placeholder="请填写申请日期"
  165. disabled/>
  166. </el-form-item>
  167. </el-col>
  168. </el-row>
  169. <el-row>
  170. <el-col :span="24">
  171. <el-form-item label="使用理由" prop="useResult">
  172. <el-input v-model="ruleForm.useResult" show-word-limit placeholder="请填写使用理由"/>
  173. </el-form-item>
  174. </el-col>
  175. </el-row>
  176. <el-row>
  177. <el-col :span="24">
  178. <el-form-item label="温馨提示" prop="desc">
  179. <el-input v-model="desc" show-word-limit placeholder="温馨提示" disabled/>
  180. </el-form-item>
  181. </el-col>
  182. </el-row>
  183. <el-form-item>
  184. <el-button type="primary" @click="submitForm(ruleFormRef)">
  185. 申请
  186. </el-button>
  187. <el-button type="info" @click="resetForm(ruleFormRef)">重置</el-button>
  188. </el-form-item>
  189. </el-form>
  190. </el-tab-pane>
  191. </el-tabs>
  192. </div>
  193. </div>
  194. </template>
  195. <script setup>
  196. import {ref, onMounted, nextTick} from 'vue'
  197. import {useUserStore} from '@/pinia/user-store'
  198. import {ElMessage} from 'element-plus'
  199. import {Export} from '@/utils/ExportExcel'
  200. import {formatDatetime, getDateRangeFormatDate} from '@/utils/date'
  201. import {maxHalfYear} from '@/data/shortcuts'
  202. import {clone} from '@/utils/clone'
  203. import {selectYpTempPurchase, selectTempPurchaseYp, saveYpTempPurchase} from '@/api/yp-inventory/yp-temp-purchase.js'
  204. import TempPurchaseAudit from '@/views/yp-inventory/TempPurchaseAudit.vue'
  205. import TempPurchaseEdit from '@/views/yp-inventory/TempPurchaseEdit.vue'
  206. const userInfo = useUserStore().userInfo
  207. const editableTabsValue = ref('ypPurchaseInfo')
  208. const userCode = userInfo.code
  209. const userName = userInfo.name
  210. const ypPurchaseData = ref([])
  211. const inpatientNo = ref('')
  212. const chargeCode = ref('')
  213. const ztFlag = ref('')
  214. const dateRange = ref([])
  215. const now = formatDatetime(new Date())
  216. const start = formatDatetime(maxHalfYear[2].value[0])
  217. const end = formatDatetime(maxHalfYear[2].value[1])
  218. const pageSize = ref(30)
  219. const currentPage = ref(1)
  220. const handleSizeChange = (val) => {
  221. pageSize.value = val
  222. }
  223. const handleCurrentChange = (val) => {
  224. currentPage.value = val
  225. }
  226. const handleClick = (tab, event) => {
  227. editableTabsValue.value = tab.props.name
  228. if (editableTabsValue.value === 'ypPurchaseInfo') {
  229. queryYpTempPurchaseData()
  230. }
  231. }
  232. const ztOptions = [
  233. {value: '1', label: '已接收'}, {value: '2', label: '未接收'},
  234. {value: '3', label: '已采购'}, {value: '4', label: '未采购'},
  235. {value: '5', label: '已入库'}, {value: '6', label: '未入库'}]
  236. const desc = ref('科室临购药品在本院出现滞销(90天以上未使用或使用数量低于购进数量的30%以下),导致过期现象,则该药品的损失由申请科室承担,并1年内不能再申请新药。')
  237. const tempPurchaseData = ref([])
  238. const queryData = ref({
  239. inpatientNo: '',
  240. chargeCode: '',
  241. ztFlag: '',
  242. startTime: '',
  243. endTime: '',
  244. })
  245. onMounted(() => {
  246. nextTick(() => {
  247. queryTempPurchaseYp('')
  248. queryData.startTime = start;
  249. queryData.endTime = end + " 23:59:59";
  250. dateRange.value = [start, end];
  251. queryYpTempPurchaseData()
  252. })
  253. })
  254. const showAuditTempPurchase = ref(false)
  255. const auditTempPurchaseName = ref('临购药品审核')
  256. const ypTempPurchaseDetail = ref([])
  257. const showEditTempPurchase = ref(false)
  258. const editTempPurchaseName = ref('临购药品修改')
  259. const ypTempPurchaseEditData = ref([])
  260. const queryYpTempPurchaseData = () => {
  261. if (dateRange.value) {
  262. let dateS = getDateRangeFormatDate(dateRange.value)
  263. queryData.value.startTime = dateS.startTime
  264. queryData.value.endTime = dateS.endTime
  265. }
  266. queryData.value.chargeCode = chargeCode.value
  267. queryData.value.inpatientNo = inpatientNo.value
  268. queryData.value.ztFlag = ztFlag.value
  269. selectYpTempPurchase(queryData.value)
  270. .then((res) => {
  271. ypPurchaseData.value = res
  272. })
  273. .catch(() => {
  274. ypPurchaseData.value = []
  275. })
  276. }
  277. const queryTempPurchaseYp = (text) => {
  278. selectTempPurchaseYp(text)
  279. .then((res) => {
  280. tempPurchaseData.value = res
  281. })
  282. .catch(() => {
  283. tempPurchaseData.value = []
  284. })
  285. }
  286. const ypChange = async () => {
  287. await nextTick()
  288. let dataF = tempPurchaseData.value.filter((item) => {
  289. return item.chargeCode === ruleForm.value.chargeCode
  290. })
  291. if (dataF) {
  292. ruleForm.value.chargeName = dataF[0].chargeName
  293. ruleForm.value.serial = dataF[0].serial
  294. ruleForm.value.specification = dataF[0].specification
  295. }
  296. }
  297. const formSize = ref('default')
  298. const ruleFormRef = ref()
  299. const ruleForm = ref({
  300. applyId: '', // 申请id
  301. chargeName: '', // 药品名称
  302. chargeCode: '', // 药品code
  303. serial: '', // 序号
  304. specification: '', // 规格
  305. amount: '', // 申请数量
  306. useResult: '', // 使用理由
  307. op: userName, // 申请人(要求是临床科主任)
  308. opId: userCode, // 申请人id
  309. name: '', // 患者姓名
  310. inpatientNo: '', // 住院号
  311. receptFlag: '', // 是否接收(1: 接收)
  312. purchaseFlag: '', // 是否采购(1: 采购)
  313. storageFlag: '', // 是否入库(1: 入库)
  314. applyDate: now, // 申请日期
  315. auditDate: '', // 审核日期
  316. result: '', // 未采购原因
  317. })
  318. const rules = ref({
  319. chargeCode: [
  320. {required: true, message: '请选择药品', trigger: 'change'},
  321. ],
  322. amount: [
  323. {required: true, message: '请填写申请数量', trigger: 'blur'},
  324. ],
  325. useResult: [
  326. {required: true, message: '请填写使用理由', trigger: 'blur'},
  327. ],
  328. name: [
  329. {required: true, message: '请填写患者姓名', trigger: 'blur'},
  330. ],
  331. inpatientNo: [
  332. {required: true, message: '请填写住院号', trigger: 'blur'},
  333. ],
  334. })
  335. const submitForm = async (formEl) => {
  336. if (!formEl) return
  337. await formEl.validate((valid, fields) => {
  338. if (valid) {
  339. if (Number.isNaN(Number.parseFloat(ruleForm.value.amount))) {
  340. ElMessage({
  341. type: "warning",
  342. message: '申请数量不是数值,请检查!',
  343. duration: 2500,
  344. showClose: true,
  345. });
  346. return
  347. }
  348. saveYpTempPurchase(ruleForm.value).then((res) => {
  349. if (res.cg) {
  350. ElMessage({
  351. type: "success",
  352. message: res.cg,
  353. duration: 2500,
  354. showClose: true,
  355. });
  356. formEl.resetFields()
  357. editableTabsValue.value = 'ypPurchaseInfo'
  358. queryYpTempPurchaseData()
  359. }
  360. });
  361. } else {
  362. console.log('error submit!', fields)
  363. }
  364. })
  365. }
  366. const resetForm = (formEl) => {
  367. if (!formEl) return
  368. formEl.resetFields()
  369. }
  370. const auditTempPurchase = (row) => {
  371. showAuditTempPurchase.value = true
  372. ypTempPurchaseDetail.value = row
  373. }
  374. const closeTempPurchaseAudit = (flag) => {
  375. if (flag) {
  376. showAuditTempPurchase.value = false
  377. }
  378. queryYpTempPurchaseData()
  379. }
  380. const handleClose = (done) => {
  381. queryYpTempPurchaseData()
  382. done()
  383. }
  384. const editTempPurchase = (row) => {
  385. if (row.receptFlag === '1') {
  386. ElMessage({
  387. type: "warning",
  388. message: '临购药品已接收的申请不允许修改,请检查!',
  389. duration: 2500,
  390. showClose: true,
  391. });
  392. return
  393. }
  394. showEditTempPurchase.value = true
  395. ypTempPurchaseEditData.value = row
  396. }
  397. const closeTempPurchaseEdit = (flag) => {
  398. if (flag) {
  399. showEditTempPurchase.value = false
  400. }
  401. queryYpTempPurchaseData()
  402. }
  403. // 导出临购药品明细信息
  404. const exportData = () => {
  405. if (ypPurchaseData.value.length === 0) {
  406. ElMessage({
  407. message: "没有可以导出的数据!",
  408. type: "warning",
  409. duration: 2500,
  410. showClose: true,
  411. });
  412. } else {
  413. const title = {
  414. chargeCode: "药品编码",
  415. chargeName: "药品名称",
  416. serial: "药品包装",
  417. specification: "药品规格",
  418. name: "患者姓名",
  419. inpatientNo: "住院号",
  420. amount: "数量",
  421. useResult: "使用理由",
  422. op: "申请人",
  423. receptFlag: "是否接收",
  424. purchaseFlag: "是否采购",
  425. storageFlag: "是否入库",
  426. applyDate: "申请日期",
  427. auditDate: "审核日期",
  428. result: "采购情况",
  429. };
  430. const d = clone(ypPurchaseData.value)
  431. d.forEach(val => {
  432. if (val.serial === '99') {
  433. val.serial = '大包装'
  434. } else {
  435. val.serial = '小包装'
  436. }
  437. if (val.receptFlag === '1') {
  438. val.receptFlag = '是'
  439. } else {
  440. val.receptFlag = '否'
  441. }
  442. if (val.purchaseFlag === '1') {
  443. val.purchaseFlag = '是'
  444. } else {
  445. val.purchaseFlag = '否'
  446. }
  447. if (val.storageFlag === '1') {
  448. val.storageFlag = '是'
  449. } else {
  450. val.storageFlag = '否'
  451. }
  452. });
  453. Export(d, title, "临购药品明细信息")
  454. }
  455. }
  456. </script>