project-tech-submit.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div>
  3. <div class="my-title">处理</div>
  4. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  5. <el-row class="my-row">
  6. <el-col :span="6">
  7. <el-form-item label="项目名称:" prop="projectName">
  8. <span>{{ dataForm.projectName }}</span>
  9. </el-form-item>
  10. </el-col>
  11. <el-col :span="6">
  12. <el-form-item label="任务号:" prop="orderCode">
  13. <span>{{ dataForm.orderCode }}</span>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="6">
  17. <el-form-item label="技术协议:" prop="attachList1">
  18. <span class="attch-file" @click="attachDetail(dataForm.attachList1)">{{ dataForm.attachList1 == null ||
  19. dataForm.attachList1.length == 0 ? '' : dataForm.attachList1[0].fileName }}</span>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="6">
  23. <el-form-item label="资料:" prop="attachList2">
  24. <span class="attch-file" @click="attachDetail(dataForm.attachList2)">{{ dataForm.attachList2 == null ||
  25. dataForm.attachList2.length == 0 ? '' : dataForm.attachList2[0].fileName }}</span>
  26. </el-form-item>
  27. </el-col>
  28. </el-row>
  29. <el-table :data="dataForm.proProductList" border v-loading="dataListLoading" style="width: 100%;">
  30. <el-table-column label="序号" type="index" width="100" align="center">
  31. </el-table-column>
  32. <el-table-column prop="productName" header-align="center" align="center" min-width="140"
  33. :show-tooltip-when-overflow="true" label="名称">
  34. </el-table-column>
  35. <el-table-column prop="mapNumber" header-align="center" align="center" min-width="140"
  36. :show-tooltip-when-overflow="true" label="图号">
  37. </el-table-column>
  38. <el-table-column prop="versionNumber" header-align="center" align="center" min-width="140"
  39. :show-tooltip-when-overflow="true" label="版本号">
  40. </el-table-column>
  41. <el-table-column prop="attachList2" header-align="center" align="center" min-width="100"
  42. :show-tooltip-when-overflow="true" label="简图">
  43. <template slot-scope="scope">
  44. <div class="thumb-list" v-if="getImageList(scope.row.attachList2).length">
  45. <img v-for="(img, idx) in getImageList(scope.row.attachList2)" :key="(img.url || '') + idx" class="thumb"
  46. :src="downloadUrl + img.url" :alt="img.fileName" @click="previewFile(img.fileName, img.url)" />
  47. </div>
  48. </template>
  49. </el-table-column>
  50. <el-table-column prop="materials" header-align="center" align="center" min-width="140"
  51. :show-tooltip-when-overflow="true" label="材料">
  52. </el-table-column>
  53. <el-table-column prop="unit" header-align="center" align="center" min-width="140"
  54. :show-tooltip-when-overflow="true" label="单位">
  55. </el-table-column>
  56. <el-table-column prop="cnt" header-align="center" align="center" min-width="140"
  57. :show-tooltip-when-overflow="true" label="单套数量">
  58. </el-table-column>
  59. <el-table-column prop="productSpec" header-align="center" align="center" min-width="140"
  60. :show-tooltip-when-overflow="true" label="材料规格">
  61. </el-table-column>
  62. <el-table-column prop="size" header-align="center" align="center" min-width="140"
  63. :show-tooltip-when-overflow="true" label="净尺寸">
  64. </el-table-column>
  65. <el-table-column prop="projectName" header-align="center" align="center" min-width="140"
  66. :show-tooltip-when-overflow="true" label="表处理">
  67. </el-table-column>
  68. <el-table-column prop="heatTreatment" header-align="center" align="center" min-width="140"
  69. :show-tooltip-when-overflow="true" label="热处理">
  70. </el-table-column>
  71. <el-table-column prop="projectName" header-align="center" align="center" min-width="140"
  72. :show-tooltip-when-overflow="true" label="关重性">
  73. </el-table-column>
  74. <el-table-column fixed="right" prop="isTechnology" header-align="center" align="center" min-width="140"
  75. :show-tooltip-when-overflow="true" label="是否编制工艺">
  76. <template slot-scope="scope">
  77. {{ scope.row.isTechnology == 2 ? '否' : '是' }}
  78. </template>
  79. </el-table-column>
  80. <el-table-column fixed="right" prop="techId" header-align="center" align="center" min-width="140"
  81. :show-tooltip-when-overflow="true" label="是否有工艺">
  82. <template slot-scope="scope">
  83. {{ scope.row.techId == null || scope.row.techId == 0 ? '否' : '是' }}
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="notes" header-align="center" align="center" min-width="140"
  87. :show-tooltip-when-overflow="true" label="备注">
  88. </el-table-column>
  89. <el-table-column v-if="!disabled" fixed="right" prop="disposal" header-align="center" align="center" width="120"
  90. :show-tooltip-when-overflow="true" label="操作">
  91. <template slot-scope="scope">
  92. <el-button type="text" v-if="scope.row.techId == null || scope.row.techId == 0"
  93. @click="handleCrafts(0)">新建工艺</el-button>
  94. <el-button type="text" v-else @click="handleCrafts(scope.row.techId)">修改工艺</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. </el-form>
  99. <span slot="footer" class="dialog-footer">
  100. <el-button @click="onChose">取消</el-button>
  101. </span>
  102. <attach-detail-dialog ref="attachDetail" />
  103. <preview-component v-if="previewVisible" ref="preview" />
  104. </div>
  105. </template>
  106. <script>
  107. import AttachDetailDialog from '../common/attach-detail-dialog'
  108. import PreviewComponent from '../common/preview-component'
  109. import { downloadUrl } from '@/api/file'
  110. export default {
  111. name: 'plan-submit',
  112. components: { AttachDetailDialog, PreviewComponent },
  113. computed: {},
  114. data() {
  115. return {
  116. disabled: false,
  117. id: 0,
  118. dataForm: {
  119. proProductList: []
  120. },
  121. dataRule: {
  122. planCnt: [{ required: true, message: '请输入', trigger: 'blur' }],
  123. disposal: [{ required: true, message: '请选择', trigger: 'change' }],
  124. isTechnology: [{ required: true, message: '请选择', trigger: 'change' }]
  125. },
  126. dataList: [],
  127. dataListLoading: false,
  128. craftsAddOrDetailVisible: false,
  129. previewVisible: false,
  130. downloadUrl: downloadUrl
  131. }
  132. },
  133. created() { },
  134. beforeDestroy() { },
  135. methods: {
  136. onChose() {
  137. this.$emit('refreshDataList')
  138. this.$emit('onChose')
  139. },
  140. async init(item, readonly) {
  141. let id = item.technologyId
  142. if (readonly) {
  143. this.disabled = true
  144. }
  145. this.$http({
  146. url: this.$http.adornUrl(`/biz-service/projTechnology/info/${id}`),
  147. method: 'get'
  148. }).then(({ data }) => {
  149. if (data && data.code === '200') {
  150. this.dataForm = data.data
  151. data.data.proProductList.map(item => {
  152. if (item.proProductList != null && item.proProductList.length > 0) {
  153. item.proProductList.map(item2 => {
  154. this.dataForm.proProductList.push(item2)
  155. })
  156. }
  157. })
  158. } else {
  159. this.$message.error(data.msg)
  160. }
  161. })
  162. },
  163. validateField(type) {
  164. this.$refs.dataForm.validateField(type)
  165. },
  166. attachDetail(attachList) {
  167. this.$nextTick(() => {
  168. this.$refs.attachDetail.init(attachList)
  169. })
  170. },
  171. // 过滤图片附件
  172. getImageList(attachList) {
  173. if (!attachList || !Array.isArray(attachList)) return []
  174. return attachList.filter(item => this.isImage(item && item.fileName))
  175. },
  176. isImage(fileName) {
  177. if (!fileName || typeof fileName !== 'string') return false
  178. const ext = fileName.split('.').pop().toLowerCase()
  179. return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(ext)
  180. },
  181. // 预览大图
  182. previewFile(fileName, url) {
  183. this.previewVisible = true
  184. this.$nextTick(() => {
  185. this.$refs.preview && this.$refs.preview.init(fileName, url)
  186. })
  187. },
  188. // 表单提交
  189. dataFormSubmit() {
  190. this.$refs['dataForm'].validate((valid) => {
  191. if (valid) {
  192. let data = {
  193. orderCode: this.dataForm.orderCode,
  194. proProductList: this.dataForm.proProductList
  195. }
  196. console.log('data', data)
  197. this.$http({
  198. url: this.$http.adornUrl(`/biz-service/projProduction/submitPlan`),
  199. method: 'post',
  200. data: this.$http.adornData(data)
  201. }).then(({ data }) => {
  202. if (data && data.code === '200') {
  203. this.$message({
  204. message: '操作成功',
  205. type: 'success',
  206. duration: 1500,
  207. onClose: () => {
  208. this.onChose()
  209. this.$emit('refreshDataList')
  210. }
  211. })
  212. } else {
  213. this.$message.error(data.msg)
  214. }
  215. })
  216. }
  217. })
  218. },
  219. handleCrafts(techId) {
  220. this.$emit('showCraftsAddOrDetail', techId)
  221. }
  222. }
  223. }
  224. </script>
  225. <style>
  226. .my-row {
  227. margin-bottom: 20px;
  228. }
  229. .radio-group-wrap {
  230. display: flex;
  231. align-items: flex-start;
  232. flex-direction: column;
  233. gap: 10px 0px;
  234. /* 行列间距控制 */
  235. }
  236. .attch-file {
  237. cursor: pointer;
  238. color: #3e8ef7;
  239. }
  240. /* 缩略图样式 */
  241. .thumb-list {
  242. display: flex;
  243. flex-wrap: wrap;
  244. gap: 6px;
  245. justify-content: center;
  246. }
  247. .thumb {
  248. width: 48px;
  249. height: 48px;
  250. object-fit: cover;
  251. border: 1px solid #ebeef5;
  252. border-radius: 4px;
  253. cursor: pointer;
  254. }
  255. </style>