index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="出库单号" prop="no">
  12. <el-input
  13. v-model="queryParams.no"
  14. placeholder="请输入出库单号"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="产品" prop="productId">
  21. <el-select
  22. v-model="queryParams.productId"
  23. clearable
  24. filterable
  25. placeholder="请选择产品"
  26. class="!w-240px"
  27. >
  28. <el-option
  29. v-for="item in productList"
  30. :key="item.id"
  31. :label="item.name"
  32. :value="item.id"
  33. />
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="出库时间" prop="outTime">
  37. <el-date-picker
  38. v-model="queryParams.outTime"
  39. value-format="YYYY-MM-DD HH:mm:ss"
  40. type="daterange"
  41. start-placeholder="开始日期"
  42. end-placeholder="结束日期"
  43. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  44. class="!w-240px"
  45. />
  46. </el-form-item>
  47. <el-form-item label="客户" prop="customerId">
  48. <el-select
  49. v-model="queryParams.customerId"
  50. clearable
  51. filterable
  52. placeholder="请选择供客户"
  53. class="!w-240px"
  54. >
  55. <el-option
  56. v-for="item in customerList"
  57. :key="item.id"
  58. :label="item.name"
  59. :value="item.id"
  60. />
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item label="仓库" prop="warehouseId">
  64. <el-select
  65. v-model="queryParams.warehouseId"
  66. clearable
  67. filterable
  68. placeholder="请选择仓库"
  69. class="!w-240px"
  70. >
  71. <el-option
  72. v-for="item in warehouseList"
  73. :key="item.id"
  74. :label="item.name"
  75. :value="item.id"
  76. />
  77. </el-select>
  78. </el-form-item>
  79. <el-form-item label="创建人" prop="creator">
  80. <el-select
  81. v-model="queryParams.creator"
  82. clearable
  83. filterable
  84. placeholder="请选择创建人"
  85. class="!w-240px"
  86. >
  87. <el-option
  88. v-for="item in userList"
  89. :key="item.id"
  90. :label="item.nickname"
  91. :value="item.id"
  92. />
  93. </el-select>
  94. </el-form-item>
  95. <el-form-item label="状态" prop="status">
  96. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
  97. <el-option
  98. v-for="dict in getIntDictOptions(DICT_TYPE.ERP_AUDIT_STATUS)"
  99. :key="dict.value"
  100. :label="dict.label"
  101. :value="dict.value"
  102. />
  103. </el-select>
  104. </el-form-item>
  105. <el-form-item label="备注" prop="remark">
  106. <el-input
  107. v-model="queryParams.remark"
  108. placeholder="请输入备注"
  109. clearable
  110. @keyup.enter="handleQuery"
  111. class="!w-240px"
  112. />
  113. </el-form-item>
  114. <el-form-item>
  115. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  116. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  117. <el-button
  118. type="primary"
  119. plain
  120. @click="openForm('create')"
  121. v-hasPermi="['erp:stock-out:create']"
  122. >
  123. <Icon icon="ep:plus" class="mr-5px" /> 新增
  124. </el-button>
  125. <el-button
  126. type="success"
  127. plain
  128. @click="handleExport"
  129. :loading="exportLoading"
  130. v-hasPermi="['erp:stock-out:export']"
  131. >
  132. <Icon icon="ep:download" class="mr-5px" /> 导出
  133. </el-button>
  134. <el-button
  135. type="danger"
  136. plain
  137. @click="handleDelete(selectionList.map((item) => item.id))"
  138. v-hasPermi="['erp:stock-out:delete']"
  139. :disabled="selectionList.length === 0"
  140. >
  141. <Icon icon="ep:delete" class="mr-5px" /> 删除
  142. </el-button>
  143. </el-form-item>
  144. </el-form>
  145. </ContentWrap>
  146. <!-- 列表 -->
  147. <ContentWrap>
  148. <el-table
  149. v-loading="loading"
  150. :data="list"
  151. :stripe="true"
  152. :show-overflow-tooltip="true"
  153. @selection-change="handleSelectionChange"
  154. >
  155. <el-table-column width="30" label="选择" type="selection" />
  156. <el-table-column min-width="180" label="出库单号" align="center" prop="no" />
  157. <el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
  158. <el-table-column label="客户" align="center" prop="customerName" />
  159. <el-table-column
  160. label="出库时间"
  161. align="center"
  162. prop="outTime"
  163. :formatter="dateFormatter2"
  164. width="120px"
  165. />
  166. <el-table-column label="创建人" align="center" prop="creatorName" />
  167. <el-table-column
  168. label="数量"
  169. align="center"
  170. prop="totalCount"
  171. :formatter="erpCountTableColumnFormatter"
  172. />
  173. <el-table-column
  174. label="金额"
  175. align="center"
  176. prop="totalPrice"
  177. :formatter="erpPriceTableColumnFormatter"
  178. />
  179. <el-table-column label="状态" align="center" fixed="right" width="90" prop="status">
  180. <template #default="scope">
  181. <dict-tag :type="DICT_TYPE.ERP_AUDIT_STATUS" :value="scope.row.status" />
  182. </template>
  183. </el-table-column>
  184. <el-table-column label="操作" align="center" fixed="right" width="220">
  185. <template #default="scope">
  186. <el-button
  187. link
  188. @click="openForm('detail', scope.row.id)"
  189. v-hasPermi="['erp:stock-out:query']"
  190. >
  191. 详情
  192. </el-button>
  193. <el-button
  194. link
  195. type="primary"
  196. @click="openForm('update', scope.row.id)"
  197. v-hasPermi="['erp:stock-out:update']"
  198. :disabled="scope.row.status === 20"
  199. >
  200. 编辑
  201. </el-button>
  202. <el-button
  203. link
  204. type="primary"
  205. @click="handleUpdateStatus(scope.row.id, 20)"
  206. v-hasPermi="['erp:stock-out:update-status']"
  207. v-if="scope.row.status === 10"
  208. >
  209. 审批
  210. </el-button>
  211. <el-button
  212. link
  213. type="danger"
  214. @click="handleUpdateStatus(scope.row.id, 10)"
  215. v-hasPermi="['erp:stock-out:update-status']"
  216. v-else
  217. >
  218. 反审批
  219. </el-button>
  220. <el-button
  221. link
  222. type="danger"
  223. @click="handleDelete([scope.row.id])"
  224. v-hasPermi="['erp:stock-out:delete']"
  225. >
  226. 删除
  227. </el-button>
  228. </template>
  229. </el-table-column>
  230. </el-table>
  231. <!-- 分页 -->
  232. <Pagination
  233. :total="total"
  234. v-model:page="queryParams.pageNo"
  235. v-model:limit="queryParams.pageSize"
  236. @pagination="getList"
  237. />
  238. </ContentWrap>
  239. <!-- 表单弹窗:添加/修改 -->
  240. <StockOutForm ref="formRef" @success="getList" />
  241. </template>
  242. <script setup lang="ts">
  243. import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
  244. import { dateFormatter2 } from '@/utils/formatTime'
  245. import download from '@/utils/download'
  246. import { StockOutApi, StockOutVO } from '@/api/erp/stock/out'
  247. import StockOutForm from './StockOutForm.vue'
  248. import { ProductApi, ProductVO } from '@/api/erp/product/product'
  249. import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
  250. import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
  251. import { UserVO } from '@/api/system/user'
  252. import * as UserApi from '@/api/system/user'
  253. import { erpCountTableColumnFormatter, erpPriceTableColumnFormatter } from '@/utils'
  254. import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
  255. /** ERP 其它出库单列表 */
  256. defineOptions({ name: 'ErpStockOut' })
  257. const message = useMessage() // 消息弹窗
  258. const { t } = useI18n() // 国际化
  259. const loading = ref(true) // 列表的加载中
  260. const list = ref<StockOutVO[]>([]) // 列表的数据
  261. const total = ref(0) // 列表的总页数
  262. const queryParams = reactive({
  263. pageNo: 1,
  264. pageSize: 10,
  265. no: undefined,
  266. productId: undefined,
  267. customerId: undefined,
  268. outTime: [],
  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 customerList = ref<CustomerVO[]>([]) // 客户列表
  278. const userList = ref<UserVO[]>([]) // 用户列表
  279. /** 查询列表 */
  280. const getList = async () => {
  281. loading.value = true
  282. try {
  283. const data = await StockOutApi.getStockOutPage(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 StockOutApi.deleteStockOut(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 StockOutApi.updateStockOutStatus(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 StockOutApi.exportStockOut(queryParams)
  338. download.excel(data, '其它出库单.xls')
  339. } catch {
  340. } finally {
  341. exportLoading.value = false
  342. }
  343. }
  344. /** 选中操作 */
  345. const selectionList = ref<StockOutVO[]>([])
  346. const handleSelectionChange = (rows: StockOutVO[]) => {
  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. customerList.value = await CustomerApi.getCustomerSimpleList()
  356. userList.value = await UserApi.getSimpleUserList()
  357. })
  358. // TODO 芋艿:可优化功能:列表界面,支持导入
  359. // TODO 芋艿:可优化功能:详情界面,支持打印
  360. </script>