CmmsSpotcheckContentModalAdd.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <j-modal
  3. :title="title"
  4. :width="width"
  5. :visible="visible"
  6. @ok="handleOk"
  7. @cancel="handleCancel"
  8. cancelText="关闭">
  9. <a-table
  10. ref="table"
  11. size="middle"
  12. :scroll="{x:true}"
  13. bordered
  14. rowKey="id"
  15. :columns="columns"
  16. :dataSource="dataSource"
  17. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  18. :pagination="false"
  19. class="j-table-force-nowrap">
  20. </a-table>
  21. </j-modal>
  22. </template>
  23. <script>
  24. import { httpAction, getAction } from '@/api/manage'
  25. export default {
  26. name: 'CmmsSpotcheckContentModalAdd',
  27. components: {
  28. },
  29. props: {
  30. //表单禁用
  31. modelForm: {
  32. type: Object,
  33. default: function(){
  34. return {} // 使用工厂函数返回默认值
  35. }
  36. },
  37. dataList: {
  38. type: Array,
  39. default: function(){
  40. return [] // 使用工厂函数返回默认值
  41. }
  42. },
  43. },
  44. data () {
  45. return {
  46. title:'',
  47. width:1000,
  48. visible: false,
  49. /* table选中keys*/
  50. selectedRowKeys: [],
  51. /* table选中records*/
  52. selectionRows: [],
  53. columns: [
  54. // {
  55. // title: '#',
  56. // dataIndex: '',
  57. // key:'rowIndex',
  58. // width:60,
  59. // align:"center",
  60. // customRender:function (t,r,index) {
  61. // return parseInt(index)+1;
  62. // }
  63. // },
  64. {
  65. title:'点检项ID',
  66. align:"center",
  67. dataIndex: 'id'
  68. },
  69. {
  70. title:'点检项编号',
  71. align:"center",
  72. dataIndex: 'itemcode'
  73. },
  74. {
  75. title:'点检项名称',
  76. align:"center",
  77. dataIndex: 'itemname'
  78. },
  79. {
  80. title:'标准',
  81. align:"center",
  82. dataIndex: 'conditions',
  83. },
  84. {
  85. title:'备注',
  86. align:"center",
  87. dataIndex: 'remark'
  88. }
  89. ],
  90. dataSource: [],
  91. url: {
  92. getList: "/cmmsSpotcheckItem/cmmsSpotcheckItem/listbyequipmentid/{equipmentid}"
  93. },
  94. }
  95. },
  96. methods: {
  97. add () {
  98. this.visible = true;
  99. getAction(`/cmmsSpotcheckItem/cmmsSpotcheckItem/listbyequipmentid/${this.modelForm.equipmentid}`).then((res) => {
  100. this.dataSource = res.result
  101. })
  102. },
  103. // 将以选中的值重新在列表中选中
  104. selectList() {
  105. this.selectionRows = this.dataList
  106. this.selectedRowKeys = this.dataList.map((res) => {
  107. return res.id
  108. })
  109. },
  110. close () {
  111. this.$emit('close');
  112. this.visible = false;
  113. this.onClearSelected()
  114. this.selectionRows = this.dataList
  115. this.selectedRowKeys = this.dataList.map((res) => {
  116. return res.id
  117. })
  118. },
  119. handleOk () {
  120. console.log(this.selectionRows)
  121. this.$emit('customEvent', this.selectionRows);
  122. this.visible = false;
  123. },
  124. submitCallback(){
  125. this.$emit('ok');
  126. this.visible = false;
  127. },
  128. handleCancel () {
  129. this.close()
  130. },
  131. onSelectChange(selectedRowKeys, selectionRows) {
  132. this.selectedRowKeys = selectedRowKeys;
  133. this.selectionRows = selectionRows;
  134. console.log(this.selectedRowKeys,this.selectionRows)
  135. },
  136. onClearSelected() {
  137. this.selectedRowKeys = [];
  138. this.selectionRows = [];
  139. },
  140. }
  141. }
  142. </script>