index1.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <ContentWrap>
  3. <el-tabs v-model="activeTab" type="border-card" tab-position="left" v-loading="loading" style="height: 84vh">
  4. <el-tab-pane
  5. style="height: 100%"
  6. v-for="(item,index) in list"
  7. :key="index"
  8. >
  9. <template #label>
  10. <!-- <span @click="openFill(item.deviceCategoryId,item.deviceId,item.deptId,item.deviceName,item.deviceCode)">
  11. {{item.deviceCode}} ({{ item.deviceName }})
  12. </span>-->
  13. <span class="custom-label" v-if='item.isFill === 1' @click="openFill(item.deviceCategoryId,item.deviceId,item.deptId,item.deviceName,item.deviceCode)">
  14. {{item.deviceCode}} ({{ item.deviceName }})
  15. </span>
  16. <span v-else @click="openFill(item.deviceCategoryId,item.deviceId,item.deptId,item.deviceName,item.deviceCode)">
  17. {{item.deviceCode}} ({{ item.deviceName }})
  18. </span>
  19. </template>
  20. <div class="form-wrapper">
  21. <el-form label-width="120px">
  22. <div style="margin-left: 24px">
  23. <el-form class="demo-form-inline" :inline="true">
  24. <el-form-item label="所属队伍:">
  25. {{item.orgName}}
  26. </el-form-item>
  27. <el-form-item label="累计运行时间:">
  28. {{totalRunTime1}}h
  29. </el-form-item>
  30. </el-form>
  31. </div>
  32. <div v-for="(item,index) in attrList" :key="index">
  33. <el-form-item :label='item.name' prop="deviceId" v-if="item.name==='当日运转时间'" >
  34. <el-input
  35. v-model="item.fillContent" @input="attrList[index].fillContent = $event.target.fillContent"
  36. clearable
  37. style="width: 200px"
  38. disabled
  39. />
  40. </el-form-item>
  41. <el-form-item :label='item.name' prop="deviceId" v-else>
  42. <el-input
  43. v-model="item.fillContent" @input="attrList[index].fillContent = $event.target.fillContent"
  44. clearable
  45. style="width: 200px"
  46. />
  47. </el-form-item>
  48. </div>
  49. <el-form-item>
  50. <el-button type="info" @click="deleteFillInfo">取消</el-button>
  51. <el-button type="primary" @click="getFillInfo">确定</el-button>
  52. </el-form-item>
  53. </el-form>
  54. </div>
  55. </el-tab-pane>
  56. </el-tabs>
  57. </ContentWrap>
  58. </template>
  59. <script setup lang="ts">
  60. import { dateFormatter2 } from '@/utils/formatTime'
  61. import download from '@/utils/download'
  62. import { IotOpeationFillApi, IotOpeationFillVO } from '@/api/pms/iotopeationfill'
  63. import IotOpeationFillForm from './IotOpeationFillForm.vue'
  64. import Vue from "@vitejs/plugin-vue";
  65. import {useUserStore} from "@/store/modules/user";
  66. /** 运行记录填报 列表 */
  67. defineOptions({ name: 'IotOpeationFill' })
  68. const message = useMessage() // 消息弹窗
  69. const { t } = useI18n() // 国际化
  70. /** 提交表单 */
  71. const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
  72. const loading = ref(true) // 列表的加载中
  73. const { params, name } = useRoute() // 查询参数
  74. const deptId = params.id
  75. const list = ref<IotOpeationFillVO[]>([]) // 列表的数据
  76. const attrList = ref<IotOpeationFillVO[]>([]) // 列表的数据
  77. const total = ref(0) // 列表的总页数
  78. const arry1 =ref([]);
  79. let totalRunTime1: string = '123'
  80. const queryParams = reactive({
  81. pageNo: 1,
  82. pageSize: 10,
  83. deviceCode: undefined,
  84. deviceName: undefined,
  85. fillContent: undefined,
  86. deviceType: undefined,
  87. deviceComponent: undefined,
  88. deptId: undefined,
  89. orgName: undefined,
  90. proId: undefined,
  91. proName: undefined,
  92. teamId: undefined,
  93. teamName: undefined,
  94. dutyName: undefined,
  95. creDate: [],
  96. createTime: [],
  97. deviceCategoryId:1,
  98. })
  99. const queryFormRef = ref() // 搜索的表单
  100. const exportLoading = ref(false) // 导出的加载中
  101. const formatDescription = async(row, column, cellValue) =>{
  102. return cellValue.split(',').map(part => `<div>${part}</div>`).join('');
  103. }
  104. /** 查询列表 */
  105. const getList = async () => {
  106. loading.value = true
  107. try {
  108. queryParams.deptId = deptId.split(",")[0];
  109. queryParams.userId = deptId.split(",")[1];
  110. queryParams.createTime = formatTimestamp(JSON.parse(deptId.split(",")[2]));
  111. const data = await IotOpeationFillApi.getIotOpeationFillPage(queryParams)
  112. list.value = data;
  113. list.value.forEach(function (item, index) {
  114. arry1.value[index] = item;
  115. });
  116. queryParams.deviceCategoryId = arry1.value[0].deviceCategoryId
  117. queryParams.deptId = arry1.value[0].deptId;
  118. queryParams.deviceCode = arry1.value[0].deviceCode;
  119. queryParams.deviceName = arry1.value[0].deviceName;
  120. queryParams.deviceId = arry1.value[0].deviceId;
  121. getAttrList();
  122. } finally {
  123. loading.value = false
  124. }
  125. }
  126. function formatTimestamp(timestamp) {
  127. const date = new Date(timestamp);
  128. const year = date.getFullYear();
  129. const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的
  130. const day = String(date.getDate()).padStart(2, '0');
  131. return `${year}-${month}-${day}`;
  132. }
  133. /** 搜索按钮操作 */
  134. const handleQuery = () => {
  135. queryParams.pageNo = 1
  136. getList()
  137. }
  138. /** 重置按钮操作 */
  139. const resetQuery = () => {
  140. queryFormRef.value.resetFields()
  141. handleQuery()
  142. }
  143. /** 添加/修改操作 */
  144. const formRef = ref()
  145. const openForm = (type: string, id?: number) => {
  146. formRef.value.open(type, id)
  147. }
  148. const open = async (type: string, id?: number) => {
  149. alert(id)
  150. }
  151. defineExpose({ open }) // 提供 open 方法,用于打开弹窗
  152. const openFill = (deviceCategoryId?:number,deviceId?:number,deptId?:number,deviceName?:string,deviceCode?:string) =>{
  153. queryParams.deviceCategoryId = deviceCategoryId;
  154. queryParams.deptId = deptId;
  155. queryParams.deviceCode = deviceCode;
  156. queryParams.deviceName = deviceName;
  157. queryParams.deviceId = deviceId;
  158. getAttrList();
  159. }
  160. const getAttrList = async () => {
  161. loading.value = true
  162. try {
  163. totalRunTime1 = 0;
  164. const data = await IotOpeationFillApi.getAttrs(queryParams)
  165. attrList.value = data;
  166. //totalRunTime1 = Number(attrList.value[0].totalRunTime).toFixed(2)
  167. attrList.value.forEach(function (item,index){
  168. if(item.name==='累计运行时间'){
  169. item.name = '当日运转时间'
  170. totalRunTime1 = Number(item.totalRunTime).toFixed(2)
  171. }
  172. item.fillContent = Number(item.fillContent).toFixed(2)
  173. item.deviceCode = queryParams.deviceCode;
  174. item.deptId = queryParams.deptId;
  175. item.deviceId = queryParams.deviceId;
  176. item.deviceCategoryId = queryParams.deviceCategoryId;
  177. })
  178. } finally {
  179. loading.value = false
  180. }
  181. }
  182. /** 获取填写信息保存到后台*/
  183. const getFillInfo = async () => {
  184. try {
  185. attrList.value.forEach(function (item,index){
  186. item.pointName = item.name;
  187. item.createTime = formatTimestamp(JSON.parse(deptId.split(",")[2]));
  188. item.userId = deptId.split(",")[1];
  189. })
  190. const data = attrList.value as unknown as IotOpeationFillVO
  191. await IotOpeationFillApi.insertLog(data)
  192. message.success(t('common.createSuccess'))
  193. // 发送操作成功的事件
  194. emit('success')
  195. getList();
  196. } finally {
  197. }
  198. }
  199. /**清空填写信息*/
  200. const deleteFillInfo = () =>{
  201. attrList.value.forEach(function (item, index){
  202. item.fillContent = '';
  203. });
  204. }
  205. /** 删除按钮操作 */
  206. const handleDelete = async (id: number) => {
  207. try {
  208. // 删除的二次确认
  209. await message.delConfirm()
  210. // 发起删除
  211. await IotOpeationFillApi.deleteIotOpeationFill(id)
  212. message.success(t('common.delSuccess'))
  213. // 刷新列表
  214. await getList()
  215. } catch {}
  216. }
  217. /** 导出按钮操作 */
  218. const handleExport = async () => {
  219. try {
  220. // 导出的二次确认
  221. await message.exportConfirm()
  222. // 发起导出
  223. exportLoading.value = true
  224. const data = await IotOpeationFillApi.exportIotOpeationFill(queryParams)
  225. download.excel(data, '运行记录填报.xls')
  226. } catch {
  227. } finally {
  228. exportLoading.value = false
  229. }
  230. }
  231. /** 初始化 **/
  232. onMounted(() => {
  233. getList()
  234. })
  235. </script>
  236. <style scoped>
  237. .back-red{ /* 红色背景 */
  238. background-color: red;
  239. }
  240. .back-blue{
  241. background-color: grey;
  242. }
  243. .step-container {
  244. display: grid;
  245. grid-template-columns: 220px 1fr;
  246. gap: 10px;
  247. height: 100%;
  248. min-height: 600px;
  249. }
  250. .steps-nav {
  251. overflow-y: auto;
  252. padding-right: 15px;
  253. }
  254. .form-wrapper {
  255. background: #fff;
  256. padding: 30px;
  257. border-radius: 8px;
  258. box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  259. }
  260. .navigation-controls {
  261. margin-top: 40px;
  262. text-align: center;
  263. }
  264. .custom-label {
  265. color: green;
  266. }
  267. ::v-deep .el-step__icon {
  268. background-color: #409eff;
  269. color: #fff;
  270. border: 0px;
  271. }
  272. .step-title-wrapper {
  273. display: inline-flex;
  274. align-items: center;
  275. gap: 8px;
  276. position: relative;
  277. padding-right: 25px;
  278. }
  279. /* 覆盖步骤条默认样式 */
  280. :deep(.custom-steps) {
  281. /* 调整头部位置 */
  282. .el-step__head {
  283. top: 3px;
  284. }
  285. /* 标题容器定位 */
  286. .el-step__title {
  287. display: inline-block;
  288. margin-left: 10px;
  289. padding-right: 0;
  290. }
  291. /* 步骤连接线 */
  292. .el-step__line {
  293. left: 11px;
  294. background-color: #ebeef5;
  295. }
  296. /* 当前步骤样式 */
  297. .is-process .title-text {
  298. font-weight: 600;
  299. color: #409eff;
  300. }
  301. /* 完成状态图标 */
  302. .is-finish .tip-icon {
  303. color: #67c23a;
  304. }
  305. }
  306. </style>