index.vue 10 KB

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