replaceMaterialPop.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <el-dialog
  3. title="替代料"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="90%"
  11. >
  12. <ele-pro-table
  13. ref="replaceMaterialPop"
  14. :columns="columns"
  15. :datasource="replaceMaterial"
  16. :need-page="false"
  17. :immediate="true"
  18. >
  19. <!-- 表头工具栏 -->
  20. <template v-slot:toolbar>
  21. <el-button type="primary" v-if="!isView" @click="handAdd"
  22. >添加</el-button
  23. >
  24. </template>
  25. <template v-slot:unit="{ row }">
  26. <div v-if="isView">{{ row.unit }}</div>
  27. <div v-else>
  28. <DictSelection dictName="计量单位" v-model="row.unit"></DictSelection>
  29. </div>
  30. </template>
  31. <template v-slot:count="{ row }">
  32. <div v-if="isView">{{ row.count }}</div>
  33. <el-input
  34. v-else
  35. v-model="row.count"
  36. placeholder="请输入"
  37. @input="
  38. (value) =>
  39. (row.count = value.replace(
  40. /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
  41. '$1$2.$3'
  42. ))
  43. "
  44. ></el-input>
  45. </template>
  46. <template v-slot:bomArtFiles="{ row }">
  47. <fileUpload v-model="row.bomArtFiles" type="add" size="mini" />
  48. </template>
  49. <template v-slot:remark="{ row }">
  50. <div v-if="isView">{{ row.remark }}</div>
  51. <el-input v-else v-model="row.remark" placeholder="请输入"></el-input>
  52. </template>
  53. <template v-slot:action="{ row, $index }">
  54. <el-link type="danger" @click="handleDel(row, $index)">删除</el-link>
  55. </template>
  56. </ele-pro-table>
  57. <div class="btns">
  58. <el-button type="primary" size="small" @click="selected">选择</el-button>
  59. <el-button size="small" @click="handleClose">关闭</el-button>
  60. </div>
  61. <ProductModalMultiple
  62. ref="productMultipleRefs"
  63. @selection="selectionList"
  64. ></ProductModalMultiple>
  65. </el-dialog>
  66. </template>
  67. <script>
  68. import fileUpload from '@/components/addDoc/index.vue';
  69. import ProductModalMultiple from './ProductModalMultiple.vue';
  70. export default {
  71. components: {
  72. fileUpload,
  73. ProductModalMultiple
  74. },
  75. props: {
  76. isView: {
  77. type: Boolean,
  78. default: false
  79. }
  80. },
  81. data() {
  82. return {
  83. visible: false,
  84. rootCategoryLevelId: null,
  85. replaceMaterial: [],
  86. columns: [
  87. {
  88. type: 'index',
  89. width: 55,
  90. align: 'center'
  91. },
  92. {
  93. label: '物料名称',
  94. prop: 'categoryName'
  95. },
  96. {
  97. label: '编码',
  98. prop: 'categoryCode'
  99. },
  100. {
  101. label: '牌号',
  102. prop: 'brandNum'
  103. },
  104. {
  105. label: '型号',
  106. prop: 'modelType'
  107. },
  108. {
  109. prop: 'specification',
  110. label: '规格',
  111. align: 'center',
  112. showOverflowTooltip: true
  113. },
  114. {
  115. label: '数量',
  116. slot: 'count',
  117. action: 'count'
  118. },
  119. {
  120. label: '单位',
  121. slot: 'unit',
  122. action: 'unit'
  123. },
  124. {
  125. label: '附件',
  126. slot: 'bomArtFiles',
  127. action: 'bomArtFiles',
  128. minWidth: 150
  129. },
  130. {
  131. label: '备注',
  132. slot: 'remark',
  133. action: 'remark'
  134. },
  135. {
  136. columnKey: 'action',
  137. label: '操作',
  138. align: 'center',
  139. resizable: false,
  140. slot: 'action',
  141. showOverflowTooltip: true
  142. }
  143. ]
  144. };
  145. },
  146. methods: {
  147. open(row) {
  148. this.replaceId = row.id;
  149. this.rootCategoryLevelId = row.rootCategoryLevelId;
  150. if (Object.prototype.hasOwnProperty.call(row, 'replaceMaterial')) {
  151. this.replaceMaterial = row.replaceMaterial;
  152. } else {
  153. this.replaceMaterial = [];
  154. }
  155. this.visible = true;
  156. },
  157. handAdd() {
  158. this.$refs.productMultipleRefs.open(null, [this.rootCategoryLevelId], this.replaceMaterial);
  159. },
  160. selectionList(list) {
  161. let array = [];
  162. list.map((item, index) => {
  163. array.push({
  164. id: item.id,
  165. categoryName: item.name,
  166. categoryCode: item.categoryCode,
  167. isReworkBom: 0,
  168. brandNum: item.brandNum,
  169. count: item.count || '',
  170. modelType: item.modelType,
  171. unit: item.measuringUnit,
  172. bomArtFiles: [],
  173. remark: '',
  174. specification: item.specification,
  175. rootCategoryLevelId: item.categoryLevelPathIdParent,
  176. extInfo: item.extInfo
  177. });
  178. });
  179. this.replaceMaterial = [...this.replaceMaterial, ...array] ;
  180. },
  181. handleDel(row, index) {
  182. this.replaceMaterial.splice(index, 1);
  183. },
  184. selected() {
  185. this.$emit('selected', this.replaceId, this.replaceMaterial);
  186. this.visible = false;
  187. },
  188. handleClose() {
  189. this.visible = false;
  190. }
  191. }
  192. };
  193. </script>
  194. <style lang="scss" scoped>
  195. .btns {
  196. text-align: center;
  197. padding: 10px 0;
  198. }
  199. </style>