index.vue 10 KB

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