DetailView.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div class="AboutView">
  3. <div class="w-full h-[180px] relative flex items-center md:h-[380px]">
  4. <div
  5. class="w-full h-full bg-[url('/src/assets/images/detail_top_bg.png')] bg-no-repeat bg-center bg-cover absolute left-0 top-0 z-0"
  6. ></div>
  7. <div class="relative z-1 p-4 w-full md:w-[780px] m-auto">
  8. <div
  9. class="font-['PingFang-Heavy'] px-3 font-semibold text-xl md:text-[32px] md:leading-tight"
  10. >
  11. 工具数字化展示
  12. </div>
  13. <div class="flex mt-6">
  14. <div
  15. class="ml-3"
  16. v-for="typeItem in typeOptions1Ref"
  17. :key="typeItem.id"
  18. @click="handleReturn(typeItem)"
  19. >
  20. {{ typeItem.toolName }}
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <section
  26. class="w-full bg-[url('/src/assets/images/detail_bg.png')] bg-no-repeat bg-center bg-cover left-0 top-0 z-0 flex justify-center"
  27. >
  28. <div
  29. class="w-[1440px] max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-7xl"
  30. >
  31. <div class="md:flex">
  32. <div class="w-full md:w-[450px] md:shrink-0 p-3">
  33. <div class="w-full h-[450px] tool-img border-2 flex items-center justify-center">
  34. <van-image class="max-w-[450px] max-h-[450px] tool-img" :src="devPath + sytPath" />
  35. </div>
  36. <van-grid
  37. square
  38. :column-num="4"
  39. class="h-full w-full object-cover md:h-[105px] mt-4"
  40. :gutter="10"
  41. >
  42. <van-grid-item
  43. v-for="syt in sytList"
  44. :key="syt.id"
  45. @click="changeImg(syt)"
  46. :class="[syt.id === detailImg ? 'active' : '']"
  47. >
  48. <van-image class="max-w-[105px] max-h-[105px]" :src="devPath + syt.filePath" />
  49. </van-grid-item>
  50. </van-grid>
  51. </div>
  52. <div class="p-8 w-full">
  53. <div
  54. class="font-['PingFang-Heavy'] font-semibold text-xl md:text-[20px] md:leading-tight"
  55. >
  56. {{ queryToolName }}
  57. </div>
  58. <div
  59. class="bg-[#E6F7FF] border border-[#004EA2] rounded px-3 text-[#004EA2] text-center mt-9 font-normal text-xs w-[200px] h-[22px] leading-[22px] truncate"
  60. >
  61. {{ breadTitle }}
  62. </div>
  63. <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex">
  64. <div>物料名称:</div>
  65. <div class="font-['PingFang-SC'] text-sm font-normal">{{ selectMaterialName }}</div>
  66. </div>
  67. <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex">
  68. <div class="min-w-20">物料规格:</div>
  69. <div>
  70. <van-tag
  71. v-for="i in wlList"
  72. :key="i.id"
  73. :color="i.id === wlSelectId ? '#004EA2' : '#F0F0F0'"
  74. :text-color="i.id === wlSelectId ? '#FFFFFF' : '#000000'"
  75. class="m-1 h-[35px] leading-[35px]"
  76. @click="changeWlCode(i)"
  77. >{{ i.specifications }}</van-tag
  78. >
  79. </div>
  80. </div>
  81. <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex items-center">
  82. <div>物料编码:</div>
  83. <div>{{ selectWlCode }}</div>
  84. <van-icon
  85. v-show="selectWlCode"
  86. name="description-o"
  87. class="text-[#004EA2] description-o ml-1 cursor-pointer"
  88. @click="codeCopy"
  89. />
  90. </div>
  91. <div class="font-['PingFang-SC'] text-sm font-normal mt-10">
  92. <div>附件:</div>
  93. <van-cell-group>
  94. <van-cell v-for="file in fileList" :key="file.id">
  95. <template #title>
  96. <span class="cursor-pointer" @click="fileDownload(file)">{{
  97. file.fileName
  98. }}</span>
  99. </template>
  100. <template #right-icon>
  101. <img
  102. class="w-[18px] h-[18px] cursor-pointer"
  103. src="../assets/images/download.png"
  104. alt=""
  105. @click="fileDownload(file)"
  106. />
  107. </template>
  108. </van-cell>
  109. </van-cell-group>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </section>
  115. <!-- <h1 class="text-3xl font-bold underline" @click="goBack">详情页</h1> -->
  116. </div>
  117. </template>
  118. <script setup name="AboutView">
  119. import { ref } from 'vue'
  120. import { useRoute, useRouter } from 'vue-router'
  121. import { detailList } from '@/api/index.js'
  122. import Clipboard from 'clipboard'
  123. import { listTools } from '@/api/index.js'
  124. const router = useRouter()
  125. const route = useRoute()
  126. const queryId = ref(route.query.id)
  127. const queryToolName = ref(route.query.toolName)
  128. console.log('route.query.id', queryId.value)
  129. const wlList = ref([])
  130. const wlSelectId = ref(0)
  131. const selectWlCode = ref('')
  132. const selectMaterialName = ref('')
  133. const sytList = ref([])
  134. const fileList = ref([])
  135. const detailImg = ref(0)
  136. const sytPath = ref('')
  137. const devPath = import.meta.env.VITE_APP_BASE_API
  138. const breadTitle = ref('')
  139. const typeOptions1Ref = ref([])
  140. const init = () => {
  141. detailList({ id: queryId.value }).then((res) => {
  142. const toolDetails = res.data.toolDetails
  143. wlList.value = toolDetails.filter((item) => item.informationType === 'wl')
  144. console.log(wlList.value)
  145. if (wlList.value.length > 0) {
  146. selectWlCode.value = wlList.value[0].materialNo
  147. selectMaterialName.value = wlList.value[0].materialName
  148. wlSelectId.value = wlList.value[0].id
  149. }
  150. sytList.value = toolDetails.filter((item) => item.informationType === 'syt')
  151. if (sytList.value.length > 0) {
  152. detailImg.value = sytList.value[0].id
  153. sytPath.value = sytList.value[0].filePath
  154. }
  155. fileList.value = toolDetails.filter(
  156. (item) => item.informationType !== 'syt' && item.informationType !== 'wl'
  157. )
  158. const ttoolBasis = res.data.ttoolBasis
  159. breadTitle.value = ttoolBasis.map((item) => item.toolName).join(' > ')
  160. })
  161. listTools({
  162. level: '1',
  163. pageSize: 999
  164. }).then((res) => {
  165. typeOptions1Ref.value = res.rows
  166. })
  167. }
  168. init()
  169. const changeImg = ({ id, filePath }) => {
  170. detailImg.value = id
  171. sytPath.value = filePath
  172. }
  173. const codeCopy = async () => {
  174. const clipboard = new Clipboard('.description-o', {
  175. text: () => selectWlCode.value
  176. })
  177. // 添加成功事件处理函数
  178. clipboard.on('success', (e) => {
  179. e.clearSelection()
  180. })
  181. // 添加失败事件处理函数
  182. clipboard.on('error', () => {
  183. console.warn('无法复制到剪贴板!')
  184. })
  185. }
  186. const changeWlCode = ({ id, materialNo, materialName }) => {
  187. wlSelectId.value = id
  188. selectWlCode.value = materialNo
  189. selectMaterialName.value = materialName
  190. }
  191. // informationType 物料 wl 点击切换 物料编码 materialNo
  192. // informationType 示意图 syt 左侧图
  193. const fileDownload = ({ fileName, filePath }) => {
  194. console.log('filePath', filePath)
  195. const el = document.createElement('a')
  196. el.style.display = 'none'
  197. el.setAttribute('target', '_blank')
  198. fileName && el.setAttribute('download', fileName)
  199. el.href = devPath + filePath
  200. document.body.appendChild(el)
  201. el.click()
  202. document.body.removeChild(el)
  203. }
  204. const handleReturn = (typeItem) => {
  205. router.push({ path: '/', query: { id: typeItem.id } })
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. :deep(.van-grid-item__content--surround:after) {
  210. border: 4px solid #e5e7eb;
  211. }
  212. .active {
  213. :deep(.van-grid-item__content--surround:after) {
  214. border: 4px solid #004ea2;
  215. }
  216. }
  217. </style>