drawingDetail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <div class="page-container column-container">
  3. <section class="list-part-container">
  4. <!-- 搜索区域 -->
  5. <el-form class="list-search-container" :inline="true">
  6. <el-form-item label="客户:">
  7. {{ currentProduct.companyAlias }}
  8. </el-form-item>
  9. <el-form-item label="图号:">
  10. {{ currentProduct.drawingNumber }}
  11. </el-form-item>
  12. <el-form-item label="规格:">
  13. {{ currentProduct.specification }}
  14. </el-form-item>
  15. <el-form-item label="产品描述:">
  16. {{ currentProduct.description }}
  17. </el-form-item>
  18. <el-form-item>
  19. </el-form-item>
  20. <el-form-item class="section-title" label="工艺版本:">
  21. <el-select-v2 v-model="currentTechnological.id" :options="technologicalProcessList" placeholder="请选择版本"
  22. @change="handelTechnological" style="width: 200px" />
  23. </el-form-item>
  24. <el-form-item class="section-title" label="当前工序:">
  25. <el-select-v2 v-model="technologicalDetailId" clearable :options="technologicalProcessDetailsList"
  26. placeholder="请选择工序" style="width: 200px" @change="handleDetailsChange" />
  27. </el-form-item>
  28. </el-form>
  29. </section>
  30. <div class="page-container row-container">
  31. <section class="list-part-container" style="flex: 4">
  32. <div class="list-btns-container">
  33. <el-button type="primary" icon="Plus" v-hasPermi="['business:electronicDrawings:add']"
  34. @click="handelUpload()">上传
  35. </el-button>
  36. </div>
  37. <div class="page-container form-container">
  38. <!-- 列表区 -->
  39. <div class="el-table-container">
  40. <el-table ref="equipmentTable" v-loading="loading" row-key="id"
  41. @current-change="handleSelectionChange" :data="drawingList" height="600px">
  42. <!-- <el-table-column type="selection" width="40" align="center" /> -->
  43. <el-table-column type="index" label="行号" width="50" align="center" />
  44. <el-table-column label="图纸" prop="drawingName" align="center">
  45. <template #default="scope">
  46. <el-button link type="primary">{{
  47. scope.row.drawingName }}</el-button>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="状态" width="80px" prop="status" align="center">
  51. <template #default="scope">
  52. <dict-tag :options="drawing_status" :value="scope.row.status" />
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="是否废弃" width="80px" prop="abandoned" align="center">
  56. <template #default="scope">
  57. <dict-tag :options="drawing_type" :value="scope.row.abandoned" />
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="制作人" width="100px" prop="producer" align="center" />
  61. <el-table-column label="审核人" width="100px" prop="reviewer" align="center" />
  62. <el-table-column label="批准人" width="100px" prop="issuer" align="center" />
  63. <el-table-column fixed="right" label="操作" align="center" width="280px">
  64. <template #default="scope">
  65. <el-button v-if="scope.row.status == 0 && scope.row.abandoned == 0" link type="primary"
  66. v-hasPermi="['business:electronicDrawings:examine']"
  67. @click="handlePreview(scope.row)">审核
  68. </el-button>
  69. <el-button v-if="scope.row.status == 1" link type="success" plain
  70. v-hasPermi="['business:electronicDrawings:raift']"
  71. @click="handlePreview(scope.row)">批准</el-button>
  72. <el-upload :action="webHost + '/common/upload'" :headers="headers" :limit="1"
  73. :on-success="handleReplaceSuccess" :on-exceed="handleReplaceExceed"
  74. :before-upload="beforeUpload" :show-file-list="false">
  75. <el-button v-if="scope.row.status == 2 && scope.row.abandoned == 0" link
  76. type="warning" plain
  77. v-hasPermi="['business:electronicDrawings:replace']">替换</el-button>
  78. </el-upload>
  79. <el-button
  80. v-if="(scope.row.status == 0 || scope.row.status == 1) && scope.row.abandoned == 0"
  81. link type="danger" v-hasPermi="['business:electronicDrawings:NG']"
  82. @click="handleDrawingNG(scope.row)">NG
  83. </el-button>
  84. <el-button v-if="scope.row.status == 2 && scope.row.abandoned == 0" link type="danger"
  85. v-hasPermi="['business:electronicDrawings:remove']"
  86. @click="handleDrawingRemove(scope.row)">作废
  87. </el-button>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. </div>
  92. <!-- 分页 -->
  93. <pagination v-show="total > 0" :total="total" v-model:page="queryparams.pageNum"
  94. v-model:limit="queryparams.pageSize" @pagination="getDrawing" />
  95. </div>
  96. </section>
  97. <section class="list-part-container" style="flex: 3">
  98. <el-form class="list-search-container" :model="draform" ref="queryRef" :inline="true"
  99. style="margin-right: 0px">
  100. <el-form-item class="section-title" label="预览" />
  101. <el-form-item style="float: inline-end;margin-top: 8px;">
  102. <el-button link type="primary" v-hasPermi="['business:product:remove']"
  103. @click="openDrawing">全屏预览</el-button>
  104. </el-form-item>
  105. </el-form>
  106. <iframe :src="drawingUrl" frameborder="no" style="width: 100%; height: 100%" scrolling="auto" />
  107. </section>
  108. </div>
  109. <!-- 添加图纸对话框 -->
  110. <el-dialog title="上传文件" v-model="open" width="500px" append-to-body>
  111. <el-form ref="drawingRef" :model="form" :rules="rules" label-width="120px" v-loading="formLoading">
  112. <el-form-item label="工序:" prop="technologicalProcessDetailId">
  113. <el-select-v2 v-model="form.technologicalProcessDetailId" clearable
  114. :options="technologicalProcessDetailsList" placeholder="请选择工序:" @change="handleDetailsFormChange"
  115. style="width: 200px" />
  116. </el-form-item>
  117. <el-form-item label="标识:" prop="identification">
  118. <el-checkbox v-model="form.identification" label="重" size="large" />
  119. <el-checkbox v-model="form.markD" label="D标识" size="large" />
  120. </el-form-item>
  121. <el-form-item label="上传文件:" prop="url">
  122. <el-input disabled v-model="form.url" placeholder="上传文件">
  123. <template #append>
  124. <el-upload :disabled="!form.technologicalProcessDetailId" :action="webHost + '/common/upload'"
  125. :headers="headers" :limit="1" :on-success="handleSuccess" :on-exceed="handleExceed"
  126. :before-upload="beforeUpload" :show-file-list="false">
  127. <el-button icon="Upload"></el-button>
  128. </el-upload>
  129. </template>
  130. </el-input>
  131. </el-form-item>
  132. </el-form>
  133. <template #footer>
  134. <div class="dialog-footer">
  135. <el-button :disabled="!form.url" type="primary" @click="submitForm">确 定</el-button>
  136. <el-button @click="cancel">取 消</el-button>
  137. </div>
  138. </template>
  139. </el-dialog>
  140. </div>
  141. </template>
  142. <script setup name="drawingDetails">
  143. import { ref } from "vue";
  144. import { getToken } from '@/utils/auth'
  145. import { getNormalDrawing, getListByName, saveDrawing, drawingNG, replace, drawingRemove } from "@/api/business/drawing";
  146. import useUserStore from '@/store/modules/user'
  147. import { getTechnological, getById } from '@/api/business/product'
  148. import { getTechnologicalProcessDetails } from '@/api/business/technologicalProcessDetail'
  149. const drawingUrl = ref('')
  150. const webHost = import.meta.env.VITE_APP_BASE_API
  151. const fileUrl = import.meta.env.VITE_PREVIEW_API
  152. const hostUrl = import.meta.env.VITE_HOST_URL
  153. const { proxy } = getCurrentInstance();
  154. const { drawing_status } = proxy.useDict("drawing_status");
  155. const { drawing_type } = proxy.useDict("drawing_type");
  156. const total = ref(0)
  157. const route = useRoute();
  158. const coverName = ref("")
  159. const currentProduct = ref({})
  160. const currentTechnological = ref({})
  161. const formLoading = ref(false)
  162. const currentTechnologicalDetail = ref({})
  163. const technologicalProcessList = ref([])
  164. const technologicalProcessDetailsList = ref([])
  165. const technologicalDetailId = ref(null)
  166. const open = ref(false)
  167. const draform = ref({})
  168. const currentDrawing = ref({})
  169. const replaceForm = ref({})
  170. const repeatingDrawings = ref([])
  171. const loading = ref(false);
  172. const drawingList = ref([])
  173. const headers = { Authorization: getToken() }
  174. const productId = ref(null)
  175. const technologicalprocessDetailId = ref(null)
  176. const technologicalprocessId = ref(null)
  177. /** 查询对象 */
  178. const data = reactive({
  179. queryparams: {
  180. pageNum: 1,
  181. pageSize: 10,
  182. technologicalProcessDetailId: null
  183. },
  184. form: {
  185. pageNum: 1,
  186. pageSize: 10,
  187. technologicalProcessDetailId: null,
  188. groupDetailList: [],
  189. code: "",
  190. remark: "",
  191. type: false
  192. },
  193. rules: {
  194. technologicalProcessDetailId: [{ required: true, message: "工序不能为空", trigger: "blur" }],
  195. },
  196. });
  197. const { form, rules, queryparams } = toRefs(data);
  198. function getList() {
  199. console.log(route.params)
  200. // 解析查询字符串
  201. // var urlSearchParams = new URLSearchParams(route.params.currentProduct);
  202. // 将 URLSearchParams 对象转换为普通对象
  203. // var paramsObject = Object.fromEntries(urlSearchParams);
  204. // currentProduct.value = paramsObject
  205. productId.value = route.params.productId
  206. technologicalprocessId.value = route.params.productProcessId
  207. if (route.params.processDetailId) {
  208. console.log(route.params.processDetailId)
  209. technologicalprocessDetailId.value = route.params.processDetailId
  210. }
  211. //查询产品
  212. getById(productId.value).then(resMsg => {
  213. if (resMsg.code == 200) {
  214. currentProduct.value = resMsg.data
  215. }
  216. })
  217. //查询工艺版本
  218. getTechnological({ productId: productId.value }).then(res => {
  219. if (res.code == 200) {
  220. technologicalProcessList.value = res.data
  221. //版本下拉框默认值
  222. currentTechnological.value.id = technologicalprocessId.value
  223. if (technologicalprocessDetailId.value !== undefined && technologicalprocessDetailId.value !== null && technologicalprocessDetailId.value !== 'undefined') {
  224. technologicalDetailId.value = technologicalprocessDetailId.value
  225. currentTechnologicalDetail.value.id = technologicalprocessDetailId.value
  226. }
  227. //查询工艺工序
  228. getTechnologicalProcessDetails({ technologicalProcessId: currentTechnological.value.id }).then(response => {
  229. if (response.code == 200) {
  230. technologicalProcessDetailsList.value = response.data
  231. getDrawing()
  232. }
  233. })
  234. }
  235. })
  236. }
  237. function handleDetailsFormChange() {
  238. console.log(form.value.technologicalProcessDetailId)
  239. console.log(technologicalDetailId.value, 123123)
  240. technologicalDetailId.value = form.value.technologicalProcessDetailId
  241. }
  242. function openDrawing() {
  243. window.open(drawingUrl.value)
  244. // console.log(fileUrl + hostUrl + webHost + row.url,9797)
  245. // console.log(document.location.protocol)
  246. }
  247. function handleSelectionChange(row) {
  248. currentDrawing.value = row
  249. drawingUrl.value = fileUrl + encodeURIComponent(Base64.encode(hostUrl + webHost + row.url))
  250. console.log(hostUrl + webHost + row.url)
  251. console.log(document.location)
  252. }
  253. /**文件数量超出的回调 */
  254. function handleExceed(files) {
  255. form.value.url = files[0].url
  256. }
  257. /** 文件上传前的 回调事件 */
  258. function beforeUpload(file) {
  259. formLoading.value = true
  260. const allowedTypes = ['application/pdf'];
  261. const isAllowed = allowedTypes.includes(file.type);
  262. if (!isAllowed) {
  263. proxy.$modal.msgError('只能上传 PDF 格式的文件!')
  264. formLoading.value = false
  265. return false
  266. }
  267. }
  268. function handelUpload() {
  269. open.value = true
  270. form.value.technologicalProcessDetailId = currentTechnologicalDetail.value.id
  271. console.log(currentTechnologicalDetail.value.id)
  272. console.log(technologicalDetailId.value)
  273. }
  274. /**获取图纸列表 */
  275. function getDrawing() {
  276. console.log(currentTechnological.value.id)
  277. queryparams.value.technologicalProcessId = currentTechnological.value.id
  278. if (currentTechnologicalDetail.value.id !== undefined && currentTechnologicalDetail.value.id !== 'undefined') {
  279. queryparams.value.technologicalProcessDetailId = currentTechnologicalDetail.value.id
  280. }
  281. getNormalDrawing(queryparams.value).then(res => {
  282. if (res.code == 200) {
  283. drawingList.value = res.rows
  284. console.log(res.rows)
  285. total.value = res.total
  286. }
  287. })
  288. }
  289. /**上传成功回调 */
  290. function handleSuccess(row) {
  291. form.value.url = row.fileName
  292. var fileDrawing = {}
  293. fileDrawing.drawingName = row.originalFilename
  294. fileDrawing.technologicalProcessDetailId = currentTechnologicalDetail.value.id
  295. getListByName(fileDrawing).then(res => {
  296. // debugger;
  297. if (res.code == 200) {
  298. console.log(res, "数据库查询")
  299. repeatingDrawings.value = res.data
  300. if (repeatingDrawings.value.length == 0) {
  301. coverName.value = row.originalFilename
  302. formLoading.value = false
  303. } else {
  304. //判断重名文件状态是否已发行需要替换
  305. if (repeatingDrawings.value[0].status == 0) {
  306. proxy.$modal.msgWarning("待审核中已有相同文件");
  307. var item = {}
  308. item = repeatingDrawings.value[0]
  309. item.parentId = currentDrawing.value.id
  310. item.id = null
  311. item.url = replaceForm.value.url
  312. item.drawingName = fileDrawing.drawingName
  313. item.technologicalProcessDetailId = fileDrawing.technologicalProcessDetailId
  314. handleReplace(item)
  315. } else {
  316. proxy.$modal.msgError("已有相同文件,请修改后重新上传");
  317. open.value = false
  318. }
  319. }
  320. }
  321. })
  322. }
  323. /**文件数量超出的回调 */
  324. function handleReplaceExceed(files) {
  325. replaceForm.value.url = files[0].url
  326. }
  327. /**上传成功回调 */
  328. function handleReplaceSuccess(row) {
  329. replaceForm.value.url = row.fileName
  330. var fileDrawing = {}
  331. fileDrawing.drawingName = row.originalFilename
  332. fileDrawing.technologicalProcessDetailId = currentTechnologicalDetail.value.id
  333. var item = {}
  334. item.parentId = currentDrawing.value.id
  335. item.id = null
  336. item.url = replaceForm.value.url
  337. item.drawingName = fileDrawing.drawingName
  338. item.technologicalProcessDetailId = fileDrawing.technologicalProcessDetailId
  339. handleReplace(item)
  340. }
  341. function submitForm() {
  342. proxy.$refs["drawingRef"].validate((valid) => {
  343. console.log(proxy.$refs["drawingRef"])
  344. if (valid) {
  345. open.value = false
  346. saveDrawingDetail()
  347. }
  348. });
  349. }
  350. /**保存方法 */
  351. function saveDrawingDetail() {
  352. if (currentTechnologicalDetail.value.id !== undefined && currentTechnologicalDetail.value.id !== null && currentTechnologicalDetail.value.id !== 'undefined') {
  353. form.value.technologicalProcessDetailId = currentTechnologicalDetail.value.id
  354. }
  355. form.value.drawingName = coverName.value
  356. var itemList = []
  357. itemList.push(form.value)
  358. saveDrawing(itemList).then(res => {
  359. if (res.code == 200) {
  360. reset();
  361. getList();
  362. formLoading.value = false
  363. }
  364. })
  365. }
  366. /**审核 */
  367. function handlePreview(row) {
  368. var drawing = []
  369. drawing.push(row)
  370. saveDrawing(drawing).then(res => {
  371. if (res.code == 200) {
  372. proxy.$modal.msgSuccess("审核通过");
  373. reset()
  374. getList();
  375. }
  376. })
  377. }
  378. function reset() {
  379. form.value = {
  380. pageNum: 1,
  381. pageSize: 10,
  382. code: null,
  383. remark: null,
  384. groupDetailList: [],
  385. url: null,
  386. drawingName: null,
  387. type: false
  388. };
  389. currentProduct.value = {}
  390. currentTechnologicalDetail.value = {}
  391. currentTechnological.value = {}
  392. coverName.value = ''
  393. repeatingDrawings.value = []
  394. proxy.resetForm("drawingRef");
  395. }
  396. // 取消按钮
  397. function cancel() {
  398. open.value = false
  399. reset()
  400. }
  401. /**版本change事件 */
  402. function handelTechnological(row) {
  403. getDrawing()
  404. }
  405. /**工序选择change事件 */
  406. function handleDetailsChange(row) {
  407. currentTechnologicalDetail.value.id = technologicalDetailId.value == undefined ? null : technologicalDetailId.value
  408. getDrawing()
  409. }
  410. /**NG电子图纸 */
  411. function handleDrawingNG(row) {
  412. console.log(row)
  413. proxy.$modal
  414. .confirm("是否确认NG?")
  415. .then(function () {
  416. var itemList = []
  417. itemList.push(row)
  418. return drawingNG(itemList);
  419. })
  420. .then(() => {
  421. reset()
  422. getList();
  423. open.value = false
  424. proxy.$modal.msgSuccess("操作成功");
  425. })
  426. .catch(() => { });
  427. }
  428. /**废弃电子图纸 */
  429. function handleDrawingRemove(row) {
  430. console.log(row)
  431. proxy.$modal
  432. .confirm("是否确认作废?")
  433. .then(function () {
  434. var itemList = []
  435. itemList.push(row)
  436. return drawingRemove(itemList);
  437. })
  438. .then(() => {
  439. reset()
  440. getList();
  441. open.value = false
  442. proxy.$modal.msgSuccess("操作成功");
  443. })
  444. .catch(() => { });
  445. }
  446. function handleReplace(row) {
  447. proxy.$modal
  448. .confirm("是否确认替换图纸?")
  449. .then(function () {
  450. return replace(row);
  451. })
  452. .then(() => {
  453. reset()
  454. getList();
  455. open.value = false
  456. proxy.$modal.msgSuccess("替换成功");
  457. })
  458. .catch(() => { });
  459. }
  460. getList()
  461. </script>
  462. <style scoped>
  463. :deep(.el-form-item .el-form-item__label) {
  464. font-size: 18px !important;
  465. padding-right: 0 !important;
  466. }
  467. :deep(#list-search-container .el-form-item--default .el-form-item__content) {
  468. line-height: 32px;
  469. font-size: 18px;
  470. }
  471. </style>