index.vue 11 KB

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