|
|
@@ -20,15 +20,15 @@
|
|
|
</div>
|
|
|
<div style="overflow-y: auto;">
|
|
|
<div class="selectedList">
|
|
|
- <div class="m-[10px] mr-0" style="display: flex; align-items: center; justify-content: space-between;"
|
|
|
- v-for="(item, index) in selectedList" :key="item.id">
|
|
|
- <span>{{ item.productName }}</span>
|
|
|
- <el-icon style="cursor: pointer;" @click="handleDel(item, index)">
|
|
|
- <Close />
|
|
|
- </el-icon>
|
|
|
+ <div class="m-[10px] mr-0" style="display: flex; align-items: center; justify-content: space-between;"
|
|
|
+ v-for="(item, index) in selectedList" :key="item.id">
|
|
|
+ <span>{{ item.productName }}</span>
|
|
|
+ <el-icon style="cursor: pointer;" v-if="item.selectedStatus!=='3'" @click="handleDel(item, index)">
|
|
|
+ <Close />
|
|
|
+ </el-icon>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -46,6 +46,7 @@ import api from "@/api";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import type { ElTree } from 'element-plus'
|
|
|
|
|
|
+const props = defineProps(['multiple']);
|
|
|
const treeRef = ref<InstanceType<typeof ElTree>>()
|
|
|
|
|
|
const emits = defineEmits(['close'])
|
|
|
@@ -71,6 +72,7 @@ let JYXList = ref([])
|
|
|
const defaultProps = {
|
|
|
children: 'children',
|
|
|
label: 'productName',
|
|
|
+ disabled: (data)=> data.selectedStatus === '3',
|
|
|
}
|
|
|
const handleCheckChange = (data, row) => {
|
|
|
if (row.checkedNodes.length > 0) {
|
|
|
@@ -120,8 +122,8 @@ const handleType = (item, index) => {
|
|
|
}
|
|
|
// 清空
|
|
|
const clear = () => {
|
|
|
- selectedList.value = []
|
|
|
- treeRef.value!.setCheckedKeys([], true)
|
|
|
+ selectedList.value = selectedList.value.filter(a => a.selectedStatus === '3')
|
|
|
+ treeRef.value!.setCheckedKeys(selectedList.value.map(a => a.drivingIntentionId), true)
|
|
|
}
|
|
|
// 删除
|
|
|
const handleDel = (item, index) => {
|
|
|
@@ -137,36 +139,31 @@ const handleDel = (item, index) => {
|
|
|
|
|
|
// 编辑
|
|
|
let editIndex = ref(0)
|
|
|
-const initEditData = (data, index, id) => {
|
|
|
- console.log('驾意险回显', data)
|
|
|
+const initEditData = (data, index, id, arr = []) => {
|
|
|
+
|
|
|
editIndex.value = index
|
|
|
- // JYXList.value.forEach(item => {
|
|
|
- // item.checked = false
|
|
|
- // })
|
|
|
- // let list = [...JYXList.value]
|
|
|
+ const setList = (list) => {
|
|
|
+ if (list && list.length > 0) {
|
|
|
+ list.forEach(item => {
|
|
|
+ item.checked = false
|
|
|
+ item.drivingIntentionId = item.id
|
|
|
+ })
|
|
|
+ }
|
|
|
+ JYXList.value = list
|
|
|
+ if (list && Array.isArray(list)) {
|
|
|
+ selectedList.value = JSON.parse(JSON.stringify(list))
|
|
|
+ selectedKeys.value = selectedList.value.map(a => a.drivingIntentionId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(arr.length){
|
|
|
+ setList(arr)
|
|
|
+ return
|
|
|
+ }
|
|
|
api.projectApi.jyxList({
|
|
|
- company: id ? id : '1738811735599380291'
|
|
|
+ company: id
|
|
|
}).then(res => {
|
|
|
if (res.code == 200) {
|
|
|
- if (res.data && res.data.length > 0) {
|
|
|
- res.data.forEach(item => {
|
|
|
- item.checked = false
|
|
|
- item.drivingIntentionId = item.id
|
|
|
- })
|
|
|
- }
|
|
|
- JYXList.value = res.data
|
|
|
- if (data && Array.isArray(data)) {
|
|
|
- // data.forEach(item => {
|
|
|
- // item.checked = true
|
|
|
- // })
|
|
|
- // JYXList.value = res.data.map(a => {
|
|
|
- // let obj = data.find(b => b.drivingIntentionId === a.drivingIntentionId)
|
|
|
- // return obj || a
|
|
|
- // })
|
|
|
- // selectedList.value = JYXList.value.filter(a => a.checked)
|
|
|
- selectedList.value = JSON.parse(JSON.stringify(data))
|
|
|
- selectedKeys.value = selectedList.value.map(a => a.drivingIntentionId)
|
|
|
- }
|
|
|
+ setList(res.data)
|
|
|
} else {
|
|
|
ElMessage({
|
|
|
message: res.msg,
|
|
|
@@ -185,8 +182,8 @@ const handleCancel = () => {
|
|
|
}
|
|
|
// 保存
|
|
|
const handleConfirm = () => {
|
|
|
- if(selectedList.value.length > 1){
|
|
|
- ElMessage({
|
|
|
+ if (selectedList.value.length > 1 && !props.multiple) {
|
|
|
+ ElMessage({
|
|
|
message: '只能选择一种驾意险',
|
|
|
type: 'warning'
|
|
|
})
|
|
|
@@ -203,16 +200,17 @@ onMounted(() => {
|
|
|
})
|
|
|
|
|
|
defineExpose({
|
|
|
- initEditData
|
|
|
+ initEditData,
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
-.selectedList{
|
|
|
+.selectedList {
|
|
|
height: 300px;
|
|
|
width: 100%;
|
|
|
}
|
|
|
+
|
|
|
.insuranceLeft {
|
|
|
overflow-y: auto;
|
|
|
}
|
|
|
@@ -262,11 +260,12 @@ defineExpose({
|
|
|
min-height: 26px;
|
|
|
align-items: flex-start;
|
|
|
}
|
|
|
+
|
|
|
:deep(.el-tree-node__label) {
|
|
|
- white-space: normal;
|
|
|
- word-break: break-all;
|
|
|
- padding-top: 4px;
|
|
|
- padding-bottom: 4px;
|
|
|
-}
|
|
|
+ white-space: normal;
|
|
|
+ word-break: break-all;
|
|
|
+ padding-top: 4px;
|
|
|
+ padding-bottom: 4px;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|