DetailView.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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-[1280px] mx-auto">
  8. <div
  9. class="font-['PingFang-Heavy'] px-3 mibold text-xl md:text-[32px] md:leading-tight"
  10. >
  11. 工具数字化展示
  12. </div>
  13. <div class="flex mt-4 flex-wrap">
  14. <div
  15. class="ml-3 text-[14px] font-semibold cursor-pointer"
  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="w-full object-cover 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' : '', 'cursor-pointer']"
  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. {{ toolInfoRef.toolName }}
  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="my-8">
  64. <!-- 搜索表单 -->
  65. <el-form :model="queryParams" ref="searchFormRef" :inline="true" v-show="showSearch">
  66. <el-form-item label="物料编码" prop="materialNo">
  67. <el-input
  68. v-model="queryParams.materialNo"
  69. placeholder="请输入物料编码"
  70. clearable
  71. style="width: 200px"
  72. @keyup.enter="handleQuery"
  73. />
  74. </el-form-item>
  75. <el-form-item label="物料名称" prop="materialName">
  76. <el-input
  77. v-model="queryParams.materialName"
  78. placeholder="请输入物料名称"
  79. clearable
  80. style="width: 200px"
  81. @keyup.enter="handleQuery"
  82. />
  83. </el-form-item>
  84. <el-form-item>
  85. <el-button type="primary" @click="handleQuery">搜索</el-button>
  86. <el-button @click="resetQuery">重置</el-button>
  87. </el-form-item>
  88. </el-form>
  89. <!-- 是否展示搜索图标 -->
  90. <van-icon class="float-right" name="search" @click="toggleSearch()" />
  91. <!-- 表格 -->
  92. <el-table :data="wlList">
  93. <el-table-column label="物料编码" align="center" prop="materialNo">
  94. <template #default="scope">
  95. <div class="flex items-center justify-center">
  96. <div>{{ scope.row.materialNo }}</div>
  97. <van-icon
  98. name="description-o"
  99. class="text-[#004EA2] description-o ml-1 cursor-pointer"
  100. @click="codeCopy(scope.row.materialNo)"
  101. />
  102. </div>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="物料名称" align="center" prop="materialName" />
  106. <el-table-column label="规格" align="center" prop="specifications" />
  107. </el-table>
  108. <div class="w-full mt-2">
  109. <el-pagination
  110. background
  111. hide-on-single-page
  112. :current-page="pageNum"
  113. :page-size="5"
  114. :pager-count="5"
  115. layout="->,prev, pager, next"
  116. :total="total"
  117. @current-change="handleCurrentChange"
  118. />
  119. </div>
  120. </div>
  121. <div class="font-['PingFang-SC'] text-sm font-normal mt-4">
  122. <div class="font-semibold">标准规格说明:</div>
  123. <div>{{ toolInfoRef.specifications }}</div>
  124. </div>
  125. <div class="font-['PingFang-SC'] text-sm font-normal mt-4">
  126. <div class="font-semibold">举例:</div>
  127. <div>{{ toolInfoRef.example }}</div>
  128. </div>
  129. <div class="font-['PingFang-SC'] text-sm font-normal mt-4">
  130. <div class="font-semibold">附件:</div>
  131. <van-cell-group v-if="fileList.length > 0">
  132. <van-cell v-for="file in fileList" :key="file.id">
  133. <template #title>
  134. <span class="cursor-pointer" @click="fileDownload(file)">{{
  135. file.fileName
  136. }}</span>
  137. </template>
  138. <template #right-icon>
  139. <img
  140. class="w-[18px] h-[18px] cursor-pointer"
  141. src="../assets/images/download.png"
  142. alt=""
  143. @click="fileDownload(file)"
  144. />
  145. </template>
  146. </van-cell>
  147. </van-cell-group>
  148. <van-empty v-else image-size="100" description="暂无数据" />
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </section>
  154. <!-- <h1 class="text-3xl font-bold underline" @click="goBack">详情页</h1> -->
  155. </div>
  156. </template>
  157. <script setup name="AboutView">
  158. import { ref } from 'vue'
  159. import { useRoute, useRouter } from 'vue-router'
  160. import { detailList } from '@/api/index.js'
  161. import Clipboard from 'clipboard'
  162. import { listTools, getwlList } from '@/api/index.js'
  163. import { ElMessage } from 'element-plus'
  164. const router = useRouter()
  165. const route = useRoute()
  166. const queryId = ref(route.query.id)
  167. const wlList = ref([])
  168. // const wlSelectId = ref(0)
  169. // const selectWlCode = ref('')
  170. // const selectMaterialName = ref('')
  171. const sytList = ref([])
  172. const fileList = ref([])
  173. const detailImg = ref(0)
  174. const sytPath = ref('')
  175. const devPath = import.meta.env.VITE_APP_BASE_API
  176. const breadTitle = ref('')
  177. const typeOptions1Ref = ref([])
  178. const toolInfoRef = ref({})
  179. // 物料搜索相关参数
  180. const queryParams = ref({
  181. materialNo: '',
  182. materialName: ''
  183. })
  184. const showSearch = ref(false)
  185. const pageNum = ref(1)
  186. const total = ref(0)
  187. const getWlList = (params) => {
  188. getwlList({ basisId: queryId.value, ...params }).then((res) => {
  189. console.log(res)
  190. wlList.value = res.rows
  191. total.value = res.total
  192. })
  193. }
  194. const init = () => {
  195. // 查详情
  196. detailList({ id: queryId.value }).then((res) => {
  197. const toolDetails = res.data.toolDetails || []
  198. toolInfoRef.value = res.data.toolData || {}
  199. sytList.value = toolDetails.filter((item) => item.informationType === 'syt')
  200. if (sytList.value.length > 0) {
  201. detailImg.value = sytList.value[0].id
  202. sytPath.value = sytList.value[0].filePath
  203. }
  204. fileList.value = toolDetails.filter(
  205. (item) => item.informationType !== 'syt' && item.informationType !== 'wl'
  206. )
  207. const ttoolBasis = res.data.ttoolBasis
  208. breadTitle.value = ttoolBasis.map((item) => item.toolName).join(' > ')
  209. })
  210. listTools({
  211. level: '1',
  212. pageSize: 999
  213. }).then((res) => {
  214. typeOptions1Ref.value = res.rows
  215. })
  216. // 查物料详情的
  217. getWlList({ pageNum: 1, pageSize: 5 })
  218. }
  219. init()
  220. const changeImg = ({ id, filePath }) => {
  221. detailImg.value = id
  222. sytPath.value = filePath
  223. }
  224. const codeCopy = async (val) => {
  225. // console.log(val)
  226. const clipboard = new Clipboard('.description-o', {
  227. text: () => val
  228. })
  229. // 添加成功事件处理函数
  230. clipboard.on('success', (e) => {
  231. e.clearSelection()
  232. ElMessage.success('复制成功')
  233. clipboard.destroy()
  234. })
  235. // 添加失败事件处理函数
  236. clipboard.on('error', () => {
  237. ElMessage.error('无法复制到剪贴板!')
  238. console.warn('无法复制到剪贴板!')
  239. })
  240. }
  241. // const changeWlCode = ({ id, materialNo, materialName }) => {
  242. // wlSelectId.value = id
  243. // selectWlCode.value = materialNo
  244. // selectMaterialName.value = materialName
  245. // }
  246. // informationType 物料 wl 点击切换 物料编码 materialNo
  247. // informationType 示意图 syt 左侧图
  248. const fileDownload = ({ fileName, filePath }) => {
  249. // console.log('filePath', filePath)
  250. const el = document.createElement('a')
  251. el.style.display = 'none'
  252. el.setAttribute('target', '_blank')
  253. fileName && el.setAttribute('download', fileName)
  254. el.href = devPath + filePath
  255. document.body.appendChild(el)
  256. el.click()
  257. document.body.removeChild(el)
  258. }
  259. const handleReturn = (typeItem) => {
  260. router.push({ path: '/home', query: { id: typeItem.id } })
  261. }
  262. // 搜索物料
  263. const handleQuery = () => {
  264. const params = {
  265. materialNo: queryParams.value.materialNo || '',
  266. materialName: queryParams.value.materialName || '',
  267. // 看看有没有分页
  268. pageNum: pageNum.value,
  269. pageSize: 5
  270. }
  271. // console.log('搜索物料', params)
  272. getWlList(params)
  273. }
  274. const searchFormRef = ref(null)
  275. // 重置
  276. const resetQuery = () => {
  277. searchFormRef.value.resetFields()
  278. handleQuery()
  279. }
  280. // 切换分页
  281. const handleCurrentChange = (val) => {
  282. // console.log(val)
  283. pageNum.value = val
  284. handleQuery()
  285. }
  286. // 显示搜索框
  287. const toggleSearch = () => {
  288. showSearch.value = !showSearch.value
  289. }
  290. </script>
  291. <style lang="scss" scoped>
  292. :deep(.van-grid-item__content--surround:after) {
  293. border: 4px solid #e5e7eb;
  294. }
  295. .active {
  296. :deep(.van-grid-item__content--surround:after) {
  297. border: 4px solid #004ea2;
  298. }
  299. }
  300. </style>