qxyw_detail.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <script setup lang="ts">
  2. import configs from "@/core/config/Index"
  3. import { ElDatePicker } from "element-plus"
  4. import moment from "moment"
  5. import { ref } from "vue"
  6. import VbUpload from "@/components/Upload/VbUpload.vue"
  7. import { useRoute } from "vue-router"
  8. import type { VbFormItem } from "@/components/Forms/models"
  9. import RequestService from "@/core/services/RequestService"
  10. const route = useRoute()
  11. const table = ref()
  12. const cols = ref([
  13. {
  14. name: "序号",
  15. width: 60,
  16. field: configs.TABLE_INDEX_FIELD,
  17. },
  18. {
  19. name: "净化器名称",
  20. field: "monitor_name",
  21. },
  22. {
  23. name: "天数",
  24. field: "day_condition",
  25. },
  26. {
  27. name: "开机小时",
  28. field: "hour_condition",
  29. },
  30. {
  31. name: "最后清洗时间",
  32. field: "last_clean_time",
  33. },
  34. {
  35. name: "经过天数",
  36. field: "run_day",
  37. },
  38. {
  39. name: "开机小时数",
  40. field: "run_hour",
  41. },
  42. {
  43. name: "剩余天数",
  44. field: "surplus_day",
  45. },
  46. {
  47. name: "剩余小时数",
  48. field: "surplus_hour",
  49. },
  50. {
  51. name: "操作",
  52. field: "action",
  53. },
  54. ])
  55. const queryParams = ref({
  56. company_id: route.query.company_id as string,
  57. })
  58. const modal = ref()
  59. const modalTable = ref()
  60. const dateRange = ref<any>("")
  61. const col2s = ref<Array<any>>([
  62. {
  63. name: "设备名称",
  64. field: "device_name",
  65. },
  66. {
  67. name: "清洗时间",
  68. field: "clean_start",
  69. },
  70. {
  71. name: "清洗照片",
  72. field: "pictures",
  73. },
  74. ])
  75. const queryParam2s = ref<any>({
  76. device_id: "0",
  77. })
  78. const deviceId = ref("")
  79. function cleanList(row: any) {
  80. deviceId.value = row.device_id
  81. query()
  82. modal.value.show()
  83. }
  84. function query() {
  85. const params: any = {
  86. device_id: deviceId.value + "",
  87. }
  88. if (dateRange.value[0]) {
  89. params.clean_start = moment(dateRange.value[0]).format("YYYYMMDD")
  90. params.clean_end = moment(dateRange.value[1]).format("YYYYMMDD")
  91. }
  92. //[moment(new Date()).add(-1, "M").toDate(), new Date()]
  93. queryParam2s.value = params
  94. }
  95. function reset() {
  96. dateRange.value = ""
  97. query()
  98. }
  99. const uploadEl = ref()
  100. function clean(row: any) {
  101. uploadEl.value?.clearFiles()
  102. formData.value = Object.assign({}, row)
  103. formData.value.picture_name = ""
  104. formData.value.clean_end = new Date()
  105. modal2.value.show()
  106. }
  107. const validatePic = (rule: any, value: any, callback: any) => {
  108. if (!value) {
  109. callback(new Error("请选择附件"))
  110. } else {
  111. callback()
  112. }
  113. }
  114. const modal2 = ref()
  115. const formData = ref<any>({})
  116. const formItems = ref<Array<VbFormItem>>([
  117. {
  118. label: "设施名称:",
  119. field: "monitor_name",
  120. component: "innerText",
  121. },
  122. {
  123. label: "清洗时间:",
  124. field: "clean_end",
  125. placeholder: "请选择清洗时间",
  126. class: "w-100",
  127. required: true,
  128. component: ElDatePicker,
  129. props: {
  130. type: "date",
  131. disabledDate: (v: any) => {
  132. return (
  133. (v && v > moment().endOf("day")) ||
  134. v < moment(formData.value.last_clean_time, "YYYYMMDD").add(1, "days").toDate()
  135. )
  136. },
  137. },
  138. },
  139. {
  140. label: "清洗图片:",
  141. field: "picture_name",
  142. component: VbUpload,
  143. rules: [{ validator: validatePic, trigger: "change" }],
  144. },
  145. ])
  146. function onSave() {
  147. const data = {
  148. company_id: route.query.company_id,
  149. device_id: formData.value.device_id,
  150. clean_end: moment(formData.value.clean_end).format("YYYYMMDD"),
  151. picture_name: formData.value.picture_name,
  152. }
  153. RequestService.post("sys/operationMerchant/newCleanLog", { data }).then(() => {
  154. table.value.search()
  155. })
  156. }
  157. </script>
  158. <template>
  159. <h2 class="text-primary mb-3">{{ route.query.company_name }}</h2>
  160. <VbDataTable
  161. ref="table"
  162. url="sys/operationMerchant/getPurifierList"
  163. :header="cols"
  164. :query-params="queryParams"
  165. method="post"
  166. :has-checkbox="false"
  167. :pagination="true"
  168. >
  169. <template #tableHeader>
  170. <thead>
  171. <tr class="text-center">
  172. <th class="bg-light-primary" rowspan="2" style="vertical-align: middle">序号</th>
  173. <th class="bg-light-primary" rowspan="2" style="vertical-align: middle">净化器名称</th>
  174. <th class="bg-light-primary" colspan="2">清洗周期</th>
  175. <th class="bg-light-primary" rowspan="2" style="vertical-align: middle">最后清洗时间</th>
  176. <th class="bg-light-primary" colspan="2">上次清洗至今</th>
  177. <th class="bg-light-primary" colspan="2">距下次清洗</th>
  178. <th class="bg-light-primary" rowspan="2" style="vertical-align: middle">清洗记录</th>
  179. </tr>
  180. <tr class="text-center">
  181. <th class="bg-light-primary">天数</th>
  182. <th class="bg-light-primary">开机小时</th>
  183. <th class="bg-light-primary">经过天数</th>
  184. <th class="bg-light-primary">开机小时数</th>
  185. <th class="bg-light-primary">剩余天数</th>
  186. <th class="bg-light-primary">剩余小时数</th>
  187. </tr>
  188. </thead>
  189. </template>
  190. <template #last_clean_time="{ row }">
  191. {{ moment(row.last_clean_time, "YYYYMMDDHHmmss").format("YYYY-MM-DD") }}
  192. </template>
  193. <template #action="{ row }">
  194. <span class="table-action" @click="cleanList(row)">清洗记录</span>
  195. <span class="table-action" @click="clean(row)">填报记录</span>
  196. </template>
  197. </VbDataTable>
  198. <VbModal
  199. v-model:modal="modal"
  200. title="清洗记录"
  201. close-btn-class="btn btn-primary"
  202. :confirm-btn="false"
  203. modal-dialog-style="max-width: 1100px;width: 1100px;"
  204. >
  205. <template #body>
  206. <VbDataTable
  207. ref="modalTable"
  208. :header="col2s"
  209. url="sys/operationMerchant/selectCleanLog"
  210. method="post"
  211. :auto-search="false"
  212. :query-params="queryParam2s"
  213. :has-checkbox="false"
  214. >
  215. <template v-slot:table-tool="">
  216. <el-form class="align-items-center" :inline="true">
  217. <el-form-item class="mb-0 me-0 align-items-center" label="日期">
  218. <el-date-picker
  219. v-model="dateRange"
  220. type="daterange"
  221. range-separator="~"
  222. start-placeholder="开始时间"
  223. end-placeholder="结束时间"
  224. size="default"
  225. />
  226. </el-form-item>
  227. <el-form-item class="mb-0 me-0 align-items-center">
  228. <el-button class="ms-3 mt-0 btn btn-sm btn-primary" @click="query">查询</el-button>
  229. <el-button class="ms-3 mt-0 btn btn-sm btn-light-primary btn-outline" @click="reset">重置</el-button>
  230. </el-form-item>
  231. </el-form>
  232. </template>
  233. <template #pictures="{ row }">
  234. <div class="d-flex h-100 justify-content-center align-items-center p-3">
  235. <el-image
  236. v-for="(pic, i) in row.pictures?.split(',')"
  237. :key="i"
  238. :src="`/api/file/upload/res/${pic}`"
  239. :preview-src-list="row.pictures.split(',').map((v:any)=>{
  240. return `/api/file/upload/res/${v}`
  241. })"
  242. :hide-on-click-modal="true"
  243. fit="cover"
  244. style="height: 50px; width: 75px; max-width: none; border-radius: 0.475rem; margin-left: 5px"
  245. alt=""
  246. />
  247. </div>
  248. </template>
  249. </VbDataTable>
  250. </template>
  251. </VbModal>
  252. <VbModal v-model:modal="modal2" title="清洗填报" :form-data="formData" :form-items="formItems" @confirm="onSave">
  253. <template #picture_name_form>
  254. <VbUpload ref="uploadEl" v-model="formData.picture_name"></VbUpload>
  255. </template>
  256. </VbModal>
  257. </template>