index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="90px"
  10. >
  11. <el-form-item label="领用单编号" prop="requisitionNumber">
  12. <el-input
  13. v-model="queryParams.requisitionNumber"
  14. placeholder="请输入物料领用单编号"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="领用日期" prop="requisitionTime">
  21. <el-date-picker
  22. v-model="queryParams.requisitionTime"
  23. value-format="YYYY-MM-DD HH:mm:ss"
  24. type="daterange"
  25. start-placeholder="开始日期"
  26. end-placeholder="结束日期"
  27. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  28. class="!w-220px"
  29. />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  33. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  34. <el-button
  35. type="primary"
  36. plain
  37. @click="openForm('create')"
  38. v-hasPermi="['pms:iot-material-requisition:create']"
  39. >
  40. <Icon icon="ep:plus" class="mr-5px" /> 新增
  41. </el-button>
  42. <el-button
  43. type="success"
  44. plain
  45. @click="handleExport"
  46. :loading="exportLoading"
  47. v-hasPermi="['pms:iot-material-requisition:export']"
  48. >
  49. <Icon icon="ep:download" class="mr-5px" /> 导出
  50. </el-button>
  51. </el-form-item>
  52. </el-form>
  53. </ContentWrap>
  54. <!-- 列表 -->
  55. <ContentWrap>
  56. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  57. <el-table-column label="领用单编号" align="center" prop="requisitionNumber" />
  58. <el-table-column label="领用单名称" align="center" prop="name" />
  59. <el-table-column label="领用人姓名" align="center" prop="responsiblePerson" />
  60. <el-table-column label="总费用" align="center" prop="cost" />
  61. <el-table-column
  62. label="领用日期"
  63. align="center"
  64. prop="requisitionTime"
  65. :formatter="dateFormatter"
  66. width="180px"
  67. />
  68. <el-table-column label="操作" align="center" min-width="120px">
  69. <template #default="scope">
  70. <el-button
  71. link
  72. type="primary"
  73. @click="detail(scope.row.id)"
  74. v-hasPermi="['pms:iot-material-requisition:query']"
  75. >
  76. {{ t('operationFill.view') }}
  77. </el-button>
  78. <el-button
  79. link
  80. type="primary"
  81. @click="openForm('update', scope.row.id)"
  82. v-hasPermi="['pms:iot-material-requisition:update']"
  83. >
  84. 编辑
  85. </el-button>
  86. <el-button
  87. link
  88. type="danger"
  89. @click="handleDelete(scope.row.id)"
  90. v-hasPermi="['pms:iot-material-requisition:delete']"
  91. >
  92. 删除
  93. </el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <!-- 分页 -->
  98. <Pagination
  99. :total="total"
  100. v-model:page="queryParams.pageNo"
  101. v-model:limit="queryParams.pageSize"
  102. @pagination="getList"
  103. />
  104. </ContentWrap>
  105. <!-- 表单弹窗:添加/修改 -->
  106. <IotMaterialRequisitionForm ref="formRef" @success="getList" />
  107. </template>
  108. <script setup lang="ts">
  109. import { dateFormatter } from '@/utils/formatTime'
  110. import download from '@/utils/download'
  111. import { IotMaterialRequisitionApi, IotMaterialRequisitionVO } from '@/api/pms/iotmaterialrequisition'
  112. import IotMaterialRequisitionForm from './IotMaterialRequisitionForm.vue'
  113. const { push } = useRouter() // 路由跳转
  114. /** 物料领用 列表 */
  115. defineOptions({ name: 'IotMaterialRequisition' })
  116. const message = useMessage() // 消息弹窗
  117. const { t } = useI18n() // 国际化
  118. const loading = ref(true) // 列表的加载中
  119. const list = ref<IotMaterialRequisitionVO[]>([]) // 列表的数据
  120. const total = ref(0) // 列表的总页数
  121. const queryParams = reactive({
  122. pageNo: 1,
  123. pageSize: 10,
  124. deptId: undefined,
  125. requisitionNumber: undefined,
  126. name: undefined,
  127. type: undefined,
  128. responsiblePerson: undefined,
  129. cost: undefined,
  130. result: undefined,
  131. otherCost: undefined,
  132. laborCost: undefined,
  133. requisitionTime: [],
  134. reason: undefined,
  135. remark: undefined,
  136. status: undefined,
  137. processInstanceId: undefined,
  138. auditStatus: undefined,
  139. createTime: [],
  140. })
  141. const queryFormRef = ref() // 搜索的表单
  142. const exportLoading = ref(false) // 导出的加载中
  143. /** 查询列表 */
  144. const getList = async () => {
  145. loading.value = true
  146. try {
  147. const data = await IotMaterialRequisitionApi.getIotMaterialRequisitionPage(queryParams)
  148. list.value = data.list
  149. total.value = data.total
  150. } finally {
  151. loading.value = false
  152. }
  153. }
  154. /** 搜索按钮操作 */
  155. const handleQuery = () => {
  156. queryParams.pageNo = 1
  157. getList()
  158. }
  159. /** 重置按钮操作 */
  160. const resetQuery = () => {
  161. queryFormRef.value.resetFields()
  162. handleQuery()
  163. }
  164. /** 添加/修改操作 */
  165. const formRef = ref()
  166. /* const openForm = (type: string, id?: number) => {
  167. formRef.value.open(type, id)
  168. } */
  169. const openForm = (type: string, id?: number) => {
  170. // 修改
  171. if (typeof id === 'number') {
  172. push({ name: 'IotMaterialRequisitionEdit', params: {id } })
  173. return
  174. } else {
  175. // 新增
  176. push({ name: 'IotMaterialRequisitionAdd', params:{} })
  177. }
  178. }
  179. const detail = (id?: number) => {
  180. push({ name: 'IotMaterialReqDetail', params:{id} })
  181. }
  182. /** 删除按钮操作 */
  183. const handleDelete = async (id: number) => {
  184. try {
  185. // 删除的二次确认
  186. await message.delConfirm()
  187. // 发起删除
  188. await IotMaterialRequisitionApi.deleteIotMaterialRequisition(id)
  189. message.success(t('common.delSuccess'))
  190. // 刷新列表
  191. await getList()
  192. } catch {}
  193. }
  194. /** 导出按钮操作 */
  195. const handleExport = async () => {
  196. try {
  197. // 导出的二次确认
  198. await message.exportConfirm()
  199. // 发起导出
  200. exportLoading.value = true
  201. const data = await IotMaterialRequisitionApi.exportIotMaterialRequisition(queryParams)
  202. download.excel(data, '物料领用.xls')
  203. } catch {
  204. } finally {
  205. exportLoading.value = false
  206. }
  207. }
  208. /** 初始化 **/
  209. onMounted(() => {
  210. getList()
  211. })
  212. </script>