index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <el-row :gutter="20">
  3. <!-- 左侧部门树 -->
  4. <el-col :span="4" :xs="24">
  5. <ContentWrap class="h-1/1">
  6. <DeptTree @node-click="handleDeptNodeClick" />
  7. </ContentWrap>
  8. </el-col>
  9. <el-col :span="20" :xs="24">
  10. <ContentWrap>
  11. <!-- 搜索工作栏 -->
  12. <el-form
  13. class="-mb-15px"
  14. :model="queryParams"
  15. ref="queryFormRef"
  16. :inline="true"
  17. label-width="68px"
  18. >
  19. <el-form-item label="资产编码" prop="deviceCode">
  20. <el-input
  21. v-model="queryParams.deviceCode"
  22. placeholder="请输入资产编码"
  23. clearable
  24. @keyup.enter="handleQuery"
  25. class="!w-200px"
  26. />
  27. </el-form-item>
  28. <el-form-item label="设备名称" prop="deviceName">
  29. <el-input
  30. v-model="queryParams.deviceName"
  31. placeholder="请输入设备名称"
  32. clearable
  33. @keyup.enter="handleQuery"
  34. class="!w-200px"
  35. />
  36. </el-form-item>
  37. <el-form-item label="品牌" prop="brand">
  38. <el-input
  39. v-model="queryParams.brand"
  40. placeholder="请输入品牌"
  41. clearable
  42. @keyup.enter="handleQuery"
  43. class="!w-200px"
  44. />
  45. </el-form-item>
  46. <el-form-item v-show="ifShow" label="设备状态" label-width="85px" prop="deviceStatus">
  47. <el-select
  48. v-model="queryParams.deviceStatus"
  49. placeholder="设备状态"
  50. clearable
  51. class="!w-240px"
  52. >
  53. <el-option
  54. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_DEVICE_STATUS)"
  55. :key="dict.value"
  56. :label="dict.label"
  57. :value="dict.value"
  58. />
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item v-show="ifShow" label="资产性质" prop="assetProperty">
  62. <el-select
  63. v-model="queryParams.assetProperty"
  64. placeholder="资产性质"
  65. clearable
  66. class="!w-240px"
  67. >
  68. <el-option
  69. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_ASSET_PROPERTY)"
  70. :key="dict.value"
  71. :label="dict.label"
  72. :value="dict.value"
  73. />
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item>
  77. <el-button v-if="!ifShow" @click="moreQuery(true)" type="warning"><Icon icon="ep:search" class="mr-5px"/> 更多查询</el-button>
  78. <el-button v-if="ifShow" @click="moreQuery(false)" type="danger"><Icon icon="ep:search" class="mr-5px"/> 收起查询</el-button>
  79. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  80. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  81. <el-button
  82. type="primary"
  83. plain
  84. @click="openForm('create',undefined,queryParams.deptId)"
  85. v-hasPermi="['rq:iot-device:create']"
  86. >
  87. <Icon icon="ep:plus" class="mr-5px" /> 新增
  88. </el-button>
  89. <el-button
  90. type="success"
  91. plain
  92. @click="handleExport"
  93. :loading="exportLoading"
  94. v-hasPermi="['rq:iot-device:export']"
  95. >
  96. <Icon icon="ep:download" class="mr-5px" /> 导出
  97. </el-button>
  98. </el-form-item>
  99. </el-form>
  100. </ContentWrap>
  101. <!-- 列表 -->
  102. <ContentWrap>
  103. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  104. <el-table-column label="资产编码" align="center" prop="deviceCode" />
  105. <el-table-column label="设备名称" align="center" prop="deviceName" >
  106. <template #default="scope">
  107. <el-link :underline="false" type="primary" @click="handleDetail(scope.row.id)">
  108. {{ scope.row.deviceName }}
  109. </el-link>
  110. </template>
  111. <!-- <template #default="{ row }">-->
  112. <!-- <div class="custom-cell">{{ row.deviceName }}</div>-->
  113. <!-- </template>-->
  114. </el-table-column>
  115. <el-table-column label="所在部门" align="center" prop="deptName" />
  116. <el-table-column label="设备状态" align="center" prop="deviceStatus">
  117. <template #default="scope">
  118. <dict-tag :type="DICT_TYPE.PMS_DEVICE_STATUS" :value="scope.row.deviceStatus" />
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="资产性质" align="center" prop="assetProperty">
  122. <template #default="scope">
  123. <dict-tag :type="DICT_TYPE.PMS_ASSET_PROPERTY" :value="scope.row.assetProperty" />
  124. </template>
  125. </el-table-column>
  126. <el-form-item label="创建时间" prop="createTime">
  127. <el-date-picker
  128. v-model="queryParams.createTime"
  129. value-format="YYYY-MM-DD HH:mm:ss"
  130. type="daterange"
  131. start-placeholder="开始日期"
  132. end-placeholder="结束日期"
  133. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  134. class="!w-240px"
  135. />
  136. </el-form-item>
  137. <el-table-column
  138. label="创建时间"
  139. align="center"
  140. prop="createTime"
  141. :formatter="dateFormatter"
  142. width="180px"
  143. />
  144. <el-table-column label="操作" align="center" min-width="120px">
  145. <template #default="scope">
  146. <el-button
  147. link
  148. type="primary"
  149. @click="openForm('update', scope.row.id)"
  150. v-hasPermi="['rq:iot-device:update']"
  151. >
  152. 编辑
  153. </el-button>
  154. <el-button
  155. link
  156. type="danger"
  157. @click="handleDelete(scope.row.id)"
  158. v-hasPermi="['rq:iot-device:delete']"
  159. >
  160. 删除
  161. </el-button>
  162. <el-button
  163. link
  164. type="warning"
  165. @click="handleUpload(scope.row.id)"
  166. >
  167. 资料上传
  168. </el-button>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. <!-- 分页 -->
  173. <Pagination
  174. :total="total"
  175. v-model:page="queryParams.pageNo"
  176. v-model:limit="queryParams.pageSize"
  177. @pagination="getList"
  178. />
  179. </ContentWrap>
  180. </el-col>
  181. </el-row>
  182. <!-- 表单弹窗:添加/修改 -->
  183. <!-- <IotDeviceForm ref="formRef" @success="getList" />-->
  184. </template>
  185. <script setup lang="ts">
  186. import download from '@/utils/download'
  187. import { IotDeviceApi, IotDeviceVO } from '@/api/pms/device'
  188. import IotDeviceForm from './IotDeviceForm.vue'
  189. import {DICT_TYPE, getIntDictOptions, getStrDictOptions} from "@/utils/dict";
  190. import {dateFormatter} from "@/utils/formatTime";
  191. import PmsTree from "@/views/system/tree/PmsTree.vue";
  192. import DeptTree from "@/views/system/user/DeptTree.vue";
  193. import {CACHE_KEY, useCache} from "@/hooks/web/useCache";
  194. /** 设备台账 列表 */
  195. defineOptions({ name: 'IotDevicePms' })
  196. const message = useMessage() // 消息弹窗
  197. const { t } = useI18n() // 国际化
  198. const { push } = useRouter() // 路由跳转
  199. const loading = ref(true) // 列表的加载中
  200. const ifShow = ref(false)
  201. const isDetail = ref(false) // 是否查看详情
  202. const list = ref<IotDeviceVO[]>([]) // 列表的数据
  203. const total = ref(0) // 列表的总页数
  204. const queryParams = reactive({
  205. pageNo: 1,
  206. pageSize: 10,
  207. deviceCode: undefined,
  208. deviceName: undefined,
  209. brand: undefined,
  210. model: undefined,
  211. deptId: undefined,
  212. deviceStatus: undefined,
  213. assetProperty: undefined,
  214. picUrl: undefined,
  215. remark: undefined,
  216. manufacturerId: undefined,
  217. supplierId: undefined,
  218. manDate: [],
  219. nameplate: undefined,
  220. expires: undefined,
  221. plPrice: undefined,
  222. plDate: [],
  223. plYear: undefined,
  224. plStartDate: [],
  225. plMonthed: undefined,
  226. plAmounted: undefined,
  227. remainAmount: undefined,
  228. infoId: undefined,
  229. infoType: undefined,
  230. infoName: undefined,
  231. infoRemark: undefined,
  232. infoUrl: undefined,
  233. templateJson: undefined,
  234. creator: undefined
  235. })
  236. const queryFormRef = ref() // 搜索的表单
  237. const exportLoading = ref(false) // 导出的加载中
  238. /** 查询列表 */
  239. const getList = async () => {
  240. loading.value = true
  241. try {
  242. const data = await IotDeviceApi.getIotDevicePage(queryParams)
  243. list.value = data.list
  244. total.value = data.total
  245. } finally {
  246. loading.value = false
  247. }
  248. }
  249. /** 处理部门被点击 */
  250. const handleDeptNodeClick = async (row) => {
  251. queryParams.deptId = row.id
  252. await getList()
  253. }
  254. /** 搜索按钮操作 */
  255. const handleQuery = () => {
  256. queryParams.pageNo = 1
  257. getList()
  258. }
  259. const moreQuery = (show) => {
  260. ifShow.value = show
  261. }
  262. /** 重置按钮操作 */
  263. const resetQuery = () => {
  264. queryFormRef.value.resetFields()
  265. handleQuery()
  266. }
  267. /** 添加/修改操作 */
  268. const formRef = ref()
  269. const openForm = (type: string, id?: number) => {
  270. //修改
  271. debugger
  272. if (typeof id === 'number') {
  273. push({ name: 'DeviceDetailEdit', params: {id } })
  274. return
  275. }
  276. // 新增
  277. push({ name: 'DeviceDetailAdd', params:{} })
  278. }
  279. /** 删除按钮操作 */
  280. const handleDelete = async (id: number) => {
  281. try {
  282. // 删除的二次确认
  283. await message.delConfirm()
  284. // 发起删除
  285. await IotDeviceApi.deleteIotDevice(id)
  286. message.success(t('common.delSuccess'))
  287. // 刷新列表
  288. await getList()
  289. } catch {}
  290. }
  291. const handleDetail = (id: number) => {
  292. push({ name: 'DeviceDetailInfo', params:{id} })
  293. }
  294. const handleUpload = (id: number) => {
  295. push({ name: 'DeviceUpload', params:{id} })
  296. }
  297. /** 导出按钮操作 */
  298. const handleExport = async () => {
  299. try {
  300. // 导出的二次确认
  301. await message.exportConfirm()
  302. // 发起导出
  303. exportLoading.value = true
  304. const data = await IotDeviceApi.exportIotDevice(queryParams)
  305. download.excel(data, '设备台账.xls')
  306. } catch {
  307. } finally {
  308. exportLoading.value = false
  309. }
  310. }
  311. const { wsCache } = useCache()
  312. /** 初始化 **/
  313. onMounted(() => {
  314. const user = wsCache.get(CACHE_KEY.USER)
  315. queryParams.deptId = user.user.deptId
  316. getList()
  317. })
  318. </script>
  319. <style scoped>
  320. </style>