plan-submit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 header-align="center" align="center" min-width="140" :show-tooltip-when-overflow="true"
  42. label="简图">
  43. <template slot-scope="scope">
  44. <el-button :disabled="!scope.row.attachList2 || scope.row.attachList2.length === 0" type="text" size="small"
  45. @click="attachDetail(scope.row.attachList2)">查看</el-button>
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="unit" header-align="center" align="center" min-width="140"
  49. :show-tooltip-when-overflow="true" label="单位">
  50. </el-table-column>
  51. <el-table-column prop="cnt" header-align="center" align="center" min-width="140"
  52. :show-tooltip-when-overflow="true" label="单套数量">
  53. </el-table-column>
  54. <el-table-column prop="productSpec" header-align="center" align="center" min-width="140"
  55. :show-tooltip-when-overflow="true" label="材料规格">
  56. </el-table-column>
  57. <el-table-column prop="size" header-align="center" align="center" min-width="140"
  58. :show-tooltip-when-overflow="true" label="净尺寸">
  59. </el-table-column>
  60. <el-table-column prop="projectName" header-align="center" align="center" min-width="140"
  61. :show-tooltip-when-overflow="true" label="表处理">
  62. </el-table-column>
  63. <el-table-column prop="heatTreatment" header-align="center" align="center" min-width="140"
  64. :show-tooltip-when-overflow="true" label="热处理">
  65. </el-table-column>
  66. <el-table-column prop="projectName" header-align="center" align="center" min-width="140"
  67. :show-tooltip-when-overflow="true" label="关重性">
  68. </el-table-column>
  69. <el-table-column prop="notes" header-align="center" align="center" min-width="140"
  70. :show-tooltip-when-overflow="true" label="备注">
  71. </el-table-column>
  72. <el-table-column fixed="right" prop="materialCnt" header-align="center" align="center" width="70"
  73. :show-tooltip-when-overflow="true" label="库存数">
  74. </el-table-column>
  75. <el-table-column fixed="right" prop="planCnt" header-align="center" align="center" width="100"
  76. :show-tooltip-when-overflow="true" label="计划数量">
  77. <template slot-scope="scope">
  78. <el-form-item :prop="'proProductList.' + scope.$index + '.planCnt'" :rules="dataRule.planCnt"
  79. label-width="0">
  80. <el-input v-model="scope.row.planCnt" style="width:80px" :disabled="disabled"
  81. @input="scope.row.planCnt = scope.row.planCnt.replace(/[^\d]/g, '')" />
  82. </el-form-item>
  83. </template>
  84. </el-table-column>
  85. <el-table-column fixed="right" prop="disposal" header-align="center" align="center" width="90"
  86. :show-tooltip-when-overflow="true" label="处置">
  87. <template slot-scope="scope">
  88. <div class="radio-wrapper">
  89. <el-form-item :prop="'proProductList.' + scope.$index + '.disposal'" :rules="dataRule.disposal"
  90. label-width="0">
  91. <el-radio-group v-model="scope.row.disposal" class="radio-group-wrap" :disabled="disabled">
  92. <el-radio :label="2" style="margin-left:0">采购件</el-radio>
  93. <el-radio :label="3" style="margin-left:0">委外件</el-radio>
  94. <el-radio :label="1" style="margin-left:0">自制件</el-radio>
  95. </el-radio-group>
  96. </el-form-item>
  97. </div>
  98. </template>
  99. </el-table-column>
  100. <el-table-column fixed="right" prop="isTechnology" header-align="center" align="center" width="90"
  101. :show-tooltip-when-overflow="true" label="工艺">
  102. <template slot-scope="scope">
  103. <el-form-item :prop="'proProductList.' + scope.$index + '.isTechnology'" :rules="dataRule.isTechnology"
  104. label-width="0">
  105. <el-radio-group v-model="scope.row.isTechnology" class="radio-group-wrap" :disabled="disabled">
  106. <el-radio :label="1" style="margin-left:0">需要</el-radio>
  107. <el-radio :label="2" style="margin-left:0">不需要</el-radio>
  108. </el-radio-group>
  109. </el-form-item>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. </el-form>
  114. <span slot="footer" class="dialog-footer">
  115. <el-button @click="onChose">取消</el-button>
  116. <el-button v-if="!disabled" type="primary" @click="dataFormSubmit()" v-reClick>提交</el-button>
  117. </span>
  118. <attach-detail-dialog ref="attachDetail" />
  119. </div>
  120. </template>
  121. <script>
  122. import AttachDetailDialog from '../common/attach-detail-dialog'
  123. export default {
  124. name: 'plan-submit',
  125. components: { AttachDetailDialog },
  126. computed: {},
  127. data() {
  128. return {
  129. disabled: false,
  130. id: 0,
  131. dataForm: {
  132. proProductList: []
  133. },
  134. dataRule: {
  135. planCnt: [{ required: true, message: '请输入', trigger: 'blur' }],
  136. disposal: [{ required: true, message: '请选择', trigger: 'change' }],
  137. isTechnology: [{ required: true, message: '请选择', trigger: 'change' }]
  138. },
  139. dataList: [],
  140. dataListLoading: false,
  141. expandedRowKeys: [],
  142. treeMap: new Map()
  143. }
  144. },
  145. created() { },
  146. beforeDestroy() { },
  147. methods: {
  148. onChose() {
  149. this.$emit('onChose')
  150. },
  151. async init(item, readonly) {
  152. let id = item.productionManagementId
  153. if (readonly) {
  154. this.disabled = true
  155. }
  156. this.$http({
  157. url: this.$http.adornUrl(`/biz-service/projProduction/info/${id}`),
  158. method: 'get'
  159. }).then(({ data }) => {
  160. if (data && data.code === '200') {
  161. this.dataForm = data.data
  162. data.data.proProductList.map(item => {
  163. if (item.proProductList != null && item.proProductList.length > 0) {
  164. item.proProductList.map(item2 => {
  165. this.dataForm.proProductList.push(item2)
  166. })
  167. }
  168. })
  169. console.log(this.dataForm)
  170. } else {
  171. this.$message.error(data.msg)
  172. }
  173. })
  174. },
  175. validateField(type) {
  176. this.$refs.dataForm.validateField(type)
  177. },
  178. attachDetail(attachList) {
  179. this.$nextTick(() => {
  180. this.$refs.attachDetail.init(attachList)
  181. })
  182. },
  183. // 表单提交
  184. dataFormSubmit() {
  185. this.$refs['dataForm'].validate((valid) => {
  186. if (valid) {
  187. let data = {
  188. orderCode: this.dataForm.orderCode,
  189. proProductList: this.dataForm.proProductList
  190. }
  191. let index = this.dataForm.proProductList.findIndex(item => item.isTechnology == null)
  192. if (index > -1) {
  193. this.$message.error("请勾选 工艺")
  194. return
  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. handleExpandChange(row, expanded) {
  220. console.log(row, expanded)
  221. if (expanded) {
  222. this.expandedRowKeys.push(row.productId)
  223. } else {
  224. const index = this.expandedRowKeys.indexOf(row.productId)
  225. if (index !== -1) {
  226. this.expandedRowKeys.splice(index, 1)
  227. }
  228. }
  229. },
  230. loadingData(row, treeNode, resolve) {
  231. console.log('loadingData')
  232. if (!this.treeMap.has(row.productId)) {
  233. this.treeMap.set(row.productId, { row, treeNode, resolve })
  234. }
  235. row.children = row.proProductList
  236. resolve(row.proProductList)
  237. },
  238. }
  239. }
  240. </script>
  241. <style>
  242. .my-row {
  243. margin-bottom: 20px;
  244. }
  245. .radio-group-wrap {
  246. display: flex;
  247. align-items: flex-start;
  248. flex-direction: column;
  249. gap: 10px 0px;
  250. /* 行列间距控制 */
  251. }
  252. .attch-file {
  253. cursor: pointer;
  254. color: #3e8ef7;
  255. }
  256. </style>