index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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="outTime">
  38. <el-date-picker
  39. v-model="queryParams.outTime"
  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-240px"
  46. />
  47. </el-form-item>
  48. <el-form-item label="客户" prop="customerId">
  49. <el-select
  50. v-model="queryParams.customerId"
  51. clearable
  52. filterable
  53. placeholder="请选择供客户"
  54. class="!w-240px"
  55. >
  56. <el-option
  57. v-for="item in customerList"
  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-out: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-out: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-out: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="customerName" />
  160. <el-table-column
  161. label="出库时间"
  162. align="center"
  163. prop="outTime"
  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-out: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-out: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-out: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-out: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-out: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. <StockOutForm 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 { StockOutApi, StockOutVO } from '@/api/erp/stock/out'
  248. import StockOutForm from './StockOutForm.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. import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
  256. /** ERP 其它出库单列表 */
  257. defineOptions({ name: 'ErpStockOut' })
  258. const message = useMessage() // 消息弹窗
  259. const { t } = useI18n() // 国际化
  260. const loading = ref(true) // 列表的加载中
  261. const list = ref<StockOutVO[]>([]) // 列表的数据
  262. const total = ref(0) // 列表的总页数
  263. const queryParams = reactive({
  264. pageNo: 1,
  265. pageSize: 10,
  266. no: undefined,
  267. productId: undefined,
  268. customerId: undefined,
  269. warehouseId: undefined,
  270. outTime: [],
  271. status: undefined,
  272. remark: undefined,
  273. creator: undefined
  274. })
  275. const queryFormRef = ref() // 搜索的表单
  276. const exportLoading = ref(false) // 导出的加载中
  277. const productList = ref<ProductVO[]>([]) // 产品列表
  278. const warehouseList = ref<WarehouseVO[]>([]) // 仓库列表
  279. const customerList = ref<CustomerVO[]>([]) // 客户列表
  280. const userList = ref<UserVO[]>([]) // 用户列表
  281. /** 查询列表 */
  282. const getList = async () => {
  283. loading.value = true
  284. try {
  285. const data = await StockOutApi.getStockOutPage(queryParams)
  286. list.value = data.list
  287. total.value = data.total
  288. } finally {
  289. loading.value = false
  290. }
  291. }
  292. /** 搜索按钮操作 */
  293. const handleQuery = () => {
  294. queryParams.pageNo = 1
  295. getList()
  296. }
  297. /** 重置按钮操作 */
  298. const resetQuery = () => {
  299. queryFormRef.value.resetFields()
  300. handleQuery()
  301. }
  302. /** 添加/修改操作 */
  303. const formRef = ref()
  304. const openForm = (type: string, id?: number) => {
  305. formRef.value.open(type, id)
  306. }
  307. /** 删除按钮操作 */
  308. const handleDelete = async (ids: number[]) => {
  309. try {
  310. // 删除的二次确认
  311. await message.delConfirm()
  312. // 发起删除
  313. await StockOutApi.deleteStockOut(ids)
  314. message.success(t('common.delSuccess'))
  315. // 刷新列表
  316. await getList()
  317. selectionList.value = selectionList.value.filter((item) => !ids.includes(item.id))
  318. } catch {}
  319. }
  320. /** 审批/反审批操作 */
  321. const handleUpdateStatus = async (id: number, status: number) => {
  322. try {
  323. // 审批的二次确认
  324. await message.confirm(`确定${status === 20 ? '审批' : '反审批'}该出库单吗?`)
  325. // 发起审批
  326. await StockOutApi.updateStockOutStatus(id, status)
  327. message.success(`${status === 20 ? '审批' : '反审批'}成功`)
  328. // 刷新列表
  329. await getList()
  330. } catch {}
  331. }
  332. /** 导出按钮操作 */
  333. const handleExport = async () => {
  334. try {
  335. // 导出的二次确认
  336. await message.exportConfirm()
  337. // 发起导出
  338. exportLoading.value = true
  339. const data = await StockOutApi.exportStockOut(queryParams)
  340. download.excel(data, '其它出库单.xls')
  341. } catch {
  342. } finally {
  343. exportLoading.value = false
  344. }
  345. }
  346. /** 选中操作 */
  347. const selectionList = ref<StockOutVO[]>([])
  348. const handleSelectionChange = (rows: StockOutVO[]) => {
  349. selectionList.value = rows
  350. }
  351. /** 初始化 **/
  352. onMounted(async () => {
  353. await getList()
  354. // 加载产品、仓库列表、客户
  355. productList.value = await ProductApi.getProductSimpleList()
  356. warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
  357. customerList.value = await CustomerApi.getCustomerSimpleList()
  358. userList.value = await UserApi.getSimpleUserList()
  359. })
  360. // TODO 芋艿:可优化功能:列表界面,支持导入
  361. // TODO 芋艿:可优化功能:详情界面,支持打印
  362. </script>