YpTempPurchase.vue 19 KB

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