InStorage.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <script setup lang="ts">
  2. import { useRouter } from 'vue-router'
  3. import { GlobalStore } from '@/stores/index'
  4. import { View,Edit,Delete } from '@element-plus/icons-vue'
  5. import { ElMessage, ElMessageBox } from 'element-plus'
  6. import InStorageForm from './InStorageForm.vue'
  7. import InStorageEdit from './InStorageEdit.vue'
  8. import { ref, reactive } from 'vue'
  9. import TableBase from '@/components/TableBase/index.vue'
  10. import type { ColumnProps } from '@/components/TableBase/interface/index'
  11. import { Storehouse_StockIn_List,Storehouse_StockIn_del } from '@/api/storehouse/index'
  12. import { depotHooks } from '@/hooks/useDepot'
  13. const router = useRouter()
  14. const globalStore = GlobalStore()
  15. const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
  16. const columns: ColumnProps[] = [
  17. { type: 'index', label: '序号', width: 80 },
  18. { prop: 'T_number', label: '入库单号' },
  19. { prop: 'T_submit_name', label: '经办人' },
  20. { prop: 'T_depot_name', label: '入库仓库' },
  21. { prop: 'T_date', label: '入库日期' },
  22. { prop: 'operation', label: '操作', width: 260, fixed: 'right' }
  23. ]
  24. const InStorageFormRef = ref<InstanceType<typeof InStorageForm> | null>(null)
  25. const InStorageRef = ref()
  26. /**
  27. * 查看详情
  28. */
  29. const preview = (id: string) => {
  30. router.push({ name: 'InStorageDetail', params: { id } })
  31. }
  32. /**
  33. * 编辑
  34. */
  35. const previewEdit = (row: any) => {
  36. // console.log('编辑',row,InStorageRef.value)
  37. InStorageRef.value?.openDrawer()
  38. InStorageRef.value?.getStorehouseContractGet(row.T_number)
  39. for (let key in InStorageRef.value?.form) {
  40. if (row.hasOwnProperty(key)) InStorageRef.value.form[key] = row[key];
  41. }
  42. // console.log('111',InStorageRef.value?.form)
  43. }
  44. // 搜索
  45. const T_date = ref<string[]>([])
  46. const initParam = reactive({
  47. User_tokey: globalStore.GET_User_tokey,
  48. T_end_date: '',
  49. T_start_date: '',
  50. T_depot_id: ''
  51. })
  52. const searchHandle = () => {
  53. initParam.T_end_date = T_date.value ? T_date.value[1] : ''
  54. initParam.T_start_date = T_date.value ? T_date.value[0] : ''
  55. TableRef.value?.searchTable()
  56. }
  57. /**
  58. * 添加入库
  59. */
  60. const openInStorageFormDrawer = () => InStorageFormRef.value?.openDrawer()
  61. /**
  62. * 删除
  63. */
  64. const deleteFun = (row:any)=>{
  65. ElMessageBox.confirm(
  66. '删除操作,是否立即删除?',
  67. '删除',
  68. {
  69. confirmButtonText: '立即删除',
  70. cancelButtonText: '取消',
  71. type: 'warning',
  72. center: true,
  73. }
  74. ).then(async () => {
  75. const result:any = await Storehouse_StockIn_del({T_number:row})
  76. if(result.Code==200){
  77. ElMessage.success('删除成功')
  78. TableRef.value?.searchTable()
  79. }
  80. }).catch(() => {})
  81. }
  82. // 拿到仓库列表
  83. const { options } = depotHooks()
  84. </script>
  85. <template>
  86. <div class="InStorage">
  87. <TableBase ref="TableRef" :columns="columns" :requestApi="Storehouse_StockIn_List" :initParam="initParam">
  88. <template #table-header>
  89. <div class="input-suffix">
  90. <el-row :gutter="20" style="margin-bottom: 0">
  91. <el-col :xl="6" :lg="9" :md="11" style="display: flex">
  92. <span class="inline-flex items-center">入库日期:</span>
  93. <el-date-picker
  94. v-model="T_date"
  95. type="daterange"
  96. range-separator="~"
  97. start-placeholder="开始时间"
  98. end-placeholder="结束时间"
  99. format="YYYY-MM-DD"
  100. value-format="YYYY-MM-DD"
  101. />
  102. </el-col>
  103. <el-col :xl="6" :lg="7" :md="9" style="display: flex">
  104. <span class="inline-flex items-center">仓库:</span>
  105. <el-select v-model="initParam.T_depot_id" clearable placeholder="请选择仓库~">
  106. <el-option v-for="item in options" :key="item.Id" :label="item.T_name" :value="item.Id" />
  107. </el-select>
  108. <el-button type="primary" @click="searchHandle">搜索</el-button>
  109. </el-col>
  110. <el-col :xl="12" :lg="8" :md="4" class="btn"
  111. ><el-button type="primary" @click="openInStorageFormDrawer">入库</el-button></el-col
  112. >
  113. </el-row>
  114. </div>
  115. </template>
  116. <template #right="{ row }">
  117. <el-button link type="success" size="small" :icon="View" @click="preview(row.T_number)">详情</el-button>
  118. <el-button link type="success" size="small" :icon="Edit" @click="previewEdit(row)">编辑</el-button>
  119. <el-button link type="danger" size="small" :icon="Delete" @click="deleteFun(row.T_number)">删除</el-button>
  120. </template>
  121. </TableBase>
  122. <InStorageForm ref="InStorageFormRef" :options="options" @onUpdateList="searchHandle" />
  123. <InStorageEdit ref="InStorageRef" :options="options" @onUpdateList="searchHandle" />
  124. </div>
  125. </template>
  126. <style scoped lang="scss">
  127. @import '@/styles/var.scss';
  128. .InStorage {
  129. @include f-direction;
  130. .input-suffix {
  131. width: 100%;
  132. .inline-flex {
  133. white-space: nowrap;
  134. }
  135. .w-50 {
  136. width: 12.5rem;
  137. }
  138. .btn {
  139. display: flex;
  140. justify-content: end;
  141. .el-button {
  142. padding: 0 20px;
  143. }
  144. }
  145. }
  146. }
  147. </style>