BomInfo.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div class="container-tree" ref="container">
  3. <el-row>
  4. <div class="left-tree" :style="{ width: leftWidth + 'px' }">
  5. <ContentWrapNoBottom>
  6. <BomTree @node-click="handleFileNodeClick" @success="successList" :deviceId="id" />
  7. </ContentWrapNoBottom>
  8. </div>
  9. <div class="divider-tree" @mousedown="startDrag"></div>
  10. <div class="right-tree" :style="{ width: rightWidth + 'px' }">
  11. <ContentWrap>
  12. <el-form
  13. class="-mb-15px"
  14. :model="queryParams"
  15. ref="queryFormRef"
  16. :inline="true"
  17. label-width="68px"
  18. >
  19. <el-form-item label="物料名称" prop="name">
  20. <el-input
  21. v-model="queryParams.name"
  22. placeholder="请输入物料名称"
  23. clearable
  24. @keyup.enter="handleQuery"
  25. class="!w-240px"
  26. />
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button @click="handleQuery"><Icon icon="ep:search" />搜索</el-button>
  30. <el-button @click="resetQuery"><Icon icon="ep:refresh" />重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. </ContentWrap>
  34. <ContentWrap>
  35. <el-table
  36. v-loading="formLoading"
  37. :data="list"
  38. :stripe="true"
  39. :show-overflow-tooltip="true"
  40. >
  41. <el-table-column label="物料编码" align="center" prop="code" />
  42. <el-table-column label="物料名称" align="center" prop="name" />
  43. <el-table-column label="规格型号" align="center" prop="model" />
  44. <el-table-column label="单位" align="center" prop="unit" />
  45. <el-table-column label="备注" align="center" prop="remark" />
  46. <el-table-column
  47. label="创建时间"
  48. align="center"
  49. prop="createTime"
  50. :formatter="dateFormatter"
  51. width="180px"
  52. />
  53. </el-table>
  54. <Pagination
  55. :total="total"
  56. v-model:page="queryParams.pageNo"
  57. v-model:limit="queryParams.pageSize"
  58. @pagination="getList"
  59. />
  60. </ContentWrap> </div
  61. ></el-row>
  62. </div>
  63. <IotInfoForm
  64. ref="formRef"
  65. @success="getList"
  66. :deviceId="deviceId"
  67. :classId="queryParams.classId"
  68. />
  69. </template>
  70. <script lang="ts" setup>
  71. import { IotDeviceVO } from '@/api/pms/device'
  72. import { dateFormatter } from '@/utils/formatTime'
  73. import IotInfoForm from '@/views/pms/iotinfo/IotInfoForm.vue'
  74. import { onMounted, ref } from 'vue'
  75. import BomTree from '@/views/pms/device/BomTree.vue'
  76. import * as PmsMaterialApi from '@/api/pms/material'
  77. defineOptions({ name: 'DeviceUpload' })
  78. const queryFormRef = ref() // 搜索的表单
  79. const { t } = useI18n() // 国际化
  80. const message = useMessage() // 消息弹窗
  81. const loading = ref(true) // 列表的加载中
  82. const { params } = useRoute() // 查询参数
  83. const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  84. const list = ref<IotDeviceVO[]>([]) // 列表的数据
  85. const total = ref(0) // 列表的总页数
  86. const id = params.id as unknown as number
  87. const container = ref(null)
  88. const leftWidth = ref(350) // 初始左侧宽度
  89. const rightWidth = ref(window.innerWidth * 0.69)
  90. let isDragging = false
  91. const startDrag = (e) => {
  92. isDragging = true
  93. document.addEventListener('mousemove', onDrag)
  94. document.addEventListener('mouseup', stopDrag)
  95. }
  96. const onDrag = (e) => {
  97. if (!isDragging) return
  98. const containerRect = container.value.getBoundingClientRect()
  99. const newWidth = e.clientX - containerRect.left
  100. // 设置最小和最大宽度限制
  101. if (newWidth > 300 && newWidth < containerRect.width - 100) {
  102. leftWidth.value = newWidth
  103. }
  104. }
  105. const stopDrag = () => {
  106. isDragging = false
  107. document.removeEventListener('mousemove', onDrag)
  108. document.removeEventListener('mouseup', stopDrag)
  109. }
  110. const queryParams = reactive({
  111. pageNo: 1,
  112. pageSize: 10,
  113. createTime: [],
  114. deviceId: null,
  115. bomId: null,
  116. name: null
  117. })
  118. const formRef = ref()
  119. const deviceId = ref('')
  120. const handleFileNodeClick = async (row) => {
  121. queryParams.bomId = row.id
  122. await getList()
  123. }
  124. /** 查询列表 */
  125. const getList = async () => {
  126. formLoading.value = true
  127. try {
  128. // queryParams.deviceId = deviceId.value
  129. const data = await PmsMaterialApi.listByBomId(queryParams)
  130. list.value = data.list
  131. total.value = data.total
  132. } finally {
  133. formLoading.value = false
  134. }
  135. }
  136. const successList = async (id) => {
  137. queryParams.bomId = id
  138. await getList()
  139. }
  140. /** 搜索按钮操作 */
  141. const handleQuery = () => {
  142. queryParams.pageNo = 1
  143. getList()
  144. }
  145. /** 重置按钮操作 */
  146. const resetQuery = () => {
  147. queryFormRef.value?.resetFields()
  148. handleQuery()
  149. }
  150. /** 初始化 */
  151. onMounted(async () => {
  152. // await getDetail()
  153. // await getList()
  154. deviceId.value = params.id as unknown as number
  155. })
  156. </script>
  157. <style scoped>
  158. .container-tree {
  159. display: flex;
  160. height: 100%;
  161. user-select: none; /* 防止拖动时选中文本 */
  162. }
  163. .left-tree {
  164. background: #f0f0f0;
  165. height: 100%;
  166. overflow: auto;
  167. }
  168. .right-tree {
  169. flex: 1;
  170. background: #fff;
  171. height: 100%;
  172. overflow: auto;
  173. margin-left: 5px;
  174. }
  175. .divider-tree {
  176. width: 2px;
  177. background: #ccc;
  178. cursor: col-resize;
  179. position: relative;
  180. }
  181. .divider-tree:hover {
  182. background: #666;
  183. }
  184. </style>