index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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('operationFill.name')" prop="orderName" style="margin-left: 15px">
  19. <el-input
  20. v-model="queryParams.orderName"
  21. :placeholder="t('operationFill.nameHolder')"
  22. clearable
  23. @keyup.enter="handleQuery"
  24. class="!w-240px"
  25. />
  26. </el-form-item>
  27. <el-form-item :label="t('operationFill.status')" prop="orderStatus">
  28. <el-select
  29. v-model="queryParams.orderStatus"
  30. :placeholder="t('operationFill.status')"
  31. clearable
  32. class="!w-240px"
  33. >
  34. <el-option
  35. v-for="dict in getStrDictOptions(DICT_TYPE.OPERATION_FILL_ORDER_STATUS)"
  36. :key="dict.value"
  37. :label="dict.label"
  38. :value="dict.value"
  39. />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item :label="t('operationFill.createTime')" prop="createTime" label-width="100px">
  43. <el-date-picker
  44. v-model="queryParams.createTime"
  45. value-format="YYYY-MM-DD HH:mm:ss"
  46. type="daterange"
  47. :start-placeholder="t('operationFill.start')"
  48. :end-placeholder="t('operationFill.end')"
  49. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  50. class="!w-220px"
  51. />
  52. </el-form-item>
  53. <el-form-item>
  54. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" />{{t('operationFill.search')}}</el-button>
  55. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" />{{t('operationFill.reset')}}</el-button>
  56. <!-- <el-button-->
  57. <!-- type="primary"-->
  58. <!-- plain-->
  59. <!-- @click="openForm('create')"-->
  60. <!-- v-hasPermi="['rq:iot-inspect-order:create']"-->
  61. <!-- >-->
  62. <!-- <Icon icon="ep:plus" class="mr-5px" /> 新增-->
  63. <!-- </el-button>-->
  64. <!-- <el-button
  65. type="success"
  66. plain
  67. @click="handleExport"
  68. :loading="exportLoading"
  69. v-hasPermi="['rq:iot-inspect-order:export']"
  70. >
  71. <Icon icon="ep:download" class="mr-5px" /> 导出
  72. </el-button>-->
  73. </el-form-item>
  74. </el-form>
  75. </ContentWrap>
  76. <!-- 列表 -->
  77. <ContentWrap>
  78. <el-table v-loading="loading" :data="list" :stripe="true" >
  79. <el-table-column label="序号" width="60" align="center">
  80. <template #default="scope">
  81. {{ scope.$index + 1 }}
  82. </template>
  83. </el-table-column>
  84. <el-table-column :label="t('operationFill.name')" align="center" prop="orderName" width="300"/>
  85. <el-table-column :label="t('operationFill.duty')" align="center" prop="userName" />
  86. <!-- <el-table-column label="工单类型" align="center" prop="orderType" />-->
  87. <el-table-column :label="t('operationFill.status')" align="center" prop="orderStatus" >
  88. <template #default="scope">
  89. <dict-tag :type="DICT_TYPE.OPERATION_FILL_ORDER_STATUS" :value="scope.row.orderStatus" />
  90. </template>
  91. </el-table-column>
  92. <!-- <el-table-column label="备注" align="center" prop="remark" />-->
  93. <el-table-column
  94. :label="t('dict.createTime')"
  95. align="center"
  96. prop="createTime"
  97. :formatter="dateFormatter"
  98. />
  99. <el-table-column
  100. label="填写时间"
  101. align="center"
  102. prop="updateTime"
  103. :formatter="dateFormatter"
  104. />
  105. <el-table-column :label="t('operationFill.operation')" align="center" min-width="120px">
  106. <template #default="scope">
  107. <div v-if="scope.row.orderStatus !== 1">
  108. <el-button
  109. link
  110. type="primary"
  111. @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime+','+scope.row.id+','+scope.row.orderStatus)"
  112. v-hasPermi="['rq:iot-opeation-fill:update']"
  113. v-if="scope.row.orderStatus !== 1"
  114. >
  115. {{t('operationFill.fill')}}
  116. </el-button>
  117. </div>
  118. <div v-else>
  119. <el-button
  120. link
  121. type="primary"
  122. @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime+','+scope.row.id+','+0)"
  123. v-hasPermi="['rq:iot-opeation-fill:update']"
  124. v-if="isSameDay(scope.row.createTime)"
  125. >
  126. {{t('fault.edit')}}
  127. </el-button>
  128. <el-button
  129. link
  130. type="success"
  131. @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime+','+scope.row.id+','+scope.row.orderStatus)"
  132. >
  133. {{t('operationFill.view')}}
  134. </el-button>
  135. </div>
  136. <!-- 编辑按钮 -->
  137. </template>
  138. </el-table-column>
  139. </el-table>
  140. <!-- 分页 -->
  141. <Pagination
  142. :total="total"
  143. v-model:page="queryParams.pageNo"
  144. v-model:limit="queryParams.pageSize"
  145. @pagination="getList"
  146. />
  147. </ContentWrap>
  148. </el-col>
  149. </el-row>
  150. <!-- 表单弹窗:添加/修改 -->
  151. <IotInspectOrderForm ref="formRef" @success="getList" />
  152. </template>
  153. <script setup lang="ts">
  154. import { dateFormatter } from '@/utils/formatTime'
  155. import download from '@/utils/download'
  156. import { IotInspectOrderApi, IotInspectOrderVO } from '@/api/pms/inspect/order'
  157. //import IotInspectOrderForm from './IotInspectOrderForm.vue'
  158. import {DICT_TYPE, getStrDictOptions} from "@/utils/dict";
  159. import DeptTree from "@/views/system/user/DeptTree.vue";
  160. import {onMounted, ref} from "vue";
  161. import {IotOpeationFillApi, IotOpeationFillVO} from "@/api/pms/iotopeationfill";
  162. import {useUserStore} from "@/store/modules/user";
  163. const { push } = useRouter()
  164. const { query} = useRoute() // 查询参数
  165. const deptId= query.deptId;
  166. const orderStatus = query.orderStatus;
  167. const createTime = query.createTime;
  168. /** 巡检工单 列表 */
  169. defineOptions({ name: 'IotOpeationFill1' })
  170. const message = useMessage() // 消息弹窗
  171. const { t } = useI18n() // 国际化
  172. const loading = ref(true) // 列表的加载中
  173. const list = ref<IotOpeationFillVO[]>([]) // 列表的数据
  174. const total = ref(0) // 列表的总页数
  175. const queryParams = reactive({
  176. pageNo: 1,
  177. pageSize: 10,
  178. inspectOrderTitle: undefined,
  179. inspectOrderCode: undefined,
  180. status: undefined,
  181. remark: undefined,
  182. createTime: [],
  183. deptId: useUserStore().getUser.deptId,
  184. deviceIds: undefined,
  185. orderStatus:undefined
  186. //userId:useUserStore().getUser.id
  187. })
  188. const queryFormRef = ref() // 搜索的表单
  189. const exportLoading = ref(false) // 导出的加载中
  190. // 判断两个日期是否为同一天
  191. const isSameDay = (dateString) => {
  192. if (!dateString) return false
  193. // 将日期字符串转换为日期对象
  194. const targetDate = new Date(dateString)
  195. const today = new Date()
  196. // 比较年、月、日
  197. return targetDate.getFullYear() === today.getFullYear() &&
  198. targetDate.getMonth() === today.getMonth() &&
  199. targetDate.getDate() === today.getDate()
  200. }
  201. const handleDeptNodeClick = async (row) => {
  202. queryParams.deptId = row.id
  203. await getList()
  204. }
  205. /** 查询列表 */
  206. const getList = async () => {
  207. loading.value = true
  208. try {
  209. const data = await IotOpeationFillApi.getIotOpeationFillPage1(queryParams)
  210. list.value = data.list
  211. total.value = data.total
  212. } finally {
  213. loading.value = false
  214. }
  215. }
  216. /** 搜索按钮操作 */
  217. const handleQuery = () => {
  218. queryParams.pageNo = 1
  219. getList()
  220. }
  221. /** 重置按钮操作 */
  222. const resetQuery = () => {
  223. queryFormRef.value.resetFields()
  224. handleQuery()
  225. }
  226. /** 添加/修改操作 */
  227. const formRef = ref()
  228. const openForm = (id?: number) => {
  229. push({ name: 'InspectOrderDetail', params:{id} })
  230. }
  231. const openWrite = (id?: string) => {
  232. push({ name: 'FillOrderInfo',params:{id}})
  233. }
  234. /** 删除按钮操作 */
  235. const handleDelete = async (id: number) => {
  236. try {
  237. // 删除的二次确认
  238. await message.delConfirm()
  239. // 发起删除
  240. await IotInspectOrderApi.deleteIotInspectOrder(id)
  241. message.success(t('common.delSuccess'))
  242. // 刷新列表
  243. await getList()
  244. } catch {}
  245. }
  246. /** 导出按钮操作 */
  247. const handleExport = async () => {
  248. try {
  249. // 导出的二次确认
  250. await message.exportConfirm()
  251. // 发起导出
  252. exportLoading.value = true
  253. const data = await IotInspectOrderApi.exportIotInspectOrder(queryParams)
  254. download.excel(data, '巡检工单.xls')
  255. } catch {
  256. } finally {
  257. exportLoading.value = false
  258. }
  259. }
  260. /** 初始化 **/
  261. onMounted(async () => {
  262. alert(JSON.stringify(query))
  263. if(deptId != null){
  264. queryParams.deptId = deptId;
  265. }
  266. if(orderStatus === 3){
  267. queryParams.orderStatus = null
  268. }
  269. if(orderStatus != null && orderStatus != 3){
  270. queryParams.orderStatus = orderStatus;
  271. }
  272. if(createTime){
  273. queryParams.createTime = createTime;
  274. }
  275. getList()
  276. })
  277. </script>