index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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="t('common.index')" min-width="60" align="center">
  80. <template #default="scope">
  81. {{ scope.$index + 1 }}
  82. </template>
  83. </el-table-column>
  84. <el-table-column :label="t('bomList.name')" align="center" prop="orderName" min-width="320"/>
  85. <el-table-column :label="t('operationFill.duty')" align="center" prop="userName" min-width="100"/>
  86. <el-table-column :label="t('operationFill.orderDevice')" align="center" prop="fillList" min-width="150" :show-overflow-tooltip="true"/>
  87. <el-table-column :label="t('operationFill.status')" align="center" prop="orderStatus" min-width="120">
  88. <template #default="scope">
  89. <el-tooltip
  90. v-if="scope.row.orderStatus === 3"
  91. effect="dark"
  92. :content="scope.row.reason"
  93. placement="top"
  94. >
  95. <dict-tag :type="DICT_TYPE.OPERATION_FILL_ORDER_STATUS" :value="scope.row.orderStatus" />
  96. </el-tooltip>
  97. <dict-tag
  98. v-else
  99. :type="DICT_TYPE.OPERATION_FILL_ORDER_STATUS"
  100. :value="scope.row.orderStatus"
  101. />
  102. </template>
  103. </el-table-column>
  104. <el-table-column :label="t('operationFill.deviceCount')" align="center" prop="allDev" min-width="120">
  105. <template #default="scope">
  106. <el-tag type="info"> {{scope.row.allDev}}</el-tag>
  107. </template>
  108. </el-table-column>
  109. <el-table-column :label="t('operationFill.fillCount')" align="center" prop="fillDev" min-width="120">
  110. <template #default="scope">
  111. <el-tag type="success"> {{scope.row.fillDev}}</el-tag>
  112. </template>
  113. </el-table-column>
  114. <el-table-column :label="t('operationFill.unFillCount')" align="center" prop="unFillDev" min-width="120">
  115. <template #default="scope">
  116. <el-tag type="danger"> {{scope.row.unFillDev}}</el-tag>
  117. </template>
  118. </el-table-column>
  119. <el-table-column
  120. :label="t('dict.createTime')"
  121. align="center"
  122. prop="createTime"
  123. :formatter="dateFormatter"
  124. min-width="170"
  125. />
  126. <el-table-column
  127. :label="t('dict.fillTime')"
  128. align="center"
  129. prop="updateTime"
  130. :formatter="dateFormatter"
  131. min-width="170"
  132. />
  133. <el-table-column :label="t('operationFill.operation')" align="center" min-width="120px" fixed="right">
  134. <template #default="scope">
  135. <div v-if="scope.row.orderStatus == 0||scope.row.orderStatus == 2">
  136. <el-button
  137. link
  138. type="primary"
  139. @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime+','+scope.row.id+','+scope.row.orderStatus)"
  140. v-hasPermi="['rq:iot-opeation-fill:update']"
  141. v-if="scope.row.orderStatus !== 1"
  142. >
  143. {{t('operationFill.fill')}}
  144. </el-button>
  145. <el-button
  146. link
  147. type="warning"
  148. v-hasPermi="['rq:iot-opeation-fill:update']"
  149. v-if="scope.row.orderStatus !== 1"
  150. @click="openDialog(scope.row.id)"
  151. >
  152. {{t('operationFill.ignore')}}
  153. </el-button>
  154. </div>
  155. <div v-else-if="scope.row.orderStatus === 3">
  156. <el-button
  157. link
  158. type="success"
  159. @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime+','+scope.row.id+','+scope.row.orderStatus)"
  160. >
  161. {{t('operationFill.view')}}
  162. </el-button>
  163. </div>
  164. <div v-else>
  165. <el-button
  166. link
  167. type="primary"
  168. @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime+','+scope.row.id+','+0)"
  169. v-hasPermi="['rq:iot-opeation-fill:update']"
  170. v-if="isSameDay(scope.row.createTime)"
  171. >
  172. {{t('fault.edit')}}
  173. </el-button>
  174. <el-button
  175. link
  176. type="success"
  177. @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime+','+scope.row.id+','+scope.row.orderStatus)"
  178. >
  179. {{t('operationFill.view')}}
  180. </el-button>
  181. </div>
  182. <!-- 编辑按钮 -->
  183. </template>
  184. </el-table-column>
  185. </el-table>
  186. <el-dialog
  187. v-model="dialogVisible"
  188. title="忽略理由"
  189. :width="600"
  190. :before-close="handleClose"
  191. append-to-body
  192. :close-on-click-modal="false"
  193. >
  194. <el-form
  195. ref="reasonFormRef"
  196. :model="form"
  197. :rules="rules"
  198. label-width="60px"
  199. >
  200. <el-form-item label="理由" prop="reason">
  201. <el-input
  202. type="textarea"
  203. v-model="form.reason"
  204. placeholder="请输入忽略理由"
  205. :rows="4"
  206. resize="none"
  207. />
  208. </el-form-item>
  209. </el-form>
  210. <template #footer>
  211. <el-button @click="handleCancel">取消</el-button>
  212. <el-button type="primary" @click="handleConfirm">确定</el-button>
  213. </template>
  214. </el-dialog>
  215. <!-- 分页 -->
  216. <Pagination
  217. :total="total"
  218. v-model:page="queryParams.pageNo"
  219. v-model:limit="queryParams.pageSize"
  220. @pagination="getList"
  221. />
  222. </ContentWrap>
  223. </el-col>
  224. </el-row>
  225. <!-- 表单弹窗:添加/修改 -->
  226. <IotInspectOrderForm ref="formRef" @success="getList" />
  227. </template>
  228. <script setup lang="ts">
  229. import { dateFormatter } from '@/utils/formatTime'
  230. import download from '@/utils/download'
  231. import { IotInspectOrderApi, IotInspectOrderVO } from '@/api/pms/inspect/order'
  232. //import IotInspectOrderForm from './IotInspectOrderForm.vue'
  233. import {DICT_TYPE, getStrDictOptions} from "@/utils/dict";
  234. import DeptTree from "@/views/system/user/DeptTree.vue";
  235. import {onMounted, ref} from "vue";
  236. import {IotOpeationFillApi, IotOpeationFillVO} from "@/api/pms/iotopeationfill";
  237. import {useUserStore} from "@/store/modules/user";
  238. const { push } = useRouter()
  239. const { query} = useRoute() // 查询参数
  240. const deptId= query.deptId;
  241. const orderStatus = query.orderStatus;
  242. const createTime = query.createTime;
  243. /** 巡检工单 列表 */
  244. defineOptions({ name: 'IotOpeationFill1' })
  245. const dialogVisible = ref(false);
  246. const message = useMessage() // 消息弹窗
  247. const { t } = useI18n() // 国际化
  248. const loading = ref(true) // 列表的加载中
  249. const list = ref<IotOpeationFillVO[]>([]) // 列表的数据
  250. const total = ref(0) // 列表的总页数
  251. const queryParams = reactive({
  252. pageNo: 1,
  253. pageSize: 10,
  254. inspectOrderTitle: undefined,
  255. inspectOrderCode: undefined,
  256. status: undefined,
  257. remark: undefined,
  258. createTime: [],
  259. deptId: useUserStore().getUser.deptId,
  260. deviceIds: undefined,
  261. orderStatus:undefined
  262. //userId:useUserStore().getUser.id
  263. })
  264. const form = reactive({
  265. id: undefined,
  266. reason: '',
  267. });
  268. // 表单验证规则
  269. const rules = {
  270. reason: [
  271. { required: true, message: '请输入忽略理由', trigger: 'blur' },
  272. { min: 2, message: '理由长度不能少于2个字符', trigger: 'blur' }
  273. ]
  274. };
  275. // 打开对话框
  276. const openDialog = (id:number) => {
  277. dialogVisible.value = true;
  278. form.id = id;
  279. form.reason = '';
  280. };
  281. // 取消按钮处理
  282. const handleCancel = () => {
  283. dialogVisible.value = false;
  284. resetForm();
  285. };
  286. // 确定按钮处理
  287. const handleConfirm = async () => {
  288. // 表单验证
  289. try {
  290. await reasonFormRef.value.validate();
  291. // 验证通过,调用接口
  292. await IotOpeationFillApi.updateIotOpeationFill1(form)
  293. ElMessage.success('操作成功');
  294. dialogVisible.value = false;
  295. resetForm();
  296. } catch (error) {
  297. return;
  298. }
  299. };
  300. // 重置表单
  301. const resetForm = () => {
  302. reasonFormRef.value?.resetFields();
  303. };
  304. const reasonFormRef = ref(null);
  305. const queryFormRef = ref() // 搜索的表单
  306. const exportLoading = ref(false) // 导出的加载中
  307. // 新增变量用于控制悬浮提示
  308. const hoverRowId = ref<number | null>(null)
  309. // 鼠标进入表格单元格时
  310. const handleMouseEnter = (row: IotOpeationFillVO) => {
  311. hoverRowId.value = row.id
  312. }
  313. // 鼠标离开表格单元格时
  314. const handleMouseLeave = () => {
  315. hoverRowId.value = null
  316. }
  317. // 定义要显示的悬浮内容
  318. const getTooltipContent = (row: IotOpeationFillVO) => {
  319. // 根据实际需求自定义显示内容
  320. return `
  321. ${t('operationFill.name')}: ${row.orderName || '-'}\n
  322. ${t('operationFill.duty')}: ${row.userName || '-'}\n
  323. ${t('dict.createTime')}: ${row.createTime ? dateFormatter(row.createTime) : '-'}
  324. `
  325. }
  326. // 判断两个日期是否为同一天
  327. const isSameDay = (dateString) => {
  328. if (!dateString) return false
  329. // 将日期字符串转换为日期对象
  330. const targetDate = new Date(dateString)
  331. const today = new Date()
  332. // 比较年、月、日
  333. return targetDate.getFullYear() === today.getFullYear() &&
  334. targetDate.getMonth() === today.getMonth() &&
  335. targetDate.getDate() === today.getDate()
  336. }
  337. const handleDeptNodeClick = async (row) => {
  338. queryParams.deptId = row.id
  339. await getList()
  340. }
  341. /** 查询列表 */
  342. const getList = async () => {
  343. loading.value = true
  344. try {
  345. const data = await IotOpeationFillApi.getIotOpeationFillPage1(queryParams)
  346. list.value = data.list
  347. total.value = data.total
  348. } finally {
  349. loading.value = false
  350. }
  351. }
  352. /** 搜索按钮操作 */
  353. const handleQuery = () => {
  354. queryParams.pageNo = 1
  355. getList()
  356. }
  357. /** 重置按钮操作 */
  358. const resetQuery = () => {
  359. queryFormRef.value.resetFields()
  360. handleQuery()
  361. }
  362. /** 添加/修改操作 */
  363. const formRef = ref()
  364. const openForm = (id?: number) => {
  365. push({ name: 'InspectOrderDetail', params:{id} })
  366. }
  367. const openWrite = (id?: string) => {
  368. push({ name: 'FillOrderInfo',params:{id}})
  369. }
  370. /** 删除按钮操作 */
  371. const handleDelete = async (id: number) => {
  372. try {
  373. // 删除的二次确认
  374. await message.delConfirm()
  375. // 发起删除
  376. await IotInspectOrderApi.deleteIotInspectOrder(id)
  377. message.success(t('common.delSuccess'))
  378. // 刷新列表
  379. await getList()
  380. } catch {}
  381. }
  382. /** 导出按钮操作 */
  383. const handleExport = async () => {
  384. try {
  385. // 导出的二次确认
  386. await message.exportConfirm()
  387. // 发起导出
  388. exportLoading.value = true
  389. const data = await IotInspectOrderApi.exportIotInspectOrder(queryParams)
  390. download.excel(data, '巡检工单.xls')
  391. } catch {
  392. } finally {
  393. exportLoading.value = false
  394. }
  395. }
  396. /** 初始化 **/
  397. onMounted(async () => {
  398. // 计算近一周时间
  399. const end = new Date();
  400. const start = new Date();
  401. start.setTime(start.getTime() - 7 * 24 * 60 * 60 * 1000);
  402. // 格式化日期为后端需要的格式
  403. const formatDate = (date) => {
  404. const year = date.getFullYear();
  405. const month = String(date.getMonth() + 1).padStart(2, '0');
  406. const day = String(date.getDate()).padStart(2, '0');
  407. const hours = String(date.getHours()).padStart(2, '0');
  408. const minutes = String(date.getMinutes()).padStart(2, '0');
  409. const seconds = String(date.getSeconds()).padStart(2, '0');
  410. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  411. };
  412. queryParams.createTime = [formatDate(start), formatDate(end)];
  413. if(deptId != null){
  414. queryParams.deptId = deptId;
  415. }
  416. if(orderStatus === 4){
  417. queryParams.orderStatus = null
  418. }
  419. if(orderStatus != null && orderStatus != 4){
  420. queryParams.orderStatus = orderStatus;
  421. }
  422. if(createTime){
  423. const timeArr = createTime.split(',');
  424. if (timeArr.length === 2) {
  425. queryParams.createTime = timeArr;
  426. } else {
  427. // 处理格式不正确的情况,可以给个默认值或提示
  428. console.warn('createTime参数格式不正确');
  429. }
  430. //queryParams.createTime = createTime;
  431. }
  432. getList()
  433. })
  434. </script>