EquipmentDialog.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <el-dialog
  3. :visible.sync="equipmentdialog"
  4. :before-close="handleClose"
  5. :close-on-click-modal="true"
  6. :close-on-press-escape="false"
  7. append-to-body
  8. width="60%"
  9. >
  10. <div>
  11. <el-row>
  12. <el-col :span="24" class="table_col" v-if="equipmentdialog">
  13. <ele-pro-table
  14. ref="equiTable"
  15. :columns="columns"
  16. :datasource="datasource"
  17. :selection.sync="selection"
  18. :current.sync="current"
  19. highlight-current-row
  20. cache-key="systemRoleTable3"
  21. @selection-change="selectionChange"
  22. @select="select"
  23. row-key="id"
  24. height="50vh"
  25. @done="onDone"
  26. >
  27. </ele-pro-table>
  28. </el-col>
  29. </el-row>
  30. </div>
  31. <div class="btns">
  32. <el-button type="primary" size="small" @click="selected">选择</el-button>
  33. <el-button size="small" @click="handleClose">关闭</el-button>
  34. </div>
  35. </el-dialog>
  36. </template>
  37. <script>
  38. import { getList } from '@/api/inspectionProject';
  39. export default {
  40. components: {},
  41. props: {
  42. selectList: Array,
  43. type: {
  44. default: 1 //1多选 2单选
  45. }
  46. },
  47. data() {
  48. return {
  49. equipmentdialog: false,
  50. current: null,
  51. columns: [
  52. {
  53. width: 45,
  54. type: 'selection',
  55. columnKey: 'selection',
  56. align: 'center',
  57. reserveSelection: true,
  58. show:this.type==1
  59. },
  60. {
  61. prop: 'inspectionCode',
  62. label: '编码'
  63. },
  64. {
  65. label: '质检项名称',
  66. prop: 'inspectionName'
  67. },
  68. // {
  69. // label: '是否生成过程',
  70. // prop: 'isCreateCourse',
  71. // formatter: (row, column, cellValue) => {
  72. // return cellValue == 1 ? '是' : cellValue === 0 ? '否' : '';
  73. // }
  74. // },
  75. {
  76. label: '质检标准',
  77. prop: 'inspectionStandard',
  78. formatter: (row, column, cellValue) => {
  79. return row.symbol+' '+cellValue+' '+row.unit
  80. }
  81. },
  82. // {
  83. // label: '质检工具',
  84. // prop: 'inspectionTool'
  85. // },
  86. {
  87. label: '状态',
  88. prop: 'status',
  89. formatter: (row, column, cellValue) => {
  90. return cellValue == 1 ? '启用' : cellValue === 0 ? '停用' : '';
  91. }
  92. },
  93. {
  94. label: '描述',
  95. prop: 'description'
  96. },
  97. {
  98. label: '备注',
  99. prop: 'inspectionRemark'
  100. }
  101. ],
  102. categoryLevelId: null,
  103. code: null,
  104. selection: [],
  105. ids:[],
  106. oldSelection:[],//存储selection
  107. }
  108. },
  109. watch: {},
  110. methods: {
  111. datasource({ page, where, limit }) {
  112. return getList({
  113. ...where,
  114. pageNum: page,
  115. size: limit
  116. });
  117. },
  118. open(ids) {
  119. this.equipmentdialog = true;
  120. this.ids=ids
  121. },
  122. selectionChange(selection){
  123. this.oldSelection.push(...selection)
  124. },
  125. select(selection, row){
  126. if(!selection.find(item=>item.id==row.id)){
  127. this.ids= this.ids.filter(item=>item!=row.id)
  128. }else{
  129. this.ids.push(row.id)
  130. }
  131. },
  132. onDone(){
  133. this.$nextTick(() => {
  134. this.$refs.equiTable.setSelectedRowKeys(this.ids);
  135. });
  136. },
  137. handleClose() {
  138. this.equipmentdialog = false;
  139. this.$refs.equiTable.clearSelection();
  140. },
  141. // 选择
  142. selected() {
  143. if(this.type==1){
  144. let ids= [...new Set(this.ids)]
  145. this.selection=ids.map(item=>this.oldSelection.find(val=>val.id==item))
  146. }
  147. this.$emit('choose', this.type==1?JSON.parse(JSON.stringify(this.selection)):JSON.parse(JSON.stringify(this.current)));
  148. this.handleClose();
  149. }
  150. }
  151. };
  152. </script>
  153. <style lang="scss" scoped>
  154. .tree_col {
  155. border: 1px solid #eee;
  156. padding: 10px 0;
  157. box-sizing: border-box;
  158. max-height: 530px;
  159. overflow: auto;
  160. }
  161. .table_col {
  162. padding-left: 10px;
  163. ::v-deep .el-table th.el-table__cell {
  164. background: #f2f2f2;
  165. }
  166. }
  167. .pagination {
  168. text-align: right;
  169. padding: 10px 0;
  170. }
  171. .btns {
  172. text-align: center;
  173. padding: 10px 0;
  174. }
  175. .topsearch {
  176. margin-bottom: 15px;
  177. }
  178. </style>