Certificate.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="addOpen"
  6. title="合格证"
  7. :close-on-click-modal="false"
  8. width="85%"
  9. :maxable="true"
  10. append-to-body
  11. @close="handleClose"
  12. >
  13. <el-form ref="certificateForm" :model="form" class="certificate_form">
  14. <ele-pro-table
  15. :columns="columns"
  16. :datasource="form.tableList"
  17. ref="table"
  18. :need-page="false"
  19. class="el-form-box"
  20. :toolkit="[]"
  21. >
  22. <template v-slot:toolbar>
  23. <el-button :loading="loading" type="primary" @click="addBank"
  24. >添加</el-button
  25. >
  26. </template>
  27. <template v-slot:headerNumber="{ column }">
  28. <span class="is-required">{{ column.label }}</span>
  29. </template>
  30. <template v-slot:certificateNumber="{ row, $index }">
  31. <el-form-item
  32. :prop="`tableList.${$index}.certificateNumber`"
  33. :rules="{
  34. required: true,
  35. message: '请输入合格证号',
  36. trigger: 'change'
  37. }"
  38. >
  39. <el-input
  40. v-model="row.certificateNumber"
  41. placeholder="请输入"
  42. ></el-input>
  43. </el-form-item>
  44. </template>
  45. <template v-slot:remark="{ row }">
  46. <el-form-item>
  47. <el-input v-model="row.remark" placeholder="请输入"></el-input>
  48. </el-form-item>
  49. </template>
  50. <template v-slot:certificateAttachments="{ row }">
  51. <fileMain v-model="row.certificateAttachments"></fileMain>
  52. </template>
  53. <template v-slot:action="{ $index }">
  54. <el-popconfirm
  55. class="ele-action"
  56. title="确定要删除当前数据吗?"
  57. @confirm="delSon($index)"
  58. >
  59. <template v-slot:reference>
  60. <el-link type="danger" :underline="false" icon="el-icon-delete"
  61. >删除</el-link
  62. >
  63. </template>
  64. </el-popconfirm>
  65. </template>
  66. </ele-pro-table>
  67. </el-form>
  68. <div slot="footer" class="footer">
  69. <el-button type="primary" @click="submitAdd">保存</el-button>
  70. <el-button @click="handleClose">返回</el-button>
  71. </div>
  72. </ele-modal>
  73. </template>
  74. <script>
  75. import {
  76. updateCertificateNumber,
  77. qualityWorkOrderCertificate
  78. } from '@/api/inspectionWork';
  79. import fileMain from '@/components/addDoc/index.vue';
  80. export default {
  81. data() {
  82. return {
  83. form: {
  84. tableList: []
  85. },
  86. loading: false
  87. };
  88. },
  89. components: { fileMain },
  90. props: {
  91. addOpen: {
  92. type: Boolean,
  93. default: false
  94. },
  95. rowData: {
  96. type: Object,
  97. default: () => {}
  98. }
  99. },
  100. computed: {
  101. columns() {
  102. return [
  103. {
  104. type: 'index',
  105. label: '序号',
  106. align: 'center',
  107. width: 60
  108. },
  109. {
  110. label: '合格证号',
  111. prop: 'certificateNumber',
  112. slot: 'certificateNumber',
  113. headerSlot: 'headerNumber',
  114. align: 'center',
  115. width: 250
  116. },
  117. {
  118. prop: 'remark',
  119. slot: 'remark',
  120. label: '备注',
  121. align: 'center'
  122. },
  123. {
  124. prop: 'certificateAttachments',
  125. slot: 'certificateAttachments',
  126. label: '合格证附件',
  127. align: 'center',
  128. width: 120
  129. },
  130. {
  131. columnKey: 'action',
  132. label: '操作',
  133. width: 150,
  134. align: 'center',
  135. resizable: false,
  136. slot: 'action'
  137. }
  138. ];
  139. }
  140. },
  141. mounted() {
  142. this.getList();
  143. },
  144. methods: {
  145. handleClose() {
  146. this.$emit('closeModel');
  147. },
  148. getList() {
  149. let params = {
  150. pageNum: 1,
  151. qualityWorkOrderId: this.rowData.id,
  152. size: 1000
  153. };
  154. this.loading = true;
  155. qualityWorkOrderCertificate(params)
  156. .then((res) => {
  157. this.loading = false;
  158. if (res.list.length > 0) {
  159. this.form.tableList = res.list;
  160. }
  161. })
  162. .catch((err) => {
  163. this.loading = true;
  164. });
  165. },
  166. addBank() {
  167. this.form.tableList.push({
  168. certificateNumber: '',
  169. remark: ''
  170. });
  171. },
  172. delSon(index) {
  173. this.form.tableList.splice(index, 1);
  174. },
  175. submitAdd() {
  176. if (this.form.tableList.length == 0) {
  177. return this.$message.warning('至少需要保留一条数据');
  178. }
  179. this.$refs.certificateForm.validate((valid) => {
  180. if (valid) {
  181. let certificates = this.form.tableList.map((el) => {
  182. return {
  183. ...el,
  184. qualityWorkOrderCode: this.rowData.code,
  185. qualityWorkOrderId: this.rowData.id,
  186. qualityWorkOrderName: this.rowData.name
  187. };
  188. });
  189. let data = {
  190. certificates,
  191. id: this.rowData.id
  192. };
  193. updateCertificateNumber(data).then((res) => {
  194. if (res) {
  195. this.$message.success('操作成功');
  196. this.handleClose();
  197. this.$emit('search');
  198. }
  199. });
  200. }
  201. });
  202. }
  203. }
  204. };
  205. </script>
  206. <style lang="scss" scoped>
  207. .certificate_form {
  208. min-height: 500px;
  209. :deep(.el-form-item) {
  210. margin: 16px 0;
  211. }
  212. }</style
  213. >>