|
|
@@ -17,7 +17,7 @@
|
|
|
tool-class="ele-toolbar-form"
|
|
|
row-key="qualityLevelId"
|
|
|
v-if="equipmentdialog"
|
|
|
- :selection.sync="selection"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
:initLoad="false"
|
|
|
@columns-change="handleColumnChange"
|
|
|
:cache-key="cacheKeyUrl"
|
|
|
@@ -36,18 +36,17 @@
|
|
|
<script>
|
|
|
import search from './search.vue';
|
|
|
import { getList } from '@/api/inspectionTemplate';
|
|
|
-
|
|
|
import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
+
|
|
|
export default {
|
|
|
components: { search },
|
|
|
mixins: [tabMixins],
|
|
|
data() {
|
|
|
return {
|
|
|
- cacheKeyUrl:
|
|
|
- 'qms-c2e9664a-inspectionTemplate-components-inspectionTemplateDialog',
|
|
|
+ cacheKeyUrl: 'qms-c2e9664a-inspectionTemplate-components-inspectionTemplateDialog',
|
|
|
type: '',
|
|
|
equipmentdialog: false,
|
|
|
- selection: [],
|
|
|
+ selection: [], // 存储单选结果(仅一条数据)
|
|
|
tableHeight: 'calc(100vh - 605px)',
|
|
|
columns: [
|
|
|
{
|
|
|
@@ -55,7 +54,7 @@ export default {
|
|
|
type: 'selection',
|
|
|
columnKey: 'selection',
|
|
|
align: 'center',
|
|
|
- reserveSelection: true
|
|
|
+ reserveSelection: false // 关闭保留选中(避免切换页签残留)
|
|
|
},
|
|
|
{
|
|
|
columnKey: 'index',
|
|
|
@@ -104,44 +103,57 @@ export default {
|
|
|
]
|
|
|
};
|
|
|
},
|
|
|
-
|
|
|
- watch: {},
|
|
|
methods: {
|
|
|
datasource({ page, where, limit }) {
|
|
|
return getList({
|
|
|
...where,
|
|
|
pageNum: page,
|
|
|
size: limit
|
|
|
- // type: this.type
|
|
|
});
|
|
|
},
|
|
|
+ // 打开弹窗:清空历史选中
|
|
|
open(type) {
|
|
|
this.type = type;
|
|
|
this.equipmentdialog = true;
|
|
|
+ this.selection = []; // 清空选中状态
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.search.setWhere(type);
|
|
|
this.$refs.search.search();
|
|
|
+ // 重置表格选中状态
|
|
|
+ if (this.$refs.table) this.$refs.table.clearSelection();
|
|
|
});
|
|
|
},
|
|
|
handleClose() {
|
|
|
this.equipmentdialog = false;
|
|
|
+ this.selection = []; // 关闭时清空选中
|
|
|
+ if (this.$refs.table) this.$refs.table.clearSelection();
|
|
|
},
|
|
|
- // 选择
|
|
|
- selected() {
|
|
|
- if (!this.selection.length) {
|
|
|
- this.$message.error('至少选择一条数据');
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
- this.$emit('choose', this.selection);
|
|
|
- this.handleClose();
|
|
|
- },
|
|
|
-
|
|
|
+ // 单选控制:仅保留最后一个选中项
|
|
|
+ handleSelectionChange(val) {
|
|
|
+ if (val.length > 1) {
|
|
|
+ const lastVal = val[val.length - 1];
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
+ this.$refs.table.toggleRowSelection(lastVal, true);
|
|
|
+ this.selection = [lastVal];
|
|
|
+ } else {
|
|
|
+ this.selection = val;
|
|
|
+ }
|
|
|
+},
|
|
|
+// 子组件:选择按钮(校验并传值)
|
|
|
+selected() {
|
|
|
+ if (this.selection.length !== 1) {
|
|
|
+ this.$message.error('请选择一条数据');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$emit('choose', this.selection); // 传递单选结果(数组形式)
|
|
|
+ this.handleClose();
|
|
|
+},
|
|
|
search(where) {
|
|
|
this.$refs.table.reload({ page: 1, where });
|
|
|
+ this.selection = []; // 搜索时清空选中
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped></style>
|
|
|
+<style lang="scss" scoped></style>
|