index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <el-row :gutter="20">
  3. <el-col :span="4" :xs="24">
  4. <ContentWrap class="h-1/1">
  5. <DeptTree @node-click="handleDeptNodeClick" />
  6. </ContentWrap>
  7. </el-col>
  8. <el-col :span="20" :xs="24">
  9. <ContentWrap>
  10. <!-- 搜索工作栏 -->
  11. <el-form
  12. class="-mb-15px"
  13. :model="queryParams"
  14. ref="queryFormRef"
  15. :inline="true"
  16. label-width="68px"
  17. >
  18. <el-form-item :label="t('bomList.name')" prop="inspectOrderTitle">
  19. <el-input
  20. v-model="queryParams.inspectOrderTitle"
  21. :placeholder="t('bomList.nHolder')"
  22. clearable
  23. @keyup.enter="handleQuery"
  24. class="!w-240px"
  25. />
  26. </el-form-item>
  27. <!-- <el-form-item label="工单编码" prop="inspectOrderCode">-->
  28. <!-- <el-input-->
  29. <!-- v-model="queryParams.inspectOrderCode"-->
  30. <!-- placeholder="请输入工单编码"-->
  31. <!-- clearable-->
  32. <!-- @keyup.enter="handleQuery"-->
  33. <!-- class="!w-240px"-->
  34. <!-- />-->
  35. <!-- </el-form-item>-->
  36. <el-form-item :label="t('operationFill.status')" prop="status">
  37. <el-select
  38. v-model="queryParams.status"
  39. :placeholder="t('operationFill.status')"
  40. clearable
  41. class="!w-240px"
  42. >
  43. <el-option
  44. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_INSPECT_ORDER_STATUS)"
  45. :key="dict.value"
  46. :label="dict.label"
  47. :value="dict.value"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <!-- <el-form-item label="创建时间" prop="createTime">-->
  52. <!-- <el-date-picker-->
  53. <!-- v-model="queryParams.createTime"-->
  54. <!-- value-format="YYYY-MM-DD HH:mm:ss"-->
  55. <!-- type="daterange"-->
  56. <!-- start-placeholder="开始日期"-->
  57. <!-- end-placeholder="结束日期"-->
  58. <!-- :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"-->
  59. <!-- class="!w-220px"-->
  60. <!-- />-->
  61. <!-- </el-form-item>-->
  62. <el-form-item>
  63. <el-button @click="handleQuery"
  64. ><Icon icon="ep:search" class="mr-5px" />
  65. {{ t('operationFill.search') }}</el-button
  66. >
  67. <el-button @click="resetQuery"
  68. ><Icon icon="ep:refresh" class="mr-5px" /> {{ t('operationFill.reset') }}</el-button
  69. >
  70. <!-- <el-button-->
  71. <!-- type="primary"-->
  72. <!-- plain-->
  73. <!-- @click="openForm('create')"-->
  74. <!-- v-hasPermi="['rq:iot-inspect-order:create']"-->
  75. <!-- >-->
  76. <!-- <Icon icon="ep:plus" class="mr-5px" /> 新增-->
  77. <!-- </el-button>-->
  78. <el-button
  79. type="success"
  80. plain
  81. @click="handleExport"
  82. :loading="exportLoading"
  83. v-hasPermi="['rq:iot-inspect-order:export']"
  84. >
  85. <Icon icon="ep:download" class="mr-5px" /> 导出
  86. </el-button>
  87. </el-form-item>
  88. </el-form>
  89. </ContentWrap>
  90. <!-- 列表 -->
  91. <ContentWrap>
  92. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  93. <el-table-column :label="t('iotDevice.serial')" width="70" align="center">
  94. <template #default="scope">
  95. {{ scope.$index + 1 }}
  96. </template>
  97. </el-table-column>
  98. <el-table-column :label="t('bomList.name')" align="center" prop="inspectOrderTitle" />
  99. <!-- <el-table-column label="工单编码" align="center" prop="inspectOrderCode" />-->
  100. <el-table-column :label="t('route.orderType')" align="center" prop="type" />
  101. <el-table-column :label="t('operationFill.status')" align="center" prop="status">
  102. <template #default="scope">
  103. <dict-tag :type="DICT_TYPE.PMS_INSPECT_ORDER_STATUS" :value="scope.row.status" />
  104. </template>
  105. </el-table-column>
  106. <el-table-column :label="t('iotMaintain.PersonInCharge')" align="center" prop="chargeName" />
  107. <!-- <el-table-column label="备注" align="center" prop="remark" />-->
  108. <el-table-column
  109. label="生成时间"
  110. align="center"
  111. prop="createTime"
  112. :formatter="dateFormatter"
  113. width="180px"
  114. />
  115. <el-table-column :label="t('iotMaintain.operation')" align="center" min-width="120px">
  116. <template #default="scope">
  117. <!-- <el-button-->
  118. <!-- link-->
  119. <!-- type="primary"-->
  120. <!-- @click="openForm('update', scope.row.id)"-->
  121. <!-- v-hasPermi="['rq:iot-inspect-order:update']"-->
  122. <!-- >-->
  123. <!-- 编辑-->
  124. <!-- </el-button>-->
  125. <!-- <el-button-->
  126. <!-- link-->
  127. <!-- type="danger"-->
  128. <!-- @click="handleDelete(scope.row.id)"-->
  129. <!-- v-hasPermi="['rq:iot-inspect-order:delete']"-->
  130. <!-- >-->
  131. <!-- 删除-->
  132. <!-- </el-button>-->
  133. <el-button link type="primary" @click="openForm(scope.row.id)"> {{ t('operationFill.view') }} </el-button>
  134. <el-button
  135. v-if="scope.row.status === 'todo'"
  136. link
  137. type="primary"
  138. @click="openWrite(scope.row.id)"
  139. v-hasPermi="['rq:iot-inspect-order:update']"
  140. >
  141. {{ t('operationFill.fill') }}
  142. </el-button>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <!-- 分页 -->
  147. <Pagination
  148. :total="total"
  149. v-model:page="queryParams.pageNo"
  150. v-model:limit="queryParams.pageSize"
  151. @pagination="getList"
  152. />
  153. </ContentWrap>
  154. </el-col>
  155. </el-row>
  156. <!-- 表单弹窗:添加/修改 -->
  157. <IotInspectOrderForm ref="formRef" @success="getList" />
  158. </template>
  159. <script setup lang="ts">
  160. import { dateFormatter } from '@/utils/formatTime'
  161. import download from '@/utils/download'
  162. import { IotInspectOrderApi, IotInspectOrderVO } from '@/api/pms/inspect/order'
  163. import IotInspectOrderForm from './IotInspectOrderForm.vue'
  164. import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
  165. import DeptTree from '@/views/system/user/DeptTree.vue'
  166. const { push } = useRouter()
  167. const { params } = useRoute()
  168. /** 巡检工单 列表 */
  169. defineOptions({ name: 'IotInspectOrder' })
  170. const message = useMessage() // 消息弹窗
  171. const { t } = useI18n() // 国际化
  172. const loading = ref(true) // 列表的加载中
  173. const list = ref<IotInspectOrderVO[]>([]) // 列表的数据
  174. const status = params.status
  175. const deptId= params.deptId;
  176. const createTime = params.createTime;
  177. const total = ref(0) // 列表的总页数
  178. const queryParams = reactive({
  179. pageNo: 1,
  180. pageSize: 10,
  181. inspectOrderTitle: undefined,
  182. inspectOrderCode: undefined,
  183. status: undefined,
  184. remark: undefined,
  185. createTime: [],
  186. deptId: undefined,
  187. deviceIds: undefined
  188. })
  189. const queryFormRef = ref() // 搜索的表单
  190. const exportLoading = ref(false) // 导出的加载中
  191. const handleDeptNodeClick = async (row) => {
  192. queryParams.deptId = row.id
  193. await getList()
  194. }
  195. /** 查询列表 */
  196. const getList = async () => {
  197. loading.value = true
  198. try {
  199. const data = await IotInspectOrderApi.getIotInspectOrderPage(queryParams)
  200. list.value = data.list
  201. total.value = data.total
  202. } finally {
  203. loading.value = false
  204. }
  205. }
  206. /** 搜索按钮操作 */
  207. const handleQuery = () => {
  208. queryParams.pageNo = 1
  209. getList()
  210. }
  211. /** 重置按钮操作 */
  212. const resetQuery = () => {
  213. queryFormRef.value.resetFields()
  214. handleQuery()
  215. }
  216. /** 添加/修改操作 */
  217. const formRef = ref()
  218. const openForm = (id?: number) => {
  219. push({ name: 'InspectOrderDetail', params: { id } })
  220. }
  221. const openWrite = (id?: number) => {
  222. IotInspectOrderApi.getIotInspectOrder(id).then((res) => {
  223. if (res.status === 'finished') {
  224. message.warning('该工单已执行')
  225. return
  226. }
  227. })
  228. push({ name: 'InspectOrderWrite', params: { id } })
  229. }
  230. /** 删除按钮操作 */
  231. const handleDelete = async (id: number) => {
  232. try {
  233. // 删除的二次确认
  234. await message.delConfirm()
  235. // 发起删除
  236. await IotInspectOrderApi.deleteIotInspectOrder(id)
  237. message.success(t('common.delSuccess'))
  238. // 刷新列表
  239. await getList()
  240. } catch {}
  241. }
  242. /** 导出按钮操作 */
  243. const handleExport = async () => {
  244. try {
  245. // 导出的二次确认
  246. await message.exportConfirm()
  247. // 发起导出
  248. exportLoading.value = true
  249. const data = await IotInspectOrderApi.exportIotInspectOrder(queryParams)
  250. download.excel(data, '巡检工单.xls')
  251. } catch {
  252. } finally {
  253. exportLoading.value = false
  254. }
  255. }
  256. /** 初始化 **/
  257. onMounted(() => {
  258. debugger
  259. if (params.status) {
  260. queryParams.status = params.status
  261. }
  262. if(deptId != null){
  263. queryParams.deptId = deptId;
  264. }
  265. if(createTime){
  266. queryParams.createTime = createTime;
  267. }
  268. getList()
  269. })
  270. </script>