index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <doc-alert title="【库存】其它入库、其它出库" url="https://doc.iocoder.cn/erp/stock-in-out/" />
  3. <ContentWrap>
  4. <!-- 搜索工作栏 -->
  5. <el-form
  6. class="-mb-15px"
  7. :model="queryParams"
  8. ref="queryFormRef"
  9. :inline="true"
  10. label-width="68px"
  11. >
  12. <el-form-item label="入库单号" prop="no">
  13. <el-input
  14. v-model="queryParams.no"
  15. placeholder="请输入入库单号"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. class="!w-240px"
  19. />
  20. </el-form-item>
  21. <el-form-item label="产品" prop="productId">
  22. <el-select
  23. v-model="queryParams.productId"
  24. clearable
  25. filterable
  26. placeholder="请选择产品"
  27. class="!w-240px"
  28. >
  29. <el-option
  30. v-for="item in productList"
  31. :key="item.id"
  32. :label="item.name"
  33. :value="item.id"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="入库时间" prop="inTime">
  38. <el-date-picker
  39. v-model="queryParams.inTime"
  40. value-format="YYYY-MM-DD HH:mm:ss"
  41. type="daterange"
  42. start-placeholder="开始日期"
  43. end-placeholder="结束日期"
  44. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  45. class="!w-220px"
  46. />
  47. </el-form-item>
  48. <el-form-item label="供应商" prop="supplierId">
  49. <el-select
  50. v-model="queryParams.supplierId"
  51. clearable
  52. filterable
  53. placeholder="请选择供应商"
  54. class="!w-240px"
  55. >
  56. <el-option
  57. v-for="item in supplierList"
  58. :key="item.id"
  59. :label="item.name"
  60. :value="item.id"
  61. />
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="仓库" prop="warehouseId">
  65. <el-select
  66. v-model="queryParams.warehouseId"
  67. clearable
  68. filterable
  69. placeholder="请选择仓库"
  70. class="!w-240px"
  71. >
  72. <el-option
  73. v-for="item in warehouseList"
  74. :key="item.id"
  75. :label="item.name"
  76. :value="item.id"
  77. />
  78. </el-select>
  79. </el-form-item>
  80. <el-form-item label="创建人" prop="creator">
  81. <el-select
  82. v-model="queryParams.creator"
  83. clearable
  84. filterable
  85. placeholder="请选择创建人"
  86. class="!w-240px"
  87. >
  88. <el-option
  89. v-for="item in userList"
  90. :key="item.id"
  91. :label="item.nickname"
  92. :value="item.id"
  93. />
  94. </el-select>
  95. </el-form-item>
  96. <el-form-item label="状态" prop="status">
  97. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
  98. <el-option
  99. v-for="dict in getIntDictOptions(DICT_TYPE.ERP_AUDIT_STATUS)"
  100. :key="dict.value"
  101. :label="dict.label"
  102. :value="dict.value"
  103. />
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item label="备注" prop="remark">
  107. <el-input
  108. v-model="queryParams.remark"
  109. placeholder="请输入备注"
  110. clearable
  111. @keyup.enter="handleQuery"
  112. class="!w-240px"
  113. />
  114. </el-form-item>
  115. <el-form-item>
  116. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  117. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  118. <el-button
  119. type="primary"
  120. plain
  121. @click="openForm('create')"
  122. v-hasPermi="['erp:stock-in:create']"
  123. >
  124. <Icon icon="ep:plus" class="mr-5px" /> 新增
  125. </el-button>
  126. <el-button
  127. type="success"
  128. plain
  129. @click="handleExport"
  130. :loading="exportLoading"
  131. v-hasPermi="['erp:stock-in:export']"
  132. >
  133. <Icon icon="ep:download" class="mr-5px" /> 导出
  134. </el-button>
  135. <el-button
  136. type="danger"
  137. plain
  138. @click="handleDelete(selectionList.map((item) => item.id))"
  139. v-hasPermi="['erp:stock-in:delete']"
  140. :disabled="selectionList.length === 0"
  141. >
  142. <Icon icon="ep:delete" class="mr-5px" /> 删除
  143. </el-button>
  144. </el-form-item>
  145. </el-form>
  146. </ContentWrap>
  147. <!-- 列表 -->
  148. <ContentWrap>
  149. <el-table
  150. v-loading="loading"
  151. :data="list"
  152. :stripe="true"
  153. :show-overflow-tooltip="true"
  154. @selection-change="handleSelectionChange"
  155. >
  156. <el-table-column width="30" label="选择" type="selection" />
  157. <el-table-column min-width="180" label="入库单号" align="center" prop="no" />
  158. <el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
  159. <el-table-column label="供应商" align="center" prop="supplierName" />
  160. <el-table-column
  161. label="入库时间"
  162. align="center"
  163. prop="inTime"
  164. :formatter="dateFormatter2"
  165. width="120px"
  166. />
  167. <el-table-column label="创建人" align="center" prop="creatorName" />
  168. <el-table-column
  169. label="数量"
  170. align="center"
  171. prop="totalCount"
  172. :formatter="erpCountTableColumnFormatter"
  173. />
  174. <el-table-column
  175. label="金额"
  176. align="center"
  177. prop="totalPrice"
  178. :formatter="erpPriceTableColumnFormatter"
  179. />
  180. <el-table-column label="状态" align="center" fixed="right" width="90" prop="status">
  181. <template #default="scope">
  182. <dict-tag :type="DICT_TYPE.ERP_AUDIT_STATUS" :value="scope.row.status" />
  183. </template>
  184. </el-table-column>
  185. <el-table-column label="操作" align="center" fixed="right" width="220">
  186. <template #default="scope">
  187. <el-button
  188. link
  189. @click="openForm('detail', scope.row.id)"
  190. v-hasPermi="['erp:stock-in:query']"
  191. >
  192. 详情
  193. </el-button>
  194. <el-button
  195. link
  196. type="primary"
  197. @click="openForm('update', scope.row.id)"
  198. v-hasPermi="['erp:stock-in:update']"
  199. :disabled="scope.row.status === 20"
  200. >
  201. 编辑
  202. </el-button>
  203. <el-button
  204. link
  205. type="primary"
  206. @click="handleUpdateStatus(scope.row.id, 20)"
  207. v-hasPermi="['erp:stock-in:update-status']"
  208. v-if="scope.row.status === 10"
  209. >
  210. 审批
  211. </el-button>
  212. <el-button
  213. link
  214. type="danger"
  215. @click="handleUpdateStatus(scope.row.id, 10)"
  216. v-hasPermi="['erp:stock-in:update-status']"
  217. v-else
  218. >
  219. 反审批
  220. </el-button>
  221. <el-button
  222. link
  223. type="danger"
  224. @click="handleDelete([scope.row.id])"
  225. v-hasPermi="['erp:stock-in:delete']"
  226. >
  227. 删除
  228. </el-button>
  229. </template>
  230. </el-table-column>
  231. </el-table>
  232. <!-- 分页 -->
  233. <Pagination
  234. :total="total"
  235. v-model:page="queryParams.pageNo"
  236. v-model:limit="queryParams.pageSize"
  237. @pagination="getList"
  238. />
  239. </ContentWrap>
  240. <!-- 表单弹窗:添加/修改 -->
  241. <StockInForm ref="formRef" @success="getList" />
  242. </template>
  243. <script setup lang="ts">
  244. import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
  245. import { dateFormatter2 } from '@/utils/formatTime'
  246. import download from '@/utils/download'
  247. import { StockInApi, StockInVO } from '@/api/erp/stock/in'
  248. import StockInForm from './StockInForm.vue'
  249. import { ProductApi, ProductVO } from '@/api/erp/product/product'
  250. import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
  251. import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
  252. import { UserVO } from '@/api/system/user'
  253. import * as UserApi from '@/api/system/user'
  254. import { erpCountTableColumnFormatter, erpPriceTableColumnFormatter } from '@/utils'
  255. /** ERP 其它入库单列表 */
  256. defineOptions({ name: 'ErpStockIn' })
  257. const message = useMessage() // 消息弹窗
  258. const { t } = useI18n() // 国际化
  259. const loading = ref(true) // 列表的加载中
  260. const list = ref<StockInVO[]>([]) // 列表的数据
  261. const total = ref(0) // 列表的总页数
  262. const queryParams = reactive({
  263. pageNo: 1,
  264. pageSize: 10,
  265. no: undefined,
  266. productId: undefined,
  267. supplierId: undefined,
  268. inTime: [],
  269. status: undefined,
  270. remark: undefined,
  271. creator: undefined
  272. })
  273. const queryFormRef = ref() // 搜索的表单
  274. const exportLoading = ref(false) // 导出的加载中
  275. const productList = ref<ProductVO[]>([]) // 产品列表
  276. const warehouseList = ref<WarehouseVO[]>([]) // 仓库列表
  277. const supplierList = ref<SupplierVO[]>([]) // 供应商列表
  278. const userList = ref<UserVO[]>([]) // 用户列表
  279. /** 查询列表 */
  280. const getList = async () => {
  281. loading.value = true
  282. try {
  283. const data = await StockInApi.getStockInPage(queryParams)
  284. list.value = data.list
  285. total.value = data.total
  286. } finally {
  287. loading.value = false
  288. }
  289. }
  290. /** 搜索按钮操作 */
  291. const handleQuery = () => {
  292. queryParams.pageNo = 1
  293. getList()
  294. }
  295. /** 重置按钮操作 */
  296. const resetQuery = () => {
  297. queryFormRef.value.resetFields()
  298. handleQuery()
  299. }
  300. /** 添加/修改操作 */
  301. const formRef = ref()
  302. const openForm = (type: string, id?: number) => {
  303. formRef.value.open(type, id)
  304. }
  305. /** 删除按钮操作 */
  306. const handleDelete = async (ids: number[]) => {
  307. try {
  308. // 删除的二次确认
  309. await message.delConfirm()
  310. // 发起删除
  311. await StockInApi.deleteStockIn(ids)
  312. message.success(t('common.delSuccess'))
  313. // 刷新列表
  314. await getList()
  315. selectionList.value = selectionList.value.filter((item) => !ids.includes(item.id))
  316. } catch {}
  317. }
  318. /** 审批/反审批操作 */
  319. const handleUpdateStatus = async (id: number, status: number) => {
  320. try {
  321. // 审批的二次确认
  322. await message.confirm(`确定${status === 20 ? '审批' : '反审批'}该入库单吗?`)
  323. // 发起审批
  324. await StockInApi.updateStockInStatus(id, status)
  325. message.success(`${status === 20 ? '审批' : '反审批'}成功`)
  326. // 刷新列表
  327. await getList()
  328. } catch {}
  329. }
  330. /** 导出按钮操作 */
  331. const handleExport = async () => {
  332. try {
  333. // 导出的二次确认
  334. await message.exportConfirm()
  335. // 发起导出
  336. exportLoading.value = true
  337. const data = await StockInApi.exportStockIn(queryParams)
  338. download.excel(data, '其它入库单.xls')
  339. } catch {
  340. } finally {
  341. exportLoading.value = false
  342. }
  343. }
  344. /** 选中操作 */
  345. const selectionList = ref<StockInVO[]>([])
  346. const handleSelectionChange = (rows: StockInVO[]) => {
  347. selectionList.value = rows
  348. }
  349. /** 初始化 **/
  350. onMounted(async () => {
  351. await getList()
  352. // 加载产品、仓库列表、供应商
  353. productList.value = await ProductApi.getProductSimpleList()
  354. warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
  355. supplierList.value = await SupplierApi.getSupplierSimpleList()
  356. userList.value = await UserApi.getSimpleUserList()
  357. })
  358. // TODO 芋艿:可优化功能:列表界面,支持导入
  359. // TODO 芋艿:可优化功能:详情界面,支持打印
  360. </script>