|
@@ -14,8 +14,9 @@
|
|
|
rowKey="id"
|
|
|
:columns="columns"
|
|
|
:dataSource="dataSource"
|
|
|
- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
|
|
- :pagination="false"
|
|
|
+ :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, onSelect: onSelect}"
|
|
|
+ :pagination="ipagination"
|
|
|
+ @change="handleTableChange"
|
|
|
class="j-table-force-nowrap">
|
|
|
</a-table>
|
|
|
</j-modal>
|
|
@@ -23,9 +24,12 @@
|
|
|
|
|
|
<script>
|
|
|
import { httpAction, getAction } from '@/api/manage'
|
|
|
+ import { mixinDevice } from '@/utils/mixin'
|
|
|
+ import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
|
|
|
|
|
export default {
|
|
|
name: 'SpotcheckContentModalAdd',
|
|
|
+ mixins:[JeecgListMixin, mixinDevice],
|
|
|
components: {
|
|
|
|
|
|
},
|
|
@@ -89,55 +93,119 @@
|
|
|
},
|
|
|
],
|
|
|
dataSource: [],
|
|
|
+ chooseData: [],
|
|
|
url: {
|
|
|
- getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
|
|
|
- contentList: "/cmmsInspectContent/cmmsInspectContent/listDetails",
|
|
|
+ list: "/cmmsInspectContent/cmmsInspectContent/listDetails",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ selectData: {
|
|
|
+ handler(newV, oldV){
|
|
|
+ console.log(newV, oldV)
|
|
|
+ if(newV.length > 0){
|
|
|
+ this.selectList()
|
|
|
+ }
|
|
|
},
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- add () {
|
|
|
+ add(){
|
|
|
this.visible = true;
|
|
|
- getAction(this.url.contentList, {status: '0'}).then((res) => {
|
|
|
- this.dataSource = res.result.records
|
|
|
+ this.loadData()
|
|
|
+ },
|
|
|
+ loadData () {
|
|
|
+ // {status: '0'}
|
|
|
+ var params = this.getQueryParams();//查询条件
|
|
|
+ params.status = '0'
|
|
|
+ this.loading = true;
|
|
|
+ getAction(this.url.list, params).then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ this.dataSource = res.result.records||res.result;
|
|
|
+ if(res.result.total)
|
|
|
+ {
|
|
|
+ this.ipagination.total = res.result.total;
|
|
|
+ }else{
|
|
|
+ this.ipagination.total = 0;
|
|
|
+ }
|
|
|
+ // this.selectList()
|
|
|
+ }else{
|
|
|
+ this.$message.warning(res.message)
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false
|
|
|
})
|
|
|
- this.selectList()
|
|
|
},
|
|
|
// 将以选中的值重新在列表中选中
|
|
|
selectList() {
|
|
|
- this.selectionRows = this.selectData
|
|
|
- console.log(this.selectData)
|
|
|
+ this.chooseData = [...this.selectData]
|
|
|
+ // console.log(this.selectData)
|
|
|
this.selectedRowKeys = this.selectData.map((res) => {
|
|
|
return res.id
|
|
|
})
|
|
|
},
|
|
|
close () {
|
|
|
- this.$emit('close');
|
|
|
this.visible = false;
|
|
|
- this.onClearSelected()
|
|
|
- this.selectionRows = this.selectData
|
|
|
- this.selectedRowKeys = this.selectData.map((res) => {
|
|
|
- return res.id
|
|
|
- })
|
|
|
- this.dataSource = []
|
|
|
},
|
|
|
handleOk () {
|
|
|
- console.log(this.selectionRows)
|
|
|
- this.$emit('ok', this.selectionRows);
|
|
|
+ this.$emit('ok', this.chooseData);
|
|
|
+ console.log(this.chooseData)
|
|
|
this.visible = false;
|
|
|
},
|
|
|
handleCancel () {
|
|
|
this.close()
|
|
|
},
|
|
|
- onSelectChange(selectedRowKeys, selectionRows) {
|
|
|
- this.selectedRowKeys = selectedRowKeys;
|
|
|
- this.selectionRows = selectionRows;
|
|
|
- console.log(this.selectedRowKeys,this.selectionRows)
|
|
|
- },
|
|
|
- onClearSelected() {
|
|
|
- this.selectedRowKeys = [];
|
|
|
- this.selectionRows = [];
|
|
|
+ onSelect(selectedRow, selected){
|
|
|
+ // console.log(selectedRow, selected)
|
|
|
+ if(selected){
|
|
|
+ // 新增
|
|
|
+ this.chooseData.push(selectedRow)
|
|
|
+ } else {
|
|
|
+ // 删除(过滤)
|
|
|
+ var index = this.chooseData.findIndex(item => item.id === selectedRow.id)
|
|
|
+ this.chooseData.splice(index, 1)
|
|
|
+ }
|
|
|
},
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 将以选中的值重新在列表中选中
|
|
|
+ // selectList() {
|
|
|
+ // this.selectionRows = this.selectData
|
|
|
+ // console.log(this.selectData)
|
|
|
+ // this.selectedRowKeys = this.selectData.map((res) => {
|
|
|
+ // return res.id
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // close () {
|
|
|
+ // this.$emit('close');
|
|
|
+ // this.visible = false;
|
|
|
+ // this.onClearSelected()
|
|
|
+ // this.selectionRows = this.selectData
|
|
|
+ // this.selectedRowKeys = this.selectData.map((res) => {
|
|
|
+ // return res.id
|
|
|
+ // })
|
|
|
+ // this.dataSource = []
|
|
|
+ // },
|
|
|
+ // handleOk () {
|
|
|
+ // console.log(this.selectionRows)
|
|
|
+ // this.$emit('ok', this.selectionRows);
|
|
|
+ // this.visible = false;
|
|
|
+ // },
|
|
|
+ // handleCancel () {
|
|
|
+ // this.close()
|
|
|
+ // },
|
|
|
+ // onSelectChange(selectedRowKeys, selectionRows) {
|
|
|
+ // this.selectedRowKeys = selectedRowKeys;
|
|
|
+ // this.selectionRows = selectionRows;
|
|
|
+ // console.log(this.selectedRowKeys,this.selectionRows)
|
|
|
+ // },
|
|
|
+ // onClearSelected() {
|
|
|
+ // this.selectedRowKeys = [];
|
|
|
+ // this.selectionRows = [];
|
|
|
+ // },
|
|
|
}
|
|
|
}
|
|
|
</script>
|