index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <!-- -->
  2. <template>
  3. <div class="storagePut">
  4. <searchAdd isButtom="查询" @event="eventFun">
  5. <template #searchConter>
  6. <el-form-item label="血液制品名称">
  7. <el-select v-model.number="initParam.productId" filterable remote reserve-keyword placeholder="血液制品名称"
  8. :remote-method="remoteMethod1" :loading="loading" clearable style="width: 200px;"
  9. @clear="initParam.productId = null" @click="click1">
  10. <el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value" />
  11. </el-select>
  12. </el-form-item>
  13. <el-form-item label="生产企业">
  14. <el-select v-model.number="initParam.enterpriseId" filterable remote reserve-keyword placeholder="生产企业"
  15. :remote-method="remoteMethod2" :loading="loading" clearable @clear="initParam.enterpriseId = null"
  16. @click="click2" style="width: 200px;">
  17. <el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value" />
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="批准文号">
  21. <el-input v-model="initParam.batchNumber" placeholder="血液制品批号" clearable style="width: 200px;" />
  22. </el-form-item>
  23. <el-form-item label="出库日期">
  24. <el-date-picker v-model="data.datepick" type="daterange" placeholder="出/入库日期" clearable
  25. start-placeholder="开始" end-placeholder="结束" value-format="YYYY-MM-DD" style="width: 200px;"
  26. @change="changFun" />
  27. </el-form-item>
  28. <el-form-item label="收货单位">
  29. <el-select v-model="initParam.receivingUnit" filterable remote reserve-keyword placeholder="收货单位"
  30. :remote-method="remoteMethod3" :loading="loading" clearable @click="click3" style="width: 200px;">
  31. <el-option v-for="item in options3" :key="item.value" :label="item.label" :value="item.value" />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="条码">
  35. <el-input v-model="initParam.qrcode" placeholder="请输入条码" clearable style="width: 200px;" />
  36. </el-form-item>
  37. </template>
  38. </searchAdd>
  39. <bg istitle="基本信息">
  40. <template #btn>
  41. <Labour @scanCode="scanCodeFun"></Labour>
  42. <scanCode @scanCode="scanCodeFun" style="margin:0 10px;"></scanCode>
  43. <Outbound></Outbound>
  44. <downing></downing>
  45. </template>
  46. <template #bg>
  47. <tables ref="TableRef" :requestApi="stockOutList" :columns="columns" :initParam="initParam">
  48. <template #right="{ row }">
  49. <Editinventory :row="row" @editinvent="editinventFun"></Editinventory>
  50. </template>
  51. </tables>
  52. </template>
  53. </bg>
  54. </div>
  55. </template>
  56. <script setup lang="ts">
  57. import {
  58. stockOutList,
  59. productList,//血液制品名称
  60. enterpriseList,//生产企业
  61. stockunit,//收发货单位
  62. medicineColumns,//表头
  63. } from "@/api";
  64. import Editinventory from './Editinventory.vue'
  65. import { reactive, ref,onMounted,onBeforeMount } from "vue";
  66. import tables from "@/components/table.vue";
  67. import searchAdd from "@/components/searchAdd.vue";
  68. import bg from '@/components/bg.vue'
  69. import scanCode from './scanCode.vue'
  70. import Labour from './Labour.vue'
  71. import Outbound from './Outbound.vue'
  72. import downing from './downing.vue'
  73. const TableRef = ref()
  74. import { columnsTableOut } from "@/plugins/rulesData";
  75. //函数
  76. const scanCodeFun = async ()=>{
  77. console.log('添加完成')
  78. TableRef.value?.getTableList()
  79. }
  80. //函数
  81. const editinventFun = async ()=>{
  82. TableRef.value?.getTableList()
  83. }
  84. //函数
  85. const datepickFn = ()=>{
  86. const today = new Date()
  87. const year = today.getFullYear();
  88. const month = (today.getMonth() + 1).toString().padStart(2,'0'); // 注意月份从0开始,所以要加1
  89. const date = (today.getDate()).toString().padStart(2,'0');
  90. const j = year +'-' + month + '-'+date
  91. data.datepick = [j,j]
  92. initParam.startDate = j; initParam.endDate = j
  93. }
  94. onBeforeMount(()=>{//默认获取当天的时间
  95. // datepickFn()
  96. })
  97. const columns:any = []
  98. //提交参数
  99. const initParam = reactive({
  100. "batchNumber": "",
  101. "enterpriseId": null,
  102. "endDate": "",
  103. "startDate": "",
  104. "productId": null,
  105. "receivingUnit": "",
  106. "qrcode":''
  107. })
  108. const data:any = reactive({
  109. datepick: []
  110. })
  111. /**
  112. *
  113. * @param val 子传值
  114. */
  115. const eventFun = (val: any) => {
  116. TableRef.value?.getTableList()
  117. }
  118. const loading = ref(false)
  119. const list1 = ref<ListItem[]>([])//血液制品名称
  120. const list2 = ref<ListItem[]>([])//生产企业
  121. const list3 = ref<ListItem[]>([])//收发货单位
  122. //函数
  123. const click1 = async () => { options1.value = list1.value }
  124. const click2 = async () => { options2.value = list2.value }
  125. const click3 = async ()=>{options3.value = list3.value}
  126. // 渲染表格
  127. onMounted(async () => {
  128. let r:any = await medicineColumns({})
  129. if(r.code==200){
  130. let obj = [...r.data?.list]
  131. TableRef.value.tableColumns = [...obj,...columnsTableOut]
  132. }
  133. const result1: any = await productList({ age: 1, pageSize: 999 })//血液制品名称
  134. const result2: any = await enterpriseList({ age: 1, pageSize: 999 })//生产企业
  135. const result3: any = await stockunit({ type: 2 })//收发货单位
  136. list1.value = findMap(result1.data?.list || [], 'obj')
  137. list2.value = findMap(result2.data?.list || [], 'obj')
  138. list3.value = findMap(result3.data?.list || [],'map')
  139. })
  140. //函数
  141. const changFun = async (e: any) => {
  142. if (e) { initParam.startDate = e[0]; initParam.endDate = e[1] }
  143. else { initParam.startDate = ""; initParam.endDate = "" }
  144. }
  145. interface ListItem {
  146. value: string
  147. label: string
  148. }
  149. const options1 = ref<ListItem[]>([])
  150. const options2 = ref<ListItem[]>([])
  151. const options3 = ref<ListItem[]>([])
  152. const remoteMethod1 = async (query: string) => {
  153. if (query) {
  154. loading.value = true
  155. setTimeout(() => {
  156. loading.value = false
  157. options1.value = list1.value.filter((item: any) => {
  158. return item.label.toLowerCase().includes(query.toLowerCase())
  159. })
  160. }, 200)
  161. } else {
  162. options1.value = []
  163. }
  164. }
  165. const remoteMethod2 = async (query: string) => {
  166. if (query) {
  167. loading.value = true
  168. setTimeout(() => {
  169. loading.value = false
  170. options2.value = list2.value.filter((item: any) => {
  171. console.log('第一个', query, item)
  172. return item.label.toLowerCase().includes(query.toLowerCase())
  173. })
  174. }, 200)
  175. } else {
  176. options2.value = []
  177. }
  178. }
  179. const remoteMethod3 = async (query: string) => {
  180. if (query) {
  181. loading.value = true
  182. setTimeout(() => {
  183. loading.value = false
  184. options3.value = list3.value.filter((item: any) => {
  185. return item.label.toLowerCase().includes(query.toLowerCase())
  186. })
  187. }, 200)
  188. } else {
  189. options3.value = []
  190. }
  191. }
  192. //函数
  193. const findMap = (arr: any, obj: any) => {
  194. return arr.map((item: any) => {
  195. return { value: obj == 'obj' ? item.id : item, label: obj == 'obj' ? item.name : item }
  196. })
  197. }
  198. </script>
  199. <style lang="scss">
  200. .storagePut {
  201. user-select: none;
  202. }
  203. .el-form-item {
  204. // margin-bottom: 0;
  205. }
  206. </style>